...
 
Commits (42)
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
# Changelog
## Version 2.2.0
#### system
* **Introduced hardware accelerated cryptography API**, including support for:
* Hardware accelerated AES-128/AES-192/AES-256 with single-block ECB and multi-block CBC/CTR/XTS modes
* Hardware accelerated SHA-1/SHA-256
* Hardware accelerated AES-128-CMAC/AES-192-CMAC/AES-256-CMAC
* Hardware accelerated HMAC-SHA1/HMAC-SHA256
* Added a custom MOD0 extension to make it easier to locate the got section.
* Added syscall: svcQueryProcessMemory.
* Improved smInitialize robustness during early system initialization in order to avoid race conditions when SM itself hasn't fully started up.
* **Fixed TLS slot issue on 8.0.0 - please recompile all your homebrew applications with this libnx release in order to fix crashes on 8.0.0.**
#### applet
* **Added support for VR mode, available on 6.0.0+**:
* Added appletIsVrModeEnabled (3.0.0+) and appletSetVrModeEnabled.
* **Added support for CPU boost, available on 7.0.0+**:
* Added appletSetCpuBoostMode and appletGetCurrentPerformanceConfiguration.
* **Added support for the light sensor, available on 3.0.0+**:
* appletGetCurrentIlluminance, appletGetCurrentIlluminanceEx (5.0.0+) and appletIsIlluminanceAvailable.
* Added support for the pctlauth library applet.
* Added libappletStart and libappletLaunch.
* Updated swkbd support with new functionality present in 6.0.0+, and added accessor functions for the SwkbdConfig struct:
* Added swkbdConfigSetType, swkbdConfigSetDicFlag, swkbdConfigSetKeySetDisableBitmask, swkbdConfigSetInitialCursorPos, swkbdConfigSetStringLenMax, swkbdConfigSetStringLenMaxExt, swkbdConfigSetPasswordFlag, swkbdConfigSetTextDrawType, swkbdConfigSetReturnButtonFlag, swkbdConfigSetBlurBackground and swkbdConfigSetTextGrouping.
* Added swkbdInlineAppearEx, swkbdInlineSetCustomizedDictionaries and swkbdInlineUnsetCustomizedDictionaries.
* Users are advised to use the new accessor functions and stop manipulating directly the contents of the SwkbdConfig struct.
* Updated web support with new functionality present in 6.0.0+:
* Added webConfigSetMediaAutoPlay, webConfigSetMediaPlayerSpeedControl, webConfigAddAlbumEntryAndMediaData, webConfigSetBootFooterButtonVisible, webConfigSetOverrideWebAudioVolume and webConfigSetOverrideMediaAudioVolume.
#### filesystem
* Added romfsMountFromFsdev.
* Added fsdevTranslatePath.
* Updated FsSave/FsSaveDataInfo structures.
* Fixed leakage of `0x402` error codes (now they get converted to `EEXIST`).
#### hid
* **Added support for the HOME-button notification LED, available on 7.0.0+**:
* Added NotificationLed struct for describing LED patterns.
* Added hidsysSetNotificationLedPattern.
* Added hidsysGetUniquePadsFromNpad and hidsysGetUniquePadIds.
#### other services
* Added clkrst service wrappers.
* Added pctl service wrappers.
* Added ro:1 service wrappers.
* Added ldr:ro command: ldrRoLoadNrrEx.
* Improved pcv support for 8.0.0 changes:
* Added PcvModuleId enum.
* Added pcvGetModuleId for converting PcvModule to PcvModuleId.
* Added checks to avoid calling pcv commands removed in 8.0.0 (use clkrst instead).
* Fixed LoaderModuleInfo struct.
* Fixed signature of roDmntGetModuleInfos and ldrDmntGetModuleInfos.
* Fixed signature of splCryptoCryptAesCtr.
* Removed `apm:p` service support in order to support 8.0.0.
#### miscellaneous
* Further improvements to overall system stability and other minor adjustments to enhance the user experience.
## Version 2.1.0
#### system
......
......@@ -9,7 +9,7 @@ endif
include $(DEVKITPRO)/devkitA64/base_rules
export LIBNX_MAJOR := 2
export LIBNX_MINOR := 1
export LIBNX_MINOR := 2
export LIBNX_PATCH := 0
......@@ -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
......
......@@ -68,6 +68,7 @@ extern "C" {
#include "switch/services/usbds.h"
#include "switch/services/usbhs.h"
#include "switch/services/hid.h"
#include "switch/services/hiddbg.h"
#include "switch/services/hidsys.h"
#include "switch/services/irs.h"
#include "switch/services/pl.h"
......
......@@ -50,6 +50,8 @@ typedef enum {
SwkbdRequestCommand_Calc = 0xA,
SwkbdRequestCommand_SetCustomizedDictionaries = 0xB,
SwkbdRequestCommand_UnsetCustomizedDictionaries = 0xC,
SwkbdRequestCommand_SetChangedStringV2Flag = 0xD,
SwkbdRequestCommand_SetMovedCursorV2Flag = 0xE,
} SwkbdRequestCommand;
/// SwkbdInline Interactive output storage reply ID.
......@@ -66,6 +68,10 @@ typedef enum {
SwkbdReplyType_UnsetCustomizeDic = 0xA,
SwkbdReplyType_ReleasedUserWordInfo = 0xB,
SwkbdReplyType_UnsetCustomizedDictionaries = 0xC,
SwkbdReplyType_ChangedStringV2 = 0xD,
SwkbdReplyType_MovedCursorV2 = 0xE,
SwkbdReplyType_ChangedStringUtf8V2 = 0xF,
SwkbdReplyType_MovedCursorUtf8V2 = 0x10,
} SwkbdReplyType;
/// SwkbdInline State
......@@ -151,7 +157,10 @@ typedef struct {
u32 textGrouping[8]; ///< Same as SwkbdArgV7::textGrouping.
u64 entries[0x18]; ///< This is SwkbdCustomizedDictionarySet::entries.
u8 total_entries; ///< This is SwkbdCustomizedDictionarySet::total_entries.
u8 pad_x4b5[0x13];
u8 unkFlag; ///< [8.0.0+]
u8 pad_x4b6[0xD];
u8 trigger; ///< [8.0.0+]
u8 pad_x4c4[4];
} SwkbdArgVB;
typedef struct {
......@@ -163,12 +172,16 @@ typedef struct {
SwkbdCustomizedDictionarySet customizedDictionarySet;
u8 unkFlag;
u8 trigger;
u32 version;
} SwkbdConfig;
/// InitializeArg for SwkbdInline.
typedef struct {
u32 unk_x0;
u8 mode; ///< See \ref SwkbdInlineMode.
u8 mode; ///< See \ref SwkbdInlineMode. (u8 bool)
u8 unk_x5; ///< Only set on 5.0.0+.
u8 pad[2];
} SwkbdInitializeArg;
......@@ -259,10 +272,18 @@ typedef struct {
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdChangedStringCb)(const char* str, SwkbdChangedStringArg* arg);
/// This callback is used by \ref swkbdInlineUpdate when handling ChangedString*V2 replies (text changed by the user or by \ref swkbdInlineSetInputText).
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdChangedStringV2Cb)(const char* str, SwkbdChangedStringArg* arg, bool flag);
/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor* replies.
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdMovedCursorCb)(const char* str, SwkbdMovedCursorArg* arg);
/// This callback is used by \ref swkbdInlineUpdate when handling MovedCursor*V2 replies.
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdMovedCursorV2Cb)(const char* str, SwkbdMovedCursorArg* arg, bool flag);
/// This callback is used by \ref swkbdInlineUpdate when handling MovedTab* replies.
/// str is the UTF-8 string for the current text.
typedef void (*SwkbdMovedTabCb)(const char* str, SwkbdMovedTabArg* arg);
......@@ -292,8 +313,11 @@ typedef struct {
size_t interactive_strbuf_size;
VoidFn finishedInitializeCb;
VoidFn decidedCancelCb;
SwkbdChangedStringCb changedStringCb;
SwkbdChangedStringV2Cb changedStringV2Cb;
SwkbdMovedCursorCb movedCursorCb;
SwkbdMovedCursorV2Cb movedCursorV2Cb;
SwkbdMovedTabCb movedTabCb;
SwkbdDecidedEnterCb decidedEnterCb;
VoidFn releasedUserWordInfoCb;
......@@ -519,6 +543,22 @@ static inline void swkbdConfigSetTextGrouping(SwkbdConfig* c, u32 index, u32 val
c->arg.textGrouping[index] = value;
}
/**
* @brief Sets SwkbdConfig::unkFlag, default is 0. Copied to SwkbdArgVB::unkFlag with [8.0.0+].
* @param flag Flag
*/
static inline void swkbdConfigSetUnkFlag(SwkbdConfig* c, u8 flag) {
c->unkFlag = flag;
}
/**
* @brief Sets SwkbdConfig::trigger, default is 0. Copied to SwkbdArgVB::trigger with [8.0.0+].
* @param trigger Trigger
*/
static inline void swkbdConfigSetTrigger(SwkbdConfig* c, u8 trigger) {
c->trigger = trigger;
}
/**
* @brief Launch swkbd with the specified config. This will return once swkbd is finished running.
* @note The string buffer is also used for the buffer passed to the \ref SwkbdTextCheckCb, when it's set. Hence, in that case this buffer should be large enough to handle TextCheck string input/output. The size passed to the callback is the same size passed here, -1.
......@@ -543,11 +583,20 @@ Result swkbdInlineCreate(SwkbdInline* s);
Result swkbdInlineClose(SwkbdInline* s);
/**
* @brief Launches the applet with the SwkbdInline object.
* @brief Does setup for \ref SwkbdInitializeArg and launches the applet with the SwkbdInline object.
* @note The initArg is cleared, and on [5.0.0+] unk_x5 is set to 1.
* @param s SwkbdInline object.
*/
Result swkbdInlineLaunch(SwkbdInline* s);
/**
* @brief Same as \ref swkbdInlineLaunch, except mode and unk_x5 for \ref SwkbdInitializeArg are set to the input params.
* @param s SwkbdInline object.
* @param mode Value for SwkbdInitializeArg::mode.
* @param unk_x5 Value for SwkbdInitializeArg::unk_x5.
*/
Result swkbdInlineLaunchForLibraryApplet(SwkbdInline* s, u8 mode, u8 unk_x5);
/**
* @brief Handles updating SwkbdInline state, this should be called periodically.
* @note Handles applet exit if needed, and also sends the \ref SwkbdInlineCalcArg to the applet if needed. Hence, this should be called at some point after writing to \ref SwkbdInlineCalcArg.
......@@ -564,20 +613,49 @@ Result swkbdInlineUpdate(SwkbdInline* s, SwkbdState* out_state);
*/
void swkbdInlineSetFinishedInitializeCallback(SwkbdInline* s, VoidFn cb);
/**
* @brief Sets the DecidedCancel callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
* @param cb Callback
*/
void swkbdInlineSetDecidedCancelCallback(SwkbdInline* s, VoidFn cb);
/**
* @brief Sets the ChangedString callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note This clears the callback set by \ref swkbdInlineSetChangedStringV2Callback.
* @note This should be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdChangedStringCb Callback
*/
void swkbdInlineSetChangedStringCallback(SwkbdInline* s, SwkbdChangedStringCb cb);
/**
* @brief Sets the ChangedStringV2 callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note Only available with [8.0.0+].
* @note This must be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdChangedStringV2Cb Callback
*/
void swkbdInlineSetChangedStringV2Callback(SwkbdInline* s, SwkbdChangedStringV2Cb cb);
/**
* @brief Sets the MovedCursor callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note This clears the callback set by \ref swkbdInlineSetMovedCursorV2Callback.
* @note This should be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdMovedCursorCb Callback
*/
void swkbdInlineSetMovedCursorCallback(SwkbdInline* s, SwkbdMovedCursorCb cb);
/**
* @brief Sets the MovedCursorV2 callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @note Only available with [8.0.0+].
* @note This must be called after \ref swkbdInlineLaunch / \ref swkbdInlineLaunchForLibraryApplet.
* @param s SwkbdInline object.
* @param cb \ref SwkbdMovedCursorV2Cb Callback
*/
void swkbdInlineSetMovedCursorV2Callback(SwkbdInline* s, SwkbdMovedCursorV2Cb cb);
/**
* @brief Sets the MovedTab callback, used by \ref swkbdInlineUpdate. The default is NULL for none.
* @param s SwkbdInline object.
......
......@@ -99,6 +99,7 @@ typedef struct {
/// Common container struct for applets' reply data, from the output storage.
typedef struct {
bool type; ///< Type of reply: false = ret, true = storage.
WebShimKind shimKind; ///< ShimKind
WebCommonReturnValue ret; ///< Reply data for reply=false.
WebCommonTLVStorage storage; ///< Reply data for reply=true.
} WebCommonReply;
......@@ -173,18 +174,22 @@ typedef enum {
WebArgType_BootFooterButton = 0x3E, ///< [6.0.0+] Array of \ref WebBootFooterButtonEntry with 0x10 entries.
WebArgType_OverrideWebAudioVolume = 0x3F, ///< [6.0.0+] float
WebArgType_OverrideMediaAudioVolume = 0x40, ///< [6.0.0+] float
WebArgType_SessionBootMode = 0x41, ///< [7.0.0+] u32 enum WebSessionBootMode
WebArgType_SessionFlag = 0x42, ///< [7.0.0+] u8 bool, enables using WebSession when set.
WebArgType_MediaPlayerUi = 0x43, ///< [8.0.0+] u8 bool
} WebArgType;
/// Types for \ref WebArgTLV, output storage.
typedef enum {
WebReplyType_ExitReason = 0x1, ///< [3.0.0+] u32 ShareExitReason
WebReplyType_LastUrl = 0x2, ///< [3.0.0+] string
WebReplyType_LastUrlSize = 0x3, ///< [3.0.0+] u64
WebReplyType_SharePostResult = 0x4, ///< [3.0.0+] u32 SharePostResult
WebReplyType_PostServiceName = 0x5, ///< [3.0.0+] string
WebReplyType_PostServiceNameSize = 0x6, ///< [3.0.0+] u64
WebReplyType_PostId = 0x7, ///< [3.0.0+] string
WebReplyType_PostIdSize = 0x8, ///< [3.0.0+] u64
WebReplyType_ExitReason = 0x1, ///< [3.0.0+] u32 ExitReason
WebReplyType_LastUrl = 0x2, ///< [3.0.0+] string
WebReplyType_LastUrlSize = 0x3, ///< [3.0.0+] u64
WebReplyType_SharePostResult = 0x4, ///< [3.0.0+] u32 SharePostResult
WebReplyType_PostServiceName = 0x5, ///< [3.0.0+] string
WebReplyType_PostServiceNameSize = 0x6, ///< [3.0.0+] u64
WebReplyType_PostId = 0x7, ///< [3.0.0+] string
WebReplyType_PostIdSize = 0x8, ///< [3.0.0+] u64
WebReplyType_MediaPlayerAutoClosedByCompletion = 0x9, ///< [8.0.0+] u8 bool
} WebReplyType;
/// This controls the kind of content to mount with Offline-applet.
......@@ -642,6 +647,14 @@ Result webConfigSetOverrideWebAudioVolume(WebCommonConfig* config, float value);
*/
Result webConfigSetOverrideMediaAudioVolume(WebCommonConfig* config, float value);
/**
* @brief Sets whether MediaPlayerUi is enabled.
* @note Only available with config created by \ref webOfflineCreate on [8.0.0+].
* @param config WebCommonConfig object.
* @param flag Flag
*/
Result webConfigSetMediaPlayerUi(WebCommonConfig* config, bool flag);
/**
* @brief Launches the {web applet} with the specified config and waits for it to exit.
* @param config WebCommonConfig object.
......@@ -703,3 +716,11 @@ Result webReplyGetPostServiceName(WebCommonReply *reply, char *outstr, size_t ou
*/
Result webReplyGetPostId(WebCommonReply *reply, char *outstr, size_t outstr_maxsize, size_t *out_size);
/**
* @brief Gets the MediaPlayerAutoClosedByCompletion flag from the specified reply.
* @note Only available with reply data from Web on [8.0.0+].
* @param reply WebCommonReply object.
* @param flag Output flag
*/
Result webReplyGetMediaPlayerAutoClosedByCompletion(WebCommonReply *reply, bool *flag);
/**
* @file atomics.h
* @brief AArch64 atomic operations.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
/// Atomically increments a 32-bit value.
static inline u32 atomicIncrement32(u32* p) {
return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST);
}
/// Atomically decrements a 32-bit value.
static inline u32 atomicDecrement32(u32* p) {
return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST);
}
/// Atomically increments a 64-bit value.
static inline u64 atomicIncrement64(u64* p) {
return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST);
}
/// Atomically decrements a 64-bit value.
static inline u64 atomicDecrement64(u64* p) {
return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST);
}
// Copyright 2018 plutoo
/**
* @file event.h
* @brief Kernel-mode event synchronization primitive.
* @author plutoo
* @copyright libnx Authors
*/
#pragma once
#include "../types.h"
#include "../result.h"
#include "wait.h"
/// Kernel-mode event structure.
typedef struct {
Handle revent;
Handle wevent;
bool autoclear;
Handle revent; ///< Read-only event handle
Handle wevent; ///< Write-only event handle
bool autoclear; ///< Autoclear flag
} Event;
/// Creates a \ref Waiter for a kernel-mode event.
......@@ -19,16 +25,60 @@ static inline Waiter waiterForEvent(Event* t)
return wait_obj;
}
/**
* @brief Creates a kernel-mode event.
* @param[out] t Pointer to \ref Event structure.
* @param[in] autoclear Autoclear flag.
* @return Result code.
* @warning This is a privileged operation; in normal circumstances applications shouldn't use this function.
*/
Result eventCreate(Event* t, bool autoclear);
/**
* @brief Loads a kernel-mode event obtained from IPC.
* @param[out] t Pointer to \ref Event structure.
* @param[in] handle Read-only event handle.
* @param[in] autoclear Autoclear flag.
*/
void eventLoadRemote(Event* t, Handle handle, bool autoclear);
/**
* @brief Closes a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
*/
void eventClose(Event* t);
/// Returns whether the Event is initialized.
/**
* @brief Returns whether an \ref Event is initialized.
* @param[in] t Pointer to \ref Event structure.
* @return Initialization status.
*/
static inline bool eventActive(Event* t)
{
return t->revent != INVALID_HANDLE;
}
/**
* @brief Waits on a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @param[in] timeout Timeout in nanoseconds (pass UINT64_MAX to wait indefinitely).
* @return Result code.
*/
Result eventWait(Event* t, u64 timeout);
/**
* @brief Signals a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @return Result code.
* @note This function only works for events initialized with \ref eventCreate, it doesn't work with events initialized with \ref eventLoadRemote.
* @warning This is a privileged operation; in normal circumstances applications shouldn't use this function.
*/
Result eventFire(Event* t);
/**
* @brief Clears a kernel-mode event.
* @param[in] t Pointer to \ref Event structure.
* @return Result code.
* @note This function shouldn't be used on autoclear events.
*/
Result eventClear(Event* t);
......@@ -198,13 +198,13 @@ static inline void ipcAddRecvStatic(IpcCommand* cmd, void* buffer, size_t size,
/**
* @brief Adds a smart-buffer (buffer + static-buffer pair) to an IPC command structure.
* @param cmd IPC command structure.
* @param ipc_buffer_size IPC buffer size.
* @param pointer_buffer_size Pointer buffer size.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param index Index of buffer.
*/
static inline void ipcAddSendSmart(IpcCommand* cmd, size_t ipc_buffer_size, const void* buffer, size_t size, u8 index) {
if (ipc_buffer_size != 0 && size <= ipc_buffer_size) {
static inline void ipcAddSendSmart(IpcCommand* cmd, size_t pointer_buffer_size, const void* buffer, size_t size, u8 index) {
if (pointer_buffer_size != 0 && size <= pointer_buffer_size) {
ipcAddSendBuffer(cmd, NULL, 0, BufferType_Normal);
ipcAddSendStatic(cmd, buffer, size, index);
} else {
......@@ -216,13 +216,13 @@ static inline void ipcAddSendSmart(IpcCommand* cmd, size_t ipc_buffer_size, cons
/**
* @brief Adds a smart-receive-buffer (buffer + static-receive-buffer pair) to an IPC command structure.
* @param cmd IPC command structure.
* @param ipc_buffer_size IPC buffer size.
* @param pointer_buffer_size Pointer buffer size.
* @param buffer Address of the buffer.
* @param size Size of the buffer.
* @param index Index of buffer.
*/
static inline void ipcAddRecvSmart(IpcCommand* cmd, size_t ipc_buffer_size, void* buffer, size_t size, u8 index) {
if (ipc_buffer_size != 0 && size <= ipc_buffer_size) {
static inline void ipcAddRecvSmart(IpcCommand* cmd, size_t pointer_buffer_size, void* buffer, size_t size, u8 index) {
if (pointer_buffer_size != 0 && size <= pointer_buffer_size) {
ipcAddRecvBuffer(cmd, NULL, 0, BufferType_Normal);
ipcAddRecvStatic(cmd, buffer, size, index);
} else {
......
......@@ -7,3 +7,9 @@ void nvGpuExit(void);
const nvioctl_gpu_characteristics* nvGpuGetCharacteristics(void);
u32 nvGpuGetZcullCtxSize(void);
const nvioctl_zcull_info* nvGpuGetZcullInfo(void);
const u32* nvGpuGetTpcMasks(u32 *num_masks_out);
Result nvGpuZbcGetActiveSlotMask(u32 *out_slot, u32 *out_mask);
Result nvGpuZbcAddColor(const u32 color_l2[4], const u32 color_ds[4], u32 format);
Result nvGpuZbcAddDepth(float depth);
......@@ -44,6 +44,29 @@
#define __nv_out
#define __nv_inout
typedef struct {
u32 width_align_pixels; // 0x20 (32)
u32 height_align_pixels; // 0x20 (32)
u32 pixel_squares_by_aliquots; // 0x400 (1024)
u32 aliquot_total; // 0x800 (2048)
u32 region_byte_multiplier; // 0x20 (32)
u32 region_header_size; // 0x20 (32)
u32 subregion_header_size; // 0xC0 (192)
u32 subregion_width_align_pixels; // 0x20 (32)
u32 subregion_height_align_pixels; // 0x40 (64)
u32 subregion_count; // 0x10 (16)
} nvioctl_zcull_info;
typedef struct {
u32 color_ds[4];
u32 color_l2[4];
u32 depth;
u32 ref_cnt;
u32 format;
u32 type;
u32 size;
} nvioctl_zbc_entry;
typedef struct {
u32 arch; // 0x120 (NVGPU_GPU_ARCH_GM200)
u32 impl; // 0xB (NVGPU_GPU_IMPL_GM20B)
......@@ -90,9 +113,9 @@ typedef struct {
} nvioctl_va_region;
typedef struct {
u32 mask; // always 0x07
u32 flush; // active flush bit field
} nvioctl_l2_state;
u32 slot; // always 0x07 (?)
u32 mask;
} nvioctl_zbc_slot_mask;
typedef struct {
u32 id;
......@@ -106,6 +129,10 @@ typedef struct {
};
} nvioctl_gpfifo_entry;
#define NVGPU_ZBC_TYPE_INVALID 0
#define NVGPU_ZBC_TYPE_COLOR 1
#define NVGPU_ZBC_TYPE_DEPTH 2
// Used with nvioctlNvmap_Param().
typedef enum nvioctl_map_param {
NvMapParam_Size = 1,
......@@ -181,10 +208,12 @@ Result nvioctlNvhostCtrl_EventRegister(u32 fd, u32 event_id);
Result nvioctlNvhostCtrl_EventUnregister(u32 fd, u32 event_id);
Result nvioctlNvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out);
Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, u32 out[40>>2]);
Result nvioctlNvhostCtrlGpu_ZCullGetInfo(u32 fd, nvioctl_zcull_info *out);
Result nvioctlNvhostCtrlGpu_ZbcSetTable(u32 fd, const u32 color_ds[4], const u32 color_l2[4], u32 depth, u32 format, u32 type);
Result nvioctlNvhostCtrlGpu_ZbcQueryTable(u32 fd, u32 index, nvioctl_zbc_entry *out);
Result nvioctlNvhostCtrlGpu_GetCharacteristics(u32 fd, nvioctl_gpu_characteristics *out);
Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, u32 inval, u32 out[24>>2]);
Result nvioctlNvhostCtrlGpu_GetL2State(u32 fd, nvioctl_l2_state *out);
Result nvioctlNvhostCtrlGpu_GetTpcMasks(u32 fd, void *buffer, size_t size);
Result nvioctlNvhostCtrlGpu_ZbcGetActiveSlotMask(u32 fd, nvioctl_zbc_slot_mask *out);
Result nvioctlNvhostAsGpu_BindChannel(u32 fd, u32 channel_fd);
Result nvioctlNvhostAsGpu_AllocSpace(u32 fd, u32 pages, u32 page_size, u32 flags, u64 align_or_offset, u64 *offset);
......
......@@ -42,11 +42,20 @@ FsFileSystem* fsdevGetDeviceFileSystem(const char *name);
/// Returns the FsFileSystem for the default device (SD card), if mounted. Used internally by romfs_dev.
FsFileSystem* fsdevGetDefaultFileSystem(void);
/// Writes the FS-path to outpath (which has buffer size FS_MAX_PATH), for the input device path. The FsFileSystem is also written to device when not NULL.
/// Writes the FS-path to outpath (which has buffer size FS_MAX_PATH), for the input path (as used in stdio). The FsFileSystem is also written to device when not NULL.
int fsdevTranslatePath(const char *path, FsFileSystem** device, char *outpath);
/// This calls fsFsSetArchiveBit on the filesystem specified by the input absolute path.
/// This calls fsFsSetArchiveBit on the filesystem specified by the input path (as used in stdio).
Result fsdevSetArchiveBit(const char *path);
/// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio).
Result fsdevCreateFile(const char* path, size_t size, int flags);
/// Recursively deletes the directory specified by the input path (as used in stdio).
Result fsdevDeleteDirectoryRecursively(const char *path);
/// Unmounts all devices and cleans up any resources used by the FS driver.
Result fsdevUnmountAll(void);
/// Retrieves the last native result code generated during a failed fsdev operation.
Result fsdevGetLastResult(void);
......@@ -84,6 +84,12 @@ static inline Result romfsInitFromStorage(FsStorage storage, u64 offset)
return romfsMountFromStorage(storage, offset, "romfs");
}
/**
* @brief Mounts RomFS using the current process host title RomFS.
* @param name Device mount name.
*/
Result romfsMountFromCurrentProcess(const char *name);
/**
* @brief Mounts RomFS from a file path in a mounted fsdev device.
* @param path File path.
......
/**
* @file nxlink.h
* @brief Netloader (nxlink) utilities
* @author WinterMute
* @copyright libnx Authors
*/
#pragma once
struct in_addr;
/// Address of the host connected through nxlink
extern struct in_addr __nxlink_host;
#define NXLINK_SERVER_PORT 28280
#define NXLINK_CLIENT_PORT 28771
#define NXLINK_SERVER_PORT 28280 ///< nxlink TCP server port
#define NXLINK_CLIENT_PORT 28771 ///< nxlink TCP client port
/**
* @brief Sets up stdout/stderr redirection to the nxlink host.
* @return Socket fd on success, negative number on failure.
* @note The socket should be closed with close() during application cleanup.
*/
int nxlinkStdio(void);
......@@ -20,6 +20,10 @@
/// For use with \ref FsSave and \ref FsSaveDataInfo.
#define FS_SAVEDATA_USERID_COMMONSAVE 0
typedef struct {
u8 c[0x10];
} FsRightsId;
typedef struct {
Service s;
} FsFileSystem;
......@@ -98,8 +102,8 @@ typedef struct
} FsTimeStampRaw;
typedef enum {
ENTRYTYPE_DIR = 0,
ENTRYTYPE_FILE = 1
ENTRYTYPE_DIR = 0,
ENTRYTYPE_FILE = 1,
} FsEntryType;
typedef enum
......@@ -109,18 +113,35 @@ typedef enum
FS_OPEN_APPEND = BIT(2), ///< Append file.
} FsFileFlags;
typedef enum
{
FS_CREATE_BIG_FILE = BIT(0), ///< Creates a ConcatenationFile (dir with archive bit) instead of file.
} FsFileCreateFlags;
/// For use with fsFsOpenDirectory.
typedef enum
{
FS_DIROPEN_DIRECTORY = BIT(0), ///< Enable reading directory entries.
FS_DIROPEN_FILE = BIT(1), ///< Enable reading file entries.
FS_DIROPEN_DIRECTORY = BIT(0), ///< Enable reading directory entries.
FS_DIROPEN_FILE = BIT(1), ///< Enable reading file entries.
FS_DIROPEN_NO_FILE_SIZE = BIT(31), ///< Causes result entries to not contain filesize information (always 0).
} FsDirectoryFlags;
typedef enum
{
FsStorageId_None = 0,
FsStorageId_Host = 1,
FsStorageId_GameCard = 2,
FS_READOPTION_NONE = 0, ///< No Option.
} FsReadOption;
typedef enum
{
FS_WRITEOPTION_NONE = 0, ///< No option.
FS_WRITEOPTION_FLUSH = BIT(0), ///< Forces a flush after write.
} FsWriteOption;
typedef enum
{
FsStorageId_None = 0,
FsStorageId_Host = 1,
FsStorageId_GameCard = 2,
FsStorageId_NandSystem = 3,
FsStorageId_NandUser = 4,
FsStorageId_SdCard = 5,
......@@ -140,7 +161,7 @@ typedef enum
FsSaveDataSpaceId_SdCard = 2,
FsSaveDataSpaceId_TemporaryStorage = 3,
FsSaveDataSpaceId_All = -1, ///< Pseudo value for fsOpenSaveDataIterator().
FsSaveDataSpaceId_All = -1, ///< Pseudo value for fsOpenSaveDataIterator().
} FsSaveDataSpaceId;
typedef enum
......@@ -163,13 +184,47 @@ typedef struct {
u32 value;
} FsGameCardHandle;
typedef struct {
u32 aes_ctr_key_type; ///< Contains bitflags describing how data is AES encrypted.
u32 speed_emulation_type; ///< Contains bitflags describing how data is emulated.
u32 reserved[0x38/sizeof(u32)];
} FsRangeInfo;
typedef enum {
FsOperationId_Clear, ///< Fill range with zero for supported file/storage.
FsOperationId_ClearSignature, ///< Clears signature for supported file/storage.
FsOperationId_InvalidateCache, ///< Invalidates cache for supported file/storage.
FsOperationId_QueryRange, ///< Retrieves information on data for supported file/storage.
} FsOperationId;
typedef enum {
FsBisStorageId_Boot0 = 0,
FsBisStorageId_Boot1 = 10,
FsBisStorageId_UserDataRoot = 20,
FsBisStorageId_BootConfigAndPackage2NormalMain = 21,
FsBisStorageId_BootConfigAndPackage2NormalSub = 22,
FsBisStorageId_BootConfigAndPackage2SafeMain = 23,
FsBisStorageId_BootConfigAndPackage2SafeSub = 24,
FsBisStorageId_BootConfigAndPackage2RepairMain = 25,
FsBisStorageId_BootConfigAndPackage2RepairSub = 26,
FsBisStorageId_CalibrationBinary = 27,
FsBisStorageId_CalibrationFile = 28,
FsBisStorageId_SafeMode = 29,
FsBisStorageId_User = 30,
FsBisStorageId_System = 31,
FsBisStorageId_SystemProperEncryption = 32,
FsBisStorageId_SystemProperPartition = 33,
} FsBisStorageId;
Result fsInitialize(void);
void fsExit(void);
Service* fsGetServiceSession(void);
Result fsOpenBisStorage(FsStorage* out, u32 PartitionId);
Result fsOpenBisFileSystem(FsFileSystem* out, u32 PartitionId, const char* string);
Result fsOpenBisStorage(FsStorage* out, FsBisStorageId PartitionId);
Result fsOpenBisFileSystem(FsFileSystem* out, FsBisStorageId PartitionId, const char* string);
Result fsIsExFatSupported(bool* out);
......@@ -179,10 +234,17 @@ 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 fsOpenContentStorageFileSystem(FsFileSystem* out, FsContentStorageId content_storage_id);
Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, FsStorageId storageId);
Result fsOpenDeviceOperator(FsDeviceOperator* out);
Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out);
/// Retrieves the rights id corresponding to the content path. Only available on [2.0.0+].
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);
// todo: Rest of commands here
/// FsFileSystem can be mounted with fs_dev for use with stdio, see fs_dev.h.
......@@ -197,12 +259,12 @@ Result fsMount_SystemSaveData(FsFileSystem* out, u64 saveID);
typedef enum
{
FsFileSystemType_Logo = 2,
FsFileSystemType_ContentControl = 3,
FsFileSystemType_ContentManual = 4,
FsFileSystemType_ContentMeta = 5,
FsFileSystemType_ContentData = 6,
FsFileSystemType_ApplicationPackage = 7
FsFileSystemType_Logo = 2,
FsFileSystemType_ContentControl = 3,
FsFileSystemType_ContentManual = 4,
FsFileSystemType_ContentMeta = 5,
FsFileSystemType_ContentData = 6,
FsFileSystemType_ApplicationPackage = 7,
} FsFileSystemType;
typedef enum
......@@ -213,6 +275,7 @@ typedef enum
/// Mount requested filesystem type from content file
Result fsOpenFileSystem(FsFileSystem* out, FsFileSystemType fsType, const char* contentPath); /// same as calling fsOpenFileSystemWithId with 0 as titleId
Result fsOpenFileSystemWithId(FsFileSystem* out, u64 titleId, FsFileSystemType fsType, const char* contentPath); /// works on all firmwares, titleId is ignored on 1.0.0
Result fsOpenFileSystemWithPatch(FsFileSystem* out, u64 titleId, FsFileSystemType fsType); /// 2.0.0+, like OpenFileSystemWithId but without content path.
// IFileSystem
Result fsFsCreateFile(FsFileSystem* fs, const char* path, size_t size, int flags);
......@@ -220,8 +283,8 @@ Result fsFsDeleteFile(FsFileSystem* fs, const char* path);
Result fsFsCreateDirectory(FsFileSystem* fs, const char* path);
Result fsFsDeleteDirectory(FsFileSystem* fs, const char* path);
Result fsFsDeleteDirectoryRecursively(FsFileSystem* fs, const char* path);
Result fsFsRenameFile(FsFileSystem* fs, const char* path0, const char* path1);
Result fsFsRenameDirectory(FsFileSystem* fs, const char* path0, const char* path1);
Result fsFsRenameFile(FsFileSystem* fs, const char* cur_path, const char* new_path);
Result fsFsRenameDirectory(FsFileSystem* fs, const char* cur_path, const char* new_path);
Result fsFsGetEntryType(FsFileSystem* fs, const char* path, FsEntryType* out);
Result fsFsOpenFile(FsFileSystem* fs, const char* path, int flags, FsFile* out);
Result fsFsOpenDirectory(FsFileSystem* fs, const char* path, int flags, FsDir* out);
......@@ -238,11 +301,12 @@ void fsFsClose(FsFileSystem* fs);
Result fsFsSetArchiveBit(FsFileSystem* fs, const char *path);
// IFile
Result fsFileRead(FsFile* f, u64 off, void* buf, size_t len, size_t* out);
Result fsFileWrite(FsFile* f, u64 off, const void* buf, size_t len);
Result fsFileRead(FsFile* f, u64 off, void* buf, size_t len, u32 option, size_t* out);
Result fsFileWrite(FsFile* f, u64 off, const void* buf, size_t len, u32 option);
Result fsFileFlush(FsFile* f);
Result fsFileSetSize(FsFile* f, u64 sz);
Result fsFileGetSize(FsFile* f, u64* out);
Result fsFileOperateRange(FsFile* f, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// 4.0.0+
void fsFileClose(FsFile* f);
// IDirectory
......@@ -256,6 +320,7 @@ Result fsStorageWrite(FsStorage* s, u64 off, const void* buf, size_t len);
Result fsStorageFlush(FsStorage* s);
Result fsStorageSetSize(FsStorage* s, u64 sz);
Result fsStorageGetSize(FsStorage* s, u64* out);
Result fsStorageOperateRange(FsStorage* s, FsOperationId op_id, u64 off, size_t len, FsRangeInfo* out); /// 4.0.0+
void fsStorageClose(FsStorage* s);
// ISaveDataInfoReader
......
/**
* @file i2c.h
* @brief I2C service IPC wrapper.
* @file gpio.h
* @brief GPIO service IPC wrapper.
* @author SciresM
* @copyright libnx Authors
*/
......
......@@ -555,14 +555,49 @@ typedef struct HidControllerSixAxisLayout
HidControllerSixAxisEntry entries[17];
} HidControllerSixAxisLayout;
/// Controller flags.
typedef struct {
u32 powerInfo : 6; ///< Use \ref hidGetControllerPowerInfo instead of accessing this directly.
u32 bit6 : 1; ///< Unused
u32 bit7 : 1; ///< Unused
u32 bit8 : 1; ///< Unused
u32 unsupportedButtonPressed_NpadSystem : 1; ///< Unsupported button pressed with controller NpadSystem.
u32 unsupportedButtonPressed_NpadSystemExt : 1; ///< Unsupported button pressed with controller NpadSystemExt.
u32 abxyButtonOriented : 1;
u32 slSrButtonOriented : 1;
u32 plusButtonCapability : 1; ///< [4.0.0+]
u32 minusButtonCapability : 1; ///< [4.0.0+]
u32 directionalButtonsSupported : 1; ///< [8.0.0+]
u32 unused;
u32 unintendedHomeButtonInputProtectionDisabled : 1;
} HidFlags;
typedef struct {
u32 deviceType;
u32 pad;
HidFlags flags;
u32 batteryCharge[3];
u8 unk_1[0x20];
HidControllerMAC macLeft;
HidControllerMAC macRight;
} HidControllerMisc;
typedef struct {
bool powerConnected;
bool isCharging;
u32 batteryCharge; ///< Battery charge, always 0-4.
} HidPowerInfo;
typedef struct HidController
{
HidControllerHeader header;
HidControllerLayout layouts[7];
HidControllerSixAxisLayout sixaxis[6];
u8 unk_1[0x40];
HidControllerMAC macLeft;
HidControllerMAC macRight;
HidControllerMisc misc;
u8 unk_2[0xDF8];
} HidController;
......@@ -628,6 +663,15 @@ HidControllerType hidGetControllerType(HidControllerID id);
void hidGetControllerColors(HidControllerID id, HidControllerColors *colors);
bool hidIsControllerConnected(HidControllerID id);
/// Gets the DeviceType for the specified controller.
u32 hidGetControllerDeviceType(HidControllerID id);
/// Gets the flags for the specified controller.
void hidGetControllerFlags(HidControllerID id, HidFlags *flags);
/// Gets the \ref HidPowerInfo for the specified controller. info is the output array, where total_info is the number of entries. total_info must be 1 or 2: former for the main battery info, latter for reading left/right Joy-Con PowerInfo.
void hidGetControllerPowerInfo(HidControllerID id, HidPowerInfo *info, size_t total_info);
void hidScanInput(void);
u64 hidKeysHeld(HidControllerID id);
......@@ -717,3 +761,25 @@ Result hidStartSixAxisSensor(u32 SixAxisSensorHandle);
/// Stops the SixAxisSensor for the specified handle.
Result hidStopSixAxisSensor(u32 SixAxisSensorHandle);
/// Starts the SevenSixAxisSensor. Only available on [5.0.0+].
Result hidStartSevenSixAxisSensor(void);
/// Stops the SevenSixAxisSensor. Only available on [5.0.0+].
Result hidStopSevenSixAxisSensor(void);
/// Initializes the SevenSixAxisSensor. Only available on [5.0.0+].
Result hidInitializeSevenSixAxisSensor(void);
/// Finalizes the SevenSixAxisSensor. Also used automatically by \ref hidExit. Only available on [5.0.0+].
Result hidFinalizeSevenSixAxisSensor(void);
/// Sets the SevenSixAxisSensor FusionStrength. Only available on [5.0.0+].
Result hidSetSevenSixAxisSensorFusionStrength(float strength);
/// Gets the SevenSixAxisSensor FusionStrength. Only available on [5.0.0+].
Result hidGetSevenSixAxisSensorFusionStrength(float *strength);
/// Resets the timestamp for the SevenSixAxisSensor. Only available on [6.0.0+].
Result hidResetSevenSixAxisSensorTimestamp(void);
/**
* @file hiddbg.h
* @brief hid:dbg service IPC wrapper.
* @author yellows8
*/
#pragma once
#include "../types.h"
#include "../services/hid.h"
#include "../services/sm.h"
/// HdlsDeviceInfo
typedef struct {
u32 type; ///< See \ref HidControllerType, only one bit can be set.
u32 singleColorBody; ///< RGBA Single Body Color
u32 singleColorButtons; ///< RGBA Single Buttons Color
u8 unk_xc; ///< Unknown
u8 pad[0x3]; ///< Padding
} HiddbgHdlsDeviceInfo;
/// HdlsState
typedef struct {
u8 unk_x0[0x8]; ///< 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 padding[0x3]; ///< Padding
} HiddbgHdlsState;
/// HdlsNpadAssignment
typedef struct {
u8 unk_x0[0x208]; ///< Unknown
} HiddbgHdlsNpadAssignment;
/// HdlsStateListEntry
typedef struct {
u64 HdlsHandle; ///< HdlsHandle
HiddbgHdlsDeviceInfo device; ///< \ref HiddbgHdlsDeviceInfo. With \ref hiddbgApplyHdlsStateList this is only used when creating new devices.
HiddbgHdlsState state; ///< \ref HiddbgHdlsState
} HiddbgHdlsStateListEntry;
/// HdlsStateList. This contains a list of all controllers, including non-virtual controllers.
typedef struct {
s32 total_entries; ///< Total entries for the below entries.
u32 pad; ///< Padding
HiddbgHdlsStateListEntry entries[0x10]; ///< \ref HiddbgHdlsStateListEntry
} HiddbgHdlsStateList;
Result hiddbgInitialize(void);
void hiddbgExit(void);
/// Initialize Hdls. Hdls is for virtual HID controllers. Only available with [7.0.0+].
Result hiddbgAttachHdlsWorkBuffer(void);
/// Exit Hdls, must be called at some point prior to hiddbgExit. Only available with [7.0.0+].
Result hiddbgReleaseHdlsWorkBuffer(void);
/// Gets state for \ref HiddbgHdlsNpadAssignment. Only available with [7.0.0+].
Result hiddbgDumpHdlsNpadAssignmentState(HiddbgHdlsNpadAssignment *state);
/// Gets state for \ref HiddbgHdlsStateList. Only available with [7.0.0+].
Result hiddbgDumpHdlsStates(HiddbgHdlsStateList *state);
/// Sets state for \ref HiddbgHdlsNpadAssignment. Only available with [7.0.0+].
Result hiddbgApplyHdlsNpadAssignmentState(const HiddbgHdlsNpadAssignment *state, bool flag);
/// Sets state for \ref HiddbgHdlsStateList. Only available with [7.0.0+].
/// The HiddbgHdlsState will be applied for each HdlsHandle. If a HdlsHandle is not found, code similar to \ref hiddbgAttachHdlsVirtualDevice will run with the \ref HiddbgHdlsDeviceInfo, then it will continue with applying state with the new device.
Result hiddbgApplyHdlsStateList(const HiddbgHdlsStateList *state);
/// Attach a device with the input info, where the output handle is written to HdlsHandle. Only available with [7.0.0+].
Result hiddbgAttachHdlsVirtualDevice(u64 *HdlsHandle, const HiddbgHdlsDeviceInfo *info);
/// Detach the specified device. Only available with [7.0.0+].
Result hiddbgDetachHdlsVirtualDevice(u64 HdlsHandle);
/// Sets state for the specified device. Only available with [7.0.0+].
Result hiddbgSetHdlsState(u64 HdlsHandle, const HiddbgHdlsState *state);
......@@ -9,9 +9,27 @@
#include "../services/hid.h"
#include "../services/sm.h"
/// Mini Cycle struct for \ref HidsysNotificationLedPattern.
typedef struct {
u8 ledIntensity; ///< Mini Cycle X LED Intensity.
u8 transitionSteps; ///< Fading Transition Steps to Mini Cycle X (Uses PWM). Value 0x0: Instant. Each step duration is based on HidsysNotificationLedPattern::baseMiniCycleDuration.
u8 finalStepDuration; ///< Final Step Duration Multiplier of Mini Cycle X. Value 0x0: 12.5ms, 0x1 - xF: 1x - 15x. Value is a Multiplier of HidsysNotificationLedPattern::baseMiniCycleDuration.
u8 pad;
} HidsysNotificationLedPatternCycle;
/// Structure for \ref hidsysSetNotificationLedPattern.
/// See also: https://switchbrew.org/wiki/HID_services#NotificationLedPattern
/// Only the low 4bits of each used byte in this struct is used.
typedef struct {
u8 unk_x0[0x48]; ///< TODO
u8 baseMiniCycleDuration; ///< Mini Cycle Base Duration. Value 0x1-0xF: 12.5ms - 187.5ms. Value 0x0 = 0ms/OFF.
u8 totalMiniCycles; ///< Number of Mini Cycles + 1. Value 0x0-0xF: 1 - 16 mini cycles.
u8 totalFullCycles; ///< Number of Full Cycles. Value 0x1-0xF: 1 - 15 full cycles. Value 0x0 is repeat forever, but if baseMiniCycleDuration is set to 0x0, it does the 1st Mini Cycle with a 12.5ms step duration and then the LED stays on with startIntensity.
u8 startIntensity; ///< LED Start Intensity. Value 0x0=0% - 0xF=100%.
HidsysNotificationLedPatternCycle miniCycles[16]; ///< Mini Cycles
u8 unk_x44[0x2]; ///< Unknown
u8 pad_x46[0x2]; ///< Padding
} HidsysNotificationLedPattern;
Result hidsysInitialize(void);
......
......@@ -9,7 +9,39 @@
#include "sm.h"
typedef enum {
I2cDevice_AudioCodec = 4,
I2cDevice_DebugPad = 0,
I2cDevice_TouchPanel = 1,
I2cDevice_Tmp451 = 2,
I2cDevice_Nct72 = 3,
I2cDevice_Alc5639 = 4,
I2cDevice_Max77620Rtc = 5,
I2cDevice_Max77620Pmic = 6,
I2cDevice_Max77621Cpu = 7,
I2cDevice_Max77621Gpu = 8,
I2cDevice_Bq24193 = 9,
I2cDevice_Max17050 = 10,
I2cDevice_Bm92t30mwv = 11,
I2cDevice_Ina226Vdd15v0Hb = 12,
I2cDevice_Ina226VsysCpuDs = 13,
I2cDevice_Ina226VsysGpuDs = 14,
I2cDevice_Ina226VsysDdrDs = 15,
I2cDevice_Ina226VsysAp = 16,
I2cDevice_Ina226VsysBlDs = 17,
I2cDevice_Bh1730 = 18,
I2cDevice_Ina226VsysCore = 19,
I2cDevice_Ina226Soc1V8 = 20,
I2cDevice_Ina226Lpddr1V8 = 21,
I2cDevice_Ina226Reg1V32 = 22,
I2cDevice_Ina226Vdd3V3Sys = 23,
I2cDevice_HdmiDdc = 24,
I2cDevice_HdmiScdc = 25,
I2cDevice_HdmiHdcp = 26,
I2cDevice_Fan53528 = 27,
I2cDevice_Max77812_3 = 28,
I2cDevice_Max77812_2 = 29,
I2cDevice_Ina226VddDdr0V6 = 30,
I2cDevice_Count,
} I2cDevice;
typedef struct {
......@@ -28,5 +60,7 @@ void i2cExit(void);
Result i2cOpenSession(I2cSession *out, I2cDevice dev);
Result i2csessionSendAuto(I2cSession *s, void *buf, size_t size, I2cTransactionOption option);
Result i2csessionSendAuto(I2cSession *s, const void *buf, size_t size, I2cTransactionOption option);
Result i2csessionReceiveAuto(I2cSession *s, void *buf, size_t size, I2cTransactionOption option);
Result i2csessionExecuteCommandList(I2cSession *s, void *dst, size_t dst_size, const void *cmd_list, size_t cmd_list_size);
void i2csessionClose(I2cSession *s);
......@@ -18,6 +18,23 @@ typedef enum {
NcmContentType_Info = 5,
} NcmContentType;
typedef enum {
NcmContentMetaType_SystemProgram = 0x01,
NcmContentMetaType_SystemData = 0x02,
NcmContentMetaType_SystemUpdate = 0x03,
NcmContentMetaType_BootImagePackage = 0x04,
NcmContentMetaType_BootImagePackageSafe = 0x05,
NcmContentMetaType_Application = 0x80,
NcmContentMetaType_Patch = 0x81,
NcmContentMetaType_AddOnContent = 0x82,
NcmContentMetaType_Delta = 0x83,
} NcmContentMetaType;
typedef enum {
NcmContentMetaAttribute_Exfat = (1 << 0),
NcmContentMetaAttribute_Rebootless = (1 << 1),
} NcmContentMetaAttribute;
typedef struct {
Service s;
} NcmContentStorage;
......@@ -57,10 +74,6 @@ typedef struct {
u64 baseTitleId;
} NcmApplicationContentMetaKey;
typedef struct {
u8 c[0x10];
} NcmRightsId;
Result ncmInitialize(void);
void ncmExit(void);
......@@ -80,7 +93,7 @@ Result ncmContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs);
Result ncmContentStorageGetSize(NcmContentStorage* cs, const NcmNcaId* ncaId, u64* out);
Result ncmContentStorageDisableForcibly(NcmContentStorage* cs);
Result ncmContentStorageReadContentIdFile(NcmContentStorage* cs, const NcmNcaId* ncaId, u64 offset, void* outBuf, size_t bufSize);
Result ncmContentStorageGetRightsIdFromContentId(NcmContentStorage* cs, const NcmNcaId* ncaId, NcmRightsId* rightsIdOut, u32* keyGenerationOut);
Result ncmContentStorageGetRightsIdFromContentId(NcmContentStorage* cs, const NcmNcaId* ncaId, FsRightsId* rightsIdOut, u32* keyGenerationOut);
Result ncmContentMetaDatabaseSet(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u64 inDataSize, const NcmContentMetaRecordsHeader* srcRecordsData);
Result ncmContentMetaDatabaseGet(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u64 outDataSize, NcmContentMetaRecordsHeader* outRecordsData, u64* sizeRead);
......@@ -93,3 +106,4 @@ Result ncmContentMetaDatabaseListApplication(NcmContentMetaDatabase* db, u8 filt
Result ncmContentMetaDatabaseHas(NcmContentMetaDatabase* db, const NcmMetaRecord* record, bool* out);
Result ncmContentMetaDatabaseDisableForcibly(NcmContentMetaDatabase* db);
Result ncmContentMetaDatabaseCommit(NcmContentMetaDatabase* db);
Result ncmContentMetaDatabaseGetAttributes(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u8* out);
......@@ -11,6 +11,7 @@
#include "../kernel/event.h"
#define SET_MAX_NAME_SIZE 0x48
#define SET_MAX_NICKNAME_SIZE 0x80
typedef enum {
ColorSetId_Light=0,
......@@ -175,3 +176,15 @@ Result setsysBindFatalDirtyFlagEvent(Event *out);
* @param flags_1 Pointer to populate with second 64 flags.
*/
Result setsysGetFatalDirtyFlags(u64 *flags_0, u64 *flags_1);
/**
* @brief Gets the system's nickname.
* @param nickname Pointer to output the nickname to. (The buffer size needs to be at least 0x80 bytes)
*/
Result setsysGetDeviceNickname(char* nickname);
/**
* @brief Sets the system's nickname.
* @param nickname Pointer to read the nickname from.
*/
Result setsysSetDeviceNickname(const char* nickname);
......@@ -57,8 +57,8 @@ Result splUserExpMod(const void *input, const void *modulus, const void *exp, si
Result splSetConfig(SplConfigItem config_item, u64 value);
Result splGetRandomBytes(void *out, size_t out_size);
Result splIsDevelopment(bool *out_is_development);
Result splSetSharedData(u32 value);
Result splGetSharedData(u32 *out_value);
Result splSetBootReason(u32 value);
Result splGetBootReason(u32 *out_value);
Result splCryptoGenerateAesKek(const void *wrapped_kek, u32 key_generation, u32 option, void *out_sealed_kek);
Result splCryptoLoadAesKey(const void *sealed_kek, const void *wrapped_key, u32 keyslot);
......
......@@ -96,6 +96,7 @@ typedef struct {
typedef struct {
Service s;
Event eventXfer; ///< [2.0.0+] Signaled when PostBufferAsync finishes.
size_t ptrbufsize; ///< [3.0.0+] IPC pointer buffer size.
struct usb_endpoint_descriptor desc;
} UsbHsClientEpSession;
......
......@@ -52,7 +52,9 @@ static void _swkbdConfigClear(SwkbdConfig* c) {
static void _swkbdInitVersion(u32* version) {
u32 hosver = hosversionGet();
if (hosver >= MAKEHOSVERSION(6,0,0))
if (hosver >= MAKEHOSVERSION(8,0,0))
*version = 0x8000D;
else if (hosver >= MAKEHOSVERSION(6,0,0))
*version = 0x6000B;
else if (hosver >= MAKEHOSVERSION(5,0,0))
*version = 0x50009;
......@@ -68,14 +70,17 @@ static void _swkbdInitVersion(u32* version) {
Result swkbdCreate(SwkbdConfig* c, s32 max_dictwords) {
Result rc=0;
s32 maxwords = 0x3e8;
memset(c, 0, sizeof(SwkbdConfig));
_swkbdConfigClear(c);
_swkbdInitVersion(&c->version);
if (c->version >= 0x8000D) maxwords = 0x1388;
c->workbuf_size = 0x1000;
if (max_dictwords > 0 && max_dictwords <= 0x3e8) c->max_dictwords = max_dictwords;
if (max_dictwords > 0 && max_dictwords <= maxwords) c->max_dictwords = max_dictwords;
if (c->max_dictwords) {
c->workbuf_size = c->max_dictwords*sizeof(SwkbdDictWord) + 0x7e8;
......@@ -301,6 +306,11 @@ Result swkbdShow(SwkbdConfig* c, char* out_string, size_t out_string_size) {
memcpy(arg_vb.entries, c->customizedDictionarySet.entries, sizeof(arg_vb.entries));
arg_vb.total_entries = c->customizedDictionarySet.total_entries;
if (c->version >= 0x8000D) { // [8.0.0+]
arg_vb.unkFlag = c->unkFlag;
arg_vb.trigger = c->trigger;
}
rc = libappletPushInData(&holder, &arg_vb, sizeof(arg_vb));
}
else if (c->version >= 0x30007) rc = libappletPushInData(&holder, &c->arg, sizeof(c->arg)); // [3.0.0+] has a larger struct.
......@@ -381,8 +391,6 @@ Result swkbdInlineCreate(SwkbdInline* s) {
s->calcArg.unk_x0 = 0x30000;
s->calcArg.size = sizeof(s->calcArg);
//if (s->version >= 0x50009) s->calcArg.initArg.unk_x5 = 0x1;//Set in a separate init func by official sw on 5.0.0+.
s->calcArg.volume = 1.0f;
s->calcArg.appearArg.type = SwkbdType_QWERTY;
s->calcArg.unk_x6 = 1;
......@@ -479,9 +487,12 @@ Result swkbdInlineClose(SwkbdInline* s) {
return rc;
}
Result swkbdInlineLaunch(SwkbdInline* s) {
static Result _swkbdInlineLaunch(SwkbdInline* s, SwkbdInitializeArg *initArg) {
Result rc=0;
memcpy(&s->calcArg.initArg, initArg, sizeof(*initArg));
s->calcArg.flags |= 0x1;
rc = appletCreateLibraryApplet(&s->holder, AppletId_swkbd, s->calcArg.initArg.mode!=SwkbdInlineMode_UserDisplay ? LibAppletMode_Background : LibAppletMode_Unknown3);
if (R_FAILED(rc)) return rc;
......@@ -496,6 +507,23 @@ Result swkbdInlineLaunch(SwkbdInline* s) {
return rc;
}
Result swkbdInlineLaunch(SwkbdInline* s) {
SwkbdInitializeArg initArg = {0};
if (s->version >= 0x50009) initArg.unk_x5 = 0x1; // [5.0.0+]
return _swkbdInlineLaunch(s, &initArg);
}
Result swkbdInlineLaunchForLibraryApplet(SwkbdInline* s, u8 mode, u8 unk_x5) {
SwkbdInitializeArg initArg = {0};
initArg.mode = mode;
initArg.unk_x5 = unk_x5;
return _swkbdInlineLaunch(s, &initArg);
}
static void _swkbdProcessReply(SwkbdInline* s, SwkbdReplyType ReplyType, size_t size) {
size_t stringendoff_utf8 = 0x7D4;
size_t stringendoff_utf16 = 0x3EC;
......@@ -507,10 +535,14 @@ static void _swkbdProcessReply(SwkbdInline* s, SwkbdReplyType ReplyType, size_t
if ((ReplyType==SwkbdReplyType_ChangedString && size != 0x3FC) || (ReplyType==SwkbdReplyType_ChangedStringUtf8 && size != 0x7E4)) return;
if ((ReplyType==SwkbdReplyType_MovedCursor && size != 0x3F4) || (ReplyType==SwkbdReplyType_MovedCursorUtf8 && size != 0x7DC)) return;
if ((ReplyType==SwkbdReplyType_ChangedStringV2 && size != 0x3FC+0x1) || (ReplyType==SwkbdReplyType_ChangedStringUtf8V2 && size != 0x7E4+0x1)) return;
if ((ReplyType==SwkbdReplyType_MovedCursorV2 && size != 0x3F4+0x1) || (ReplyType==SwkbdReplyType_MovedCursorUtf8V2 && size != 0x7DC+0x1)) return;
if ((ReplyType==SwkbdReplyType_DecidedEnter && size != 0x3F0) || (ReplyType==SwkbdReplyType_DecidedEnterUtf8 && size != 0x7D8)) return;
if (ReplyType==SwkbdReplyType_MovedTab && size != 0x3F4) return;
if (ReplyType==SwkbdReplyType_ChangedString || ReplyType==SwkbdReplyType_MovedCursor || ReplyType==SwkbdReplyType_MovedTab || ReplyType==SwkbdReplyType_DecidedEnter) {
if (ReplyType==SwkbdReplyType_ChangedString || ReplyType==SwkbdReplyType_ChangedStringV2 || ReplyType==SwkbdReplyType_MovedCursor || ReplyType==SwkbdReplyType_MovedCursorV2 || ReplyType==SwkbdReplyType_MovedTab || ReplyType==SwkbdReplyType_DecidedEnter) {
_swkbdConvertToUTF8(s->interactive_strbuf, (u16*)strdata, s->interactive_strbuf_size-1);
strdata = s->interactive_strbuf;
}
......@@ -520,6 +552,10 @@ static void _swkbdProcessReply(SwkbdInline* s, SwkbdReplyType ReplyType, size_t
if (s->finishedInitializeCb) s->finishedInitializeCb();
break;
case SwkbdReplyType_DecidedCancel:
if (s->decidedCancelCb) s->decidedCancelCb();
break;
case SwkbdReplyType_ChangedString:
case SwkbdReplyType_ChangedStringUtf8:
if (s->changedStringCb) {
......@@ -528,6 +564,14 @@ static void _swkbdProcessReply(SwkbdInline* s, SwkbdReplyType ReplyType, size_t
}
break;
case SwkbdReplyType_ChangedStringV2:
case SwkbdReplyType_ChangedStringUtf8V2:
if (s->changedStringV2Cb) {
if (ReplyType==SwkbdReplyType_ChangedStringV2) s->changedStringV2Cb(strdata, (SwkbdChangedStringArg*)argdataend_utf16, s->interactive_tmpbuf[size-1]==0);
if (ReplyType==SwkbdReplyType_ChangedStringUtf8V2) s->changedStringV2Cb(strdata, (SwkbdChangedStringArg*)argdataend_utf8, s->interactive_tmpbuf[size-1]==0);
}
break;
case SwkbdReplyType_MovedCursor:
case SwkbdReplyType_MovedCursorUtf8:
if (s->movedCursorCb) {
......@@ -536,6 +580,14 @@ static void _swkbdProcessReply(SwkbdInline* s, SwkbdReplyType ReplyType, size_t
}
break;
case SwkbdReplyType_MovedCursorV2:
case SwkbdReplyType_MovedCursorUtf8V2:
if (s->movedCursorV2Cb) {
if (ReplyType==SwkbdReplyType_MovedCursorV2) s->movedCursorV2Cb(strdata, (SwkbdMovedCursorArg*)argdataend_utf16, s->interactive_tmpbuf[size-1]==0);
if (ReplyType==SwkbdReplyType_MovedCursorUtf8V2) s->movedCursorV2Cb(strdata, (SwkbdMovedCursorArg*)argdataend_utf8, s->interactive_tmpbuf[size-1]==0);
}
break;
case SwkbdReplyType_MovedTab:
if (s->movedTabCb) s->movedTabCb(strdata, (SwkbdMovedTabArg*)argdataend_utf16);
break;
......@@ -632,16 +684,44 @@ Result swkbdInlineUpdate(SwkbdInline* s, SwkbdState* out_state) {
return rc;
}
static inline Result _swkbdSendRequestV2Flag(SwkbdInline* s, SwkbdRequestCommand req, bool flag) {
if (s->version < 0x8000D) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u8 tmp = flag!=0;
return _swkbdSendRequest(s, req, &tmp, sizeof(tmp));
}
void swkbdInlineSetFinishedInitializeCallback(SwkbdInline* s, VoidFn cb) {
s->finishedInitializeCb = cb;
}
void swkbdInlineSetDecidedCancelCallback(SwkbdInline* s, VoidFn cb) {
s->decidedCancelCb = cb;
}
void swkbdInlineSetChangedStringCallback(SwkbdInline* s, SwkbdChangedStringCb cb) {
s->changedStringCb = cb;
s->changedStringV2Cb = NULL;
_swkbdSendRequestV2Flag(s, SwkbdRequestCommand_SetChangedStringV2Flag, false);