Preliminary fixes for boot/libultra (#1032)

* Preliminary fixes

* Missed a NULL
This commit is contained in:
Tharo
2021-11-28 12:50:35 +00:00
committed by GitHub
parent 09f0dc84b8
commit 982e7be1f7
31 changed files with 68 additions and 88 deletions

View File

@@ -7,21 +7,23 @@
.section .text
.set BOOT_STACK_SIZE, 0x400
glabel entrypoint # 0x80000400
lui $t0, %hi(_bootSegmentBssStart) # $t0, 0x8001
addiu $t0, %lo(_bootSegmentBssStart) # addiu $t0, $t0, 0x2370
li $t1, %lo(_bootSegmentBssSize) # li $t1, 0x4A30
lui $t0, %hi(_bootSegmentBssStart)
addiu $t0, %lo(_bootSegmentBssStart)
li $t1, %lo(_bootSegmentBssSize)
.L8000040C:
addi $t1, $t1, -8
sw $zero, ($t0)
sw $zero, 4($t0)
bnez $t1, .L8000040C
addi $t0, $t0, 8
lui $t2, %hi(bootproc) # $t2, 0x8000
lui $sp, %hi(gMainThread) # $sp, 0x8001
addiu $t2, %lo(bootproc) # addiu $t2, $t2, 0x0498
lui $t2, %hi(bootproc)
lui $sp, %hi(sBootThreadStack + BOOT_STACK_SIZE)
addiu $t2, %lo(bootproc)
jr $t2
addiu $sp, %lo(gMainThread) # addiu $sp, $sp, 0x2D60
addiu $sp, %lo(sBootThreadStack + BOOT_STACK_SIZE)
nop
nop
nop

View File

@@ -49,13 +49,13 @@ glabel osInvalDCache
/* 006E84 80006284 00000000 */ nop
.L80006288:
/* 006E88 80006288 3C088000 */ lui $t0, %hi(D_80000010) # $t0, 0x8000
/* 006E88 80006288 3C088000 */ lui $t0, 0x8000
/* 006E8C 8000628C 010B4821 */ addu $t1, $t0, $t3
/* 006E90 80006290 2529FFF0 */ addiu $t1, $t1, -0x10
.L80006294:
/* 006E94 80006294 BD010000 */ cache 1, ($t0)
/* 006E98 80006298 0109082B */ sltu $at, $t0, $t1
/* 006E9C 8000629C 1420FFFD */ bnez $at, .L80006294
/* 006EA0 800062A0 25080010 */ addiu $t0, %lo(D_80000010) # addiu $t0, $t0, 0x10
/* 006EA0 800062A0 25080010 */ addiu $t0, 0x10
/* 006EA4 800062A4 03E00008 */ jr $ra
/* 006EA8 800062A8 00000000 */ nop

View File

@@ -34,13 +34,13 @@ glabel osInvalICache
/* 006D9C 8000619C 00000000 */ nop
.L800061A0:
/* 006DA0 800061A0 3C088000 */ lui $t0, %hi(D_80000020) # $t0, 0x8000
/* 006DA0 800061A0 3C088000 */ lui $t0, 0x8000
/* 006DA4 800061A4 010B4821 */ addu $t1, $t0, $t3
/* 006DA8 800061A8 2529FFE0 */ addiu $t1, $t1, -0x20
.L800061AC:
/* 006DAC 800061AC BD000000 */ cache 0, ($t0)
/* 006DB0 800061B0 0109082B */ sltu $at, $t0, $t1
/* 006DB4 800061B4 1420FFFD */ bnez $at, .L800061AC
/* 006DB8 800061B8 25080020 */ addiu $t0, %lo(D_80000020) # addiu $t0, $t0, 0x20
/* 006DB8 800061B8 25080020 */ addiu $t0, 0x20
/* 006DBC 800061BC 03E00008 */ jr $ra
/* 006DC0 800061C0 00000000 */ nop

View File

@@ -34,13 +34,13 @@ glabel osWritebackDCache
/* 00530C 8000470C 00000000 */ nop
.L80004710:
/* 005310 80004710 3C088000 */ lui $t0, %hi(D_80000010) # $t0, 0x8000
/* 005310 80004710 3C088000 */ lui $t0, 0x8000
/* 005314 80004714 010B4821 */ addu $t1, $t0, $t3
/* 005318 80004718 2529FFF0 */ addiu $t1, $t1, -0x10
.L8000471C:
/* 00531C 8000471C BD010000 */ cache 1, ($t0)
/* 005320 80004720 0109082B */ sltu $at, $t0, $t1
/* 005324 80004724 1420FFFD */ bnez $at, .L8000471C
/* 005328 80004728 25080010 */ addiu $t0, %lo(D_80000010) # addiu $t0, $t0, 0x10
/* 005328 80004728 25080010 */ addiu $t0, 0x10
/* 00532C 8000472C 03E00008 */ jr $ra
/* 005330 80004730 00000000 */ nop

View File

@@ -10,7 +10,7 @@
.balign 16
glabel osWritebackDCacheAll
/* B7D630 80106490 3C088000 */ lui $t0, %hi(D_80000010) # $t0, 0x8000
/* B7D630 80106490 3C088000 */ lui $t0, 0x8000
/* B7D634 80106494 240A2000 */ li $t2, 8192
/* B7D638 80106498 010A4821 */ addu $t1, $t0, $t2
/* B7D63C 8010649C 2529FFF0 */ addiu $t1, $t1, -0x10
@@ -18,6 +18,6 @@ glabel osWritebackDCacheAll
/* B7D640 801064A0 BD010000 */ cache 1, ($t0)
/* B7D644 801064A4 0109082B */ sltu $at, $t0, $t1
/* B7D648 801064A8 1420FFFD */ bnez $at, .L801064A0
/* B7D64C 801064AC 25080010 */ addiu $t0, %lo(D_80000010) # addiu $t0, $t0, 0x10
/* B7D64C 801064AC 25080010 */ addiu $t0, 0x10
/* B7D650 801064B0 03E00008 */ jr $ra
/* B7D654 801064B4 00000000 */ nop

View File

@@ -160,8 +160,8 @@ OSViContext* __osViGetCurrentContext(void);
void osStartThread(OSThread* thread);
void osViSetYScale(f32 scale);
void osViSetXScale(f32 value);
void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg);
void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg);
void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* sp);
void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handlerOut)(void), void** spOut);
void __osSetWatchLo(u32);
EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params);

View File

@@ -64,7 +64,7 @@
#define PI_STATUS_BUSY 0x1
#define PI_STATUS_IOBUSY 0x2
#define PI_STATUS_ERROR 0x3
#define PI_STATUS_ERROR 0x4
#define PI_STATUS_RESET_CONTROLLER 0x1
#define PI_STATUS_CLEAR_INTR 0x2

View File

@@ -12,8 +12,8 @@ typedef struct {
} OSMgrArgs; // size = 0x1C
typedef struct {
/* 0x00 */ OSMesgQueue* queue;
/* 0x04 */ OSMesg msg;
/* 0x00 */ s32 (*handler)(void);
/* 0x04 */ void* sp;
} __osHwInt; // size = 0x08
typedef struct {

View File

@@ -2,5 +2,6 @@
#define ULTRA64_INTERRUPT_H
typedef u32 OSIntMask;
typedef u32 OSHWIntr;
#endif

View File

@@ -44,16 +44,16 @@ typedef struct {
} __OSThreadprofile; // size = 0x10
typedef struct OSThread {
/*0x00*/ struct OSThread* next;
/*0x04*/ OSPri priority;
/*0x08*/ struct OSThread** queue;
/*0x0C*/ struct OSThread* tlnext;
/*0x10*/ u16 state;
/*0x12*/ u16 flags;
/*0x14*/ OSId id;
/*0x18*/ s32 fp;
/*0x1C*/ __OSThreadprofile* thprof;
/*0x20*/ __OSThreadContext context;
/* 0x00 */ struct OSThread* next;
/* 0x04 */ OSPri priority;
/* 0x08 */ struct OSThread** queue;
/* 0x0C */ struct OSThread* tlnext;
/* 0x10 */ u16 state;
/* 0x12 */ u16 flags;
/* 0x14 */ OSId id;
/* 0x18 */ s32 fp;
/* 0x1C */ __OSThreadprofile* thprof;
/* 0x20 */ __OSThreadContext context;
} OSThread; // size = 0x1B0
#endif

View File

@@ -14,17 +14,11 @@ extern Gfx D_060257B8[];
extern Gfx D_0602A738[];
extern Gfx D_0602CB48[];
//extern ? D_80000004;
//extern ? D_80000008;
//extern ? D_8000000C;
//extern ? D_80000010;
//extern ? D_80000020;
extern u32 osTvType;
extern u32 osRomBase;
extern u32 osResetType;
extern u32 osMemSize;
extern u8 osAppNmiBuffer[];
extern u8 osAppNmiBuffer[0x40];
extern u8 D_80009320[];
extern u8 D_800093F0[];

View File

@@ -1,7 +1,7 @@
#include "global.h"
#include "ultra64/internal.h"
void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg) {
*outQueue = __osHwIntTable[idx].queue;
*outMsg = __osHwIntTable[idx].msg;
void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handlerOut)(void), void** spOut) {
*handlerOut = __osHwIntTable[interrupt].handler;
*spOut = __osHwIntTable[interrupt].sp;
}

View File

@@ -1,7 +1,7 @@
#include "global.h"
void __osResetGlobalIntMask(u32 mask) {
register s32 prevInt = __osDisableInt();
register u32 prevInt = __osDisableInt();
__OSGlobalIntMask &= ~(mask & ~0x401);
__osRestoreInt(prevInt);

View File

@@ -1,7 +1,7 @@
#include "global.h"
void __osSetGlobalIntMask(u32 mask) {
register s32 prevInt = __osDisableInt();
register u32 prevInt = __osDisableInt();
__OSGlobalIntMask |= mask;
__osRestoreInt(prevInt);

View File

@@ -1,11 +1,11 @@
#include "global.h"
#include "ultra64/internal.h"
void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg) {
register s32 prevInt = __osDisableInt();
void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* sp) {
register u32 prevInt = __osDisableInt();
__osHwIntTable[idx].queue = queue;
__osHwIntTable[idx].msg = msg;
__osHwIntTable[interrupt].handler = handler;
__osHwIntTable[interrupt].sp = sp;
__osRestoreInt(prevInt);
}

View File

@@ -58,7 +58,7 @@ void __osInitialize_common(void) {
osClockRate = (u64)((osClockRate * 3ll) / 4ull);
if (!osResetType) {
bzero(osAppNmiBuffer, 0x40);
bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer));
}
if (osTvType == OS_TV_PAL) {

View File

@@ -1,7 +1,7 @@
#include "global.h"
void osDestroyThread(OSThread* thread) {
register s32 prevInt = __osDisableInt();
register u32 prevInt = __osDisableInt();
register OSThread* s1;
register OSThread* s2;

View File

@@ -1,7 +1,7 @@
#include "global.h"
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) {
register s32 prevInt = __osDisableInt();
register u32 prevInt = __osDisableInt();
while (mq->validCount >= mq->msgCount) {
if (flag == OS_MESG_BLOCK) {

View File

@@ -1,7 +1,7 @@
#include "global.h"
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) {
register s32 prevInt = __osDisableInt();
register u32 prevInt = __osDisableInt();
while (mq->validCount == 0) {
if (flag == OS_MESG_NOBLOCK) {

View File

@@ -4,7 +4,7 @@ s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data) {
s32 status;
OSPiHandle* curHandle;
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) {
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
;
}

Some files were not shown because too many files have changed in this diff Show More