mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
spsm: update for new-ipc
This commit is contained in:
parent
48905d70d2
commit
16fde00323
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "../services/sm.h"
|
#include "../sf/service.h"
|
||||||
|
|
||||||
Result spsmInitialize(void);
|
Result spsmInitialize(void);
|
||||||
void spsmExit(void);
|
void spsmExit(void);
|
||||||
|
@ -1,32 +1,17 @@
|
|||||||
#include "types.h"
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
#include "result.h"
|
#include "service_guard.h"
|
||||||
#include "arm/atomics.h"
|
|
||||||
#include "kernel/ipc.h"
|
|
||||||
#include "services/spsm.h"
|
#include "services/spsm.h"
|
||||||
#include "services/sm.h"
|
|
||||||
|
|
||||||
static Service g_spsmSrv;
|
static Service g_spsmSrv;
|
||||||
static u64 g_refCnt;
|
|
||||||
|
|
||||||
Result spsmInitialize(void) {
|
NX_GENERATE_SERVICE_GUARD(spsm);
|
||||||
Result rc = 0;
|
|
||||||
|
|
||||||
atomicIncrement64(&g_refCnt);
|
|
||||||
|
|
||||||
if (serviceIsActive(&g_spsmSrv))
|
Result _spsmInitialize(void) {
|
||||||
return 0;
|
return smGetService(&g_spsmSrv, "spsm");
|
||||||
|
|
||||||
rc = smGetService(&g_spsmSrv, "spsm");
|
|
||||||
|
|
||||||
if (R_FAILED(rc)) spsmExit();
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void spsmExit(void) {
|
void _spsmCleanup(void) {
|
||||||
if (atomicDecrement64(&g_refCnt) == 0) {
|
serviceClose(&g_spsmSrv);
|
||||||
serviceClose(&g_spsmSrv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Service* spsmGetServiceSession(void) {
|
Service* spsmGetServiceSession(void) {
|
||||||
@ -34,67 +19,10 @@ Service* spsmGetServiceSession(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result spsmShutdown(bool reboot) {
|
Result spsmShutdown(bool reboot) {
|
||||||
IpcCommand c;
|
const u8 in = reboot != 0;
|
||||||
ipcInitialize(&c);
|
return serviceDispatchIn(&g_spsmSrv, 3, in);
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
u32 reboot;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = serviceIpcPrepareHeader(&g_spsmSrv, &c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 3;
|
|
||||||
raw->reboot = reboot;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_spsmSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_spsmSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result spsmPutErrorState(void) {
|
Result spsmPutErrorState(void) {
|
||||||
IpcCommand c;
|
return serviceDispatch(&g_spsmSrv, 10);
|
||||||
ipcInitialize(&c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = serviceIpcPrepareHeader(&g_spsmSrv, &c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 10;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_spsmSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
} *resp;
|
|
||||||
|
|
||||||
serviceIpcParse(&g_spsmSrv, &r, sizeof(*resp));
|
|
||||||
resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user