Fix proper stack sizes
Add `DECLARE_STACK` and `STACK_START` macros Fix addresses so `nuStackIdle` and `obStackMain` are 0x2000 in size
This commit is contained in:
parent
b035cebc4f
commit
0872cce98b
|
|
@ -75,6 +75,10 @@ typedef u8 bool;
|
||||||
#define SCREEN_WIDTH_MAX 640
|
#define SCREEN_WIDTH_MAX 640
|
||||||
#define SCREEN_HEIGHT_MAX 480
|
#define SCREEN_HEIGHT_MAX 480
|
||||||
|
|
||||||
|
#define DECLARE_STACK(name, size) u64 name[size / sizeof(u64)]
|
||||||
|
// Stacks grow backwards (towards smaller addresses)
|
||||||
|
#define STACK_START(stack) ((u8*)(&stack) + sizeof(stack))
|
||||||
|
|
||||||
#include "character.h"
|
#include "character.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,9 @@ extern "C" {
|
||||||
/*--------------------------------------*/
|
/*--------------------------------------*/
|
||||||
/* NUSYS STACK SIZE */
|
/* NUSYS STACK SIZE */
|
||||||
/*--------------------------------------*/
|
/*--------------------------------------*/
|
||||||
//#define NU_IDLE_STACK_SIZE 0x2000 /* Idle thread */
|
#define NU_IDLE_STACK_SIZE 0x2000 /* Idle thread */
|
||||||
#define NU_RMON_STACK_SIZE 0x2000 /* Rmon thread */
|
#define NU_RMON_STACK_SIZE 0x2000 /* Rmon thread */
|
||||||
//#define NU_MAIN_STACK_SIZE NU_SPEC_BOOT_STACK_SIZE /* Main thread */
|
#define NU_MAIN_STACK_SIZE NU_SPEC_BOOT_STACK_SIZE /* Main thread */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ nuSiMesgQ = 0x800E9B88;
|
||||||
nuSiMesgBuf = 0x800BBE60;
|
nuSiMesgBuf = 0x800BBE60;
|
||||||
siMgrThread = 0x800BBE80; // size:0x1B0
|
siMgrThread = 0x800BBE80; // size:0x1B0
|
||||||
nuThreadIdle = 0x800AF440;
|
nuThreadIdle = 0x800AF440;
|
||||||
nuStackIdle = 0x800B0010;
|
nuStackIdle = 0x800AF7A0; // size:0x2000
|
||||||
nuPiCartHandle = 0x800E7A20;
|
nuPiCartHandle = 0x800E7A20;
|
||||||
nuPiMgrMesgQ = 0x800BE030;
|
nuPiMgrMesgQ = 0x800BE030;
|
||||||
nuPiMesgBuf = 0x800BE048;
|
nuPiMesgBuf = 0x800BE048;
|
||||||
|
|
@ -1029,8 +1029,8 @@ __VIRTUAL_MEMORY_EXHAUSTED = 0x800AE35C;
|
||||||
__virtual_mem_alloc = 0x80070F30;
|
__virtual_mem_alloc = 0x80070F30;
|
||||||
|
|
||||||
obMain = 0x80071EB0;
|
obMain = 0x80071EB0;
|
||||||
obThreadMain = 0x800AF5F0;
|
obThreadMain = 0x800AF5F0; // size:0x1B0
|
||||||
obStackMain = 0x800C4CF0;
|
obStackMain = 0x800C4D60; // size:0x2000
|
||||||
|
|
||||||
entry = 0x80070C00;
|
entry = 0x80070C00;
|
||||||
|
|
||||||
|
|
|
||||||
11
src/boot.c
11
src/boot.c
|
|
@ -2,20 +2,21 @@
|
||||||
|
|
||||||
#include "nu/nusys.h"
|
#include "nu/nusys.h"
|
||||||
|
|
||||||
#define NU_IDLE_STACK_SIZE 0x1790
|
|
||||||
#define OB_MAIN_STACK_SIZE 0x2070
|
#define OB_MAIN_STACK_SIZE 0x2070
|
||||||
|
|
||||||
extern OSThread nuThreadIdle;
|
extern OSThread nuThreadIdle;
|
||||||
extern u64 nuStackIdle[NU_IDLE_STACK_SIZE / sizeof(u64)];
|
extern DECLARE_STACK(nuStackIdle, NU_IDLE_STACK_SIZE);
|
||||||
|
|
||||||
extern OSThread obThreadMain;
|
extern OSThread obThreadMain;
|
||||||
extern u64 obStackMain[OB_MAIN_STACK_SIZE / sizeof(u64)];
|
extern DECLARE_STACK(obStackMain, NU_MAIN_STACK_SIZE);
|
||||||
|
|
||||||
|
const int test = sizeof(obThreadMain);
|
||||||
|
|
||||||
void nuIdle(void* arg);
|
void nuIdle(void* arg);
|
||||||
|
|
||||||
void nuBoot(void) {
|
void nuBoot(void) {
|
||||||
osInitialize();
|
osInitialize();
|
||||||
osCreateThread(&nuThreadIdle, NU_IDLE_THREAD_ID, nuIdle, NULL, nuStackIdle + NU_IDLE_STACK_SIZE / sizeof(u64), NU_MAIN_THREAD_PRI);
|
osCreateThread(&nuThreadIdle, NU_IDLE_THREAD_ID, nuIdle, NULL, STACK_START(nuStackIdle), NU_MAIN_THREAD_PRI);
|
||||||
osStartThread(&nuThreadIdle);
|
osStartThread(&nuThreadIdle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ void nuIdle(void* arg) {
|
||||||
|
|
||||||
osViSetSpecialFeatures(OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF);
|
osViSetSpecialFeatures(OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF);
|
||||||
|
|
||||||
osCreateThread(&obThreadMain, NU_MAIN_THREAD_ID, obMain, NULL, obStackMain + OB_MAIN_STACK_SIZE / sizeof(u64), NU_MAIN_THREAD_PRI);
|
osCreateThread(&obThreadMain, NU_MAIN_THREAD_ID, obMain, NULL, STACK_START(obStackMain), NU_MAIN_THREAD_PRI);
|
||||||
osStartThread(&obThreadMain);
|
osStartThread(&obThreadMain);
|
||||||
|
|
||||||
osSetThreadPri(&nuThreadIdle, NU_IDLE_THREAD_PRI);
|
osSetThreadPri(&nuThreadIdle, NU_IDLE_THREAD_PRI);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
void nuSiMgrThread(void* arg);
|
void nuSiMgrThread(void* arg);
|
||||||
|
|
||||||
extern u64 nuStackSiMgrThread[0x2000 / sizeof(u64)];
|
extern DECLARE_STACK(nuStackSiMgrThread, 0x2000);
|
||||||
|
|
||||||
/* 1A060 80089C60 */
|
/* 1A060 80089C60 */
|
||||||
u8 nuSiMgrInit(void) {
|
u8 nuSiMgrInit(void) {
|
||||||
|
|
@ -17,7 +17,7 @@ u8 nuSiMgrInit(void) {
|
||||||
|
|
||||||
osContInit(&nuSiMesgQ, &pattern, status);
|
osContInit(&nuSiMesgQ, &pattern, status);
|
||||||
|
|
||||||
osCreateThread(&siMgrThread, 5, nuSiMgrThread, NULL, nuStackSiMgrThread + 0x2000 / sizeof(u64), NU_SI_THREAD_PRI);
|
osCreateThread(&siMgrThread, 5, nuSiMgrThread, NULL, STACK_START(nuStackSiMgrThread), NU_SI_THREAD_PRI);
|
||||||
osStartThread(&siMgrThread);
|
osStartThread(&siMgrThread);
|
||||||
|
|
||||||
return pattern;
|
return pattern;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue