mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 13:02:38 +02:00
Added hiddbgReadSerialFlash.
This commit is contained in:
parent
a9c35dceb8
commit
74c102ed3f
@ -51,6 +51,10 @@ typedef struct {
|
|||||||
Result hiddbgInitialize(void);
|
Result hiddbgInitialize(void);
|
||||||
void hiddbgExit(void);
|
void hiddbgExit(void);
|
||||||
|
|
||||||
|
/// Reads spi-flash for the specified controller. See hidsys.h for UniquePadId.
|
||||||
|
/// This doesn't seem to be usable?
|
||||||
|
Result hiddbgReadSerialFlash(u32 offset, void* buffer, size_t size, u64 UniquePadId);
|
||||||
|
|
||||||
/// Initialize Hdls. Hdls is for virtual HID controllers. Only available with [7.0.0+].
|
/// Initialize Hdls. Hdls is for virtual HID controllers. Only available with [7.0.0+].
|
||||||
Result hiddbgAttachHdlsWorkBuffer(void);
|
Result hiddbgAttachHdlsWorkBuffer(void);
|
||||||
|
|
||||||
|
@ -140,6 +140,63 @@ static Result _hiddbgCmdInU64NoOut(u64 cmd_id, u64 val) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result _hiddbgReadSerialFlash(TransferMemory *tmem, u32 offset, u64 size, u64 UniquePadId) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
ipcSendHandleCopy(&c, tmem->handle);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u32 offset;
|
||||||
|
u64 size;
|
||||||
|
u64 UniquePadId;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = serviceIpcPrepareHeader(&g_hiddbgSrv, &c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 229;
|
||||||
|
raw->offset = offset;
|
||||||
|
raw->size = size;
|
||||||
|
raw->UniquePadId = UniquePadId;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_hiddbgSrv);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
} *resp;
|
||||||
|
|
||||||
|
serviceIpcParse(&g_hiddbgSrv, &r, sizeof(*resp));
|
||||||
|
resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result hiddbgReadSerialFlash(u32 offset, void* buffer, size_t size, u64 UniquePadId) {
|
||||||
|
Result rc=0;
|
||||||
|
TransferMemory tmem;
|
||||||
|
size_t sizealign = (size+0x1000) & ~0xfff;
|
||||||
|
|
||||||
|
if (hosversionBefore(6,0,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
rc = tmemCreate(&tmem, sizealign, Perm_Rw);
|
||||||
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
|
rc = _hiddbgReadSerialFlash(&tmem, offset, size, UniquePadId);
|
||||||
|
if (R_SUCCEEDED(rc)) memcpy(buffer, tmem.src_addr, size);
|
||||||
|
tmemClose(&g_hiddbgHdlsTmem);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static Result _hiddbgAttachHdlsWorkBuffer(TransferMemory *tmem) {
|
static Result _hiddbgAttachHdlsWorkBuffer(TransferMemory *tmem) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
|
Loading…
Reference in New Issue
Block a user