1
0
mirror of https://github.com/switchbrew/libnx.git synced 2025-07-14 23:12:15 +02:00
libnx/nx/source/kernel/detect.c
TuxSH 5abc4873d8 Include only what is really necessary...
add pragma once in every header, etc.
2018-01-22 18:42:57 +01:00

44 lines
960 B
C

// Copyright 2017 plutoo
#include <switch/types.h>
#include <switch/kernel/detect.h>
#include <switch/kernel/svc.h>
static bool g_IsAbove200;
static bool g_IsAbove300;
static bool g_IsAbove400;
static bool g_HasCached = 0;
static void _CacheValues(void)
{
// This is actually thread safe, might cache twice but that's fine.
if (!g_HasCached)
{
u64 tmp;
g_IsAbove200 = (svcGetInfo(&tmp, 12, INVALID_HANDLE, 0) != 0xF001);
g_IsAbove300 = (svcGetInfo(&tmp, 18, INVALID_HANDLE, 0) != 0xF001);
g_IsAbove400 = (svcGetInfo(&tmp, 19, INVALID_HANDLE, 0) != 0xF001);
g_HasCached = true;
}
}
bool kernelAbove200(void) {
_CacheValues();
return g_IsAbove200;
}
bool kernelAbove300(void) {
_CacheValues();
return g_IsAbove300;
}
bool kernelAbove400(void) {
_CacheValues();
return g_IsAbove400;
}
bool detectDebugger(void) {
u64 tmp;
svcGetInfo(&tmp, 8, 0, 0);
return !!tmp;
}