Finish Linux x86_64 build

This commit is contained in:
2025-02-10 00:00:38 +08:00
parent bc3c5a8f9d
commit 6c60067ba7
301 changed files with 30720 additions and 1048 deletions

View File

@@ -54,24 +54,24 @@ public:
private:
bool* At(VAddr addr) {
if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) {
return &vram[(addr - VRAM_VADDR) / CITRA_PAGE_SIZE];
return &vram[(addr - VRAM_VADDR) / LUCINA3DS_PAGE_SIZE];
}
if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) {
return &linear_heap[(addr - LINEAR_HEAP_VADDR) / CITRA_PAGE_SIZE];
return &linear_heap[(addr - LINEAR_HEAP_VADDR) / LUCINA3DS_PAGE_SIZE];
}
if (addr >= NEW_LINEAR_HEAP_VADDR && addr < NEW_LINEAR_HEAP_VADDR_END) {
return &new_linear_heap[(addr - NEW_LINEAR_HEAP_VADDR) / CITRA_PAGE_SIZE];
return &new_linear_heap[(addr - NEW_LINEAR_HEAP_VADDR) / LUCINA3DS_PAGE_SIZE];
}
if (addr >= PLUGIN_3GX_FB_VADDR && addr < PLUGIN_3GX_FB_VADDR_END) {
return &plugin_fb[(addr - PLUGIN_3GX_FB_VADDR) / CITRA_PAGE_SIZE];
return &plugin_fb[(addr - PLUGIN_3GX_FB_VADDR) / LUCINA3DS_PAGE_SIZE];
}
return nullptr;
}
std::array<bool, VRAM_SIZE / CITRA_PAGE_SIZE> vram{};
std::array<bool, LINEAR_HEAP_SIZE / CITRA_PAGE_SIZE> linear_heap{};
std::array<bool, NEW_LINEAR_HEAP_SIZE / CITRA_PAGE_SIZE> new_linear_heap{};
std::array<bool, PLUGIN_3GX_FB_SIZE / CITRA_PAGE_SIZE> plugin_fb{};
std::array<bool, VRAM_SIZE / LUCINA3DS_PAGE_SIZE> vram{};
std::array<bool, LINEAR_HEAP_SIZE / LUCINA3DS_PAGE_SIZE> linear_heap{};
std::array<bool, NEW_LINEAR_HEAP_SIZE / LUCINA3DS_PAGE_SIZE> new_linear_heap{};
std::array<bool, PLUGIN_3GX_FB_SIZE / LUCINA3DS_PAGE_SIZE> plugin_fb{};
static_assert(sizeof(bool) == 1);
friend class boost::serialization::access;
@@ -161,13 +161,13 @@ public:
auto& page_table = *process.vm_manager.page_table;
std::size_t remaining_size = size;
std::size_t page_index = src_addr >> CITRA_PAGE_BITS;
std::size_t page_offset = src_addr & CITRA_PAGE_MASK;
std::size_t page_index = src_addr >> LUCINA3DS_PAGE_BITS;
std::size_t page_offset = src_addr & LUCINA3DS_PAGE_MASK;
while (remaining_size > 0) {
const std::size_t copy_amount = std::min(CITRA_PAGE_SIZE - page_offset, remaining_size);
const std::size_t copy_amount = std::min(LUCINA3DS_PAGE_SIZE - page_offset, remaining_size);
const VAddr current_vaddr =
static_cast<VAddr>((page_index << CITRA_PAGE_BITS) + page_offset);
static_cast<VAddr>((page_index << LUCINA3DS_PAGE_BITS) + page_offset);
switch (page_table.attributes[page_index]) {
case PageType::Unmapped: {
@@ -210,13 +210,13 @@ public:
const void* src_buffer, const std::size_t size) {
auto& page_table = *process.vm_manager.page_table;
std::size_t remaining_size = size;
std::size_t page_index = dest_addr >> CITRA_PAGE_BITS;
std::size_t page_offset = dest_addr & CITRA_PAGE_MASK;
std::size_t page_index = dest_addr >> LUCINA3DS_PAGE_BITS;
std::size_t page_offset = dest_addr & LUCINA3DS_PAGE_MASK;
while (remaining_size > 0) {
const std::size_t copy_amount = std::min(CITRA_PAGE_SIZE - page_offset, remaining_size);
const std::size_t copy_amount = std::min(LUCINA3DS_PAGE_SIZE - page_offset, remaining_size);
const VAddr current_vaddr =
static_cast<VAddr>((page_index << CITRA_PAGE_BITS) + page_offset);
static_cast<VAddr>((page_index << LUCINA3DS_PAGE_BITS) + page_offset);
switch (page_table.attributes[page_index]) {
case PageType::Unmapped: {
@@ -393,10 +393,10 @@ void MemorySystem::RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode
void MemorySystem::MapPages(PageTable& page_table, u32 base, u32 size, MemoryRef memory,
PageType type) {
LOG_DEBUG(HW_Memory, "Mapping {} onto {:08X}-{:08X}", (void*)memory.GetPtr(),
base * CITRA_PAGE_SIZE, (base + size) * CITRA_PAGE_SIZE);
base * LUCINA3DS_PAGE_SIZE, (base + size) * LUCINA3DS_PAGE_SIZE);
if (impl->system.IsPoweredOn()) {
RasterizerFlushVirtualRegion(base << CITRA_PAGE_BITS, size * CITRA_PAGE_SIZE,
RasterizerFlushVirtualRegion(base << LUCINA3DS_PAGE_BITS, size * LUCINA3DS_PAGE_SIZE,
FlushMode::FlushAndInvalidate);
}
@@ -408,27 +408,27 @@ void MemorySystem::MapPages(PageTable& page_table, u32 base, u32 size, MemoryRef
page_table.pointers[base] = memory;
// If the memory to map is already rasterizer-cached, mark the page
if (type == PageType::Memory && impl->cache_marker.IsCached(base * CITRA_PAGE_SIZE)) {
if (type == PageType::Memory && impl->cache_marker.IsCached(base * LUCINA3DS_PAGE_SIZE)) {
page_table.attributes[base] = PageType::RasterizerCachedMemory;
page_table.pointers[base] = nullptr;
}
base += 1;
if (memory != nullptr && memory.GetSize() > CITRA_PAGE_SIZE)
memory += CITRA_PAGE_SIZE;
if (memory != nullptr && memory.GetSize() > LUCINA3DS_PAGE_SIZE)
memory += LUCINA3DS_PAGE_SIZE;
}
}
void MemorySystem::MapMemoryRegion(PageTable& page_table, VAddr base, u32 size, MemoryRef target) {
ASSERT_MSG((size & CITRA_PAGE_MASK) == 0, "non-page aligned size: {:08X}", size);
ASSERT_MSG((base & CITRA_PAGE_MASK) == 0, "non-page aligned base: {:08X}", base);
MapPages(page_table, base / CITRA_PAGE_SIZE, size / CITRA_PAGE_SIZE, target, PageType::Memory);
ASSERT_MSG((size & LUCINA3DS_PAGE_MASK) == 0, "non-page aligned size: {:08X}", size);
ASSERT_MSG((base & LUCINA3DS_PAGE_MASK) == 0, "non-page aligned base: {:08X}", base);
MapPages(page_table, base / LUCINA3DS_PAGE_SIZE, size / LUCINA3DS_PAGE_SIZE, target, PageType::Memory);
}
void MemorySystem::UnmapRegion(PageTable& page_table, VAddr base, u32 size) {
ASSERT_MSG((size & CITRA_PAGE_MASK) == 0, "non-page aligned size: {:08X}", size);
ASSERT_MSG((base & CITRA_PAGE_MASK) == 0, "non-page aligned base: {:08X}", base);
MapPages(page_table, base / CITRA_PAGE_SIZE, size / CITRA_PAGE_SIZE, nullptr,
ASSERT_MSG((size & LUCINA3DS_PAGE_MASK) == 0, "non-page aligned size: {:08X}", size);
ASSERT_MSG((base & LUCINA3DS_PAGE_MASK) == 0, "non-page aligned base: {:08X}", base);
MapPages(page_table, base / LUCINA3DS_PAGE_SIZE, size / LUCINA3DS_PAGE_SIZE, nullptr,
PageType::Unmapped);
}
@@ -449,11 +449,11 @@ void MemorySystem::UnregisterPageTable(std::shared_ptr<PageTable> page_table) {
template <typename T>
T MemorySystem::Read(const VAddr vaddr) {
const u8* page_pointer = impl->current_page_table->pointers[vaddr >> CITRA_PAGE_BITS];
const u8* page_pointer = impl->current_page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS];
if (page_pointer) {
// NOTE: Avoid adding any extra logic to this fast-path block
T value;
std::memcpy(&value, &page_pointer[vaddr & CITRA_PAGE_MASK], sizeof(T));
std::memcpy(&value, &page_pointer[vaddr & LUCINA3DS_PAGE_MASK], sizeof(T));
return value;
}
@@ -472,7 +472,7 @@ T MemorySystem::Read(const VAddr vaddr) {
}
}
PageType type = impl->current_page_table->attributes[vaddr >> CITRA_PAGE_BITS];
PageType type = impl->current_page_table->attributes[vaddr >> LUCINA3DS_PAGE_BITS];
switch (type) {
case PageType::Unmapped:
LOG_ERROR(HW_Memory, "unmapped Read{} @ 0x{:08X} at PC 0x{:08X}", sizeof(T) * 8, vaddr,
@@ -497,10 +497,10 @@ T MemorySystem::Read(const VAddr vaddr) {
template <typename T>
void MemorySystem::Write(const VAddr vaddr, const T data) {
u8* page_pointer = impl->current_page_table->pointers[vaddr >> CITRA_PAGE_BITS];
u8* page_pointer = impl->current_page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS];
if (page_pointer) {
// NOTE: Avoid adding any extra logic to this fast-path block
std::memcpy(&page_pointer[vaddr & CITRA_PAGE_MASK], &data, sizeof(T));
std::memcpy(&page_pointer[vaddr & LUCINA3DS_PAGE_MASK], &data, sizeof(T));
return;
}
@@ -521,7 +521,7 @@ void MemorySystem::Write(const VAddr vaddr, const T data) {
}
}
PageType type = impl->current_page_table->attributes[vaddr >> CITRA_PAGE_BITS];
PageType type = impl->current_page_table->attributes[vaddr >> LUCINA3DS_PAGE_BITS];
switch (type) {
case PageType::Unmapped:
LOG_ERROR(HW_Memory, "unmapped Write{} 0x{:08X} @ 0x{:08X} at PC 0x{:08X}",
@@ -542,15 +542,15 @@ void MemorySystem::Write(const VAddr vaddr, const T data) {
template <typename T>
bool MemorySystem::WriteExclusive(const VAddr vaddr, const T data, const T expected) {
u8* page_pointer = impl->current_page_table->pointers[vaddr >> CITRA_PAGE_BITS];
u8* page_pointer = impl->current_page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS];
if (page_pointer) {
const auto volatile_pointer =
reinterpret_cast<volatile T*>(&page_pointer[vaddr & CITRA_PAGE_MASK]);
reinterpret_cast<volatile T*>(&page_pointer[vaddr & LUCINA3DS_PAGE_MASK]);
return Common::AtomicCompareAndSwap(volatile_pointer, data, expected);
}
PageType type = impl->current_page_table->attributes[vaddr >> CITRA_PAGE_BITS];
PageType type = impl->current_page_table->attributes[vaddr >> LUCINA3DS_PAGE_BITS];
switch (type) {
case PageType::Unmapped:
LOG_ERROR(HW_Memory, "unmapped Write{} 0x{:08X} @ 0x{:08X} at PC 0x{:08X}",
@@ -574,12 +574,12 @@ bool MemorySystem::WriteExclusive(const VAddr vaddr, const T data, const T expec
bool MemorySystem::IsValidVirtualAddress(const Kernel::Process& process, const VAddr vaddr) {
auto& page_table = *process.vm_manager.page_table;
auto page_pointer = page_table.pointers[vaddr >> CITRA_PAGE_BITS];
auto page_pointer = page_table.pointers[vaddr >> LUCINA3DS_PAGE_BITS];
if (page_pointer) {
return true;
}
if (page_table.attributes[vaddr >> CITRA_PAGE_BITS] == PageType::RasterizerCachedMemory) {
if (page_table.attributes[vaddr >> LUCINA3DS_PAGE_BITS] == PageType::RasterizerCachedMemory) {
return true;
}
@@ -591,12 +591,12 @@ bool MemorySystem::IsValidPhysicalAddress(const PAddr paddr) const {
}
u8* MemorySystem::GetPointer(const VAddr vaddr) {
u8* page_pointer = impl->current_page_table->pointers[vaddr >> CITRA_PAGE_BITS];
u8* page_pointer = impl->current_page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS];
if (page_pointer) {
return page_pointer + (vaddr & CITRA_PAGE_MASK);
return page_pointer + (vaddr & LUCINA3DS_PAGE_MASK);
}
if (impl->current_page_table->attributes[vaddr >> CITRA_PAGE_BITS] ==
if (impl->current_page_table->attributes[vaddr >> LUCINA3DS_PAGE_BITS] ==
PageType::RasterizerCachedMemory) {
return GetPointerForRasterizerCache(vaddr);
}
@@ -606,12 +606,12 @@ u8* MemorySystem::GetPointer(const VAddr vaddr) {
}
const u8* MemorySystem::GetPointer(const VAddr vaddr) const {
const u8* page_pointer = impl->current_page_table->pointers[vaddr >> CITRA_PAGE_BITS];
const u8* page_pointer = impl->current_page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS];
if (page_pointer) {
return page_pointer + (vaddr & CITRA_PAGE_MASK);
return page_pointer + (vaddr & LUCINA3DS_PAGE_MASK);
}
if (impl->current_page_table->attributes[vaddr >> CITRA_PAGE_BITS] ==
if (impl->current_page_table->attributes[vaddr >> LUCINA3DS_PAGE_BITS] ==
PageType::RasterizerCachedMemory) {
return GetPointerForRasterizerCache(vaddr);
}
@@ -720,14 +720,14 @@ void MemorySystem::RasterizerMarkRegionCached(PAddr start, u32 size, bool cached
return;
}
u32 num_pages = ((start + size - 1) >> CITRA_PAGE_BITS) - (start >> CITRA_PAGE_BITS) + 1;
u32 num_pages = ((start + size - 1) >> LUCINA3DS_PAGE_BITS) - (start >> LUCINA3DS_PAGE_BITS) + 1;
PAddr paddr = start;
for (unsigned i = 0; i < num_pages; ++i, paddr += CITRA_PAGE_SIZE) {
for (unsigned i = 0; i < num_pages; ++i, paddr += LUCINA3DS_PAGE_SIZE) {
for (VAddr vaddr : PhysicalToVirtualAddressForRasterizer(paddr)) {
impl->cache_marker.Mark(vaddr, cached);
for (auto& page_table : impl->page_table_list) {
PageType& page_type = page_table->attributes[vaddr >> CITRA_PAGE_BITS];
PageType& page_type = page_table->attributes[vaddr >> LUCINA3DS_PAGE_BITS];
if (cached) {
// Switch page type to cached if now cached
@@ -738,7 +738,7 @@ void MemorySystem::RasterizerMarkRegionCached(PAddr start, u32 size, bool cached
break;
case PageType::Memory:
page_type = PageType::RasterizerCachedMemory;
page_table->pointers[vaddr >> CITRA_PAGE_BITS] = nullptr;
page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS] = nullptr;
break;
default:
UNREACHABLE();
@@ -752,8 +752,8 @@ void MemorySystem::RasterizerMarkRegionCached(PAddr start, u32 size, bool cached
break;
case PageType::RasterizerCachedMemory: {
page_type = PageType::Memory;
page_table->pointers[vaddr >> CITRA_PAGE_BITS] =
GetPointerForRasterizerCache(vaddr & ~CITRA_PAGE_MASK);
page_table->pointers[vaddr >> LUCINA3DS_PAGE_BITS] =
GetPointerForRasterizerCache(vaddr & ~LUCINA3DS_PAGE_MASK);
break;
}
default:
@@ -838,13 +838,13 @@ void MemorySystem::ZeroBlock(const Kernel::Process& process, const VAddr dest_ad
const std::size_t size) {
auto& page_table = *process.vm_manager.page_table;
std::size_t remaining_size = size;
std::size_t page_index = dest_addr >> CITRA_PAGE_BITS;
std::size_t page_offset = dest_addr & CITRA_PAGE_MASK;
std::size_t page_index = dest_addr >> LUCINA3DS_PAGE_BITS;
std::size_t page_offset = dest_addr & LUCINA3DS_PAGE_MASK;
while (remaining_size > 0) {
const std::size_t copy_amount = std::min(CITRA_PAGE_SIZE - page_offset, remaining_size);
const std::size_t copy_amount = std::min(LUCINA3DS_PAGE_SIZE - page_offset, remaining_size);
const VAddr current_vaddr =
static_cast<VAddr>((page_index << CITRA_PAGE_BITS) + page_offset);
static_cast<VAddr>((page_index << LUCINA3DS_PAGE_BITS) + page_offset);
switch (page_table.attributes[page_index]) {
case PageType::Unmapped: {
@@ -887,13 +887,13 @@ void MemorySystem::CopyBlock(const Kernel::Process& dest_process,
std::size_t size) {
auto& page_table = *src_process.vm_manager.page_table;
std::size_t remaining_size = size;
std::size_t page_index = src_addr >> CITRA_PAGE_BITS;
std::size_t page_offset = src_addr & CITRA_PAGE_MASK;
std::size_t page_index = src_addr >> LUCINA3DS_PAGE_BITS;
std::size_t page_offset = src_addr & LUCINA3DS_PAGE_MASK;
while (remaining_size > 0) {
const std::size_t copy_amount = std::min(CITRA_PAGE_SIZE - page_offset, remaining_size);
const std::size_t copy_amount = std::min(LUCINA3DS_PAGE_SIZE - page_offset, remaining_size);
const VAddr current_vaddr =
static_cast<VAddr>((page_index << CITRA_PAGE_BITS) + page_offset);
static_cast<VAddr>((page_index << LUCINA3DS_PAGE_BITS) + page_offset);
switch (page_table.attributes[page_index]) {
case PageType::Unmapped: {