pl: Add 16.0.0 sysver checks, etc.

This commit is contained in:
yellows8 2023-03-07 18:35:32 -05:00
parent ee873e34d0
commit 4ece4e5b8f
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 24 additions and 4 deletions

View File

@ -10,7 +10,7 @@
typedef enum {
PlServiceType_User = 0, ///< Initializes pl:u.
PlServiceType_System = 1, ///< Initializes pl:s.
PlServiceType_System = 1, ///< Initializes pl:s. With [16.0.0+] SharedFont is no longer available with this, pl:u must be used for that.
} PlServiceType;
/// SharedFontType

View File

@ -2,6 +2,7 @@
#include "service_guard.h"
#include <string.h>
#include "kernel/shmem.h"
#include "runtime/hosversion.h"
#include "services/pl.h"
#define SHAREDMEMFONT_SIZE 0x1100000
@ -28,11 +29,11 @@ Result _plInitialize(PlServiceType service_type) {
break;
}
if (R_SUCCEEDED(rc)) {
if (R_SUCCEEDED(rc) && !(hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)) {
rc = _plGetSharedMemoryNativeHandle(&sharedmem_handle);
if (R_SUCCEEDED(rc)) {
shmemLoadRemote(&g_plSharedmem, sharedmem_handle, 0x1100000, Perm_R);
shmemLoadRemote(&g_plSharedmem, sharedmem_handle, SHAREDMEMFONT_SIZE, Perm_R);
rc = shmemMap(&g_plSharedmem);
}
@ -43,6 +44,7 @@ Result _plInitialize(PlServiceType service_type) {
void _plCleanup(void) {
serviceClose(&g_plSrv);
if (!(hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System))
shmemClose(&g_plSharedmem);
}
@ -70,22 +72,37 @@ static Result _plCmdInU32OutU32(Service* srv, u32 inval, u32 *out, u32 cmd_id) {
}
static Result _plRequestLoad(u32 SharedFontType) {
if (hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _plCmdInU32NoOut(&g_plSrv, SharedFontType, 0);
}
static Result _plGetLoadState(u32 SharedFontType, u32* LoadState) {
if (hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _plCmdInU32OutU32(&g_plSrv, SharedFontType, LoadState, 1);
}
static Result _plGetSize(u32 SharedFontType, u32* size) {
if (hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _plCmdInU32OutU32(&g_plSrv, SharedFontType, size, 2);
}
static Result _plGetSharedMemoryAddressOffset(u32 SharedFontType, u32* offset) {
if (hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _plCmdInU32OutU32(&g_plSrv, SharedFontType, offset, 3);
}
static Result _plGetSharedMemoryNativeHandle(Handle* handle_out) {
if (hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _plCmdGetHandle(&g_plSrv, handle_out, 4);
}
@ -142,6 +159,9 @@ Result plGetSharedFontByType(PlFontData* font, PlSharedFontType SharedFontType)
}
Result plGetSharedFont(u64 LanguageCode, PlFontData* fonts, s32 max_fonts, s32* total_fonts) {
if (hosversionAtLeast(16,0,0) && g_plServiceType == PlServiceType_System)
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc=0;
u32 types[PlSharedFontType_Total]={0};
u32 offsets[PlSharedFontType_Total]={0};