ldn: Allow using an user-specified priority.

This commit is contained in:
yellows8 2025-08-01 12:41:13 -04:00
parent 9e26b562d7
commit eb780c49ac
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 7 additions and 2 deletions

View File

@ -10,6 +10,9 @@
#include "../sf/service.h"
#include "../kernel/event.h"
#define LDN_PRIORITY_SYSTEM 0x38 ///< System priority for __nx_ldn_priority.
#define LDN_PRIORITY_USER 0x5A ///< User priority for __nx_ldn_priority.
typedef enum {
LdnServiceType_User = 0, ///< Initializes ldn:u.
LdnServiceType_System = 1, ///< Initializes ldn:s.
@ -276,6 +279,7 @@ Result ldnmGetNetworkConfig(LdnNetworkConfig *out);
///@{
/// Initialize ldn.
/// The priority is only used with ::LdnServiceType_System on [19.0.0+]. To optionally set this, define "s32 __nx_ldn_priority". The priority must be \ref LDN_PRIORITY_SYSTEM (default) or \ref LDN_PRIORITY_USER.
Result ldnInitialize(LdnServiceType service_type);
/// Exit ldn.

View File

@ -6,6 +6,8 @@
static LdnServiceType g_ldnServiceType;
__attribute__((weak)) s32 __nx_ldn_priority = LDN_PRIORITY_SYSTEM;
static Service g_ldnSrv;
static Service g_ldnmSrv;
@ -84,7 +86,6 @@ Result _ldnInitialize(LdnServiceType service_type) {
Service srv_creator={0};
Result rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
s32 version=0;
s32 priority=0x38;
g_ldnServiceType = service_type;
switch (g_ldnServiceType) {
case LdnServiceType_User:
@ -109,7 +110,7 @@ Result _ldnInitialize(LdnServiceType service_type) {
version = 0x4;
if (g_ldnServiceType == LdnServiceType_System && hosversionAtLeast(19,0,0))
rc = _ldnCmdInitializeWithPriority(version, priority);
rc = _ldnCmdInitializeWithPriority(version, __nx_ldn_priority);
else
rc = _ldnCmdInitializeWithVersion(version);
}