Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
Loading...
Searching...
No Matches

Overview

Function definitions for CLINT driver.

Functions

void clint_uDelay (u32 usec, u32 hz)
 This function introduces a microsecond delay using the CLINT TIME register.

CLINT (Get Functions)

Retrieve value from CLINT register.

double clint_timerSub (u64 t0, u64 t1)
 Get the time difference between t0 and t1.
u64 clint_getTime ()
 Reads the current time value from the CLINT TIME register.
u32 clint_getTimeLow ()
 Reads the low part of the current time.
u32 clint_getTimeHigh ()
 Reads the high part of the current time.
u32 clint_get_SoftInterrupt (u32 hart_id)
 Obtain the current state of the software interrupt for a specific hart.

CLINT (Set Functions)

Set value to CLINT register.

void clint_setCmp (u64 cmp, u32 hart_id)
 This function sets the compare value for the CLINT CMP register for a specific hardware thread.
void clint_set_SoftInterrupt (clint_msip_t enable, u32 hart_id)
 Sets the software interrupt state for a specific hart.

Function Documentation

◆ clint_get_SoftInterrupt()

u32 clint_get_SoftInterrupt ( u32 hart_id)

#include <clint.h>

Obtain the current state of the software interrupt for a specific hart.

Parameters
hart_idThe ID of the hart for which to read the software interrupt state

Definition at line 39 of file clint.c.

◆ clint_getTime()

u64 clint_getTime ( )

#include <clint.h>

Reads the current time value from the CLINT TIME register.

Returns
The current time as a 64-bit unsigned integer.

The function reads the high and low 32-bit parts of the CLINT TIME register in a loop to ensure a consistent snapshot of the time value. It first reads the high part, then the low part, and finally checks if the high part has changed during the read. If it has changed, it repeats the process until a consistent value is obtained. The final 64-bit time value is constructed by combining the high and low parts.

Definition at line 45 of file clint.c.

◆ clint_getTimeHigh()

u32 clint_getTimeHigh ( )

#include <clint.h>

Reads the high part of the current time.

Note
Reads a 32-bit unsigned integer value from the CLINT TIME register offset by 4 bytes (representing the high part).

Definition at line 33 of file clint.c.

◆ clint_getTimeLow()

u32 clint_getTimeLow ( )

#include <clint.h>

Reads the low part of the current time.

Note
Reads a 32-bit unsigned integer value from the CLINT TIME register.

Definition at line 27 of file clint.c.

◆ clint_set_SoftInterrupt()

void clint_set_SoftInterrupt ( clint_msip_t enable,
u32 hart_id )

#include <clint.h>

Sets the software interrupt state for a specific hart.

Parameters
enableThe desired state of the software interrupt (enable or disable).
hart_idThe ID of the hart for which to set the software interrupt state.

Definition at line 72 of file clint.c.

◆ clint_setCmp()

void clint_setCmp ( u64 cmp,
u32 hart_id )

#include <clint.h>

This function sets the compare value for the CLINT CMP register for a specific hardware thread.

Parameters
cmpis the 64-bit compare value to be set in the CMP register.
hart_idis the ID of the hardware thread for which the compare value is being set.
Note
The function calculates the address offset for the CMP register associated with the specified hardware thread and writes the lower 32 bits of the compare value to the lower 32 bits of the CMP register, the upper 32 bits of the compare value to the upper 32 bits of the CMP register, and sets the lower 32 bits to all 1s (0xFFFFFFFF) to ensure the compare value is treated as an absolute value.

Definition at line 56 of file clint.c.

◆ clint_timerSub()

double clint_timerSub ( u64 t0,
u64 t1 )

#include <clint.h>

Get the time difference between t0 and t1.

Parameters
t0Time 1
t1Time 2
Returns
Time Difference between t0 and t1.

Definition at line 77 of file clint.c.

◆ clint_uDelay()

void clint_uDelay ( u32 usec,
u32 hz )

#include <clint.h>

This function introduces a microsecond delay using the CLINT TIME register.

Parameters
usecis the delay time in microseconds.
hzis the frequency of the timer in Hz.
Note
The function calculates the number of machine cycles per microsecond based on the given timer frequency 'hz'. It then calculates the time limit by adding the delay 'usec' in microseconds to the current time obtained from the CLINT TIME register. The function enters a loop, continuously checking if the difference between the current time and the time limit is non-negative, indicating that the delay has not yet elapsed.

Definition at line 64 of file clint.c.