feat: publish FreeRTOS C FC09 card
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#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 0
|
||||
#define configMAX_PRIORITIES 5
|
||||
#define configMINIMAL_STACK_SIZE 128
|
||||
#define configMAX_TASK_NAME_LEN 16
|
||||
#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 1
|
||||
#define INCLUDE_vTaskDelayUntil 0
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskSuspend 0
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskPrioritySet 0
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 0
|
||||
|
||||
#define configENABLE_FPU 0
|
||||
#define configENABLE_VPU 0
|
||||
#define configISR_STACK_SIZE_WORDS 128
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
void lab_assert_fail( const char * file, int line );
|
||||
#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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef TASK01_EVENT_GROUPS_H
|
||||
#define TASK01_EVENT_GROUPS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "event_groups.h"
|
||||
#include "task.h"
|
||||
#include "task01_event_groups_model.h"
|
||||
|
||||
#define FC09_READY_A ( ( EventBits_t ) 0x01U )
|
||||
#define FC09_READY_B ( ( EventBits_t ) 0x02U )
|
||||
#define FC09_READY_ALL ( FC09_READY_A | FC09_READY_B )
|
||||
#define FC09_SYNC_A ( ( EventBits_t ) 0x10U )
|
||||
#define FC09_SYNC_B ( ( EventBits_t ) 0x20U )
|
||||
#define FC09_SYNC_C ( ( EventBits_t ) 0x40U )
|
||||
#define FC09_SYNC_ALL ( FC09_SYNC_A | FC09_SYNC_B | FC09_SYNC_C )
|
||||
#define FC09_TASK_STACK_WORDS 256U
|
||||
#define FC09_COORDINATOR_PRIORITY 3U
|
||||
#define FC09_WORKER_A_PRIORITY 2U
|
||||
#define FC09_WORKER_B_PRIORITY 1U
|
||||
#define FC09_VERIFIER_PRIORITY 0U
|
||||
#define FC09_TIMEOUT_TICKS 20U
|
||||
#define FC09_EVENT_CAPACITY 12U
|
||||
|
||||
typedef struct EventGroupExperiment
|
||||
{
|
||||
EventGroupHandle_t group;
|
||||
TaskHandle_t coordinator_handle;
|
||||
TaskHandle_t worker_a_handle;
|
||||
TaskHandle_t worker_b_handle;
|
||||
TaskHandle_t verifier_handle;
|
||||
EventBits_t ready_result;
|
||||
EventBits_t sync_a_result;
|
||||
EventBits_t sync_b_result;
|
||||
EventBits_t sync_c_result;
|
||||
EventBits_t partial_bits;
|
||||
EventBits_t final_bits;
|
||||
eTaskState worker_a_state_at_partial;
|
||||
eTaskState coordinator_state_before_final_sync;
|
||||
uintptr_t coordinator_sp;
|
||||
uintptr_t worker_a_sp;
|
||||
uintptr_t worker_b_sp;
|
||||
uint32_t coordinator_done;
|
||||
uint32_t worker_a_done;
|
||||
uint32_t worker_b_done;
|
||||
uint32_t pass;
|
||||
uint32_t evidence_digest;
|
||||
} EventGroupExperiment;
|
||||
|
||||
extern EventGroupExperiment g_fc09;
|
||||
extern EventGroupEvidence g_fc09_events[ FC09_EVENT_CAPACITY ];
|
||||
extern volatile uint32_t g_fc09_event_count;
|
||||
extern volatile uint32_t g_fc09_last_checkpoint;
|
||||
extern volatile uint32_t g_fc09_pass;
|
||||
|
||||
void fc09_checkpoint_committed( uint32_t point, const void * subject );
|
||||
void fc09_coordinator_entry( void * context );
|
||||
void fc09_worker_a_entry( void * context );
|
||||
void fc09_worker_b_entry( void * context );
|
||||
void fc09_verifier_entry( void * context );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
#ifndef TASK01_EVENT_GROUPS_MODEL_H
|
||||
#define TASK01_EVENT_GROUPS_MODEL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct EventGroupEvidence
|
||||
{
|
||||
uint32_t sequence;
|
||||
uint32_t event;
|
||||
uint32_t tick;
|
||||
uint32_t actor;
|
||||
uint32_t value;
|
||||
uint32_t committed;
|
||||
} EventGroupEvidence;
|
||||
|
||||
static inline uint32_t fc09_digest( const EventGroupEvidence * events,
|
||||
size_t count )
|
||||
{
|
||||
uint32_t hash = 2166136261U;
|
||||
size_t index;
|
||||
|
||||
for( index = 0U; index < count; ++index )
|
||||
{
|
||||
hash = ( hash ^ events[ index ].event ) * 16777619U;
|
||||
hash = ( hash ^ events[ index ].actor ) * 16777619U;
|
||||
hash = ( hash ^ events[ index ].value ) * 16777619U;
|
||||
hash = ( hash ^ events[ index ].committed ) * 16777619U;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
static inline int fc09_mask_contains( uint32_t value, uint32_t mask )
|
||||
{
|
||||
return ( value & mask ) == mask;
|
||||
}
|
||||
|
||||
static inline int fc09_order_is_valid( const EventGroupEvidence * events,
|
||||
size_t count )
|
||||
{
|
||||
size_t index;
|
||||
|
||||
if( events == NULL || count != 11U )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for( index = 0U; index < count; ++index )
|
||||
{
|
||||
if( events[ index ].sequence != index + 1U ||
|
||||
events[ index ].event != index + 1U ||
|
||||
events[ index ].committed != ( 0xFC090000U | ( index + 1U ) ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user