From d1e5a5d6c8a597c7b06056b9ee826077ff4ccdc1 Mon Sep 17 00:00:00 2001 From: fincs Date: Wed, 11 Dec 2019 00:40:38 +0100 Subject: [PATCH 1/2] libnx v3.0.0 --- Changelog.md | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++ nx/Makefile | 4 +- 2 files changed, 238 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index fbd6fa89..1d49a714 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,241 @@ # Changelog +## Version 3.0.0 + +#### system +* **The IPC system has been redesigned with a brand new interface and implementation**. + * Changed serviceClone to actually use the non-Ex cmif control command. + * Added serviceCloneEx. +* Added NX_INLINE and NX_CONSTEXPR helper macros. +* Added ServiceMgr object, used for multiplexed multithreaded services. +* Native threading API now supports using user-provided memory as stack. + * pthread explicit stack ptr/size attributes are now supported. +* Fixed incorrect bounds check in virtmem code (solves long-standing JIT bug). +* Added InfoType_IsApplication. +* Added LibnxError_ShouldNotHappen. +* Read-write lock object (rwlock) was completely rewritten to closely match the official implementation. + +#### services in general +* **All service wrappers have been converted to use the new IPC interface**. + * Fixed thread safety during service init/exit. + * Numerous commands that had IPC bugs were fixed. +* Improved documentation for many services (list too long to fit here). +* Corrected and documented system version checks for many different commands. +* Corrected many structs to avoid using types with incorrect alignment or size. +* Changed many names of fields in several structs to be more consistent and less random. +* Corrected many parameter types and names to be more consistent with official software (as well as using enums when possible). +* Phased out non-existent "Title ID" concept in favor of "Program ID" or other applicable official ID names. + * Many parameter and enum names were renamed as a result. +* Added AccountUid struct, which replaces u128 user ids throughout libnx and reduces the need for packed structs. "userID" replaced by "uid" throughout libnx. + * Added accountUidIsValid. +* Added Uuid struct, which replaces u128 uuids where applicable and reduces the need for packed structs. +* Added NacpSendReceiveConfiguration struct. +* Updated NacpStruct with many fixes and additions. +* Fixed locking issue in usbComms which caused a hang in usbCommsInitialize(Ex) on failure. + +#### sm +* Introduced SmServiceName structure: + * Added constexpr helper functions: smServiceNameToU64, smServiceNameFromU64, smServiceNamesAreEqual, smEncodeName. + * All SM functions now take in SmServiceName instead of a string, except for smGetService. + * Added smGetServiceWrapper (which takes SmServiceName and looks inside the override list). + * smGetService is now an inline wrapper for smEncodeName+smGetServiceWrapper. +* Removed smHasInitialized. + +#### filesystem +* **Added transparent multithreaded filesystem support.** + * Default maximum number of concurrent filesystem operations is 3, this can be changed through the `__nx_fs_num_sessions` weak var. +* Added fsSetPriority, fsFsIsValidSignedSystemPartitionOnSdCard. +* Thoroughly fixed the names of commands, enums, flags to match official software and be more consistent with the libnx code style (list too long to fit here). +* Removed FS_SAVEDATA_USERID_COMMONSAVE. +* Renamed FsStorageId to NcmStorageId (and renamed enum value names too). +* Added FsSaveDataSpaceId_ProperSystem, FsFileSystemType_RegisteredUpdate, FsSaveDataSpaceId_SdUser, FsSaveDataSpaceId_SafeMode. +* Added FsSaveDataType_SystemBcat. +* Added FsGameCardPartition_Logo. (also, a typo was fixed in the name of this enum) +* Added FsSaveDataFlags_NeedsSecureDelete. +* Added FsSaveDataRank enum. +* Added FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard. +* Added FsGameCardAttribute_DifferentRegionCupToTerraDeviceFlag, FsGameCardAttribute_DifferentRegionCupToGlobalDeviceFlag. +* Renamed FsBisStorageId to FsBisPartitionId. + * Added FsBisPartitionId_SignedSystemPartitionOnSafeMode. +* Removed spurious inval param from fsDirRead. +* fspr: + * Now using domains. +* fsdev: + * Timestamps are now converted into proper POSIX UTC format instead of local time. + * Directory iterator memory footprint can now be configured with `__nx_fsdev_direntry_cache_size`. + * Reduced TLS footprint for rarely used codepaths. + * Reduced TLS footprint by sharing the path buffer with romfsdev. + * Removed fsdevGetDefaultFileSystem and default-fs handling. + * Refactored CWD support to have (dynamically allocated) per-device CWDs (CWD support as a whole can be turned off with `__nx_fsdev_support_cwd`). + * Many internal optimizations that reduce unnecessary lookups and buffer copies. + * Fixed string comparison logic in fsdevFindDevice. + * Mounting a filesystem now automatically sets the default device if there wasn't any previous default device (or if it's stdnull). + * fsdevMountSdmc no longer sets cwd to the folder containing the executable; this logic was moved to a new internal function called on startup by default (and it is now disabled for NSOs). + * Added fsdevMountSaveData/SystemSaveData wrappers. + * Added fsdevIsValidSignedSystemPartitionOnSdCard. + * Enhanced fsOpen_SystemSaveData/fsdevMountSystemSaveData with new parameters. +* romfsdev: + * Reduced TLS footprint by sharing the path buffer with fsdev. + * Cleaned up romfsMount\* functions and removed unused/unnecessary logic. + * Changed romfsMount\* functions to return real result codes. + * Renamed romfsMount to romfsMountSelf. + * Removed romfsInitFromFile and romfsInitFromStorage (use Mount instead). + * Added bounds-checking safety measures. + * Fixed errno to use ENOENT instead of EEXIST where required. + +#### network +* **Added transparent multithreaded socket support.** + * Default maximum number of concurrent socket operations is 3, this can be changed through `SocketInitConfig::num_bsd_sessions`. +* **DNS resolver support was rewritten** and spun off from the socket device wrapper. + * No initialization is required to use resolver functions. + * Removed phantom sfdnsres commands. + * Redesigned sfdnsres IPC wrappers. + * "timeout" was actually the cancel handle. + * Fixed bug in addrinfo deserialization. + * Fixed bug in getaddrinfo when hints is NULL. + * Added commands to configure behavior: resolverGetCancelHandle, resolverGetEnableServiceDiscovery, resolverSetEnableServiceDiscovery, resolverCancel. + * Placeholders for not-yet-implemented 5.0+ config keys: resolverGetEnableDnsCache, resolverSetEnableDnsCache, resolverRemoveHostnameFromCache, resolverRemoveIpAddressFromCache. +* Added service session getters: nifmGetServiceSession_StaticService, nifmGetServiceSession_GeneralService. +* Introduced BsdServiceType enum, which is now used for revised service type handling (bsd:u is now the default service). +* SocketInitConfig was changed: + * Added num_bsd_sessions and bsd_service_type fields. + * Removed fields related to sfdnsres. +* socketInitialize no longer initializes nifm. As a result, gethostid now calls nifmInitialize/nifmExit as needed. +* Renamed socketGetLastBsdResult to socketGetLastResult. +* Renamed socketGetLastSfdnsresResult to resolverGetLastResult. + +#### applet +* Many internal improvements and fixes stemming from new IPC refactoring. +* appletGetOperationMode now returns AppletOperationMode instead of u8. +* appletGetPerformanceMode now returns ApmPerformanceMode instead of u8. +* Added 9.0+ support for using appletSetTerminateResult via IAppletCommonFunctions. +* Added 9.0+ support for using appletGetLaunchStorageInfoForDebug, appletGetGpuErrorDetectedSystemEvent with AppletType_LibraryApplet. +* Added 9.1+ support for using appletSetHandlingHomeButtonShortPressedEnabled with non-AppletType_OverlayApplet. +* Added appletPushToAppletBoundChannel, appletTryPopFromAppletBoundChannel, appletGetSettingsPlatformRegion, appletSetHdcpAuthenticationActivated, appletSetInputDetectionPolicy, appletSetHealthWarningShowingState, appletGetHealthWarningDisappearedSystemEvent, appletIsForceTerminateApplicationDisabledForDebug, appletGetFriendInvitationStorageChannelEvent, appletTryPopFromFriendInvitationStorageChannel, appletGetNotificationStorageChannelEvent, appletTryPopFromNotificationStorageChannel, appletApplicationPushToFriendInvitationStorageChannel, appletApplicationPushToNotificationStorageChannel, appletPushToAppletBoundChannelForDebug, appletTryPopFromAppletBoundChannelForDebug, appletAlarmSettingNotificationEnableAppEventReserve, appletAlarmSettingNotificationDisableAppEventReserve, appletAlarmSettingNotificationPushAppEventNotify, appletFriendInvitationSetApplicationParameter, appletFriendInvitationClearApplicationParameter, appletFriendInvitationPushApplicationParameter. +* Added enum: AppletInputDetectionPolicy. + +#### libapplets +* Added support for the friendsLa libapplet. +* Added support for the psel (player select) libapplet. +* Added support for the hidLa (controller configuration) libapplet. +* Renamed webConfigSetUserID to webConfigSetUid. +* Renamed WebArgType_UserID to WebArgType_Uid. + +#### ns +* Corrected names of nsdevLaunchApplicationForDevelop, nsdevLaunchApplicationWithStorageIdForDevelop, nsdevGetRunningApplicationProcessIdForDevelop, nsdevSetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop. +* Corrected parameters of nsListApplicationRecord, nsListApplicationContentMetaStatus, nsvmGetSafeSystemVersion. +* Added support for ns:su. +* Added enum: NsApplicationControlSource. +* Added service session getters: nsGetServiceSession_GetterInterface, nsGetServiceSession_ApplicationManagerInterface, nsdevGetServiceSession, nssuGetServiceSession. +* Added structs: NsApplicationDeliveryInfo, NsReceiveApplicationProgress, NsSendApplicationProgress, NsSystemDeliveryInfo, NsSystemUpdateProgress. +* Added nsGetSystemDeliveryInfo, nsGetApplicationDeliveryInfo, nsSelectLatestSystemDeliveryInfo, nsVerifyDeliveryProtocolVersion, nsHasAllContentsToDeliver, nsCompareApplicationDeliveryInfo, nsCanDeliverApplication, nsListContentMetaKeyToDeliverApplication, nsNeedsSystemUpdateToDeliverApplication, nsEstimateRequiredSize, nsRequestReceiveApplication, nsCommitReceiveApplication, nsGetReceiveApplicationProgress, nsRequestSendApplication, nsGetSendApplicationProgress, nsCompareSystemDeliveryInfo, nsListNotCommittedContentMeta, nsGetApplicationDeliveryInfoHash. + +#### other services +* account: + * Added AccountServiceType, and changed accountInitialize to accept it. + * Renamed AccountProfileBase::username to nickname. + * Removed output bool from accountGetLastOpenedUser. + * Added AccountNetworkServiceAccountId struct. + * Added accountIsUserRegistrationRequestPermitted, accountTrySelectUserWithoutInteraction. +* apm: + * Added enum: ApmPerformanceMode. + * Added service session getter: apmGetServiceSession_Session. +* async: Added support for the IAsyncValue/IAsyncResult interfaces. +* audin: + * Added missing count param to audinListAudioIns. + * Changed wrapper to use 3.x+ Auto commands if available. + * Added service session getters: audinGetServiceSession, audinGetServiceSession_AudioIn. +* audout: + * Added missing count param to audoutListAudioOuts. + * Changed wrapper to use 3.x+ Auto commands if available. + * Added service session getters: audoutGetServiceSession, audoutGetServiceSession_AudioOut. +* audren: + * Changed wrapper to use 3.x+ Auto commands if available. + * Renamed audrenGetServiceSession to audrenGetServiceSession_AudioRenderer. +* fatal: + * Corrected names of commands and types to match official names more closely. + * **fatalSimple was renamed to fatalThrow**. +* friends: + * Added structs: FriendsInAppScreenName, FriendsFriendInvitationGameModeDescription, FriendsFriendInvitationId, FriendsFriendInvitationGroupId. + * Added friendsGetFriendInvitationNotificationEvent, friendsTryPopFriendInvitationNotificationInfo. +* grc: + * Renamed grcdRead to grcdTransfer. +* hid: + * Added hidIsVibrationDeviceMounted, hidGetNpadJoyHoldType. + * Added internal 5.0+ support for using ActivateNpadWithRevision with the sysver-specific revision value. + * Changed hidInitializeSevenSixAxisSensor to use ActivateConsoleSixAxisSensor earlier on instead of ActivateSevenSixAxisSensor. +* hiddbg: + * Added hiddbgAcquireOperationEventHandle, hiddbgGetOperationResult, hiddbgWriteSerialFlash, hiddbgIsHdlsVirtualDeviceAttached. + * Fixed bug in hiddbgReadSerialFlash. +* hidsys: + * Added hidsysSetNotificationLedPatternWithTimeout. + * Added hidsysAcquireCaptureButtonEventHandle, hidsysAcquireSleepButtonEventHandle to header. + * Corrected bug that affected internal GetMaskedSupportedNpadStyleSet logic. +* loader (ldrShell/ldrDmnt/ldrPm): + * Updated names to match official software. +* ncm: + * Added new ncm_types.h header, which is used by several other services that need NCM types. + * Updated structs: NcmContentMetaKey, NcmContentInfo, NcmContentMetaHeader, NcmApplicationMetaExtendedHeader. + * Renamed NcmNcaId to NcmContentId. + * Added NcmRightsId struct, which is now used by the RightsId funcs. + * Added NcmProgramLocation, which is now used by pmshellLaunchProgram. + * Changed several commands to accept array element count instead of byte size. + * Fixed handling for ncmContentStorageGetPath/ncmContentStorageGetPlaceHolderPath. + * Corrected NcmContentId struct alignment. + * Added NcmPlaceHolderId struct, which is used instead of NcmContentId where needed. + * Renamed FsStorageId to NcmStorageId (and renamed enum value names too). + * Added structs: NcmPackagedContentInfo, NcmContentMetaInfo. +* nfc/nfp: + * Renamed from nfcu/nfpu to nfc/nfp. + * Separated nfc service init/exit into nfcInitialize/nfcExit. + * Renamed nfpuIsNfcEnabled to nfcIsNfcEnabled. + * Renamed NfpuInitConfig to NfcRequiredMcuVersionData, removed it from nfpInitialize input, and changed it to be handled properly as an array. + * Added NfcDeviceHandle struct, which is now used instead of HidControllerID. + * Added NfpServiceType/NfcServiceType, and changed nfpInitialize/nfpInitialize to accept them. + * Added service session getters: nfpuGetServiceSession, nfcuGetServiceSession, nfcuGetServiceSession_Interface, nfpuGetServiceSession_Interface (previously known as nfpuGetInterface). +* nifm: + * Replaced nifmSetServiceType with service type parameter in nifmInitialize. +* notif: Added support. +* nv: + * Added service session getter: nvGetServiceSession. +* pctl: + * Added service session getters: pctlGetServiceSession, pctlGetServiceSession_Service. +* pdm: + * Renamed PdmApplicationEvent to PdmAppletEvent. + * Renamed pdmqryQueryApplicationEvent to pdmqryQueryAppletEvent. +* pdmqry: + * Renamed pdmqryGetUserPlayedApplications to pdmqryQueryRecentlyPlayedApplication. + * Renamed pdmqryGetUserAccountEvent to pdmqryGetRecentlyPlayedApplicationUpdateEvent. +* pm: + * Corrected names of commands to match official software. +* roDmnt: + * Renamed roDmntGetModuleInfos to roDmntGetProcessModuleInfo. +* set: + * Added SetLanguage_ZHHANS, SetLanguage_ZHHANT. + * Added SetRegion_CHN, SetRegion_KOR, SetRegion_TWN. + * Added size_out parameter to setsysGetSettingsItemValue, which was previously missing. + * Replaced SetSysFlag/setsysGetFlag/setsysSetFlag with dedicated funcs for each flag. + * Use SetLanguage instead of s32 in setMakeLanguage(Code). + * Added setsysGetPlatformRegion, setsysSetPlatformRegion, setsysGetHomeMenuScheme, setsysGetHomeMenuSchemeModel, setsysGetMemoryUsageRateFlag, setsysGetTouchScreenMode, setsysSetTouchScreenMode, setsysGetPctlReadyFlag, setsysSetPctlReadyFlag, setsysIsUserSystemClockAutomaticCorrectionEnabled, setsysSetUserSystemClockAutomaticCorrectionEnabled, setsysSetLanguageCode, setsysGetAccountSettings, setsysSetAccountSettings, setsysGetEulaVersions, setsysSetEulaVersions, setsysGetNotificationSettings, setsysSetNotificationSettings, setsysGetAccountNotificationSettings, setsysSetAccountNotificationSettings, setsysGetTvSettings, setsysSetTvSettings, setsysGetDataDeletionSettings, setsysSetDataDeletionSettings, setsysGetWirelessCertificationFileSize, setsysGetWirelessCertificationFile, setsysSetRegionCode, setsysGetPrimaryAlbumStorage, setsysSetPrimaryAlbumStorage, setsysGetBatteryLot, setsysGetSleepSettings, setsysSetSleepSettings, setsysGetInitialLaunchSettings, setsysSetInitialLaunchSettings, setsysGetProductModel, setsysGetMiiAuthorId, setsysGetErrorReportSharePermission, setsysSetErrorReportSharePermission, setsysGetAppletLaunchFlags, setsysSetAppletLaunchFlags, setsysGetKeyboardLayout, setsysSetKeyboardLayout, setsysGetRebootlessSystemUpdateVersion, setsysGetChineseTraditionalInputMethod, setsysSetChineseTraditionalInputMethod. + * Added enums: SetSysPlatformRegion, SetSysHomeMenuScheme, SetSysTouchScreenMode, SetSysUserSelectorFlag, SetSysEulaVersionClockType, SetSysNotificationVolume, SetSysFriendPresenceOverlayPermission, SetSysPrimaryAlbumStorage, SetSysHandheldSleepPlan, SetSysConsoleSleepPlan, SetSysErrorReportSharePermission, SetKeyboardLayout, SetChineseTraditionalInputMethod. + * Added structs: SetBatteryLot, SetSysUserSelectorSettings, SetSysAccountSettings, SetSysEulaVersion, SetSysNotificationTime, SetSysNotificationSettings, SetSysAccountNotificationSettings, SetSysTvSettings, SetSysDataDeletionSettings, SetSysSleepSettings, SetSysInitialLaunchSettings, SetSysRebootlessSystemUpdateVersion. +* time: + * Changed service type handling to use new TimeServiceType enum (and `__nx_time_service_type` weak var), time:u is now the default service. + * Changed timeToPosixTime/timeToPosixTimeWithMyRule to accept array element count instead of byte size. + * Changed timeLoadLocationNameList to accept array element count instead of byte size. + * Added service session getters: timeGetServiceSession_SystemClock, timeGetServiceSession_TimeZoneService. + * Added TimeSteadyClockTimePoint struct (which is now used elsewhere in libnx). +* ts: Added support. +* usbhs: + * 8.0+ support fixed; UsbHsInterfaceInfo input/output endpoints were swapped. + * Fixed bug in usbHsEpClose. +* vi: + * Renamed viGetDisplayMinimumZ to viGetZOrderCountMin. + * Renamed viGetDisplayMaximumZ to viGetZOrderCountMax. + +#### miscellaneous +* Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience. + ## Version 2.5.0 #### system diff --git a/nx/Makefile b/nx/Makefile index f2d1e4fd..834c40c2 100644 --- a/nx/Makefile +++ b/nx/Makefile @@ -8,8 +8,8 @@ endif include $(DEVKITPRO)/devkitA64/base_rules -export LIBNX_MAJOR := 2 -export LIBNX_MINOR := 5 +export LIBNX_MAJOR := 3 +export LIBNX_MINOR := 0 export LIBNX_PATCH := 0 From 2f7d9bf0268102c544d827375189c6b3bebbc2e8 Mon Sep 17 00:00:00 2001 From: fincs Date: Thu, 12 Dec 2019 02:25:05 +0100 Subject: [PATCH 2/2] Delete old IPC :tada: --- nx/include/switch.h | 1 - nx/include/switch/kernel/ipc.h | 786 -------------------------------- nx/include/switch/services/sm.h | 87 ---- 3 files changed, 874 deletions(-) delete mode 100644 nx/include/switch/kernel/ipc.h diff --git a/nx/include/switch.h b/nx/include/switch.h index 578f839b..c4322d7b 100644 --- a/nx/include/switch.h +++ b/nx/include/switch.h @@ -36,7 +36,6 @@ extern "C" { #include "switch/kernel/detect.h" #include "switch/kernel/random.h" #include "switch/kernel/jit.h" -#include "switch/kernel/ipc.h" // Deprecated #include "switch/kernel/barrier.h" #include "switch/sf/hipc.h" diff --git a/nx/include/switch/kernel/ipc.h b/nx/include/switch/kernel/ipc.h deleted file mode 100644 index 114936fa..00000000 --- a/nx/include/switch/kernel/ipc.h +++ /dev/null @@ -1,786 +0,0 @@ -/** - * @file ipc.h - * @brief Inter-process communication handling - * @author plutoo - * @copyright libnx Authors - */ -#pragma once -#include "../result.h" -#include "../arm/tls.h" -#include "../kernel/svc.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -/// IPC input header magic -#define SFCI_MAGIC 0x49434653 -/// IPC output header magic -#define SFCO_MAGIC 0x4f434653 - -/// IPC invalid object ID -#define IPC_INVALID_OBJECT_ID UINT32_MAX - -///@name IPC request building -///@{ - -/// IPC command (request) structure. -#define IPC_MAX_BUFFERS 8 -#define IPC_MAX_OBJECTS 8 - -typedef enum { - BufferType_Normal=0, ///< Regular buffer. - BufferType_Type1=1, ///< Allows ProcessMemory and shared TransferMemory. - BufferType_Invalid=2, - BufferType_Type3=3 ///< Same as Type1 except remote process is not allowed to use device-mapping. -} BufferType DEPRECATED; - -typedef enum { - BufferDirection_Send=0, - BufferDirection_Recv=1, - BufferDirection_Exch=2, -} BufferDirection DEPRECATED; - -typedef enum { - IpcCommandType_Invalid = 0, - IpcCommandType_LegacyRequest = 1, - IpcCommandType_Close = 2, - IpcCommandType_LegacyControl = 3, - IpcCommandType_Request = 4, - IpcCommandType_Control = 5, - IpcCommandType_RequestWithContext = 6, - IpcCommandType_ControlWithContext = 7, -} IpcCommandType DEPRECATED; - -typedef enum { - DomainMessageType_Invalid = 0, - DomainMessageType_SendMessage = 1, - DomainMessageType_Close = 2, -} DomainMessageType DEPRECATED; - -/// IPC domain message header. -typedef struct { - u8 Type; - u8 NumObjectIds; - u16 Length; - u32 ThisObjectId; - u32 Pad[2]; -} DomainMessageHeader DEPRECATED; - -/// IPC domain response header. -typedef struct { - u32 NumObjectIds; - u32 Pad[3]; -} DomainResponseHeader DEPRECATED; - - -typedef struct { - size_t NumSend; // A - size_t NumRecv; // B - size_t NumExch; // W - const void* Buffers[IPC_MAX_BUFFERS]; - size_t BufferSizes[IPC_MAX_BUFFERS]; - BufferType BufferTypes[IPC_MAX_BUFFERS]; - - size_t NumStaticIn; // X - size_t NumStaticOut; // C - const void* Statics[IPC_MAX_BUFFERS]; - size_t StaticSizes[IPC_MAX_BUFFERS]; - u8 StaticIndices[IPC_MAX_BUFFERS]; - - bool SendPid; - size_t NumHandlesCopy; - size_t NumHandlesMove; - Handle Handles[IPC_MAX_OBJECTS]; - - size_t NumObjectIds; - u32 ObjectIds[IPC_MAX_OBJECTS]; -} IpcCommand DEPRECATED; - -/** - * @brief Initializes an IPC command structure. - * @param cmd IPC command structure. - */ -DEPRECATED -static inline void ipcInitialize(IpcCommand* cmd) { - *cmd = (IpcCommand){}; -} - -/// IPC buffer descriptor. -typedef struct { - u32 Size; ///< Size of the buffer. - u32 Addr; ///< Lower 32-bits of the address of the buffer - u32 Packed; ///< Packed data (including higher bits of the address) -} IpcBufferDescriptor DEPRECATED; - -/// IPC static send-buffer descriptor. -typedef struct { - u32 Packed; ///< Packed data (including higher bits of the address) - u32 Addr; ///< Lower 32-bits of the address -} IpcStaticSendDescriptor DEPRECATED; - -/// IPC static receive-buffer descriptor. -typedef struct { - u32 Addr; ///< Lower 32-bits of the address of the buffer - u32 Packed; ///< Packed data (including higher bits of the address) -} IpcStaticRecvDescriptor DEPRECATED; - -/** - * @brief Adds a buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param type Buffer type. - */ -DEPRECATED -static inline void ipcAddSendBuffer(IpcCommand* cmd, const void* buffer, size_t size, BufferType type) { - size_t off = cmd->NumSend; - cmd->Buffers[off] = buffer; - cmd->BufferSizes[off] = size; - cmd->BufferTypes[off] = type; - cmd->NumSend++; -} - -/** - * @brief Adds a receive-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param type Buffer type. - */ -DEPRECATED -static inline void ipcAddRecvBuffer(IpcCommand* cmd, void* buffer, size_t size, BufferType type) { - size_t off = cmd->NumSend + cmd->NumRecv; - cmd->Buffers[off] = buffer; - cmd->BufferSizes[off] = size; - cmd->BufferTypes[off] = type; - cmd->NumRecv++; -} - -/** - * @brief Adds an exchange-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param type Buffer type. - */ -DEPRECATED -static inline void ipcAddExchBuffer(IpcCommand* cmd, void* buffer, size_t size, BufferType type) { - size_t off = cmd->NumSend + cmd->NumRecv + cmd->NumExch; - cmd->Buffers[off] = buffer; - cmd->BufferSizes[off] = size; - cmd->BufferTypes[off] = type; - cmd->NumExch++; -} - -/** - * @brief Adds a static-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -DEPRECATED -static inline void ipcAddSendStatic(IpcCommand* cmd, const void* buffer, size_t size, u8 index) { - size_t off = cmd->NumStaticIn; - cmd->Statics[off] = buffer; - cmd->StaticSizes[off] = size; - cmd->StaticIndices[off] = index; - cmd->NumStaticIn++; -} - -/** - * @brief Adds a static-receive-buffer to an IPC command structure. - * @param cmd IPC command structure. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -DEPRECATED -static inline void ipcAddRecvStatic(IpcCommand* cmd, void* buffer, size_t size, u8 index) { - size_t off = cmd->NumStaticIn + cmd->NumStaticOut; - cmd->Statics[off] = buffer; - cmd->StaticSizes[off] = size; - cmd->StaticIndices[off] = index; - cmd->NumStaticOut++; -} - -/** - * @brief Adds a smart-buffer (buffer + static-buffer pair) to an IPC command structure. - * @param cmd IPC command structure. - * @param pointer_buffer_size Pointer buffer size. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -DEPRECATED -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 { - ipcAddSendBuffer(cmd, buffer, size, BufferType_Normal); - ipcAddSendStatic(cmd, NULL, 0, index); - } -} - -/** - * @brief Adds a smart-receive-buffer (buffer + static-receive-buffer pair) to an IPC command structure. - * @param cmd IPC command structure. - * @param pointer_buffer_size Pointer buffer size. - * @param buffer Address of the buffer. - * @param size Size of the buffer. - * @param index Index of buffer. - */ -DEPRECATED -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 { - ipcAddRecvBuffer(cmd, buffer, size, BufferType_Normal); - ipcAddRecvStatic(cmd, NULL, 0, index); - } -} - -/** - * @brief Tags an IPC command structure to send the PID. - * @param cmd IPC command structure. - */ -DEPRECATED -static inline void ipcSendPid(IpcCommand* cmd) { - cmd->SendPid = true; -} - -/** - * @brief Adds a copy-handle to be sent through an IPC command structure. - * @param cmd IPC command structure. - * @param h Handle to send. - * @remark The receiving process gets a copy of the handle. - */ -DEPRECATED -static inline void ipcSendHandleCopy(IpcCommand* cmd, Handle h) { - cmd->Handles[cmd->NumHandlesCopy++] = h; -} - -/** - * @brief Adds a move-handle to be sent through an IPC command structure. - * @param cmd IPC command structure. - * @param h Handle to send. - * @remark The sending process loses ownership of the handle, which is transferred to the receiving process. - */ -DEPRECATED -static inline void ipcSendHandleMove(IpcCommand* cmd, Handle h) { - cmd->Handles[cmd->NumHandlesCopy + cmd->NumHandlesMove++] = h; -} - -/** - * @brief Prepares the header of an IPC command structure. - * @param cmd IPC command structure. - * @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request - * @return Pointer to the raw embedded data structure in the request, ready to be filled out. - */ -DEPRECATED -static inline void* ipcPrepareHeader(IpcCommand* cmd, size_t sizeof_raw) { - u32* buf = (u32*)armGetTls(); - size_t i; - *buf++ = IpcCommandType_Request | (cmd->NumStaticIn << 16) | (cmd->NumSend << 20) | (cmd->NumRecv << 24) | (cmd->NumExch << 28); - - u32* fill_in_size_later = buf; - - if (cmd->NumStaticOut > 0) { - *buf = (cmd->NumStaticOut + 2) << 10; - } - else { - *buf = 0; - } - - if (cmd->SendPid || cmd->NumHandlesCopy > 0 || cmd->NumHandlesMove > 0) { - *buf++ |= 0x80000000; - *buf++ = (!!cmd->SendPid) | (cmd->NumHandlesCopy << 1) | (cmd->NumHandlesMove << 5); - - if (cmd->SendPid) - buf += 2; - - for (i=0; i<(cmd->NumHandlesCopy + cmd->NumHandlesMove); i++) - *buf++ = cmd->Handles[i]; - } - else { - buf++; - } - - for (i=0; iNumStaticIn; i++, buf+=2) { - IpcStaticSendDescriptor* desc = (IpcStaticSendDescriptor*) buf; - - uintptr_t ptr = (uintptr_t) cmd->Statics[i]; - desc->Addr = ptr; - desc->Packed = cmd->StaticIndices[i] | (cmd->StaticSizes[i] << 16) | - (((ptr >> 32) & 15) << 12) | (((ptr >> 36) & 15) << 6); - } - - for (i=0; i<(cmd->NumSend + cmd->NumRecv + cmd->NumExch); i++, buf+=3) { - IpcBufferDescriptor* desc = (IpcBufferDescriptor*) buf; - desc->Size = cmd->BufferSizes[i]; - - uintptr_t ptr = (uintptr_t) cmd->Buffers[i]; - desc->Addr = ptr; - desc->Packed = cmd->BufferTypes[i] | - (((ptr >> 32) & 15) << 28) | ((ptr >> 36) << 2); - } - - u32 padding = ((16 - (((uintptr_t) buf) & 15)) & 15) / 4; - u32* raw = (u32*) (buf + padding); - - size_t raw_size = (sizeof_raw/4) + 4; - buf += raw_size; - - u16* buf_u16 = (u16*) buf; - - for (i=0; iNumStaticOut; i++) { - size_t off = cmd->NumStaticIn + i; - size_t sz = (uintptr_t) cmd->StaticSizes[off]; - - buf_u16[i] = (sz > 0xFFFF) ? 0 : sz; - } - - size_t u16s_size = ((2*cmd->NumStaticOut) + 3)/4; - buf += u16s_size; - raw_size += u16s_size; - - *fill_in_size_later |= raw_size; - - for (i=0; iNumStaticOut; i++, buf+=2) { - IpcStaticRecvDescriptor* desc = (IpcStaticRecvDescriptor*) buf; - size_t off = cmd->NumStaticIn + i; - - uintptr_t ptr = (uintptr_t) cmd->Statics[off]; - desc->Addr = ptr; - desc->Packed = (ptr >> 32) | (cmd->StaticSizes[off] << 16); - } - - return (void*) raw; -} - -/** - * @brief Dispatches an IPC request. - * @param session IPC session handle. - * @return Result code. - */ -DEPRECATED -static inline Result ipcDispatch(Handle session) { - return svcSendSyncRequest(session); -} - -///@} - -///@name IPC response parsing -///@{ - -/// IPC parsed command (response) structure. -typedef struct { - IpcCommandType CommandType; ///< Type of the command - - bool HasPid; ///< true if the 'Pid' field is filled out. - u64 Pid; ///< PID included in the response (only if HasPid is true) - - size_t NumHandles; ///< Number of handles copied. - Handle Handles[IPC_MAX_OBJECTS]; ///< Handles. - bool WasHandleCopied[IPC_MAX_OBJECTS]; ///< true if the handle was moved, false if it was copied. - - bool IsDomainRequest; ///< true if the the message is a Domain message. - DomainMessageType InMessageType; ///< Type of the domain message. - u32 InMessageLength; ///< Size of rawdata (for domain messages). - u32 InThisObjectId; ///< Object ID to call the command on (for domain messages). - size_t InNumObjectIds; ///< Number of object IDs (for domain messages). - u32 InObjectIds[IPC_MAX_OBJECTS]; ///< Object IDs (for domain messages). - - bool IsDomainResponse; ///< true if the the message is a Domain response. - size_t OutNumObjectIds; ///< Number of object IDs (for domain responses). - u32 OutObjectIds[IPC_MAX_OBJECTS]; ///< Object IDs (for domain responses). - - size_t NumBuffers; ///< Number of buffers in the response. - void* Buffers[IPC_MAX_BUFFERS]; ///< Pointers to the buffers. - size_t BufferSizes[IPC_MAX_BUFFERS]; ///< Sizes of the buffers. - BufferType BufferTypes[IPC_MAX_BUFFERS]; ///< Types of the buffers. - BufferDirection BufferDirections[IPC_MAX_BUFFERS]; ///< Direction of each buffer. - - size_t NumStatics; ///< Number of statics in the response. - void* Statics[IPC_MAX_BUFFERS]; ///< Pointers to the statics. - size_t StaticSizes[IPC_MAX_BUFFERS]; ///< Sizes of the statics. - u8 StaticIndices[IPC_MAX_BUFFERS]; ///< Indices of the statics. - - size_t NumStaticsOut; ///< Number of output statics available in the response. - - void* Raw; ///< Pointer to the raw embedded data structure in the response. - void* RawWithoutPadding; ///< Pointer to the raw embedded data structure, without padding. - size_t RawSize; ///< Size of the raw embedded data. -} IpcParsedCommand DEPRECATED; - -/** - * @brief Parse an IPC command response into an IPC parsed command structure. - * @param r IPC parsed command structure to fill in. - * @return Result code. - */ -DEPRECATED -static inline Result ipcParse(IpcParsedCommand* r) { - u32* buf = (u32*)armGetTls(); - u32 ctrl0 = *buf++; - u32 ctrl1 = *buf++; - size_t i; - - r->IsDomainRequest = false; - r->IsDomainResponse = false; - - r->CommandType = (IpcCommandType) (ctrl0 & 0xffff); - r->HasPid = false; - r->RawSize = (ctrl1 & 0x1ff) * 4; - r->NumHandles = 0; - - r->NumStaticsOut = (ctrl1 >> 10) & 15; - if (r->NumStaticsOut >> 1) r->NumStaticsOut--; // Value 2 -> Single descriptor - if (r->NumStaticsOut >> 1) r->NumStaticsOut--; // Value 3+ -> (Value - 2) descriptors - - if (ctrl1 & 0x80000000) { - u32 ctrl2 = *buf++; - - if (ctrl2 & 1) { - r->HasPid = true; - r->Pid = *buf++; - r->Pid |= ((u64)(*buf++)) << 32; - } - - size_t num_handles_copy = ((ctrl2 >> 1) & 15); - size_t num_handles_move = ((ctrl2 >> 5) & 15); - - size_t num_handles = num_handles_copy + num_handles_move; - u32* buf_after_handles = buf + num_handles; - - if (num_handles > IPC_MAX_OBJECTS) - num_handles = IPC_MAX_OBJECTS; - - for (i=0; iHandles[i] = *(buf+i); - r->WasHandleCopied[i] = (i < num_handles_copy); - } - - r->NumHandles = num_handles; - buf = buf_after_handles; - } - - size_t num_statics = (ctrl0 >> 16) & 15; - u32* buf_after_statics = buf + num_statics*2; - - if (num_statics > IPC_MAX_BUFFERS) - num_statics = IPC_MAX_BUFFERS; - - for (i=0; iPacked; - - r->Statics[i] = (void*) (desc->Addr | (((packed >> 12) & 15) << 32) | (((packed >> 6) & 15) << 36)); - r->StaticSizes[i] = packed >> 16; - r->StaticIndices[i] = packed & 63; - } - - r->NumStatics = num_statics; - buf = buf_after_statics; - - size_t num_bufs_send = (ctrl0 >> 20) & 15; - size_t num_bufs_recv = (ctrl0 >> 24) & 15; - size_t num_bufs_exch = (ctrl0 >> 28) & 15; - - size_t num_bufs = num_bufs_send + num_bufs_recv + num_bufs_exch; - r->Raw = (void*)(((uintptr_t)(buf + num_bufs*3) + 15) &~ 15); - r->RawWithoutPadding = (void*)((uintptr_t)(buf + num_bufs*3)); - - if (num_bufs > IPC_MAX_BUFFERS) - num_bufs = IPC_MAX_BUFFERS; - - for (i=0; iPacked; - - r->Buffers[i] = (void*) (desc->Addr | ((packed >> 28) << 32) | (((packed >> 2) & 15) << 36)); - r->BufferSizes[i] = desc->Size; - r->BufferTypes[i] = (BufferType) (packed & 3); - - if (i < num_bufs_send) - r->BufferDirections[i] = BufferDirection_Send; - else if (i < (num_bufs_send + num_bufs_recv)) - r->BufferDirections[i] = BufferDirection_Recv; - else - r->BufferDirections[i] = BufferDirection_Exch; - } - - r->NumBuffers = num_bufs; - return 0; -} - -/** - * @brief Queries the size of an IPC pointer buffer. - * @param session IPC session handle. - * @param size Output variable in which to store the size. - * @return Result code. - */ -DEPRECATED -static inline Result ipcQueryPointerBufferSize(Handle session, size_t *size) { - u32* buf = (u32*)armGetTls(); - - buf[0] = IpcCommandType_Control; - buf[1] = 8; - buf[2] = 0; - buf[3] = 0; - buf[4] = SFCI_MAGIC; - buf[5] = 0; - buf[6] = 3; - buf[7] = 0; - - Result rc = ipcDispatch(session); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct ipcQueryPointerBufferSizeResponse { - u64 magic; - u64 result; - u32 size; - } *raw = (struct ipcQueryPointerBufferSizeResponse*)r.Raw; - - rc = raw->result; - - if (R_SUCCEEDED(rc)) { - *size = raw->size & 0xffff; - } - } - - return rc; -} - -/** - * @brief Closes the IPC session with proper clean up. - * @param session IPC session handle. - * @return Result code. - */ -DEPRECATED -static inline Result ipcCloseSession(Handle session) { - u32* buf = (u32*)armGetTls(); - buf[0] = IpcCommandType_Close; - buf[1] = 0; - return ipcDispatch(session); -} - -/** - * @brief Clones an IPC session. - * @param session IPC session handle. - * @param unk Unknown. - * @param new_session_out Output cloned IPC session handle. - * @return Result code. - */ -DEPRECATED -static inline Result ipcCloneSession(Handle session, u32 unk, Handle* new_session_out) { - u32* buf = (u32*)armGetTls(); - - buf[0] = IpcCommandType_Control; - buf[1] = 9; - buf[2] = 0; - buf[3] = 0; - buf[4] = SFCI_MAGIC; - buf[5] = 0; - buf[6] = 4; - buf[7] = 0; - buf[8] = unk; - - Result rc = ipcDispatch(session); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct ipcCloneSessionResponse { - u64 magic; - u64 result; - } *raw = (struct ipcCloneSessionResponse*)r.Raw; - - rc = raw->result; - - if (R_SUCCEEDED(rc) && new_session_out) { - *new_session_out = r.Handles[0]; - } - } - - return rc; -} - -///@} - -///@name IPC domain handling -///@{ - -/** - * @brief Converts an IPC session handle into a domain. - * @param session IPC session handle. - * @param object_id_out Output variable in which to store the object ID. - * @return Result code. - */ -DEPRECATED -static inline Result ipcConvertSessionToDomain(Handle session, u32* object_id_out) { - u32* buf = (u32*)armGetTls(); - - buf[0] = IpcCommandType_Control; - buf[1] = 8; - buf[4] = SFCI_MAGIC; - buf[5] = 0; - buf[6] = 0; - buf[7] = 0; - - Result rc = ipcDispatch(session); - - if (R_SUCCEEDED(rc)) { - IpcParsedCommand r; - ipcParse(&r); - - struct ipcConvertSessionToDomainResponse { - u64 magic; - u64 result; - u32 object_id; - } *raw = (struct ipcConvertSessionToDomainResponse*)r.Raw; - - rc = raw->result; - - if (R_SUCCEEDED(rc)) { - *object_id_out = raw->object_id; - } - } - - return rc; -} - -/** - * @brief Adds an object ID to be sent through an IPC domain command structure. - * @param cmd IPC domain command structure. - * @param object_id Object ID to send. - */ -DEPRECATED -static inline void ipcSendObjectId(IpcCommand* cmd, u32 object_id) { - cmd->ObjectIds[cmd->NumObjectIds++] = object_id; -} - -/** - * @brief Prepares the header of an IPC command structure (domain version). - * @param cmd IPC command structure. - * @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request - * @param object_id Domain object ID. - * @return Pointer to the raw embedded data structure in the request, ready to be filled out. - */ -DEPRECATED -static inline void* ipcPrepareHeaderForDomain(IpcCommand* cmd, size_t sizeof_raw, u32 object_id) { - void* raw = ipcPrepareHeader(cmd, sizeof_raw + sizeof(DomainMessageHeader) + cmd->NumObjectIds*sizeof(u32)); - DomainMessageHeader* hdr = (DomainMessageHeader*) raw; - u32 *object_ids = (u32*)(((uintptr_t) raw) + sizeof(DomainMessageHeader) + sizeof_raw); - - hdr->Type = DomainMessageType_SendMessage; - hdr->NumObjectIds = (u8)cmd->NumObjectIds; - hdr->Length = sizeof_raw; - hdr->ThisObjectId = object_id; - hdr->Pad[0] = hdr->Pad[1] = 0; - - for(size_t i = 0; i < cmd->NumObjectIds; i++) - object_ids[i] = cmd->ObjectIds[i]; - return (void*)(((uintptr_t) raw) + sizeof(DomainMessageHeader)); -} - -/** - * @brief Parse an IPC command request into an IPC parsed command structure (domain version). - * @param r IPC parsed command structure to fill in. - * @return Result code. - */ -DEPRECATED -static inline Result ipcParseDomainRequest(IpcParsedCommand* r) { - Result rc = ipcParse(r); - DomainMessageHeader *hdr; - u32 *object_ids; - if(R_FAILED(rc)) - return rc; - - hdr = (DomainMessageHeader*) r->Raw; - object_ids = (u32*)(((uintptr_t) hdr) + sizeof(DomainMessageHeader) + hdr->Length); - r->Raw = (void*)(((uintptr_t) r->Raw) + sizeof(DomainMessageHeader)); - - r->IsDomainRequest = true; - r->InMessageType = (DomainMessageType)(hdr->Type); - switch (r->InMessageType) { - case DomainMessageType_SendMessage: - case DomainMessageType_Close: - break; - default: - return MAKERESULT(Module_Libnx, LibnxError_DomainMessageUnknownType); - } - - r->InThisObjectId = hdr->ThisObjectId; - r->InNumObjectIds = hdr->NumObjectIds > 8 ? 8 : hdr->NumObjectIds; - if ((uintptr_t)object_ids + sizeof(u32) * r->InNumObjectIds - (uintptr_t)armGetTls() >= 0x100) { - return MAKERESULT(Module_Libnx, LibnxError_DomainMessageTooManyObjectIds); - } - for(size_t i = 0; i < r->InNumObjectIds; i++) - r->InObjectIds[i] = object_ids[i]; - - return rc; -} - -/** - * @brief Parse an IPC command response into an IPC parsed command structure (domain version). - * @param r IPC parsed command structure to fill in. - * @param sizeof_raw Size in bytes of the raw data structure. - * @return Result code. - */ -DEPRECATED -static inline Result ipcParseDomainResponse(IpcParsedCommand* r, size_t sizeof_raw) { - Result rc = ipcParse(r); - DomainResponseHeader *hdr; - u32 *object_ids; - if(R_FAILED(rc)) - return rc; - - hdr = (DomainResponseHeader*) r->Raw; - r->Raw = (void*)(((uintptr_t) r->Raw) + sizeof(DomainResponseHeader)); - object_ids = (u32*)(((uintptr_t) r->Raw) + sizeof_raw);//Official sw doesn't align this. - - r->IsDomainResponse = true; - - r->OutNumObjectIds = hdr->NumObjectIds > 8 ? 8 : hdr->NumObjectIds; - if ((uintptr_t)object_ids + sizeof(u32) * r->OutNumObjectIds - (uintptr_t)armGetTls() >= 0x100) { - return MAKERESULT(Module_Libnx, LibnxError_DomainMessageTooManyObjectIds); - } - for(size_t i = 0; i < r->OutNumObjectIds; i++) - r->OutObjectIds[i] = object_ids[i]; - - return rc; -} - -/** - * @brief Closes a domain object by ID. - * @param session IPC session handle. - * @param object_id ID of the object to close. - * @return Result code. - */ -DEPRECATED -static inline Result ipcCloseObjectById(Handle session, u32 object_id) { - IpcCommand c; - DomainMessageHeader* hdr; - - ipcInitialize(&c); - hdr = (DomainMessageHeader*)ipcPrepareHeader(&c, sizeof(DomainMessageHeader)); - - hdr->Type = DomainMessageType_Close; - hdr->NumObjectIds = 0; - hdr->Length = 0; - hdr->ThisObjectId = object_id; - hdr->Pad[0] = hdr->Pad[1] = 0; - - return ipcDispatch(session); // this command has no associated response -} - -///@} - -#pragma GCC diagnostic pop diff --git a/nx/include/switch/services/sm.h b/nx/include/switch/services/sm.h index 52e01f0e..1b8f5721 100644 --- a/nx/include/switch/services/sm.h +++ b/nx/include/switch/services/sm.h @@ -8,95 +8,8 @@ #pragma once #include "../types.h" #include "../kernel/svc.h" -#include "../kernel/ipc.h" #include "../sf/service.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -/** - * @brief Closes a domain object by ID. - * @param[in] s Service object, necessarily a domain or domain subservice. - * @param object_id ID of the object to close. - * @return Result code. - */ -DEPRECATED -static inline Result serviceCloseObjectById(Service* s, u32 object_id) { - return ipcCloseObjectById(s->session, object_id); -} - -/** - * @brief Dispatches an IPC request to a service. - * @param[in] s Service object. - * @return Result code. - */ -DEPRECATED -static inline Result serviceIpcDispatch(Service* s) { - return ipcDispatch(s->session); -} - -/** - * @brief Creates a subservice object from a parent service. - * @param[out] s Service object. - * @param[in] parent Parent service, possibly a domain or domain subservice. - * @param[in] r Parsed IPC command containing handles/object IDs to create subservice from. - * @param[in] i The index of the handle/object ID to create subservice from. - */ -DEPRECATED -static inline void serviceCreateSubservice(Service* s, Service* parent, IpcParsedCommand* r, int i) { - if (r->IsDomainResponse) { - return serviceCreateDomainSubservice(s, parent, r->OutObjectIds[i]); - } else { - return serviceCreate(s, r->Handles[i]); - } -} - -/** - * @brief Sends a service object with the specified cmd. This only supports domains. - * @param[in] s Service object to send. - * @param[in] cmd IPC command structure. - */ -DEPRECATED -static inline void serviceSendObject(Service* s, IpcCommand* cmd) { - if (serviceIsDomain(s) || serviceIsDomainSubservice(s)) { - ipcSendObjectId(cmd, s->object_id); - } -} - -/** - * @brief Prepares the header of an IPC command structure for a service. - * @param s Service to prepare message header for - * @param cmd IPC command structure. - * @param sizeof_raw Size in bytes of the raw data structure to embed inside the IPC request - * @return Pointer to the raw embedded data structure in the request, ready to be filled out. - */ -DEPRECATED -static inline void* serviceIpcPrepareHeader(Service* s, IpcCommand* cmd, size_t sizeof_raw) { - if (serviceIsDomain(s) || serviceIsDomainSubservice(s)) { - return ipcPrepareHeaderForDomain(cmd, sizeof_raw, serviceGetObjectId(s)); - } else { - return ipcPrepareHeader(cmd, sizeof_raw); - } -} - -/** - * @brief Parse an IPC command response into an IPC parsed command structure for a service. - * @param s Service to prepare message header for - * @param r IPC parsed command structure to fill in. - * @param sizeof_raw Size in bytes of the raw data structure. - * @return Result code. - */ -DEPRECATED -static inline Result serviceIpcParse(Service* s, IpcParsedCommand* r, size_t sizeof_raw) { - if (serviceIsDomain(s) || serviceIsDomainSubservice(s)) { - return ipcParseDomainResponse(r, sizeof_raw); - } else { - return ipcParse(r); - } -} - -#pragma GCC diagnostic pop - /// Structure representing a service name (null terminated, remaining characters set to zero). typedef struct SmServiceName { char name[8];