static void frontend_ctr_deinit(void *data) { (void)data; #ifndef IS_SALAMANDER global_t *global = global_get_ptr(); global->verbosity = true; #ifdef HAVE_FILE_LOGGER if (global->log_file) fclose(global->log_file); global->log_file = NULL; #endif wait_for_input(); csndExit(); gfxExit(); #if 0 sdmcExit(); fsExit(); hidExit(); aptExit(); srvExit(); #endif #endif }
void exitServices() { gpuExit(); gfxExit(); sdmcExit(); hidExit(); }
void __appExit() { // Exit services pxiDevExit(); sdmcExit(); fsExit(); hidExit(); gfxExit(); aptExit(); srvExit(); }
static void frontend_ctr_deinit(void *data) { extern PrintConsole* currentConsole; Handle lcd_handle; u8 not_2DS; (void)data; #ifndef IS_SALAMANDER global_t *global = global_get_ptr(); global->verbosity = true; #ifdef HAVE_FILE_LOGGER if (global->log_file) fclose(global->log_file); global->log_file = NULL; #endif if(gfxBottomFramebuffers[0] == (u8*)currentConsole->frameBuffer) wait_for_input(); CFGU_GetModelNintendo2DS(¬_2DS); if(not_2DS && srvGetServiceHandle(&lcd_handle, "gsp::Lcd") >= 0) { u32 *cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = 0x00110040; cmdbuf[1] = 2; svcSendSyncRequest(lcd_handle); svcCloseHandle(lcd_handle); } exitCfgu(); csndExit(); gfxExit(); #if 0 sdmcExit(); fsExit(); hidExit(); aptExit(); srvExit(); #endif #endif }
s32 main (void) { // Initialize services srvInit(); aptInit(); hidInit(NULL); gfxInitDefault(); fsInit(); sdmcInit(); hbInit(); qtmInit(); Handle fileHandle; u32 bytesRead; FS_archive sdmcArchive=(FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}}; FS_path filePath=FS_makePath(PATH_CHAR, "/rxTools.dat"); Result ret=FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE); if(ret) goto EXIT; FSFILE_Read(fileHandle, &bytesRead, 0x20000, 0x14400000, 320*1024); FSFILE_Close(fileHandle); consoleInit(GFX_BOTTOM, NULL); if (brahma_init()) { quick_boot_firm(1); printf("[!] Quickload failed\n"); brahma_exit(); } else { printf("* BRAHMA *\n\n[!]Not enough memory\n"); wait_any_key(); } EXIT: hbExit(); sdmcExit(); fsExit(); gfxExit(); hidExit(); aptExit(); srvExit(); // Return to hbmenu return 0; }
s32 main(void) { // Initialize services srvInit(); aptInit(); hidInit(NULL); gfxInitDefault(); gfxSet3D(true); fsInit(); sdmcInit(); hbInit(); qtmInit(); gfxSwapBuffers(); Handle fileHandle; u32 bytesRead; FS_archive sdmcArchive = (FS_archive){ ARCH_SDMC, (FS_path){ PATH_EMPTY, 1, (u8*)"" } }; FS_path filePath = FS_makePath(PATH_CHAR, "/" CODE_PATH); Result ret = FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE); if (ret) goto EXIT; FSFILE_Read(fileHandle, &bytesRead, 0x14000, 0x14400000, 320 * 1024); FSFILE_Close(fileHandle); if (brahma_init()) { quick_boot_firm(1); brahma_exit(); } EXIT: hbExit(); sdmcExit(); fsExit(); gfxExit(); hidExit(); aptExit(); srvExit(); // Return to hbmenu return 0; }
/*! deinitialize ftp subsystem */ void ftp_exit(void) { #ifdef _3DS Result ret; #endif /* clean up all sessions */ while(sessions != NULL) ftp_session_destroy(sessions); /* stop listening for new clients */ if(listenfd >= 0) ftp_closesocket(listenfd, 0); #ifdef _3DS /* deinitialize SOC service */ ret = SOC_Shutdown(); if(ret != 0) console_print(RED "SOC_Shutdown: 0x%08X\n" RESET, (unsigned int)ret); free(SOC_buffer); #ifdef ENABLE_LOGGING /* close log file */ if(fclose(stderr) != 0) console_print(RED "fclose: 0x%08X\n" RESET, errno); /* deinitialize sdmc_dev */ ret = sdmcExit(); if(ret != 0) console_print(RED "sdmcExit: 0x%08X\n" RESET, (unsigned int)ret); #endif /* deinitialize FS service */ ret = fsExit(); if(ret != 0) console_print(RED "fsExit: 0x%08X\n" RESET, (unsigned int)ret); #endif }
void exitFilesystem(void) { sdmcExit(); //Crashes here fsExit(); }
void __appExit(void) { // Exit services sdmcExit(); fsExit(); srvExit(); }
/*! initialize ftp subsystem */ int ftp_init(void) { int rc; #ifdef _3DS Result ret; /* initialize FS service */ ret = fsInit(); if(ret != 0) { console_print(RED "fsInit: 0x%08X\n" RESET, (unsigned int)ret); goto fs_fail; } /* initialize sdmc_dev */ ret = sdmcInit(); if(ret != 0) { console_print(RED "sdmcInit: 0x%08X\n" RESET, (unsigned int)ret); goto sdmc_fail; } #if ENABLE_LOGGING /* open log file */ FILE *fp = freopen("/ftbrony.log", "wb", stderr); if(fp == NULL) { console_print(RED "freopen: 0x%08X\n" RESET, errno); goto stderr_fail; } /* truncate log file */ if(ftruncate(fileno(fp), 0) != 0) { console_print(RED "ftruncate: 0x%08X\n" RESET, errno); goto ftruncate_fail; } #endif /* allocate buffer for SOC service */ SOC_buffer = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE); if(SOC_buffer == NULL) { console_print(RED "memalign: failed to allocate\n" RESET); goto memalign_fail; } /* initialize SOC service */ ret = SOC_Initialize(SOC_buffer, SOC_BUFFERSIZE); if(ret != 0) { console_print(RED "SOC_Initialize: 0x%08X\n" RESET, (unsigned int)ret); goto soc_fail; } #endif /* allocate socket to listen for clients */ listenfd = socket(AF_INET, SOCK_STREAM, 0); if(listenfd < 0) { console_print(RED "socket: %d %s\n" RESET, errno, strerror(errno)); ftp_exit(); return -1; } /* get address to listen on */ serv_addr.sin_family = AF_INET; #ifdef _3DS serv_addr.sin_addr.s_addr = gethostid(); serv_addr.sin_port = htons(LISTEN_PORT); #else serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(LISTEN_PORT); /* reuse address */ { int yes = 1; rc = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)); if(rc != 0) { console_print(RED "setsockopt: %d %s\n" RESET, errno, strerror(errno)); ftp_exit(); return -1; } } #endif /* bind socket to listen address */ rc = bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); if(rc != 0) { console_print(RED "bind: %d %s\n" RESET, errno, strerror(errno)); ftp_exit(); return -1; } /* listen on socket */ rc = listen(listenfd, 5); if(rc != 0) { console_print(RED "listen: %d %s\n" RESET, errno, strerror(errno)); ftp_exit(); return -1; } /* print server address */ #ifdef _3DS console_set_status("\n" GREEN STATUS_STRING " " YELLOW "IP:" CYAN "%s " YELLOW "Port:" CYAN "%u" RESET, inet_ntoa(serv_addr.sin_addr), ntohs(serv_addr.sin_port)); #else { char hostname[128]; socklen_t addrlen = sizeof(serv_addr); rc = getsockname(listenfd, (struct sockaddr*)&serv_addr, &addrlen); if(rc != 0) { console_print(RED "getsockname: %d %s\n" RESET, errno, strerror(errno)); ftp_exit(); return -1; } rc = gethostname(hostname, sizeof(hostname)); if(rc != 0) { console_print(RED "gethostname: %d %s\n" RESET, errno, strerror(errno)); ftp_exit(); return -1; } console_set_status(GREEN STATUS_STRING " " YELLOW "IP:" CYAN "%s " YELLOW "Port:" CYAN "%u" RESET, hostname, ntohs(serv_addr.sin_port)); } #endif return 0; #ifdef _3DS soc_fail: free(SOC_buffer); memalign_fail: #ifdef ENABLE_LOGGING ftruncate_fail: if(fclose(stderr) != 0) console_print(RED "fclose: 0x%08X\n" RESET, errno); stderr_fail: #endif ret = sdmcExit(); if(ret != 0) console_print(RED "sdmcExit: 0x%08X\n" RESET, (unsigned int)ret); sdmc_fail: ret = fsExit(); if(ret != 0) console_print(RED "fsExit: 0x%08X\n" RESET, (unsigned int)ret); fs_fail: return -1; #endif }
void exitFilesystem(void) { sdmcExit(); fsExit(); }