# PspPet stripped down startup # from "tyranid inspired by nem's work" # Kernel Memory Hack must be enabled # Start "main()" thread as a system thread # no common library init/fini # many STUB_FUNC entries - most not needed # see "SLIME NOTE"s .set noreorder .text .global _start .ent _start _start: addiu $29, -0x10 sw $31, 0($29) sw $16, 4($29) sw $17, 8($29) move $16, $4 # Save args move $17, $5 # create main thread la $4, _main_thread_name # Main thread setup la $5, _main li $6, 0x20 # Priority - higher than kmain li $7, 0x40000 # Stack size # lui $8, 0x8000 # User thread li $8, 0 # Kernel thread jal sceKernelCreateThread move $9, $0 move $4, $2 # Start thread move $5, $16 move $6, $17 jal sceKernelStartThread move $16, $2 # save oid lw $31, 0($29) lw $16, 4($29) lw $17, 8($29) move $2, $0 jr $31 addiu $29, 0x10 .end _start # Second stage main function .ent _main _main: # Do mainy stuff ;) addiu $29, -0x10 sw $31, 0($29) la $8, _fbss la $9, _end # Clear BSS loop: sw $0,0($8) sltu $2, $8, $9 bne $2, $0, loop addiu $8, $8, 4 la $28, _gp # NOT - Call libc initialisation jal main nop # _exit-like lw $31, 0($29) jr $31 addiu $29, 0x10 .end _main #################### _main_thread_name: .asciiz "main" ############################################################################## .section .lib.ent,"wa",@progbits __lib_ent_top: .word 0 .word 0x80000000 .word 0x00010104 .word __entrytable .section .lib.ent.btm,"wa",@progbits __lib_ent_bottom: .word 0 .section .lib.stub,"wa",@progbits __lib_stub_top: .section .lib.stub.btm,"wa",@progbits __lib_stub_bottom: .word 0 # SLIME NOTE: export lib_stub names for table patching .global __lib_stub_top .global __lib_stub_bottom ############################################################################## .section ".xodata.sceModuleInfo","wa",@progbits __moduleinfo: # SLIME NOTE - kernel mem access !! .word 0x01011000 .ascii "PSPSDK" #up to 28 char .align 5 .word _gp .word __lib_ent_top .word __lib_ent_bottom .word __lib_stub_top .word __lib_stub_bottom ############################################################################## .section .rodata.entrytable,"wa",@progbits __entrytable: .word 0xD632ACDB .word 0xF01D73A7 .word _start .word __moduleinfo .word 0 ############################################################################### .data # none .bss # none ############################################################################### .macro STUB_START module,d1,d2 .section .rodata.stubmodulename .word 0 __stub_modulestr_\@: .asciz "\module" .align 2 .section .lib.stub .word __stub_modulestr_\@ .word \d1 .word \d2 .word __stub_idtable_\@ .word __stub_text_\@ .section .rodata.stubidtable __stub_idtable_\@: .section .text.stub __stub_text_\@: .endm .macro STUB_END .endm .macro STUB_FUNC funcid,funcname .set push .set noreorder .section .text.stub .weak \funcname \funcname: jr $ra nop .section .rodata.stubidtable .word \funcid .set pop .endm STUB_START "sceDisplay",0x40010000,0x00030005 STUB_FUNC 0x0E20F177,pspDisplaySetMode STUB_FUNC 0x289D82FE,pspDisplaySetFrameBuf STUB_FUNC 0x984C27E7,pspDisplayWaitVblankStart STUB_END STUB_START "IoFileMgrForUser",0x40010000,0x000B0005 STUB_FUNC 0x6a638d83,sceIoRead STUB_FUNC 0x42ec03ac,sceIoWrite STUB_FUNC 0x27eb27b8,sceIoLseek STUB_FUNC 0x810c4bc3,sceIoClose STUB_FUNC 0x109f50bc,sceIoOpen STUB_FUNC 0xF27A9C51,sceIoRemove STUB_FUNC 0x6A70004,sceIoMkdir STUB_FUNC 0x1117C65F,sceIoRmdir STUB_FUNC 0x54F5FB11,sceIoDevctl STUB_FUNC 0x779103A0,sceIoRename STUB_FUNC 0x63632449,sceIoIoctl STUB_END STUB_START "LoadExecForUser",0x40010000,0x00040005 STUB_FUNC 0xBD2F1094,sceKernelLoadExec STUB_FUNC 0x05572a5f,sceKernelExitGame STUB_FUNC 0x2ac9954b,sceKernelExitGameWithStatus STUB_FUNC 0x4ac57943,sceKernelRegisterExitCallback STUB_END STUB_START "ModuleMgrForUser",0x40010000,0x000A0005 STUB_FUNC 0xb7f46618,sceKernelLoadModuleByID STUB_FUNC 0x977de386,sceKernelLoadModule STUB_FUNC 0x710f61b5,sceKernelLoadModuleMs STUB_FUNC 0xf9275d98,sceKernelLoadModuleBufferUsbWlan STUB_FUNC 0x50f0c1ec,sceKernelStartModule STUB_FUNC 0xd1ff982a,sceKernelStopModule STUB_FUNC 0x2e0911aa,sceKernelUnloadModule STUB_FUNC 0xd675ebb8,sceKernelSelfStopUnloadModule STUB_FUNC 0xcc1d3699,sceKernelStopUnloadSelfModule STUB_FUNC 0x748cbed9,sceKernelQueryModuleInfo STUB_END STUB_START "ThreadManForUser",0x40010000,0x000B0005 STUB_FUNC 0xe81caf8f,sceKernelCreateCallback STUB_FUNC 0x82826f70,sceKernelSleepThreadCB STUB_FUNC 0x446d8de6,sceKernelCreateThread STUB_FUNC 0xf475845d,sceKernelStartThread STUB_FUNC 0x293b45b8,sceKernelGetThreadId STUB_FUNC 0x9ace131e,sceKernelSleepThread STUB_FUNC 0x75156e8f,sceKernelResumeThread STUB_FUNC 0x9944f31f,sceKernelSuspendThread STUB_FUNC 0x278c0df5,sceKernelWaitThreadEnd STUB_FUNC 0x71bc9871,sceKernelChangeThreadPriority STUB_FUNC 0x94aa61ee,sceKernelGetThreadCurrentPriority STUB_END STUB_START "UtilsForUser",0x40010000,0x00010005 STUB_FUNC 0x79d1c3fa,sceKernelDcacheWritebackAll # no Icache access for user - call directly using KMEM trick STUB_END #REVIEW: sceNet or sceNet_Library ?? STUB_START "sceNet_Library",0x90000,0x00050005 STUB_FUNC 0x39af39a6,sceNetInit STUB_FUNC 0x281928a9,sceNetTerm STUB_FUNC 0xad6844c6,sceNetThreadAbort STUB_FUNC 0x0bf0a3ae,sceNetGetLocalEtherAddr STUB_FUNC 0xcc393e48,sceNetGetMallocStat STUB_END STUB_START "sceNetInet",0x90000,0x001c0005 STUB_FUNC 0x17943399,sceNetInetInit STUB_FUNC 0xa9ed66b9,sceNetInetTerm STUB_FUNC 0xdb094e1b,sceNetInetAccept STUB_FUNC 0x1a33f9ae,sceNetInetBind STUB_FUNC 0x8d7284ea,sceNetInetClose STUB_FUNC 0x805502dd,sceNetInetCloseWithRST STUB_FUNC 0x410b34aa,sceNetInetConnect STUB_FUNC 0xe247b6d6,sceNetInetGetpeername STUB_FUNC 0x162e6fd5,sceNetInetGetsockname STUB_FUNC 0x4a114c7c,sceNetInetGetsockopt STUB_FUNC 0xd10a1a7a,sceNetInetListen STUB_FUNC 0xfaabb1dd,sceNetInetPoll STUB_FUNC 0xcda85c99,sceNetInetRecv STUB_FUNC 0xc91142e4,sceNetInetRecvfrom STUB_FUNC 0xeece61d2,sceNetInetRecvmsg STUB_FUNC 0x5be8d595,sceNetInetSelect STUB_FUNC 0x7aa671bc,sceNetInetSend STUB_FUNC 0x05038fc7,sceNetInetSendto STUB_FUNC 0x774e36f4,sceNetInetSendmsg STUB_FUNC 0x2fe71fe7,sceNetInetSetsockopt STUB_FUNC 0x4cfe4e56,sceNetInetShutdown STUB_FUNC 0x8b7b220f,sceNetInetSocket STUB_FUNC 0x80a21abd,sceNetInetSocketAbort STUB_FUNC 0xfbabe411,sceNetInetGetErrno STUB_FUNC 0xb75d5b0a,sceNetInetInetAddr STUB_FUNC 0x1bdf5d13,sceNetInetInetAton STUB_FUNC 0xd0792666,sceNetInetInetNtop STUB_FUNC 0xe30b8c19,sceNetInetInetPton STUB_END STUB_START "sceNetAdhoc",0x90000,0x00190005 STUB_FUNC 0xe1d621d7,sceNetAdhocInit STUB_FUNC 0xa62c6f57,sceNetAdhocTerm STUB_FUNC 0x7a662d6b,sceNetAdhocPollSocket STUB_FUNC 0x73bfd52d,sceNetAdhocSetSocketAlert STUB_FUNC 0x4d2ce199,sceNetAdhocGetSocketAlert STUB_FUNC 0x6f92741b,sceNetAdhocPdpCreate STUB_FUNC 0xabed3790,sceNetAdhocPdpSend STUB_FUNC 0xdfe53e03,sceNetAdhocPdpRecv STUB_FUNC 0x7f27bb5e,sceNetAdhocPdpDelete STUB_FUNC 0xc7c1fc57,sceNetAdhocGetPdpStat STUB_FUNC 0x877f6d66,sceNetAdhocPtpOpen STUB_FUNC 0xfc6fc07b,sceNetAdhocPtpConnect STUB_FUNC 0xe08bdac1,sceNetAdhocPtpListen STUB_FUNC 0x9df81198,sceNetAdhocPtpAccept STUB_FUNC 0x4da4c788,sceNetAdhocPtpSend STUB_FUNC 0x8bea2b3e,sceNetAdhocPtpRecv STUB_FUNC 0x9ac2eeac,sceNetAdhocPtpFlush STUB_FUNC 0x157e6225,sceNetAdhocPtpClose STUB_FUNC 0xb9685118,sceNetAdhocGetPtpStat STUB_FUNC 0x7f75c338,sceNetAdhocGameModeCreateMaster STUB_FUNC 0x3278ab0c,sceNetAdhocGameModeCreateReplica STUB_FUNC 0x98c204c8,sceNetAdhocGameModeUpdateMaster STUB_FUNC 0xfa324b4e,sceNetAdhocGameModeUpdateReplica STUB_FUNC 0xa0229362,sceNetAdhocGameModeDeleteMaster STUB_FUNC 0x0b2228e9,sceNetAdhocGameModeDeleteReplica STUB_END STUB_START "sceNetAdhocctl",0x90000,0x00140005 STUB_FUNC 0xe26f226e,sceNetAdhocctlInit STUB_FUNC 0x9d689e13,sceNetAdhocctlTerm STUB_FUNC 0x0ad043ed,sceNetAdhocctlConnect STUB_FUNC 0xec0635c1,sceNetAdhocctlCreate STUB_FUNC 0x5e7f79c9,sceNetAdhocctlJoin STUB_FUNC 0x08fff7a0,sceNetAdhocctlScan STUB_FUNC 0x34401d65,sceNetAdhocctlDisconnect STUB_FUNC 0x20b317a0,sceNetAdhocctlAddHandler STUB_FUNC 0x6402490b,sceNetAdhocctlDelHandler STUB_FUNC 0x75ecd386,sceNetAdhocctlGetState STUB_FUNC 0x362cbe8f,sceNetAdhocctlGetAdhocId STUB_FUNC 0xe162cb14,sceNetAdhocctlGetPeerList STUB_FUNC 0x99560abe,sceNetAdhocctlGetAddrByName STUB_FUNC 0x8916c003,sceNetAdhocctlGetNameByAddr STUB_FUNC 0xded9d28e,sceNetAdhocctlGetParameter STUB_FUNC 0x81aee1be,sceNetAdhocctlGetScanInfo STUB_FUNC 0xa5c055ce,sceNetAdhocctlCreateEnterGameMode STUB_FUNC 0x1ff89745,sceNetAdhocctlJoinEnterGameMode STUB_FUNC 0xcf8e084d,sceNetAdhocctlExitGameMode STUB_FUNC 0x5a014ce0,sceNetAdhocctlGetGameModeInfo STUB_END STUB_START "sceNetResolver",0x90000,0x00070005 STUB_FUNC 0xf3370e61,sceNetResolverInit STUB_FUNC 0x6138194a,sceNetResolverTerm STUB_FUNC 0x244172af,sceNetResolverCreate STUB_FUNC 0x94523e09,sceNetResolverDelete STUB_FUNC 0x224c5f44,sceNetResolverStartNtoA STUB_FUNC 0x629e2fb7,sceNetResolverStartAtoN STUB_FUNC 0x808f6063,sceNetResolverStop STUB_END STUB_START "sceNetApctl",0x90000,0x00080005 STUB_FUNC 0xe2f91f9b,sceNetApctlInit STUB_FUNC 0xb3edd0ec,sceNetApctlTerm STUB_FUNC 0x2befdf23,sceNetApctlGetInfo STUB_FUNC 0x8abadd51,sceNetApctlAddHandler STUB_FUNC 0x5963991b,sceNetApctlDelHandler STUB_FUNC 0xcfb957c6,sceNetApctlConnect STUB_FUNC 0x24fe91a1,sceNetApctlDisconnect STUB_FUNC 0x5deac81b,sceNetApctlGetState STUB_END ###############################################################################