mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
First task running in RISC-V-Qemu-sifive_e-FreedomStudio demo.
This commit is contained in:
parent
d0ef322b13
commit
dc99300fa9
|
@ -1021,7 +1021,7 @@ void vApplicationMallocFailedHook( void )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvTimerCallback( TaskHandle_t xExpiredTimer )
|
static void prvTimerCallback( TimerHandle_t xExpiredTimer )
|
||||||
{
|
{
|
||||||
uint32_t ulCount;
|
uint32_t ulCount;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.8320194" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.8320194" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.379436257" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting" useByScannerDiscovery="false"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.379436257" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting" useByScannerDiscovery="false"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1043841176" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1043841176" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.383399415" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.more" valueType="enumerated"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.383399415" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.none" valueType="enumerated"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.178339006" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.178339006" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.119459497" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.119459497" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.735578493" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.735578493" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||||
|
@ -49,10 +49,10 @@
|
||||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1472778604" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1472778604" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.874608690" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.874608690" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.545620458" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.545620458" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value="../../../../bsp/env"/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/env}""/>
|
||||||
<listOptionValue builtIn="false" value="../../../../bsp/include"/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/include}""/>
|
||||||
<listOptionValue builtIn="false" value="../../../../bsp/env/freedom-e300-hifive1"/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/env/freedom-e300-hifive1}""/>
|
||||||
<listOptionValue builtIn="false" value="../../../../bsp/drivers"/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/drivers}""/>
|
||||||
</option>
|
</option>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.855588508" name="Other assembler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="-c" valueType="string"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.855588508" name="Other assembler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="-c" valueType="string"/>
|
||||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1208356864" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1208356864" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
|
||||||
|
@ -68,10 +68,12 @@
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/include}""/>
|
||||||
</option>
|
</option>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.1115817835" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.1115817835" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="USE_PLIC"/>
|
<listOptionValue builtIn="false" value="DONT_USE_PLIC"/>
|
||||||
<listOptionValue builtIn="false" value="USE_M_TIME"/>
|
<listOptionValue builtIn="false" value="DONT_USE_M_TIME"/>
|
||||||
</option>
|
</option>
|
||||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.953712529" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="-include sys/cdefs.h -fno-builtin-printf -c" valueType="string"/>
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.953712529" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="-include sys/cdefs.h -fno-builtin-printf -c" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.1963706020" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.default" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations.1382786252" name="Other optimization flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.517786622" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.517786622" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.890064572" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler"/>
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.890064572" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler"/>
|
||||||
|
@ -112,7 +114,7 @@
|
||||||
</toolChain>
|
</toolChain>
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry excluding="freedom-e-sdk/env/entry.S" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1914048489906665533" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1967898482140670668" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
#ifndef FREERTOS_CONFIG_H
|
#ifndef FREERTOS_CONFIG_H
|
||||||
#define FREERTOS_CONFIG_H
|
#define FREERTOS_CONFIG_H
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
/*-----------------------------------------------------------
|
/*-----------------------------------------------------------
|
||||||
* Application specific definitions.
|
* Application specific definitions.
|
||||||
|
@ -84,7 +85,7 @@
|
||||||
* See http://www.freertos.org/a00110.html.
|
* See http://www.freertos.org/a00110.html.
|
||||||
*----------------------------------------------------------*/
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
#define configCTRL_BASE 0x2000000
|
#define configCLINT_BASE_ADDRESS CLINT_CTRL_ADDR
|
||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
#define configUSE_IDLE_HOOK 0
|
#define configUSE_IDLE_HOOK 0
|
||||||
#define configUSE_TICK_HOOK 0
|
#define configUSE_TICK_HOOK 0
|
||||||
|
@ -92,7 +93,7 @@
|
||||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||||
#define configMAX_PRIORITIES ( 5 )
|
#define configMAX_PRIORITIES ( 5 )
|
||||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 512 )
|
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 512 )
|
||||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) )
|
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 8 * 1024 ) )
|
||||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||||
#define configUSE_TRACE_FACILITY 1
|
#define configUSE_TRACE_FACILITY 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
|
|
|
@ -0,0 +1,255 @@
|
||||||
|
/*
|
||||||
|
* FreeRTOS Kernel V10.1.1
|
||||||
|
* Copyright (C) 2018 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
|
||||||
|
* the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* http://www.FreeRTOS.org
|
||||||
|
* http://aws.amazon.com/freertos
|
||||||
|
*
|
||||||
|
* 1 tab == 4 spaces!
|
||||||
|
*/
|
||||||
|
|
||||||
|
.extern ulRegTest1LoopCounter
|
||||||
|
.extern ulRegTest2LoopCounter
|
||||||
|
|
||||||
|
.global vRegTest1Task
|
||||||
|
.global vRegTest2Task
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
vRegTest1Task:
|
||||||
|
|
||||||
|
/* Fill the core registers with known values. */
|
||||||
|
li x5, 0x5
|
||||||
|
li x6, 0x6
|
||||||
|
li x7, 0x7
|
||||||
|
li x8, 0x8
|
||||||
|
li x9, 0x9
|
||||||
|
li x10, 0xa
|
||||||
|
li x11, 0xb
|
||||||
|
li x12, 0xc
|
||||||
|
li x13, 0xd
|
||||||
|
li x14, 0xe
|
||||||
|
li x15, 0xf
|
||||||
|
li x16, 0x10
|
||||||
|
li x17, 0x11
|
||||||
|
li x18, 0x12
|
||||||
|
li x19, 0x13
|
||||||
|
li x20, 0x14
|
||||||
|
li x21, 0x15
|
||||||
|
li x22, 0x16
|
||||||
|
li x23, 0x17
|
||||||
|
li x24, 0x18
|
||||||
|
li x25, 0x19
|
||||||
|
li x26, 0x1a
|
||||||
|
li x27, 0x1b
|
||||||
|
li x28, 0x1c
|
||||||
|
li x29, 0x1d
|
||||||
|
li x30, 0x1e
|
||||||
|
|
||||||
|
reg1_loop:
|
||||||
|
|
||||||
|
/* Check each register still contains the expected known value.
|
||||||
|
vRegTest1Implementation uses x31 as the temporary, vRegTest2Implementation
|
||||||
|
uses x5 as the temporary. */
|
||||||
|
li x31, 0x5
|
||||||
|
bne x31, x5, reg1_error_loop
|
||||||
|
li x31, 0x6
|
||||||
|
bne x31, x6, reg1_error_loop
|
||||||
|
li x31, 0x7
|
||||||
|
bne x31, x7, reg1_error_loop
|
||||||
|
li x31, 0x8
|
||||||
|
bne x31, x8, reg1_error_loop
|
||||||
|
li x31, 0x9
|
||||||
|
bne x31, x9, reg1_error_loop
|
||||||
|
li x31, 0xa
|
||||||
|
bne x31, x10, reg1_error_loop
|
||||||
|
li x31, 0xb
|
||||||
|
bne x31, x11, reg1_error_loop
|
||||||
|
li x31, 0xc
|
||||||
|
bne x31, x12, reg1_error_loop
|
||||||
|
li x31, 0xd
|
||||||
|
bne x31, x13, reg1_error_loop
|
||||||
|
li x31, 0xe
|
||||||
|
bne x31, x14, reg1_error_loop
|
||||||
|
li x31, 0xf
|
||||||
|
bne x31, x15, reg1_error_loop
|
||||||
|
li x31, 0x10
|
||||||
|
bne x31, x16, reg1_error_loop
|
||||||
|
li x31, 0x11
|
||||||
|
bne x31, x17, reg1_error_loop
|
||||||
|
li x31, 0x12
|
||||||
|
bne x31, x18, reg1_error_loop
|
||||||
|
li x31, 0x13
|
||||||
|
bne x31, x19, reg1_error_loop
|
||||||
|
li x31, 0x14
|
||||||
|
bne x31, x20, reg1_error_loop
|
||||||
|
li x31, 0x15
|
||||||
|
bne x31, x21, reg1_error_loop
|
||||||
|
li x31, 0x16
|
||||||
|
bne x31, x22, reg1_error_loop
|
||||||
|
li x31, 0x17
|
||||||
|
bne x31, x23, reg1_error_loop
|
||||||
|
li x31, 0x18
|
||||||
|
bne x31, x24, reg1_error_loop
|
||||||
|
li x31, 0x19
|
||||||
|
bne x31, x25, reg1_error_loop
|
||||||
|
li x31, 0x1a
|
||||||
|
bne x31, x26, reg1_error_loop
|
||||||
|
li x31, 0x1b
|
||||||
|
bne x31, x27, reg1_error_loop
|
||||||
|
li x31, 0x1c
|
||||||
|
bne x31, x28, reg1_error_loop
|
||||||
|
li x31, 0x1d
|
||||||
|
bne x31, x29, reg1_error_loop
|
||||||
|
li x31, 0x1e
|
||||||
|
bne x31, x30, reg1_error_loop
|
||||||
|
|
||||||
|
/* Everything passed, increment the loop counter. */
|
||||||
|
lw x31, ulRegTest1LoopCounterConst
|
||||||
|
lw x30, 0(x31)
|
||||||
|
addi x30, x30, 1
|
||||||
|
sw x30, 0(x31)
|
||||||
|
|
||||||
|
/* Restore clobbered register reading for next loop. */
|
||||||
|
li x30, 0x1e
|
||||||
|
|
||||||
|
/* Yield to increase code coverage. */
|
||||||
|
ecall
|
||||||
|
|
||||||
|
/* Start again. */
|
||||||
|
jal reg1_loop
|
||||||
|
|
||||||
|
reg1_error_loop:
|
||||||
|
/* Jump here if a register contains an uxpected value. This stops the loop
|
||||||
|
counter being incremented so the check task knows an error was found. */
|
||||||
|
jal reg1_error_loop
|
||||||
|
|
||||||
|
ulRegTest1LoopCounterConst: .word ulRegTest1LoopCounter
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
vRegTest2Task:
|
||||||
|
|
||||||
|
/* Fill the core registers with known values. */
|
||||||
|
li x6, 0x61
|
||||||
|
li x7, 0x71
|
||||||
|
li x8, 0x81
|
||||||
|
li x9, 0x91
|
||||||
|
li x10, 0xa1
|
||||||
|
li x11, 0xb1
|
||||||
|
li x12, 0xc1
|
||||||
|
li x13, 0xd1
|
||||||
|
li x14, 0xe1
|
||||||
|
li x15, 0xf1
|
||||||
|
li x16, 0x20
|
||||||
|
li x17, 0x21
|
||||||
|
li x18, 0x22
|
||||||
|
li x19, 0x23
|
||||||
|
li x20, 0x24
|
||||||
|
li x21, 0x25
|
||||||
|
li x22, 0x26
|
||||||
|
li x23, 0x27
|
||||||
|
li x24, 0x28
|
||||||
|
li x25, 0x29
|
||||||
|
li x26, 0x2a
|
||||||
|
li x27, 0x2b
|
||||||
|
li x28, 0x2c
|
||||||
|
li x29, 0x2d
|
||||||
|
li x30, 0x2e
|
||||||
|
li x31, 0x2f
|
||||||
|
|
||||||
|
Reg2_loop:
|
||||||
|
|
||||||
|
/* Check each register still contains the expected known value.
|
||||||
|
vRegTest2Implementation uses x5 as the temporary, vRegTest1Implementation
|
||||||
|
uses x31 as the temporary. */
|
||||||
|
li x5, 0x61
|
||||||
|
bne x5, x6, reg2_error_loop
|
||||||
|
li x5, 0x71
|
||||||
|
bne x5, x7, reg2_error_loop
|
||||||
|
li x5, 0x81
|
||||||
|
bne x5, x8, reg2_error_loop
|
||||||
|
li x5, 0x91
|
||||||
|
bne x5, x9, reg2_error_loop
|
||||||
|
li x5, 0xa1
|
||||||
|
bne x5, x10, reg2_error_loop
|
||||||
|
li x5, 0xb1
|
||||||
|
bne x5, x11, reg2_error_loop
|
||||||
|
li x5, 0xc1
|
||||||
|
bne x5, x12, reg2_error_loop
|
||||||
|
li x5, 0xd1
|
||||||
|
bne x5, x13, reg2_error_loop
|
||||||
|
li x5, 0xe1
|
||||||
|
bne x5, x14, reg2_error_loop
|
||||||
|
li x5, 0xf1
|
||||||
|
bne x5, x15, reg2_error_loop
|
||||||
|
li x5, 0x20
|
||||||
|
bne x5, x16, reg2_error_loop
|
||||||
|
li x5, 0x21
|
||||||
|
bne x5, x17, reg2_error_loop
|
||||||
|
li x5, 0x22
|
||||||
|
bne x5, x18, reg2_error_loop
|
||||||
|
li x5, 0x23
|
||||||
|
bne x5, x19, reg2_error_loop
|
||||||
|
li x5, 0x24
|
||||||
|
bne x5, x20, reg2_error_loop
|
||||||
|
li x5, 0x25
|
||||||
|
bne x5, x21, reg2_error_loop
|
||||||
|
li x5, 0x26
|
||||||
|
bne x5, x22, reg2_error_loop
|
||||||
|
li x5, 0x27
|
||||||
|
bne x5, x23, reg2_error_loop
|
||||||
|
li x5, 0x28
|
||||||
|
bne x5, x24, reg2_error_loop
|
||||||
|
li x5, 0x29
|
||||||
|
bne x5, x25, reg2_error_loop
|
||||||
|
li x5, 0x2a
|
||||||
|
bne x5, x26, reg2_error_loop
|
||||||
|
li x5, 0x2b
|
||||||
|
bne x5, x27, reg2_error_loop
|
||||||
|
li x5, 0x2c
|
||||||
|
bne x5, x28, reg2_error_loop
|
||||||
|
li x5, 0x2d
|
||||||
|
bne x5, x29, reg2_error_loop
|
||||||
|
li x5, 0x2e
|
||||||
|
bne x5, x30, reg2_error_loop
|
||||||
|
li x5, 0x2f
|
||||||
|
bne x5, x31, reg2_error_loop
|
||||||
|
|
||||||
|
/* Everything passed, increment the loop counter. */
|
||||||
|
lw x5, ulRegTest2LoopCounterConst
|
||||||
|
lw x6, 0(x5)
|
||||||
|
addi x6, x6, 1
|
||||||
|
sw x6, 0(x5)
|
||||||
|
|
||||||
|
/* Restore clobbered register reading for next loop. */
|
||||||
|
li x6, 0x61
|
||||||
|
|
||||||
|
/* Start again. */
|
||||||
|
jal Reg2_loop
|
||||||
|
|
||||||
|
reg2_error_loop:
|
||||||
|
/* Jump here if a register contains an uxpected value. This stops the loop
|
||||||
|
counter being incremented so the check task knows an error was found. */
|
||||||
|
jal reg2_error_loop
|
||||||
|
|
||||||
|
ulRegTest2LoopCounterConst: .word ulRegTest2LoopCounter
|
||||||
|
|
||||||
|
|
|
@ -30,247 +30,99 @@ void vApplicationIdleHook( void );
|
||||||
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
|
||||||
|
|
||||||
|
|
||||||
void reset_demo (void);
|
|
||||||
|
|
||||||
// Structures for registering different interrupt handlers
|
void vRegTest1Task( void *pvParameters );
|
||||||
// for different parts of the application.
|
void vRegTest2Task( void *pvParameters );
|
||||||
typedef void (*function_ptr_t) (void);
|
|
||||||
|
|
||||||
void no_interrupt_handler (void) {};
|
|
||||||
|
|
||||||
function_ptr_t g_ext_interrupt_handlers[PLIC_NUM_INTERRUPTS];
|
|
||||||
|
|
||||||
|
|
||||||
// Instance data for the PLIC.
|
const char * const pcStartMessage = "FreeRTOS demo\r\n";
|
||||||
|
volatile uint32_t ulRegTest1LoopCounter = 0, ulRegTest2LoopCounter = 0;
|
||||||
|
static void prvCheckTask( void *pvParameters );
|
||||||
plic_instance_t g_plic;
|
plic_instance_t g_plic;
|
||||||
|
uint32_t bitbang_mask = 0;
|
||||||
|
|
||||||
|
int main( void )
|
||||||
/*Entry Point for PLIC Interrupt Handler*/
|
|
||||||
void handle_m_ext_interrupt(){
|
|
||||||
plic_source int_num = PLIC_claim_interrupt(&g_plic);
|
|
||||||
if ((int_num >=1 ) && (int_num < PLIC_NUM_INTERRUPTS)) {
|
|
||||||
g_ext_interrupt_handlers[int_num]();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
exit(1 + (uintptr_t) int_num);
|
|
||||||
}
|
|
||||||
PLIC_complete_interrupt(&g_plic, int_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*Entry Point for Machine Timer Interrupt Handler*/
|
|
||||||
void handle_m_time_interrupt(){
|
|
||||||
|
|
||||||
clear_csr(mie, MIP_MTIP);
|
|
||||||
|
|
||||||
// Reset the timer for 3s in the future.
|
|
||||||
// This also clears the existing timer interrupt.
|
|
||||||
|
|
||||||
volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
|
|
||||||
volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
|
|
||||||
uint64_t now = *mtime;
|
|
||||||
uint64_t then = now + 2 * RTC_FREQ;
|
|
||||||
*mtimecmp = then;
|
|
||||||
|
|
||||||
// read the current value of the LEDS and invert them.
|
|
||||||
uint32_t leds = GPIO_REG(GPIO_OUTPUT_VAL);
|
|
||||||
|
|
||||||
GPIO_REG(GPIO_OUTPUT_VAL) ^= ((0x1 << RED_LED_OFFSET) |
|
|
||||||
(0x1 << GREEN_LED_OFFSET) |
|
|
||||||
(0x1 << BLUE_LED_OFFSET));
|
|
||||||
|
|
||||||
// Re-enable the timer interrupt.
|
|
||||||
set_csr(mie, MIP_MTIP);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * instructions_msg = " \
|
|
||||||
\n\
|
|
||||||
SIFIVE, INC.\n\
|
|
||||||
\n\
|
|
||||||
5555555555555555555555555\n\
|
|
||||||
5555 5555\n\
|
|
||||||
5555 5555\n\
|
|
||||||
5555 5555\n\
|
|
||||||
5555 5555555555555555555555\n\
|
|
||||||
5555 555555555555555555555555\n\
|
|
||||||
5555 5555\n\
|
|
||||||
5555 5555\n\
|
|
||||||
5555 5555\n\
|
|
||||||
5555555555555555555555555555 55555\n\
|
|
||||||
55555 555555555 55555\n\
|
|
||||||
55555 55555 55555\n\
|
|
||||||
55555 5 55555\n\
|
|
||||||
55555 55555\n\
|
|
||||||
55555 55555\n\
|
|
||||||
55555 55555\n\
|
|
||||||
55555 55555\n\
|
|
||||||
55555 55555\n\
|
|
||||||
555555555\n\
|
|
||||||
55555\n\
|
|
||||||
5\n\
|
|
||||||
\n\
|
|
||||||
SiFive E-Series Software Development Kit 'demo_gpio' program.\n\
|
|
||||||
Every 2 second, the Timer Interrupt will invert the LEDs.\n\
|
|
||||||
(Arty Dev Kit Only): Press Buttons 0, 1, 2 to Set the LEDs.\n\
|
|
||||||
Pin 19 (HiFive1) or A5 (Arty Dev Kit) is being bit-banged\n\
|
|
||||||
for GPIO speed demonstration.\n\
|
|
||||||
\n\
|
|
||||||
";
|
|
||||||
|
|
||||||
void print_instructions() {
|
|
||||||
|
|
||||||
write (STDOUT_FILENO, instructions_msg, strlen(instructions_msg));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAS_BOARD_BUTTONS
|
|
||||||
void button_0_handler(void) {
|
|
||||||
|
|
||||||
// Red LED on
|
|
||||||
GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << RED_LED_OFFSET);
|
|
||||||
|
|
||||||
// Clear the GPIO Pending interrupt by writing 1.
|
|
||||||
GPIO_REG(GPIO_RISE_IP) = (0x1 << BUTTON_0_OFFSET);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void button_1_handler(void) {
|
|
||||||
|
|
||||||
// Green LED On
|
|
||||||
GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << GREEN_LED_OFFSET);
|
|
||||||
|
|
||||||
// Clear the GPIO Pending interrupt by writing 1.
|
|
||||||
GPIO_REG(GPIO_RISE_IP) = (0x1 << BUTTON_1_OFFSET);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void button_2_handler(void) {
|
|
||||||
|
|
||||||
// Blue LED On
|
|
||||||
GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << BLUE_LED_OFFSET);
|
|
||||||
|
|
||||||
GPIO_REG(GPIO_RISE_IP) = (0x1 << BUTTON_2_OFFSET);
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void reset_demo (){
|
|
||||||
|
|
||||||
// Disable the machine & timer interrupts until setup is done.
|
|
||||||
|
|
||||||
clear_csr(mie, MIP_MEIP);
|
|
||||||
clear_csr(mie, MIP_MTIP);
|
|
||||||
|
|
||||||
for (int ii = 0; ii < PLIC_NUM_INTERRUPTS; ii ++){
|
|
||||||
g_ext_interrupt_handlers[ii] = no_interrupt_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAS_BOARD_BUTTONS
|
|
||||||
g_ext_interrupt_handlers[INT_DEVICE_BUTTON_0] = button_0_handler;
|
|
||||||
g_ext_interrupt_handlers[INT_DEVICE_BUTTON_1] = button_1_handler;
|
|
||||||
g_ext_interrupt_handlers[INT_DEVICE_BUTTON_2] = button_2_handler;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
print_instructions();
|
|
||||||
|
|
||||||
#ifdef HAS_BOARD_BUTTONS
|
|
||||||
|
|
||||||
// Have to enable the interrupt both at the GPIO level,
|
|
||||||
// and at the PLIC level.
|
|
||||||
PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_0);
|
|
||||||
PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_1);
|
|
||||||
PLIC_enable_interrupt (&g_plic, INT_DEVICE_BUTTON_2);
|
|
||||||
|
|
||||||
// Priority must be set > 0 to trigger the interrupt.
|
|
||||||
PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_0, 1);
|
|
||||||
PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_1, 1);
|
|
||||||
PLIC_set_priority(&g_plic, INT_DEVICE_BUTTON_2, 1);
|
|
||||||
|
|
||||||
GPIO_REG(GPIO_RISE_IE) |= (1 << BUTTON_0_OFFSET);
|
|
||||||
GPIO_REG(GPIO_RISE_IE) |= (1 << BUTTON_1_OFFSET);
|
|
||||||
GPIO_REG(GPIO_RISE_IE) |= (1 << BUTTON_2_OFFSET);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set the machine timer to go off in 3 seconds.
|
|
||||||
// The
|
|
||||||
volatile uint64_t * mtime = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIME);
|
|
||||||
volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
|
|
||||||
uint64_t now = *mtime;
|
|
||||||
uint64_t then = now + 2*RTC_FREQ;
|
|
||||||
*mtimecmp = then;
|
|
||||||
|
|
||||||
// Enable the Machine-External bit in MIE
|
|
||||||
set_csr(mie, MIP_MEIP);
|
|
||||||
|
|
||||||
// Enable the Machine-Timer bit in MIE
|
|
||||||
set_csr(mie, MIP_MTIP);
|
|
||||||
|
|
||||||
// Enable interrupts in general.
|
|
||||||
set_csr(mstatus, MSTATUS_MIE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
{
|
||||||
// Set up the GPIOs such that the LED GPIO
|
#ifdef HAS_BOARD_BUTTONS
|
||||||
// can be used as both Inputs and Outputs.
|
GPIO_REG(GPIO_OUTPUT_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
|
||||||
|
GPIO_REG(GPIO_PULLUP_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
|
||||||
|
GPIO_REG(GPIO_INPUT_EN) |= ((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
|
||||||
|
GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
|
||||||
|
GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;
|
||||||
|
GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;
|
||||||
|
|
||||||
#ifdef HAS_BOARD_BUTTONS
|
/* For Bit-banging with Atomics demo. */
|
||||||
GPIO_REG(GPIO_OUTPUT_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
|
#ifdef _SIFIVE_HIFIVE1_H
|
||||||
GPIO_REG(GPIO_PULLUP_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
|
bitbang_mask = (1 << PIN_19_OFFSET);
|
||||||
GPIO_REG(GPIO_INPUT_EN) |= ((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));
|
#else
|
||||||
#endif
|
#ifdef _SIFIVE_COREPLEXIP_ARTY_H
|
||||||
|
bitbang_mask = (0x1 << JA_0_OFFSET);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
|
GPIO_REG(GPIO_OUTPUT_EN) |= bitbang_mask;
|
||||||
GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
|
|
||||||
GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;
|
|
||||||
GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;
|
|
||||||
|
|
||||||
|
// xTaskCreate( vRegTest1Task, "RegTest1", 1000, NULL, tskIDLE_PRIORITY, NULL );
|
||||||
|
// xTaskCreate( vRegTest2Task, "RegTest2", 1000, NULL, tskIDLE_PRIORITY, NULL );
|
||||||
|
xTaskCreate( prvCheckTask, "Check", 1000, NULL, configMAX_PRIORITIES - 1, NULL );
|
||||||
|
|
||||||
// For Bit-banging with Atomics demo.
|
vTaskStartScheduler();
|
||||||
|
|
||||||
uint32_t bitbang_mask = 0;
|
|
||||||
#ifdef _SIFIVE_HIFIVE1_H
|
|
||||||
bitbang_mask = (1 << PIN_19_OFFSET);
|
|
||||||
#else
|
|
||||||
#ifdef _SIFIVE_COREPLEXIP_ARTY_H
|
|
||||||
bitbang_mask = (0x1 << JA_0_OFFSET);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GPIO_REG(GPIO_OUTPUT_EN) |= bitbang_mask;
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Set up the PLIC
|
|
||||||
*
|
|
||||||
*************************************************************************/
|
|
||||||
PLIC_init(&g_plic,
|
|
||||||
PLIC_CTRL_ADDR,
|
|
||||||
PLIC_NUM_INTERRUPTS,
|
|
||||||
PLIC_NUM_PRIORITIES);
|
|
||||||
|
|
||||||
reset_demo();
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Demonstrate fast GPIO bit-banging.
|
|
||||||
* One can bang it faster than this if you know
|
|
||||||
* the entire OUTPUT_VAL that you want to write, but
|
|
||||||
* Atomics give a quick way to control a single bit.
|
|
||||||
*************************************************************************/
|
|
||||||
// For Bit-banging with Atomics demo.
|
|
||||||
|
|
||||||
while (1){
|
|
||||||
atomic_fetch_xor_explicit(&GPIO_REG(GPIO_OUTPUT_VAL), bitbang_mask, memory_order_relaxed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvCheckTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
const char *pcMessage = "PASS\r\n";
|
||||||
|
const TickType_t xCheckPeriod = pdMS_TO_TICKS( 3000UL );
|
||||||
|
uint32_t ulLastRegTest1LoopCounter = 0, ulLastRegTest2LoopCounter = 0;
|
||||||
|
volatile uintptr_t mstatus;
|
||||||
|
|
||||||
|
volatile uint32_t ulx;
|
||||||
|
__asm volatile ("csrr %0, mstatus" : "=r"(mstatus));
|
||||||
|
portENABLE_INTERRUPTS();
|
||||||
|
__asm volatile ("csrr %0, mstatus" : "=r"(mstatus));
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
// for( ulx = 0; ulx < 0xffff; ulx++ ) __asm volatile( "NOP" );
|
||||||
|
// vPortSetupTimerInterrupt();
|
||||||
|
vTaskDelay( xCheckPeriod );
|
||||||
|
write( STDOUT_FILENO, "Blip\r\n", strlen( "Blip\r\n" ) );
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
vTaskDelay( xCheckPeriod );
|
||||||
|
|
||||||
|
if( ulLastRegTest1LoopCounter == ulRegTest1LoopCounter )
|
||||||
|
{
|
||||||
|
/* The RegTest1 loop counter is no longer incrementing, indicating
|
||||||
|
the task failed its self check. */
|
||||||
|
pcMessage = "FAIL: RegTest1\r\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulLastRegTest1LoopCounter = ulRegTest1LoopCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ulLastRegTest2LoopCounter == ulRegTest2LoopCounter )
|
||||||
|
{
|
||||||
|
/* The RegTest1 loop counter is no longer incrementing, indicating
|
||||||
|
the task failed its self check. */
|
||||||
|
pcMessage = "FAIL: RegTest2\r\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulLastRegTest2LoopCounter = ulRegTest2LoopCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
vUARTWriteString( pcMessage );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vApplicationMallocFailedHook( void )
|
void vApplicationMallocFailedHook( void )
|
||||||
{
|
{
|
||||||
|
@ -316,11 +168,35 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define mainINTERRUPT_BIT_SET 0x80000000UL
|
||||||
|
#define mainENVIRONMENT_CALL 11UL
|
||||||
|
#define mainEXTERNAL_INTERRRUPT ( mainINTERRUPT_BIT_SET | 11UL )
|
||||||
|
#define mainTIMER_INTERRUPT ( mainINTERRUPT_BIT_SET | 7UL )
|
||||||
|
#define mainSOFTWARE_INTERRUPT ( mainINTERRUPT_BIT_SET | 3UL )
|
||||||
|
|
||||||
|
extern void Timer_IRQHandler( void );
|
||||||
|
|
||||||
void trap_entry( void )
|
uint32_t ulPortTrapHandler( uint32_t mcause, uint32_t mepc )
|
||||||
{
|
{
|
||||||
#warning Dummy until kernel code is incldued.
|
if( mcause == mainENVIRONMENT_CALL )
|
||||||
|
{
|
||||||
|
vTaskSwitchContext();
|
||||||
|
|
||||||
|
/* Ensure not to return to the instruction that generated the exception. */
|
||||||
|
mepc += 4;
|
||||||
|
}
|
||||||
|
else if( mcause == mainEXTERNAL_INTERRRUPT )
|
||||||
|
{
|
||||||
|
for( ;; );
|
||||||
|
}
|
||||||
|
else if( mcause == mainTIMER_INTERRUPT )
|
||||||
|
{
|
||||||
|
Timer_IRQHandler();
|
||||||
|
}
|
||||||
|
else if( mcause == mainSOFTWARE_INTERRUPT )
|
||||||
|
{
|
||||||
|
for( ;; );
|
||||||
|
}
|
||||||
|
|
||||||
|
return mepc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -376,9 +376,9 @@ is used in assert() statements. */
|
||||||
* memory to be allocated dynamically.
|
* memory to be allocated dynamically.
|
||||||
*
|
*
|
||||||
* @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will
|
* @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will
|
||||||
* be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer
|
* be created and a handle to the created task is returned. If either
|
||||||
* are NULL then the task will not be created and
|
* pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
|
||||||
* errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned.
|
* NULL is returned.
|
||||||
*
|
*
|
||||||
* Example usage:
|
* Example usage:
|
||||||
<pre>
|
<pre>
|
||||||
|
|
|
@ -51,7 +51,7 @@ static void prvTaskExitError( void );
|
||||||
/* Used to program the machine timer compare register. */
|
/* Used to program the machine timer compare register. */
|
||||||
static uint64_t ullNextTime = 0ULL;
|
static uint64_t ullNextTime = 0ULL;
|
||||||
static const uint64_t ullTimerIncrementsForOneTick = ( uint64_t ) ( configCPU_CLOCK_HZ / configTICK_RATE_HZ );
|
static const uint64_t ullTimerIncrementsForOneTick = ( uint64_t ) ( configCPU_CLOCK_HZ / configTICK_RATE_HZ );
|
||||||
static volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) ( configCTRL_BASE + 0x4000 );
|
static volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) ( configCLINT_BASE_ADDRESS + 0x4000 );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -175,8 +175,8 @@ const uint32_t ulMPIE_Bit = 0x80, ulMPP_Bits = 0x1800;
|
||||||
void vPortSetupTimerInterrupt( void )
|
void vPortSetupTimerInterrupt( void )
|
||||||
{
|
{
|
||||||
uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;
|
uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;
|
||||||
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( configCTRL_BASE + 0xBFFC );
|
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFFC );
|
||||||
volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCTRL_BASE + 0xBFF8 );
|
volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFF8 );
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -200,12 +200,12 @@ volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) ( configCTR
|
||||||
|
|
||||||
void Software_IRQHandler( void )
|
void Software_IRQHandler( void )
|
||||||
{
|
{
|
||||||
volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) configCTRL_BASE;
|
volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) configCLINT_BASE_ADDRESS;
|
||||||
|
|
||||||
vTaskSwitchContext();
|
vTaskSwitchContext();
|
||||||
|
|
||||||
/* Clear software interrupt. */
|
/* Clear software interrupt. */
|
||||||
*( ( uint32_t * ) configCTRL_BASE ) &= 0x08UL;
|
*( ( uint32_t * ) configCLINT_BASE_ADDRESS ) &= 0x08UL;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -246,6 +246,14 @@ extern void xPortStartFirstTask( void );
|
||||||
should be executing. */
|
should be executing. */
|
||||||
return pdFAIL;
|
return pdFAIL;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vPortEndScheduler( void )
|
||||||
|
{
|
||||||
|
/* Not implemented. */
|
||||||
|
for( ;; );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,16 @@
|
||||||
.global xPortStartFirstTask
|
.global xPortStartFirstTask
|
||||||
.global vPortTrapHandler
|
.global vPortTrapHandler
|
||||||
.extern pxCurrentTCB
|
.extern pxCurrentTCB
|
||||||
.extern handle_trap
|
.extern ulPortTrapHandler
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
.align 8
|
.align 8
|
||||||
xPortStartFirstTask:
|
xPortStartFirstTask:
|
||||||
|
|
||||||
|
la t0, vPortTrapHandler
|
||||||
|
csrw mtvec, t0
|
||||||
|
|
||||||
lw sp, pxCurrentTCB /* Load pxCurrentTCB. */
|
lw sp, pxCurrentTCB /* Load pxCurrentTCB. */
|
||||||
lw sp, 0( sp ) /* Read sp from first TCB member. */
|
lw sp, 0( sp ) /* Read sp from first TCB member. */
|
||||||
|
|
||||||
|
@ -127,7 +130,7 @@ vPortTrapHandler:
|
||||||
csrr a1, mepc
|
csrr a1, mepc
|
||||||
mv a2, sp
|
mv a2, sp
|
||||||
/*_RB_ Does stack need aligning here? */
|
/*_RB_ Does stack need aligning here? */
|
||||||
jal handle_trap
|
jal ulPortTrapHandler
|
||||||
csrw mepc, a0
|
csrw mepc, a0
|
||||||
/* Save exception return address. */
|
/* Save exception return address. */
|
||||||
sw a0, 0( sp )
|
sw a0, 0( sp )
|
||||||
|
|
|
@ -70,7 +70,7 @@ not need to be guarded with a critical section. */
|
||||||
|
|
||||||
|
|
||||||
/* Scheduler utilities. */
|
/* Scheduler utilities. */
|
||||||
#define portYIELD() __asm volatile( "ecall" ); // software interrupt alternative *( ( uint32_t * ) configCTRL_BASE ) |= 0x08UL
|
#define portYIELD() __asm volatile( "ecall" ); // software interrupt alternative *( ( uint32_t * ) configCLINT_BASE_ADDRESS ) |= 0x08UL
|
||||||
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield()
|
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield()
|
||||||
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
|
@ -2937,28 +2937,28 @@ void vTaskSwitchContext( void )
|
||||||
|
|
||||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||||
{
|
{
|
||||||
#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
|
#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
|
||||||
portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
|
portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
|
||||||
#else
|
#else
|
||||||
ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
|
ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add the amount of time the task has been running to the
|
/* Add the amount of time the task has been running to the
|
||||||
accumulated time so far. The time the task started running was
|
accumulated time so far. The time the task started running was
|
||||||
stored in ulTaskSwitchedInTime. Note that there is no overflow
|
stored in ulTaskSwitchedInTime. Note that there is no overflow
|
||||||
protection here so count values are only valid until the timer
|
protection here so count values are only valid until the timer
|
||||||
overflows. The guard against negative values is to protect
|
overflows. The guard against negative values is to protect
|
||||||
against suspect run time stat counter implementations - which
|
against suspect run time stat counter implementations - which
|
||||||
are provided by the application, not the kernel. */
|
are provided by the application, not the kernel. */
|
||||||
if( ulTotalRunTime > ulTaskSwitchedInTime )
|
if( ulTotalRunTime > ulTaskSwitchedInTime )
|
||||||
{
|
{
|
||||||
pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
|
pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
ulTaskSwitchedInTime = ulTotalRunTime;
|
ulTaskSwitchedInTime = ulTotalRunTime;
|
||||||
}
|
}
|
||||||
#endif /* configGENERATE_RUN_TIME_STATS */
|
#endif /* configGENERATE_RUN_TIME_STATS */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue