/dev/net/kd/request

From WiiBrew
< /dev | net | kd
Jump to navigation Jump to search

The main WiiConnect24 calls are done through this device.

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 none 4 bytes
3 ExecResumeScheduler none 4+ bytes
4 KD_GetTimeTriggers none 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 KD_SetTimeTriggers 8 bytes 4 bytes Sets the time triggers mentioned above to the two u32's in inbuf. Both values must be under 259200.
6 NWC24iStartupSocket none 8 bytes
7 NWC24iCleanupSocket none 8 bytes
8 NWC24iLockSocket none 8 bytes
9 NWC24iUnlockSocket none 4 bytes
0xa NWC24iCheckMailNow none 16 bytes
0xb NWC24iSendMailNow none 8 bytes Connect and send mail?
0xc NWC24iReceiveMailNow none 8 bytes
0xd NWC24iSaveMailNow none 4 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 12 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 16 bytes
0x10 NWC24iRequestRegisterUserId none 8 bytes
0x1e NWC24iGetSchedulerStat[check] none 16-256 bytes
0x1f NWC24iSetFilterMode 8 bytes 4 bytes
0x20 NWC24iSetDebugMode 4 bytes 4 bytes
0x21 KD_SetNextWakeup 4 bytes 4 bytes Input is a u32 determining the seconds till next time STM_Wakeup is called.
0x22 NWC24iSetScriptMode 4 bytes 4 bytes
0x28 (async?) NWC24iRequestShutdown 8 bytes 4 bytes Input is a u32 for the event type.

Set a shutdown event flag.

If the type is 3, this simply turns off the USB keyboard LEDs and returns 0.

Otherwise, this calls KD_ForceCleanupSoCtrl internally and the flag that is set will cause all KD processes that are running (downloading, mail, NAND writing, etc.) to stop.

STM calls this ioctl 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).