mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-21 18:19:19 +01:00
Improve reboot compatibility
This commit is contained in:
parent
f063f05fe6
commit
15bca14b98
@ -12,7 +12,6 @@
|
||||
|
||||
extern uint32_t reboot_start __attribute__((section(".text")));
|
||||
extern size_t reboot_size __attribute__((section(".text")));
|
||||
extern int reboot_entry_offset __attribute__((section(".text")));
|
||||
|
||||
|
||||
typedef struct {
|
||||
@ -134,15 +133,12 @@ void boot (boot_params_t *params) {
|
||||
cpu_io_write(&ipl3_dst[i], io_read((uint32_t) (&ipl3_src[i])));
|
||||
}
|
||||
|
||||
register void (*entry_point)(void) asm ("t3");
|
||||
register uint32_t boot_device asm ("s3");
|
||||
register uint32_t tv_type asm ("s4");
|
||||
register uint32_t reset_type asm ("s5");
|
||||
register uint32_t cic_seed asm ("s6");
|
||||
register uint32_t version asm ("s7");
|
||||
void *stack_pointer;
|
||||
|
||||
entry_point = (void (*)(void)) UNCACHED(&SP_MEM->IMEM[(int) (&reboot_entry_offset)]);
|
||||
boot_device = (params->device_type & 0x01);
|
||||
tv_type = (params->tv_type & 0x03);
|
||||
reset_type = BOOT_RESET_TYPE_COLD;
|
||||
@ -151,18 +147,16 @@ void boot (boot_params_t *params) {
|
||||
: (params->tv_type == BOOT_TV_TYPE_NTSC) ? 1
|
||||
: (params->tv_type == BOOT_TV_TYPE_MPAL) ? 4
|
||||
: 0;
|
||||
stack_pointer = (void *) UNCACHED(&SP_MEM->IMEM[1020]);
|
||||
|
||||
asm volatile (
|
||||
"move $sp, %[stack_pointer] \n"
|
||||
"jr %[entry_point] \n" ::
|
||||
[entry_point] "r" (entry_point),
|
||||
"la $t3, reboot \n"
|
||||
"jr $t3 \n" ::
|
||||
[boot_device] "r" (boot_device),
|
||||
[tv_type] "r" (tv_type),
|
||||
[reset_type] "r" (reset_type),
|
||||
[cic_seed] "r" (cic_seed),
|
||||
[version] "r" (version),
|
||||
[stack_pointer] "r" (stack_pointer)
|
||||
[version] "r" (version) :
|
||||
"t3"
|
||||
);
|
||||
|
||||
while (1);
|
||||
|
@ -1,3 +1,7 @@
|
||||
#define IPL3_ENTRY 0xA4000040
|
||||
#define REBOOT_ADDRESS 0xA4001000
|
||||
#define STACK_ADDRESS 0xA4001FF0
|
||||
|
||||
#define RI_ADDRESS 0xA4700000
|
||||
|
||||
#define RI_MODE 0x00
|
||||
@ -13,8 +17,6 @@
|
||||
#define RDRAM_RESET_DELAY 1024
|
||||
#define RDRAM_STANDBY_DELAY 512
|
||||
|
||||
#define IPL3_ENTRY 0xA4000040
|
||||
|
||||
.set noat
|
||||
.section .text.reboot, "ax", %progbits
|
||||
.type reboot, %object
|
||||
@ -36,8 +38,10 @@ ipl2:
|
||||
.set reorder
|
||||
|
||||
reboot_entry:
|
||||
.equ reboot_entry_offset, ((. - reboot_start) / 4)
|
||||
.global reboot_entry_offset
|
||||
.set reboot, REBOOT_ADDRESS + (. - reboot_start)
|
||||
.global reboot
|
||||
|
||||
li $sp, STACK_ADDRESS
|
||||
|
||||
bnez $s5, reset_rdram_skip
|
||||
|
||||
@ -64,8 +68,16 @@ reset_rdram:
|
||||
1:
|
||||
addiu $t2, (-1)
|
||||
bnez $t2, 1b
|
||||
|
||||
mtc0 $zero, $9
|
||||
reset_rdram_skip:
|
||||
|
||||
prepare_registers:
|
||||
la $t0, ra_table
|
||||
sll $t1, $s4, 2
|
||||
add $t0, $t1
|
||||
lw $ra, ($t0)
|
||||
|
||||
move $at, $zero
|
||||
move $v0, $zero
|
||||
move $v1, $zero
|
||||
@ -76,7 +88,6 @@ reset_rdram_skip:
|
||||
move $t0, $zero
|
||||
move $t1, $zero
|
||||
move $t2, $zero
|
||||
move $t3, $zero
|
||||
move $t4, $zero
|
||||
move $t5, $zero
|
||||
move $t6, $zero
|
||||
@ -90,13 +101,16 @@ reset_rdram_skip:
|
||||
move $k1, $zero
|
||||
move $gp, $zero
|
||||
move $s8, $zero
|
||||
move $ra, $zero
|
||||
|
||||
mtc0 $zero, $9
|
||||
|
||||
run_ipl3:
|
||||
li $t3, IPL3_ENTRY
|
||||
jr $t3
|
||||
|
||||
.equ reboot_size, (. - reboot_start)
|
||||
ra_values:
|
||||
.set ra_table, REBOOT_ADDRESS + (. - reboot_start)
|
||||
.word 0xA4001554
|
||||
.word 0xA4001550
|
||||
.word 0xA4001550 # TODO: Figure out address for MPAL console
|
||||
|
||||
.set reboot_size, (. - reboot_start)
|
||||
.global reboot_size
|
||||
|
Loading…
Reference in New Issue
Block a user