Relocate rodata for some OS related function (#292)

Required moving a struct def to another file, and I renamed a
 struct to something nicer

Signed-off-by: Taggerung <tyler.taggerung@gmail.com>
This commit is contained in:
Tyler McGavran 2023-03-24 02:49:30 -04:00 committed by GitHub
parent 3b8e76054d
commit bd82bf5f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 92 deletions

View File

@ -361,8 +361,8 @@ glabel L800D1668
/* 0D22B0 800D16B0 AD3A0000 */ sw $k0, ($t1)
.L800D16B4:
/* 0D22B4 800D16B4 3C01800F */ lui $at, %hi(D_800EB3B4) # $at, 0x800f
/* 0D22B8 800D16B8 AC3AB3B4 */ sw $k0, %lo(D_800EB3B4)($at)
/* 0D22B4 800D16B4 3C01800F */ lui $at, %hi(__osFaultedThread) # $at, 0x800f
/* 0D22B8 800D16B8 AC3AB3B4 */ sw $k0, %lo(__osFaultedThread)($at)
/* 0D22BC 800D16BC 24090001 */ li $t1, 1
/* 0D22C0 800D16C0 A7490010 */ sh $t1, 0x10($k0)
/* 0D22C4 800D16C4 24090002 */ li $t1, 2

View File

@ -1,55 +0,0 @@
.include "macros.inc"
.section .data
# osPiStartDma .data
#glabel __osPiDevMgr
#.word 0x00000000
#.word 0x00000000
#.word 0x00000000
#.word 0x00000000
#.word 0x00000000
#.word 0x00000000
#.word 0x00000000
#glabel __osPiTable
#.word 0x00000000
#glabel D_800EB360
#.word 0x00000000, 0x00000000, 0x00000000, 0x00000000
glabel D_800EB370
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000
glabel __osHwIntTable
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000
.word 0x00000000, 0x00000000, 0x00000000, 0x00000000
glabel D_800EB3A0
.word 0x00000000, 0xffffffff
glabel __osRunQueue
.word D_800EB3A0
glabel __osActiveQueue
.word D_800EB3A0
glabel __osRunningThread
.word 0x00000000
glabel D_800EB3B4
.word 0x00000000
.balign 16
# glabel __osTimerList
# .word __osBaseTimer
# .word 0x00000000, 0x00000000, 0x00000000

View File

@ -256,7 +256,9 @@ SECTIONS
BUILD_DIR/src/os/osViTable.o(.data);
BUILD_DIR/src/os/osCreatePiManager.o(.data);
BUILD_DIR/src/os/osContInit.o(.data);
BUILD_DIR/data/data_0DD0A0_2_1.o(.data);
BUILD_DIR/src/os/osAiSetNextBuffer.o(.data);
BUILD_DIR/src/os/__osSetHWIntrRoutine.o(.data);
BUILD_DIR/src/os/__osDequeueThread.o(.data);
BUILD_DIR/src/os/osTimer.o(.data);
BUILD_DIR/src/os/__osViInit.o(.data);
BUILD_DIR/src/os/__osPiCreateAccessQueue.o(.data);

View File

@ -1,13 +1,10 @@
#include "libultra_internal.h"
// these don't feel like they belong here
// but it makes the most logical since there was printf data before
// OSThread *D_800EB3A0 = NULL;
// u32 D_80334894 = -1;
// OSThread *__osRunQueue = (OSThread *) &D_800EB3A0;
// OSThread *__osActiveQueue = (OSThread *) &D_800EB3A0;
// OSThread *__osRunningThread = NULL;
// u32 D_803348A4 = 0; // UNKNOWN
OSThreadTail __osThreadTail = {NULL, -1};
OSThread *__osRunQueue = (OSThread *) &__osThreadTail;
OSThread *__osActiveQueue = (OSThread *) &__osThreadTail;
OSThread *__osRunningThread = NULL;
OSThread *__osFaultedThread = NULL;
void __osDequeueThread(OSThread **queue, OSThread *thread) {
register OSThread **a2;

View File

@ -1,6 +1,10 @@
#include "libultra_internal.h"
extern s32 (*__osHwIntTable[])(void);
// Its not clear how big this array should be.
// In order for file alignment to be correct, it needs to be
// at least 5 but no more than 8. Beyond that its not clear
// what its size should be
s32 (*__osHwIntTable[5])(void) = {NULL};
void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void))
{
register u32 saveMask;

View File

@ -3,15 +3,20 @@
#include <ultra64.h>
#include "macros.h"
/*
* This define is needed because the original definitions in __osDequeueThread.c are declared
* seperately instead of part of a single struct, however some code alises over this memory
* assuming a unified structure. To fix this, we declare the full type here and then alias the
* symbol names to the correct members in AVOID_UB.
*/
typedef struct __OSEventState
{
OSMesgQueue *messageQueue;
OSMesg message;
} __OSEventState;
typedef struct __osThreadTail
{
OSThread *next;
OSPri priority;
} OSThreadTail;
// Original OSThread_ListHead definitions
extern OSThread *D_800EB3A0;
extern OSThreadTail __osThreadTail;
extern OSThread *__osActiveQueue;
extern OSThread *__osRunQueue;
extern OSThread *__osRunningThread;

View File

@ -2,8 +2,7 @@
#include "osAi.h"
#include "hardware.h"
// hdwrBugFlag on libreultra
extern u8 D_800EB370; // = 0;
u8 hdwrBugFlag = 0;
/**
* It is worth noting that a previous hardware bug has been fixed by a software
@ -21,14 +20,14 @@ extern u8 D_800EB370; // = 0;
s32 osAiSetNextBuffer(void *buff, u32 len) {
u8 *sp1c = buff;
if (D_800EB370 != 0) {
if (hdwrBugFlag != 0) {
sp1c -= 0x2000;
}
if ((((uintptr_t) buff + len) & 0x3fff) == 0x2000) {
D_800EB370 = 1;
hdwrBugFlag = 1;
} else {
D_800EB370 = 0;
hdwrBugFlag = 0;
}
if (__osAiDeviceBusy()) {

View File

@ -1,8 +1,8 @@
#include "libultra_internal.h"
void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msgBuf, s32 count) {
mq->mtqueue = (OSThread *) &D_800EB3A0; //?
mq->fullqueue = (OSThread *) &D_800EB3A0;
mq->mtqueue = (OSThread *) &__osThreadTail; //?
mq->fullqueue = (OSThread *) &__osThreadTail;
mq->validCount = 0;
mq->first = 0;
mq->msgCount = count;

View File

@ -2,17 +2,6 @@
#define _OSINT_H
#include "libultra_internal.h"
typedef struct __OSEventState
{
OSMesgQueue *messageQueue;
OSMesg message;
} __OSEventState;
extern struct __osThreadTail
{
OSThread *next;
OSPri priority;
} __osThreadTail;
//maybe should be in exceptasm.h?
extern void __osEnqueueAndYield(OSThread **);
extern void __osDequeueThread(OSThread **, OSThread *);