From ffbe059a2c45c1d8afccf0c70fbd95691afdb2a3 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:01:50 -0400 Subject: [PATCH 01/13] handle kdebugserver warning --- src/debug/kdebugserver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/kdebugserver.c b/src/debug/kdebugserver.c index 7df4360c..8710c82b 100644 --- a/src/debug/kdebugserver.c +++ b/src/debug/kdebugserver.c @@ -83,7 +83,7 @@ void kdebugserver(rdbPacket packet) { } if (buffer[0] == 2) { - send((char*)&__osRunningThread->context, sizeof(__OSThreadContext)); + send((u8 *)&__osRunningThread->context, sizeof(__OSThreadContext)); numChars = 0; } else if (numChars >= 9 && buffer[0] == 1) { addr = string_to_u32(&buffer[1]); From a7e64e17a9a1066ca285e4e3a745af444bbbed0f Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:12:06 -0400 Subject: [PATCH 02/13] profile.c warnings --- src/debug/profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/profile.c b/src/debug/profile.c index bdc47ae5..b15b6265 100644 --- a/src/debug/profile.c +++ b/src/debug/profile.c @@ -33,7 +33,7 @@ static OSThread __osProfileIOThread; void osProfSendWord(u32 word); void __osProfileIO(void* arg) { - s32 totalBytes; + u32 totalBytes; u32 bytesThisBlock; u32 ct; u8* sendPtr; From abdcb3e171fa853e9dae217395f5fb1be5a9e636 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:12:31 -0400 Subject: [PATCH 03/13] readhost.c warnings --- src/host/readhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/readhost.c b/src/host/readhost.c index 9bc8d8af..4b17af47 100644 --- a/src/host/readhost.c +++ b/src/host/readhost.c @@ -13,7 +13,7 @@ u32 __osRdb_Read_Data_Buf; u32 __osRdb_Read_Data_Ct; void osReadHost(void* dramAddr, u32 nbytes) { - char tstr[4]; + u8 tstr[4]; u32 sent = 0; if (!readHostInitialized) { From e8d66f2c4816bd8040205e3602b9166099855fe8 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:13:59 -0400 Subject: [PATCH 04/13] syncprintf --- src/libc/syncprintf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libc/syncprintf.c b/src/libc/syncprintf.c index 7faa3719..04a0bda3 100644 --- a/src/libc/syncprintf.c +++ b/src/libc/syncprintf.c @@ -8,17 +8,14 @@ extern void* __printfunc; void __osSyncVPrintf(const char* fmt, va_list ap) { - - int ans; #ifndef _FINALROM if (__printfunc != NULL) { - ans = _Printf(__printfunc, NULL, fmt, ap); + _Printf(__printfunc, NULL, fmt, ap); } #endif } void osSyncPrintf(const char* fmt, ...) { - int ans; va_list ap; #ifndef _FINALROM @@ -29,13 +26,12 @@ void osSyncPrintf(const char* fmt, ...) { } void rmonPrintf(const char* fmt, ...) { - int ans; va_list ap; #ifndef _FINALROM va_start(ap, fmt); if (__printfunc != NULL) { - ans = _Printf(__printfunc, NULL, fmt, ap); + _Printf(__printfunc, NULL, fmt, ap); } va_end(ap); #endif From e3d68a8066d5f0495ace85356976a730d624a1fe Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:15:34 -0400 Subject: [PATCH 05/13] log.c --- src/log/log.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/log/log.c b/src/log/log.c index 1519c3b3..0ec0ed36 100644 --- a/src/log/log.c +++ b/src/log/log.c @@ -83,14 +83,13 @@ void osFlushLog(OSLog* log) { } void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr) { - int i; u32 saveEnable; u32 buf[19]; u32* bufp; OSLogItem* hdr; - s32* args; - s32* dest; - int numLongs; + u32* args; + u32* dest; + u32 numLongs; bufp = buf; hdr = buf; @@ -103,14 +102,14 @@ void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr) { hdr->argCount = numArgs; hdr->eventID = code; - for (i = 0; i < numArgs; i++) { + for (int i = 0; i < numArgs; i++) { *args++ = va_arg(argPtr, int); } if (__osLogOKtoWrite) { if ((log->writeOffset + numLongs) < (log->len >> 2)) { dest = log->base + log->writeOffset; - for (i = 0; i < numLongs; i++) { + for (u32 i = 0; i < numLongs; i++) { *dest++ = *bufp++; } log->writeOffset += numLongs; From a19abef3612bc248f3087ba71573dad456f54d13 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:16:59 -0400 Subject: [PATCH 06/13] free.c --- src/rg/free.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rg/free.c b/src/rg/free.c index 23fa3977..27cf3a56 100644 --- a/src/rg/free.c +++ b/src/rg/free.c @@ -13,7 +13,7 @@ void osFree(void* region, void* addr) { #ifdef _DEBUG assert((region != NULL) && (addr != NULL)); - if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + if (((u8*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { __osError(ERR_OSFREE_REGION, 1, region); return; } From 427a15e378e3f16f6715f8f63944927a1a7040d8 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:18:00 -0400 Subject: [PATCH 07/13] rest of rg funcs --- src/rg/getbufcount.c | 2 +- src/rg/getsize.c | 2 +- src/rg/malloc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rg/getbufcount.c b/src/rg/getbufcount.c index 7b4dd96d..86edc5b3 100644 --- a/src/rg/getbufcount.c +++ b/src/rg/getbufcount.c @@ -11,7 +11,7 @@ s32 osGetRegionBufCount(void* region) { #ifdef _DEBUG assert(rp != NULL); - if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + if (((u8*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { __osError(ERR_OSGETREGIONBUFCOUNT, 1, region); return 0; } diff --git a/src/rg/getsize.c b/src/rg/getsize.c index 1cbc5bed..787a94e3 100644 --- a/src/rg/getsize.c +++ b/src/rg/getsize.c @@ -11,7 +11,7 @@ s32 osGetRegionBufSize(void* region) { #ifdef _DEBUG assert(rp != NULL); - if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + if (((u8*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { __osError(ERR_OSGETREGIONBUFSIZE, 1, region); return 0; } diff --git a/src/rg/malloc.c b/src/rg/malloc.c index 3201ab44..57b301a9 100644 --- a/src/rg/malloc.c +++ b/src/rg/malloc.c @@ -12,7 +12,7 @@ void* osMalloc(void* region) { #ifdef _DEBUG assert(rp != NULL); - if (((char*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { + if (((u8*)rp + ALIGN(sizeof(OSRegion), rp->r_alignSize)) != rp->r_startBufferAddress) { __osError(ERR_OSMALLOC, 1, region); return NULL; } From 5d7965a20ab2914272894e62ae601f1a8ae40fea Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:24:06 -0400 Subject: [PATCH 08/13] remove only the part of exception thats causing a warning (we have got to remove more) --- src/os/exceptasm.s | 64 ---------------------------------------------- 1 file changed, 64 deletions(-) diff --git a/src/os/exceptasm.s b/src/os/exceptasm.s index 9a7dbea4..3ec19e0c 100644 --- a/src/os/exceptasm.s +++ b/src/os/exceptasm.s @@ -117,70 +117,6 @@ LEAF(__osExceptionPreamble) jr k0 END(__osExceptionPreamble) -#ifndef _FINALROM -LEAF(__ptExceptionPreamble) -.set noreorder - sw k0, -0x10(sp) - b pt_next - lui k0, %hi(__ptException) - nop - nop -pt_next: - addiu k0, k0, %lo(__ptException) - jr k0 - nop -.set reorder -END(__ptExceptionPreamble) - -LEAF(__ptException) -.set noreorder - mfc0 k0, C0_CAUSE - andi k0, k0, 0x7c - bnez k0, pt_not_Int - srl k0, k0, 2 - mfc0 k0, C0_CAUSE - nop - andi k0, k0, CAUSE_IP7 - beqz k0, __osException - nop - j pt_break - nop -pt_not_Int: - sw k1, -8(sp) - /* determine if the pt exception handler should deal with this cause */ - la k1, __osCauseTable_pt - add k1, k1, k0 - lbu k0, (k1) - beqz k0, __osException - nop -pt_break: -pi_ok_loop: - lw k0, PHYS_TO_K1(PI_STATUS_REG) - nop - andi k0, k0, (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY) - bnez k0, pi_ok_loop - nop - lw k0, KMC_STAT - nop - andi k0, k0, 8 - bnez k0, pt_prof - li k0, KMC_CODE_ENTRY - lw k1, -8(sp) - jr k0 - addiu sp, sp, -0x60 -pt_prof: - mfc0 k0, C0_EPC - /* the following two ways is a (necessarily) messy way to write "sw k0, KMC_WPORT" without using at */ - lui k1, (KMC_WPORT >> 16 + 1) - sw k0, -(KMC_WPORT & 0xFFFF)(k1) - lw k1, -8(sp) - lw k0, -0x10(sp) - eret - nop -.set reorder -END(__ptException) -#endif - LEAF(__osException) /* Load scratch space for thread saving */ la k0, __osThreadSave From 94efc62db895078aaa6386cd4a087f75e9f31392 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:25:50 -0400 Subject: [PATCH 09/13] explicitly split out thing in intmask --- src/os/getintmask.s | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/os/getintmask.s b/src/os/getintmask.s index 293a57ca..1499d8bd 100644 --- a/src/os/getintmask.s +++ b/src/os/getintmask.s @@ -17,8 +17,9 @@ LEAF(osGetIntMask) lw t1, PHYS_TO_K1(MI_INTR_MASK_REG) beqz t1, 1f - la t0, __OSGlobalIntMask # this is intentionally a macro in the branch delay slot - + lui t0, %hi(__OSGlobalIntMask) + + addiu t0, %lo(__OSGlobalIntMask) # Saves an instruction if the above branch was taken lw t0, 0(t0) srl t0, t0, 0x10 xor t0, t0, -1 From f07ef0761990ea69133507efc39a433e1c1a0255 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:29:41 -0400 Subject: [PATCH 10/13] remove link error from removing the part with the warning in exceptasm --- src/os/exceptasm.s | 194 --------------------------------------------- 1 file changed, 194 deletions(-) diff --git a/src/os/exceptasm.s b/src/os/exceptasm.s index 3ec19e0c..fd749480 100644 --- a/src/os/exceptasm.s +++ b/src/os/exceptasm.s @@ -138,200 +138,6 @@ LEAF(__osException) sw zero, THREAD_FP(k0) /* This instruction is useless, leftover because of bad placement of an ifdef for the debug version */ MFC0( t0, C0_CAUSE) -#ifndef _FINALROM - lw t2, __kmc_pt_mode - bnez t2, skip_kmc_mode - andi t1, t0, 0x7c - li t2, 0 - bne t1, t2, savecontext - and t1, k1, t0 - andi t2, t1, CAUSE_IP7 - beqz t2, notIP7 - /* clear rdb write interrupt */ - la t1, RDB_WRITE_INTR_REG - sw zero, (t1) -IP7check: - MFC0( t0, C0_CAUSE) - andi t0, t0, CAUSE_IP7 - bne zero, t0, IP7check - la t2, RDB_BASE_REG - lw t0, (t2) - srl t1, t0, 0x1a - andi t1, t1, 0x3f - li t2, RDB_TYPE_HtoG_DATA - beq t1, t2, HandData - li t2, RDB_TYPE_HtoG_DEBUG - beq t1, t2, HandDbg - li t2, RDB_TYPE_HtoG_KDEBUG - beq t1, t2, HandKDebug - li t2, RDB_TYPE_HtoG_DEBUG_CT - beq t1, t2, DbgCnt - li t2, RDB_TYPE_HtoG_DATA_DONE - beq t1, t2, DataRead - li t2, RDB_TYPE_HtoG_LOG_DONE - beq t1, t2, LogRead - li t2, RDB_TYPE_HtoG_REQ_RAMROM - beq t1, t2, ReqRamrom - li t2, RDB_TYPE_HtoG_FREE_RAMROM - beq t1, t2, FreeRamrom - li t2, RDB_TYPE_HtoG_PROF_SIGNAL - beq t1, t2, SignalProf - b rdbout -SignalProf: - li t2, 1 - srl t1, t0, 0x10 - andi t1, t1, 0xff - beq t1, t2, AckProf - li t2, 0xa8 - sw t2, __osRdb_Mesg - b savecontext -AckProf: - li t2, 0xb0 - sw t2, __osRdb_Mesg - b savecontext -HandKDebug: - sw t0, __os_Kdebug_Pkt - b savecontext -DbgCnt: - li t2, 0xffffff - and t1, t0, t2 - sw t1, __osRdb_DbgRead_Ct - b rdbout -DataRead: - li t2, 0x88 - sw t2, __osRdb_Mesg - b savecontext -LogRead: - li t2, 0x80 - sw t2, __osRdb_Mesg - b savecontext -ReqRamrom: - li t2, 0x90 - sw t2, __osRdb_Mesg - b savecontext -FreeRamrom: - li t2, 0x98 - sw t2, __osRdb_Mesg - b savecontext -HandData: - srl t1, t0, 0x18 - andi t1, t1, 3 - beq zero, t1, rdbout - lw t2, __osRdb_Read_Data_Ct - subu t2, t2, t1 - sw t2, __osRdb_Read_Data_Ct - sd t3, THREAD_GP11(k0) - lw t3, __osRdb_Read_Data_Buf - srl t2, t0, 0x10 - andi t2, t2, 0xff - sb t2, (t3) - addi t3, t3, 1 - addi t1, t1, -1 - beq zero, t1, doneData - srl t2, t0, 8 - andi t2, t2, 0xff - sb t2, (t3) - addi t3, t3, 1 - addi t1, t1, -1 - beq zero, t1, doneData - andi t0, t0, 0xff - sb t0, (t3) - addi t3, t3, 1 -doneData: - sw t3, __osRdb_Read_Data_Buf - ld t3, THREAD_GP11(k0) - lw t2, __osRdb_Read_Data_Ct - bne zero, t2, rdbout - li t2, 0x78 - sw t2, __osRdb_Mesg - b savecontext -HandDbg: - srl t1, t0, 0x18 - andi t1, t1, 3 - beq zero, t1, rdbout - lw t2, __osRdb_DbgRead_Ct - subu t2, t2, t1 - sw t2, __osRdb_DbgRead_Ct - sd t3, THREAD_GP11(k0) - lw t3, __osRdb_DbgRead_Buf - bne zero, t3, 1f - ld t3, THREAD_GP11(k0) - b rdbout -1: - srl t2, t0, 0x10 - andi t2, t2, 0xff - sb t2, (t3) - addi t3, t3, 1 - addi t1, t1, -1 - beq zero, t1, doneDbg - srl t2, t0, 8 - andi t2, t2, 0xff - sb t2, (t3) - addi t3, t3, 1 - addi t1, t1, -1 - beq zero, t1, doneDbg - andi t0, t0, 0xff - sb t0, (t3) - addi t3, t3, 1 -doneDbg: - sw t3, __osRdb_DbgRead_Buf - ld t3, THREAD_GP11(k0) - lw t2, __osRdb_DbgRead_Ct - bne zero, t2, rdbout - li t2, 0xa0 - sw t2, __osRdb_Mesg - b savecontext -notIP7: - andi t2, t1, CAUSE_IP6 - beqz t2, savecontext - /* clear rdb read interrupt */ - la t1, RDB_READ_INTR_REG - sw zero, (t1) - lw t2, __osRdb_IP6_Ct - bnez t2, 2f - li t2, 1 - sw t2, __osRdb_IP6_Empty - b rdbout -2: - addi t2, t2, -1 - sw t2, __osRdb_IP6_Ct - lw t0, __osRdb_IP6_Data - lw t1, __osRdb_IP6_CurSend - sll t2, t1, 2 - add t0, t2, t0 - lw t2, (t0) - addi t1, t1, 1 - lw t0, __osRdb_IP6_Size - sub t0, t0, t1 - bgtz t0, 5f - li t1, 0 -5: - sw t1, __osRdb_IP6_CurSend -checkIP6: - MFC0( t0, C0_CAUSE) - andi t0, t0, CAUSE_IP6 - bne zero, t0, checkIP6 - la t0, RDB_BASE_REG - sw t2, (t0) -rdbout: - ld t0, THREAD_GP8(k0) - ld t1, THREAD_GP9(k0) - ld t2, THREAD_GP10(k0) -.set noat - ld $1, THREAD_GP1(k0) -.set at - lw k1, THREAD_SR(k0) - MTC0( k1, C0_SR) -.set noreorder - nop - nop - nop - nop - eret -.set reorder - -skip_kmc_mode: -#endif savecontext: /* Save the context of the previously running thread to be restored when it resumes */ From 4a31e9a9f01d449dada35b4b209598e4643cfea9 Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sat, 6 Sep 2025 21:31:11 -0400 Subject: [PATCH 11/13] format --- src/debug/kdebugserver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/kdebugserver.c b/src/debug/kdebugserver.c index 8710c82b..d9e96e7c 100644 --- a/src/debug/kdebugserver.c +++ b/src/debug/kdebugserver.c @@ -83,7 +83,7 @@ void kdebugserver(rdbPacket packet) { } if (buffer[0] == 2) { - send((u8 *)&__osRunningThread->context, sizeof(__OSThreadContext)); + send((u8*)&__osRunningThread->context, sizeof(__OSThreadContext)); numChars = 0; } else if (numChars >= 9 && buffer[0] == 1) { addr = string_to_u32(&buffer[1]); From a6eeed796b1ca7916dd51a5783b7766208a7c5cc Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sun, 7 Sep 2025 16:51:46 -0400 Subject: [PATCH 12/13] use ultratype --- src/log/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/log/log.c b/src/log/log.c index 0ec0ed36..97f0c05d 100644 --- a/src/log/log.c +++ b/src/log/log.c @@ -102,8 +102,8 @@ void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr) { hdr->argCount = numArgs; hdr->eventID = code; - for (int i = 0; i < numArgs; i++) { - *args++ = va_arg(argPtr, int); + for (s32 i = 0; i < numArgs; i++) { + *args++ = va_arg(argPtr, s32); } if (__osLogOKtoWrite) { From 4a75726e10c2489613438a912564de8ee442cacf Mon Sep 17 00:00:00 2001 From: someone2639 Date: Sun, 7 Sep 2025 16:53:21 -0400 Subject: [PATCH 13/13] totalBytes fix --- src/debug/profile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debug/profile.c b/src/debug/profile.c index b15b6265..de14d771 100644 --- a/src/debug/profile.c +++ b/src/debug/profile.c @@ -33,7 +33,7 @@ static OSThread __osProfileIOThread; void osProfSendWord(u32 word); void __osProfileIO(void* arg) { - u32 totalBytes; + s32 totalBytes; u32 bytesThisBlock; u32 ct; u8* sendPtr; @@ -53,7 +53,7 @@ void __osProfileIO(void* arg) { totalBytes = t->histo_size * 2; sendPtr = t->histo_base; while (totalBytes > 0) { - bytesThisBlock = (totalBytes < 0x800U) ? totalBytes : 0x800U; + bytesThisBlock = (totalBytes < 0x800) ? totalBytes : 0x800; ct = 0; while (ct < bytesThisBlock) {