2018-08-18 10:44:23 -07:00
|
|
|
// "kernel" constants:
|
|
|
|
constant K_BASE(0x8000) // k0 is set to this.
|
|
|
|
|
|
|
|
constant K_DUMP(0x0400) // we save registers and state here
|
|
|
|
// when handling interrupts
|
|
|
|
|
|
|
|
constant K_REASON(0x0600)
|
|
|
|
constant K_CAUSE(0x0604)
|
|
|
|
constant K_STATUS(0x0608)
|
2018-08-23 20:18:48 -07:00
|
|
|
constant K_IN_ISR(0x060C)
|
2018-08-18 10:44:23 -07:00
|
|
|
constant K_EPC(0x0610)
|
|
|
|
constant K_ERRORPC(0x0614)
|
|
|
|
constant K_BADVADDR(0x0618)
|
2018-08-23 23:17:50 -07:00
|
|
|
constant K_HISTORY(0x061C)
|
2018-08-18 10:44:23 -07:00
|
|
|
|
|
|
|
constant K_64DRIVE_MAGIC(0x0700)
|
|
|
|
constant K_CI_BASE(0x0704)
|
|
|
|
constant K_CONSOLE_AVAILABLE(0x0708)
|
|
|
|
|
|
|
|
constant K_STACK(0x0C00 - 0x10)
|
|
|
|
constant K_XXD(0x0C00) // size: 0x400 (any larger and you overwrite kernel code)
|
|
|
|
|
|
|
|
// note this gets subtracted by 0x10 and the stack grows *backwards.*
|
|
|
|
constant K_STACK_INIT_BASE(0x803F)
|
|
|
|
|
|
|
|
// internal interrupt enum: (0 means no known interrupt/exception)
|
|
|
|
constant K_INT_TLB_REFILL(1)
|
|
|
|
constant K_INT_XTLB_REFILL(2)
|
|
|
|
constant K_INT_CACHE_ERROR(3)
|
|
|
|
constant K_INT_OTHER(4)
|
|
|
|
|
2018-08-23 23:19:52 -07:00
|
|
|
macro DumpString(name) {
|
2018-08-19 17:13:11 -07:00
|
|
|
if K_DEBUG {
|
2018-08-18 10:44:23 -07:00
|
|
|
// does not include error/console-checking!
|
|
|
|
// note: this first instruction must be okay to be in a delay slot.
|
|
|
|
la a2, {name}
|
|
|
|
jal Drive64WriteDirect
|
|
|
|
lli a3, {name}X - {name}
|
|
|
|
}
|
2018-08-19 17:13:11 -07:00
|
|
|
}
|
2018-08-18 10:44:23 -07:00
|
|
|
|
2018-08-23 23:19:52 -07:00
|
|
|
macro MaybeDumpString(str) {
|
|
|
|
if K_DEBUG {
|
|
|
|
lui t0, K_BASE
|
|
|
|
lw t1, K_CONSOLE_AVAILABLE(t0)
|
|
|
|
beqz t1,+
|
|
|
|
DumpString({str})
|
|
|
|
+
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-18 10:44:23 -07:00
|
|
|
macro KMaybeDumpString(str) {
|
2018-08-19 17:13:11 -07:00
|
|
|
if K_DEBUG {
|
2018-08-18 10:44:23 -07:00
|
|
|
lw t1, K_CONSOLE_AVAILABLE(k0)
|
|
|
|
beqz t1,+
|
2018-08-23 23:19:52 -07:00
|
|
|
DumpString({str})
|
2018-08-18 10:44:23 -07:00
|
|
|
+
|
|
|
|
}
|
2018-08-19 17:13:11 -07:00
|
|
|
}
|
2018-08-18 10:44:23 -07:00
|
|
|
|
2018-08-19 04:46:11 -07:00
|
|
|
macro KS(name, str) {
|
2018-08-18 10:44:23 -07:00
|
|
|
align(16)
|
|
|
|
{name}:
|
|
|
|
db {str}, 0
|
|
|
|
align(16)
|
|
|
|
{name}X:
|
|
|
|
}
|
|
|
|
|
2018-08-19 04:46:11 -07:00
|
|
|
macro KSL(name, str) {
|
2018-08-18 10:44:23 -07:00
|
|
|
align(16)
|
|
|
|
{name}:
|
|
|
|
db {str}, 10, 0
|
|
|
|
align(16)
|
|
|
|
{name}X:
|
|
|
|
}
|