diff --git a/Include/Kernel/rmp_kernel.h b/Include/Kernel/rmp_kernel.h index 73cd2f37..d7ca040a 100644 --- a/Include/Kernel/rmp_kernel.h +++ b/Include/Kernel/rmp_kernel.h @@ -185,8 +185,11 @@ do \ while(0) #endif -/* Coverage switch detection */ -#ifndef RMP_COVERAGE_MARKER +/* Coverage marker enabling */ +#ifdef RMP_COVERAGE_LINE_NUM +#define RMP_COVERAGE_WORD_NUM (RMP_ROUND_UP(RMP_COVERAGE_LINE_NUM,RMP_WORD_ORDER)>>RMP_WORD_ORDER) +#define RMP_COVERAGE_MARKER() (RMP_Coverage[__LINE__>>RMP_WORD_ORDER]|=RMP_POW2(__LINE__&RMP_WORD_MASK)) +#else #define RMP_COVERAGE_MARKER() #endif /*****************************************************************************/ @@ -339,9 +342,9 @@ struct RMP_Mem /* If the header is not used in the public mode */ #ifndef __HDR_PUBLIC__ /*****************************************************************************/ -#ifdef RMP_COVERAGE +#ifdef RMP_COVERAGE_LINE_NUM /* For coverage use only */ -static volatile rmp_ptr_t RMP_Coverage[RMP_COVERAGE_LINES]; +static volatile rmp_ptr_t RMP_Coverage[RMP_COVERAGE_WORD_NUM]; #endif /* The scheduler bitmap */ static volatile rmp_ptr_t RMP_Bitmap[RMP_PRIO_WORD_NUM]; @@ -691,8 +694,8 @@ EXTERN void RMP_Init_Hook(void); EXTERN void RMP_Init_Idle(void); /* Coverage test */ -#ifdef RMP_COVERAGE -__EXTERN__ void RMP_Print_Coverage(void); +#ifdef RMP_COVERAGE_LINE_NUM +__EXTERN__ void RMP_Coverage_Print(void); #endif /*****************************************************************************/ /* Undefine "__EXTERN__" to avoid redefinition */ diff --git a/Project/RVMDK-STM32F103RBT6/DebugConfig/RMP_STM32F103RB_1.0.0.dbgconf b/Project/RVMDK-STM32F103RBT6-COV/DebugConfig/RMP_STM32F103RB_1.0.0.dbgconf similarity index 100% rename from Project/RVMDK-STM32F103RBT6/DebugConfig/RMP_STM32F103RB_1.0.0.dbgconf rename to Project/RVMDK-STM32F103RBT6-COV/DebugConfig/RMP_STM32F103RB_1.0.0.dbgconf diff --git a/Project/RVMDK-STM32F103RBT6/EventRecorderStub.scvd b/Project/RVMDK-STM32F103RBT6-COV/EventRecorderStub.scvd similarity index 100% rename from Project/RVMDK-STM32F103RBT6/EventRecorderStub.scvd rename to Project/RVMDK-STM32F103RBT6-COV/EventRecorderStub.scvd diff --git a/Project/RVMDK-STM32F103RBT6/JLinkLog.txt b/Project/RVMDK-STM32F103RBT6-COV/JLinkLog.txt similarity index 100% rename from Project/RVMDK-STM32F103RBT6/JLinkLog.txt rename to Project/RVMDK-STM32F103RBT6-COV/JLinkLog.txt diff --git a/Project/RVMDK-STM32F103RBT6/JLinkSettings.ini b/Project/RVMDK-STM32F103RBT6-COV/JLinkSettings.ini similarity index 100% rename from Project/RVMDK-STM32F103RBT6/JLinkSettings.ini rename to Project/RVMDK-STM32F103RBT6-COV/JLinkSettings.ini diff --git a/Project/RVMDK-STM32F103RBT6/RMP.uvprojx b/Project/RVMDK-STM32F103RBT6-COV/RMP.uvprojx similarity index 99% rename from Project/RVMDK-STM32F103RBT6/RMP.uvprojx rename to Project/RVMDK-STM32F103RBT6-COV/RMP.uvprojx index cf181983..5894235e 100644 --- a/Project/RVMDK-STM32F103RBT6/RMP.uvprojx +++ b/Project/RVMDK-STM32F103RBT6-COV/RMP.uvprojx @@ -314,7 +314,7 @@ 1 - 1 + 4 1 0 1 @@ -333,7 +333,7 @@ 5 0 0 - 0 + 1 0 0 @@ -475,9 +475,9 @@ Test - rmp_benchmark.c + rmp_coverage.c 1 - ..\..\Source\Test\rmp_benchmark.c + ..\..\Source\Test\rmp_coverage.c diff --git a/Project/RVMDK-STM32F103RBT6/RTE/RTE_Components.h b/Project/RVMDK-STM32F103RBT6-COV/RTE/RTE_Components.h similarity index 100% rename from Project/RVMDK-STM32F103RBT6/RTE/RTE_Components.h rename to Project/RVMDK-STM32F103RBT6-COV/RTE/RTE_Components.h diff --git a/Project/RVMDK-STM32F103RBT6/RTE/_RMP/RTE_Components.h b/Project/RVMDK-STM32F103RBT6-COV/RTE/_RMP/RTE_Components.h similarity index 100% rename from Project/RVMDK-STM32F103RBT6/RTE/_RMP/RTE_Components.h rename to Project/RVMDK-STM32F103RBT6-COV/RTE/_RMP/RTE_Components.h diff --git a/Project/RVMDK-STM32F103RBT6/rmp_platform.h b/Project/RVMDK-STM32F103RBT6-COV/rmp_platform.h similarity index 100% rename from Project/RVMDK-STM32F103RBT6/rmp_platform.h rename to Project/RVMDK-STM32F103RBT6-COV/rmp_platform.h diff --git a/Project/RVMDK-STM32F103RBT6/rmp_platform_a7m_conf.h b/Project/RVMDK-STM32F103RBT6-COV/rmp_platform_a7m_conf.h similarity index 90% rename from Project/RVMDK-STM32F103RBT6/rmp_platform_a7m_conf.h rename to Project/RVMDK-STM32F103RBT6-COV/rmp_platform_a7m_conf.h index f718cb15..339edaa1 100644 --- a/Project/RVMDK-STM32F103RBT6/rmp_platform_a7m_conf.h +++ b/Project/RVMDK-STM32F103RBT6-COV/rmp_platform_a7m_conf.h @@ -7,7 +7,7 @@ Description : The configuration file for ARMv7-M HAL. ******************************************************************************/ /* Config Includes ***********************************************************/ -#include "Platform/A7M/Chip/STM32F103RB/rmp_platform_stm32f103rb.h" +#include "rmp_platform_stm32f103rb.h" /* End Config Includes *******************************************************/ /* End Of File ***************************************************************/ diff --git a/Project/RVMDK-STM32F103RBT6-COV/rmp_platform_stm32f103rb.h b/Project/RVMDK-STM32F103RBT6-COV/rmp_platform_stm32f103rb.h new file mode 100644 index 00000000..9246f742 --- /dev/null +++ b/Project/RVMDK-STM32F103RBT6-COV/rmp_platform_stm32f103rb.h @@ -0,0 +1,120 @@ +/****************************************************************************** +Filename : rmp_platform_stm32f103rb.h +Author : pry +Date : 24/06/2017 +Licence : The Unlicense; see LICENSE for details. +Description: The configuration file for STM32F103RB. +******************************************************************************/ + +/* Define ********************************************************************/ +/* The HAL library */ +#include "stm32f1xx_hal.h" +#include "stm32f1xx_hal_conf.h" +#include "core_cm3.h" + +/* Debugging */ +#define RMP_ASSERT_CORRECT (0U) +/* Coverage */ +#define RMP_COVERAGE_LINE_NUM (6144U) + +/* The maximum number of preemption priority levels in the system. + * This parameter must be divisible by the word length - 32 is usually sufficient */ +#define RMP_PREEMPT_PRIO_NUM (64U) +/* The maximum number of slices allowed */ +#define RMP_SLICE_MAX (100000U) +/* The maximum number of semaphore counts allowed */ +#define RMP_SEM_CNT_MAX (1000U) +/* Are we using custom hooks? */ +#define RMP_HOOK_EXTRA (0U) +/* The stzck size of the init thread */ +#define RMP_INIT_STACK_SIZE (256U) +/* The mask/unmask interrupt operations - can be adjusted to fit your own levels */ +#define RMP_INT_MASK() RMP_Int_Mask(0xFFU) +#define RMP_INT_UNMASK() RMP_Int_Mask(0x00U) + +/* What is the NVIC priority grouping? */ +#define RMP_A7M_NVIC_GROUPING RMP_A7M_NVIC_GROUPING_P2S6 +/* What is the Systick value? */ +#define RMP_A7M_SYSTICK_VAL (7200U) + +/* Other low-level initialization stuff - clock and serial + * STM32F10x APB1<36MHz, APB2<72MHz. + * This is the default initialization sequence. If you wish to supply + * your own, just redirect this macro to a custom function, or do your + * initialization stuff in the initialization hook (RMP_Start_Hook). */ +#define RMP_A7M_LOWLVL_INIT() \ +do \ +{ \ + RCC_OscInitTypeDef Osc_Init; \ + RCC_ClkInitTypeDef Clk_Init; \ + UART_HandleTypeDef USART1_Handle; \ + GPIO_InitTypeDef GPIOA_Init; \ + HAL_Init(); \ + RMP_Clear(&Osc_Init, sizeof(RCC_OscInitTypeDef)); \ + RMP_Clear(&Clk_Init, sizeof(RCC_ClkInitTypeDef)); \ + RMP_Clear(&USART1_Handle, sizeof(UART_HandleTypeDef)); \ + RMP_Clear(&GPIOA_Init, sizeof(GPIO_InitTypeDef)); \ + \ + /* Enable HSE Oscillator and activate PLL with HSE as source */ \ + Osc_Init.OscillatorType=RCC_OSCILLATORTYPE_HSE; \ + Osc_Init.HSEState=RCC_HSE_ON; \ + Osc_Init.HSEPredivValue=RCC_HSE_PREDIV_DIV1; \ + Osc_Init.PLL.PLLState=RCC_PLL_ON; \ + Osc_Init.PLL.PLLSource=RCC_PLLSOURCE_HSE; \ + Osc_Init.PLL.PLLMUL=RCC_PLL_MUL9; \ + RMP_ASSERT(HAL_RCC_OscConfig(&Osc_Init)==HAL_OK); \ + \ + /* Secect PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ \ + Clk_Init.ClockType=(RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2); \ + Clk_Init.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK; \ + Clk_Init.AHBCLKDivider=RCC_SYSCLK_DIV1; \ + Clk_Init.APB2CLKDivider=RCC_HCLK_DIV1; \ + Clk_Init.APB1CLKDivider=RCC_HCLK_DIV2; \ + RMP_ASSERT(HAL_RCC_ClockConfig(&Clk_Init, FLASH_LATENCY_2)==HAL_OK); \ + __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); \ + \ + __HAL_RCC_GPIOA_CLK_ENABLE(); \ + __HAL_RCC_USART1_CLK_ENABLE(); \ + GPIOA_Init.Mode=GPIO_MODE_AF_PP; \ + GPIOA_Init.Pin=GPIO_PIN_9; \ + GPIOA_Init.Speed=GPIO_SPEED_FREQ_HIGH; \ + HAL_GPIO_Init(GPIOA, &GPIOA_Init); \ + \ + USART1_Handle.Instance=USART1; \ + USART1_Handle.Init.BaudRate=115200; \ + USART1_Handle.Init.WordLength=UART_WORDLENGTH_8B; \ + USART1_Handle.Init.StopBits=UART_STOPBITS_1; \ + USART1_Handle.Init.Parity=UART_PARITY_NONE; \ + USART1_Handle.Init.HwFlowCtl=UART_HWCONTROL_NONE; \ + USART1_Handle.Init.Mode=UART_MODE_TX; \ + HAL_UART_Init(&USART1_Handle); \ + RMP_A7M_PUTCHAR('\r'); \ + RMP_A7M_PUTCHAR('\n'); \ + /* Enable all fault handlers */ \ + SCB->SHCSR|=RMP_A7M_SHCSR_USGFAULTENA|RMP_A7M_SHCSR_BUSFAULTENA|RMP_A7M_SHCSR_MEMFAULTENA; \ + \ + /* Set the priority of timer, svc and faults to the lowest */ \ + NVIC_SetPriorityGrouping(RMP_A7M_NVIC_GROUPING); \ + NVIC_SetPriority(SVCall_IRQn,0xFFU); \ + NVIC_SetPriority(PendSV_IRQn,0xFFU); \ + NVIC_SetPriority(SysTick_IRQn,0xFFU); \ + NVIC_SetPriority(BusFault_IRQn,0xFFU); \ + NVIC_SetPriority(UsageFault_IRQn,0xFFU); \ + NVIC_SetPriority(DebugMonitor_IRQn,0xFFU); \ + SysTick_Config(RMP_A7M_SYSTICK_VAL); \ +} \ +while(0) + +/* This is for debugging output */ +#define RMP_A7M_PUTCHAR(CHAR) \ +do \ +{ \ + USART1->DR=CHAR; \ + while((USART1->SR&0x40U)==0U); \ +} \ +while(0) +/* End Define ****************************************************************/ + +/* End Of File ***************************************************************/ + +/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/ diff --git a/Project/RVMDK-STM32F103RBT6/rmp_test.h b/Project/RVMDK-STM32F103RBT6-COV/rmp_test.h similarity index 100% rename from Project/RVMDK-STM32F103RBT6/rmp_test.h rename to Project/RVMDK-STM32F103RBT6-COV/rmp_test.h diff --git a/Source/Kernel/rmp_kernel.c b/Source/Kernel/rmp_kernel.c index 1a35e062..c8580593 100644 --- a/Source/Kernel/rmp_kernel.c +++ b/Source/Kernel/rmp_kernel.c @@ -452,28 +452,41 @@ rmp_ptr_t RMP_RBT_Generic(rmp_ptr_t Value) } /* End Function:RMP_RBT_Generic **********************************************/ -/* Function:RMP_Print_Coverage ************************************************ +/* Function:RMP_Coverage_Print ************************************************ Description : The coverage data printer. Should always be disabled for all cases except where a kernel coverage test is needed. This should never - be called ny any user application; for EDI coverage testing only. + be called any any user application; for coverage testing only. Input : None. Output : None. Return : None. ******************************************************************************/ -#ifdef RMP_COVERAGE -void RMP_Print_Coverage(void) +#ifdef RMP_COVERAGE_LINE_NUM +void RMP_Coverage_Print(void) { rmp_ptr_t Count; + rmp_ptr_t Next; - for(Count=1U;Count>RMP_WORD_ORDER]&RMP_POW2(Count&RMP_WORD_MASK))!=0U) { RMP_COVERAGE_MARKER(); RMP_DBG_I(Count); - RMP_DBG_S(":"); - RMP_DBG_I(RMP_Coverage[Count]); - RMP_DBG_S("\r\n"); + RMP_DBG_S(","); + /* We put 12 markers on a single line */ + Next++; + if(Next>11U) + { + RMP_COVERAGE_MARKER(); + Next=0U; + RMP_DBG_S("\r\n"); + } + else + { + RMP_COVERAGE_MARKER(); + /* No action needed */ + } } else { @@ -483,7 +496,7 @@ void RMP_Print_Coverage(void) } } #endif -/* End Function:RMP_Print_Coverage *******************************************/ +/* End Function:RMP_Coverage_Print *******************************************/ /* Function:RMP_Clear ********************************************************* Description : Memset a memory area to zero. @@ -3110,9 +3123,9 @@ int main(void) { rmp_ptr_t Count; -#ifdef RMP_COVERAGE +#ifdef RMP_COVERAGE_LINE_NUM /* Initialize coverage markers if coverage enabled */ - for(Count=0U;Count