minor bootloader tweaks

This commit is contained in:
Mateusz Faderewski 2023-12-08 21:22:19 +01:00
parent 92e53fd3e5
commit 3050dfa116
5 changed files with 29 additions and 51 deletions

View File

@ -81,9 +81,10 @@ $(BUILD_DIR)/bootloader.elf: $(OBJS) N64.ld
@$(OBJDUMP) -S $@ > $(BUILD_DIR)/bootloader.lst @$(OBJDUMP) -S $@ > $(BUILD_DIR)/bootloader.lst
$(BUILD_DIR)/bootloader.bin: $(BUILD_DIR)/bootloader.elf $(BUILD_DIR)/bootloader.bin: $(BUILD_DIR)/bootloader.elf
@$(STRIP) -s $< @cp $< $<.stripped
@$(N64_ELFCOMPRESS) -c 2 -o $(dir $<) $< @$(STRIP) -s $<.stripped
@$(N64_TOOL) --title "SC64 bootloader" --output $@ --align 256 $< @$(N64_ELFCOMPRESS) -c 2 -o $(dir $<) $<.stripped
@$(N64_TOOL) --title "SC64 bootloader" --output $@ --align 256 $<.stripped
all: $(BUILD_DIR)/bootloader.bin all: $(BUILD_DIR)/bootloader.bin

View File

@ -1,6 +1,7 @@
MEMORY { MEMORY {
exception (rx) : org = 0x80000000, len = 0x400
ram (rwx) : org = 0x80000400, len = 1M ram (rwx) : org = 0x80000400, len = 1M
framebuffer (rw) : org = 0x8026A000, len = 600k framebuffer (rw) : org = 0x8016A000, len = 600k
} }
ENTRY(entry_handler) ENTRY(entry_handler)
@ -9,6 +10,10 @@ __exception_stack_size = 8k;
__stack_size = 16k; __stack_size = 16k;
SECTIONS { SECTIONS {
.exception : {
KEEP(*(.text.exception_vector));
} > exception
.text : SUBALIGN(8) { .text : SUBALIGN(8) {
*(.text.entry_handler) *(.text.entry_handler)
*(.text .text.* .gnu.linkonce.t.*) *(.text .text.* .gnu.linkonce.t.*)

View File

@ -3,10 +3,6 @@
#define WATCHDOG_TIMEOUT (5 * (93750000UL / 2)) #define WATCHDOG_TIMEOUT (5 * (93750000UL / 2))
#define VECTOR_LOCATION (0xA0000000UL)
#define VECTOR_SIZE (0x80)
#define VECTOR_NUM (4)
#define ZR_OFFSET (0) #define ZR_OFFSET (0)
#define AT_OFFSET (8) #define AT_OFFSET (8)
#define V0_OFFSET (16) #define V0_OFFSET (16)
@ -46,8 +42,23 @@
#define SAVE_REGISTERS_SIZE (280) #define SAVE_REGISTERS_SIZE (280)
.section .text.exception_vector
exception_tlb_miss:
.org 0x0000
j exception_handler
exception_xtlb_miss:
.org 0x0080
j exception_handler
exception_other:
.org 0x0180
j exception_handler
.section .text.exception_handler .section .text.exception_handler
exception_handler: exception_handler:
.type exception_handler, %function
.set noat .set noat
la $k0, (_esp - SAVE_REGISTERS_SIZE) la $k0, (_esp - SAVE_REGISTERS_SIZE)
sd $zero, ZR_OFFSET($k0) sd $zero, ZR_OFFSET($k0)
@ -153,48 +164,9 @@ exception_restore:
eret eret
.section .text.exception_vector
exception_vector:
.set noreorder
la $k0, exception_handler
jalr $k1, $k0
nop
.equ exception_vector_size, (. - exception_vector)
.set reorder
.section .text.exception_install
exception_install:
.global exception_install
la $t0, exception_vector
li $t1, VECTOR_LOCATION
li $t2, (VECTOR_SIZE * VECTOR_NUM)
add $t2, $t2, $t1
1:
move $t3, $t0
move $t4, $t1
li $t5, exception_vector_size
add $t5, $t5, $t4
2:
lw $t6, 0($t3)
addiu $t3, 4
sw $t6, 0($t4)
addiu $t4, 4
bne $t4, $t5, 2b
addiu $t1, VECTOR_SIZE
bne $t1, $t2, 1b
li $t0, VECTOR_LOCATION
li $t1, (VECTOR_SIZE * VECTOR_NUM)
add $t1, $t0, $t1
3:
cache HIT_INVALIDATE_I, 0($t0)
addiu $t0, CACHE_LINE_SIZE_I
bne $t0, $t1, 3b
jr $ra
.section .text.exception_enable_interrupts .section .text.exception_enable_interrupts
exception_enable_interrupts: exception_enable_interrupts:
.type exception_enable_interrupts, %function
.global exception_enable_interrupts .global exception_enable_interrupts
mfc0 $t0, C0_STATUS mfc0 $t0, C0_STATUS
li $t1, C0_SR_IE li $t1, C0_SR_IE
@ -205,6 +177,7 @@ exception_enable_interrupts:
.section .text.exception_disable_interrupts .section .text.exception_disable_interrupts
exception_disable_interrupts: exception_disable_interrupts:
.type exception_disable_interrupts, %function
.global exception_disable_interrupts .global exception_disable_interrupts
mfc0 $t0, C0_STATUS mfc0 $t0, C0_STATUS
li $t1, ~(C0_SR_IE) li $t1, ~(C0_SR_IE)
@ -215,6 +188,7 @@ exception_disable_interrupts:
.section .text.exception_enable_watchdog .section .text.exception_enable_watchdog
exception_enable_watchdog: exception_enable_watchdog:
.type exception_enable_watchdog, %function
.global exception_enable_watchdog .global exception_enable_watchdog
mtc0 $zero, C0_COUNT mtc0 $zero, C0_COUNT
li $t1, WATCHDOG_TIMEOUT li $t1, WATCHDOG_TIMEOUT
@ -228,6 +202,7 @@ exception_enable_watchdog:
.section .text.exception_disable_watchdog .section .text.exception_disable_watchdog
exception_disable_watchdog: exception_disable_watchdog:
.type exception_disable_watchdog, %function
.global exception_disable_watchdog .global exception_disable_watchdog
mfc0 $t0, C0_STATUS mfc0 $t0, C0_STATUS
li $t1, ~(C0_SR_IM7) li $t1, ~(C0_SR_IM7)

View File

@ -7,7 +7,6 @@
#define EXCEPTION_TRIGGER(code) { asm volatile ("syscall %[c]\n" :: [c] "i" (code)); } #define EXCEPTION_TRIGGER(code) { asm volatile ("syscall %[c]\n" :: [c] "i" (code)); }
void exception_install (void);
void exception_enable_interrupts (void); void exception_enable_interrupts (void);
void exception_disable_interrupts (void); void exception_disable_interrupts (void);
void exception_enable_watchdog (void); void exception_enable_watchdog (void);

View File

@ -16,8 +16,6 @@ void init (init_tv_type_t tv_type, init_reset_type_t reset_type) {
__tv_type = tv_type; __tv_type = tv_type;
__reset_type = reset_type; __reset_type = reset_type;
exception_install();
sc64_unlock(); sc64_unlock();
if (!sc64_check_presence()) { if (!sc64_check_presence()) {