extern "C" int main(int argc, char *argv[]) { checkpointNext("Normal (FIFO):"); { SceUID fpl = sceKernelCreateFpl("fpl", PSP_MEMORY_PARTITION_USER, 0, 0x100, 1, NULL); void *data; sceKernelAllocateFpl(fpl, &data, NULL); FplWaitThread wait1("waiting thread 1", fpl, NO_TIMEOUT, 300, 0x30); FplWaitThread wait2("waiting thread 2", fpl, NO_TIMEOUT, 300, 0x34); FplWaitThread wait3("waiting thread 3", fpl, NO_TIMEOUT, 300, 0x31); sceKernelFreeFpl(fpl, data); schedfFpl(fpl); sceKernelDelayThread(200000); sceKernelDeleteFpl(fpl); } checkpointNext("Priority:"); { SceUID fpl = sceKernelCreateFpl("fpl", PSP_MEMORY_PARTITION_USER, PSP_FPL_ATTR_PRIORITY, 0x100, 1, NULL); void *data; sceKernelAllocateFpl(fpl, &data, NULL); FplWaitThread wait1("waiting thread 1", fpl, NO_TIMEOUT, 300, 0x30); FplWaitThread wait2("waiting thread 2", fpl, NO_TIMEOUT, 300, 0x34); FplWaitThread wait3("waiting thread 3", fpl, NO_TIMEOUT, 300, 0x31); sceKernelFreeFpl(fpl, data); schedfFpl(fpl); sceKernelDelayThread(200000); sceKernelDeleteFpl(fpl); } return 0; }
// OK int DriverStart(int size, void *args) { void *lpData; SceUID hFPL = sceKernelCreateFpl("SceUsbAcc", 1, 256, 368, 1, NULL); // 368 = 2*184=2*sizeof(UsbData) g_hFPL = hFPL; if (hFPL< 0) { return (-1); } if (sceKernelTryAllocateFpl(hFPL, &lpData) < 0) { sceKernelDeleteFpl(g_hFPL); return (-1); } g_lpData = lpData; struct UsbData *lpUsbData = (struct UsbData *)((int)lpData + 64); g_driver.devp_hi = lpUsbData->devdesc; // UsbData[0] g_driver.confp_hi = &lpUsbData->config; lpData = &lpUsbData->confdesc; lpUsbData = sub_00000670(SPEED_HIGH, lpUsbData->devdesc, &lpUsbData->config, &lpUsbData->confdesc); g_driver.devp = lpUsbData->devdesc; // UsbData[1] g_driver.confp = &lpUsbData->config; lpData = &lpUsbData->confdesc; lpData = sub_00000670(SPEED_FULL, lpUsbData->devdesc, &lpUsbData->config, &lpUsbData->confdesc); g_info = 0; g_bAttached = 0; int i; for (i = 0; i < 2; i++) { g_usbEndps[i].unk3 = 0; } g_usbDevReq.endp = g_usbEndps; g_usbDevReq.data = g_lpData; g_usbDevReq.size = 64; g_usbDevReq.unkc = 1; g_usbDevReq.func = UsbDevReqComplete; g_usbDevReq.recvsize = 0; g_usbDevReq.retcode = 0; g_usbDevReq.unk1c = 0; g_usbDevReq.arg = 0; sceUsbBus_driver_90B82F55(); g_bStarted = 1; return (0); }
extern "C" int main(int argc, char *argv[]) { SceUID fpl = sceKernelCreateFpl("fpl", PSP_MEMORY_PARTITION_USER, 0, 0x10, 8, NULL); void *temp; sceKernelAllocateFpl(fpl, &temp, NULL); checkpointNext("Objects:"); testFree(" Normal", fpl, &temp); testFree(" NULL", 0, &temp); testFree(" Invalid", 0xDEADBEEF, &temp); sceKernelDeleteFpl(fpl); testFree(" Deleted", fpl, &temp); fpl = sceKernelCreateFpl("fpl", PSP_MEMORY_PARTITION_USER, 0, 0x10, 8, NULL); sceKernelAllocateFpl(fpl, &temp, NULL); checkpointNext("Pointers:"); testFree(" Normal", fpl, temp); testFree(" NULL", fpl, NULL); testFree(" Invalid", fpl, (void *)0xDEADBEEF); testFree(" Already free", fpl, temp); sceKernelDeleteFpl(fpl); return 0; }
int main(int argc, char **argv) { int n; int fplid; int *fpl; int ko; fplid = sceKernelCreateFpl("BSS_NO_OVERLAP", 2, 0, sizeof(bss), 1, NULL); sceKernelAllocateFpl(fplid, (void**)&fpl, NULL); for (n = 0; n < lengthof(bss); n++) bss[n] = BSS_VALUE; for (n = 0; n < lengthof(bss); n++) fpl[n] = FPL_VALUE; ko = 0; for (n = 0; n < lengthof(bss); n++) { if (bss[n] != BSS_VALUE) ko++; if (fpl[n] != FPL_VALUE) ko++; } printf("KO: %d\n", ko); return 0; }
int sceKernelStartModulePatched(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option) { SceModule2 *mod = sceKernelFindModuleByUID660(modid); if(mod) { if(!plugins_started) { if(strcmp(mod->modname, "sceMediaSync") == 0) { plugins_started = 1; SceUID fd = -1; char path[64]; int type = sceKernelInitKeyConfig(); if(type == PSP_INIT_KEYCONFIG_GAME) { sprintf(path, "%s/GAME.TXT", rebootex_config.savedata_path); fd = sceIoOpen(path, PSP_O_RDONLY, 0); } else if(type == PSP_INIT_KEYCONFIG_POPS) { sprintf(path, "%s/POPCORN.PRX", rebootex_config.savedata_path); LoadStartModule(path); sprintf(path, "%s/POPS.TXT", rebootex_config.savedata_path); fd = sceIoOpen(path, PSP_O_RDONLY, 0); } if(fd >= 0) { SceUID fpl = sceKernelCreateFpl("", PSP_MEMORY_PARTITION_KERNEL, 0, 1024, 1, NULL); if(fpl >= 0) { char *buffer; sceKernelAllocateFpl(fpl, (void *)&buffer, NULL); int size = sceIoRead(fd, buffer, 1024); char *p = buffer; int res = 0; char plugin[64]; do { int activated = 0; memset(plugin, 0, sizeof(plugin)); res = GetPlugin(p, size, plugin, &activated); if(res > 0) { if(activated) LoadStartModule(plugin); size -= res; p += res; } } while(res > 0); sceIoClose(fd); if(buffer) { sceKernelFreeFpl(fpl, buffer); sceKernelDeleteFpl(fpl); } } } } } } return sceKernelStartModule660(modid, argsize, argp, status, option); }
void fpl_test() { int result; int fpl; int attr = 0x4000; //fpl = sceKernelCreateFpl("FPL", 2, attr, 0x1000, 1, 0x0); fpl = sceKernelCreateFpl("FPL", 2, attr, 0x1, 2, 0x0); //fpl = sceKernelCreateFpl("FPL", 2, attr, 0x4000000, 1, 0x0); // not enough free mem printf("sceKernelCreateFpl(attr=%08x) %08x\n", attr, fpl); if (fpl <= 0) return; printMem(); // 256-byte aligned consumption (may be enforced by pspsysmem, not threadman/fpl) fpl_refer(fpl); void *addr; void *addr2; addr = fpl_alloc(fpl); if (0) { // test multiple wait int thid = sceKernelCreateThread("fpl_thread", fpl_thread, 0x20, 0x4000, 0, 0); if (thid >= 0) { sceKernelStartThread(thid, 4, &fpl); } addr2 = fpl_wait_alloc("user_main", fpl); } else { addr2 = fpl_alloc(fpl); // 32-bit aligned fpl_try_alloc(fpl); //fpl_try_alloc(fpl); } fpl_refer(fpl); if (addr) { result = sceKernelFreeFpl(fpl, addr); // ok printf("sceKernelFreeFpl(addr) result=%08x\n", result); printMem(); //result = sceKernelFreeFpl(fpl, addr); // illegal mem block //printf("sceKernelFreeFpl(addr) result=%08x\n", result); //printMem(); } if (addr2) { result = sceKernelFreeFpl(fpl, addr2); // ok printf("sceKernelFreeFpl(addr2) result=%08x\n", result); printMem(); } //result = sceKernelFreeFpl(fpl, (void*)0x08A00000); // illegal mem block //printf("sceKernelFreeFpl(0x08A00000) result=%08x\n", result); //printMem(); result = sceKernelDeleteFpl(fpl); // ok printf("sceKernelDeleteFpl %08x\n", result); printMem(); result = sceKernelDeleteFpl(fpl); // not found fpl printf("sceKernelDeleteFpl %08x\n", result); printMem(); fpl_refer(fpl); // not found fpl }