s32 svcGetResourceLimitCurrentValues() { u32 values_ptr = arm11_R(0); u32 handleResourceLimit = arm11_R(1); u32 names_ptr = arm11_R(2); u32 nameCount = arm11_R(3); for (u32 i = 0; i < nameCount; i++) { u32 temp = mem_Read32(names_ptr + i*4); switch (temp) { case 1: //GetUsingMemorySize mem_Write32(values_ptr + i * 8, 0x0); mem_Write32(values_ptr + i * 8 + 4, 0x0); break; default: DEBUG("unknown ResourceLimitCurrentValues %08x",temp); break; } } return 0; }
u32 srv_SyncRequest() { u32 cid = mem_Read32(arm11_ServiceBufferAddress() + 0x80); // Read command-id. switch(cid) { case 0x10002: DEBUG("srv_Initialize\n"); // XXX: check +4, flags? mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); //no error PAUSE(); return 0; case 0x20000: DEBUG("srv_GetProcSemaphore"); mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); //no error mem_Write32(arm11_ServiceBufferAddress() + 0x88, 0); //done in sm 4.4 mem_Write32(arm11_ServiceBufferAddress() + 0x8C, eventhandle); return 0; char names[9]; case 0x000400C0: DEBUG("srv_UnRegisterService --todo--\n"); // Read rest of command header mem_Read((u8*)&req, arm11_ServiceBufferAddress() + 0x84, sizeof(req)); memcpy(names, req.name, 8); names[8] = '\0'; DEBUG("name=%s, namelen=%u\n", names, req.name_len); return 0; case 0x00030100: DEBUG("srv_registerService\n"); // Read rest of command header mem_Read((u8*)&req, arm11_ServiceBufferAddress() + 0x84, sizeof(req)); memcpy(names, req.name, 8); names[8] = '\0'; DEBUG("name=%s, namelen=%u, unk=0x%x\n", names, req.name_len, req.unk2); ownservice[ownservice_num].name = malloc(9); memcpy(ownservice[ownservice_num].name, req.name, 9); ownservice[ownservice_num].handle = handle_New(HANDLE_TYPE_SERVICE, SERVICE_DIRECT); handleinfo* hi = handle_Get(ownservice[ownservice_num].handle); if (hi == NULL) { ERROR("getting handle.\n"); return 0x0; } hi->misc[0] = HANDLE_SERV_STAT_TAKEN; //init hi->misc_ptr[0] = malloc(0x200); mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); //no error mem_Write32(arm11_ServiceBufferAddress() + 0x8C, ownservice[ownservice_num].handle); //return handle ownservice_num++; return 0; case 0x50100: DEBUG("srv_GetServiceHandle\n"); // Read rest of command header mem_Read((u8*)&req, arm11_ServiceBufferAddress() + 0x84, sizeof(req)); memcpy(names, req.name, 8); names[8] = '\0'; DEBUG("name=%s, namelen=%u, unk=0x%x\n", names, req.name_len, req.unk2); PAUSE(); u32 i; bool overdr = false; for (u32 i = 0; i < overdrivnum; i++) { if (memcmp(req.name, *(overdrivnames + i), strnlen(*(overdrivnames + i), 8)) == 0)overdr = true; } if (!overdr) { for (u32 i = 0; i < ownservice_num; i++) { if (memcmp(req.name, ownservice[i].name, strnlen(ownservice[i].name, 8)) == 0) { // Write result. mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); // Write handle_out. mem_Write32(arm11_ServiceBufferAddress() + 0x8C, ownservice[i].handle); return 0; } } } for(i=0; i<ARRAY_SIZE(services); i++) { // Find service in list. if(memcmp(req.name, services[i].name, strnlen(services[i].name, 8)) == 0) { // Write result. mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); // Write handle_out. mem_Write32(arm11_ServiceBufferAddress() + 0x8C, services[i].handle); return 0; } } ERROR("Unimplemented service: %s\n", req.name); arm11_Dump(); exit(1); case 0x90040: // EnableNotificationType DEBUG("srv_EnableNotificationType\n"); u32 type = mem_Read32(arm11_ServiceBufferAddress() + 0x84); DEBUG("STUBBED, type=%x\n", type); mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); return 0; case 0xa0040: // DisableNotificationType DEBUG("srv_DisableNotificationType\n"); type = mem_Read32(arm11_ServiceBufferAddress() + 0x84); DEBUG("STUBBED, type=%x\n", type); mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); //no error return 0; case 0xB0000: // GetNotificationType DEBUG("srv_GetNotificationType\n"); //mem_Dbugdump(); mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0); //worked mem_Write32(arm11_ServiceBufferAddress() + 0x88, 0); //type return 0; default: ERROR("Unimplemented command %08x in \"srv:\"\n", cid); arm11_Dump(); mem_Write32(arm11_ServiceBufferAddress() + 0x84, 0xFFFFFFFF); //worked return 0; //exit(1); } return 0; }