Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/debug/kdebugserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/debug/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/host/readhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions src/libc/syncprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions src/log/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++) {
*args++ = va_arg(argPtr, int);
for (s32 i = 0; i < numArgs; i++) {
*args++ = va_arg(argPtr, s32);
}

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;
Expand Down
258 changes: 0 additions & 258 deletions src/os/exceptasm.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -202,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 */
Expand Down
5 changes: 3 additions & 2 deletions src/os/getintmask.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rg/free.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rg/getbufcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading