mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-06-15 19:49:17 +08:00
Cleanup initialization process, check for service access instead of 3dsx to determine use of svchax.
This commit is contained in:
parent
71e670edde
commit
417c345141
@ -88,7 +88,7 @@ static Result spi_get_page_size(SaveChip chip, u32* pageSize) {
|
||||
size = 256;
|
||||
break;
|
||||
default:
|
||||
res = R_FBI_UNSUPPORTED_OPERATION;
|
||||
res = R_FBI_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ static Result spi_get_capacity(SaveChip chip, u32* capacity) {
|
||||
cap = 8 * 1024 * 1024;
|
||||
break;
|
||||
default:
|
||||
res = R_FBI_UNSUPPORTED_OPERATION;
|
||||
res = R_FBI_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ static Result spi_get_capacity(SaveChip chip, u32* capacity) {
|
||||
|
||||
static Result spi_execute_command(SaveChip chip, void* cmd, u32 cmdSize, void* answer, u32 answerSize, void* data, u32 dataSize) {
|
||||
if(chip == CHIP_NONE) {
|
||||
return R_FBI_UNSUPPORTED_OPERATION;
|
||||
return R_FBI_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
bool infrared = chip == CHIP_FLASH_256KB_INFRARED || chip == CHIP_FLASH_512KB_INFRARED || chip == CHIP_FLASH_1MB_INFRARED || chip == CHIP_FLASH_8MB_INFRARED;
|
||||
@ -277,7 +277,7 @@ static Result spi_read_data(SaveChip chip, u32* bytesRead, void* data, u32 offse
|
||||
pos += size;
|
||||
break;
|
||||
default:
|
||||
res = R_FBI_UNSUPPORTED_OPERATION;
|
||||
res = R_FBI_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -341,7 +341,7 @@ static Result spi_write_data(SaveChip chip, u32* bytesWritten, void* data, u32 o
|
||||
case CHIP_FLASH_8MB:
|
||||
case CHIP_FLASH_8MB_INFRARED:
|
||||
default:
|
||||
res = R_FBI_UNSUPPORTED_OPERATION;
|
||||
res = R_FBI_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -456,7 +456,7 @@ static Result spi_get_save_chip(SaveChip* chip, SaveChip base) {
|
||||
if(base < CHIP_FLASH_256KB_INFRARED) {
|
||||
res = spi_get_save_chip(&c, CHIP_FLASH_256KB_INFRARED);
|
||||
} else {
|
||||
res = R_FBI_UNSUPPORTED_OPERATION;
|
||||
res = R_FBI_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
break;
|
||||
|
113
source/main.c
113
source/main.c
@ -6,11 +6,57 @@
|
||||
#include "core/screen.h"
|
||||
#include "core/util.h"
|
||||
#include "svchax/svchax.h"
|
||||
#include "ui/error.h"
|
||||
#include "ui/mainmenu.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/section/task/task.h"
|
||||
|
||||
static void* soc_buffer;
|
||||
static void* soc_buffer = NULL;
|
||||
static u32 old_time_limit = UINT32_MAX;
|
||||
|
||||
void cleanup_services() {
|
||||
socExit();
|
||||
if(soc_buffer != NULL) {
|
||||
free(soc_buffer);
|
||||
soc_buffer = NULL;
|
||||
}
|
||||
|
||||
httpcExit();
|
||||
pxiDevExit();
|
||||
ptmuExit();
|
||||
acExit();
|
||||
cfguExit();
|
||||
amExit();
|
||||
}
|
||||
|
||||
Result init_services() {
|
||||
Result res = 0;
|
||||
|
||||
Handle tempAM = 0;
|
||||
if(R_SUCCEEDED(res = srvGetServiceHandle(&tempAM, "am:net"))) {
|
||||
svcCloseHandle(tempAM);
|
||||
|
||||
if(R_SUCCEEDED(res = amInit())
|
||||
&& R_SUCCEEDED(res = cfguInit())
|
||||
&& R_SUCCEEDED(res = acInit())
|
||||
&& R_SUCCEEDED(res = ptmuInit())
|
||||
&& R_SUCCEEDED(res = pxiDevInit())
|
||||
&& R_SUCCEEDED(res = httpcInit(0))) {
|
||||
soc_buffer = memalign(0x1000, 0x100000);
|
||||
if(soc_buffer != NULL) {
|
||||
res = socInit(soc_buffer, 0x100000);
|
||||
} else {
|
||||
res = R_FBI_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(R_FAILED(res)) {
|
||||
cleanup_services();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
clipboard_clear();
|
||||
@ -19,64 +65,65 @@ void cleanup() {
|
||||
ui_exit();
|
||||
screen_exit();
|
||||
|
||||
socExit();
|
||||
if(soc_buffer != NULL) {
|
||||
free(soc_buffer);
|
||||
soc_buffer = NULL;
|
||||
if(old_time_limit != UINT32_MAX) {
|
||||
APT_SetAppCpuTimeLimit(old_time_limit);
|
||||
}
|
||||
|
||||
amExit();
|
||||
httpcExit();
|
||||
pxiDevExit();
|
||||
ptmuExit();
|
||||
acExit();
|
||||
cfguExit();
|
||||
cleanup_services();
|
||||
|
||||
romfsExit();
|
||||
|
||||
gfxExit();
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
void init() {
|
||||
gfxInitDefault();
|
||||
|
||||
if(argc > 0) {
|
||||
Result romfsRes = romfsInit();
|
||||
if(R_FAILED(romfsRes)) {
|
||||
util_panic("Failed to mount RomFS: %08lX", romfsRes);
|
||||
return;
|
||||
}
|
||||
|
||||
if(R_FAILED(init_services())) {
|
||||
svchax_init(true);
|
||||
if(!__ctr_svchax || !__ctr_svchax_srv) {
|
||||
util_panic("Failed to acquire kernel access.");
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
util_set_3dsx_path(argv[0]);
|
||||
Result initRes = init_services();
|
||||
if(R_FAILED(initRes)) {
|
||||
util_panic("Failed to initialize services: %08lX", initRes);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Result setCpuTimeRes = APT_SetAppCpuTimeLimit(30);
|
||||
if(R_FAILED(setCpuTimeRes)) {
|
||||
util_panic("Failed to set syscore CPU time limit: %08lX", setCpuTimeRes);
|
||||
return 1;
|
||||
APT_GetAppCpuTimeLimit(&old_time_limit);
|
||||
Result cpuRes = APT_SetAppCpuTimeLimit(30);
|
||||
if(R_FAILED(cpuRes)) {
|
||||
util_panic("Failed to set syscore CPU time limit: %08lX", cpuRes);
|
||||
return;
|
||||
}
|
||||
|
||||
romfsInit();
|
||||
cfguInit();
|
||||
acInit();
|
||||
ptmuInit();
|
||||
pxiDevInit();
|
||||
httpcInit(0);
|
||||
|
||||
amInit();
|
||||
AM_InitializeExternalTitleDatabase(false);
|
||||
|
||||
soc_buffer = memalign(0x1000, 0x100000);
|
||||
if(soc_buffer != NULL) {
|
||||
socInit(soc_buffer, 0x100000);
|
||||
}
|
||||
|
||||
screen_init();
|
||||
ui_init();
|
||||
task_init();
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
if(argc > 0) {
|
||||
util_set_3dsx_path(argv[0]);
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
mainmenu_open();
|
||||
|
||||
while(aptMainLoop() && ui_update());
|
||||
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
#define R_FBI_THREAD_CREATE_FAILED MAKERESULT(RL_PERMANENT, RS_INTERNAL, RM_APPLICATION, 6)
|
||||
#define R_FBI_PARSE_FAILED MAKERESULT(RL_PERMANENT, RS_INTERNAL, RM_APPLICATION, 7)
|
||||
#define R_FBI_BAD_DATA MAKERESULT(RL_PERMANENT, RS_INTERNAL, RM_APPLICATION, 8)
|
||||
#define R_FBI_UNSUPPORTED_OPERATION MAKERESULT(RL_PERMANENT, RS_INTERNAL, RM_APPLICATION, RD_NOT_IMPLEMENTED)
|
||||
|
||||
#define R_FBI_NOT_IMPLEMENTED MAKERESULT(RL_PERMANENT, RS_INTERNAL, RM_APPLICATION, RD_NOT_IMPLEMENTED)
|
||||
#define R_FBI_OUT_OF_MEMORY MAKERESULT(RL_FATAL, RS_OUTOFRESOURCE, RM_APPLICATION, RD_OUT_OF_MEMORY)
|
||||
#define R_FBI_OUT_OF_RANGE MAKERESULT(RL_PERMANENT, RS_INVALIDARG, RM_APPLICATION, RD_OUT_OF_RANGE)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user