void MemoryProtectInit(u32 size, u32 extSize) { if (sceKernelGetModel() == 0 && sceKernelDipsw(10) == 0 && sceKernelDipsw(12) == 0) // A4B8 HW(0xBC100040) = (HW(0xBC100040) & 0xFFFFFFFC) | 0x1; else { // A2E8 HW(0xBC100040) = (HW(0xBC100040) & 0xFFFFFFFC) | 0x2; } // A2F8 if (size > 0x800000) size = 0x800000; vs32 *ptr = (s32*)0xBC000000; // A334 while (size > 0x001FFFFF) { size -= 0x200000; *(ptr++) = 0xCCCCCCCC; } // A348 if (size != 0) { u32 flag = 0xCCCCCCCC; // A36C s32 i; for (i = (size >> 18) * 4; i < 32; i += 4) flag |= (0xF << i); // A380 *(ptr++) = flag; }
// 0244 void printf_char(void *ctx, int ch) { dbg_printf("Calling %s\n", __FUNCTION__); if (ch == 0x200) { *(short*)(ctx + 2) = 0; return; } if (ch == 0x201) { // 031C short cnt = *(short*)(ctx + 2); if (cnt <= 0) return; if (sceKernelDipsw(59) == 1) sceKernelDebugWrite(*(short*)(ctx + 0), ctx + 4, *(short*)(ctx + 2)); else { short fd = *(short*)(ctx + 0); if (fd == STDOUT) fd = g_stdout; // 0348 if (fd == STDERR) fd = g_stderr; // 0354 sceIoWrite(fd, ctx + 4, *(short*)(ctx + 2)); } return; } if (ch == '\n') { // 030C printf_char(ctx, '\r'); } // 027C (*(short*)(ctx + 2))++; *(char*)(ctx + 3 + *(short*)(ctx + 2)) = ch; if (ch == '\200') { short fd = *(short*)(ctx + 0); // 02AC if (sceKernelDipsw(59) == 1) { // 02F8 sceKernelDebugWrite(fd, ctx + 4, *(short*)(ctx + 2)); } else { if (fd == STDOUT) fd = g_stdout; // 02C8 if (fd == STDERR) fd = g_stderr; // 02D4 sceIoWrite(fd, ctx + 4, *(short*)(ctx + 2)); } *(short*)(ctx + 2) = 0; } }
// 019C int stdoutReset(int flags, SceMode mode) { dbg_printf("Calling %s\n", __FUNCTION__); char openDummy = 0; if (sceKernelDipsw(58) == 1 && !sceKernelDipsw(59)) openDummy = 1; else openDummy = 0; // 01CC if (openDummy) { // 0214 int ret = sceIoOpen("tty0:", flags, mode); if (ret >= 0) return ret; } // 01E8 return sceIoOpen("dummy_drv_iofile:", flags, mode); }
void sceKernelAssert(int test, int lvl) { if (test) return; // CFD0 if (sceKernelDipsw(8) == 0) { // D00C Kprintf("assertion ignore (level %d)\n", lvl); return; } void (*assertFunc)(int) = g_assertHandler; if (assertFunc == NULL) { // CFFC Kprintf("There is no assert handler, stop\n"); for (;;) // D004 ; } assertFunc(0); }
int fdputc(int c, int fd) { dbg_printf("Calling %s\n", __FUNCTION__); char str[1] = {c}; if (c == '\t') { // print tabulations, aligning the characters (a tabulation has a size of 8 spaces) // 0574 if (sceKernelDipsw(59) == 1) { // 05E4 sceKernelDebugWrite(fd, " ", 8 - (g_linePos & 7)); } else { if (fd == STDOUT) fd = g_stdout; // 0590 if (fd == STDERR) fd = g_stderr; // 059C sceIoWrite(fd, " ", 8 - (g_linePos & 7)); } // 05C4 g_linePos = (g_linePos & 0xFFFFFFF8) + 8; } else if (c == '\n') { // 0504 if (sceKernelDipsw(59) == 1) sceKernelDebugWrite(fd, "\r\n", 2); else { if (fd == STDOUT) fd = g_stdout; // 0520 if (fd == STDERR) fd = g_stderr; // 052C sceIoWrite(fd, "\r\n", 2); } // 0544 g_linePos = 0; } else { if ((look_ctype_table(c) & 0x97) != 0) g_linePos++; // 048C if (sceKernelDipsw(59) == 1) { // 04F0 sceKernelDebugWrite(fd, str, 1); } else { if (fd == STDOUT) fd = g_stdout; // 04A8 if (fd == STDERR) fd = g_stderr; // 04B4 sceIoWrite(fd, str, 1); } } return c; }