User Tools

Site Tools


developersguide:rtcprotocol

The RTC protocol

This page provides the official documentation of the RTC device protocol of MINIX 3. It describes the protocol used between the readclock command and the readclock driver as well as the protocol used between readclock and other drivers. The current version documents the protocol used in git commit 039c8db774 and later. If you update this document because of changes to MINIX 3, please mention the commit ID of the change in the wiki comment.

General Overview

The RTC device protocol provides a means of getting and setting the time of hardware clocks. For devices that power off via an alarm, a method for setting the alarm is also provided. Drivers should use the grant based message *_G for communicating with readclock, and user programs should use the pointer based messages. Currently, only PM is allowed to set the power off alarm, and only root is allowed to set the time.

RTCDEV Flags

You may set various flags that affect how the time is written or read. You may bit-wise OR flags. If you don't wish to use any flags, set RTCDEV_FLAGS to RTCDEV_NOFLAGS.

RTCDEV_Y2KBUGInterpret 1980 as 2000 for RTC w/Y2K bug.
RTCDEV_CMOSREGAlso set the CMOS clock register bits.
RTCDEV_NOFLAGSNo flags set.

RTCDEV Messages

RTCDEV_GET_TIME_G

Get the time from the hardware clock.

Request fields

RTCDEV_GRANTm2_i3grantGrant where the time should be stored.
RTCDEV_FLAGSm2_s1shortAny combination of flags or RTCDEV_NOFLAGS.

Reply fields

  • none

Response fields

<16% >RTCDEV_STATUS m2_i2OK or error code

Description

Gets the time from the real time clock and writes it to the grant.

RTCDEV_SET_TIME_G

Set the time in the hardware clock.

Request fields

RTCDEV_GRANTm2_i3grantGrant where the time should be stored.
RTCDEV_FLAGSm2_s1shortAny combination of flags or RTCDEV_NOFLAGS.

Reply fields

  • none

Response fields

<16% >RTCDEV_STATUS m2_i2OK or error code

Description

Sets the time of the real time clock to the time given in the request.

RTCDEV_GET_TIME

Get the time from the hardware clock.

Request fields

RTCDEV_TMm2_p1pointerstruct tm * where the time should be stored.
RTCDEV_FLAGSm2_s1shortAny combination of flags or RTCDEV_NOFLAGS.

Reply fields

  • none

Response fields

<16% >RTCDEV_STATUS m2_i2OK or error code

Description

Gets the time from the real time clock and writes it to the caller's struct tm.

RTCDEV_SET_TIME

Set the time in the hardware clock.

Request fields

RTCDEV_TMm2_p1pointerstruct tm * where the time should be stored.
RTCDEV_FLAGSm2_s1shortAny combination of flags or RTCDEV_NOFLAGS.

Reply fields

  • none

Response fields

<16% >RTCDEV_STATUS m2_i2OK or error code

Description

Sets the time of the real time clock to the time given in the request.

RTCDEV_PWR_OFF

Set the time to cut the power.

Request fields

  • none

Reply fields

  • none

Response fields

<16% >RTCDEV_STATUS m2_i2OK or error code

Description

The BeagleBone and BeagleBone Black use an alarm in the real time clock to power off the the board. Use this message to set the alarm. The alarm is set to 3 seconds from the current time and then the real time clock is disabled. The kernel will re-enable the clock when the system is in a good state to be powered down.

developersguide/rtcprotocol.txt · Last modified: 2014/11/11 08:52 (external edit)