Set the mtvec register in the Spike demonstraction (#794)

* Set the mtvec register to freertos_risc_v_trap_handler
This commit is contained in:
林振凱 2022-02-18 03:01:50 +08:00 committed by GitHub
parent cc8c0266a8
commit 9abd84992b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,11 +31,18 @@
/* Run a simple demo just prints 'Blink' */ /* Run a simple demo just prints 'Blink' */
#define DEMO_BLINKY 1 #define DEMO_BLINKY 1
extern void freertos_risc_v_trap_handler( void );
void vApplicationMallocFailedHook( void ); void vApplicationMallocFailedHook( void );
void vApplicationIdleHook( void ); void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationTickHook( void ); void vApplicationTickHook( void );
/*
* Setup the Spike simulator to run this demo.
*/
static void prvSetupSpike( void );
int main_blinky( void ); int main_blinky( void );
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -43,6 +50,7 @@ int main_blinky( void );
int main( void ) int main( void )
{ {
int ret; int ret;
prvSetupSpike();
#if defined(DEMO_BLINKY) #if defined(DEMO_BLINKY)
ret = main_blinky(); ret = main_blinky();
@ -52,6 +60,11 @@ int main( void )
return ret; return ret;
} }
/*-----------------------------------------------------------*/
static void prvSetupSpike( void )
{
__asm__ volatile( "csrw mtvec, %0" :: "r"( freertos_risc_v_trap_handler ) );
}
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/