Idle + Main bss and cleanup (#1292)

* Idle bss and cleanup

* main bss and cleanup

* format

* Remove pad comment about sAudioMgr

* PR

* Missed a couple size_t changes

* unused pads

* static
This commit is contained in:
Derek Hensley
2023-06-25 17:18:50 -07:00
committed by GitHub
parent a2c2c45a0e
commit 22035890fa
33 changed files with 199 additions and 175 deletions
+1
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "audiomgr.h"
#include "idle.h"
#include "system_malloc.h"
#include "z64debug_text.h"
#include "z64rumble.h"
+1
View File
@@ -1,6 +1,7 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "buffers.h"
#include "idle.h"
#include "system_malloc.h"
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
#include "overlays/gamestates/ovl_file_choose/z_file_select.h"
+45 -36
View File
@@ -1,34 +1,41 @@
/**
* This file has unmigrated bss. It is not practical to migrate it until we have a better way of dealing with bss
* reordering than just prevent_bss_reordering.h: there is too much of it to control, and it cannot be split into
* separate files since most of it is at addresses ending in 8.
*/
#include "global.h"
#include "audiomgr.h"
#include "buffers.h"
#include "idle.h"
#include "irqmgr.h"
#include "padmgr.h"
#include "scheduler.h"
#include "stack.h"
#include "stackcheck.h"
#include "system_heap.h"
#include "z64thread.h"
extern OSMesgQueue sSiIntMsgQ;
extern OSMesg sSiIntMsgBuf[1];
extern u32 gSegments[NUM_SEGMENTS];
extern SchedContext gSchedContext;
extern IrqMgrClient irqClient;
extern OSMesgQueue irqMgrMsgQ;
extern OSMesg irqMgrMsgBuf[60];
extern OSThread gGraphThread;
extern STACK(sGraphStack, 0x1800);
extern STACK(sSchedStack, 0x600);
extern STACK(sAudioStack, 0x800);
extern STACK(sPadMgrStack, 0x500);
extern StackEntry sGraphStackInfo;
extern StackEntry sSchedStackInfo;
extern StackEntry sAudioStackInfo;
extern StackEntry sPadMgrStackInfo;
extern AudioMgr sAudioMgr;
// Variables are put before most headers as a hacky way to bypass bss reordering
OSMesgQueue sSerialEventQueue;
OSMesg sSerialMsgBuf[1];
u32 gSegments[NUM_SEGMENTS];
SchedContext gSchedContext;
IrqMgrClient sIrqClient;
OSMesgQueue sIrqMgrMsgQueue;
OSMesg sIrqMgrMsgBuf[60];
OSThread gGraphThread;
STACK(sGraphStack, 0x1800);
STACK(sSchedStack, 0x600);
STACK(sAudioStack, 0x800);
STACK(sPadMgrStack, 0x500);
StackEntry sGraphStackInfo;
StackEntry sSchedStackInfo;
StackEntry sAudioStackInfo;
StackEntry sPadMgrStackInfo;
AudioMgr sAudioMgr;
static s32 sBssPad;
PadMgr gPadMgr;
#include "main.h"
#include "buffers.h"
#include "global.h"
s32 gScreenWidth = SCREEN_WIDTH;
s32 gScreenHeight = SCREEN_HEIGHT;
size_t gSystemHeapSize = 0;
void Main(void* arg) {
intptr_t fb;
@@ -46,30 +53,31 @@ void Main(void* arg) {
sysHeap = gSystemHeap;
fb = 0x80780000;
startHeapSize = fb - sysHeap;
SystemHeap_Init(sysHeap, startHeapSize);
gSystemHeapSize = fb - sysHeap;
SystemHeap_Init(sysHeap, gSystemHeapSize);
Regs_Init();
R_ENABLE_ARENA_DBG = 0;
osCreateMesgQueue(&sSiIntMsgQ, sSiIntMsgBuf, ARRAY_COUNT(sSiIntMsgBuf));
osSetEventMesg(OS_EVENT_SI, &sSiIntMsgQ, NULL);
osCreateMesgQueue(&sSerialEventQueue, sSerialMsgBuf, ARRAY_COUNT(sSerialMsgBuf));
osSetEventMesg(OS_EVENT_SI, &sSerialEventQueue, NULL);
osCreateMesgQueue(&irqMgrMsgQ, irqMgrMsgBuf, ARRAY_COUNT(irqMgrMsgBuf));
osCreateMesgQueue(&sIrqMgrMsgQueue, sIrqMgrMsgBuf, ARRAY_COUNT(sIrqMgrMsgBuf));
StackCheck_Init(&sSchedStackInfo, sSchedStack, STACK_TOP(sSchedStack), 0, 0x100, "sched");
Sched_Init(&gSchedContext, STACK_TOP(sSchedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr);
Sched_Init(&gSchedContext, STACK_TOP(sSchedStack), Z_PRIORITY_SCHED, gViConfigModeType, 1, &gIrqMgr);
CIC6105_AddRomInfoFaultPage();
IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQ);
IrqMgr_AddClient(&gIrqMgr, &sIrqClient, &sIrqMgrMsgQueue);
StackCheck_Init(&sAudioStackInfo, sAudioStack, STACK_TOP(sAudioStack), 0, 0x100, "audio");
AudioMgr_Init(&sAudioMgr, STACK_TOP(sAudioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr);
AudioMgr_Init(&sAudioMgr, STACK_TOP(sAudioStack), Z_PRIORITY_AUDIOMGR, Z_THREAD_ID_AUDIOMGR, &gSchedContext,
&gIrqMgr);
StackCheck_Init(&sPadMgrStackInfo, sPadMgrStack, STACK_TOP(sPadMgrStack), 0, 0x100, "padmgr");
PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, STACK_TOP(sPadMgrStack));
PadMgr_Init(&sSerialEventQueue, &gIrqMgr, Z_THREAD_ID_PADMGR, Z_PRIORITY_PADMGR, STACK_TOP(sPadMgrStack));
AudioMgr_Unlock(&sAudioMgr);
@@ -81,7 +89,7 @@ void Main(void* arg) {
while (!exit) {
msg = NULL;
osRecvMesg(&irqMgrMsgQ, (OSMesg*)&msg, OS_MESG_BLOCK);
osRecvMesg(&sIrqMgrMsgQueue, (OSMesg*)&msg, OS_MESG_BLOCK);
if (msg == NULL) {
break;
}
@@ -90,12 +98,13 @@ void Main(void* arg) {
case OS_SC_PRE_NMI_MSG:
Nmi_SetPrenmiStart();
break;
case OS_SC_NMI_MSG:
exit = true;
break;
}
}
IrqMgr_RemoveClient(&gIrqMgr, &irqClient);
IrqMgr_RemoveClient(&gIrqMgr, &sIrqClient);
osDestroyThread(&gGraphThread);
}
+5 -6
View File
@@ -1,5 +1,6 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "idle.h"
#include "stackcheck.h"
#include "z64thread.h"
@@ -20,14 +21,12 @@ u64* gAudioSPDataPtr;
u32 gAudioSPDataSize;
void Sched_SwapFramebuffer(CfbInfo* cfbInfo) {
s32 one = 1;
if (cfbInfo->swapBuffer != NULL) {
osViSwapBuffer(cfbInfo->swapBuffer);
cfbInfo->updateRate2 = cfbInfo->updateRate;
if ((SREG(62) == 0) && (cfbInfo->viMode != NULL)) {
D_80096B20 = one;
D_80096B20 = 1;
osViSetMode(cfbInfo->viMode);
osViSetSpecialFeatures(cfbInfo->features);
osViSetXScale(cfbInfo->xScale);
@@ -43,7 +42,7 @@ void Sched_RetraceUpdateFramebuffer(SchedContext* sched, CfbInfo* cfbInfo) {
sched->shouldUpdateVi = false;
if (gIrqMgrResetStatus == 0) {
ViConfig_UpdateVi(0);
ViConfig_UpdateVi(false);
}
}
Sched_SwapFramebuffer(cfbInfo);
@@ -53,7 +52,7 @@ void Sched_HandleReset(SchedContext* sched) {
}
void Sched_HandleStop(SchedContext* sched) {
ViConfig_UpdateVi(1);
ViConfig_UpdateVi(true);
}
/**
@@ -600,7 +599,7 @@ void Sched_ThreadEntry(void* arg) {
* Registers an IrqClient for the thread and fault client for the SchedContext.
* Directs the OS to send SP and DP OS messages to interruptQ when the RSP or RDP signal task completion.
*/
void Sched_Init(SchedContext* sched, void* stack, OSPri pri, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr) {
void Sched_Init(SchedContext* sched, void* stack, OSPri pri, u8 viModeType, UNK_TYPE arg4, IrqMgr* irqMgr) {
bzero(sched, sizeof(SchedContext));
sched->shouldUpdateVi = true;
-6
View File
@@ -4,12 +4,6 @@
*/
#include "global.h"
extern u64 rspbootTextStart[];
extern u64 rspbootTextEnd[];
extern u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[];
extern u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[];
u64* initialgspUcodeText = gspF3DZEX2_NoN_PosLight_fifoTextStart;
u64* initialgspUcodeData = gspF3DZEX2_NoN_PosLight_fifoDataStart;
+1
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "buffers.h"
#include "idle.h"
#include "z64bombers_notebook.h"
#include "z64debug_display.h"
#include "z64quake.h"
+1 -1
View File
@@ -8,7 +8,7 @@ void PreNMI_Stop(PreNMIState* this) {
void PreNMI_Update(PreNMIState* this) {
if (this->timer == 0) {
ViConfig_UpdateVi(1);
ViConfig_UpdateVi(true);
PreNMI_Stop(this);
} else {
this->timer--;
+1 -1
View File
@@ -4,7 +4,7 @@
// 60 is an arbitrary number which specifies the max amount of limbs per skeleton this system supports
MtxF gSkinLimbMatrices[60];
static s32 sUnused;
static s32 sBssPad;
void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos) {
SkinVertex* vertexEntry;