|
KallistiOS git master
Independent SDK for the Sega Dreamcast
|
SH4 CPU peripheral providing timers and counters More...
Topics | |
| Channels | |
| TMU channel constants | |
| Direct-Access | |
| Low-level timer driver | |
| Primary Timer | |
| Primary timer used by the kernel. | |
| Uptime | |
| Maintaining time since system boot. | |
Files | |
| file | timer.h |
| Timer functionality. | |
| file | timer.h |
| Low-level timer functionality. | |
Functions | |
| static timespec_t | timer_gettime (void) |
| Get the current uptime of the system. | |
| static uint64_t | timer_ms_gettime64 (void) |
| Get the current uptime of the system (in milliseconds). | |
| static uint64_t | timer_us_gettime64 (void) |
| Get the current uptime of the system (in microseconds). | |
| static uint64_t | timer_ns_gettime64 (void) |
| Get the current uptime of the system (in nanoseconds). | |
| static void | timer_ms_gettime (uint32_t *secs, uint32_t *msecs) |
| Get the current uptime of the system (in secs and millisecs). | |
| static void | timer_us_gettime (uint32_t *secs, uint32_t *usecs) |
| Get the current uptime of the system (in secs and microsecs). | |
| static void | timer_ns_gettime (uint32_t *secs, uint32_t *nsecs) |
| Get the current uptime of the system (in secs and nanosecs). | |
| static void | timer_spin_delay_us (unsigned short us) |
| Spin-loop delay function with microsecond granularity. | |
| static void | timer_spin_delay_ns (unsigned short ns) |
| Spin-loop delay function with nanosecond granularity. | |
| Do not use | timer_spin_sleep () |
| Spin-loop delay function with millisecond granularity. | |
SH4 CPU peripheral providing timers and counters
The Dreamcast's SH4 includes an on-chip Timer Unit (TMU) containing 3 independent 32-bit channels (TMU0-TMU2). Each channel provides a down-counter with automatic reload and can be configured to use 1 of 7 divider circuits for its input clock. By default, KOS uses the fastest input clock for each TMU channel, providing a maximum internal resolution of 80ns ticks.
|
inlinestatic |
Get the current uptime of the system.
This function retrieves the number of seconds and nanoseconds since KOS was started.
References arch_timer_gettime().
Referenced by timer_ms_gettime(), timer_ms_gettime64(), timer_ns_gettime(), timer_ns_gettime64(), timer_us_gettime(), and timer_us_gettime64().
Get the current uptime of the system (in secs and millisecs).
This function retrieves the number of seconds and milliseconds since KOS was started.
| secs | A pointer to store the number of seconds since boot into. |
| msecs | A pointer to store the number of milliseconds past a second since boot. |
References timer_gettime(), and uint32_t().
|
inlinestatic |
Get the current uptime of the system (in milliseconds).
This function retrieves the number of milliseconds since KOS was started. It is equivalent to calling timer_ms_gettime() and combining the number of seconds and milliseconds into one 64-bit value.
References timer_gettime().
Referenced by thd_sleep().
Get the current uptime of the system (in secs and nanosecs).
This function retrieves the number of seconds and nanoseconds since KOS was started.
| secs | A pointer to store the number of seconds since boot into. |
| nsecs | A pointer to store the number of nanoseconds past a second since boot. |
References timer_gettime(), and uint32_t().
|
inlinestatic |
Get the current uptime of the system (in nanoseconds).
This function retrieves the number of nanoseconds since KOS was started.
References timer_gettime().
Referenced by timer_spin_delay_ns().
|
inlinestatic |
Spin-loop delay function with nanosecond granularity.
This function is meant as a very accurate delay function, even if threading and interrupts are disabled. It is a delay and not a sleep, which means that the CPU will be busy-looping during that time frame.
Note that the parameter is 16-bit, which means that the maximum acceptable value is 65535 nanoseconds.
| ns | The number of nanoseconds to wait for. |
References timer_ns_gettime64().
|
inlinestatic |
Spin-loop delay function with microsecond granularity.
This function is meant as a very accurate delay function, even if threading and interrupts are disabled. It is a delay and not a sleep, which means that the CPU will be busy-looping during that time frame. For any time frame bigger than a few hundred microseconds, it is recommended to sleep instead.
Note that the parameter is 16-bit, which means that the maximum acceptable value is 65535 microseconds.
| us | The number of microseconds to wait for. |
References timer_us_gettime64().
| Do not use timer_spin_sleep | ( | ) |
Spin-loop delay function with millisecond granularity.
This function should never be used, and is only used for compatibility with older code. It makes no sense to busy-wait for that long.
| ms | The number of microseconds to wait for. |
Get the current uptime of the system (in secs and microsecs).
This function retrieves the number of seconds and microseconds since KOS was started.
| secs | A pointer to store the number of seconds since boot into. |
| usecs | A pointer to store the number of microseconds past a second since boot. |
References timer_gettime(), and uint32_t().
|
inlinestatic |
Get the current uptime of the system (in microseconds).
This function retrieves the number of microseconds since KOS was started.
References timer_gettime().
Referenced by timer_spin_delay_us().