/** * Parse mbr for filesystem */ void mount_all_devices() { FindPartitions(DEVICE_USB); if (xenon_ata_ops.isInserted()) { XTAFMount(); FindPartitions(DEVICE_ATA); } if (xenon_atapi_ops.isInserted()) { FindPartitions(DEVICE_ATAPI); } }
void Init_USB() { //Close_USB(); printf("\n"); if (AHBPROT_DISABLED && !USB_PORT_CONNECTED) { USBmnt = false; } else { bool started = false; isUSB2 = (IOS_GetVersion() >= 200); time_t tStart = time(0); while ((time(0) - tStart) < 10) // 10 seconds timeout { Con_ClearLine(); printf("\t- USB drive: %.f...", difftime(time(0), tStart)); if (isUSB2) { started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted()); } else { started = (__io_usbstorage.startup() && __io_usbstorage.isInserted()); } if (started) break; usleep(50000); } USBmnt = (started && fatMountSimple("usb", (isUSB2 ? &__io_usbstorage2 : &__io_usbstorage))); Con_ClearLine(); } printf("\t- USB drive: %s.\n\n", (USBmnt ? "OK" : "FAILED")); }
int main(int argc, char **argv) { // Exit after 10 seconds if there is an error __exception_setreload(10); // u64 timeout = 0; CheckForGecko(); DCInvalidateRange(loader_stub, 0x1800); memcpy(loader_stub, (void*)0x80001800, 0x1800); RAMInit(); //Meh, doesnt do anything anymore anyways //STM_RegisterEventHandler(HandleSTMEvent); Initialise(); // Checking for storage devices... ShowMessageScreen("Checking storage devices..."); u32 u; //Disables MEMPROT for patches write16(MEM_PROT, 0); //Patches FS access for( u = 0x93A00000; u < 0x94000000; u+=2 ) { if( memcmp( (void*)(u), FSAccessPattern, sizeof(FSAccessPattern) ) == 0 ) { // gprintf("FSAccessPatch:%08X\r\n", u ); memcpy( (void*)u, FSAccessPatch, sizeof(FSAccessPatch) ); DCFlushRange((void*)u, sizeof(FSAccessPatch)); break; } } //for BT.c CONF_GetPadDevices((conf_pads*)0x932C0000); DCFlushRange((void*)0x932C0000, sizeof(conf_pads)); *(vu32*)0x932C0490 = CONF_GetIRSensitivity(); *(vu32*)0x932C0494 = CONF_GetSensorBarPosition(); DCFlushRange((void*)0x932C0490, 8); if(LoadKernel() < 0) { ClearScreen(); gprintf("Failed to load kernel from NAND!\r\n"); ShowMessageScreenAndExit("Failed to load kernel from NAND!", 1); } InsertModule((char*)kernel_bin, kernel_bin_size); memset( (void*)0x92f00000, 0, 0x100000 ); DCFlushRange( (void*)0x92f00000, 0x100000 ); DCInvalidateRange( (void*)0x939F02F0, 0x20 ); memcpy( (void*)0x939F02F0, Boot2Patch, sizeof(Boot2Patch) ); DCFlushRange( (void*)0x939F02F0, 0x20 ); //libogc still has that, lets close it __ES_Close(); s32 fd = IOS_Open( "/dev/es", 0 ); memset( STATUS, 0xFFFFFFFF, 0x20 ); DCFlushRange( STATUS, 0x20 ); memset( (void*)0x91000000, 0xFFFFFFFF, 0x20 ); DCFlushRange( (void*)0x91000000, 0x20 ); *(vu32*)0xD3003420 = 0; //make sure kernel doesnt reload raw_irq_handler_t irq_handler = BeforeIOSReload(); IOS_IoctlvAsync( fd, 0x1F, 0, 0, &IOCTL_Buf, NULL, NULL ); AfterIOSReload( irq_handler, FoundVersion ); while(1) { DCInvalidateRange( STATUS, 0x20 ); if((STATUS_LOADING > 0 || abs(STATUS_LOADING) > 1) && STATUS_LOADING < 20) { gprintf("Kernel sent signal\n"); break; } } /* For slow USB HDDs */ time_t timeout = time(NULL); while(time(NULL) - timeout < 10) { if(__io_custom_usbstorage.startup() && __io_custom_usbstorage.isInserted()) break; usleep(50000); } fatInitDefault(); gprintf("Nintendont at your service!\r\n%s\r\n", NIN_BUILD_STRING); KernelLoaded = 1; char* first_slash = strrchr(argv[0], '/'); if (first_slash != NULL) strncpy(launch_dir, argv[0], first_slash-argv[0]+1); gprintf("launch_dir = %s\r\n", launch_dir); FPAD_Init(); FPAD_Update(); /* Read IPL Font before doing any patches */ void *fontbuffer = memalign(32, 0x50000); __SYS_ReadROM((void*)fontbuffer,0x50000,0x1AFF00); memcpy((void*)0xD3100000, fontbuffer, 0x50000); DCInvalidateRange( (void*)0x93100000, 0x50000 ); free(fontbuffer); //gprintf("Font: 0x1AFF00 starts with %.4s, 0x1FCF00 with %.4s\n", (char*)0x93100000, (char*)0x93100000 + 0x4D000); // Simple code to autoupdate the meta.xml in Nintendont's folder FILE *meta = fopen("meta.xml", "w"); if(meta != NULL) { fprintf(meta, "%s\r\n<app version=\"1\">\r\n\t<name>%s</name>\r\n", META_XML, META_NAME); fprintf(meta, "\t<coder>%s</coder>\r\n\t<version>%d.%d</version>\r\n", META_AUTHOR, NIN_VERSION>>16, NIN_VERSION&0xFFFF); fprintf(meta, "\t<release_date>20150531000000</release_date>\r\n"); fprintf(meta, "\t<short_description>%s</short_description>\r\n", META_SHORT); fprintf(meta, "\t<long_description>%s\r\n\r\n%s</long_description>\r\n", META_LONG1, META_LONG2); fprintf(meta, "\t<ahb_access/>\r\n</app>"); fclose(meta); }
int isInserted(const char *path) { if (!strncmp(path, "USB:", 4)) return 1; return __io_sdhc.isInserted() || __io_wiisd.isInserted(); }