CLINT
- group CLINT Driver
Core Local Interruptor (CLINT) driver implementation for Chimera-SDK.
Functions
-
clint_mtime_t clint_get_mtime(void)
Retrieves the current CLINT mtime value.
- Returns:
The current CLINT timer value.
-
int clint_mtime_less_than(clint_mtime_t a, clint_mtime_t b)
Compares two CLINT mtime values.
- Parameters:
a – First CLINT time value.
b – Second CLINT time value.
- Returns:
1 if a is less than b, 0 otherwise.
-
void clint_spin_until(clint_mtime_t tgt_mtime)
Spins (busy-waits) until the specified CLINT mtime value is reached.
- Parameters:
tgt_mtime – Target CLINT time value.
-
void clint_spin_ticks(uint32_t ticks)
Spins (busy-waits) for a given number of ticks.
- Parameters:
ticks – Number of clock cycles to wait.
-
uint32_t clint_get_core_freq(uint32_t ref_freq, uint32_t ref_time_inv)
Estimates the core frequency based on a reference measurement period.
The parameter
ref_time_invis the inverse of the measurement period.- Parameters:
ref_freq – Reference frequency in Hz.
ref_time_inv – Inverse of the measurement period.
- Returns:
Estimated core frequency in Hz.
-
void clint_set_mtimecmpx(uint32_t timer_idx, clint_mtime_t value)
Sets the mtimecmp register for a specific timer index.
- Parameters:
timer_idx – Timer index to configure.
value – Target mtimecmp value.
-
void clint_sleep_until(uint32_t timer_idx, clint_mtime_t tgt_mtime)
Puts the core to sleep until the specified CLINT mtime value is reached.
- Parameters:
timer_idx – Timer index.
tgt_mtime – Target CLINT time value for wakeup.
-
void clint_sleep_ticks(uint32_t timer_idx, uint32_t ticks)
Puts the core to sleep for a specified number of ticks.
- Parameters:
timer_idx – Timer index.
ticks – Number of clock cycles to sleep.
Variables
-
const chi_interrupt_api_t default_clint_api
CLINT’s implementation of the generic interrupt-controller API.
Users should use the
chi_interrupt_t+interrupt_apiabstraction when driving CLINT.
-
chi_interrupt_t default_clint_inst
-
struct clint_mtime_t
- #include <clint.h>
Platform-specific mtime type definition.
In a 64-bit system, clint_mtime_t is typedef’d to uint64_t.
In a 32-bit system, clint_mtime_t is a structure with
.lowand.highmembers.
32-bit representation of mtime (split into low/high).
-
clint_mtime_t clint_get_mtime(void)
64-bit CLINT Driver
The 64-bit CLINT driver implements timer and interrupt functionalities using a 64-bit data type (uint64_t) for the mtime register. This configuration is activated when the PLATFORM_IS_64BIT flag is defined.
- group 64-bit CLINT Driver
64-bit CLINT driver implementation for Chimera-SDK.
This header provides the declarations for the 64-bit CLINT driver. The generic CLINT HAL API functions (declared in hal/inc/clint.h) are aliased to the 64-bit implementations in this driver.
Defines
-
PLATFORM_IS_64BIT
Functions
-
static int clint64_init(const chi_interrupt_t *ctrl)
-
static int clint64_register_handler(const chi_interrupt_t *ctrl, int irq, chi_irq_handler_t handler, void *arg)
-
static int clint64_enable_irq(const chi_interrupt_t *ctrl, int irq)
-
static int clint64_disable_irq(const chi_interrupt_t *ctrl, int irq)
-
static int clint64_set_priority(const chi_interrupt_t *ctrl, int irq, int priority)
-
static int clint64_acknowledge(const chi_interrupt_t *ctrl, int irq)
-
static void clint64_dispatch(const chi_interrupt_t *ctrl)
-
PLATFORM_IS_64BIT
32-bit CLINT Driver
The 32-bit CLINT driver adapts the timer and sleep functionalities for 32-bit platforms by representing the mtime register as a structure with two 32-bit members (low and high). This approach maintains compatibility with 32-bit systems while delivering equivalent performance and functionality as the 64-bit version.
- group 32-bit CLINT Driver
32-bit CLINT driver implementation for Chimera-SDK.
This file provides the implementation of the 32-bit CLINT driver. It includes functions for reading the current time, comparing times, spinning until a target time, and sleeping until a target time.
This header provides the declarations for the 32-bit CLINT driver. The generic CLINT HAL API functions (declared in hal/inc/clint.h) are aliased to the 32-bit implementations in this driver.
Functions
-
static int clint32_init(const chi_interrupt_t *ctrl)
-
static int clint32_register_handler(const chi_interrupt_t *ctrl, int irq, chi_irq_handler_t handler, void *arg)
-
static int clint32_enable_irq(const chi_interrupt_t *ctrl, int irq)
-
static int clint32_disable_irq(const chi_interrupt_t *ctrl, int irq)
-
static int clint32_set_priority(const chi_interrupt_t *ctrl, int irq, int prio)
-
static int clint32_acknowledge(const chi_interrupt_t *ctrl, int irq)
-
static void clint32_dispatch(const chi_interrupt_t *ctrl)
-
static int clint32_init(const chi_interrupt_t *ctrl)