mirror of
https://github.com/switchbrew/libnx.git
synced 2025-08-05 16:09:24 +02:00
Updated ts for new IPC.
This commit is contained in:
parent
08272ed12e
commit
2e56959916
@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "../services/sm.h"
|
|
||||||
|
|
||||||
/// Location
|
/// Location
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -1,31 +1,19 @@
|
|||||||
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "types.h"
|
#include "service_guard.h"
|
||||||
#include "result.h"
|
|
||||||
#include "arm/atomics.h"
|
|
||||||
#include "kernel/ipc.h"
|
|
||||||
#include "runtime/hosversion.h"
|
#include "runtime/hosversion.h"
|
||||||
#include "services/sm.h"
|
|
||||||
#include "services/ts.h"
|
#include "services/ts.h"
|
||||||
|
|
||||||
static Service g_tsSrv;
|
static Service g_tsSrv;
|
||||||
static u64 g_tsRefCnt;
|
|
||||||
|
|
||||||
Result tsInitialize(void) {
|
NX_GENERATE_SERVICE_GUARD(ts);
|
||||||
Result rc=0;
|
|
||||||
|
|
||||||
atomicIncrement64(&g_tsRefCnt);
|
Result _tsInitialize(void) {
|
||||||
|
return smGetService(&g_tsSrv, "ts");
|
||||||
if (serviceIsActive(&g_tsSrv))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
rc = smGetService(&g_tsSrv, "ts");
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsExit(void) {
|
void _tsCleanup(void) {
|
||||||
if (atomicDecrement64(&g_tsRefCnt) == 0)
|
serviceClose(&g_tsSrv);
|
||||||
serviceClose(&g_tsSrv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Service* tsGetServiceSession(void) {
|
Service* tsGetServiceSession(void) {
|
||||||
@ -33,78 +21,20 @@ Service* tsGetServiceSession(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Result _tsCmdInU8Out32(u8 inval, u32 *out, u64 cmd_id) {
|
static Result _tsCmdInU8Out32(u8 inval, u32 *out, u64 cmd_id) {
|
||||||
IpcCommand c;
|
return serviceDispatchInOut(&g_tsSrv, cmd_id, inval, *out);
|
||||||
ipcInitialize(&c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
u8 inval;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = serviceIpcPrepareHeader(&g_tsSrv, &c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = cmd_id;
|
|
||||||
raw->inval = inval;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_tsSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
u32 out;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_tsSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc) && out) *out = resp->out;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result tsGetTemperatureRange(TsLocation location, s32 *min_temperature, s32 *max_temperature) {
|
Result tsGetTemperatureRange(TsLocation location, s32 *min_temperature, s32 *max_temperature) {
|
||||||
IpcCommand c;
|
u8 tmp_location = location;
|
||||||
ipcInitialize(&c);
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u64 magic;
|
s32 min_temperature;
|
||||||
u64 cmd_id;
|
s32 max_temperature;
|
||||||
u8 location;
|
} out;
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = serviceIpcPrepareHeader(&g_tsSrv, &c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 0;
|
|
||||||
raw->location = location;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_tsSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
s32 min_temperature;
|
|
||||||
s32 max_temperature;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_tsSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc) && min_temperature) *min_temperature = resp->min_temperature;
|
|
||||||
if (R_SUCCEEDED(rc) && max_temperature) *max_temperature = resp->max_temperature;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Result rc = serviceDispatchInOut(&g_tsSrv, 0, tmp_location, out);
|
||||||
|
if (R_SUCCEEDED(rc) && min_temperature) *min_temperature = out.min_temperature;
|
||||||
|
if (R_SUCCEEDED(rc) && max_temperature) *max_temperature = out.max_temperature;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user