Skip to content

Commit

Permalink
introduce porting layer
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Jan 20, 2024
1 parent 461dcd5 commit f76481b
Show file tree
Hide file tree
Showing 18 changed files with 975 additions and 255 deletions.
32 changes: 25 additions & 7 deletions GorgonMeducer.perf_counter.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
-->

<components>
<component Cclass="Utilities" Cversion="2.2.5" Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="perf_counter.h"/>
Expand All @@ -275,11 +275,12 @@
#define __PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__ 1
</Pre_Include_Global_h>
</component>
<component Cclass="Utilities" Cversion="2.2.5" Cgroup="perf_counter" Csub="Core" Cvariant="Source" isDefaultVariant="true" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="Core" Cvariant="Source" isDefaultVariant="true" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="perf_counter.h"/>
<file category="sourceC" name="perf_counter.c" />
<file category="sourceC" name="perfc_port_default.c" />
<file category="sourceAsm" name="systick_wrapper_ual.s" condition="Previous Generation Cortex-M Arm Compiler CMSIS-CORE"/>
<file category="sourceAsm" name="systick_wrapper_gcc.S" condition="Cortex-M Arm GCC CMSIS-CORE"/>
<file category="sourceAsm" name="systick_wrapper_gnu.s" condition="Armv8-M Arm Compiler CMSIS-CORE"/>
Expand All @@ -295,17 +296,34 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.5" Cgroup="perf_counter" Csub="Core" Cvariant="SourceNoWrapper" isDefaultVariant="false" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="Core" Cvariant="SourceNoWrapper" isDefaultVariant="false" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="perf_counter.h"/>
<file category="sourceC" name="perf_counter.c" />
<file category="sourceC" name="perfc_port_default.c" />
</files>
<RTE_Components_h>

#define __PERF_COUNTER__ 1
</RTE_Components_h>
</component>

<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="Porting" Cvariant="User Defined" isDefaultVariant="true" condition="perf_counter">
<description>A user define system timer</description>
<files>
<file category="sourceC" name="template/perfc_port_user.c" attr="config" version="1.0.1"/>
<file category="Header" name="template/perfc_port_user.h" attr="config" version="1.0.1"/>
</files>

<Pre_Include_Global_h>

#define __PERFC_USE_USER_CUSTOM_PORTING__ 1
#define __PERFC_CFG_DISABLE_DEFAULT_SYSTICK_PORTING__ 1
#define __PERFC_CFG_PORTING_INCLUDE__ "perfc_port_user.h"

</Pre_Include_Global_h>
</component>


<component Cclass="Utilities" Cgroup="perf_counter" Csub="Benchmark" Cvariant="Coremark" Cversion="1.1.2" condition="perf_counter">
Expand All @@ -331,7 +349,7 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="RTX5 Patch" condition="RTX5 Patch">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="RTX5 Patch" condition="RTX5 Patch">
<description>A Patch for RTX5</description>
<files>
<file category="source" name="os/perf_os_patch_rtx5.c"/>
Expand All @@ -343,7 +361,7 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
<description>A Patch for FreeRTOS</description>
<files>
<file category="sourceC" name="os/perf_os_patch_freertos.c"/>
Expand All @@ -366,7 +384,7 @@ extern void __freertos_evr_on_task_switched_in(void *ptTCB, unsigned int uxTopPr
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
<description>A Patch for RT-Thread</description>
<files>
<file category="sourceC" name="os/perf_os_patch_rt_thread.c"/>
Expand All @@ -384,7 +402,7 @@ extern void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="ThreadX Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.3.0" Cgroup="perf_counter" Csub="ThreadX Patch" condition="perf_counter">
<description>A Patch for ThreadX</description>
<files>
<file category="sourceC" name="os/perf_os_patch_threadx.c"/>
Expand Down
80 changes: 80 additions & 0 deletions example/RTE/Device/ARMCM0/ARMCM0_ac6.sct
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#! armclang -E --target=arm-arm-none-eabi -mcpu=cortex-m0 -xc
; command above MUST be in first line (no comment above!)

/*
;-------- <<< Use Configuration Wizard in Context Menu >>> -------------------
*/

/*--------------------- Flash Configuration ----------------------------------
; <h> Flash Configuration
; <o0> Flash Base Address <0x0-0xFFFFFFFF:8>
; <o1> Flash Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
*----------------------------------------------------------------------------*/
#define __ROM_BASE 0x00000000
#define __ROM_SIZE 0x00080000

/*--------------------- Embedded RAM Configuration ---------------------------
; <h> RAM Configuration
; <o0> RAM Base Address <0x0-0xFFFFFFFF:8>
; <o1> RAM Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
*----------------------------------------------------------------------------*/
#define __RAM_BASE 0x20000000
#define __RAM_SIZE 0x00040000

/*--------------------- Stack / Heap Configuration ---------------------------
; <h> Stack / Heap Configuration
; <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
*----------------------------------------------------------------------------*/
#define __STACK_SIZE 0x00000200
#define __HEAP_SIZE 0x00000C00

/*
;------------- <<< end of configuration section >>> ---------------------------
*/


/*----------------------------------------------------------------------------
User Stack & Heap boundary definition
*----------------------------------------------------------------------------*/
#define __STACK_TOP (__RAM_BASE + __RAM_SIZE) /* starts at end of RAM */
#define __HEAP_BASE (AlignExpr(+0, 8)) /* starts after RW_RAM section, 8 byte aligned */


/*----------------------------------------------------------------------------
Scatter File Definitions definition
*----------------------------------------------------------------------------*/
#define __RO_BASE __ROM_BASE
#define __RO_SIZE __ROM_SIZE

#define __RW_BASE __RAM_BASE
#define __RW_SIZE (__RAM_SIZE - __STACK_SIZE - __HEAP_SIZE)


LR_ROM __RO_BASE __RO_SIZE { ; load region size_region
ER_ROM __RO_BASE __RO_SIZE { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
.ANY (+XO)
}

RW_NOINIT __RW_BASE UNINIT __RW_SIZE {
*(.bss.noinit)
}

RW_RAM AlignExpr(+0, 8) (__RW_SIZE - AlignExpr(ImageLength(RW_NOINIT), 8)) {
*(+RW +ZI)
}

#if __HEAP_SIZE > 0
ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap
}
#endif

ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack
}
}
146 changes: 146 additions & 0 deletions example/RTE/Device/ARMCM0/startup_ARMCM0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/******************************************************************************
* @file startup_ARMCM0.c
* @brief CMSIS-Core(M) Device Startup File for a Cortex-M0 Device
* @version V2.0.3
* @date 31. March 2020
******************************************************************************/
/*
* Copyright (c) 2009-2020 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#if defined (ARMCM0)
#include "ARMCM0.h"
#else
#error device not specified!
#endif

/*----------------------------------------------------------------------------
External References
*----------------------------------------------------------------------------*/
extern uint32_t __INITIAL_SP;

extern __NO_RETURN void __PROGRAM_START(void);

/*----------------------------------------------------------------------------
Internal References
*----------------------------------------------------------------------------*/
__NO_RETURN void Reset_Handler (void);
void Default_Handler(void);

/*----------------------------------------------------------------------------
Exception / Interrupt Handler
*----------------------------------------------------------------------------*/
/* Exceptions */
void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void HardFault_Handler (void) __attribute__ ((weak));
void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler")));

void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler")));


/*----------------------------------------------------------------------------
Exception / Interrupt Vector table
*----------------------------------------------------------------------------*/

#if defined ( __GNUC__ )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif

extern const VECTOR_TABLE_Type __VECTOR_TABLE[48];
const VECTOR_TABLE_Type __VECTOR_TABLE[48] __VECTOR_TABLE_ATTRIBUTE = {
(VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */
Reset_Handler, /* Reset Handler */
NMI_Handler, /* -14 NMI Handler */
HardFault_Handler, /* -13 Hard Fault Handler */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
0, /* Reserved */
SVC_Handler, /* -5 SVCall Handler */
0, /* Reserved */
0, /* Reserved */
PendSV_Handler, /* -2 PendSV Handler */
SysTick_Handler, /* -1 SysTick Handler */

/* Interrupts */
Interrupt0_Handler, /* 0 Interrupt 0 */
Interrupt1_Handler, /* 1 Interrupt 1 */
Interrupt2_Handler, /* 2 Interrupt 2 */
Interrupt3_Handler, /* 3 Interrupt 3 */
Interrupt4_Handler, /* 4 Interrupt 4 */
Interrupt5_Handler, /* 5 Interrupt 5 */
Interrupt6_Handler, /* 6 Interrupt 6 */
Interrupt7_Handler, /* 7 Interrupt 7 */
Interrupt8_Handler, /* 8 Interrupt 8 */
Interrupt9_Handler /* 9 Interrupt 9 */
/* Interrupts 10..31 are left out */
};

#if defined ( __GNUC__ )
#pragma GCC diagnostic pop
#endif

/*----------------------------------------------------------------------------
Reset Handler called on controller reset
*----------------------------------------------------------------------------*/
__NO_RETURN void Reset_Handler(void)
{
SystemInit(); /* CMSIS System Initialization */
__PROGRAM_START(); /* Enter PreMain (C library entry point) */
}


#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#endif

/*----------------------------------------------------------------------------
Hard Fault Handler
*----------------------------------------------------------------------------*/
void HardFault_Handler(void)
{
while(1);
}

/*----------------------------------------------------------------------------
Default Handler for Exceptions / Interrupts
*----------------------------------------------------------------------------*/
void Default_Handler(void)
{
while(1);
}

#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#pragma clang diagnostic pop
#endif

3 changes: 1 addition & 2 deletions example/example.uvmpw
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<Header>### uVision Project, (C) Keil Software</Header>

<WorkspaceName>WorkSpace</WorkspaceName>
<WorkspaceName>Y:\Work\git\perf_counter\example\example.uvmpw</WorkspaceName>

<project>
<PathAndName>.\example.uvprojx</PathAndName>
Expand All @@ -15,7 +15,6 @@

<project>
<PathAndName>.\gcc_example.uvprojx</PathAndName>
<NodeIsExpanded>1</NodeIsExpanded>
</project>

</ProjectWorkspace>
Loading

0 comments on commit f76481b

Please sign in to comment.