|
| 1 | +/* |
| 2 | +# _____ ___ ____ ___ ____ |
| 3 | +# ____| | ____| | | |____| |
| 4 | +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. |
| 5 | +#----------------------------------------------------------------------- |
| 6 | +# Copyright ps2dev - http://www.ps2dev.org |
| 7 | +# Licenced under Academic Free License version 2.0 |
| 8 | +# Review ps2sdk README & LICENSE files for further details. |
| 9 | +*/ |
| 10 | + |
| 11 | +#include <debug.h> |
| 12 | +#include <iopcontrol.h> |
| 13 | +#include <iopcontrol_special.h> |
| 14 | +#include <ioprpgen.h> |
| 15 | +#include <kernel.h> |
| 16 | +#include <malloc.h> |
| 17 | +#include <sifrpc.h> |
| 18 | +#include <stdio.h> |
| 19 | +#include <stdlib.h> |
| 20 | +#include <string.h> |
| 21 | + |
| 22 | +extern unsigned char igreeting_irx[]; |
| 23 | +extern unsigned int size_igreeting_irx; |
| 24 | + |
| 25 | +extern unsigned char threadman_irx[]; |
| 26 | +extern unsigned int size_threadman_irx; |
| 27 | + |
| 28 | +extern unsigned char sifinit_irx[]; |
| 29 | +extern unsigned int size_sifinit_irx; |
| 30 | + |
| 31 | +int main(int ac, char **av) |
| 32 | +{ |
| 33 | + struct ioprpgen_ctx ctx; |
| 34 | + struct ioprpgen_memwrite_ctx memwrite_ctx; |
| 35 | + struct ioprpgen_entry entries[3]; |
| 36 | + int sz; |
| 37 | + int sz2; |
| 38 | + void *buf; |
| 39 | + |
| 40 | + (void)ac; |
| 41 | + (void)av; |
| 42 | + |
| 43 | + init_scr(); |
| 44 | + scr_printf("Preparing IOPRP image\n"); |
| 45 | + memset(&entries, 0, sizeof(entries)); |
| 46 | + entries[0].m_name = "IGREETING"; |
| 47 | + entries[0].m_data = igreeting_irx; |
| 48 | + entries[0].m_data_size = size_igreeting_irx; |
| 49 | + entries[1].m_name = "SIFINIT"; |
| 50 | + entries[1].m_data = sifinit_irx; |
| 51 | + entries[1].m_data_size = size_sifinit_irx; |
| 52 | + // Ensure the end is NULL terminated |
| 53 | + entries[2].m_name = NULL; |
| 54 | + entries[2].m_data = NULL; |
| 55 | + entries[2].m_data_size = 0; |
| 56 | + ioprpgen_setup_membuf(&ctx, &memwrite_ctx, NULL, 0); |
| 57 | + sz = ioprpgen_write_ioprp(&ctx, entries); |
| 58 | + if ( !sz ) |
| 59 | + { |
| 60 | + scr_printf("Error getting size of IOPRP image\n"); |
| 61 | + SleepThread(); |
| 62 | + return 0; |
| 63 | + } |
| 64 | + buf = memalign(64, sz); |
| 65 | + if ( !buf ) |
| 66 | + { |
| 67 | + scr_printf("Error allocating memory for IOPRP image\n"); |
| 68 | + SleepThread(); |
| 69 | + return 0; |
| 70 | + } |
| 71 | + ioprpgen_setup_membuf(&ctx, &memwrite_ctx, buf, sz); |
| 72 | + sz2 = ioprpgen_write_ioprp(&ctx, entries); |
| 73 | + if ( sz != sz2 ) |
| 74 | + { |
| 75 | + scr_printf("Error generating IOPRP image\n"); |
| 76 | + SleepThread(); |
| 77 | + return 0; |
| 78 | + } |
| 79 | + sceSifInitRpc(0); |
| 80 | + SifIopRebootBuffer(buf, sz); |
| 81 | + while ( !SifIopSync() ) |
| 82 | + ; |
| 83 | + free(buf); |
| 84 | + sceSifInitRpc(0); |
| 85 | + scr_printf("Successfully rebooted IOP with IOPRP image!\n"); |
| 86 | + SleepThread(); |
| 87 | + return 0; |
| 88 | +} |
0 commit comments