mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-22 02:29: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 uint32_t reboot_start __attribute__((section(".text")));
|
||||||
extern size_t reboot_size __attribute__((section(".text")));
|
extern size_t reboot_size __attribute__((section(".text")));
|
||||||
extern int reboot_entry_offset __attribute__((section(".text")));
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
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])));
|
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 boot_device asm ("s3");
|
||||||
register uint32_t tv_type asm ("s4");
|
register uint32_t tv_type asm ("s4");
|
||||||
register uint32_t reset_type asm ("s5");
|
register uint32_t reset_type asm ("s5");
|
||||||
register uint32_t cic_seed asm ("s6");
|
register uint32_t cic_seed asm ("s6");
|
||||||
register uint32_t version asm ("s7");
|
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);
|
boot_device = (params->device_type & 0x01);
|
||||||
tv_type = (params->tv_type & 0x03);
|
tv_type = (params->tv_type & 0x03);
|
||||||
reset_type = BOOT_RESET_TYPE_COLD;
|
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_NTSC) ? 1
|
||||||
: (params->tv_type == BOOT_TV_TYPE_MPAL) ? 4
|
: (params->tv_type == BOOT_TV_TYPE_MPAL) ? 4
|
||||||
: 0;
|
: 0;
|
||||||
stack_pointer = (void *) UNCACHED(&SP_MEM->IMEM[1020]);
|
|
||||||
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"move $sp, %[stack_pointer] \n"
|
"la $t3, reboot \n"
|
||||||
"jr %[entry_point] \n" ::
|
"jr $t3 \n" ::
|
||||||
[entry_point] "r" (entry_point),
|
|
||||||
[boot_device] "r" (boot_device),
|
[boot_device] "r" (boot_device),
|
||||||
[tv_type] "r" (tv_type),
|
[tv_type] "r" (tv_type),
|
||||||
[reset_type] "r" (reset_type),
|
[reset_type] "r" (reset_type),
|
||||||
[cic_seed] "r" (cic_seed),
|
[cic_seed] "r" (cic_seed),
|
||||||
[version] "r" (version),
|
[version] "r" (version) :
|
||||||
[stack_pointer] "r" (stack_pointer)
|
"t3"
|
||||||
);
|
);
|
||||||
|
|
||||||
while (1);
|
while (1);
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#define IPL3_ENTRY 0xA4000040
|
||||||
|
#define REBOOT_ADDRESS 0xA4001000
|
||||||
|
#define STACK_ADDRESS 0xA4001FF0
|
||||||
|
|
||||||
#define RI_ADDRESS 0xA4700000
|
#define RI_ADDRESS 0xA4700000
|
||||||
|
|
||||||
#define RI_MODE 0x00
|
#define RI_MODE 0x00
|
||||||
@ -13,8 +17,6 @@
|
|||||||
#define RDRAM_RESET_DELAY 1024
|
#define RDRAM_RESET_DELAY 1024
|
||||||
#define RDRAM_STANDBY_DELAY 512
|
#define RDRAM_STANDBY_DELAY 512
|
||||||
|
|
||||||
#define IPL3_ENTRY 0xA4000040
|
|
||||||
|
|
||||||
.set noat
|
.set noat
|
||||||
.section .text.reboot, "ax", %progbits
|
.section .text.reboot, "ax", %progbits
|
||||||
.type reboot, %object
|
.type reboot, %object
|
||||||
@ -36,8 +38,10 @@ ipl2:
|
|||||||
.set reorder
|
.set reorder
|
||||||
|
|
||||||
reboot_entry:
|
reboot_entry:
|
||||||
.equ reboot_entry_offset, ((. - reboot_start) / 4)
|
.set reboot, REBOOT_ADDRESS + (. - reboot_start)
|
||||||
.global reboot_entry_offset
|
.global reboot
|
||||||
|
|
||||||
|
li $sp, STACK_ADDRESS
|
||||||
|
|
||||||
bnez $s5, reset_rdram_skip
|
bnez $s5, reset_rdram_skip
|
||||||
|
|
||||||
@ -64,8 +68,16 @@ reset_rdram:
|
|||||||
1:
|
1:
|
||||||
addiu $t2, (-1)
|
addiu $t2, (-1)
|
||||||
bnez $t2, 1b
|
bnez $t2, 1b
|
||||||
|
|
||||||
|
mtc0 $zero, $9
|
||||||
reset_rdram_skip:
|
reset_rdram_skip:
|
||||||
|
|
||||||
|
prepare_registers:
|
||||||
|
la $t0, ra_table
|
||||||
|
sll $t1, $s4, 2
|
||||||
|
add $t0, $t1
|
||||||
|
lw $ra, ($t0)
|
||||||
|
|
||||||
move $at, $zero
|
move $at, $zero
|
||||||
move $v0, $zero
|
move $v0, $zero
|
||||||
move $v1, $zero
|
move $v1, $zero
|
||||||
@ -76,7 +88,6 @@ reset_rdram_skip:
|
|||||||
move $t0, $zero
|
move $t0, $zero
|
||||||
move $t1, $zero
|
move $t1, $zero
|
||||||
move $t2, $zero
|
move $t2, $zero
|
||||||
move $t3, $zero
|
|
||||||
move $t4, $zero
|
move $t4, $zero
|
||||||
move $t5, $zero
|
move $t5, $zero
|
||||||
move $t6, $zero
|
move $t6, $zero
|
||||||
@ -90,13 +101,16 @@ reset_rdram_skip:
|
|||||||
move $k1, $zero
|
move $k1, $zero
|
||||||
move $gp, $zero
|
move $gp, $zero
|
||||||
move $s8, $zero
|
move $s8, $zero
|
||||||
move $ra, $zero
|
|
||||||
|
|
||||||
mtc0 $zero, $9
|
|
||||||
|
|
||||||
run_ipl3:
|
run_ipl3:
|
||||||
li $t3, IPL3_ENTRY
|
li $t3, IPL3_ENTRY
|
||||||
jr $t3
|
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
|
.global reboot_size
|
||||||
|
Loading…
Reference in New Issue
Block a user