mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Use PACKED for _usbDsGetSession resp, required for domains. Use domains for usbds, with changes from @SciresM.
This commit is contained in:
parent
68846af044
commit
3726eb8950
@ -34,6 +34,10 @@ Result usbDsInitialize(void)
|
||||
|
||||
rc = smGetService(&g_usbDsSrv, "usb:ds");
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
rc = serviceConvertToDomain(&g_usbDsSrv);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
rc = _usbDsBindDevice(UsbComplexId_Default);
|
||||
if (R_SUCCEEDED(rc))
|
||||
@ -161,7 +165,7 @@ static Result _usbDsBindDevice(UsbComplexId complexId) {
|
||||
u32 complexId;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
@ -171,12 +175,13 @@ static Result _usbDsBindDevice(UsbComplexId complexId) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -195,7 +200,7 @@ static Result _usbDsBindClientProcess(Handle prochandle) {
|
||||
|
||||
ipcSendHandleCopy(&c, prochandle);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 1;
|
||||
@ -204,12 +209,13 @@ static Result _usbDsBindClientProcess(Handle prochandle) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -226,7 +232,7 @@ static Result _usbDsGetEvent(Service* srv, Event* event_out, u64 cmd_id) {
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(srv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = cmd_id;
|
||||
@ -235,12 +241,13 @@ static Result _usbDsGetEvent(Service* srv, Event* event_out, u64 cmd_id) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(srv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
@ -261,7 +268,7 @@ Result usbDsGetState(u32 *out) {
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 4;
|
||||
@ -270,13 +277,14 @@ Result usbDsGetState(u32 *out) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 out;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
if (R_SUCCEEDED(rc) && out)*out = resp->out;
|
||||
@ -353,7 +361,7 @@ Result usbDsSetVidPidBcd(const UsbDsDeviceInfo* deviceinfo) {
|
||||
|
||||
ipcAddSendBuffer(&c, deviceinfo, sizeof(UsbDsDeviceInfo), 0);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 5;
|
||||
@ -362,12 +370,13 @@ Result usbDsSetVidPidBcd(const UsbDsDeviceInfo* deviceinfo) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -389,7 +398,7 @@ static Result _usbDsGetSession(Service* srv, Service* srv_out, u64 cmd_id, const
|
||||
if (buf1 && buf1size)
|
||||
ipcAddSendBuffer(&c, buf1, buf1size, 0);
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(srv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = cmd_id;
|
||||
@ -398,20 +407,21 @@ static Result _usbDsGetSession(Service* srv, Service* srv_out, u64 cmd_id, const
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 out;
|
||||
} *resp = r.Raw;
|
||||
} PACKED *resp;
|
||||
|
||||
serviceIpcParse(srv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc) && out) *out = resp->out;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
serviceCreate(srv_out, r.Handles[0]);
|
||||
serviceCreateSubservice(srv_out, srv, &r, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -427,7 +437,7 @@ static Result _usbDsCmdNoParams(Service* srv, u64 cmd_id) {
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(srv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = cmd_id;
|
||||
@ -436,12 +446,13 @@ static Result _usbDsCmdNoParams(Service* srv, u64 cmd_id) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(srv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -463,7 +474,7 @@ static Result _usbDsPostBuffer(Service* srv, u64 cmd_id, void* buffer, size_t si
|
||||
u64 buffer;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(srv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = cmd_id;
|
||||
@ -475,13 +486,14 @@ static Result _usbDsPostBuffer(Service* srv, u64 cmd_id, void* buffer, size_t si
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 urbId;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(srv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
if (R_SUCCEEDED(rc) && urbId)*urbId = resp->urbId;
|
||||
@ -499,7 +511,7 @@ static Result _usbDsGetReport(Service* srv, u64 cmd_id, UsbDsReportData *out) {
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(srv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = cmd_id;
|
||||
@ -508,13 +520,14 @@ static Result _usbDsGetReport(Service* srv, u64 cmd_id, UsbDsReportData *out) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
UsbDsReportData out;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(srv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
@ -584,7 +597,7 @@ Result usbDsRegisterInterface(UsbDsInterface** interface)
|
||||
u32 intf_num;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 2;
|
||||
@ -594,17 +607,18 @@ Result usbDsRegisterInterface(UsbDsInterface** interface)
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
serviceCreate(&srv, r.Handles[0]);
|
||||
serviceCreateSubservice(&srv, &g_usbDsSrv, &r, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -656,7 +670,7 @@ Result usbDsRegisterInterfaceEx(UsbDsInterface** interface, u32 intf_num)
|
||||
u32 intf_num;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 2;
|
||||
@ -666,17 +680,18 @@ Result usbDsRegisterInterfaceEx(UsbDsInterface** interface, u32 intf_num)
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
serviceCreate(&ptr->h, r.Handles[0]);
|
||||
serviceCreateSubservice(&ptr->h, &g_usbDsSrv, &r, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -714,7 +729,7 @@ static Result _usbDsAddUsbStringDescriptorRaw(u8 *out_index, struct usb_string_d
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 6;
|
||||
@ -723,13 +738,14 @@ static Result _usbDsAddUsbStringDescriptorRaw(u8 *out_index, struct usb_string_d
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u8 index;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
if (R_SUCCEEDED(rc) && out_index) {
|
||||
@ -782,7 +798,7 @@ Result usbDsDeleteUsbStringDescriptor(u8 index) {
|
||||
u32 index;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 7;
|
||||
@ -792,12 +808,13 @@ Result usbDsDeleteUsbStringDescriptor(u8 index) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -818,7 +835,7 @@ Result usbDsSetUsbDeviceDescriptor(UsbDeviceSpeed speed, struct usb_device_descr
|
||||
u32 speed;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 8;
|
||||
@ -828,12 +845,13 @@ Result usbDsSetUsbDeviceDescriptor(UsbDeviceSpeed speed, struct usb_device_descr
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -852,7 +870,7 @@ Result usbDsSetBinaryObjectStore(void* bos, size_t bos_size) {
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&g_usbDsSrv, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 9;
|
||||
@ -861,12 +879,13 @@ Result usbDsSetBinaryObjectStore(void* bos, size_t bos_size) {
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&g_usbDsSrv, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -903,7 +922,7 @@ Result usbDsInterface_GetSetupPacket(UsbDsInterface* interface, void* buffer, si
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&interface->h, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 2;
|
||||
@ -912,12 +931,13 @@ Result usbDsInterface_GetSetupPacket(UsbDsInterface* interface, void* buffer, si
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&interface->h, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -1007,7 +1027,7 @@ Result usbDsInterface_RegisterEndpoint(UsbDsInterface* interface, UsbDsEndpoint*
|
||||
u32 ep_addr;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&interface->h, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
@ -1017,17 +1037,18 @@ Result usbDsInterface_RegisterEndpoint(UsbDsInterface* interface, UsbDsEndpoint*
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&interface->h, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
serviceCreate(&ptr->h, r.Handles[0]);
|
||||
serviceCreateSubservice(&ptr->h, &interface->h, &r, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1054,7 +1075,7 @@ Result usbDsInterface_AppendConfigurationData(UsbDsInterface* interface, UsbDevi
|
||||
u32 speed;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&interface->h, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 12;
|
||||
@ -1065,12 +1086,13 @@ Result usbDsInterface_AppendConfigurationData(UsbDsInterface* interface, UsbDevi
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&interface->h, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
@ -1126,7 +1148,7 @@ Result usbDsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt)
|
||||
u32 zlt;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw = serviceIpcPrepareHeader(&endpoint->h, &c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 5;
|
||||
@ -1136,12 +1158,13 @@ Result usbDsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt)
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
} *resp;
|
||||
|
||||
serviceIpcParse(&endpoint->h, &r, sizeof(*resp));
|
||||
resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user