[APT] Add shared font

This commit is contained in:
wheremyfoodat 2023-01-23 19:32:13 +02:00
parent c8a4c7d7fa
commit cad046d9a8
7 changed files with 262187 additions and 14 deletions

View file

@ -59,7 +59,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services
src/core/services/ndm.cpp src/core/services/dsp.cpp src/core/services/cfg.cpp
src/core/services/ptm.cpp src/core/services/mic.cpp src/core/services/cecd.cpp
src/core/services/ac.cpp src/core/services/am.cpp src/core/services/boss.cpp
src/core/services/frd.cpp src/core/services/nim.cpp
src/core/services/frd.cpp src/core/services/nim.cpp src/core/services/shared_font.cpp
)
set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp
src/core/PICA/shader_interpreter.cpp
@ -86,7 +86,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc
include/services/mic.hpp include/services/cecd.hpp include/renderer_gl/renderer_gl.hpp
include/renderer_gl/surfaces.hpp include/renderer_gl/surface_cache.hpp include/services/ac.hpp
include/services/am.hpp include/services/boss.hpp include/services/frd.hpp include/services/nim.hpp
include/fs/archive_ext_save_data.hpp
include/fs/archive_ext_save_data.hpp include/services/shared_font.hpp
)
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp

View file

@ -77,7 +77,13 @@ public:
}
void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override {
Helpers::panic("Fired exception oops");
switch (exception) {
case Dynarmic::A32::Exception::UnpredictableInstruction:
Helpers::panic("Unpredictable instruction at pc = %08X", pc);
break;
default: Helpers::panic("Fired exception oops");
}
}
void AddTicks(u64 ticks) override {

View file

@ -8,6 +8,7 @@
#include "helpers.hpp"
#include "handles.hpp"
#include "loader/ncsd.hpp"
#include "services/shared_font.hpp"
namespace PhysicalAddrs {
enum : u32 {
@ -104,10 +105,11 @@ class Memory {
// This tracks our OS' memory allocations
std::vector<KernelMemoryTypes::MemoryInfo> memoryInfo;
std::array<SharedMemoryBlock, 2> sharedMemBlocks = {
std::array<SharedMemoryBlock, 3> sharedMemBlocks = {
SharedMemoryBlock(0, _shared_font_len, KernelHandles::FontSharedMemHandle), // Shared memory for the system font
SharedMemoryBlock(0, 0x1000, KernelHandles::GSPSharedMemHandle), // GSP shared memory
SharedMemoryBlock(0, 0x1000, KernelHandles::HIDSharedMemHandle) // HID shared memory
};
};
static constexpr u32 pageShift = 12;
static constexpr u32 pageSize = 1 << pageShift;

View file

@ -0,0 +1,5 @@
#pragma once
#include <cstddef>
extern unsigned char _shared_font_bin[];
extern size_t _shared_font_len;

View file

@ -1,4 +1,5 @@
#include "kernel.hpp"
#include "services/shared_font.hpp"
namespace Operation {
enum : u32 {
@ -89,7 +90,7 @@ void Kernel::queryMemory() {
// Result MapMemoryBlock(Handle memblock, u32 addr, MemoryPermission myPermissions, MemoryPermission otherPermission)
void Kernel::mapMemoryBlock() {
const Handle block = regs[0];
const u32 addr = regs[1];
u32 addr = regs[1];
const u32 myPerms = regs[2];
const u32 otherPerms = regs[3];
logSVC("MapMemoryBlock(block = %X, addr = %08X, myPerms = %X, otherPerms = %X\n", block, addr, myPerms, otherPerms);
@ -99,15 +100,24 @@ void Kernel::mapMemoryBlock() {
}
if (KernelHandles::isSharedMemHandle(block)) {
if (block == KernelHandles::FontSharedMemHandle && addr == 0) addr = 0x18000000;
u8* ptr = mem.mapSharedMemory(block, addr, myPerms, otherPerms); // Map shared memory block
// Pass pointer to shared memory to the appropriate service
if (block == KernelHandles::HIDSharedMemHandle) {
serviceManager.setHIDSharedMem(ptr);
} else if (block == KernelHandles::GSPSharedMemHandle) {
serviceManager.setGSPSharedMem(ptr);
} else {
Helpers::panic("Mapping unknown shared memory block: %X", block);
switch (block) {
case KernelHandles::HIDSharedMemHandle:
serviceManager.setHIDSharedMem(ptr);
break;
case KernelHandles::GSPSharedMemHandle:
serviceManager.setGSPSharedMem(ptr);
break;
case KernelHandles::FontSharedMemHandle:
std::memcpy(ptr, _shared_font_bin, _shared_font_len);
break;
default: Helpers::panic("Mapping unknown shared memory block: %X", block);
}
} else {
Helpers::panic("MapMemoryBlock where the handle does not refer to GSP memory");

View file

@ -43,11 +43,11 @@ void Memory::reset() {
for (auto& e : sharedMemBlocks) {
e.mapped = false;
std::optional<u32> possiblePaddr = findPaddr(e.size);
std::optional<u32> possiblePaddr = findPaddr(e.size); // Find a physical FCRAM index to allocate for the shared memory block
if (!possiblePaddr.has_value()) Helpers::panic("Failed to find paddr for shared memory block");
e.paddr = possiblePaddr.value();
if (!reserveMemory(e.paddr, e.size)) {
if (!reserveMemory(e.paddr, e.size)) { // Actually reserve the memory
Helpers::panic("Failed to reserve memory for shared memory block");
}
}

File diff suppressed because it is too large Load diff