...
 
Commits (38)
image: devkitpro/devkita64:latest
stages:
- package
- create image
package:
stage: package
before_script:
- dkp-pacman -S --noconfirm devkitARM
- export DEVKITPRO=/opt/devkitpro
- export DEVKITARM=/opt/devkitpro/devkitARM
script:
- make -j10
- make install
- rm -rf libnx/
- mv /opt/devkitpro/libnx libnx/
artifacts:
name: libnx
paths:
- libnx/
docker image:
stage: create image
script:
- "curl -X POST -F token=$TOKEN_DOCKER_IMAGE -F ref=master https://git.m4xw.net/api/v4/projects/103/trigger/pipeline"
when: on_success
only:
- master
nightly image:
stage: create image
script:
- "curl -X POST -F token=$TOKEN_DOCKER_IMAGE -F ref=develop https://git.m4xw.net/api/v4/projects/103/trigger/pipeline"
when: on_success
only:
- develop
- cicd/updates
......@@ -33,7 +33,7 @@ INCLUDES := include external/bsd/include
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
CFLAGS := -g -Wall -Werror \
CFLAGS := -g -Wall \
-ffunction-sections \
-fdata-sections \
$(ARCH) \
......@@ -122,7 +122,7 @@ debug:
lib/libnx.a : lib release $(SOURCES) $(INCLUDES)
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2" \
BUILD_CFLAGS="-DNDEBUG=1 -O3 -ffast-math" \
DEPSDIR=$(CURDIR)/release \
--no-print-directory -C release \
-f $(CURDIR)/Makefile
......
......@@ -90,6 +90,7 @@ extern "C" {
#include "switch/services/nfc.h"
#include "switch/services/wlaninf.h"
#include "switch/services/pctl.h"
#include "switch/services/pdm.h"
#include "switch/display/binder.h"
#include "switch/display/parcel.h"
......
......@@ -144,6 +144,66 @@ typedef enum {
DebugThreadParam_CoreMask=4,
} DebugThreadParam;
/// GetInfo IDs.
typedef enum {
InfoType_CoreMask = 0, ///< Bitmask of allowed Core IDs.
InfoType_PriorityMask = 1, ///< Bitmask of allowed Thread Priorities.
InfoType_AliasRegionAddress = 2, ///< Base of the Alias memory region.
InfoType_AliasRegionSize = 3, ///< Size of the Alias memory region.
InfoType_HeapRegionAddress = 4, ///< Base of the Heap memory region.
InfoType_HeapRegionSize = 5, ///< Size of the Heap memory region.
InfoType_TotalMemorySize = 6, ///< Total amount of memory available for process.
InfoType_UsedMemorySize = 7, ///< Amount of memory currently used by process.
InfoType_DebuggerAttached = 8, ///< Whether current process is being debugged.
InfoType_ResourceLimit = 9, ///< Current process's resource limit handle.
InfoType_IdleTickCount = 10, ///< Number of idle ticks on CPU.
InfoType_RandomEntropy = 11, ///< 2.0.0+ Random entropy for current process.
InfoType_AslrRegionAddress = 12, ///< 2.0.0+ Base of the process's address space.
InfoType_AslrRegionSize = 13, ///< 2.0.0+ Size of the process's address space.
InfoType_StackRegionAddress = 14, ///< 2.0.0+ Base of the Stack memory region.
InfoType_StackRegionSize = 15, ///< 2.0.0+ Size of the Stack memory region.
InfoType_SystemResourceSizeTotal = 16, ///< 3.0.0+ Total memory allocated for process memory management.
InfoType_SystemResourceSizeUsed = 17, ///< 3.0.0+ Amount of memory currently used by process memory management.
InfoType_TitleId = 18, ///< 3.0.0+ Title ID for the process.
InfoType_InitialProcessIdRange = 19, ///< 4.0.0-4.1.0 Min/max initial process IDs.
InfoType_UserExceptionContextAddress = 20, ///< 5.0.0+ Address of the process's exception context (for break).
InfoType_TotalNonSystemMemorySize = 21, ///< 6.0.0+ Total amount of memory available for process, excluding that for process memory management.
InfoType_UsedNonSystemMemorySize = 22, ///< 6.0.0+ Amount of memory used by process, excluding that for process memory management.
InfoType_ThreadTickCount = 0xF0000002, ///< Number of ticks spent on thread.
} InfoType;
/// GetSystemInfo IDs.
typedef enum {
SystemInfoType_TotalPhysicalMemorySize = 0, ///< Total amount of DRAM available to system.
SystemInfoType_UsedPhysicalMemorySize = 1, ///< Current amount of DRAM used by system.
SystemInfoType_InitialProcessIdRange = 2, ///< Min/max initial process IDs.
} SystemInfoType;
/// GetInfo Idle/Thread Tick Count Sub IDs.
typedef enum {
TickCountInfo_Core0 = 0, ///< Tick count on core 0.
TickCountInfo_Core1 = 1, ///< Tick count on core 1.
TickCountInfo_Core2 = 2, ///< Tick count on core 2.
TickCountInfo_Core3 = 3, ///< Tick count on core 3.
TickCountInfo_Total = U64_MAX, ///< Tick count on all cores.
} TickCountInfo;
/// GetInfo InitialProcessIdRange Sub IDs.
typedef enum {
InitialProcessIdRangeInfo_Minimum = 0, ///< Lowest initial process ID.
InitialProcessIdRangeInfo_Maximum = 1, ///< Highest initial process ID.
} InitialProcessIdRangeInfo;
/// GetSystemInfo PhysicalMemory Sub IDs.
typedef enum {
PhysicalMemoryInfo_Application = 0, ///< Memory allocated for application usage.
PhysicalMemoryInfo_Applet = 1, ///< Memory allocated for applet usage.
PhysicalMemoryInfo_System = 2, ///< Memory allocated for system usage.
PhysicalMemoryInfo_SystemUnsafe = 3, ///< Memory allocated for unsafe system usage (accessible to devices).
} PhysicalMemoryInfo;
///@name Memory management
///@{
......@@ -1103,7 +1163,7 @@ Result svcUnmapProcessCodeMemory(Handle proc, u64 dst, u64 src, u64 size);
* @note Syscall number 0x79.
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcCreateProcess(Handle* out, void* proc_info, u32* caps, u64 cap_num);
Result svcCreateProcess(Handle* out, const void* proc_info, const u32* caps, u64 cap_num);
/**
* @brief Starts executing a freshly created process.
......
......@@ -33,7 +33,7 @@ typedef struct
Result accountInitialize(void);
void accountExit(void);
Service* accountGetService(void);
Service* accountGetServiceSession(void);
/// Get the total number of user profiles
Result accountGetUserCount(s32* user_count);
......
......@@ -6,6 +6,7 @@
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
/// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates.
typedef enum {
......@@ -16,6 +17,7 @@ typedef enum {
Result apmInitialize(void);
void apmExit(void);
Service* apmGetServiceSession(void);
Result apmSetPerformanceConfiguration(u32 PerformanceMode, u32 PerformanceConfiguration);
Result apmGetPerformanceConfiguration(u32 PerformanceMode, u32 *PerformanceConfiguration);
This diff is collapsed.
......@@ -7,9 +7,11 @@
#pragma once
#include "../audio/audio.h"
#include "../services/sm.h"
Result auddevInitialize(void);
void auddevExit(void);
Service* auddevGetServiceSession(void);
Result auddevListAudioDeviceName(AudioDeviceName *DeviceNames, s32 max_names, s32 *total_names);
Result auddevSetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float volume);
......
......@@ -7,6 +7,7 @@
#pragma once
#include "../audio/audio.h"
#include "../services/sm.h"
#if __cplusplus >= 201402L
#define AUDREN_CONSTEXPR constexpr
......@@ -321,6 +322,7 @@ AUDREN_CONSTEXPR size_t audrenGetOutputParamSize(const AudioRendererConfig* conf
Result audrenInitialize(const AudioRendererConfig* config);
void audrenExit(void);
Service* audrenGetServiceSession(void);
void audrenWaitFrame(void);
Result audrenGetState(u32* out_state);
Result audrenRequestUpdateAudioRenderer(const void* in_param_buf, size_t in_param_buf_size, void* out_param_buf, size_t out_param_buf_size, void* perf_buf, size_t perf_buf_size);
......
......@@ -6,6 +6,7 @@
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
typedef enum {
BpcSleepButtonState_Held = 0,
......@@ -14,6 +15,7 @@ typedef enum {
Result bpcInitialize(void);
void bpcExit(void);
Service* bpcGetServiceSession(void);
Result bpcShutdownSystem(void);
Result bpcRebootSystem(void);
......
......@@ -12,6 +12,7 @@
#include "../types.h"
#include "../kernel/tmem.h"
#include "../services/sm.h"
/// Configuration structure for bsdInitalize
typedef struct {
......@@ -37,6 +38,7 @@ const BsdInitConfig *bsdGetDefaultInitConfig(void);
Result bsdInitialize(const BsdInitConfig *config);
/// Deinitialize the BSD service.
void bsdExit(void);
Service* bsdGetServiceSession(void);
/// Creates a socket.
int bsdSocket(int domain, int type, int protocol);
......
......@@ -12,6 +12,7 @@
/// Initialize caps:sc. Only available on 2.0.0+.
Result capsscInitialize(void);
void capsscExit(void);
Service* capsscGetServiceSession(void);
/**
* @brief This takes a screenshot, with the screenshot being written into the output buffer.
......
......@@ -12,6 +12,7 @@
/// Initialize caps:su. Only available on 4.0.0+.
Result capssuInitialize(void);
void capssuExit(void);
Service* capssuGetServiceSession(void);
/// Same as \ref capssuSaveScreenShotEx0, except this uses an all-zero CapsScreenShotAttribute where the first u32 is set to attr_val. attr_val can be zero.
Result capssuSaveScreenShot(const void* buffer, size_t size, u32 unk, u32 attr_val, CapsApplicationAlbumEntry *out);
......
......@@ -15,6 +15,7 @@ typedef struct {
Result clkrstInitialize(void);
void clkrstExit(void);
Service* clkrstGetServiceSession(void);
/// Opens a ClkrstSession for the requested PcvModuleId, unk is set to 3 in official sysmodules.
Result clkrstOpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32 unk);
......
......@@ -6,8 +6,10 @@
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
Result csrngInitialize(void);
void csrngExit(void);
Service* csrngGetServiceSession(void);
Result csrngGetRandomBytes(void *out, size_t out_size);
......@@ -68,7 +68,7 @@ typedef struct
u64 titleID; ///< titleID of the savedata to access when accessing other titles' savedata via SaveData, otherwise FS_SAVEDATA_CURRENT_TITLEID.
union { u128 userID; } PACKED; ///< userID of the user-specific savedata to access, otherwise FS_SAVEDATA_USERID_COMMONSAVE. See account.h.
u64 saveID; ///< saveID, 0 for SaveData.
u8 SaveDataType; ///< See \ref FsSaveDataType.
u8 saveDataType; ///< See \ref FsSaveDataType.
u8 rank; ///< Save data 'rank' or 'precedence'. 0 if this save data is considered the primary save data. 1 if it's considered the secondary save data.
u16 index; ///< Save data index.
u32 pad_x24; ///< Padding.
......@@ -77,11 +77,23 @@ typedef struct
u64 unk_x38; ///< 0 for SystemSaveData/SaveData.
} FsSave;
/// SaveCreate Struct
typedef struct {
u64 size; ///< Size of the save data.
u64 journalSize; ///< Journal size of the save data.
u64 blockSize; ///< Block size of the save data.
u64 ownerId; ///< Title id of the owner of this save data. 0 for SystemSaveData.
u32 flags; ///< Save data flags.
u8 saveDataSpaceId; ///< See \ref FsSaveDataSpaceId.
u8 unk; ///< 0 for SystemSaveData.
u8 padding[0x1A]; ///< Uninitialized for SystemSaveData.
} FsSaveCreate;
typedef struct
{
u64 saveID_unk;
u8 SaveDataSpaceId; ///< See \ref FsSaveDataSpaceId.
u8 SaveDataType; ///< See \ref FsSaveDataType.
u8 saveDataSpaceId; ///< See \ref FsSaveDataSpaceId.
u8 saveDataType; ///< See \ref FsSaveDataType.
u8 pad[6]; ///< Padding.
u128 userID; ///< See userID for \ref FsSave.
u64 saveID; ///< See saveID for \ref FsSave.
......@@ -223,8 +235,11 @@ void fsExit(void);
Service* fsGetServiceSession(void);
Result fsOpenBisStorage(FsStorage* out, FsBisStorageId PartitionId);
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId PartitionId, const char* string);
Result fsOpenBisStorage(FsStorage* out, FsBisStorageId partitionId);
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId partitionId, const char* string);
Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSave* save, const FsSaveCreate* create);
Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID);
Result fsIsExFatSupported(bool* out);
......@@ -233,7 +248,7 @@ Result fsMountSdcard(FsFileSystem* out);
Result fsMountSaveData(FsFileSystem* out, u8 inval, FsSave *save);
Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, FsSave *save);
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 SaveDataSpaceId);
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 saveDataSpaceId);
Result fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id);
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, FsStorageId storageId);
......@@ -245,8 +260,14 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id);
/// Retrieves the rights id and key generation corresponding to the content path. Only available on [3.0.0+].
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id);
Result fsDisableAutoSaveDataCreation(void);
// todo: Rest of commands here
// Wrapper(s) for fsCreateSaveDataFileSystemBySystemSaveDataId.
Result fsCreate_SystemSaveDataWithOwner(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, u128 userID, u64 ownerId, u64 size, u64 journalSize, u32 flags);
Result fsCreate_SystemSaveData(FsSaveDataSpaceId saveDataSpaceId, u64 saveID, u64 size, u64 journalSize, u32 flags);
/// FsFileSystem can be mounted with fs_dev for use with stdio, see fs_dev.h.
/// Wrapper(s) for fsMountSaveData.
......
......@@ -11,6 +11,7 @@
Result fsldrInitialize(void);
void fsldrExit(void);
Service* fsldrGetServiceSession(void);
Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out);
Result fsldrIsArchivedProgram(u64 pid, bool *out);
......
......@@ -11,6 +11,7 @@
Result fsprInitialize(void);
void fsprExit(void);
Service* fsprGetServiceSession(void);
Result fsprRegisterProgram(u64 pid, u64 titleID, FsStorageId storageID, const void *fs_access_header, size_t fah_size, const void *fs_access_control, size_t fac_size);
Result fsprUnregisterProgram(u64 pid);
......
......@@ -30,6 +30,7 @@ typedef enum {
Result gpioInitialize(void);
void gpioExit(void);
Service* gpioGetServiceSession(void);
Result gpioOpenSession(GpioPadSession *out, GpioPadName name);
......
......@@ -271,6 +271,9 @@ typedef enum
KEY_SL_RIGHT = BIT(26), ///< SL on Right Joy-Con
KEY_SR_RIGHT = BIT(27), ///< SR on Right Joy-Con
KEY_HOME = BIT(18), ///< HOME button, only available for use with HiddbgHdlsState::buttons.
KEY_CAPTURE = BIT(19), ///< Capture button, only available for use with HiddbgHdlsState::buttons.
// Pseudo-key for at least one finger on the touch screen
KEY_TOUCH = BIT(28),
......@@ -653,7 +656,7 @@ Result hidInitialize(void);
void hidExit(void);
void hidReset(void);
Service* hidGetSessionService(void);
Service* hidGetServiceSession(void);
void* hidGetSharedmemAddr(void);
void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutType);
......
......@@ -10,26 +10,40 @@
/// HdlsDeviceInfo
typedef struct {
u32 type; ///< See \ref HidControllerType, only one bit can be set.
u32 type; ///< Only one bit can be set. BIT(N*4+0) = Pro-Controller, BIT(N*4+1) = Joy-Con Left, BIT(N*4+2) = Joy-Con Right, BIT(N*4+3) = invalid. Where N is 0-1. BIT(8-10) = Pro-Controller, BIT(11) = Famicom-Controller, BIT(12) = Famicom-Controller II with microphone, BIT(13) = NES-Controller(DeviceType=0x200), BIT(14) = NES-Controller(DeviceType=0x400), BIT(15-16) = invalid, BIT(17) = unknown(DeviceType=0x8000), BIT(18-20) = invalid, BIT(21-23) = unknown(DeviceType=0x80000000).
u32 singleColorBody; ///< RGBA Single Body Color
u32 singleColorButtons; ///< RGBA Single Buttons Color
u8 unk_xc; ///< Unknown
u8 type2; ///< Additional type field used with the above type field (only applies to type bit0-bit2 and bit21), if the value doesn't match one of the following a default is used. Type Pro-Controller: value 0x3 indicates that the controller is connected via USB. Type BIT(21): value 0x3 = unknown. When value is 0x2, state is merged with an existing controller (when the type value is compatible with this). Otherwise, it's a dedicated controller.
u8 pad[0x3]; ///< Padding
} HiddbgHdlsDeviceInfo;
/// HdlsState
typedef struct {
u8 unk_x0[0x8]; ///< Unknown
u8 powerConnected; ///< powerConnected for the main PowerInfo, see \ref HidFlags.
u8 flags; ///< ORRed with powerConnected to set the value of the first byte for \ref HidFlags. For example, value 1 here will set isCharging for the main PowerInfo.
u8 unk_x2[0x6]; ///< Unknown
u32 batteryCharge; ///< batteryCharge for the main PowerInfo, see \ref HidPowerInfo.
u32 buttons; ///< See \ref HidControllerKeys.
JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; ///< \ref JoystickPosition
u8 unk_x20; ///< Unused for input. Set with output from \ref hiddbgDumpHdlsStates.
u8 unk_x20; ///< Unused for input. Set with output from \ref hiddbgDumpHdlsStates. Not set by \ref hiddbgGetAbstractedPadsState.
u8 padding[0x3]; ///< Padding
} HiddbgHdlsState;
/// HdlsNpadAssignment
/// HdlsNpadAssignmentEntry
typedef struct {
u8 unk_x0[0x208]; ///< Unknown
u64 HdlsHandle; ///< HdlsHandle
u32 unk_x8; ///< Unknown
u32 unk_xc; ///< Unknown
u64 unk_x10; ///< Unknown
u8 unk_x18; ///< Unknown
u8 pad[0x7]; ///< Padding
} HiddbgHdlsNpadAssignmentEntry;
/// HdlsNpadAssignment. Same controllers as \ref HiddbgHdlsStateList, with different entry data.
typedef struct {
s32 total_entries; ///< Total entries for the below entries.
u32 pad; ///< Padding
HiddbgHdlsNpadAssignmentEntry entries[0x10]; ///< \ref HiddbgHdlsNpadAssignmentEntry
} HiddbgHdlsNpadAssignment;
/// HdlsStateListEntry
......@@ -46,8 +60,54 @@ typedef struct {
HiddbgHdlsStateListEntry entries[0x10]; ///< \ref HiddbgHdlsStateListEntry
} HiddbgHdlsStateList;
/// AbstractedPadState
typedef struct {
u32 type; ///< Type. Converted to HiddbgHdlsDeviceInfo::type internally by \ref hiddbgSetAutoPilotVirtualPadState. BIT(0) -> BIT(0), BIT(1) -> BIT(15), BIT(2-3) -> BIT(1-2), BIT(4-5) -> BIT(1-2), BIT(6) -> BIT(3). BIT(7-11) -> BIT(11-15), BIT(12-14) -> BIT(12-14), BIT(15) -> BIT(17), BIT(31) -> BIT(21).
u8 flags; ///< Flags. Only bit0 is used by \ref hiddbgSetAutoPilotVirtualPadState: when clear it will skip using the rest of the input and run \ref hiddbgUnsetAutoPilotVirtualPadState internally.
u8 pad[0x3]; ///< Padding
u32 singleColorBody; ///< RGBA Single Body Color
u32 singleColorButtons; ///< RGBA Single Buttons Color
u8 type2; ///< See HiddbgHdlsDeviceInfo::type2.
u8 pad2[0x3]; ///< Padding
HiddbgHdlsState state; ///< State
u8 unused[0x60]; ///< Unused with \ref hiddbgSetAutoPilotVirtualPadState. Not set by \ref hiddbgGetAbstractedPadsState.
} HiddbgAbstractedPadState;
Result hiddbgInitialize(void);
void hiddbgExit(void);
Service* hiddbgGetServiceSession(void);
/// Writes the input RGB colors to the spi-flash for the specified controller (offset 0x6050 size 0x6). See hidsys.h for UniquePadId. Only available with [3.0.0+].
Result hiddbgUpdateControllerColor(u32 colorBody, u32 colorButtons, u64 UniquePadId);
/// Writes the input RGB colors followed by inval to the spi-flash for the specified controller (offset 0x6050 size 0xD). See hidsys.h for UniquePadId. Only available with [5.0.0+].
Result hiddbgUpdateDesignInfo(u32 colorBody, u32 colorButtons, u32 colorLeftGrip, u32 colorRightGrip, u8 inval, u64 UniquePadId);
/// Reads spi-flash for the specified controller. See hidsys.h for UniquePadId.
/// This doesn't seem to be usable?
Result hiddbgReadSerialFlash(u32 offset, void* buffer, size_t size, u64 UniquePadId);
/// Gets a list of AbstractedPadHandles, where AbstractedPadHandles is the output array with max entries = count. total_entries is total entries written to the output array. Only available with [5.0.0+].
Result hiddbgGetAbstractedPadHandles(u64 *AbstractedPadHandles, s32 count, s32 *total_entries);
/// Gets the state for the specified AbstractedPadHandle. Only available with [5.0.0+].
Result hiddbgGetAbstractedPadState(u64 AbstractedPadHandle, HiddbgAbstractedPadState *state);
/// Similar to \ref hiddbgGetAbstractedPadHandles except this also returns the state for each pad in output array states. Only available with [5.0.0+].
Result hiddbgGetAbstractedPadsState(u64 *AbstractedPadHandles, HiddbgAbstractedPadState *states, s32 count, s32 *total_entries);
/// Sets AutoPilot state for the specified pad.
/// AbstractedVirtualPadId can be any unique value as long as it's within bounds. For example, 0-7 is usable.
Result hiddbgSetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const HiddbgAbstractedPadState *state);
/// Clears AutoPilot state for the specified pad set by \ref hiddbgSetAutoPilotVirtualPadState.
Result hiddbgUnsetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId);
/// Clears AutoPilot state for all pads set by \ref hiddbgSetAutoPilotVirtualPadState.
Result hiddbgUnsetAllAutoPilotVirtualPadState(void);
/// Initialize Hdls. Hdls is for virtual HID controllers. Only available with [7.0.0+].
Result hiddbgAttachHdlsWorkBuffer(void);
......
......@@ -34,6 +34,7 @@ typedef struct {
Result hidsysInitialize(void);
void hidsysExit(void);
Service* hidsysGetServiceSession(void);
Result hidsysEnableAppletToGetInput(bool enable);
......@@ -71,3 +72,9 @@ Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entr
*/
Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *pattern, u64 UniquePadId);
/**
* @brief Gets the unique pad's serial number.
* @param UniquePadId UniquePadId for the controller.
* @param serial Pointer to output the serial to. (The buffer size needs to be at least 0x19 bytes)
*/
Result hidsysGetUniquePadSerialNumber(u64 UniquePadId, char *serial);
......@@ -57,6 +57,7 @@ typedef enum {
Result i2cInitialize(void);
void i2cExit(void);
Service* i2cGetServiceSession(void);
Result i2cOpenSession(I2cSession *out, I2cDevice dev);
......
......@@ -55,7 +55,7 @@ Result irsInitialize(void);
/// Exit irs.
void irsExit(void);
Service* irsGetSessionService(void);
Service* irsGetServiceSession(void);
void* irsGetSharedmemAddr(void);
/// (De)activate the IR sensor, this is automatically used by \ref irsExit. Must be called after irsInitialize() to activate the IR sensor.
......
......@@ -6,9 +6,11 @@
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
Result lblInitialize(void);
void lblExit(void);
Service* lblGetServiceSession(void);
Result lblSwitchBacklightOn(u64 fade_time);
Result lblSwitchBacklightOff(u64 fade_time);
......
......@@ -31,12 +31,18 @@ typedef struct {
Result ldrShellInitialize(void);
void ldrShellExit(void);
Service* ldrShellGetServiceSession(void);
Result ldrDmntInitialize(void);
void ldrDmntExit(void);
Service* ldrDmntGetServiceSession(void);
Result ldrPmInitialize(void);
void ldrPmExit(void);
Service* ldrPmGetServiceSession(void);
Result ldrShellAddTitleToLaunchQueue(u64 tid, const void *args, size_t args_size);
Result ldrShellClearLaunchQueue(void);
......
......@@ -19,6 +19,7 @@ typedef struct {
Result lrInitialize(void);
void lrExit(void);
Service* lrGetServiceSession(void);
Result lrOpenLocationResolver(FsStorageId storage, LrLocationResolver* out);
Result lrOpenRegisteredLocationResolver(LrRegisteredLocationResolver* out);
......
......@@ -76,6 +76,7 @@ typedef struct {
Result ncmInitialize(void);
void ncmExit(void);
Service* ncmGetServiceSession(void);
Result ncmOpenContentStorage(FsStorageId storage, NcmContentStorage* out);
Result ncmOpenContentMetaDatabase(FsStorageId storage, NcmContentMetaDatabase* out);
......
......@@ -6,6 +6,7 @@
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
typedef enum {
PcvModule_CpuBus = 0,
......@@ -192,6 +193,7 @@ typedef enum {
Result pcvInitialize(void);
void pcvExit(void);
Service* pcvGetServiceSession(void);
Result pcvGetModuleId(PcvModuleId *module_id, PcvModule module);
......
This diff is collapsed.
......@@ -27,6 +27,7 @@ typedef struct {
Result plInitialize(void);
void plExit(void);
Service* plGetServiceSession(void);
void* plGetSharedmemAddr(void);
///< Gets a specific shared-font via SharedFontType, see \ref PlSharedFontType.
......
......@@ -46,6 +46,12 @@ typedef struct {
u64 process_id;
} PmProcessEventInfo;
typedef enum {
PmBootMode_Normal = 0,
PmBootMode_Maintenance = 1,
PmBootMode_SafeMode = 2,
} PmBootMode;
Result pmdmntInitialize(void);
void pmdmntExit(void);
......@@ -54,9 +60,18 @@ Service* pmdmntGetServiceSession(void);
Result pminfoInitialize(void);
void pminfoExit(void);
Service* pminfoGetServiceSession(void);
Result pmshellInitialize(void);
void pmshellExit(void);
Service* pmshellGetServiceSession(void);
Result pmbmInitialize();
void pmbmExit();
Service* pmbmGetServiceSession(void);
Result pmdmntGetDebugProcesses(u32* out_count, u64* out_pids, size_t max_pids);
Result pmdmntStartProcess(u64 pid);
Result pmdmntGetTitlePid(u64* pid_out, u64 title_id);
......@@ -77,3 +92,7 @@ Result pmshellClearProcessExceptionOccurred(u64 pid);
Result pmshellNotifyBootFinished(void);
Result pmshellGetApplicationPid(u64* pid_out);
Result pmshellBoostSystemMemoryResourceLimit(u64 boost_size);
Result pmshellBoostSystemThreadResourceLimit(void);
Result pmbmGetBootMode(PmBootMode *out);
Result pmbmSetMaintenanceBoot(void);
......@@ -26,6 +26,7 @@ typedef struct {
Result pscInitialize(void);
void pscExit(void);
Service* pscGetServiceSession(void);
Result pscGetPmModule(PscPmModule *out, u16 module_id, const u16 *dependencies, size_t dependency_count, bool autoclear);
......
......@@ -30,6 +30,7 @@ typedef struct {
Result psmInitialize(void);
void psmExit(void);
Service* psmGetServiceSession(void);
Result psmGetBatteryChargePercentage(u32 *out);
Result psmGetChargerType(ChargerType *out);
......
......@@ -11,12 +11,15 @@
Result ldrRoInitialize(void);
void ldrRoExit(void);
Service* ldrRoGetServiceSession(void);
Result ro1Initialize(void);
void ro1Exit(void);
Service* ro1GetServiceSession(void);
Result roDmntInitialize(void);
void roDmntExit(void);
Service* roDmntGetServiceSession(void);
Result ldrRoLoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size);
Result ldrRoUnloadNro(u64 nro_address);
......
......@@ -9,6 +9,7 @@
#pragma once
#include "../result.h"
#include "../kernel/event.h"
#include "../services/sm.h"
#define SET_MAX_NAME_SIZE 0x48
#define SET_MAX_NICKNAME_SIZE 0x80
......@@ -86,6 +87,7 @@ typedef struct {
Result setInitialize(void);
void setExit(void);
Service* setGetServiceSession(void);
/// Converts LanguageCode to Language.
Result setMakeLanguage(u64 LanguageCode, s32 *Language);
......@@ -114,6 +116,7 @@ Result setGetRegionCode(SetRegion *out);
Result setsysInitialize(void);
void setsysExit(void);
Service* setsysGetServiceSession(void);
/// Gets the current system theme.
Result setsysGetColorSetId(ColorSetId *out);
......
......@@ -280,11 +280,17 @@ Result smUnregisterService(const char* name);
*/
bool smHasInitialized(void);
/**
* @brief Gets the Service session used to communicate with SM.
* @return Pointer to service session used to communicate with SM.
*/
Service *smGetServiceSession(void);
/**
* @brief Encodes a service name as a 64-bit integer.
* @param[in] name Name of the service.
* @return Encoded name.
*/
*/
u64 smEncodeName(const char* name);
/**
......
......@@ -12,5 +12,7 @@
Result smManagerInitialize(void);
void smManagerExit(void);
Service* smManagerGetServiceSession(void);
Result smManagerRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size);
Result smManagerUnregisterProcess(u64 pid);
......@@ -36,21 +36,27 @@ typedef enum {
Result splInitialize(void);
void splExit(void);
Service* splGetServiceSession(void);
Result splCryptoInitialize(void);
void splCryptoExit(void);
Service* splCryptoGetServiceSession(void);
Result splSslInitialize(void);
void splSslExit(void);
Service* splSslGetServiceSession(void);
Result splEsInitialize(void);
void splEsExit(void);
Service* splEsGetServiceSession(void);
Result splFsInitialize(void);
void splFsExit(void);
Service* splFsGetServiceSession(void);
Result splManuInitialize(void);
void splManuExit(void);
Service* splManuGetServiceSession(void);
Result splGetConfig(SplConfigItem config_item, u64 *out_config);
Result splUserExpMod(const void *input, const void *modulus, const void *exp, size_t exp_size, void *dst);
......
......@@ -6,9 +6,11 @@
*/
#pragma once
#include "../types.h"
#include "../services/sm.h"
Result spsmInitialize(void);
void spsmExit(void);
Service* spsmGetServiceSession(void);
Result spsmShutdown(bool reboot);
Result spsmPutErrorState(void);
......@@ -35,10 +35,18 @@ typedef struct {
s32 offset; ///< Seconds relative to UTC for this timezone.
} TimeCalendarAdditionalInfo;
typedef struct {
u8 data[0x4000];
} TimeZoneRule;
typedef struct {
char name[0x24];
} TimeLocationName;
Result timeInitialize(void);
void timeExit(void);
Service* timeGetSessionService(void);
Service* timeGetServiceSession(void);
Result timeGetCurrentTime(TimeType type, u64 *timestamp);
......@@ -50,5 +58,15 @@ Result timeGetCurrentTime(TimeType type, u64 *timestamp);
*/
Result timeSetCurrentTime(TimeType type, u64 timestamp);
Result timeGetDeviceLocationName(TimeLocationName *name);
Result timeSetDeviceLocationName(const TimeLocationName *name);
Result timeGetTotalLocationNameCount(u32 *total_location_name_count);
Result timeLoadLocationNameList(u32 index, TimeLocationName *location_name_array, size_t location_name_size, u32 *location_name_count);
Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule);
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_size, u32 *timestamp_count);
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_size, u32 *timestamp_count);
Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
......@@ -64,6 +64,7 @@ typedef enum {
Result usbDsInitialize(void);
/// Closes the usb:ds session. Any interfaces/endpoints which are left open are automatically closed, since otherwise usb-sysmodule won't fully reset usb:ds to defaults.
void usbDsExit(void);
Service* usbDsGetServiceSession(void);
/// Helpers
Result usbDsWaitReady(u64 timeout);
......
......@@ -104,6 +104,7 @@ typedef struct {
/// Initialize/exit usb:hs.
Result usbHsInitialize(void);
void usbHsExit(void);
Service* usbHsGetServiceSession(void);
/// Returns the Event loaded during init with autoclear=false.
/// Signaled when a device was removed.
......
......@@ -18,6 +18,7 @@ typedef enum {
Result wlaninfInitialize(void);
void wlaninfExit(void);
Service* wlaninfGetServiceSession(void);
Result wlaninfGetState(WlanInfState* out);
......
......@@ -28,15 +28,15 @@ static void _CacheVersion(void)
u64 tmp;
g_Version = 1;
if (R_VALUE(svcGetInfo(&tmp, 12, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
if (R_VALUE(svcGetInfo(&tmp, InfoType_AslrRegionAddress, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
g_Version = 2;
if (R_VALUE(svcGetInfo(&tmp, 18, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
if (R_VALUE(svcGetInfo(&tmp, InfoType_TitleId, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
g_Version = 3;
if (R_VALUE(svcGetInfo(&tmp, 19, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
if (R_VALUE(svcGetInfo(&tmp, InfoType_InitialProcessIdRange, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
g_Version = 4;
if (R_VALUE(svcGetInfo(&tmp, 20, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
if (R_VALUE(svcGetInfo(&tmp, InfoType_UserExceptionContextAddress, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
g_Version = 5;
if (R_VALUE(svcGetInfo(&tmp, 21, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
if (R_VALUE(svcGetInfo(&tmp, InfoType_TotalNonSystemMemorySize, INVALID_HANDLE, 0)) != KERNELRESULT(InvalidEnumValue))
g_Version = 6;
__atomic_store_n(&g_VersionCached, true, __ATOMIC_SEQ_CST);
......@@ -88,7 +88,7 @@ int detectKernelVersion(void) {
bool detectDebugger(void) {
u64 tmp;
svcGetInfo(&tmp, 8, 0, 0);
svcGetInfo(&tmp, InfoType_DebuggerAttached, INVALID_HANDLE, 0);
return !!tmp;
}
......
......@@ -136,7 +136,7 @@ static void _randomInit(void)
for (i=0; i<4; i++)
{
// Get process TRNG seeds from kernel.
if (R_FAILED(svcGetInfo(&seed[i], 11, 0, i)))
if (R_FAILED(svcGetInfo(&seed[i], InfoType_RandomEntropy, INVALID_HANDLE, i)))
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_BadGetInfo_Rng));
}
......
......@@ -45,7 +45,7 @@ static inline bool _InRegion(VirtualRegion* r, u64 addr) {
}
void virtmemSetup(void) {
if (R_FAILED(_GetRegionFromInfo(&g_AddressSpace, 12, 13))) {
if (R_FAILED(_GetRegionFromInfo(&g_AddressSpace, InfoType_AslrRegionAddress, InfoType_AslrRegionSize))) {
// 1.0.0 doesn't expose address space size so we have to do this dirty hack to detect it.
// Forgive me.
......@@ -74,16 +74,16 @@ void virtmemSetup(void) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_WeirdKernel));
}
} else {
if (R_FAILED(_GetRegionFromInfo(&g_Region[REGION_STACK], 14, 15))) {
if (R_FAILED(_GetRegionFromInfo(&g_Region[REGION_STACK], InfoType_StackRegionAddress, InfoType_StackRegionSize))) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_BadGetInfo_Stack));
}
}
if (R_FAILED(_GetRegionFromInfo(&g_Region[REGION_HEAP], 4, 5))) {
if (R_FAILED(_GetRegionFromInfo(&g_Region[REGION_HEAP], InfoType_HeapRegionAddress, InfoType_HeapRegionSize))) {
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_BadGetInfo_Heap));
}
}
_GetRegionFromInfo(&g_Region[REGION_LEGACY_ALIAS], 2, 3);
_GetRegionFromInfo(&g_Region[REGION_LEGACY_ALIAS], InfoType_AliasRegionAddress, InfoType_AliasRegionSize);
}
void* virtmemReserve(size_t size) {
......
......@@ -72,8 +72,8 @@ void __attribute__((weak)) __libnx_initheap(void)
}
else {
if (__nx_heap_size==0) {
svcGetInfo(&mem_available, 6, CUR_PROCESS_HANDLE, 0);
svcGetInfo(&mem_used, 7, CUR_PROCESS_HANDLE, 0);
svcGetInfo(&mem_available, InfoType_TotalMemorySize, CUR_PROCESS_HANDLE, 0);
svcGetInfo(&mem_used, InfoType_UsedMemorySize, CUR_PROCESS_HANDLE, 0);
if (mem_available > mem_used+0x200000)
size = (mem_available - mem_used - 0x200000) & ~0x1FFFFF;
if (size==0)
......
......@@ -179,7 +179,7 @@ int __syscall_thread_create(struct __pthread_t **thread, void* (*func)(void*), v
*thread = NULL;
u64 core_mask = 0;
rc = svcGetInfo(&core_mask, 0, CUR_PROCESS_HANDLE, 0);
rc = svcGetInfo(&core_mask, InfoType_CoreMask, CUR_PROCESS_HANDLE, 0);
if (R_FAILED(rc))
return EPERM;
......
......@@ -5,10 +5,13 @@
#include "services/acc.h"
#include "services/sm.h"
#include "services/applet.h"
#include "runtime/hosversion.h"
static Service g_accSrv;
static u64 g_refCnt;
static Result _accountInitializeApplicationInfo(void);
Result accountInitialize(void)
{
Result rc=0;
......@@ -19,7 +22,12 @@ Result accountInitialize(void)
return 0;
rc = smGetService(&g_accSrv, "acc:u1");
if (R_FAILED(rc)) rc = smGetService(&g_accSrv, "acc:u0");
if (R_FAILED(rc)) {
rc = smGetService(&g_accSrv, "acc:u0");
if (R_SUCCEEDED(rc)) rc = _accountInitializeApplicationInfo();
}
if (R_FAILED(rc)) accountExit();
return rc;
}
......@@ -30,10 +38,46 @@ void accountExit(void)
serviceClose(&g_accSrv);
}
Service* accountGetService(void) {
Service* accountGetServiceSession(void) {
return &g_accSrv;
}
static Result _accountInitializeApplicationInfo(void) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u64 pid_placeholder;
} *raw;
ipcSendPid(&c);
raw = serviceIpcPrepareHeader(&g_accSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = hosversionBefore(6,0,0) ? 100 : 140;
raw->pid_placeholder = 0;
Result rc = serviceIpcDispatch(&g_accSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(&g_accSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result accountGetUserCount(s32* user_count)
{
IpcCommand c;
......
......@@ -41,6 +41,10 @@ void apmExit(void)
}
}
Service* apmGetServiceSession(void) {
return &g_apmSrv;
}
static Result _apmGetSession(Service* srv, Service* srv_out, u64 cmd_id) {
IpcCommand c;
ipcInitialize(&c);
......
This diff is collapsed.
......@@ -47,6 +47,10 @@ void auddevExit(void) {
}
}
Service* auddevGetServiceSession(void) {
return &g_auddevIAudioDevice;
}
static Result _auddevGetAudioDeviceService(Service* srv, Service* out_srv, u64 aruid) {
IpcCommand c;
ipcInitialize(&c);
......
......@@ -129,6 +129,10 @@ void audrenExit(void)
tmemClose(&g_audrenWorkBuf);
}
Service* audrenGetServiceSession(void) {
return &g_audrenIAudioRenderer;
}
void audrenWaitFrame(void)
{
eventWait(&g_audrenEvent, U64_MAX);
......
......@@ -29,6 +29,10 @@ void bpcExit(void)
serviceClose(&g_bpcSrv);
}
Service* bpcGetServiceSession(void) {
return &g_bpcSrv;
}
Result bpcShutdownSystem(void)
{
IpcCommand c;
......
......@@ -277,6 +277,10 @@ void bsdExit(void) {
tmemClose(&g_bsdTmem);
}
Service* bsdGetServiceSession(void) {
return &g_bsdSrv;
}
int bsdSocket(int domain, int type, int protocol) {
return _bsdSocketCreationCommand(2, domain, type, protocol);
}
......
......@@ -33,6 +33,10 @@ void capsscExit(void) {
serviceClose(&g_capsscSrv);
}
Service* capsscGetServiceSession(void) {
return &g_capsscSrv;
}
Result capsscCaptureScreenshot(void* buf, size_t size, u32 inval, u64 width, u64 height, s64 buffer_count, s64 buffer_index, u64 timeout) {
IpcCommand c;
ipcInitialize(&c);
......
......@@ -35,6 +35,10 @@ void capssuExit(void) {
serviceClose(&g_capssuSrv);
}
Service* capssuGetServiceSession(void) {
return &g_capssuSrv;
}
static Result _capssuSaveScreenShotEx0(const void* buffer, size_t size, CapsScreenShotAttribute *attr, u32 unk, CapsApplicationAlbumEntry *out) {
u64 AppletResourceUserId = 0;
appletGetAppletResourceUserId(&AppletResourceUserId);
......
......@@ -37,6 +37,10 @@ void clkrstExit(void) {
}
}
Service* clkrstGetServiceSession(void) {
return &g_clkrstSrv;
}
Result clkrstOpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32 unk) {
IpcCommand c;
ipcInitialize(&c);
......
......@@ -25,6 +25,10 @@ void csrngExit(void) {
serviceClose(&g_csrngSrv);
}
Service* csrngGetServiceSession(void) {
return &g_csrngSrv;
}
Result csrngGetRandomBytes(void *out, size_t out_size) {
IpcCommand c;
ipcInitialize(&c);
......
......@@ -70,7 +70,7 @@ Service* fsGetServiceSession(void) {
return &g_fsSrv;
}
Result fsOpenBisStorage(FsStorage* out, FsBisStorageId PartitionId) {
Result fsOpenBisStorage(FsStorage* out, FsBisStorageId partitionId) {
IpcCommand c;
ipcInitialize(&c);
......@@ -84,7 +84,7 @@ Result fsOpenBisStorage(FsStorage* out, FsBisStorageId PartitionId) {
raw->magic = SFCI_MAGIC;
raw->cmd_id = 12;
raw->PartitionId = PartitionId;
raw->PartitionId = partitionId;
Result rc = serviceIpcDispatch(&g_fsSrv);
......@@ -108,7 +108,7 @@ Result fsOpenBisStorage(FsStorage* out, FsBisStorageId PartitionId) {
return rc;
}
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId PartitionId, const char* string) {
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId partitionId, const char* string) {
IpcCommand c;
ipcInitialize(&c);
......@@ -126,7 +126,7 @@ Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId PartitionId, const
raw->magic = SFCI_MAGIC;
raw->cmd_id = 11;
raw->PartitionId = PartitionId;
raw->PartitionId = partitionId;
Result rc = serviceIpcDispatch(&g_fsSrv);
......@@ -150,6 +150,78 @@ Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId PartitionId, const
return rc;
}
Result fsCreateSaveDataFileSystemBySystemSaveDataId(const FsSave* save, const FsSaveCreate* create) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
FsSave save;
FsSaveCreate create;
} PACKED *raw;
raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 23;
memcpy(&raw->save, save, sizeof(FsSave));
memcpy(&raw->create, create, sizeof(FsSaveCreate));
Result rc = serviceIpcDispatch(&g_fsSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(&g_fsSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId saveDataSpaceId, u64 saveID) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
u8 saveDataSpaceId;
u64 saveID;
} *raw;
raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 25;
raw->saveDataSpaceId = saveDataSpaceId;
raw->saveID = saveID;
Result rc = serviceIpcDispatch(&g_fsSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(&g_fsSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result fsMountSdcard(FsFileSystem* out) {
IpcCommand c;
ipcInitialize(&c);
......@@ -266,7 +338,7 @@ Result fsMountSystemSaveData(FsFileSystem* out, u8 inval, FsSave *save) {
return rc;
}
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 SaveDataSpaceId) {
Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 saveDataSpaceId) {
IpcCommand c;
ipcInitialize(&c);
......@@ -278,10 +350,10 @@ Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 SaveDataSpaceId) {
struct {
u64 magic;
u64 cmd_id;
u8 SaveDataSpaceId;
u8 saveDataSpaceId;
} *raw2;
if (SaveDataSpaceId == FsSaveDataSpaceId_All) {
if (saveDataSpaceId == FsSaveDataSpaceId_All) {
raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
......@@ -292,7 +364,7 @@ Result fsOpenSaveDataIterator(FsSaveDataIterator* out, s32 SaveDataSpaceId) {
raw2->magic = SFCI_MAGIC;
raw2->cmd_id = 61;
raw2->SaveDataSpaceId = SaveDataSpaceId;
raw2->saveDataSpaceId = saveDataSpaceId;
}
Result rc = serviceIpcDispatch(&g_fsSrv);
......@@ -590,6 +662,37 @@ Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generat
return rc;
}
Result fsDisableAutoSaveDataCreation(void) {
IpcCommand c;
ipcInitialize(&c);
struct {
u64 magic;
u64 cmd_id;
} *raw;
raw = serviceIpcPrepareHeader(&g_fsSrv, &c, sizeof(*raw));
raw->magic = SFCI_MAGIC;
raw->cmd_id = 1003;
Result rc = serviceIpcDispatch(&g_fsSrv);
if (R_SUCCEEDED(rc)) {
IpcParsedCommand r;
struct {
u64 magic;
u64 result;
} *resp;
serviceIpcParse(&g_fsSrv, &r, sizeof(*resp));
resp = r.Raw;
rc = resp->result;
}
return rc;
}
Result fsIsExFatSupported(bool* out)
{