Clock device

This is the specification for the clock device of the Bedrock computer system.

This document is aimed at people who are implementing the Bedrock system from scratch. For people who are learning about or writing program for the Bedrock system, the clock device manual will generally be more useful.

Concepts

Countdown timer

A countdown timer is an unsigned 16 bit integer. The value of a timer will decrement by 1 for each full 1/256 second duration elapsed, stopping at zero. The initial value of each timer is zero.

This device contains four countdown timers: one for each of the four timer port groups.

Ports

Port Name Description Read Write
0x30 Year Current year.
0x31 Month Current month of the year.
0x32 Day Current day of the month.
0x33 Hour Current hour of the day.
0x34 Minute Current minute of the hour.
0x35 Second Current second of the minute.
0x36 Uptime Incrementing uptime counter.
0x37 grouped grouped
0x38 Timer Countdown timer 1.
0x39 grouped grouped
0x3A Timer Countdown timer 2.
0x3B grouped grouped
0x3C Timer Countdown timer 3.
0x3D grouped grouped
0x3E Timer Countdown timer 4.
0x3F grouped grouped

Year

Reading from this port will return the number of full years elapsed since the start of the year 2000. The value returned after the year 2255 is undefined.

Writing to this port will optionally set the year on the clock to the value written.

Month

Reading from this port will return the number of full months elapsed since the start of the year.

Writing to this port will optionally set the month on the clock to the value written.

Day

Reading from this port will return the number of full days elapsed since the start of the month.

Writing to this port will optionally set the day on the clock to the value written.

Hour

Reading from this port will return the number of full hours elapsed since the start of the day.

Writing to this port will optionally set the hour on the clock to the value written.

Minute

Reading from this port will return the number of full minutes elapsed since the start of the hour.

Writing to this port will optionally set the minute on the clock to the value written.

Second

Reading from this port will return the number of full seconds elapsed since the start of the minute. The value returned during a leap second is undefined.

Writing to this port will optionally set the second on the clock to the value written.

Uptime

Reading from this port group will perform an atomic read, returning the number of full 1/256 second durations elapsed since the system was last reset. The value will wrap to zero on overflow.

Timer

Each timer port group is associated with a countdown timer.

Reading from one of these port groups will perform an atomic read, returning the value of the associated timer. Writing to one of these port groups will perform an atomic write, setting the timer to the value written on commit.

Wake behaviour

This device will send a wake request to the system device when a countdown timer decrements to zero.