mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-05 10:52:15 +02:00
Added initial implementation of es services
This commit is contained in:
parent
6b91ac26a5
commit
06e9eaa29f
@ -81,6 +81,8 @@ extern "C" {
|
||||
#include "switch/services/spl.h"
|
||||
#include "switch/services/ncm.h"
|
||||
#include "switch/services/psc.h"
|
||||
#include "switch/services/es.h"
|
||||
|
||||
|
||||
#include "switch/display/binder.h"
|
||||
#include "switch/display/parcel.h"
|
||||
|
18
nx/include/switch/services/es.h
Normal file
18
nx/include/switch/services/es.h
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file es.h
|
||||
* @brief ETicket service IPC wrapper.
|
||||
* @author simontime
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../kernel/ipc.h"
|
||||
|
||||
#include "../services/sm.h"
|
||||
|
||||
Result esInitialize(void);
|
||||
void esExit(void);
|
||||
|
||||
Result esCountCommmonTicket(u32* out);
|
||||
Result esCountPersonalizedTicket(u32* out);
|
92
nx/source/services/es.c
Normal file
92
nx/source/services/es.c
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
* @file es.c
|
||||
* @brief ETicket service IPC wrapper.
|
||||
* @author simontime
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
|
||||
#include "services/es.h"
|
||||
#include "arm/atomics.h"
|
||||
|
||||
static Service g_esSrv;
|
||||
static u64 g_RefCnt;
|
||||
|
||||
Result esInitialize(void) {
|
||||
atomicIncrement64(&g_RefCnt);
|
||||
|
||||
if (serviceIsActive(&g_esSrv))
|
||||
return 0;
|
||||
|
||||
return smGetService(&g_esSrv, "es");
|
||||
}
|
||||
|
||||
void esExit(void) {
|
||||
if (atomicDecrement64(&g_RefCnt) == 0)
|
||||
serviceClose(&g_esSrv);
|
||||
}
|
||||
|
||||
Result esCountCommmonTicket(u32* out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof *raw);
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 9;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_esSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 out;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
*out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result esCountPersonalizedTicket(u32* out) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof *raw);
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 10;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_esSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 out;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
*out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
Loading…
Reference in New Issue
Block a user