Add custom ioctl to read the OTP

This commit is contained in:
Maschell 2021-10-09 00:55:43 +02:00
parent 6f5829e73f
commit 7388fa001f
3 changed files with 15 additions and 0 deletions

View File

@ -28,5 +28,6 @@
#define KERNEL_WRITE32 2
#define KERNEL_MEMCPY 3
#define KERNEL_GET_CFW_CONFIG 4
#define KERNEL_READ_OTP 5
#endif

View File

@ -71,6 +71,11 @@ int kernel_syscall_0x81(u32 command, u32 arg1, u32 arg2, u32 arg3) {
//kernel_memcpy((void*)arg1, &cfw_config, sizeof(cfw_config));
break;
}
case KERNEL_READ_OTP: {
int (*read_otp_internal)(int index, void* out_buf, u32 size) = (int (*)(int, void*, u32)) 0x08120248;
read_otp_internal(0, (void*)(arg1), 0x400);
break;
}
default:
return -1;
}

View File

@ -47,6 +47,7 @@
#define IOCTL_REPEATED_WRITE 0x05
#define IOCTL_KERN_READ32 0x06
#define IOCTL_KERN_WRITE32 0x07
#define IOCTL_READ_OTP 0x08
#define IOCTL_FSA_OPEN 0x40
#define IOCTL_FSA_CLOSE 0x41
@ -172,6 +173,14 @@ static int ipc_ioctl(ipcmessage *message) {
svcCustomKernelCommand(KERNEL_WRITE32, message->ioctl.buffer_in[0], message->ioctl.buffer_in[1]);
}
break;
}
case IOCTL_READ_OTP: {
if ((message->ioctl.length_io < 0x400)) {
res = IOS_ERROR_INVALID_SIZE;
} else {
svcCustomKernelCommand(KERNEL_READ_OTP, message->ioctl.buffer_io);
}
break;
}
//!--------------------------------------------------------------------------------------------------------------
//! FSA handles for better performance