mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
csrng: Updated for new-ipc. Removed copyright comment-header in the .c (other .c don't have it and the .h has one anyway).
This commit is contained in:
parent
e320f3cdf1
commit
ed2d72b9ff
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "../services/sm.h"
|
#include "../sf/service.h"
|
||||||
|
|
||||||
Result csrngInitialize(void);
|
Result csrngInitialize(void);
|
||||||
void csrngExit(void);
|
void csrngExit(void);
|
||||||
|
@ -1,27 +1,16 @@
|
|||||||
// Copyright 2018 SciresM
|
#define NX_SERVICE_ASSUME_NON_DOMAIN
|
||||||
#include <string.h>
|
#include "service_guard.h"
|
||||||
#include "types.h"
|
|
||||||
#include "result.h"
|
|
||||||
#include "arm/atomics.h"
|
|
||||||
#include "kernel/ipc.h"
|
|
||||||
#include "services/csrng.h"
|
#include "services/csrng.h"
|
||||||
#include "services/sm.h"
|
|
||||||
#include "services/spl.h"
|
|
||||||
|
|
||||||
static Service g_csrngSrv;
|
static Service g_csrngSrv;
|
||||||
static u64 g_csrngRefCnt;
|
|
||||||
|
|
||||||
Result csrngInitialize(void) {
|
NX_GENERATE_SERVICE_GUARD(csrng);
|
||||||
atomicIncrement64(&g_csrngRefCnt);
|
|
||||||
|
|
||||||
if (serviceIsActive(&g_csrngSrv))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
Result _csrngInitialize(void) {
|
||||||
return smGetService(&g_csrngSrv, "csrng");
|
return smGetService(&g_csrngSrv, "csrng");
|
||||||
}
|
}
|
||||||
|
|
||||||
void csrngExit(void) {
|
void _csrngCleanup(void) {
|
||||||
if (atomicDecrement64(&g_csrngRefCnt) == 0)
|
|
||||||
serviceClose(&g_csrngSrv);
|
serviceClose(&g_csrngSrv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,34 +19,8 @@ Service* csrngGetServiceSession(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result csrngGetRandomBytes(void *out, size_t out_size) {
|
Result csrngGetRandomBytes(void *out, size_t out_size) {
|
||||||
IpcCommand c;
|
return serviceDispatch(&g_csrngSrv, 0,
|
||||||
ipcInitialize(&c);
|
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
||||||
|
.buffers = { { out, out_size } },
|
||||||
ipcAddRecvBuffer(&c, out, out_size, BufferType_Normal);
|
);
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
} *raw;
|
|
||||||
|
|
||||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
|
||||||
|
|
||||||
raw->magic = SFCI_MAGIC;
|
|
||||||
raw->cmd_id = 0;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_csrngSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
ipcParse(&r);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
} *resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user