next up previous contents
Next: Cache Coherency Management Up: Hardware Abstraction Layer: Portable Previous: MMU Management   Contents

Subsections

Timer Management

Every platform should contain at least one available timer interrupt. These functions manage that timer interrupt and any others that may be available.

The DC part is relevant enough here that I'm going to go ahead and document it as well for this part.

Totally Portable Parts

void timer_ms_gettime(uint32 * secs, uint32 * msecs)

Returns the number of seconds and milliseconds since the program was started. This is for fine timing where the time of day doesn't really matter.

int timer_ints_enabled(int which)

Returns non-zero if the requested timer is enabled. The value of which is entirely platform dependent, but you can always use the constant TIMER_ID to refer to the primary timer that is used for threading and such.

void timer_disable_ints(int which)

Disables interrupts for the requested timer.

void timer_enable_ints(int which)

Enables interrupts for the requested timer.

void timer_spin_sleep(int ms)

Precise spin-loop sleep function. On the DC, this function does not interfere in any way with threading or other timer usage because it uses TMU1. On other platforms, this may be different.

void timer_primary_enable()

Enable the "primary" timer - start it counting and enable any associated interrupts. This is generally the timer used by pre-emptive threading.

void timer_primary_disable()

Disable the "primary" timer.

DC Parts

The SH-4 contains four usable timers, and we support three. These are TMU0, TMU1, and TMU2. TMU0 is the "primary" timer, TMU1 is used by timer_spin_sleep, and the other is available for programmer usage.

int timer_prime(int which, uint32 speed, int interrupts)

Pre-initialize a timer; setup the values but don't actually start it running. Timer which will be set to expire in speed milliseconds, and if interrupts is non-zero, interrupts will be enabled for it.

int timer_start(int which)

Starts the requested timer actually running.

int timer_stop(int which)

Stops the requested timer from running.

uint32 timer_count(int which)

Returns the count value of the requested timer.

int timer_clear(int which)

Clears the underflow bit of the requested timer and returns what its count value was.


next up previous contents
Next: Cache Coherency Management Up: Hardware Abstraction Layer: Portable Previous: MMU Management   Contents
Dan Potter 2002-07-29