/dev/net/kd/request

From WiiBrew
< /dev‎ | net
Jump to: navigation, search

KD is the IOS module responsible for implementing WiiConnect24 functionality. It can perform HTTP(S) downloads, send and receive mail via SMTP, and execute a JavaScript-like language while the Wii is in standby mode.

Ioctl listing

Inbuf addr & 3 is written to outbuf for most or all ioctls.

Request number Name Input Output Notes
1 ExecSuspendScheduler none 4 bytes
2 ExecTrySuspendScheduler 32 bytes 32 bytes
3 ExecResumeScheduler none 4+ bytes
4 KD_GetTimeTriggers ? 12 bytes Writes the time triggers for the minutes of the hour for when KD_Download and KD_CheckMail are triggered to outbuf + 4.
5 ? ? 4+ bytes
6 NWC24iStartupSocket none 32 bytes
7 NWC24iCleanupSocket none 32 bytes
8 NWC24iLockSocket none 32 bytes
9 NWC24iUnlockSocket none 32 bytes
0xa NWC24iCheckMailNow none 32 bytes
0xb NWC24iSendMailNow none 8+ bytes Connect and send mail?
0xc NWC24iReceiveMailNow ? 8+ bytes
0xd NWC24iSaveMailNow none 32 bytes Saves temporary dlcnt.bin mail content to wc24recv.mbx immediately. Actual outbuf size is 4, outbuf+0 is KD_SaveMail/KD_ProcessMail retval.
0xe NWC24iDownloadNowEx 32 bytes 32 bytes inbuf + 0 u32 is flags, inbuf + 6 u16 is nwc24dl.bin entry index, inbuf + 8 u32 is subTask bitmask. Starting at outbuf + 8 is a buffer of unknown size. Flags bit 1 must be set to manually specify a task/entry. When clear, a task is chosen automatically with the same mechanism used for choosing a task in the background.(When bit 1 is clear with this ioctl from Broadway, nothing will be downloaded since no entries will be ready for download due to dl frequencies fields.) subTask bitmap is a bitmap of subTasks to download when flags bit 2 is set, so setting bit 0 will download subTask zero, and so on. When flags is negative with bit 31 set, KD will sync the current UTC time with the time server. Outbuf+0 is KD_Download retval.
0xf NWC24iRequestGenerateUserId none 32 bytes
0x10 NWC24iRequestRegisterUserId none 32 bytes
0x1e NWC24iGetSchedulerStat none none
0x1f NWC24iSetFilterMode 32 bytes 32 bytes
0x20 NWC24iSetDebugMode 32 bytes 32 bytes
0x21 KD_SetNextWakeup 4 bytes 4 bytes Input is a u32 determining the seconds till next time STM_Wakeup is called.
0x22 NWC24iSetScriptMode 32 bytes 32 bytes
0x28 (async?) NWC24iRequestShutdown 32 bytes 32 bytes Input is a u32 for the event type. This shuts down all KD processes that are running, downloading, mail, NAND writing, etc.

This is called by STM in the Wakeup function to "shut down KD", which can happen in the following cases:

  • /dev/stm/immediate ioctl 0x2005 is used.
  • The console is idle and the DI cover polling thread has detected that the cover was closed (i.e. a disc was inserted).
  • The console is idle and a GPIO event handler is triggered (i.e. the POWER button was pressed).