unsigned long rtc_time (void)


This is a user-replaceable function responsible for returning the number of seconds since January 1 1970 00:00:00 GMT.

This function defaults to calling rtc_time_mc146818(), which knows how to get the time from an IBM-PC standard clock chip.
The default library version simply returns zero.

Currently, these are the chip-specific versions:

Dallas Semiconductor DS-1386 compatible
SGS-Thomson M48T59 RTC/NVRAM chip
Motorola 146818 compatible
FOX RTC-72423 compatible

There's also a “none” version to use if your board doesn't have RTC hardware:

unsigned long rtc_time_none(void);

If you're supplying the rtc_time() routine, you should call one of the chip-specific routines or write your own. The chip-specific routines all share the same parameter list:

(paddr_t base, unsigned reg_shift, int mmap, int cent_reg);

The base parameter indicates the physical base address or I/O port of the device. The reg_shift indicates the register offset as a power of two.

A typical value would be 0 (meaning 20, i.e. 1), indicating that the registers of the device are one byte apart in the address space. As another example, a value of 2 (meaning 22, i.e. 4) indicates that the registers in the device are four bytes apart.

If the mmap variable is 0, then the device is in I/O space. If mmap is 1, then the device is in memory space.

Finally, cent_reg indicates which register in the device contains the century byte (-1 indicates no such register). If there's no century byte register, then the behavior is chip-specific. If the chip is year 2000-compliant, then we will get the correct time. If the chip isn't compliant, then if the year is less than 70, we assume it's in the range 2000 to 2069; else we assume it's in the range 1970 to 1999.