Clean up and follow up on code consistency

This commit is contained in:
Joel 2017-07-05 16:22:25 -04:00
parent 669b5d0115
commit 51697267e4
12 changed files with 216 additions and 202 deletions

View File

@ -4,16 +4,8 @@
#include <3ds.h> #include <3ds.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
Handle actHandle;
int actRefCount;
u32 *act_shareMemAddr;
u32 act_shareMemSize;
Handle act_shareMemHandle;
Result actInit(u32 sdkVer, u32 sharedMemSize); Result actInit(u32 sdkVer, u32 sharedMemSize);
void actExit(void); void actExit(void);
Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize); Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize);

View File

@ -2,12 +2,7 @@
#define AM_H #define AM_H
#include <3ds.h> #include <3ds.h>
#include <stdlib.h>
#include <string.h>
Handle amHandle;
char * base64encode(const char * input);
Result amNetGetDeviceCert(u8 const * buffer); Result amNetGetDeviceCert(u8 const * buffer);
#endif #endif

View File

@ -3,8 +3,6 @@
#include <3ds.h> #include <3ds.h>
Handle cfgHandle;
Result cfgsInit(); Result cfgsInit();
Result cfgsExit(); Result cfgsExit();
Result CFG_GetConfig(u32 size, u32 blkID, u8* outData); Result CFG_GetConfig(u32 size, u32 blkID, u8* outData);

View File

@ -3,8 +3,6 @@
#include <3ds.h> #include <3ds.h>
Handle gspLcdHandle;
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness); Result GSPLCD_GetBrightness(u32 screen, u32 *brightness);
#endif #endif

View File

@ -3,8 +3,6 @@
#include <3ds.h> #include <3ds.h>
Handle mcuhwcHandle;
Result mcuInit(); Result mcuInit();
Result mcuExit(); Result mcuExit();
Result mcuGetBatteryLevel(u8* out); Result mcuGetBatteryLevel(u8* out);

View File

@ -11,7 +11,7 @@ Option:
UseOnSD : true # true if App is to be installed to SD UseOnSD : true # true if App is to be installed to SD
FreeProductCode : true # Removes limitations on ProductCode FreeProductCode : true # Removes limitations on ProductCode
MediaFootPadding : false # If true CCI files are created with padding MediaFootPadding : false # If true CCI files are created with padding
EnableCrypt : false # Enables encryption for NCCH and CIA" EnableCrypt : false # Enables encryption for NCCH and CIA
EnableCompress : true # Compresses where applicable (currently only exefs:/.code) EnableCompress : true # Compresses where applicable (currently only exefs:/.code)
AccessControlInfo: AccessControlInfo:
@ -31,36 +31,37 @@ AccessControlInfo:
# FS:USER Archive Access Permissions # FS:USER Archive Access Permissions
# Uncomment as required # Uncomment as required
FileSystemAccess: FileSystemAccess:
#- CategorySystemApplication - CategorySystemApplication
#- CategoryHardwareCheck - CategoryHardwareCheck
- CategoryFileSystemTool - CategoryFileSystemTool
#- Debug - Debug
#- TwlCardBackup - TwlCardBackup
#- TwlNandData - TwlNandData
#- Boss - Boss
- DirectSdmc - DirectSdmc
#- Core - Core
#- CtrNandRo - CtrNandRo
#- CtrNandRw - CtrNandRw
#- CtrNandRoWrite - CtrNandRoWrite
#- CategorySystemSettings - CategorySystemSettings
#- CardBoard - CardBoard
#- ExportImportIvs - ExportImportIvs
#- DirectSdmcWrite - DirectSdmcWrite
#- SwitchCleanup - SwitchCleanup
#- SaveDataMove - SaveDataMove
#- Shop - Shop
#- Shell - Shell
#- CategoryHomeMenu - CategoryHomeMenu
- SeedDB
IoAccessControl: IoAccessControl:
#- FsMountNand - FsMountNand
#- FsMountNandRoWrite - FsMountNandRoWrite
#- FsMountTwln - FsMountTwln
#- FsMountWnand - FsMountWnand
#- FsMountCardSpi - FsMountCardSpi
#- UseSdif3 - UseSdif3
#- CreateSeed - CreateSeed
#- UseCardSpi - UseCardSpi
# Process Settings # Process Settings
MemoryType : Application # Application/System/Base MemoryType : Application # Application/System/Base
@ -82,7 +83,7 @@ AccessControlInfo:
# New3DS Exclusive Process Settings # New3DS Exclusive Process Settings
SystemModeExt : $(APP_SYSTEM_MODE_EXT) # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode SystemModeExt : $(APP_SYSTEM_MODE_EXT) # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
CpuSpeed : 804MHz # 256MHz(Default)/804MHz CpuSpeed : $(APP_CPU_SPEED) # 268MHz(Default)/804MHz
EnableL2Cache : true # false(default)/true EnableL2Cache : true # false(default)/true
CanAccessCore2 : true CanAccessCore2 : true
@ -92,61 +93,115 @@ AccessControlInfo:
MemoryMapping: MemoryMapping:
- 1f000000-1f5fffff:r # VRAM - 1f000000-1f5fffff:r # VRAM
# Accessible SVCs, <Name>:<ID> # Accessible SVCs, <Name>:<ID>
SystemCallAccess: SystemCallAccess:
ArbitrateAddress: 34
Backdoor: 123
Break: 60
CancelTimer: 28
ClearEvent: 25
ClearTimer: 29
CloseHandle: 35
ConnectToPort: 45
ControlMemory: 1 ControlMemory: 1
ControlProcessMemory: 112
CreateAddressArbiter: 33
CreateEvent: 23
CreateMemoryBlock: 30
CreateMutex: 19
CreateSemaphore: 21
CreateThread: 8
CreateTimer: 26
DuplicateHandle: 39
ExitProcess: 3
ExitThread: 9
GetCurrentProcessorNumber: 17
GetHandleInfo: 41
GetProcessId: 53
GetProcessIdOfThread: 54
GetProcessIdealProcessor: 6
GetProcessInfo: 43
GetResourceLimit: 56
GetResourceLimitCurrentValues: 58
GetResourceLimitLimitValues: 57
GetSystemInfo: 42
GetSystemTick: 40
GetThreadContext: 59
GetThreadId: 55
GetThreadIdealProcessor: 15
GetThreadInfo: 44
GetThreadPriority: 11
MapMemoryBlock: 31
OutputDebugString: 61
QueryMemory: 2 QueryMemory: 2
ExitProcess: 3
GetProcessAffinityMask: 4
SetProcessAffinityMask: 5
GetProcessIdealProcessor: 6
SetProcessIdealProcessor: 7
CreateThread: 8
ExitThread: 9
SleepThread: 10
GetThreadPriority: 11
SetThreadPriority: 12
GetThreadAffinityMask: 13
SetThreadAffinityMask: 14
GetThreadIdealProcessor: 15
SetThreadIdealProcessor: 16
GetCurrentProcessorNumber: 17
Run: 18
CreateMutex: 19
ReleaseMutex: 20 ReleaseMutex: 20
CreateSemaphore: 21
ReleaseSemaphore: 22 ReleaseSemaphore: 22
CreateEvent: 23
SignalEvent: 24
ClearEvent: 25
CreateTimer: 26
SetTimer: 27
CancelTimer: 28
ClearTimer: 29
CreateMemoryBlock: 30
MapMemoryBlock: 31
UnmapMemoryBlock: 32
CreateAddressArbiter: 33
ArbitrateAddress: 34
CloseHandle: 35
WaitSynchronization1: 36
WaitSynchronizationN: 37
SignalAndWait: 38
DuplicateHandle: 39
GetSystemTick: 40
GetHandleInfo: 41
GetSystemInfo: 42
GetProcessInfo: 43
GetThreadInfo: 44
ConnectToPort: 45
SendSyncRequest1: 46 SendSyncRequest1: 46
SendSyncRequest2: 47 SendSyncRequest2: 47
SendSyncRequest3: 48 SendSyncRequest3: 48
SendSyncRequest4: 49 SendSyncRequest4: 49
SendSyncRequest: 50 SendSyncRequest: 50
SetThreadPriority: 12 OpenProcess: 51
SetTimer: 27 OpenThread: 52
SignalEvent: 24 GetProcessId: 53
SleepThread: 10 GetProcessIdOfThread: 54
UnmapMemoryBlock: 32 GetThreadId: 55
WaitSynchronization1: 36 GetResourceLimit: 56
WaitSynchronizationN: 37 GetResourceLimitLimitValues: 57
GetResourceLimitCurrentValues: 58
GetThreadContext: 59
Break: 60
OutputDebugString: 61
ControlPerformanceCounter: 62
CreatePort: 71
CreateSessionToPort: 72
CreateSession: 73
AcceptSession: 74
ReplyAndReceive1: 75
ReplyAndReceive2: 76
ReplyAndReceive3: 77
ReplyAndReceive4: 78
ReplyAndReceive: 79
BindInterrupt: 80
UnbindInterrupt: 81
InvalidateProcessDataCache: 82
StoreProcessDataCache: 83
FlushProcessDataCache: 84
StartInterProcessDma: 85
StopDma: 86
GetDmaState: 87
RestartDma: 88
DebugActiveProcess: 96
BreakDebugProcess: 97
TerminateDebugProcess: 98
GetProcessDebugEvent: 99
ContinueDebugEvent: 100
GetProcessList: 101
GetThreadList: 102
GetDebugThreadContext: 103
SetDebugThreadContext: 104
QueryDebugProcessMemory: 105
ReadProcessMemory: 106
WriteProcessMemory: 107
SetHardwareBreakPoint: 108
GetDebugThreadParam: 109
ControlProcessMemory: 112
MapProcessMemory: 113
UnmapProcessMemory: 114
CreateCodeSet: 115
CreateProcess: 117
TerminateProcess: 118
SetProcessResourceLimits: 119
CreateResourceLimit: 120
SetResourceLimitValues: 121
AddCodeSegment: 122
Backdoor: 123
KernelSetState: 124
QueryProcessMemory: 125
# Service List # Service List
# Maximum 34 services (32 if firmware is prior to 9.6.0) # Maximum 34 services (32 if firmware is prior to 9.6.0)
@ -155,41 +210,37 @@ AccessControlInfo:
- ac:u - ac:u
- act:u - act:u
- am:net - am:net
- $hioFIO
- $hostio0
- $hostio1
- boss:U - boss:U
- cam:u - cam:u
- cecd:u - cecd:u
- cfg:nor
- cfg:u - cfg:u
- cfg:s - cfg:s
- dlp:FKCL - csnd:SND
- dlp:SRVR
- dsp::DSP - dsp::DSP
- fs:USER - fs:USER
- gsp::Gpu - gsp::Gpu
- gsp::Lcd - gsp::Lcd
- hid:USER - hid:USER
- http:C
- ir:rst - ir:rst
- ir:u - ir:u
- ir:USER - ir:USER
- mcu::HWC - mcu::HWC
- ndm:u - ndm:u
- ps:ps - news:s
- nwm::EXT
- nwm::UDS - nwm::UDS
- ptm:sysm
- ptm:u - ptm:u
- pxi:dev - pxi:dev
- soc:U - soc:U
- ssl:C
- y2r:u - y2r:u
- ldr:ro
- csnd:SND
- am:u
- ns:s
SystemControlInfo: SystemControlInfo:
SaveDataSize: 0KB # Change if the app uses savedata SaveDataSize: 0KB # Change if the app uses savedata
RemasterVersion: 2 RemasterVersion: 1
StackSize: 0x40000 StackSize: 0x40000
# Modules that run services listed above should be included below # Modules that run services listed above should be included below
@ -197,7 +248,7 @@ SystemControlInfo:
# <module name>:<module titleid> # <module name>:<module titleid>
Dependency: Dependency:
ac: 0x0004013000002402 ac: 0x0004013000002402
act: 0x0004013000003802 #act: 0x0004013000003802
am: 0x0004013000001502 am: 0x0004013000001502
boss: 0x0004013000003402 boss: 0x0004013000003402
camera: 0x0004013000001602 camera: 0x0004013000001602
@ -218,13 +269,13 @@ SystemControlInfo:
mic: 0x0004013000002002 mic: 0x0004013000002002
ndm: 0x0004013000002b02 ndm: 0x0004013000002b02
news: 0x0004013000003502 news: 0x0004013000003502
nfc: 0x0004013000004002 #nfc: 0x0004013000004002
nim: 0x0004013000002c02 nim: 0x0004013000002c02
nwm: 0x0004013000002d02 nwm: 0x0004013000002d02
pdn: 0x0004013000002102 pdn: 0x0004013000002102
ps: 0x0004013000003102 ps: 0x0004013000003102
ptm: 0x0004013000002202 ptm: 0x0004013000002202
qtm: 0x0004013020004202 #qtm: 0x0004013020004202
ro: 0x0004013000003702 ro: 0x0004013000003702
socket: 0x0004013000002e02 socket: 0x0004013000002e02
spi: 0x0004013000002302 spi: 0x0004013000002302

View File

@ -108,9 +108,9 @@ int main(int argc, char *argv[])
ret = osGetSystemVersionData(nver, cver); ret = osGetSystemVersionData(nver, cver);
if (ret) if (ret)
printf("\x1b[33;1m*\x1b[0m osGetSystemVersionData returned 0x%08liX\n\n", ret); printf("\x1b[33;1m*\x1b[0m System version: 0x%08liX\n\n", ret);
snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m Current system version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n", snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m System version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
cver->mainver, cver->mainver,
cver->minor, cver->minor,
cver->build, cver->build,
@ -163,7 +163,7 @@ int main(int argc, char *argv[])
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n\x1b[0m", batteryPercent, batteryStatus()); printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n\x1b[0m", batteryPercent, batteryStatus());
mcuGetBatteryVoltage(&batteryVolt); mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m\n", batteryVolt);//,(Estimated: %0.1lf V) estimatedVolt); printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0)); // Estimated volt
u8 mcuFwMajor, mcuFwMinor; u8 mcuFwMajor, mcuFwMinor;
@ -185,18 +185,6 @@ int main(int argc, char *argv[])
printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize); printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize);
printf("\x1b[32;1m*\x1b[0m Installed titles: SD: \x1b[32;1m%i\x1b[0m (NAND: \x1b[32;1m%i\x1b[0m)\n", (int)titleCount(MEDIATYPE_SD), (int)titleCount(MEDIATYPE_NAND)); printf("\x1b[32;1m*\x1b[0m Installed titles: SD: \x1b[32;1m%i\x1b[0m (NAND: \x1b[32;1m%i\x1b[0m)\n", (int)titleCount(MEDIATYPE_SD), (int)titleCount(MEDIATYPE_NAND));
/*wifiPercent = (osGetWifiStrength() * 33.3333333333);
printf("\x1b[32;1m*\x1b[0m WiFi signal strength: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
HIDUSER_GetSoundVolume(&volume);
volPercent = (volume * 1.5873015873);
printf("\x1b[32;1m*\x1b[0m Volume slider state: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", volume, volPercent);
_3dSliderPercent = (osGet3DSliderState() * 100.0);
printf("\x1b[32;1m*\x1b[0m 3D slider state: \x1b[32;1m%.1lf\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));*/
while (aptMainLoop()) while (aptMainLoop())
{ {
@ -210,7 +198,7 @@ int main(int argc, char *argv[])
printf("\x1b[19;0H"); //Move the cursor to the top left corner of the screen printf("\x1b[19;0H"); //Move the cursor to the top left corner of the screen
mcuGetBatteryVoltage(&batteryVolt); mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m\n", batteryVolt);//,(Estimated: %0.1lf V) estimatedVolt); printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt);
//=====================================================================// //=====================================================================//
//------------------------------Misc Info------------------------------// //------------------------------Misc Info------------------------------//
//=====================================================================// //=====================================================================//

View File

@ -1,11 +1,21 @@
#include "actu.h" #include "actu.h"
static Handle actHandle;
static int actRefCount;
static u32 *act_shareMemAddr;
static u32 act_shareMemSize;
static Handle act_shareMemHandle;
Result actInit(u32 sdkVer, u32 sharedMemSize) Result actInit(u32 sdkVer, u32 sharedMemSize)
{ {
Result ret=0; Result ret = 0;
ret = srvGetServiceHandle(&actHandle, "act:u"); ret = srvGetServiceHandle(&actHandle, "act:u");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&actHandle, "act:a");
if (R_FAILED(ret))
ret = srvGetServiceHandle(&actHandle, "act:a");
if (R_SUCCEEDED(ret)) if (R_SUCCEEDED(ret))
{ {
act_shareMemSize = sharedMemSize; act_shareMemSize = sharedMemSize;
@ -14,6 +24,7 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
if(act_shareMemSize) if(act_shareMemSize)
{ {
act_shareMemAddr = (u32*)memalign(0x1000, act_shareMemSize); act_shareMemAddr = (u32*)memalign(0x1000, act_shareMemSize);
if(act_shareMemAddr != NULL) if(act_shareMemAddr != NULL)
{ {
memset((void*)act_shareMemAddr, 0, act_shareMemSize); memset((void*)act_shareMemAddr, 0, act_shareMemSize);
@ -22,6 +33,7 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
actExit(); actExit();
} }
} }
ret = ACT_Initialize(sdkVer, &act_shareMemHandle, act_shareMemSize); ret = ACT_Initialize(sdkVer, &act_shareMemHandle, act_shareMemSize);
if (R_FAILED(ret)) if (R_FAILED(ret))
@ -32,7 +44,9 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
void actExit(void) void actExit(void)
{ {
if (AtomicDecrement(&actRefCount)) return; if (AtomicDecrement(&actRefCount))
return;
svcCloseHandle(actHandle); svcCloseHandle(actHandle);
if(act_shareMemHandle) if(act_shareMemHandle)
@ -59,7 +73,8 @@ Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize)
cmdbuf[5] = 0; cmdbuf[5] = 0;
cmdbuf[6] = (u32)addr; cmdbuf[6] = (u32)addr;
if(R_FAILED(ret = svcSendSyncRequest(actHandle))) return ret; if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
@ -76,7 +91,8 @@ Result ACT_GetAccountInfo(void *buffer, u32 size, u32 blkId)
cmdbuf[4] = 0x10 * size | 0xC; cmdbuf[4] = 0x10 * size | 0xC;
cmdbuf[5] = (u32)buffer; cmdbuf[5] = (u32)buffer;
if(R_FAILED(ret = svcSendSyncRequest(actHandle))) return ret; if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
@ -104,7 +120,8 @@ Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle)
cmdbuf[5] = 0x0; cmdbuf[5] = 0x0;
cmdbuf[6] = handle; cmdbuf[6] = handle;
if((ret = svcSendSyncRequest(actHandle))!=0) return ret; if((ret = svcSendSyncRequest(actHandle))!= 0)
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
@ -121,7 +138,8 @@ Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output
cmdbuf[4] = (size << 4) | 0xC; cmdbuf[4] = (size << 4) | 0xC;
cmdbuf[5] = (u32) output; cmdbuf[5] = (u32) output;
if((ret = svcSendSyncRequest(actHandle))!=0) return ret; if((ret = svcSendSyncRequest(actHandle))!= 0)
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }

View File

@ -1,59 +1,6 @@
#include "am.h" #include "am.h"
char * base64encode(const char * input)
{
int len = strlen(input);
int leftover = len % 3;
char *ret = malloc(((len/3) * 4) + ((leftover)?4:0) + 1);
int n = 0;
int outlen = 0;
uint8_t i = 0;
uint8_t *inp = (uint8_t *) input;
const char *index = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
if (ret == NULL) static Handle amHandle;
return NULL;
// Convert each 3 bytes of input to 4 bytes of output.
len -= leftover;
for (n = 0; n < len; n+=3) {
i = inp[n] >> 2;
ret[outlen++] = index[i];
i = (inp[n] & 0x03) << 4;
i |= (inp[n+1] & 0xf0) >> 4;
ret[outlen++] = index[i];
i = ((inp[n+1] & 0x0f) << 2);
i |= ((inp[n+2] & 0xc0) >> 6);
ret[outlen++] = index[i];
i = (inp[n+2] & 0x3f);
ret[outlen++] = index[i];
}
// Handle leftover 1 or 2 bytes.
if (leftover) {
i = (inp[n] >> 2);
ret[outlen++] = index[i];
i = (inp[n] & 0x03) << 4;
if (leftover == 2) {
i |= (inp[n+1] & 0xf0) >> 4;
ret[outlen++] = index[i];
i = ((inp[n+1] & 0x0f) << 2);
}
ret[outlen++] = index[i];
ret[outlen++] = '=';
if (leftover == 1)
ret[outlen++] = '=';
}
ret[outlen] = '\0';
return ret;
}
Result amNetGetDeviceCert(u8 const * buffer) Result amNetGetDeviceCert(u8 const * buffer)
{ {
@ -65,7 +12,8 @@ Result amNetGetDeviceCert(u8 const * buffer)
cmdbuf[2] = (0x180 << 4) | 0xC; cmdbuf[2] = (0x180 << 4) | 0xC;
cmdbuf[3] = (u32)buffer; cmdbuf[3] = (u32)buffer;
if(R_FAILED(ret = svcSendSyncRequest(amHandle))) return ret; if(R_FAILED(ret = svcSendSyncRequest(amHandle)))
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }

View File

@ -1,5 +1,7 @@
#include "cfgs.h" #include "cfgs.h"
static Handle cfgHandle;
Result cfgsInit() //Already initialized with CFGUinit(); Result cfgsInit() //Already initialized with CFGUinit();
{ {
return srvGetServiceHandle(&cfgHandle, "cfg:s"); return srvGetServiceHandle(&cfgHandle, "cfg:s");
@ -21,7 +23,8 @@ Result CFG_GetConfig(u32 size, u32 blkID, u8* outData)
cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_W); cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_W);
cmdbuf[4] = (u32)outData; cmdbuf[4] = (u32)outData;
if(R_FAILED(ret = svcSendSyncRequest(cfgHandle)))return ret; if (R_FAILED(ret = svcSendSyncRequest(cfgHandle)))
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
@ -36,7 +39,8 @@ Result cfgsSecureInfoGetSerialNo(char *serial)
cmdbuf[2] = 12 | (0xF << 4); cmdbuf[2] = 12 | (0xF << 4);
cmdbuf[3] = (u32)serial; cmdbuf[3] = (u32)serial;
if(R_FAILED(ret = svcSendSyncRequest(cfgHandle)))return ret; if (R_FAILED(ret = svcSendSyncRequest(cfgHandle)))
return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }

View File

@ -1,5 +1,7 @@
#include "gsplcd.h" #include "gsplcd.h"
static Handle gspLcdHandle;
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness) Result GSPLCD_GetBrightness(u32 screen, u32 *brightness)
{ {
u32 *cmdbuf = getThreadCommandBuffer(); u32 *cmdbuf = getThreadCommandBuffer();

View File

@ -1,5 +1,7 @@
#include "mcu.h" #include "mcu.h"
static Handle mcuhwcHandle;
Result mcuInit() Result mcuInit()
{ {
return srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC"); return srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC");
@ -12,31 +14,46 @@ Result mcuExit()
Result mcuGetBatteryLevel(u8* out) Result mcuGetBatteryLevel(u8* out)
{ {
u32* ipc = getThreadCommandBuffer(); u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x50000; ipc[0] = 0x50000;
Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret; Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0)
return ret;
*out = ipc[2]; *out = ipc[2];
return ipc[1];
return ipc[1];
} }
Result mcuGetBatteryVoltage(u8* out) Result mcuGetBatteryVoltage(u8* out)
{ {
u32* ipc = getThreadCommandBuffer(); u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x40000; ipc[0] = 0x40000;
Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret; Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0)
return ret;
*out = ipc[2]; *out = ipc[2];
return ipc[1];
return ipc[1];
} }
Result GetMcuFwVerHigh(u8* out) Result GetMcuFwVerHigh(u8* out)
{ {
u32* ipc = getThreadCommandBuffer(); u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x100000; ipc[0] = 0x100000;
Result ret = svcSendSyncRequest(mcuhwcHandle); Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret;
*out = ipc[2]; if(ret < 0)
return ret;
*out = ipc[2];
return ipc[1]; return ipc[1];
} }
@ -44,8 +61,13 @@ Result GetMcuFwVerLow(u8* out)
{ {
u32* ipc = getThreadCommandBuffer(); u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x110000; ipc[0] = 0x110000;
Result ret = svcSendSyncRequest(mcuhwcHandle); Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret;
*out = ipc[2]; if(ret < 0)
return ret;
*out = ipc[2];
return ipc[1]; return ipc[1];
} }