ultramodern / recomp runtime: Relax alignment restrictions in osEPiReadIo, implement some more stubs (#130)
- osDriveRomInit - __osPiGetAccess - __osPiRelAccess - osPfsChecker
This commit is contained in:
parent
d5fb5f50c1
commit
89af45ae34
|
@ -31,6 +31,7 @@ namespace recomp {
|
||||||
bool is_rom_loaded();
|
bool is_rom_loaded();
|
||||||
void set_rom_contents(std::vector<uint8_t>&& new_rom);
|
void set_rom_contents(std::vector<uint8_t>&& new_rom);
|
||||||
void do_rom_read(uint8_t* rdram, gpr ram_address, uint32_t physical_addr, size_t num_bytes);
|
void do_rom_read(uint8_t* rdram, gpr ram_address, uint32_t physical_addr, size_t num_bytes);
|
||||||
|
void do_rom_pio(uint8_t* rdram, gpr ram_address, uint32_t physical_addr)
|
||||||
void start(ultramodern::WindowHandle window_handle, const ultramodern::audio_callbacks_t& audio_callbacks, const ultramodern::input_callbacks_t& input_callbacks, const ultramodern::gfx_callbacks_t& gfx_callbacks);
|
void start(ultramodern::WindowHandle window_handle, const ultramodern::audio_callbacks_t& audio_callbacks, const ultramodern::input_callbacks_t& input_callbacks, const ultramodern::gfx_callbacks_t& gfx_callbacks);
|
||||||
void start_game(Game game);
|
void start_game(Game game);
|
||||||
void message_box(const char* message);
|
void message_box(const char* message);
|
||||||
|
|
|
@ -29,3 +29,7 @@ extern "C" void osPfsFindFile_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||||
extern "C" void osPfsReadWriteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
|
extern "C" void osPfsReadWriteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||||
ctx->r2 = 1; // PFS_ERR_NOPACK
|
ctx->r2 = 1; // PFS_ERR_NOPACK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void osPfsChecker_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||||
|
ctx->r2 = 1; // PFS_ERR_NOPACK
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ void recomp::set_rom_contents(std::vector<uint8_t>&& new_rom) {
|
||||||
// that involve physical addresses don't need to be handled for flashram.
|
// that involve physical addresses don't need to be handled for flashram.
|
||||||
constexpr uint32_t sram_base = 0x08000000;
|
constexpr uint32_t sram_base = 0x08000000;
|
||||||
constexpr uint32_t rom_base = 0x10000000;
|
constexpr uint32_t rom_base = 0x10000000;
|
||||||
|
constexpr uint32_t drive_base = 0x06000000;
|
||||||
|
|
||||||
constexpr uint32_t k1_to_phys(uint32_t addr) {
|
constexpr uint32_t k1_to_phys(uint32_t addr) {
|
||||||
return addr & 0x1FFFFFFF;
|
return addr & 0x1FFFFFFF;
|
||||||
|
@ -34,6 +35,12 @@ constexpr uint32_t phys_to_k1(uint32_t addr) {
|
||||||
return addr | 0xA0000000;
|
return addr | 0xA0000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void __osPiGetAccess_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void __osPiRelAccess_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void osCartRomInit_recomp(uint8_t* rdram, recomp_context* ctx) {
|
extern "C" void osCartRomInit_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
OSPiHandle* handle = TO_PTR(OSPiHandle, ultramodern::cart_handle);
|
OSPiHandle* handle = TO_PTR(OSPiHandle, ultramodern::cart_handle);
|
||||||
handle->type = 0; // cart
|
handle->type = 0; // cart
|
||||||
|
@ -43,6 +50,15 @@ extern "C" void osCartRomInit_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
ctx->r2 = (gpr)ultramodern::cart_handle;
|
ctx->r2 = (gpr)ultramodern::cart_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void osDriveRomInit_recomp(uint8_t * rdram, recomp_context * ctx) {
|
||||||
|
OSPiHandle* handle = TO_PTR(OSPiHandle, ultramodern::drive_handle);
|
||||||
|
handle->type = 1; // bulk
|
||||||
|
handle->baseAddress = phys_to_k1(drive_base);
|
||||||
|
handle->domain = 0;
|
||||||
|
|
||||||
|
ctx->r2 = (gpr)ultramodern::drive_handle;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void osCreatePiManager_recomp(uint8_t* rdram, recomp_context* ctx) {
|
extern "C" void osCreatePiManager_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +77,16 @@ void recomp::do_rom_read(uint8_t* rdram, gpr ram_address, uint32_t physical_addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void recomp::do_rom_pio(uint8_t* rdram, gpr ram_address, uint32_t physical_addr) {
|
||||||
|
assert((physical_addr & 0x3) == 0 && "PIO not 4-byte aligned in device, currently unsupported");
|
||||||
|
assert((ram_address & 0x3) == 0 && "PIO not 4-byte aligned in RDRAM, currently unsupported");
|
||||||
|
uint8_t* rom_addr = rom.data() + physical_addr - rom_base;
|
||||||
|
MEM_B(0, ram_address) = *rom_addr++;
|
||||||
|
MEM_B(1, ram_address) = *rom_addr++;
|
||||||
|
MEM_B(2, ram_address) = *rom_addr++;
|
||||||
|
MEM_B(3, ram_address) = *rom_addr++;
|
||||||
|
}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
std::array<char, 0x20000> save_buffer;
|
std::array<char, 0x20000> save_buffer;
|
||||||
std::thread saving_thread;
|
std::thread saving_thread;
|
||||||
|
@ -247,7 +273,7 @@ extern "C" void osEPiReadIo_recomp(RDRAM_ARG recomp_context * ctx) {
|
||||||
|
|
||||||
if (physical_addr > rom_base) {
|
if (physical_addr > rom_base) {
|
||||||
// cart rom
|
// cart rom
|
||||||
recomp::do_rom_read(PASS_RDRAM dramAddr, physical_addr, sizeof(uint32_t));
|
recomp::do_rom_pio(PASS_RDRAM dramAddr, physical_addr);
|
||||||
} else {
|
} else {
|
||||||
// sram
|
// sram
|
||||||
assert(false && "SRAM ReadIo unimplemented");
|
assert(false && "SRAM ReadIo unimplemented");
|
||||||
|
|
|
@ -53,7 +53,8 @@ namespace ultramodern {
|
||||||
// We need a place in rdram to hold the PI handles, so pick an address in extended rdram
|
// We need a place in rdram to hold the PI handles, so pick an address in extended rdram
|
||||||
constexpr uint32_t rdram_size = 1024 * 1024 * 16; // 16MB to give extra room for anything custom
|
constexpr uint32_t rdram_size = 1024 * 1024 * 16; // 16MB to give extra room for anything custom
|
||||||
constexpr int32_t cart_handle = 0x80800000;
|
constexpr int32_t cart_handle = 0x80800000;
|
||||||
constexpr int32_t flash_handle = (int32_t)(cart_handle + sizeof(OSPiHandle));
|
constexpr int32_t drive_handle = (int32_t)(cart_handle + sizeof(OSPiHandle));
|
||||||
|
constexpr int32_t flash_handle = (int32_t)(drive_handle + sizeof(OSPiHandle));
|
||||||
constexpr uint32_t save_size = 1024 * 1024 / 8; // Maximum save size, 1Mbit for flash
|
constexpr uint32_t save_size = 1024 * 1024 / 8; // Maximum save size, 1Mbit for flash
|
||||||
|
|
||||||
// Initialization.
|
// Initialization.
|
||||||
|
|
Loading…
Reference in New Issue