From 749b909e322ab5e10b0c8e72b73c4b8bf636fadd Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Fri, 25 Apr 2025 10:44:11 +0000 Subject: [PATCH] update freertos bindings --- .../target_os/freertos/bindings.rs | 110 ++++++++++++++++-- .../src/systemstate/target_os/freertos/mod.rs | 12 +- 2 files changed, 105 insertions(+), 17 deletions(-) diff --git a/fuzzers/FRET/src/systemstate/target_os/freertos/bindings.rs b/fuzzers/FRET/src/systemstate/target_os/freertos/bindings.rs index 493733ad4f..41b67f9ccb 100644 --- a/fuzzers/FRET/src/systemstate/target_os/freertos/bindings.rs +++ b/fuzzers/FRET/src/systemstate/target_os/freertos/bindings.rs @@ -1,21 +1,71 @@ #![allow(non_camel_case_types,non_snake_case,non_upper_case_globals,deref_nullptr,unused)] use serde::{Deserialize, Serialize}; -// Manual Types -use libafl_qemu::Qemu; /*========== Start of generated Code =============*/ pub type char_ptr = ::std::os::raw::c_uint; -pub type ListItem_t_ptr = ::std::os::raw::c_uint; -pub type StackType_t_ptr = ::std::os::raw::c_uint; pub type void_ptr = ::std::os::raw::c_uint; +pub type ListItem_t_ptr = ::std::os::raw::c_uint; +pub type QueueDefinition_ptr = ::std::os::raw::c_uint; +pub type StackType_t_ptr = ::std::os::raw::c_uint; +pub type i_ptr8 = ::std::os::raw::c_uint; pub type tskTaskControlBlock_ptr = ::std::os::raw::c_uint; pub type xLIST_ptr = ::std::os::raw::c_uint; pub type xLIST_ITEM_ptr = ::std::os::raw::c_uint; -/* automatically generated by rust-bindgen 0.59.2 */ +/* automatically generated by rust-bindgen 0.71.1 */ + +pub const configASSERT_DEFINED: u32 = 1; +pub const configQUEUE_REGISTRY_SIZE: u32 = 20; +pub const configUSE_PREEMPTION: u32 = 1; +pub const configUSE_TIME_SLICING: u32 = 0; +pub const configUSE_PORT_OPTIMISED_TASK_SELECTION: u32 = 0; +pub const configUSE_IDLE_HOOK: u32 = 1; +pub const configUSE_TICK_HOOK: u32 = 1; +pub const configUSE_DAEMON_TASK_STARTUP_HOOK: u32 = 0; +pub const configMAX_TASK_NAME_LEN: u32 = 10; +pub const configUSE_TRACE_FACILITY: u32 = 0; +pub const configUSE_STATS_FORMATTING_FUNCTIONS: u32 = 0; +pub const configUSE_16_BIT_TICKS: u32 = 0; +pub const configIDLE_SHOULD_YIELD: u32 = 1; +pub const configUSE_CO_ROUTINES: u32 = 0; +pub const configMAX_PRIORITIES: u32 = 15; +pub const configMAX_CO_ROUTINE_PRIORITIES: u32 = 2; +pub const configTIMER_QUEUE_LENGTH: u32 = 20; +pub const configTIMER_TASK_PRIORITY: u32 = 14; +pub const configUSE_COUNTING_SEMAPHORES: u32 = 1; +pub const configSUPPORT_DYNAMIC_ALLOCATION: u32 = 1; +pub const configSUPPORT_STATIC_ALLOCATION: u32 = 1; +pub const configNUM_TX_DESCRIPTORS: u32 = 15; +pub const configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN: u32 = 2; +pub const configUSE_QUEUE_SETS: u32 = 1; +pub const configUSE_MALLOC_FAILED_HOOK: u32 = 1; +pub const configUSE_MUTEXES: u32 = 1; +pub const configUSE_RECURSIVE_MUTEXES: u32 = 1; +pub const configUSE_TIMERS: u32 = 1; +pub const INCLUDE_vTaskPrioritySet: u32 = 1; +pub const INCLUDE_uxTaskPriorityGet: u32 = 1; +pub const INCLUDE_vTaskDelete: u32 = 1; +pub const INCLUDE_vTaskCleanUpResources: u32 = 0; +pub const INCLUDE_vTaskSuspend: u32 = 1; +pub const INCLUDE_vTaskDelayUntil: u32 = 1; +pub const INCLUDE_vTaskDelay: u32 = 1; +pub const INCLUDE_uxTaskGetStackHighWaterMark: u32 = 1; +pub const INCLUDE_uxTaskGetStackHighWaterMark2: u32 = 1; +pub const INCLUDE_xTaskGetSchedulerState: u32 = 1; +pub const INCLUDE_xTimerGetTimerDaemonTaskHandle: u32 = 1; +pub const INCLUDE_xTaskGetIdleTaskHandle: u32 = 1; +pub const INCLUDE_xTaskGetHandle: u32 = 1; +pub const INCLUDE_eTaskGetState: u32 = 1; +pub const INCLUDE_xSemaphoreGetMutexHolder: u32 = 1; +pub const INCLUDE_xTimerPendFunctionCall: u32 = 1; +pub const INCLUDE_xTaskAbortDelay: u32 = 1; +pub const projCOVERAGE_TEST: u32 = 0; +pub const configKERNEL_INTERRUPT_PRIORITY: u32 = 255; +pub const configMAX_SYSCALL_INTERRUPT_PRIORITY: u32 = 191; +pub const configMAC_INTERRUPT_PRIORITY: u32 = 5; +pub const configUSE_TASK_NOTIFICATIONS: u32 = 1; +pub const configTASK_NOTIFICATION_ARRAY_ENTRIES: u32 = 4; +/* automatically generated by rust-bindgen 0.71.1 */ -pub type __uint8_t = ::std::os::raw::c_uchar; -pub type __uint16_t = ::std::os::raw::c_ushort; -pub type __uint32_t = ::std::os::raw::c_uint; pub type StackType_t = u32; pub type UBaseType_t = ::std::os::raw::c_uint; pub type TickType_t = u32; @@ -67,6 +117,45 @@ pub struct xTASK_STATUS { pub usStackHighWaterMark: u16, } pub type TaskStatus_t = xTASK_STATUS; +pub type QueueHandle_t = QueueDefinition_ptr; +#[repr(C)] +#[derive(Debug, Copy, Clone, Default, Serialize, Deserialize)] +pub struct QueuePointers { + pub pcTail: i_ptr8, + pub pcReadFrom: i_ptr8, +} +pub type QueuePointers_t = QueuePointers; +#[repr(C)] +#[derive(Debug, Copy, Clone, Default, Serialize, Deserialize)] +pub struct SemaphoreData { + pub xMutexHolder: TaskHandle_t, + pub uxRecursiveCallCount: UBaseType_t, +} +pub type SemaphoreData_t = SemaphoreData; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct QueueDefinition { + pub pcHead: i_ptr8, + pub pcWriteTo: i_ptr8, + pub u: QueueDefinition__bindgen_ty_1, + pub xTasksWaitingToSend: List_t, + pub xTasksWaitingToReceive: List_t, + pub uxMessagesWaiting: UBaseType_t, + pub uxLength: UBaseType_t, + pub uxItemSize: UBaseType_t, + pub cRxLock: i8, + pub cTxLock: i8, + pub ucStaticallyAllocated: u8, + pub pxQueueSetContainer: QueueDefinition_ptr, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union QueueDefinition__bindgen_ty_1 { + pub xQueue: QueuePointers_t, + pub xSemaphore: SemaphoreData_t, +} +pub type xQUEUE = QueueDefinition; +pub type Queue_t = xQUEUE; #[repr(C)] #[derive(Debug, Copy, Clone, Default, Serialize, Deserialize)] pub struct tskTaskControlBlock { @@ -78,11 +167,10 @@ pub struct tskTaskControlBlock { pub pcTaskName: [::std::os::raw::c_char; 10usize], pub uxBasePriority: UBaseType_t, pub uxMutexesHeld: UBaseType_t, - pub ulNotifiedValue: [u32; 1usize], - pub ucNotifyState: [u8; 1usize], + pub ulNotifiedValue: [u32; 4usize], + pub ucNotifyState: [u8; 4usize], pub ucStaticallyAllocated: u8, pub ucDelayAborted: u8, } pub type tskTCB = tskTaskControlBlock; pub type TCB_t = tskTCB; -/*========== End of generated Code =============*/ \ No newline at end of file diff --git a/fuzzers/FRET/src/systemstate/target_os/freertos/mod.rs b/fuzzers/FRET/src/systemstate/target_os/freertos/mod.rs index b442788d07..dbbc22ff42 100644 --- a/fuzzers/FRET/src/systemstate/target_os/freertos/mod.rs +++ b/fuzzers/FRET/src/systemstate/target_os/freertos/mod.rs @@ -296,8 +296,8 @@ pub struct RefinedTCB { pub priority: u32, pub base_priority: u32, mutexes_held: u32, - notify_value: u32, - notify_state: u8, + notify_value: [u32; configTASK_NOTIFICATION_ARRAY_ENTRIES as usize], + notify_state: [u8; configTASK_NOTIFICATION_ARRAY_ENTRIES as usize], } impl PartialEq for RefinedTCB { @@ -339,8 +339,8 @@ impl RefinedTCB { priority: input.uxPriority, base_priority: input.uxBasePriority, mutexes_held: input.uxMutexesHeld, - notify_value: input.ulNotifiedValue[0], - notify_state: input.ucNotifyState[0], + notify_value: input.ulNotifiedValue, + notify_state: input.ucNotifyState, } } } @@ -357,8 +357,8 @@ impl RefinedTCB { priority: input.uxPriority, base_priority: input.uxBasePriority, mutexes_held: input.uxMutexesHeld, - notify_value: input.ulNotifiedValue[0], - notify_state: input.ucNotifyState[0], + notify_value: input.ulNotifiedValue, + notify_state: input.ucNotifyState, } } }