mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Use serviceIpcPrepareHeader/serviceIpcParse with binder to support using domains.
This commit is contained in:
parent
4177031ebe
commit
3999ec147e
@ -5,11 +5,21 @@
|
||||
#include "runtime/hosversion.h"
|
||||
#include "display/binder.h"
|
||||
|
||||
static void* _binderIpcPrepareHeader(Binder* b, IpcCommand* cmd, size_t sizeof_raw)
|
||||
{
|
||||
return serviceIpcPrepareHeader(b->relay, cmd, sizeof_raw);
|
||||
}
|
||||
|
||||
static Result _binderIpcDispatch(Binder* b)
|
||||
{
|
||||
return serviceIpcDispatch(b->relay);
|
||||
}
|
||||
|
||||
static Result _binderIpcParse(Binder* b, IpcParsedCommand* r, size_t sizeof_raw)
|
||||
{
|
||||
return serviceIpcParse(b->relay, r, sizeof_raw);
|
||||
}
|
||||
|
||||
void binderCreate(Binder* b, s32 id)
|
||||
{
|
||||
memset(b, 0, sizeof(Binder));
|
||||
@ -93,7 +103,7 @@ static Result _binderTransactParcel(
|
||||
ipcAddSendBuffer(&c, parcel_data, parcel_data_size, 0);
|
||||
ipcAddRecvBuffer(&c, parcel_reply, parcel_reply_size, 0);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = _binderIpcPrepareHeader(b, &c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
raw->session_id = b->id;
|
||||
@ -104,12 +114,13 @@ static Result _binderTransactParcel(
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
_binderIpcParse(b, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -140,7 +151,7 @@ static Result _binderTransactParcelAuto(
|
||||
ipcAddSendSmart(&c, b->ipc_buffer_size, parcel_data, parcel_data_size, 0);
|
||||
ipcAddRecvSmart(&c, b->ipc_buffer_size, parcel_reply, parcel_reply_size, 0);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = _binderIpcPrepareHeader(b, &c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 3;
|
||||
raw->session_id = b->id;
|
||||
@ -151,12 +162,13 @@ static Result _binderTransactParcelAuto(
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
_binderIpcParse(b, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -222,7 +234,7 @@ Result binderAdjustRefcount(Binder* b, s32 addval, s32 type)
|
||||
s32 type;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = _binderIpcPrepareHeader(b, &c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 1;
|
||||
raw->session_id = b->id;
|
||||
@ -233,12 +245,13 @@ Result binderAdjustRefcount(Binder* b, s32 addval, s32 type)
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
_binderIpcParse(b, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -261,7 +274,7 @@ Result binderGetNativeHandle(Binder* b, u32 inval, Event *event_out)
|
||||
u32 inval;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = _binderIpcPrepareHeader(b, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 2;
|
||||
@ -272,13 +285,14 @@ Result binderGetNativeHandle(Binder* b, u32 inval, Event *event_out)
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
_binderIpcParse(b, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
|
Loading…
Reference in New Issue
Block a user