diff --git a/lib/asm/non_matchings/unknown_0D3020/__osResetGlobalIntMask.s b/lib/asm/non_matchings/unknown_0D3020/__osResetGlobalIntMask.s deleted file mode 100644 index b6cb5ad9..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/__osResetGlobalIntMask.s +++ /dev/null @@ -1,26 +0,0 @@ -glabel __osResetGlobalIntMask -/* 0D7100 800D6500 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0D7104 800D6504 AFBF001C */ sw $ra, 0x1c($sp) -/* 0D7108 800D6508 AFA40028 */ sw $a0, 0x28($sp) -/* 0D710C 800D650C 0C034958 */ jal __osDisableInt -/* 0D7110 800D6510 AFB00018 */ sw $s0, 0x18($sp) -/* 0D7114 800D6514 8FAF0028 */ lw $t7, 0x28($sp) -/* 0D7118 800D6518 3C0E800E */ lui $t6, %hi(__OSGlobalIntMask) # $t6, 0x800e -/* 0D711C 800D651C 8DCE38AC */ lw $t6, %lo(__OSGlobalIntMask)($t6) -/* 0D7120 800D6520 2401FBFE */ li $at, -1026 -/* 0D7124 800D6524 01E1C024 */ and $t8, $t7, $at -/* 0D7128 800D6528 0300C827 */ not $t9, $t8 -/* 0D712C 800D652C 00408025 */ move $s0, $v0 -/* 0D7130 800D6530 3C01800E */ lui $at, %hi(__OSGlobalIntMask) # $at, 0x800e -/* 0D7134 800D6534 01D94024 */ and $t0, $t6, $t9 -/* 0D7138 800D6538 AC2838AC */ sw $t0, %lo(__OSGlobalIntMask)($at) -/* 0D713C 800D653C 0C034960 */ jal __osRestoreInt -/* 0D7140 800D6540 02002025 */ move $a0, $s0 -/* 0D7144 800D6544 8FBF001C */ lw $ra, 0x1c($sp) -/* 0D7148 800D6548 8FB00018 */ lw $s0, 0x18($sp) -/* 0D714C 800D654C 27BD0028 */ addiu $sp, $sp, 0x28 -/* 0D7150 800D6550 03E00008 */ jr $ra -/* 0D7154 800D6554 00000000 */ nop - -/* 0D7158 800D6558 00000000 */ nop -/* 0D715C 800D655C 00000000 */ nop diff --git a/lib/asm/non_matchings/unknown_0D3020/__osSpDeviceBusy.s b/lib/asm/non_matchings/unknown_0D3020/__osSpDeviceBusy.s deleted file mode 100644 index a6148e0b..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/__osSpDeviceBusy.s +++ /dev/null @@ -1,16 +0,0 @@ -glabel __osSpDeviceBusy -/* 0D70D0 800D64D0 3C0EA404 */ lui $t6, %hi(SP_STATUS_REG) # $t6, 0xa404 -/* 0D70D4 800D64D4 8DC40010 */ lw $a0, %lo(SP_STATUS_REG)($t6) -/* 0D70D8 800D64D8 27BDFFF8 */ addiu $sp, $sp, -8 -/* 0D70DC 800D64DC 308F001C */ andi $t7, $a0, 0x1c -/* 0D70E0 800D64E0 11E00003 */ beqz $t7, .L800D64F0 -/* 0D70E4 800D64E4 00000000 */ nop -/* 0D70E8 800D64E8 10000002 */ b .L800D64F4 -/* 0D70EC 800D64EC 24020001 */ li $v0, 1 -.L800D64F0: -/* 0D70F0 800D64F0 00001025 */ move $v0, $zero -.L800D64F4: -/* 0D70F4 800D64F4 03E00008 */ jr $ra -/* 0D70F8 800D64F8 27BD0008 */ addiu $sp, $sp, 8 - -/* 0D70FC 800D64FC 00000000 */ nop diff --git a/lib/asm/non_matchings/unknown_0D3020/__osSpGetStatus.s b/lib/asm/non_matchings/unknown_0D3020/__osSpGetStatus.s deleted file mode 100644 index 68a4645c..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/__osSpGetStatus.s +++ /dev/null @@ -1,6 +0,0 @@ -glabel __osSpGetStatus -/* 0D6FF0 800D63F0 3C0EA404 */ lui $t6, 0xa404 -/* 0D6FF4 800D63F4 03E00008 */ jr $ra -/* 0D6FF8 800D63F8 8DC20010 */ lw $v0, 0x10($t6) - -/* 0D6FFC 800D63FC 00000000 */ nop diff --git a/lib/asm/non_matchings/unknown_0D3020/__osSpRawStartDma.s b/lib/asm/non_matchings/unknown_0D3020/__osSpRawStartDma.s deleted file mode 100644 index 33e5605a..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/__osSpRawStartDma.s +++ /dev/null @@ -1,42 +0,0 @@ -glabel __osSpRawStartDma -/* 0D7040 800D6440 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0D7044 800D6444 AFBF0014 */ sw $ra, 0x14($sp) -/* 0D7048 800D6448 AFA40018 */ sw $a0, 0x18($sp) -/* 0D704C 800D644C AFA5001C */ sw $a1, 0x1c($sp) -/* 0D7050 800D6450 AFA60020 */ sw $a2, 0x20($sp) -/* 0D7054 800D6454 0C035934 */ jal __osSpDeviceBusy -/* 0D7058 800D6458 AFA70024 */ sw $a3, 0x24($sp) -/* 0D705C 800D645C 10400003 */ beqz $v0, .L800D646C -/* 0D7060 800D6460 00000000 */ nop -/* 0D7064 800D6464 10000015 */ b .L800D64BC -/* 0D7068 800D6468 2402FFFF */ li $v0, -1 -.L800D646C: -/* 0D706C 800D646C 8FAE001C */ lw $t6, 0x1c($sp) -/* 0D7070 800D6470 3C0FA404 */ lui $t7, 0xa404 -/* 0D7074 800D6474 ADEE0000 */ sw $t6, ($t7) -/* 0D7078 800D6478 0C03233C */ jal osVirtualToPhysical -/* 0D707C 800D647C 8FA40020 */ lw $a0, 0x20($sp) -/* 0D7080 800D6480 3C18A404 */ lui $t8, %hi(SP_DRAM_ADDR_REG) # $t8, 0xa404 -/* 0D7084 800D6484 AF020004 */ sw $v0, %lo(SP_DRAM_ADDR_REG)($t8) -/* 0D7088 800D6488 8FB90018 */ lw $t9, 0x18($sp) -/* 0D708C 800D648C 17200006 */ bnez $t9, .L800D64A8 -/* 0D7090 800D6490 00000000 */ nop -/* 0D7094 800D6494 8FA80024 */ lw $t0, 0x24($sp) -/* 0D7098 800D6498 3C0AA404 */ lui $t2, %hi(SP_WR_LEN_REG) # $t2, 0xa404 -/* 0D709C 800D649C 2509FFFF */ addiu $t1, $t0, -1 -/* 0D70A0 800D64A0 10000005 */ b .L800D64B8 -/* 0D70A4 800D64A4 AD49000C */ sw $t1, %lo(SP_WR_LEN_REG)($t2) -.L800D64A8: -/* 0D70A8 800D64A8 8FAB0024 */ lw $t3, 0x24($sp) -/* 0D70AC 800D64AC 3C0DA404 */ lui $t5, %hi(SP_RD_LEN_REG) # $t5, 0xa404 -/* 0D70B0 800D64B0 256CFFFF */ addiu $t4, $t3, -1 -/* 0D70B4 800D64B4 ADAC0008 */ sw $t4, %lo(SP_RD_LEN_REG)($t5) -.L800D64B8: -/* 0D70B8 800D64B8 00001025 */ move $v0, $zero -.L800D64BC: -/* 0D70BC 800D64BC 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D70C0 800D64C0 27BD0018 */ addiu $sp, $sp, 0x18 -/* 0D70C4 800D64C4 03E00008 */ jr $ra -/* 0D70C8 800D64C8 00000000 */ nop - -/* 0D70CC 800D64CC 00000000 */ nop diff --git a/lib/asm/non_matchings/unknown_0D3020/__osSpSetPc.s b/lib/asm/non_matchings/unknown_0D3020/__osSpSetPc.s deleted file mode 100644 index 21c1baff..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/__osSpSetPc.s +++ /dev/null @@ -1,20 +0,0 @@ -glabel __osSpSetPc -/* 0D7000 800D6400 3C0EA404 */ lui $t6, %hi(SP_STATUS_REG) # $t6, 0xa404 -/* 0D7004 800D6404 8DC50010 */ lw $a1, %lo(SP_STATUS_REG)($t6) -/* 0D7008 800D6408 27BDFFF8 */ addiu $sp, $sp, -8 -/* 0D700C 800D640C 30AF0001 */ andi $t7, $a1, 1 -/* 0D7010 800D6410 15E00003 */ bnez $t7, .L800D6420 -/* 0D7014 800D6414 00000000 */ nop -/* 0D7018 800D6418 10000004 */ b .L800D642C -/* 0D701C 800D641C 2402FFFF */ li $v0, -1 -.L800D6420: -/* 0D7020 800D6420 3C18A408 */ lui $t8, 0xa408 -/* 0D7024 800D6424 AF040000 */ sw $a0, ($t8) -/* 0D7028 800D6428 00001025 */ move $v0, $zero -.L800D642C: -/* 0D702C 800D642C 03E00008 */ jr $ra -/* 0D7030 800D6430 27BD0008 */ addiu $sp, $sp, 8 - -/* 0D7034 800D6434 00000000 */ nop -/* 0D7038 800D6438 00000000 */ nop -/* 0D703C 800D643C 00000000 */ nop diff --git a/lib/asm/non_matchings/unknown_0D3020/osEPiRawWriteIo.s b/lib/asm/non_matchings/unknown_0D3020/osEPiRawWriteIo.s deleted file mode 100644 index 6fc35ae7..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/osEPiRawWriteIo.s +++ /dev/null @@ -1,24 +0,0 @@ -glabel osEPiRawWriteIo -/* 0D7160 800D6560 3C0EA460 */ lui $t6, %hi(PI_STATUS_REG) # $t6, 0xa460 -/* 0D7164 800D6564 8DC70010 */ lw $a3, %lo(PI_STATUS_REG)($t6) -/* 0D7168 800D6568 27BDFFF8 */ addiu $sp, $sp, -8 -/* 0D716C 800D656C 30EF0003 */ andi $t7, $a3, 3 -/* 0D7170 800D6570 11E00006 */ beqz $t7, .L800D658C -/* 0D7174 800D6574 00000000 */ nop -.L800D6578: -/* 0D7178 800D6578 3C18A460 */ lui $t8, %hi(PI_STATUS_REG) # $t8, 0xa460 -/* 0D717C 800D657C 8F070010 */ lw $a3, %lo(PI_STATUS_REG)($t8) -/* 0D7180 800D6580 30F90003 */ andi $t9, $a3, 3 -/* 0D7184 800D6584 1720FFFC */ bnez $t9, .L800D6578 -/* 0D7188 800D6588 00000000 */ nop -.L800D658C: -/* 0D718C 800D658C 8C88000C */ lw $t0, 0xc($a0) -/* 0D7190 800D6590 3C01A000 */ lui $at, 0xa000 -/* 0D7194 800D6594 27BD0008 */ addiu $sp, $sp, 8 -/* 0D7198 800D6598 01054825 */ or $t1, $t0, $a1 -/* 0D719C 800D659C 01215025 */ or $t2, $t1, $at -/* 0D71A0 800D65A0 AD460000 */ sw $a2, ($t2) -/* 0D71A4 800D65A4 03E00008 */ jr $ra -/* 0D71A8 800D65A8 00001025 */ move $v0, $zero - -/* 0D71AC 800D65AC 00000000 */ nop diff --git a/lib/src/os/__osResetGlobalIntMask.c b/lib/src/os/__osResetGlobalIntMask.c new file mode 100644 index 00000000..fdf01e98 --- /dev/null +++ b/lib/src/os/__osResetGlobalIntMask.c @@ -0,0 +1,16 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D6500 */ + +#include "libultra_internal.h" + +extern u32 __OSGlobalIntMask; + +void __osResetGlobalIntMask(OSHWIntr interrupt) { + register u32 saveMask = __osDisableInt(); + + //not sure about these constants, SR_IBIT3 is external level 3 INT0, which I think corresponds to the rcp + //os.h has several masks defined that end in 401 but non that are just 401 + __OSGlobalIntMask &= ~(interrupt & ~(SR_IBIT3 | SR_IE)); + + __osRestoreInt(saveMask); +} diff --git a/lib/src/os/__osSpDeviceBusy.c b/lib/src/os/__osSpDeviceBusy.c new file mode 100644 index 00000000..a9662071 --- /dev/null +++ b/lib/src/os/__osSpDeviceBusy.c @@ -0,0 +1,11 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D64D0 */ + +#include "libultra_internal.h" + +int __osSpDeviceBusy() { + register u32 stat = IO_READ(SP_STATUS_REG); + if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) + return 1; + return 0; +} diff --git a/lib/src/os/__osSpGetStatus.c b/lib/src/os/__osSpGetStatus.c new file mode 100644 index 00000000..81e8e284 --- /dev/null +++ b/lib/src/os/__osSpGetStatus.c @@ -0,0 +1,8 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D63EC */ + +#include "libultra_internal.h" + +u32 __osSpGetStatus() { + return IO_READ(SP_STATUS_REG); +} diff --git a/lib/src/os/__osSpRawStartDma.c b/lib/src/os/__osSpRawStartDma.c new file mode 100644 index 00000000..a887f301 --- /dev/null +++ b/lib/src/os/__osSpRawStartDma.c @@ -0,0 +1,16 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D6440 */ + +#include "libultra_internal.h" + +s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) { + if (__osSpDeviceBusy()) + return -1; + IO_WRITE(SP_MEM_ADDR_REG, devAddr); + IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); + if (direction == OS_READ) + IO_WRITE(SP_WR_LEN_REG, size - 1); + else + IO_WRITE(SP_RD_LEN_REG, size - 1); + return 0; +} diff --git a/lib/src/os/__osSpSetPc.c b/lib/src/os/__osSpSetPc.c new file mode 100644 index 00000000..a18f4c55 --- /dev/null +++ b/lib/src/os/__osSpSetPc.c @@ -0,0 +1,14 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D63FC */ + +#include "libultra_internal.h" + +s32 __osSpSetPc(u32 data) { + register u32 stat = IO_READ(SP_STATUS_REG); + if (!(stat & SP_STATUS_HALT)) + return -1; + else { + IO_WRITE(SP_PC_REG, data); + } + return 0; +} diff --git a/lib/src/os/osEPiRawWriteIo.c b/lib/src/os/osEPiRawWriteIo.c new file mode 100644 index 00000000..cf7311a3 --- /dev/null +++ b/lib/src/os/osEPiRawWriteIo.c @@ -0,0 +1,15 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D6560 */ + +#include "libultra_internal.h" +#include "piint.h" + +s32 osEPiRawWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) { + register u32 stat = IO_READ(PI_STATUS_REG); + + while (stat & PI_STATUS_ERROR) + stat = IO_READ(PI_STATUS_REG); + + IO_WRITE(pihandle->baseAddress | devAddr, data); + return 0; +} diff --git a/lib/src/os/piint.h b/lib/src/os/piint.h index 0c4b300c..9c3f06b8 100644 --- a/lib/src/os/piint.h +++ b/lib/src/os/piint.h @@ -91,6 +91,12 @@ #define LEO_ERROR_24 24 //no reference position found? #define LEO_ERROR_29 29 // +/* + * PI/EPI + */ +#define PI_DOMAIN1 0 +#define PI_DOMAIN2 1 + extern OSDevMgr __osPiDevMgr; extern OSPiHandle *__osCurrentHandle[2]; extern OSPiHandle CartRomHandle; diff --git a/lib/src/os/unknown_0D6C90.c b/lib/src/os/unknown_0D6C90.c deleted file mode 100644 index 39e7d2b2..00000000 --- a/lib/src/os/unknown_0D6C90.c +++ /dev/null @@ -1,13 +0,0 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800D63EC */ - -#include "macros.h" -#include "libultra_internal.h" -#include "viint.h" - -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSpGetStatus.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSpSetPc.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSpRawStartDma.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSpDeviceBusy.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osResetGlobalIntMask.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/osEPiRawWriteIo.s")