NMSIS-Core
Version 1.3.1
NMSIS-Core support for Nuclei processor-based devices
|
Functions for system and clock setup available in system_<device>.c. More...
Modules | |
Interrupt and Exception and NMI Handling | |
Functions for interrupt, exception and nmi handle available in system_<device>.c. | |
Macros | |
#define | FALLBACK_DEFAULT_ECLIC_BASE 0x0C000000UL |
#define | FALLBACK_DEFAULT_SYSTIMER_BASE 0x02000000UL |
#define | CLINT_MSIP(base, hartid) (*(volatile uint32_t *)((uintptr_t)((base) + ((hartid) * 4)))) |
#define | SMP_CTRLREG(base, ofs) (*(volatile uint32_t *)((uintptr_t)((base) + (ofs)))) |
Typedefs | |
typedef void(* | fnptr) (void) |
Functions | |
void | default_intexc_handler (void) |
default eclic interrupt or exception interrupt handler More... | |
void | SystemCoreClockUpdate (void) |
Function to update the variable SystemCoreClock. More... | |
void | SystemInit (void) |
Function to Initialize the system. More... | |
void | SystemBannerPrint (void) |
Banner Print for Nuclei SDK. More... | |
void | ECLIC_Init (void) |
initialize eclic config More... | |
int32_t | ECLIC_Register_IRQ (IRQn_Type IRQn, uint8_t shv, ECLIC_TRIGGER_Type trig_mode, uint8_t lvl, uint8_t priority, void *handler) |
Initialize a specific IRQ and register the handler. More... | |
int32_t | ECLIC_Register_IRQ_S (IRQn_Type IRQn, uint8_t shv, ECLIC_TRIGGER_Type trig_mode, uint8_t lvl, uint8_t priority, void *handler) |
Initialize a specific IRQ and register the handler for supervisor mode. More... | |
static void | _get_iregion_info (IRegion_Info_Type *iregion) |
Get Nuclei Internal Region Information. More... | |
void | __sync_harts (void) |
Synchronize all harts. More... | |
static void | Trap_Init (void) |
do the init for trap(interrupt and exception) entry for supervisor mode More... | |
void | _premain_init (void) |
early init function before main More... | |
void | _postmain_fini (int status) |
finish function after main More... | |
void | _init (void) |
_init function called in __libc_init_array() More... | |
void | _fini (void) |
_fini function called in __libc_fini_array() More... | |
Variables | |
fnptr | irq_entry_s |
default entry for s-mode non-vector irq entry More... | |
fnptr | exc_entry_s |
default entry for s-mode exception entry More... | |
volatile uint32_t | SystemCoreClock = SYSTEM_CLOCK |
Variable to hold the system core clock value. More... | |
volatile IRegion_Info_Type | SystemIRegionInfo |
Nuclei RISC-V CPU IRegion Information Variable used to store probed info. More... | |
Functions for system and clock setup available in system_<device>.c.
Nuclei provides a template file system_Device.c that must be adapted by the silicon vendor to match their actual device. As a minimum requirement, this file must provide:
The file configures the device and, typically, initializes the oscillator (PLL) that is part of the microcontroller device. This file might export other functions or variables that provide a more flexible configuration of the microcontroller system.
And this file also provided common interrupt, exception and NMI exception handling framework template, Silicon vendor can customize these template code as they want.
SystemCoreClock
. This variable might be used throughout the whole system initialization and runtime to calculate frequency/time related values. Thus one must assure that the variable always reflects the actual system clock speed.SystemCoreClock
during low level initialization (i.e. SystemInit()
) might get overwritten by C libray startup code and/or .bss section initialization. Thus its highly recommended to call SystemCoreClockUpdate at the beginning of the user main()
routine. #define CLINT_MSIP | ( | base, | |
hartid | |||
) | (*(volatile uint32_t *)((uintptr_t)((base) + ((hartid) * 4)))) |
Definition at line 681 of file system_Device.c.
#define FALLBACK_DEFAULT_ECLIC_BASE 0x0C000000UL |
Definition at line 649 of file system_Device.c.
#define FALLBACK_DEFAULT_SYSTIMER_BASE 0x02000000UL |
Definition at line 650 of file system_Device.c.
#define SMP_CTRLREG | ( | base, | |
ofs | |||
) | (*(volatile uint32_t *)((uintptr_t)((base) + (ofs)))) |
Definition at line 682 of file system_Device.c.
typedef void(* fnptr) (void) |
Definition at line 74 of file system_Device.c.
void __sync_harts | ( | void | ) |
Synchronize all harts.
This function is used to synchronize all the harts, especially to wait the boot hart finish initialization of data section, bss section and c runtines initialization This function must be placed in .text.init section, since section initialization is not ready, global variable and static variable should be avoid to use in this function, and avoid to call other functions
Definition at line 684 of file system_Device.c.
void _fini | ( | void | ) |
_fini function called in __libc_fini_array()
This __libc_fini_array()
function is called when exit main. user need to implement this function, otherwise when link it will error fini.c:(.text.__libc_fini_array+0x28): undefined reference to ‘_fini’
Definition at line 884 of file system_Device.c.
|
static |
Get Nuclei Internal Region Information.
This function is used to get nuclei cpu internal region information, such as iregion base, eclic base, smp base, timer base and idu base, and fallback to old evalsoc timer and eclic base if no iregion feature found
Definition at line 662 of file system_Device.c.
void _init | ( | void | ) |
_init function called in __libc_init_array()
This __libc_init_array()
function is called during startup code, user need to implement this function, otherwise when link it will error init.c:(.text.__libc_init_array+0x26): undefined reference to ‘_init’
Definition at line 870 of file system_Device.c.
void _postmain_fini | ( | int | status | ) |
finish function after main
[in] | status | status code return from main |
This function is executed right after main function. For RISC-V gnu toolchain, _fini function might not be called by __libc_fini_array function, so we defined a new function to do initialization
Definition at line 854 of file system_Device.c.
void _premain_init | ( | void | ) |
early init function before main
This function is executed right before main function. For RISC-V gnu toolchain, _init function might not be called by __libc_init_array function, so we defined a new function to do initialization.
Definition at line 774 of file system_Device.c.
void default_intexc_handler | ( | void | ) |
default eclic interrupt or exception interrupt handler
void ECLIC_Init | ( | void | ) |
initialize eclic config
ECLIC needs be initialized after boot up, Vendor could also change the initialization configuration.
Definition at line 553 of file system_Device.c.
int32_t ECLIC_Register_IRQ | ( | IRQn_Type | IRQn, |
uint8_t | shv, | ||
ECLIC_TRIGGER_Type | trig_mode, | ||
uint8_t | lvl, | ||
uint8_t | priority, | ||
void * | handler | ||
) |
Initialize a specific IRQ and register the handler.
This function set vector mode, trigger mode and polarity, interrupt level and priority, assign handler for specific IRQn.
[in] | IRQn | NMI interrupt handler address |
[in] | shv | ECLIC_NON_VECTOR_INTERRUPT means non-vector mode, and ECLIC_VECTOR_INTERRUPT is vector mode |
[in] | trig_mode | see ECLIC_TRIGGER_Type |
[in] | lvl | interupt level |
[in] | priority | interrupt priority |
[in] | handler | interrupt handler, if NULL, handler will not be installed |
Definition at line 583 of file system_Device.c.
int32_t ECLIC_Register_IRQ_S | ( | IRQn_Type | IRQn, |
uint8_t | shv, | ||
ECLIC_TRIGGER_Type | trig_mode, | ||
uint8_t | lvl, | ||
uint8_t | priority, | ||
void * | handler | ||
) |
Initialize a specific IRQ and register the handler for supervisor mode.
This function set vector mode, trigger mode and polarity, interrupt level and priority, assign handler for specific IRQn.
[in] | IRQn | NMI interrupt handler address |
[in] | shv | ECLIC_NON_VECTOR_INTERRUPT means non-vector mode, and ECLIC_VECTOR_INTERRUPT is vector mode |
[in] | trig_mode | see ECLIC_TRIGGER_Type |
[in] | lvl | interupt level |
[in] | priority | interrupt priority |
[in] | handler | interrupt handler, if NULL, handler will not be installed |
Definition at line 624 of file system_Device.c.
void SystemBannerPrint | ( | void | ) |
void SystemCoreClockUpdate | ( | void | ) |
Function to update the variable SystemCoreClock.
Updates the variable SystemCoreClock and must be called whenever the core clock is changed during program execution. The function evaluates the clock register settings and calculates the current core clock.
Definition at line 231 of file system_Device.c.
void SystemInit | ( | void | ) |
Function to Initialize the system.
Initializes the microcontroller system. Typically, this function configures the oscillator (PLL) that is part of the microcontroller device. For systems with a variable clock speed, it updates the variable SystemCoreClock. SystemInit is called from the file startup_device.
Definition at line 249 of file system_Device.c.
|
static |
do the init for trap(interrupt and exception) entry for supervisor mode
This function provide initialization of CSR_STVT CSR_STVT2 and CSR_STVEC.
Definition at line 744 of file system_Device.c.
fnptr exc_entry_s |
default entry for s-mode exception entry
fnptr irq_entry_s |
default entry for s-mode non-vector irq entry
volatile uint32_t SystemCoreClock = SYSTEM_CLOCK |
Variable to hold the system core clock value.
Holds the system core clock, which is the system clock frequency supplied to the SysTick timer and the processor core clock. This variable can be used by debuggers to query the frequency of the debug timer or to configure the trace clock speed.
Definition at line 218 of file system_Device.c.
volatile IRegion_Info_Type SystemIRegionInfo |
Nuclei RISC-V CPU IRegion Information Variable used to store probed info.
Definition at line 653 of file system_Device.c.