From 99f5b80ae46b4790ab819dc0213ff958d80e82f2 Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Mon, 11 Sep 2023 23:17:46 +0530 Subject: [PATCH] Install FreeRTOS trap handler (#1087) Install FreeRTOS trap handler The application is supposed to program mtvec correctly depending on whether they want to use vectored interrupt or not. Signed-off-by: Gaurav Aggarwal --- FreeRTOS/Demo/RISC-V-Qemu-sifive_e-Eclipse-GCC/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-Eclipse-GCC/main.c b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-Eclipse-GCC/main.c index 529be64e4..147533400 100644 --- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-Eclipse-GCC/main.c +++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-Eclipse-GCC/main.c @@ -1,6 +1,6 @@ /* * FreeRTOS V202212.00 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -49,7 +49,7 @@ * This project has only been tested in the QEMU emulation of the HiFive board * from SiFive. * - * NOTE - Requires QEMU 1908xx or higher. Start QEMU using the following command + * NOTE - Requires QEMU 1908xx or higher. Start QEMU using the following command * line: * * [your_path_1]\qemu-system-riscv32 -kernel [your_path_2]\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-FreedomStudio\Debug\RTOSDemo.elf -S -s -machine sifive_e @@ -95,6 +95,9 @@ void vApplicationIdleHook( void ); void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationTickHook( void ); +/* Trap handler implemented in the portASM.S file. */ +extern void freertos_risc_v_trap_handler( void ); + /* * Very simply polling write to the UART. The full demo only writes single * characters at a time so as not to disrupt the timing of the test and demo @@ -106,6 +109,9 @@ void vSendString( const char * pcString ); int main( void ) { + /* Program mtvec with the FreeRTOS trap handler. */ + __asm__ volatile( "csrw mtvec, %0" :: "r"( freertos_risc_v_trap_handler ) ); + vSendString( "Starting" ); /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top