Difference between revisions of "/dev/net/kd/time"

From WiiBrew
< /dev‎ | net
Jump to navigation Jump to search
(Correct names)
m (added descriptions for the ioctl calls)
Line 45: Line 45:
 
|  
 
|  
 
|}
 
|}
 +
 +
== Detailed Description ==
 +
/dev/net/kd/time is used to get and set utc and rtc offsets. this is used by things like nwc24's scheduler and the module handles reading and editing of /shared2/nwc24/misc.bin
 +
 +
=== KD_GetUTCTime ===
 +
<nowiki>
 +
no inbuffer
 +
outbuffer must be >= 0xC bytes and must be 0x4 aligned
 +
if outbuffer is not >= 0xC bytes or outbuffer == NULL the IOS_Ioctl will return -4, else it returns 0
 +
checks if a word is set in the module's memory that indicates the Universal time is ready and returns -30 in outbuffer->retval if not
 +
outbuffer->time is set to the stored utc otherwise
 +
</nowiki>
 +
 +
=== KD_SetUTCTime ===
 +
<nowiki>
 +
inbuffer must be >= 0xC bytes and must be 0x4 aligned
 +
outbuffer must be >= 0x4 bytes and must be 0x4 aligned
 +
if outbuffer or inbuffer is NULL or are not aligned the IOS_Ioctl will return -4, else it returns 0
 +
struct inbuffer { u64 utc, u32 other_value };
 +
checks that 0x30df3b00 <= utc <= 0xdfaef080 else it sets outbuffer->retval to -3
 +
if utc is ok, it sets the module's struct containing the utc and the other_value
 +
</nowiki>
 +
 +
=== Undefined ===
 +
<nowiki>
 +
no buffers checked
 +
always returns -9 from IOS_Ioctl
 +
</nowiki>
 +
 +
=== NWC24iSetRtcCounter ===
 +
<nowiki>
 +
inbuffer must be >= 0x8 bytes and must be 0x4 aligned
 +
outbuffer must be >= 0x4 bytes and must be 0x4 aligned
 +
if outbuffer or inbuffer is NULL or not aligned the IOS_Ioctl will return -4, else it returns 0
 +
struct inbuffer { u32 rtc_value, u32 other_value };
 +
other_value is checked for the lowest bit to be either 0 or 1 which sets a word in memory
 +
this function messes with the /shared2/nwc24/misc.bin file and by reading and writing utc data to/from it
 +
it also sets utc when it needs to be synchronized due to offset
 +
outbuffer->retval will always hold 0 if the IOS_Ioctl doesn't return -4
 +
</nowiki>
 +
 +
=== NWC24iGetTimeDifference ===
 +
<nowiki>inbuffer is not checked
 +
outbuffer must be >= 0xC bytes and must be 0x4 aligned
 +
if outbuffer is NULL or not aligned the IOS_Ioctl will return -4
 +
if the module's memory indicates no time difference the IOS_Ioctl will return -30
 +
else it returns 0
 +
outbuffer->retval could hold the outbuffer address & 3 if:
 +
a) it wasn't doing a 32bit write to an unaligned address
 +
b) it didn't jump to return -4 from the Ioctl when it was unaligned
 +
so it'll always hold 0
 +
outbuffer->time will hold the timedifference</nowiki>

Revision as of 10:52, 9 February 2012

Ioctl listing

typedef struct _skd_timebuf//This is used by all ioctls for at least outbuf. For ioctl 0x18, inbuf addr & 3 is written to retval.
{
       s32 retval;//Zero for success, -30 when "Universal time is not ready.".
       u64 time;//UTC time in seconds.
} kd_timebuf;
Request number Name Input Output Notes
0x14 NWC24iGetUniversalTime none 12 bytes Writes the current UTC time to inbuf kd_timebuf->time.
0x15 NWC24iSetUniversalTime 12 bytes 4 bytes Sets the current UTC time to inbuf kd_timebuf->time.
0x16 Undefined none none always returns -9
0x17 NWC24iSetRtcCounter 8 bytes 4 bytes Corrects the internal KD RTC by adding the input u64.
0x18 NWC24iGetTimeDifference none 12 bytes

Detailed Description

/dev/net/kd/time is used to get and set utc and rtc offsets. this is used by things like nwc24's scheduler and the module handles reading and editing of /shared2/nwc24/misc.bin

KD_GetUTCTime

no inbuffer outbuffer must be >= 0xC bytes and must be 0x4 aligned if outbuffer is not >= 0xC bytes or outbuffer == NULL the IOS_Ioctl will return -4, else it returns 0 checks if a word is set in the module's memory that indicates the Universal time is ready and returns -30 in outbuffer->retval if not outbuffer->time is set to the stored utc otherwise

KD_SetUTCTime

inbuffer must be >= 0xC bytes and must be 0x4 aligned outbuffer must be >= 0x4 bytes and must be 0x4 aligned if outbuffer or inbuffer is NULL or are not aligned the IOS_Ioctl will return -4, else it returns 0 struct inbuffer { u64 utc, u32 other_value }; checks that 0x30df3b00 <= utc <= 0xdfaef080 else it sets outbuffer->retval to -3 if utc is ok, it sets the module's struct containing the utc and the other_value

Undefined

no buffers checked always returns -9 from IOS_Ioctl

NWC24iSetRtcCounter

inbuffer must be >= 0x8 bytes and must be 0x4 aligned outbuffer must be >= 0x4 bytes and must be 0x4 aligned if outbuffer or inbuffer is NULL or not aligned the IOS_Ioctl will return -4, else it returns 0 struct inbuffer { u32 rtc_value, u32 other_value }; other_value is checked for the lowest bit to be either 0 or 1 which sets a word in memory this function messes with the /shared2/nwc24/misc.bin file and by reading and writing utc data to/from it it also sets utc when it needs to be synchronized due to offset outbuffer->retval will always hold 0 if the IOS_Ioctl doesn't return -4

NWC24iGetTimeDifference

inbuffer is not checked outbuffer must be >= 0xC bytes and must be 0x4 aligned if outbuffer is NULL or not aligned the IOS_Ioctl will return -4 if the module's memory indicates no time difference the IOS_Ioctl will return -30 else it returns 0 outbuffer->retval could hold the outbuffer address & 3 if: a) it wasn't doing a 32bit write to an unaligned address b) it didn't jump to return -4 from the Ioctl when it was unaligned so it'll always hold 0 outbuffer->time will hold the timedifference