feat: publish FreeRTOS C FC03 card

This commit is contained in:
2026-07-19 16:36:02 +02:00
commit 34d08ae979
203 changed files with 57403 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/* Hazard3 testbench: mtime advances once per simulated cycle. */
#define configCPU_CLOCK_HZ ( 1000000UL )
#define configTICK_RATE_HZ ( 1000U )
#define configMTIME_BASE_ADDRESS ( 0xC0000100UL )
#define configMTIMECMP_BASE_ADDRESS ( 0xC0000108UL )
#define configUSE_PREEMPTION 1
#define configUSE_TIME_SLICING 1
#define configNUMBER_OF_CORES 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 1
#define configMAX_PRIORITIES 5
#define configMINIMAL_STACK_SIZE 128
#define configMAX_TASK_NAME_LEN 12
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
#define configIDLE_SHOULD_YIELD 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configSUPPORT_STATIC_ALLOCATION 0
#define configTOTAL_HEAP_SIZE ( 16U * 1024U )
#define configAPPLICATION_ALLOCATED_HEAP 1
#define configUSE_MALLOC_FAILED_HOOK 1
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
#define configUSE_TIMERS 0
#define configUSE_MUTEXES 0
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_TASK_NOTIFICATIONS 0
#define configUSE_TRACE_FACILITY 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_CO_ROUTINES 0
#define configUSE_NEWLIB_REENTRANT 0
#define configUSE_POSIX_ERRNO 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configRECORD_STACK_HIGH_ADDRESS 1
#define INCLUDE_vTaskDelay 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
/* Hazard3 is RV32I: no floating-point or vector register file to save. */
#define configENABLE_FPU 0
#define configENABLE_VPU 0
/* Keep interrupt and task stack domains visually distinct. */
#define configISR_STACK_SIZE_WORDS 128
#ifndef __ASSEMBLER__
#ifdef __cplusplus
extern "C" void lab_assert_fail( const char * file, int line );
#else
void lab_assert_fail( const char * file, int line );
#endif
#define configASSERT( condition ) do { if( !( condition ) ) { lab_assert_fail( __FILE__, __LINE__ ); } } while( 0 )
#else
#define configASSERT( condition )
#endif
#endif
@@ -0,0 +1,15 @@
#ifndef FREERTOS_RISC_V_CHIP_SPECIFIC_EXTENSIONS_H
#define FREERTOS_RISC_V_CHIP_SPECIFIC_EXTENSIONS_H
/* Hazard3 adds no architectural registers to the base RV32I context. */
#define portasmHAS_MTIME 1
#define portasmHAS_SIFIVE_CLINT 0
#define portasmADDITIONAL_CONTEXT_SIZE 0
.macro portasmSAVE_ADDITIONAL_REGISTERS
.endm
.macro portasmRESTORE_ADDITIONAL_REGISTERS
.endm
#endif
+11
View File
@@ -0,0 +1,11 @@
#ifndef LAB_FREESTANDING_STDLIB_H
#define LAB_FREESTANDING_STDLIB_H
/*
* The selected FreeRTOS sources include <stdlib.h> for standard types, but the
* configuration used by this card does not call hosted stdlib functions.
* GCC's freestanding headers provide size_t through <stddef.h>.
*/
#include <stddef.h>
#endif
+17
View File
@@ -0,0 +1,17 @@
#ifndef LAB_FREESTANDING_STRING_H
#define LAB_FREESTANDING_STRING_H
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
void * memcpy( void * destination, const void * source, size_t count );
void * memset( void * destination, int value, size_t count );
size_t strlen( const char * text );
#ifdef __cplusplus
}
#endif
#endif
+80
View File
@@ -0,0 +1,80 @@
#ifndef TASK01_SCHEDULER_H
#define TASK01_SCHEDULER_H
#include <stdint.h>
#include "FreeRTOS.h"
#include "task.h"
#define SCHED_TRACE_CAPACITY 16U
#define SCHED_PEER_STACK_WORDS 192U
#define SCHED_PROBE_STACK_WORDS 192U
#define SCHED_VERIFY_STACK_WORDS 192U
#define SCHED_PEER_PRIORITY 2U
#define SCHED_PROBE_INITIAL_PRIORITY 0U
#define SCHED_PROBE_TARGET_PRIORITY 3U
#define SCHED_VERIFY_PRIORITY 1U
#define SCHED_TIMEOUT_TICKS 100U
typedef enum
{
SCHED_PHASE_PREPARED = 0,
SCHED_PHASE_READY,
SCHED_PHASE_RUNNING,
SCHED_PHASE_COMPLETED
} SchedulerPhase;
typedef struct
{
uint32_t id;
UBaseType_t configured_priority;
volatile UBaseType_t observed_priority;
TaskHandle_t handle;
uintptr_t created_handle;
uintptr_t tcb_address;
uintptr_t entry_sp;
uintptr_t stack_low;
uintptr_t stack_high;
volatile uint32_t iterations;
volatile uint32_t checksum;
volatile TickType_t first_tick;
volatile TickType_t last_tick;
volatile SchedulerPhase phase;
} PeerContext;
typedef struct
{
UBaseType_t initial_priority;
UBaseType_t target_priority;
volatile UBaseType_t observed_initial_priority;
volatile UBaseType_t observed_priority;
TaskHandle_t handle;
uintptr_t created_handle;
uintptr_t tcb_address;
uintptr_t entry_sp;
uintptr_t stack_low;
uintptr_t stack_high;
volatile TickType_t run_tick;
volatile uint32_t ran_before_caller_returned;
volatile uint32_t verifier_was_not_running;
volatile SchedulerPhase phase;
} HighProbeContext;
typedef struct
{
UBaseType_t configured_priority;
volatile UBaseType_t observed_priority;
TaskHandle_t handle;
volatile uint32_t pass;
volatile SchedulerPhase phase;
} VerifierContext;
void peer_task_entry( void * pv_parameters );
void high_probe_task_entry( void * pv_parameters );
void verifier_task_entry( void * pv_parameters );
void task01_scheduler_checkpoint( uint32_t point, const void * subject );
void task01_scheduler_checkpoint_committed( uint32_t point,
const void * subject );
void task01_tick_checkpoint_committed( void );
#endif
+57
View File
@@ -0,0 +1,57 @@
#ifndef TASK01_SCHEDULER_MODEL_H
#define TASK01_SCHEDULER_MODEL_H
#include <stddef.h>
#include <stdint.h>
enum
{
SCHED_PEER_A = 0U,
SCHED_PEER_B = 1U,
SCHED_ORDER_BEFORE_RAISE = 1U,
SCHED_ORDER_HIGH_PROBE = 2U,
SCHED_ORDER_AFTER_RAISE = 3U
};
static inline int scheduler_trace_has_aba( const uint32_t * task_ids,
size_t count )
{
size_t index;
for( index = 2U; index < count; ++index )
{
if( task_ids[ index - 2U ] == SCHED_PEER_A &&
task_ids[ index - 1U ] == SCHED_PEER_B &&
task_ids[ index ] == SCHED_PEER_A )
{
return 1;
}
}
return 0;
}
static inline int scheduler_ticks_nondecreasing( const uint32_t * ticks,
size_t count )
{
size_t index;
for( index = 1U; index < count; ++index )
{
if( ticks[ index ] < ticks[ index - 1U ] )
{
return 0;
}
}
return 1;
}
static inline int scheduler_preemption_order_valid( const uint32_t * order,
size_t count )
{
return count == 3U &&
order[ 0 ] == SCHED_ORDER_BEFORE_RAISE &&
order[ 1 ] == SCHED_ORDER_HIGH_PROBE &&
order[ 2 ] == SCHED_ORDER_AFTER_RAISE;
}
#endif