mirror of https://github.com/inolen/redream.git
rename menu syscall vector to system syscall vector
add support for system boot syscall
This commit is contained in:
parent
d271986064
commit
b7cb524c02
|
@ -33,7 +33,7 @@ enum {
|
|||
VECTOR_FLASHROM = 0x0c0000b8,
|
||||
VECTOR_GDROM = 0x0c0000bc,
|
||||
VECTOR_GDROM2 = 0x0c0000c0,
|
||||
VECTOR_MENU = 0x0c0000e0,
|
||||
VECTOR_SYSTEM = 0x0c0000e0,
|
||||
};
|
||||
|
||||
/* address of syscall entrypoints */
|
||||
|
@ -43,7 +43,7 @@ enum {
|
|||
SYSCALL_FLASHROM = 0x0c003d00,
|
||||
SYSCALL_GDROM = 0x0c001000,
|
||||
SYSCALL_GDROM2 = 0x0c0010f0,
|
||||
SYSCALL_MENU = 0x0c000800,
|
||||
SYSCALL_SYSTEM = 0x0c000800,
|
||||
};
|
||||
|
||||
static uint32_t bios_local_time() {
|
||||
|
@ -209,7 +209,34 @@ static void bios_validate_flash(struct bios *bios) {
|
|||
}
|
||||
}
|
||||
|
||||
static void bios_boot(struct bios *bios) {
|
||||
static int bios_post_init(struct device *dev) {
|
||||
struct bios *bios = (struct bios *)dev;
|
||||
|
||||
bios_validate_flash(bios);
|
||||
|
||||
bios_override_settings(bios);
|
||||
|
||||
#if 0
|
||||
/* this code enables a "hybrid" hle mode. in this mode, syscalls are patched
|
||||
to trap into their hle handlers, but the real bios can still be ran to
|
||||
test if bugs exist in the syscall emulation or bootstrap emulation. note,
|
||||
the boot rom does a bootstrap on startup which copies the boot rom into
|
||||
system ram. due to this, the invalid instructions are written to the
|
||||
original rom, not the system ram (or else, they would be overwritten by
|
||||
the bootstrap process) */
|
||||
struct boot *boot = bios->dc->boot;
|
||||
boot_rom_write(boot, SYSCALL_FONTROM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_SYSINFO - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_FLASHROM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_GDROM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_GDROM2 - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_SYSTEM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bios_boot(struct bios *bios) {
|
||||
struct dreamcast *dc = bios->dc;
|
||||
struct flash *flash = dc->flash;
|
||||
struct gdrom *gd = dc->gdrom;
|
||||
|
@ -289,40 +316,13 @@ static void bios_boot(struct bios *bios) {
|
|||
sh4_write32(dc->mem, VECTOR_FLASHROM, SYSCALL_FLASHROM);
|
||||
sh4_write32(dc->mem, VECTOR_GDROM, SYSCALL_GDROM);
|
||||
sh4_write32(dc->mem, VECTOR_GDROM2, SYSCALL_GDROM2);
|
||||
sh4_write32(dc->mem, VECTOR_MENU, SYSCALL_MENU);
|
||||
sh4_write32(dc->mem, VECTOR_SYSTEM, SYSCALL_SYSTEM);
|
||||
}
|
||||
|
||||
/* start executing at license screen code inside of ip.bin */
|
||||
ctx->pc = 0xac008300;
|
||||
}
|
||||
|
||||
static int bios_post_init(struct device *dev) {
|
||||
struct bios *bios = (struct bios *)dev;
|
||||
|
||||
bios_validate_flash(bios);
|
||||
|
||||
bios_override_settings(bios);
|
||||
|
||||
#if 0
|
||||
/* this code enables a "hybrid" hle mode. in this mode, syscalls are patched
|
||||
to trap into their hle handlers, but the real bios can still be ran to
|
||||
test if bugs exist in the syscall emulation or bootstrap emulation. note,
|
||||
the boot rom does a bootstrap on startup which copies the boot rom into
|
||||
system ram. due to this, the invalid instructions are written to the
|
||||
original rom, not the system ram (or else, they would be overwritten by
|
||||
the bootstrap process) */
|
||||
struct boot *boot = bios->dc->boot;
|
||||
boot_rom_write(boot, SYSCALL_FONTROM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_SYSINFO - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_FLASHROM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_GDROM - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_GDROM2 - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
boot_rom_write(boot, SYSCALL_MENU - SH4_AREA3_BEGIN, 0x0, 0xffff);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bios_invalid_instr(struct bios *bios) {
|
||||
struct dreamcast *dc = bios->dc;
|
||||
struct sh4_context *ctx = &dc->sh4->ctx;
|
||||
|
@ -355,8 +355,8 @@ int bios_invalid_instr(struct bios *bios) {
|
|||
bios_gdrom_vector(bios);
|
||||
break;
|
||||
|
||||
case SYSCALL_MENU:
|
||||
bios_menu_vector(bios);
|
||||
case SYSCALL_SYSTEM:
|
||||
bios_system_vector(bios);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -19,5 +19,6 @@ struct bios *bios_create(struct dreamcast *dc);
|
|||
void bios_destroy(struct bios *bios);
|
||||
|
||||
int bios_invalid_instr(struct bios *bios);
|
||||
void bios_boot(struct bios *bios);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,18 +14,39 @@
|
|||
#endif
|
||||
|
||||
/*
|
||||
* menu syscalls
|
||||
* system syscalls
|
||||
*/
|
||||
void bios_menu_vector(struct bios *bios) {
|
||||
enum {
|
||||
SYSTEM_BOOT = -3,
|
||||
SYSTEM_UNKNOWN = -2,
|
||||
SYSTEM_RESET1 = -1,
|
||||
SYSTEM_SECURITY = 0,
|
||||
SYSTEM_RESET2 = 1,
|
||||
SYSTEM_CHKDISC = 2,
|
||||
SYSTEM_RESET3 = 3,
|
||||
SYSTEM_RESET4 = 4,
|
||||
};
|
||||
|
||||
void bios_system_vector(struct bios *bios) {
|
||||
struct dreamcast *dc = bios->dc;
|
||||
struct sh4_context *ctx = &dc->sh4->ctx;
|
||||
|
||||
uint32_t fn = ctx->r[4];
|
||||
|
||||
LOG_SYSCALL("MENU 0x%x", fn);
|
||||
LOG_SYSCALL("SYSTEM 0x%x", fn);
|
||||
|
||||
/* nop, branch to the return address */
|
||||
ctx->pc = ctx->pr;
|
||||
|
||||
switch (fn) {
|
||||
case SYSTEM_BOOT:
|
||||
bios_boot(bios);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WARNING("bios_system_vector unhandled fn=0x%x", fn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -7,6 +7,6 @@ void bios_fontrom_vector(struct bios *bios);
|
|||
void bios_sysinfo_vector(struct bios *bios);
|
||||
void bios_flashrom_vector(struct bios *bios);
|
||||
void bios_gdrom_vector(struct bios *bios);
|
||||
void bios_menu_vector(struct bios *bios);
|
||||
void bios_system_vector(struct bios *bios);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue