Changes

Jump to navigation Jump to search
revise some syscall descriptions
(please feel free to contribute your own findings!)
Names starting with IOS_ are official names. The rest are only educated guesses. {|border=1class="wikitable"|+ List of syscalls in IOS
|-
! ID # !! Internal name !! Description !! Return value
|-
| 0 || int thread_createIOS_CreateThread( u32 (*proc)(void* arg), void* arg, u32* stack_top, u32 stacksize, int priority, BOOL detached) || Creates a thread (in paused state) || New threadid or error (negative value)
|-
| 1 || int thread_joinJoinThread(int threadid, u32 *returned_value) || Waits for a thread to finish executing || 0 on success
|-
| 2 || thread_cancelint CancelThread(int threadid, u32 ? return_value )|| Ends a thread, called automatically when proc returns || 0 on success
|-
| 3 || int get_tidIOS_GetThreadId(void) || Get the current thread's ID || Current threadid
|-
| 4 || int get_pidGetProcessId(void) || Get the current process's ID || Current processid
|-
| 5 || int thread_resumeIOS_StartThread(int threadid) || Resume the specified thread || 0 on success
|-
| 6 || int thread_suspendSuspendThread(int threadid) || Suspend the specified thread || 0 on success
|-
| 7 || int thread_yieldYieldThread(void) || Yield execution to any higher priority threads || 0 on success
|-
| 8 || int thread_get_priorityIOS_GetThreadPriority(int threadid) || Get the priority of the specified thread || thread's priority or error (negative value)
|-
| 9 || int thread_set_priorityIOS_SetThreadPriority(int threadid, int priority) || Set the priority of the specified thread || 0 on success
|-
| a || int message_queue_createIOS_CreateMessageQueue(u32 *ptr, u32 n_msgs) || Create a queue at ptr, for n_msgs messages || The queue ID
|-
| b || int message_queue_destroyIOS_DestroyMessageQueue(int queueid) || Destroy a message queue || 0 on success
|-
| c || int message_queue_sendIOS_SendMessage(int queueid, u32 message, u32 flags) || Add a message to the end queue || 0 on success
|-
| d || int message_queue_send_nowIOS_JamMessage(int queueid, u32 message, u32 flags) || Add a message to the front of a queue || 0 on success
|-
| e || int message_queue_receiveIOS_ReceiveMessage(int queueid, u32 *message, u32 flags) || Fetch a message from the front of a queue || 0 on success
|-
| f || int RegisterEventHandlerIOS_HandleEvent(int device, int queueid, int message) || Register queueid as a handler for interrupts generated by device (sends message to queueid when device's interrupt is triggered) || 0 on success
|-
| 10 || int UnregisterEventHandler(int device) || Unregister handler for device || 0 on success
|-
| 11 || int CreateTimerIOS_CreateTimer(int time_us, int repeat_time_us, int queueid, u32 message) || Create a timer that sends a message to a queue after the elapsed period(s) || timerid or error (negative value)
|-
| 12 || int RestartTimerIOS_RestartTimer(int timerid, int time_us, int repeat_time_us) || Restart a timer using the specified period(s) || 0 on success
|-
| 13 || int StopTimerIOS_StopTimer(int timerid) || Pauses the specified timer || 0 on success
|-
| 14 || int DestroyTimerIOS_DestroyTimer(int timerid) || Destroys the specified timer || 0 on success
|-
| 15 || u32 time_now() || Fetch the current value of starlet's timer || The current value of the [[Hardware/Starlet_Timer|HW_TIMER]] register
|-
| 16 || int heap_createIOS_CreateHeap(void *ptr, int size) || Create a new heap at ptr of size bytes || heapid or error (negative value)
|-
| 17 || int heap_destroyIOS_DestroyHeap(int heapid) || Destroy the specified heap || 0 on success
|-
| 18 || void* heap_allocIOS_Alloc(int heapid, u32 size) || Allocate size bytes from the specified heap || pointer to memory
|-
| 19 || void* heap_alloc_alignedAllocAligned(int heapid, u32 size, u32 align) || Allocate size bytes from the specified heap with the requested alignment || pointer to aligned memory
|-
| 1a || void heap_freeint IOS_Free(int heapid, void *ptr) || Release allocated memory back to the heap|| 0 on success
|-
| 1b || BOOL device_registerbool IOS_RegisterResourceManager(const char* device, int queueid) || Registers device to the device tree, so it can be opened (from Starlet and PPC) || 0 on success
|-
| 1c || int device_openIOS_Open(const char* device, int mode) || Similar to IOS_Open on PPC, except now internal to the IOS system || Returns an fd or error (negative)
|-
| 1d || int device_closeIOS_Close(int fd) || Close a previously opened fd || 0 on success
|-
| 1e || int device_readIOS_Read(int fd, void *buf, u32 len) || Read len bytes from fd into buf || The number of bytes read or error
|-
| 1f || int device_writeIOS_Write(int fd, const void *buf, u32 len) || Write len bytes to fd from buf || The number of bytes written or error
|-
| 20 || int device_seekIOS_Seek(int fd, int offset, int origin) || Seek to offset relative to origin || The new absolute offset or error
|-
| 21 || int device_ioctlIOS_Ioctl(int fd, u32 request, void *input_buffer, u32 input_buffer_len, void *output_buffer, u32 output_buffer_len) || Perform the requested IOCTL || Return value from IOCTL
|-
| 22 || int device_ioctlvIOS_Ioctlv(int fd, u32 request, u32 vector_count_in, u32 vector_count_out, [[IOS/struct iovecResource request|struct iovecIOVector]] *vector) || Perform the requested IOCTL || Return value from IOCTL
|-
| 23 || int device_open_asyncIOS_OpenAsync(const char* device, int mode, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_open IOS_Open || 0 on success, ipcmessage is sent to the queue with the command's return value
|-
| 24 || int device_close_asyncIOS_CloseAsync(int fd, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_close IOS_Close || 0 on success
|-
| 25 || int device_read_asyncIOS_ReadAsync(int fd, void *buf, u32 len, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_readIOS_Read
|-
| 26 || int device_write_asyncIOS_WriteAsync(int fd, const void *buf, u32 len, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_writeIOS_Write
|-
| 27 || int device_seek_asyncIOS_SeekAsync(int fd, int offset int origin, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_seekIOS_Seek
|-
| 28 || int device_ioctl_asyncIOS_IoctlAsync(int fd, u32 request, void *input_buffer, u32 input_buffer_len, void *output_buffer, u32 output_buffer_len, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_ioctlIOS_Ioctl
|-
| 29 || int device_ioctlv_asyncIOS_IoctlvAsync(int fd, u32 request, u32 vector_count_in, u32 vector_count_out, [[IOS/struct iovecResource_request|struct iovecIOVector]] *vector, int queueid, ipcmessage IOSRequest *message) || Async implementation of device_ioctlvIOS_Ioctlv
|-
| 2a || void message_ackIOS_ResourceReply( [[IOS/resource request|const struct ios_resource_requestIOSRequest]] *request, int retval) || return from a cmd on a [[IOS|resource]]
|-
| 2b || SetUIDIOSError SetUid(u32 pid, u32 uid) || Set the UID for a process (PID <= 0x13). This can only be used from the kernel or ES. || IPC_SUCCESS on success, IPC_EACCES (permission denied if current PID > 0x1) or IPC_EINVAL (invalid PID)
|-
| 2c || get_hmac_queue_for_pidu32 GetUid() || Get the UID for the active process (based on the thread PID). || UID (u32)
|-
| 2d || SetGIDIOSError SetGid(u32 pid, u16 gid) || Set the GID for a process (PID <= 0x13). This can only be used from the kernel or ES. || IPC_SUCCESS on success, IPC_EACCES (permission denied if current PID > 0x1) or IPC_EINVAL (invalid PID)
|-
| 2e || lookup_GID_maybeu16 GetGid() || Get the GID for the active process (based on the thread PID). || GID (u16)
|-
| 2f || cc_ahbMemFlushint ahbMemFlush(int ahb_dev)
|-
| 30 || syscall_ahbMemFlush_wrapper
|-
| 31 || software_IRQ_31 int enable_irq_iop() || seems to enable Enables [[Hardware/Hollywood IRQs|hardware interrupts ]] for device nr 31([[Hardware/IPC|IPC (Starlet)]]) (can only be used from the kernel or ES) || 0 on success, -4 for no permission.
|-
| 32 || software_irq_18 int enable_irq_di() || seems to enable Enables [[Hardware/Hollywood IRQs|hardware interrupts ]] for device nr 18([[Hardware/Drive Interface|DI]]) (can only be used from DI) || 0 on success, -4 for no permission
|-
| 33 || software_IRQ_7_or_8int enable_irq_sdhc(int id) || seems to enable Enables [[Hardware/Hollywood IRQs|hardware interrupts ]] for device nr 7 ([[Hardware/SD Host Controller|SDHC]] - must be SDI) if id==0, else device nr 8 (sdhc[[Hardware/802.11 Wireless|802.11 Wireless]] - must be WL)|| 0 on success, -4 for no permission
|-
| 34 || software_IRQint enable_irq(int id) || enables Enables [[Hardware/Hollywood IRQs|hardware interrupts ]] for the given device nr, with PID requirements (this is also used to syscalls 31 through 33): {| class="wikitable" ! id !! PID |- | 4 ([[Hardware/USB Host Controller|USB Host Controller]]) || 6 (EHCI) |- | 5 ([[Hardware/USB Host Controller|USB Host Controller]]) || 4 (OH0/OHCI0) |- | 6 ([[Hardware/USB Host Controller|USB Host Controller]]) || 5 (OH1) |- | 7 ([[Hardware/SD Host Controller|SD Host Controller]]) || 7 (SDI) |- | 8 ([[Hardware/802. id11 Wireless|802.11 Wireless]]) || 11 (WL) |- | 11 ([[Hardware/Hollywood GPIOs|Hollywood GPIOs]] (Starlet); check caller PIDalso updates POWER (1) in [[Hardware/Hollywood_GPIOs#HW_GPIO_INTFLAG|HW_GPIO_INTFLAG]]) || 14 (STM) |- | 17 (Reset button) || 14 (STM) |- | 18 ([[Hardware/Drive Interface|Drive Interface]]) || 3 (DI) |- | 31 ([[Hardware/IPC|IPC (Starlet)]]) || 0 (Kernel or ES) |}| 0 on success, -1 for unknown IRQ (not in that table), -4 for no permission
|-
| 35 || access_iobuf_pool(arg1) || no-op in IOS-35, arg1=0 || returns always 0
| 3d || int verify_iobuf([[IOS/IoBuffer|struct iobuf]] *iob) || verify if the argument points to an io buffer
|-
| 3e || syscall_3e|| Unknown; related to IO buffer functionality
|-
| 3f || void sync_before_readIOS_InvalidateDCache(void *address, u32 size) || "sync_before_read" - Invalidates dcache, and something (probably related to flushing memory)
|-
| 40 || void sync_after_writeIOS_FlushDCache(const void *address, u32 size) || "sync_after_write" - Flushes dcache and does magic bullshit (aka magic AHB operations)
|-
| 41 || ppc_boot(const char *path) || Loads a .dol or .elf file into memory and bootstraps the PPC
|-
| 42 || <nowiki>[[noreturn]]</nowiki> IOSError ios_boot(const char *path, u32 flag, u32 version) || Loads Suspends the IPC thread, loads a new IOS kernelfrom the NAND to 0x10100000 in IOS59), then calls <code>boot_new_ios_kernel(0x10100000, version)</code>. This can only be called from UID 0. || Doesn't return if the boot succeeded; otherwise, an error code is returned.
|-
| 43 || syscall_43<nowiki>[[noreturn]]</nowiki> void boot_new_ios_kernel(void* ios_binary_address, u32 new_version) || Sets the version at 0x3140 to <code>new_version</code> and the IPC buffer range ("DDR settings") to the legacy range ("12M"), before branching to the new kernel. This can only be called from UID 0. || -
|-
| 44 || int syscall_assert_di_reset assert_di_reset() || Clears bit 10 (DI) of 0xD800194 [[Hardware/Hollywood_Registers#HW_RESETS|HW_RESETS]] (can only be called from DI) || Returns 0 on success, -1 on error
|-
| 45 || int syscall_deassert_di_reset deassert_di_reset() || Enables bit 10 (DI) of 0xD800194 [[Hardware/Hollywood_Registers#HW_RESETS|HW_RESETS]] (can only be called from DI) || Returns 0 on success, -1 on error
|-
| 46 || BOOL syscall_check_di_reset bool check_di_reset() || Checks bit 10 (DI) of 0xD800194 [[Hardware/Hollywood_Registers#HW_RESETS|HW_RESETS]] (can only be called from DI) || Returns 1 on reset asserted, 0 on (deasserted or error)
|-
| 47 || GetSomeFlags void get_kernel_flavor(u32 *type, u16 *unk) || Depending on what is currently running (boot2/IOS) it The implementation of this syscall differs between "flavors" of kernel and returns different values some identifiers. || IOS: *The IOSv58 system menu kernel writes (u32*)r0type=0 3, *(u16*)r1unk=0).Boot2: *The boot2v04 kernel writes (u32*)r0type=3 *(u160, *unk_0)r1=0.
|-
| 48 || set_r0_1_r1_0void get_unk_flavor(u32 *type, u16 *unk) || Potentially vestigial. Probably related to syscall 0x47 above. || Always returns (*type=1, *unk=0).
|-
| 49 || u32 get_boot_vector() || Returns a pointer (?) depending on the SRAM mirror bit in [[Hardware/Hollywood_Registers#HW_MEMIRR|HW_MEMIRR]].|| Returns 0xffffff00 when the mirror bit is set.Returns 0x0d40ff00 when the mirror bit is unset.
|-
| 4a || GetHollywoodRevision
| 4c || int kernel_set_version(u32 version) || Stores version to 0x3140 (can only be called by ES) || 0 on success
|-
| 4d || u32 kernel_get_version() || Returns the current IOS version from 0x3140 (can only be called by ES ) || IOS version or 0 on error
|-
| 4e || poke_E0_1 int set_di_spinup(uint enable) || Sets or clears the DI_SPIN [[Hardware/Hollywood GPIOs|GPIO]]; if enable is 0 then the flag is set (disabling spinup); it is cleared otherwise. (Can only be called by DI) || 0 on success, -1 on error
|-
| 4f || void* virt_to_phys(void *ptr) || Converts a virtual pointer to its physical equivalent
|-
| 50 || void int Set_DVDVideo(u32 enablebool disable) || Enable/Disable DI DVD Video commands (can only be called from DI) || 0 on success, -1 on error
|-
| 51 || u32 Get_DVDVideobool Check_DVDVideo() || Return status of DI DVD Video commands (can only be called from DI) || 1 if enableddisabled, 0 if disabled enabled or error
|-
| 52 || int syscall_52 (bool value) || can Sets bit 4 of [[Hardware/Hollywood_Registers#HW_EXICTRL|HW_EXICTRL]], clearing it if value is 0 and setting it otherwise. DI only seems to call it with false{{check}}. (Can only be called from DI)| 0 on success, -1 on error
|-
| 53 || bool syscall_53 () || Checks bit 4 of [[Hardware/Hollywood_Registers#HW_EXICTRL|HW_EXICTRL]] (can only be called from DI) || 1 if bit 4 of [[Hardware/Hollywood_Registers#HW_EXICTRL|HW_EXICTRL]] is set, 0 if not set or error
|-
| 54 || int set_ahbprot(u32 enable) || Enable/Disable PPC AHBPROT setting (can only be called from ES) || 0 on success, -1 on error
| 56 || int poke_gpios(u32 reg, u32 value) || Set gpio reg to value (can only be called from STM) || 0 on success, -1 on error
|-
| 57 || syscall_57 int write_ddr_reg(u32 reg_idx, u16 val) || can Writes a 16-bit value to the specified Memory Controller register. Can only be called from the STM module. || Returns 0 on success, -1 on error.
|-
| 58 || void call_poke_debug_portpoke_debug_port(u8 value) || Set [[Hardware/Hollywood GPIOs|GPIO ]] lines 16-23 (DEBUG1DEBUG0-7, the [[debug port]]) to the provided value.
|-
| 59 || load_PPC set_ipc_access_rights || can Related to PPC IPC. Can only be called from the ES module. Called when bootstrapping PPC. || 0 on success, negative for error.
|-
| 5a || u32 load_module(const char* path) || Load the specified an ARM ELF [IOS module ] and run it (can only be called from UID 0, which is kernel or ES) start a new thread. || 0 on success, negative for error
|-
! ENUMS !! KEY_USAGE !! KEY_TYPE !! KEY_IDS| 5b || IOSCError IOSC_CreateObject(u32* key_handle, IOSCObjectType type, IOSCObjectSubType subtype); || Create a new keyring entry. <code>key_handle</code> is updated with a key handle to use with other IOSC calls. || 0 on success, negative for error
|-
| 5c || crypto IOSCError IOSC_DeleteObject(u32 key_handle) || aes Remove a keyring entry || ECC Private Key0 on success, negative for error
|-
| 5d || signature IOSCError IOSC_ImportSecretKey(IOSCSecretKeyHandle importedHandle, IOSCSecretKeyHandle verifyHandle, IOSCSecretKeyHandle decryptHandle, IOSCSecretKeySecurity flag, u8 * signbuffer, u8 * ivData, u8 * keybuffer); || hmac Sets the contents of a key handle. This is commonly used to import a built-in key handle (such as the common key). || Console ID0 on success, negative for error
|-
| 5e || ECC Pair IOSCError IOSC_ExportSecretKey(IOSCSecretKeyHandle exportedHandle, IOSCSecretKeyHandle signHandle, IOSCSecretKeyHandle encryptHandle, IOSCSecretKeySecurity security_flag, u8 * signbuffer, u8 * ivData, u8 * keybuffer); || 2048b Certificate || NAND AES Key0 on success, negative for error
|-
| 5f || Informative IOSCError IOSC_ImportPublicKey(u8 * publicKeyData, u8 * exponent, IOSCPublicKeyHandle publicKeyHandle); || 4096b Certificate Sets the contents of a signature. The imported public key must match <code>publicKeyHandle</code>'s type. <code>exponent</code> is optional 4 bytes that can be attached || NAND HMAC0 on success, negative for error
|-
| 60 || IOSCError IOSC_ExportPublicKey(u8 * publicKeyData, u8 * exponent, IOSCPublicKeyHandle publicKeyHandle); || ECC Gets the contents of a signature || Common Key0 on success, negative for error
|-
| 61 || IOSCError IOSC_ComputeSharedKey(IOSCSecretKeyHandle privateHandle, IOSCPublicKeyHandle publicHandle, IOSCSecretKeyHandle sharedHandle); || Console ID Generates a new AES crypto key (<code>sharedHandle</code>) from an ecdh shared secret calculated from a sender's ECC key (<code>publicHandle</code>) and our own ECC key (<code>privateHandle</code>) || PRNG Seed0 on success, negative for error
|-
| 62 || IOSCError IOSC_SetData(IOSCDataHandle dataHandle, u32 value); || [[Hardware/SEEPROM|SEEPROM]] Counter || SD Key0 on success, negative for error
|-
| 63 || IOSCError IOSC_GetData(IOSCDataHandle dataHandle, u32 * value); || Fetch 4 bytes of userdata from the key || Boot2 Version0 on success (userdata in data), negative for error
|-
| 64 || IOSCError IOSC_GetKeySize(u32 * keySize, IOSCKeyHandle handle);|| Return the key size || ?0 on success, negative for error
|-
| 65 || IOSCError IOSC_GetSignatureSize(u32 * signSize, int handle); || Return the signature size || ?0 on success, negative for error
|-
| 66 || int IOSC_GenerateHashAsync(u8 * context, u8 * inputData, u32 inputSize, u32 chainingFlag, u8 * hashData, int message_queue_id, IOSRequest* reply); || Calculate SHA1 hash of <code>inputData</code>. An IPC reply is sent to the message queue on completion. || [[Hardware/SEEPROM|SEEPROM]] NAND Generation0 on success
|-
| 67 || IOSCError IOSC_GenerateHash(u8 * context, u8 * inputData, u32 inputSize, u32 chainingFlag, u8 * hashData); || Synchronous implementation of IOSC_GenerateHashAsync || Korean Common Key0 on success
|-
| 5b 68 || int create_keyIOSC_EncryptAsync(int IOSCSecretKeyHandle encryptHandle, u8 * ivData, u8 *keyidinputData, KEY_USAGE usageu32 inputSize, KEY_TYPE typeu8 * outputData, int message_queue_id, IOSRequest* reply) || create a new keyring entry AES-encrypt <code>inputSize</code> bytes from <code>inputData</code> using <code>encryptHandle</code> and <code>ivData</code> (which gets updated) and write to <code>outputData</code>. An IPC reply is sent to the message queue on completion. || 0 on success, negative for error
|-
| 5c 69 || int destroy_keyIOSCError IOSC_Encrypt(int keyidIOSCSecretKeyHandle encryptHandle, u8 * ivData, u8 * inputData, u32 inputSize, u8 * outputData) ; || Remove a keyring entry Synchronous implementation of IOSC_EncryptAsync || 0 on success, negative for error
|-
| 5d 6a || int initialize_keyIOSC_DecryptAsync(int (IOSCSecretKeyHandle decryptHandle, u8 *keyidivData, u32, int decryption_keyidu8 * inputData, u32inputSize, u32u8 * outputData, void *ivint message_queue_id, void IOSRequest*crypted_keyrequest) ; || Sets AES-decrypt <code>inputSize</code> bytes from <code>inputData</code> using <code>decryptHandle</code> and <code>ivData</code> (which gets updated) and write to <code>outputData</code>. An IPC reply is sent to the contents of a key message queue on completion. || 0 on success, negative for error
|-
| 5e 6b || keyring_deallocate_entryIOSCError IOSC_Decrypt(int indexIOSCSecretKeyHandle decryptHandle, u8 * ivData, u8 * inputData, u32 inputSize, u8 * outputData) ; || Synchronous implementation of IOSC_DecryptAsync || 0 on success, negative for error
|-
| 5f 6c || int set_sig_dataIOSCError IOSC_VerifyPublicKeySign(const void u8 *datainputData, const u32 inputSize, IOSCPublicKeyHandle publicHandle, u8 *userdata, int keyidsignData) ; || Sets the contents of a signature. data length should match the signature type, user_data is optional 4 bytes that can be attached || 0 on success, negative for error
|-
| 60 6d || int get_sig_infoIOSCError IOSC_GenerateBlockMAC(void u8 *datacontext, u8 * inputData, u32 inputSize, u8 *userdatacustomData, u32 customDataSize, IOSCSecretKeyHandle signerHandle, int keyidu32 chainingFlag, u8 * signData) ; || Gets the contents of a signature || 0 on success, negative for error
|-
| 61 6e || int calc_ecdh_shared_secretIOSCError IOSC_GenerateBlockMACAsync(int self_ecc_keyidu8 * context, u8 * inputData, u32 inputSize, u8 * customData, u32 customDataSize, IOSCSecretKeyHandle signerHandle, u32 chainingFlag, u8 * signData, int sender_ecc_public_keyidmessage_queue_id, int dest_keyidIOSRequest* reply) ; || Generates a new AES crypto key from an ecdh shared secret calculated from a sender's ECC key and our own ECC key Async version of IOSC_GenerateBlockMAC || 0 on success, negative for error
|-
| 62 6f || int set_4byte_keyIOSCError IOSC_ImportCertificate(int keyidu8 * certData, IOSCPublicKeyHandle signerHandle, const u32 *dataIOSCPublicKeyHandle publicKeyHandle) ; || || 0 on success, negative for error
|-
| 63 70 || int get_4byte_keyIOSCError IOSC_GetDeviceCertificate(int keyid, u32 IOSCEccSignedCert *datacertificate) ; || Fetch 4 Write 0x180 bytes of userdata from the key NG certificate to <code>certificate</code> || 0 on success (userdata in data), negative for error
|-
| 64 71 || int get_key_sizeIOSCError IOSC_SetOwnership(int keyidu32 handle, u32 *sizeusers) ; || Return Allow the PIDs set in mask to use this key's size in size[0] || 0 on success, negative for error
|-
| 65 72 || int get_key_userdata_sizeIOSCError IOSC_GetOwnership(int keyidu32 handle, u32 *sizeusers) ; || Return Get a mask of the PIDs allowed to use this key's userdata size in size[0] || 0 on success, negative for error
|-
| 66 73 || int sha1_asyncIOSCError IOSC_GenerateRand(void u8 *SHACarry, const void *data, u32 lengthrandBytes, u32 SHAMode, void *hash, int queueid, ipcmessage *messagenumBytes) ; || Calculate SHA1 hash Write size bytes of random data, send message to queueid with result data || 0 on success
|-
| 67 74 || int sha1IOSCError IOSC_GenerateKey(void *SHACarry, const void *data, u32 length, u32 SHAMode, void *hashIOSCKeyHandle handle) ; || Synchronous implementation Sets contents of sha1_async || 0 on success<code>handle</code> to random data
|-
| 68 75 || int aes_encrypt_asyncIOSCError IOSC_GeneratePublicKeySign(int keyid, void u8 *ivhash, const void *inu32 hashLength, int lenIOSCSecretKeyHandle signerHandle, void u8 *out, int queueid, ipcmessage *messageeccSignature) ; || Encrypt len bytes from in using keyid and iv (which gets updated) and write to out. Send message to queueid with result Makes an ECC signature || 0 on success
|-
| 69 76 || int aes_encryptIOSCError IOSC_GenerateCertificate(int keyidIOSCSecretKeyHandle privateHandle, void *iv, const void *in, int lenIOSCCertName certname, void IOSCEccSignedCert *outcertificate) ; || Synchronous implmentation of aes_encrypt_async || 0 on success
|-
| 6a 77 || int aes_decrypt_asyncIOSCError IOSC_CheckDiHashes(int keyid, void u8 *ivdestAddr, const void u8 *in, int lendiskRdBuf, void *outu32 h1Index, int queueidu32 h2Index, ipcmessage u8 *messageh3Ptr) ; || Decrypt len bytes can only be called from in using keyid and iv (which gets updated) and write to out. Send message to queueid with result DI || 0 on success, negative on error
|-
| 6b 78 || int aes_decryptsyscall_78_set(int keyid, void *ivbuf, const void *in, int u32 len, void *out) || Synchronous implemntation of aes_decrypt_async Related to thread priorities? Can only be called from ES. || Returns 0 on success, negative on error
|-
| 6c 79 || int check_sigsyscall_79_get(const void *hash, int hash_length, int signer_keyid, const void *sig) || || 0 on success|-| 6d || int hmac || || 0 on success|-| 6e || int hmac_async || || 0 on success|-| 6f || int validate_cert(void *cert, int signer_keyid, int dest_keyid) || || 0 on success|-| 70 || int get_ng_cert(void *cert) || Write 0x180 bytes of NG certificate to cert || 0 on success|-| 71 || int set_key_permissions(int keyidbuf, u32 masklen) || Allow the PIDs set in mask Related to use this key thread priorities? Can only be called from ES. || 0 Returns negative on success|-| 72 || int get_key_permissions(int keyid, u32 *mask) || Get a mask of the PIDs allowed to use this key || 0 on success|-| 73 || int get_random_data(void *data, u32 size) || Write size bytes of random data to data || 0 on success|-| 74 || int init_random_key(int keyid) || Sets contents of keyid to random data|-| 75 || int make_ECC_sig(void *SHAhash, u32 hash_length, int keyid, void *ecc_sig) || || 0 on success|-| 76 || int syscall_76(int ecc_keyid, void *in_64bytes, void *out_180bytes) || || 0 on success|-| 77 || syscall_77|-| 78 || syscall_78|-| 79 || syscall_79error.
|-
| 7a || syscall_7a
|-
| 4 || write(const char *string) || Prints a null-terminated debug message. || none.
|}
 
== IOSC built-in key handles ==
The above crypto commands use key/crypto object handles. These handles can be either from IOSC_CreateObject(which can then be initialized with IOSC_ImportSecretKey in the case of AES), or a built-in handle. The available built-in handles/ids are listed below.
 
Names starting with IOSC are official names which were found in the GPLed parts of IOS.
 
{|border=1 class="wikitable"
|+ List of built-in key handles in IOS
|-
! ID !! Internal name !! Description
|-
| 0 || IOSC_DEV_SIGNING_KEY_HANDLE || ECC-233 private key (source: xyzzy)
|-
| 1 || IOSC_DEV_ID_HANDLE || Console ID
|-
| 2 || IOSC_FS_ENC_HANDLE || NAND AES-128 key
|-
| 3 || IOSC_FS_MAC_HANDLE || NAND HMAC
|-
| 4 || IOSC_COMMON_ENC_HANDLE || Common key
|-
| 5 || IOSC_BACKUP_ENC_HANDLE || PRNG seed (source: xyzzy)
|-
| 6 || IOSC_APP_ENC_HANDLE || SD AES-128 key (source: xyzzy)
|-
| 7 || IOSC_BOOTOSVER_HANDLE || boot2 version (4 bytes, updated by ES_ImportBoot with the low 32 bits from the TMD IOS title ID field)
|-
| 8 || IOSC_CACRLVER_HANDLE || Unknown - Appears to be unused
|-
| 9 || IOSC_SIGNERCRLVER_HANDLE || Unknown - Appears to be unused
|-
| 10 || IOSC_FSVER_HANDLE || Unknown - Used in the FS driver - [[Hardware/SEEPROM|SEEPROM]] NAND generation?
|-
| 11 || IOSC_COMMON2_ENC_HANDLE || Korean common key
|-
|}

Navigation menu