[][src]Crate cmos

cmos is a library for interfacing with the CMOS chip found on most motherboards. Along with this generic functionality, there is also added functions for reading the RTC (Real Time Clock).

The implementation is based off of the implementation found on the osdev.org page, where more information can be found.

Notes

Getting date information from the RTC is mostly trivial, except for calculating the year. Some RTC chips support calculating the correct year through a century register, but this is platform specific. This can be done by querying the Fixed ACPI Description Table. More details can be found here. This library also supports providing the current year, through the CMOSCenturyHandler enum as a fallback.

Examples

To get the current RTC time using the current year:

// Create a CMOS object (unsafe due to the use of port I/O)
let mut cmos = unsafe { CMOS::new() };
// Read the rtc date time using this year
let rtc = cmos.read_rtc(CMOSCenturyHandler::CurrentYear(2018));

To get the current RTC tiem by passing in the century register num:

// Create a CMOS object (unsafe due to the use of port I/O)
let mut cmos = unsafe { CMOS::new() };
// Read the rtc date time using this year
let rtc = cmos.read_rtc(CMOSCenturyHandler::CenturyRegister(0xA5));

Structs

CMOS

The standard CMOS struct

RTCDateTime

Results struct from reading RTC with self-explanatory fields

Enums

CMOSCenturyHandler

Enum for determining how to calculate the year when reading the RTC