From 50f39cc64d907938028292c9ba493833fcbcad90 Mon Sep 17 00:00:00 2001 From: Runyu Pan Date: Fri, 24 May 2024 23:43:00 +0800 Subject: [PATCH] :rocket: finish up AVR support --- .../ATMEGA1284P/rmp_platform_atmega1284p.h | 24 ++- .../Chip/ATMEGA2560/rmp_platform_atmega2560.h | 25 ++- Include/Platform/AVR/rmp_platform_avr.h | 16 +- Include/Platform/AVR/rmp_platform_avr_gcc.inc | 61 +++--- Include/Test/Chip/rmp_test_atmega1284p.h | 52 ++++- Include/Test/Chip/rmp_test_atmega2560.h | 135 ++++++++++++ .../ATS-ATMEGA1284P/RMP/RMP.componentinfo.xml | 14 +- Project/ATS-ATMEGA1284P/RMP/RMP.cproj | 105 ++++++---- .../RMP/rmp_platform_avr_conf.h | 4 +- Project/ATS-ATMEGA1284P/RMP/rmp_test.h | 2 +- .../RMP/rmp_test_atmega1284p_gcc.s | 16 +- Project/ATS-ATMEGA2560/RMP.atsln | 22 ++ .../ATS-ATMEGA2560/RMP/RMP.componentinfo.xml | 86 ++++++++ Project/ATS-ATMEGA2560/RMP/RMP.cproj | 197 ++++++++++++++++++ Project/ATS-ATMEGA2560/RMP/rmp_platform.h | 15 ++ .../RMP/rmp_platform_avr_conf.h | 15 ++ Project/ATS-ATMEGA2560/RMP/rmp_test.h | 15 ++ .../RMP/rmp_test_atmega2560_gcc.s | 48 +++++ README.md | 11 +- README_CN.md | 62 +++--- Source/Kernel/rmp_kernel.c | 2 +- Source/Platform/AVR/rmp_platform_avr.c | 7 +- Source/Platform/AVR/rmp_platform_avr_gcc.s | 90 +++----- Source/Test/rmp_benchmark.c | 12 +- 24 files changed, 825 insertions(+), 211 deletions(-) create mode 100644 Include/Test/Chip/rmp_test_atmega2560.h create mode 100644 Project/ATS-ATMEGA2560/RMP.atsln create mode 100644 Project/ATS-ATMEGA2560/RMP/RMP.componentinfo.xml create mode 100644 Project/ATS-ATMEGA2560/RMP/RMP.cproj create mode 100644 Project/ATS-ATMEGA2560/RMP/rmp_platform.h create mode 100644 Project/ATS-ATMEGA2560/RMP/rmp_platform_avr_conf.h create mode 100644 Project/ATS-ATMEGA2560/RMP/rmp_test.h create mode 100644 Project/ATS-ATMEGA2560/RMP/rmp_test_atmega2560_gcc.s diff --git a/Include/Platform/AVR/Chip/ATMEGA1284P/rmp_platform_atmega1284p.h b/Include/Platform/AVR/Chip/ATMEGA1284P/rmp_platform_atmega1284p.h index 9789b9c9..b885be85 100644 --- a/Include/Platform/AVR/Chip/ATMEGA1284P/rmp_platform_atmega1284p.h +++ b/Include/Platform/AVR/Chip/ATMEGA1284P/rmp_platform_atmega1284p.h @@ -27,7 +27,7 @@ Description: The configuration file for ATMEGA1284P. #define RMP_INT_MASK() RMP_Int_Disable() #define RMP_INT_UNMASK() RMP_Int_Enable() -/* What is the Systick value? */ +/* What is the Systick value? 50U = 12800 cycles = 0.8ms */ #define RMP_AVR_TICK_VAL (50U) /* Does the chip have RAMP, EIND, and is it XMEGA? */ #define RMP_AVR_COP_RAMP (1U) @@ -41,18 +41,32 @@ Description: The configuration file for ATMEGA1284P. #define RMP_AVR_LOWLVL_INIT() \ do \ { \ - /* No need to set clock because we have fuse bits */ \ - \ - /* Initialize serial */ \ + /* USART0 TX pin - PD1 */ \ + DDRD=0x02U; \ + /* USART0 - double speed, TX only, 115200-8-N-1 */ \ + UCSR0A=0x02U; \ + UCSR0B=0x08U; \ + UCSR0C=0x06U; \ + UBRR0=16U; \ + /* Timer 0 - CTC mode, UP counter, prescaler 256 */ \ + TCNT0=0x00U; \ + OCR0A=RMP_AVR_TICK_VAL; \ + TIFR0=0x00U; \ + TCCR0A=0x02U; \ + TCCR0B=0x04U; \ + TIMSK0=0x02U; \ } \ while(0) -#define RMP_AVR_TIM_CLR() +#define RMP_AVR_TIM_CLR() (TIFR0=0x00U) /* This is for debugging output */ #define RMP_AVR_PUTCHAR(CHAR) \ do \ { \ + /* Wait for transmit buffer to be empty */ \ + while((UCSR0A&0x20U)==0U); \ + UDR0=(CHAR); \ } \ while(0) /* End Define ****************************************************************/ diff --git a/Include/Platform/AVR/Chip/ATMEGA2560/rmp_platform_atmega2560.h b/Include/Platform/AVR/Chip/ATMEGA2560/rmp_platform_atmega2560.h index 89d71c86..e6e1eb92 100644 --- a/Include/Platform/AVR/Chip/ATMEGA2560/rmp_platform_atmega2560.h +++ b/Include/Platform/AVR/Chip/ATMEGA2560/rmp_platform_atmega2560.h @@ -7,7 +7,7 @@ Description: The configuration file for ATMEGA2560. ******************************************************************************/ /* Define ********************************************************************/ -/* The HAL library */ +/* The AVR I/O library */ #include "avr/io.h" /* Debugging */ @@ -27,8 +27,8 @@ Description: The configuration file for ATMEGA2560. #define RMP_INT_MASK() RMP_Int_Disable() #define RMP_INT_UNMASK() RMP_Int_Enable() -/* What is the Systick value? */ -#define RMP_AVR_TICK_VAL (2000U) +/* What is the Systick value? 50U = 12800 cycles = 0.8ms */ +#define RMP_AVR_TICK_VAL (50U) /* Does the chip have RAMP, EIND, and is it XMEGA? */ #define RMP_AVR_COP_RAMP (1U) #define RMP_AVR_COP_EIND (1U) @@ -41,15 +41,32 @@ Description: The configuration file for ATMEGA2560. #define RMP_AVR_LOWLVL_INIT() \ do \ { \ + /* USART0 TX pin - PE1 */ \ + DDRE=0x02U; \ + /* USART0 - double speed, TX only, 115200-8-N-1 */ \ + UCSR0A=0x02U; \ + UCSR0B=0x08U; \ + UCSR0C=0x06U; \ + UBRR0=16U; \ + /* Timer 0 - CTC mode, UP counter, prescaler 256 */ \ + TCNT0=0x00U; \ + OCR0A=RMP_AVR_TICK_VAL; \ + TIFR0=0x00U; \ + TCCR0A=0x02U; \ + TCCR0B=0x04U; \ + TIMSK0=0x02U; \ } \ while(0) -#define RMP_AVR_TIM_CLR() +#define RMP_AVR_TIM_CLR() (TIFR0=0x00U) /* This is for debugging output */ #define RMP_AVR_PUTCHAR(CHAR) \ do \ { \ + /* Wait for transmit buffer to be empty */ \ + while((UCSR0A&0x20U)==0U); \ + UDR0=(CHAR); \ } \ while(0) /* End Define ****************************************************************/ diff --git a/Include/Platform/AVR/rmp_platform_avr.h b/Include/Platform/AVR/rmp_platform_avr.h index 899fa142..0c1b2828 100644 --- a/Include/Platform/AVR/rmp_platform_avr.h +++ b/Include/Platform/AVR/rmp_platform_avr.h @@ -5,6 +5,7 @@ Date : 01/04/2017 Licence : The Unlicense; see LICENSE for details. Description : The header of "rmp_platform_avr.c". This port supports both MegaAVR and XMegaAVR but not TinyAVR. + Supported cores include AVRe, AVRe+, AVRxm and AVRxt. Please refrain from trying to use this port on chips that has less than 32kB of Flash, because the kernel uses about 16kB. In contrast, the IAR compiler is expected to generate less code @@ -12,7 +13,15 @@ Description : The header of "rmp_platform_avr.c". software stack as most 8-bitters lack SP-relative addressing), however this scheme precludes the porting of the kernel. This port is supplied as a proof of existence of RMP on even - 8-bit devices rather than to be used in a production setting. + 8-bit devices rather than to be used in a production setting; + AVR is not particularly great in term of code density when + compared with other 8-bitters such as PIC, STM8, and even 8051. + All kernel functions assume zero for all RAMP/EIND segment + registers; still, they are saved and restored as a part of the + context switch, and are cleared before calling any ISR written + in C. This is in accordance with the GCC's use of these registers, + and the user is responsible for clearing them when they are + changed before calling the kernel APIs. ******************************************************************************/ /* Define ********************************************************************/ @@ -151,11 +160,12 @@ struct RMP_AVR_Stack rmp_u8_t R29_YH; rmp_u8_t R30_ZL; rmp_u8_t R31_ZH; - rmp_u8_t PCL; - rmp_u8_t PCH; + /* Big-endian for CALL and interrupt entry PC */ #if(RMP_AVR_COP_EIND!=0U) rmp_u8_t PCU; #endif + rmp_u8_t PCH; + rmp_u8_t PCL; }; /*****************************************************************************/ /* __RMP_PLATFORM_AVR_STRUCT__ */ diff --git a/Include/Platform/AVR/rmp_platform_avr_gcc.inc b/Include/Platform/AVR/rmp_platform_avr_gcc.inc index ffed1bfc..19ef588b 100644 --- a/Include/Platform/AVR/rmp_platform_avr_gcc.inc +++ b/Include/Platform/AVR/rmp_platform_avr_gcc.inc @@ -28,13 +28,13 @@ Description : The assembly part of the RMP RTOS. This is for AVR, and .extern _RMP_AVR_SP_Kern /* The current thread stack */ .extern RMP_SP_Cur - ;The interrupt active flag + /* The interrupt active flag */ .extern RMP_AVR_Int_Act - ;The yield pending flag + /* The yield pending flag */ .extern _RMP_AVR_Yield_Pend - ;Extract highest priority running thread + /* Extract highest priority running thread */ .extern _RMP_Run_High - ;Handler for DSPIC timer interrupt + /* Handler for DSPIC timer interrupt */ .extern _RMP_AVR_Tim_Handler /* End Import ****************************************************************/ @@ -79,45 +79,34 @@ Description : The assembly part of the RMP RTOS. This is for AVR, and /* Actual context switch *****************************************************/ .macro RMP_AVR_SWITCH_PRE - IN R18,RMP_SPL /* Save the SP to control block */ - IN R19,RMP_SPH - LDI R28,lo8(RMP_SP_Cur) /* Y[29:28] is Callee-save */ - LDI R29,hi8(RMP_SP_Cur) - ST Y,R18 - STD Y+1,R19 - LDI R30,lo8(_RMP_AVR_SP_Kern) /* Load SP for kernel */ - LDI R31,hi8(_RMP_AVR_SP_Kern) - LD R18,Z - LDD R19,Z+1 - OUT RMP_SPL,R18 + IN R19,RMP_SPH /* Save the SP to control block */ + IN R18,RMP_SPL + STS RMP_SP_Cur+1,R19 + STS RMP_SP_Cur,R18 + LDS R19,_RMP_AVR_SP_Kern+1 /* Load SP for kernel */ + LDS R18,_RMP_AVR_SP_Kern OUT RMP_SPH,R19 - LDI R30,lo8(RMP_AVR_Int_Act) /* Indicate interrupt active */ - LDI R31,hi8(RMP_AVR_Int_Act) - LDI R18,1 - ST Z,R18 + OUT RMP_SPL,R18 + LDI R18,1 /* Indicate interrupt active */ + STS RMP_AVR_Int_Act,R18 + EOR R1,R1 /* Clear implicit zero register */ .endm /* Actual context switch *****************************************************/ .macro RMP_AVR_SWITCH_POST - LDI R30,lo8(_RMP_AVR_Yield_Pend) - LDI R31,hi8(_RMP_AVR_Yield_Pend) - LD R18,Z + LDS R18,_RMP_AVR_Yield_Pend CPI R18,0 BREQ 1f - LDI R18,0 - ST Z,R18 - LDI R30,lo8(_RMP_Run_High) - LDI R31,hi8(_RMP_Run_High) - ICALL + EOR R18,R18 + STS _RMP_AVR_Yield_Pend,R18 + CALL _RMP_Run_High /* No need to clean R1 again */ 1: - LDI R30,lo8(RMP_AVR_Int_Act) - LDI R31,hi8(RMP_AVR_Int_Act) - LDI R18,0 - ST Z,R18 - LD R18,Y /* Load the SP from control block */ - LDD R19,Y+1 /* Y[29:28] is Callee-save */ - OUT RMP_SPL,R18 + EOR R18,R18 + STS RMP_AVR_Int_Act,R18 + LDS R19,RMP_SP_Cur+1 /* Load the SP from control block */ + LDS R18,RMP_SP_Cur OUT RMP_SPH,R19 + OUT RMP_SPL,R18 .endm /* Restore all GP regs *******************************************************/ @@ -169,7 +158,7 @@ Description : The assembly part of the RMP RTOS. This is for AVR, and PUSH R20 PUSH R19 PUSH R18 - LDI R18,0x00 + EOR R18,R18 OUT RMP_RAMPD,R18 OUT RMP_RAMPX,R18 OUT RMP_RAMPY,R18 @@ -192,7 +181,7 @@ Description : The assembly part of the RMP RTOS. This is for AVR, and .macro RMP_AVR_EIND_SAVE IN R18,RMP_EIND PUSH R18 - LDI R18,0x00 + EOR R18,R18 OUT RMP_EIND,R18 .endm diff --git a/Include/Test/Chip/rmp_test_atmega1284p.h b/Include/Test/Chip/rmp_test_atmega1284p.h index 52cbe14a..dbf375cf 100644 --- a/Include/Test/Chip/rmp_test_atmega1284p.h +++ b/Include/Test/Chip/rmp_test_atmega1284p.h @@ -4,6 +4,45 @@ Author : pry Date : 22/07/2017 Licence : The Unlicense; see LICENSE for details. Description : The testbench for ATMEGA1284P. + This test takes 1 min @16 MHz. Just observe how slow the AVR is. + +GCC 4.7.4 (Atmel Studio GNU 5.4.0) -O3 + ___ __ ___ ___ + / _ \ / |/ // _ \ Simple real-time kernel + / , _// /|_/ // ___/ Standard benchmark test +/_/|_|/_/ /_//_/ +==================================================== +Test (number in CPU cycles) : AVG / MAX / MIN +Yield : 437 / 739 / 437 +Mailbox : 751 / 1036 / 734 +Semaphore : 717 / 1003 / 701 +FIFO : 314 / 609 / 307 +Message queue : 1098 / 1375 / 1073 +Blocking message queue : 1352 / 1623 / 1321 +Memory allocation/free pair : 1680 / 1809 / 1558 +ISR Mailbox : 637 / 922 / 620 +ISR Semaphore : 639 / 924 / 622 +ISR Message queue : 921 / 1198 / 896 +ISR Blocking message queue : 1087 / 1361 / 1059 + +GCC 4.7.4 (Atmel Studio GNU 5.4.0) -Os -mcall-prologues + ___ __ ___ ___ + / _ \ / |/ // _ \ Simple real-time kernel + / , _// /|_/ // ___/ Standard benchmark test +/_/|_|/_/ /_//_/ +==================================================== +Test (number in CPU cycles) : AVG / MAX / MIN +Yield : 428 / 705 / 428 +Mailbox : 793 / 1054 / 777 +Semaphore : 740 / 1002 / 725 +FIFO : 314 / 585 / 308 +Message queue : 1193 / 1445 / 1168 +Blocking message queue : 1522 / 1767 / 1490 +Memory allocation/free pair : 2220 / 2354 / 2097 +ISR Mailbox : 671 / 931 / 654 +ISR Semaphore : 634 / 895 / 618 +ISR Message queue : 944 / 1198 / 921 +ISR Blocking message queue : 1132 / 1382 / 1105 ******************************************************************************/ /* Include *******************************************************************/ @@ -44,6 +83,10 @@ Return : None. void Timer_Init(void) { /* TIM1 clock = CPU clock */ + TCCR1A=0x00U; + TCCR1B=0x01U; + TCCR1C=0x00U; + TCNT1=0x0000U; } /* End Function:Timer_Init ***************************************************/ @@ -57,11 +100,18 @@ Return : None. void Int_Init(void) { /* TIM2 clock = 1/256 CPU clock */ + TCNT2=0x00U; + OCR2A=100U; + TIFR2=0x00U; + TCCR2A=0x02U; + TCCR2B=0x04U; + TIMSK2=0x02U; } /* The interrupt handler */ void TIM2_Handler(void) { + TIFR2=0x00U; Int_Handler(); } /* End Function:Int_Init *****************************************************/ @@ -75,7 +125,7 @@ Return : None. ******************************************************************************/ void Int_Disable(void) { - + TIMSK2=0x00U; } #endif /* End Function:Int_Disable **************************************************/ diff --git a/Include/Test/Chip/rmp_test_atmega2560.h b/Include/Test/Chip/rmp_test_atmega2560.h new file mode 100644 index 00000000..2a061a8c --- /dev/null +++ b/Include/Test/Chip/rmp_test_atmega2560.h @@ -0,0 +1,135 @@ +/****************************************************************************** +Filename : rmp_test_atmega2560.h +Author : pry +Date : 22/07/2017 +Licence : The Unlicense; see LICENSE for details. +Description : The testbench for ATMEGA1284P. + This test takes 1 min @16 MHz. Just observe how slow the AVR is. + +GCC 4.7.4 (Atmel Studio GNU 5.4.0) -O3 + ___ __ ___ ___ + / _ \ / |/ // _ \ Simple real-time kernel + / , _// /|_/ // ___/ Standard benchmark test +/_/|_|/_/ /_//_/ +==================================================== +Test (number in CPU cycles) : AVG / MAX / MIN +Yield : 449 / 763 / 449 +Mailbox : 774 / 1070 / 756 +Semaphore : 736 / 1033 / 719 +FIFO : 326 / 633 / 319 +Message queue : 1131 / 1418 / 1104 +Blocking message queue : 1396 / 1677 / 1363 +Memory allocation/free pair : 1686 / 1809 / 1565 +ISR Mailbox : 656 / 952 / 638 +ISR Semaphore : 654 / 950 / 636 +ISR Message queue : 942 / 1230 / 916 +ISR Blocking message queue : 1117 / 1401 / 1087 + +GCC 4.7.4 (Atmel Studio GNU 5.4.0) -Os -mcall-prologues + ___ __ ___ ___ + / _ \ / |/ // _ \ Simple real-time kernel + / , _// /|_/ // ___/ Standard benchmark test +/_/|_|/_/ /_//_/ +==================================================== +Test (number in CPU cycles) : AVG / MAX / MIN +Yield : 442 / 731 / 442 +Mailbox : 825 / 1096 / 807 +Semaphore : 768 / 1041 / 752 +FIFO : 331 / 613 / 324 +Message queue : 1246 / 1508 / 1219 +Blocking message queue : 1596 / 1850 / 1561 +Memory allocation/free pair : 2253 / 2395 / 2128 +ISR Mailbox : 694 / 966 / 677 +ISR Semaphore : 655 / 927 / 638 +ISR Message queue : 977 / 1242 / 953 +ISR Blocking message queue : 1176 / 1437 / 1148 +******************************************************************************/ + +/* Include *******************************************************************/ +#include "rmp.h" +/* End Include ***************************************************************/ + +/* Define ********************************************************************/ +/* How to read counter */ +#define RMP_CNT_READ() ((rmp_tim_t)(TCNT1)) +/* Are we testing the memory pool? */ +#define TEST_MEM_POOL (2048U) +/* Are we doing minimal measurements? */ +/* #define MINIMAL_SIZE */ +/* The AVR timers we use is 16 bits, so */ +typedef rmp_u16_t rmp_tim_t; +/* The pointer is also 16-bit, resort to 32-bit accumulators */ +#define PTR_16_BIT +/* End Define ****************************************************************/ + +/* Global ********************************************************************/ +#ifndef MINIMAL_SIZE +void Int_Handler(void); +rmp_ptr_t Stack_1[256]; +rmp_ptr_t Stack_2[256]; + +void Timer_Init(void); +void Int_Init(void); +void Int_Disable(void); +/* End Global ****************************************************************/ + +/* Function:Timer_Init ******************************************************** +Description : Initialize the timer for timing measurements. This function needs + to be adapted to your specific hardware. +Input : None. +Output : None. +Return : None. +******************************************************************************/ +void Timer_Init(void) +{ + /* TIM1 clock = CPU clock */ + TCCR1A=0x00U; + TCCR1B=0x01U; + TCCR1C=0x00U; + TCNT1=0x0000U; +} +/* End Function:Timer_Init ***************************************************/ + +/* Function:Int_Init ********************************************************** +Description : Initialize an periodic interrupt source. This function needs + to be adapted to your specific hardware. +Input : None. +Output : None. +Return : None. +******************************************************************************/ +void Int_Init(void) +{ + /* TIM2 clock = 1/256 CPU clock */ + TCNT2=0x00U; + OCR2A=100U; + TIFR2=0x00U; + TCCR2A=0x02U; + TCCR2B=0x04U; + TIMSK2=0x02U; +} + +/* The interrupt handler */ +void TIM2_Handler(void) +{ + TIFR2=0x00U; + Int_Handler(); +} +/* End Function:Int_Init *****************************************************/ + +/* Function:Int_Disable ******************************************************* +Description : Disable the periodic interrupt source. This function needs + to be adapted to your specific hardware. +Input : None. +Output : None. +Return : None. +******************************************************************************/ +void Int_Disable(void) +{ + TIMSK2=0x00U; +} +#endif +/* End Function:Int_Disable **************************************************/ + +/* End Of File ***************************************************************/ + +/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/ diff --git a/Project/ATS-ATMEGA1284P/RMP/RMP.componentinfo.xml b/Project/ATS-ATMEGA1284P/RMP/RMP.componentinfo.xml index 5d52dc17..06d38b8c 100644 --- a/Project/ATS-ATMEGA1284P/RMP/RMP.componentinfo.xml +++ b/Project/ATS-ATMEGA1284P/RMP/RMP.componentinfo.xml @@ -26,13 +26,13 @@ - C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\include\avr\iom1284p.h + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\include\avr\iom2560.h header C - sBNrZHKciubwnkFlY7UYbg== + MkwPezikXVtYA90mpLpFfA== - include/avr/iom1284p.h + include/avr/iom2560.h @@ -41,7 +41,7 @@ template source C Exe - gyuTZ9F1hwJ4stgtRel/wg== + KjvOcFWd++tbnsEMfVPd/w== templates/main.c Main file (.c) @@ -59,13 +59,13 @@ - C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega1284p + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560 libraryPrefix GCC - gcc/dev/atmega1284p + gcc/dev/atmega2560 @@ -74,7 +74,7 @@ C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.7.374/Atmel.ATmega_DFP.pdsc 1.7.374 true - ATmega1284P + ATmega2560 diff --git a/Project/ATS-ATMEGA1284P/RMP/RMP.cproj b/Project/ATS-ATMEGA1284P/RMP/RMP.cproj index 10df5582..8dce862b 100644 --- a/Project/ATS-ATMEGA1284P/RMP/RMP.cproj +++ b/Project/ATS-ATMEGA1284P/RMP/RMP.cproj @@ -5,7 +5,7 @@ 7.0 com.Atmel.AVRGCC8.C dce6c7e3-ee26-4d79-826b-08594b9ad897 - ATmega1284P + ATmega2560 none Executable C @@ -16,7 +16,7 @@ RMP RMP Native - true + false false true true @@ -40,8 +40,9 @@ - com.atmel.avrdbg.tool.simulator - + + + J30200009582 0x1E9705 @@ -55,7 +56,7 @@ Custom Programming Tool - + JTAG @@ -68,11 +69,23 @@ Simulator + + + + 200000 + + JTAG + + com.atmel.avrdbg.tool.jtagice3plus + J30200009582 + JTAGICE3 + + 200000 - -mmcu=atmega1284p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega1284p" + -mmcu=atmega2560 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560" True True True @@ -111,46 +124,46 @@ - -mmcu=atmega1284p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega1284p" - True - True - True - True - True - False - True - True - - - DEBUG - - - - - %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ - ../../../../Include - .. - - - Optimize for size (-Os) - True - True - Default (-g2) - True - - - libm - - - - - %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ - ../../../../Include - .. - - - Default (-Wa,-g) - + -mmcu=atmega2560 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560" + True + True + True + True + True + False + True + True + + + DEBUG + + + + + ../../../../Include + .. + %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ + + + Optimize for size (-Os) + True + True + Default (-g2) + True + + + libm + + + + + ../../../../Include + .. + %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ + + + Default (-Wa,-g) + diff --git a/Project/ATS-ATMEGA1284P/RMP/rmp_platform_avr_conf.h b/Project/ATS-ATMEGA1284P/RMP/rmp_platform_avr_conf.h index fed126b3..08108ed1 100644 --- a/Project/ATS-ATMEGA1284P/RMP/rmp_platform_avr_conf.h +++ b/Project/ATS-ATMEGA1284P/RMP/rmp_platform_avr_conf.h @@ -1,9 +1,9 @@ /****************************************************************************** Filename : rmp_platform_avr_conf.h Author : pry -Date : 24/06/2017 +Date : 24/05/2024 Licence : LGPL v3+; see COPYING for details. -Description : The configuration file for RV32P HAL. +Description : The configuration file for AVR HAL. ******************************************************************************/ /* Config Includes ***********************************************************/ diff --git a/Project/ATS-ATMEGA1284P/RMP/rmp_test.h b/Project/ATS-ATMEGA1284P/RMP/rmp_test.h index 8cfad20a..ee1e78f6 100644 --- a/Project/ATS-ATMEGA1284P/RMP/rmp_test.h +++ b/Project/ATS-ATMEGA1284P/RMP/rmp_test.h @@ -1,7 +1,7 @@ /****************************************************************************** Filename : rmp_test.h Author : pry -Date : 24/06/2017 +Date : 24/05/2024 Licence : LGPL v3+; see COPYING for details. Description : The configuration file for testing program. ******************************************************************************/ diff --git a/Project/ATS-ATMEGA1284P/RMP/rmp_test_atmega1284p_gcc.s b/Project/ATS-ATMEGA1284P/RMP/rmp_test_atmega1284p_gcc.s index 01a552c0..f34d0b74 100644 --- a/Project/ATS-ATMEGA1284P/RMP/rmp_test_atmega1284p_gcc.s +++ b/Project/ATS-ATMEGA1284P/RMP/rmp_test_atmega1284p_gcc.s @@ -27,11 +27,9 @@ Input : None. Output : None. ******************************************************************************/ TIMER0_COMPA_vect: - RMP_AVR_INT_SAVE_MEGA_EIND - LDI R30,lo8(_RMP_AVR_Tim_Handler) - LDI R31,hi8(_RMP_AVR_Tim_Handler) - ICALL - RMP_AVR_INT_LOAD_MEGA_EIND + RMP_AVR_INT_SAVE_MEGA_RAMP + CALL _RMP_AVR_Tim_Handler + RMP_AVR_INT_LOAD_MEGA_RAMP /* End Function:TIMER0_COMPA_vect ********************************************/ /* Function:TIMER2_COMPA_vect ************************************************* @@ -40,11 +38,9 @@ Input : None. Output : None. ******************************************************************************/ TIMER2_COMPA_vect: - RMP_AVR_INT_SAVE_MEGA_EIND - LDI R30,lo8(TIM2_Handler) - LDI R31,hi8(TIM2_Handler) - ICALL - RMP_AVR_INT_LOAD_MEGA_EIND + RMP_AVR_INT_SAVE_MEGA_RAMP + CALL TIM2_Handler + RMP_AVR_INT_LOAD_MEGA_RAMP /* End Function:TIMER2_COMPA_vect ********************************************/ /* End Of File ***************************************************************/ diff --git a/Project/ATS-ATMEGA2560/RMP.atsln b/Project/ATS-ATMEGA2560/RMP.atsln new file mode 100644 index 00000000..702272a4 --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP.atsln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Atmel Studio Solution File, Format Version 11.00 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "RMP", "RMP\RMP.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR + {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Project/ATS-ATMEGA2560/RMP/RMP.componentinfo.xml b/Project/ATS-ATMEGA2560/RMP/RMP.componentinfo.xml new file mode 100644 index 00000000..06d38b8c --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP/RMP.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.7.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\include\ + + include + C + + + include/ + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\include\avr\iom2560.h + + header + C + MkwPezikXVtYA90mpLpFfA== + + include/avr/iom2560.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\templates\main.c + template + source + C Exe + KjvOcFWd++tbnsEMfVPd/w== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\templates\main.cpp + template + source + C Exe + mkKaE95TOoATsuBGv6jmxg== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560 + + libraryPrefix + GCC + + + gcc/dev/atmega2560 + + + + + ATmega_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.7.374/Atmel.ATmega_DFP.pdsc + 1.7.374 + true + ATmega2560 + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/Project/ATS-ATMEGA2560/RMP/RMP.cproj b/Project/ATS-ATMEGA2560/RMP/RMP.cproj new file mode 100644 index 00000000..c4ce4ed5 --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP/RMP.cproj @@ -0,0 +1,197 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATmega2560 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + RMP + RMP + RMP + Native + false + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + 0 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.jtagice3plus + J30200009582 + 0x1E9801 + + + + + + + + custom + + + Custom Programming Tool + + JTAG + + + + + + + + com.atmel.avrdbg.tool.simulator + + + Simulator + + + + + 200000 + 125000 + + JTAG + + com.atmel.avrdbg.tool.jtagice3plus + J30200009582 + JTAGICE3 + + 200000 + + + + + -mmcu=atmega2560 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560" + True + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ + + + + + + + + + -mmcu=atmega2560 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega2560" + True + True + True + True + True + False + True + True + + + DEBUG + + + + + ../../../../Include + .. + %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ + + + Optimize for size (-Os) + True + True + Default (-g2) + True + + + libm + + + + + ../../../../Include + .. + %24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\ + + + Default (-Wa,-g) + + + + + + compile + Kernel\rmp_kernel.c + + + compile + Platform\rmp_platform_avr.c + + + compile + Platform\rmp_platform_avr_gcc.s + + + compile + Test\rmp_benchmark.c + + + compile + Test\rmp_test_atmega2560_gcc.s + + + + + + + + + \ No newline at end of file diff --git a/Project/ATS-ATMEGA2560/RMP/rmp_platform.h b/Project/ATS-ATMEGA2560/RMP/rmp_platform.h new file mode 100644 index 00000000..017e13cb --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP/rmp_platform.h @@ -0,0 +1,15 @@ +/****************************************************************************** +Filename : rmp_platform.h +Author : pry +Date : 22/07/2017 +Licence : LGPL v3+; see COPYING for details. +Description : The platform specific types for RMP. +******************************************************************************/ + +/* Platform Includes *********************************************************/ +#include "Platform/AVR/rmp_platform_avr.h" +/* End Platform Includes *****************************************************/ + +/* End Of File ***************************************************************/ + +/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/ diff --git a/Project/ATS-ATMEGA2560/RMP/rmp_platform_avr_conf.h b/Project/ATS-ATMEGA2560/RMP/rmp_platform_avr_conf.h new file mode 100644 index 00000000..9fe641a8 --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP/rmp_platform_avr_conf.h @@ -0,0 +1,15 @@ +/****************************************************************************** +Filename : rmp_platform_avr_conf.h +Author : pry +Date : 24/05/2024 +Licence : LGPL v3+; see COPYING for details. +Description : The configuration file for AVR HAL. +******************************************************************************/ + +/* Config Includes ***********************************************************/ +#include "Platform/AVR/Chip/ATMEGA2560/rmp_platform_atmega2560.h" +/* End Config Includes *******************************************************/ + +/* End Of File ***************************************************************/ + +/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/ diff --git a/Project/ATS-ATMEGA2560/RMP/rmp_test.h b/Project/ATS-ATMEGA2560/RMP/rmp_test.h new file mode 100644 index 00000000..e78b7b3b --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP/rmp_test.h @@ -0,0 +1,15 @@ +/****************************************************************************** +Filename : rmp_test.h +Author : pry +Date : 24/05/2024 +Licence : LGPL v3+; see COPYING for details. +Description : The configuration file for testing program. +******************************************************************************/ + +/* Config Includes ***********************************************************/ +#include "Test/Chip/rmp_test_atmega2560.h" +/* End Config Includes *******************************************************/ + +/* End Of File ***************************************************************/ + +/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/ diff --git a/Project/ATS-ATMEGA2560/RMP/rmp_test_atmega2560_gcc.s b/Project/ATS-ATMEGA2560/RMP/rmp_test_atmega2560_gcc.s new file mode 100644 index 00000000..04ad2a1d --- /dev/null +++ b/Project/ATS-ATMEGA2560/RMP/rmp_test_atmega2560_gcc.s @@ -0,0 +1,48 @@ +/****************************************************************************** +Filename : rmp_test_atmega2560_gcc.s +Author : pry +Date : 10/04/2012 +Description : The extra testing file for this chip. +******************************************************************************/ + +/* Header ********************************************************************/ + .text + /* AVR-GCC does not honor regular .include directive */ + #include "avr/io.h" + #include "Platform/AVR/rmp_platform_avr_gcc.inc" +/* End Header ****************************************************************/ + +/* Import ********************************************************************/ + .extern TIM2_Handler +/* End Import ****************************************************************/ + +/* Export ********************************************************************/ + .global TIMER0_COMPA_vect + .global TIMER2_COMPA_vect +/* End Export ****************************************************************/ + +/* Function:TIMER0_COMPA_vect ************************************************* +Description : Timer 0 interrupt routine for tick timer. Prescaler 256. +Input : None. +Output : None. +******************************************************************************/ +TIMER0_COMPA_vect: + RMP_AVR_INT_SAVE_MEGA_EIND + CALL _RMP_AVR_Tim_Handler + RMP_AVR_INT_LOAD_MEGA_EIND +/* End Function:TIMER0_COMPA_vect ********************************************/ + +/* Function:TIMER2_COMPA_vect ************************************************* +Description : Timer 2 interrupt routine for ISR latency testing. Prescaler 256. +Input : None. +Output : None. +******************************************************************************/ +TIMER2_COMPA_vect: + RMP_AVR_INT_SAVE_MEGA_EIND + CALL TIM2_Handler + RMP_AVR_INT_LOAD_MEGA_EIND +/* End Function:TIMER2_COMPA_vect ********************************************/ + +/* End Of File ***************************************************************/ + +/* Copyright (C) Evo-Devo Instrum. All rights reserved ***********************/ diff --git a/README.md b/README.md index d815db43..75224d4a 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,11 @@ This software is an official work of EDI, and thus belongs to the **public domai |Chipname |Platform |Build |Yield|Mail |Sem |FIFO |Msgq |Bmq |Mail/I|Sem/I|Msgq/I |Bmq/I |Mem | |:-----------:|:----------:|:----:|:---:|:---:|:---:|:---:|:---:|:---:|:----:|:---:|:-----:|:----:|:---:| +|ATMEGA1284P |AVR |GCC |437 |751 |717 |314 |1098 |1352 |637 |639 |921 |1087 |1680 | +|ATMEGA2560 |... |... |449 |774 |736 |326 |1131 |1396 |656 |654 |942 |1117 |1686 | +|DSPIC33EP512 |DSPIC33E |XC16 |470 |886 |766 |440 |1266 |1777 |709 |614 |958 |1254 |893 | +|MSP430F149 |MSP430 |CCS |312 |641 |573 |312 |985 |1278 |528 |487 |739 |898 |N/A | +|MSP430FR5994 |MSP430X |CCS |468 |1054 |891 |492 |1573 |2072 |891 |784 |1176 |1464 |3291 | |STM32F030F4 |Cortex-M0 |Keil |362 |763 |666 |379 |1196 |1609 |689 |616 |950 |1211 |N/A | |... |... |GCC |366 |802 |690 |396 |1246 |1685 |705 |622 |954 |1200 |N/A | |STM32L071CB |Cortex-M0+ |Keil |335 |581 |532 |253 |892 |1167 |554 |524 |756 |945 |N/A | @@ -193,13 +198,10 @@ This software is an official work of EDI, and thus belongs to the **public domai |... |... |GCC |182 |335 |288 |156 |473 |643 |313 |264 |375 |514 |332 | |TMS570LS0432 |Cortex-R4 |CCS |306 |493 |460 |193 |686 |897 |480 |464 |592 |736 |533 | |TMS570LC4357 |Cortex-R5 |CCS |275 |479 |467 |216 |746 |998 |440 |435 |595 |763 |482 | -|DSPIC33EP512 |DSPIC33E |XC16 |470 |886 |766 |440 |1266 |1777 |709 |614 |958 |1254 |893 | -|MSP430F149 |MSP430 |CCS |312 |641 |573 |312 |985 |1278 |528 |487 |739 |898 |N/A | -|MSP430FR5994 |MSP430X |CCS |468 |1054 |891 |492 |1573 |2072 |891 |784 |1176 |1464 |3291 | |PIC32MZ2048 |MIPS M14k |XC32 |260 |392 |370 |146 |540 |672 |440 |420 |530 |620 |364 | |TMS320F28335 |C28x |CCS |246 |513 |440 |235 |751 |1001 |440 |413 |622 |770 |946 | |CH32V307 |RV32IMAC |GCC |246 |426 |386 |179 |605 |767 |359 |321 |466 |593 |TBD | -|CH32V307 |RV32IMAFC |GCC |318 |495 |457 |182 |674 |836 |405 |366 |500 |624 |TBD | +|... |RV32IMAFC |GCC |318 |495 |457 |182 |674 |836 |405 |366 |500 |624 |TBD | |i9-7980XE |X86-LINUX |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |   The **[RVM](https://github.com/EDI-Systems/M7M02_Ammonite)** embedded hypervisor virtualized versions: @@ -212,6 +214,7 @@ This software is an official work of EDI, and thus belongs to the **public domai |... |... |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | |STM32F767IG |Cortex-M7 |Keil |221 |403 |348 |150 |589 |765 |942 |962 |1134 |1227 |334 | |... |... |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | +|CH32V307 |RV32IMAFC |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | In contrast, RT-Linux 4.12's best context switch time on Cortex-M7 is bigger than 25000 cycles (have to run from FMC SDRAM). This is measured with futex; if other forms of IPC such as pipes are used, this time is even longer. diff --git a/README_CN.md b/README_CN.md index 7768a8a4..a6dbedad 100644 --- a/README_CN.md +++ b/README_CN.md @@ -180,39 +180,41 @@ Click **[HERE](README.md)** for English version.   `Msgq`和`Bmq`的区别在于前者只有接收方可以阻塞,后者双方都可以阻塞。 -|芯片 |架构 |工具链 | Yield | Mail | Sem | FIFO | Msgq | Bmq | Mail/I | Sem/I | Msgq/I | Bmq/I | Mem | -| :----------: | :--------: | :---: | :---: | :--: | :--: | :--: | :--: | :--: | :----: | :---: | :----: | :---: | :--: | -| STM32F030F4 | Cortex-M0 | Keil | 362 | 763 | 666 | 379 | 1196 | 1609 | 689 | 616 | 950 | 1211 | N/A | -| ... | ... | GCC | 366 | 802 | 690 | 396 | 1246 | 1685 | 705 | 622 | 954 | 1200 | N/A | -| STM32L071CB | Cortex-M0+ | Keil | 335 | 581 | 532 | 253 | 892 | 1167 | 554 | 524 | 756 | 945 | N/A | -| ... | ... | GCC | 337 | 656 | 600 | 284 | 947 | 1260 | 578 | 602 | 794 | 1003 | N/A | -| STM32F103RE | Cortex-M3 | Keil | 203 | 438 | 385 | 226 | 684 | 930 | 392 | 354 | 542 | 707 | 518 | -| ... | ... | GCC | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | -| STM32F405RG | Cortex-M4 | Keil | 180 | 345 | 321 | 180 | 667 | 886 | 309 | 302 | 498 | 626 | 455 | -| ... | ... | GCC | 196 | 388 | 345 | 192 | 677 | 953 | 381 | 349 | 566 | 743 | 411 | -| STM32F767IG | Cortex-M7 | Keil | 176 | 329 | 277 | 174 | 510 | 694 | 328 | 259 | 413 | 516 | 334 | -| ... | ... | GCC | 182 | 335 | 288 | 156 | 473 | 643 | 313 | 264 | 375 | 514 | 332 | -| TMS570LS0432 | Cortex-R4 | CCS | 306 | 493 | 460 | 193 | 686 | 897 | 480 | 464 | 592 | 736 | 533 | -| TMS570LC4357 | Cortex-R5 | CCS | 275 | 479 | 467 | 216 | 746 | 998 | 440 | 435 | 595 | 763 | 482 | -| DSPIC33EP512 | DSPIC33E | XC16 | 470 | 886 | 766 | 440 | 1266 | 1777 | 709 | 614 | 958 | 1254 | 893 | -| MSP430F149 | MSP430 | CCS | 312 | 641 | 573 | 312 | 985 | 1278 | 528 | 487 | 739 | 898 | N/A | -| MSP430FR5994 | MSP430X | CCS | 468 | 1054 | 891 | 492 | 1573 | 2072 | 891 | 784 | 1176 | 1464 | 3291 | -| PIC32MZ2048 | MIPS M14k | XC32 | 260 | 392 | 370 | 146 | 540 | 672 | 440 | 420 | 530 | 620 | 364 | -| TMS320F28335 | C28x | CCS | 246 | 513 | 440 | 235 | 751 | 1001 | 440 | 413 | 622 | 770 | 946 | -| CH32V307 | RV32IMAC | GCC | 246 | 426 | 386 | 179 | 605 | 767 | 359 | 321 | 466 | 593 | TBD | -| CH32V307 | RV32IMAFC | GCC | 318 | 495 | 457 | 182 | 674 | 836 | 405 | 366 | 500 | 624 | TBD | -| i9-7980XE | X86-LINUX | GCC | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | +|芯片 |架构 |工具链 |Yield|Mail |Sem |FIFO |Msgq |Bmq |Mail/I|Sem/I|Msgq/I |Bmq/I |Mem | +|:-----------:|:----------:|:----:|:---:|:---:|:---:|:---:|:---:|:---:|:----:|:---:|:-----:|:----:|:---:| +|ATMEGA1284P |AVR |GCC |437 |751 |717 |314 |1098 |1352 |637 |639 |921 |1087 |1680 | +|ATMEGA2560 |... |... |449 |774 |736 |326 |1131 |1396 |656 |654 |942 |1117 |1686 | +|DSPIC33EP512 |DSPIC33E |XC16 |470 |886 |766 |440 |1266 |1777 |709 |614 |958 |1254 |893 | +|MSP430F149 |MSP430 |CCS |312 |641 |573 |312 |985 |1278 |528 |487 |739 |898 |N/A | +|MSP430FR5994 |MSP430X |CCS |468 |1054 |891 |492 |1573 |2072 |891 |784 |1176 |1464 |3291 | +|STM32F030F4 |Cortex-M0 |Keil |362 |763 |666 |379 |1196 |1609 |689 |616 |950 |1211 |N/A | +|... |... |GCC |366 |802 |690 |396 |1246 |1685 |705 |622 |954 |1200 |N/A | +|STM32L071CB |Cortex-M0+ |Keil |335 |581 |532 |253 |892 |1167 |554 |524 |756 |945 |N/A | +|... |... |GCC |337 |656 |600 |284 |947 |1260 |578 |602 |794 |1003 |N/A | +|STM32F103RE |Cortex-M3 |Keil |203 |438 |385 |226 |684 |930 |392 |354 |542 |707 |518 | +|... |... |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | +|STM32F405RG |Cortex-M4 |Keil |180 |345 |321 |180 |667 |886 |309 |302 |498 |626 |455 | +|... |... |GCC |196 |388 |345 |192 |677 |953 |381 |349 |566 |743 |411 | +|STM32F767IG |Cortex-M7 |Keil |176 |329 |277 |174 |510 |694 |328 |259 |413 |516 |334 | +|... |... |GCC |182 |335 |288 |156 |473 |643 |313 |264 |375 |514 |332 | +|TMS570LS0432 |Cortex-R4 |CCS |306 |493 |460 |193 |686 |897 |480 |464 |592 |736 |533 | +|TMS570LC4357 |Cortex-R5 |CCS |275 |479 |467 |216 |746 |998 |440 |435 |595 |763 |482 | +|PIC32MZ2048 |MIPS M14k |XC32 |260 |392 |370 |146 |540 |672 |440 |420 |530 |620 |364 | +|TMS320F28335 |C28x |CCS |246 |513 |440 |235 |751 |1001 |440 |413 |622 |770 |946 | +|CH32V307 |RV32IMAC |GCC |246 |426 |386 |179 |605 |767 |359 |321 |466 |593 |TBD | +|... |RV32IMAFC |GCC |318 |495 |457 |182 |674 |836 |405 |366 |500 |624 |TBD | +|i9-7980XE |X86-LINUX |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |   **[RVM](https://github.com/EDI-Systems/M7M02_Ammonite)** 嵌入式虚拟机监视器虚拟化版本: -|芯片 |架构 |工具链 | Yield | Mail | Sem | FIFO | Msgq | Bmq | Mail/I | Sem/I | Msgq/I | Bmq/I | Mem | -| :---------: | :--------: | :---: | :---: | :--: | :--: | :--: | :--: | :--: | :----: | :---: | :----: | :---: | :--: | -| STM32L071CB | Cortex-M0+ | Keil | 469 | 841 | 717 | 391 | 1143 | 1529 | 1484 | 1376 | 1646 | 1867 | N/A | -| ... | ... | GCC | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | -| STM32F405RG | Cortex-M4 | Keil | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | -| ... | ... | GCC | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | -| STM32F767IG | Cortex-M7 | Keil | 221 | 403 | 348 | 150 | 589 | 765 | 942 | 962 | 1134 | 1227 | 334 | -| ... | ... | GCC | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | TBD | +|芯片 |架构 |工具链 |Yield |Mail |Sem |FIFO |Msgq |Bmq |Mail/I|Sem/I|Msgq/I |Bmq/I |Mem | +|:-----------:|:----------:|:----:|:---:|:---:|:---:|:---:|:---:|:---:|:----:|:---:|:-----:|:----:|:---:| +|STM32L071CB |Cortex-M0+ |Keil |469 |841 |717 |391 |1143 |1529 |1484 |1376 |1646 |1867 |N/A | +|... |... |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | +|STM32F405RG |Cortex-M4 |Keil |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | +|... |... |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | +|STM32F767IG |Cortex-M7 |Keil |221 |403 |348 |150 |589 |765 |942 |962 |1134 |1227 |334 | +|... |... |GCC |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD |TBD | 作为对比,RT-Linux 4.12在Cortex-M7上的最好线程切换时间是25000时钟周期。这是使用futex测得的;如使用其他IPC如管道等,则结果更差。 diff --git a/Source/Kernel/rmp_kernel.c b/Source/Kernel/rmp_kernel.c index 34755863..50864672 100644 --- a/Source/Kernel/rmp_kernel.c +++ b/Source/Kernel/rmp_kernel.c @@ -1052,7 +1052,7 @@ void _RMP_Run_High(void) /* No action required */ } - /* Replenish timeslices */ + /* Replenish timeslices for the old thread and switch to the new one */ RMP_Thd_Cur->Slice_Left=RMP_Thd_Cur->Slice; RMP_Thd_Cur=(volatile struct RMP_Thd*)(RMP_Run[Prio].Next); diff --git a/Source/Platform/AVR/rmp_platform_avr.c b/Source/Platform/AVR/rmp_platform_avr.c index cc86a5b9..7750958d 100644 --- a/Source/Platform/AVR/rmp_platform_avr.c +++ b/Source/Platform/AVR/rmp_platform_avr.c @@ -50,7 +50,7 @@ rmp_ptr_t _RMP_Stack_Init(rmp_ptr_t Stack, #if(RMP_AVR_COP_XMEGA!=0U) Ptr->SREG_SR=0x80U; #else - Ptr->SREG_SR=0x80U; + Ptr->SREG_SR=0x00U; #endif /* Pass entry and parameter - program space is in words instead of bytes */ @@ -59,9 +59,10 @@ rmp_ptr_t _RMP_Stack_Init(rmp_ptr_t Stack, Ptr->R25=Param>>8; Ptr->R24=Param&0xFFU; - /* Fill the rest for ease of identification */ + /* Fill the rest for ease of identification - R1 is implicitly zero as required + * by GCC, but we still save/restore it in case the program includes assembly */ Ptr->R0=0x00U; - Ptr->R1=0x01U; + Ptr->R1=0x00U; Ptr->R2=0x02U; Ptr->R3=0x03U; Ptr->R4=0x04U; diff --git a/Source/Platform/AVR/rmp_platform_avr_gcc.s b/Source/Platform/AVR/rmp_platform_avr_gcc.s index 0590a0b3..d31fcee8 100644 --- a/Source/Platform/AVR/rmp_platform_avr_gcc.s +++ b/Source/Platform/AVR/rmp_platform_avr_gcc.s @@ -97,12 +97,10 @@ Output : None. Return : None. ******************************************************************************/ RMP_Int_Mask: - LDI R30,lo8(RMP_PMIC_CTRL) - LDI R31,hi8(RMP_PMIC_CTRL) - LD R18,Z + LDS R18,RMP_PMIC_CTRL ANDI R18,0xF8 OR R18,R24 - ST Z,R18 + STS RMP_PMIC_CTRL,R18 RET /* End Function:RMP_Int_Enable ***********************************************/ @@ -115,19 +113,16 @@ Return : None. ******************************************************************************/ _RMP_Start: /* Save the current kernel SP address */ - LDI R30,hi8(_RMP_AVR_SP_Kern) - LDI R31,lo8(_RMP_AVR_SP_Kern) - IN R18,RMP_SPL IN R19,RMP_SPH - ST Z,R18 - STD Z+1,R19 + IN R18,RMP_SPL + STS _RMP_AVR_SP_Kern+1,R19 + STS _RMP_AVR_SP_Kern,R18 /* Load SP for the first task */ - OUT RMP_SPL,R22 OUT RMP_SPH,R23 + OUT RMP_SPL,R22 /* Jump to the entry */ - MOV R30,R24 - MOV R31,R25 - ICALL + MOVW R30,R24 + IJMP /* Should not reach here */ /* End Function:_RMP_Start ***************************************************/ @@ -150,8 +145,7 @@ Return : None. * its PMIC masking features, and we assume all kernel-aware interrupts * are low-level interrupts in XMEGA. */ .macro RMP_AVR_SAVE - /* R31-R29 are handled elsewhere because we need some temporaries */ - PUSH R28 + PUSH R28 /* R31-R29 are temporaries */ PUSH R27 PUSH R26 PUSH R25 @@ -183,26 +177,23 @@ Return : None. .endm /* Actual context switch *****************************************************/ + /* No need to clean R1 here because _RMP_Yield is a function, and R1 is + * guaranteed to be zero when it is called; this is different from the + * interrupt case where R1 has to be cleaned up before calling C ISR. */ .macro RMP_AVR_SWITCH - IN R18,RMP_SPL /* Save the SP to control block */ - IN R19,RMP_SPH - LDI R28,lo8(RMP_SP_Cur) /* Y[29:28] is Callee-save */ - LDI R29,hi8(RMP_SP_Cur) - ST Y,R18 - STD Y+1,R19 - LDI R30,lo8(_RMP_AVR_SP_Kern) /* Load SP for kernel */ - LDI R31,hi8(_RMP_AVR_SP_Kern) - LD R18,Z - LDD R19,Z+1 + IN R19,RMP_SPH /* Save the SP to control block */ + IN R18,RMP_SPL + STS RMP_SP_Cur+1,R19 + STS RMP_SP_Cur,R18 + LDS R19,_RMP_AVR_SP_Kern+1 /* Load SP for kernel */ + LDS R18,_RMP_AVR_SP_Kern OUT RMP_SPL,R18 OUT RMP_SPH,R19 - LDI R30,lo8(_RMP_Run_High) /* Get the highest ready task */ - LDI R31,hi8(_RMP_Run_High) - ICALL /* Use ICALL to remain compatible */ - LD R18,Y /* Load the SP from control block */ - LDD R19,Y+1 /* Y[29:28] is Callee-save */ - OUT RMP_SPL,R18 + CALL _RMP_Run_High /* Get the highest ready task */ + LDS R19,RMP_SP_Cur+1 + LDS R18,RMP_SP_Cur /* Load the SP from control block */ OUT RMP_SPH,R19 + OUT RMP_SPL,R18 .endm /* Restore all GP regs *******************************************************/ @@ -240,21 +231,17 @@ Return : None. /* Save temporaries **********************************************************/ .macro RMP_AVR_TEMP_SAVE - /* Push temporaries */ PUSH R31 PUSH R30 PUSH R29 - /* Save SR early */ - IN R29,RMP_SREG + IN R29,RMP_SREG /* Save SR early */ PUSH R29 .endm /* Restore temporaries *******************************************************/ .macro RMP_AVR_TEMP_LOAD - /* Load SR late */ - POP R18 - OUT RMP_SREG,R18 - /* Pop temporaries */ + POP R29 /* Load SR late */ + OUT RMP_SREG,R29 POP R29 POP R30 POP R31 @@ -270,7 +257,7 @@ Return : None. PUSH R20 PUSH R19 PUSH R18 - LDI R18,0x00 + EOR R18,R18 OUT RMP_RAMPD,R18 OUT RMP_RAMPX,R18 OUT RMP_RAMPY,R18 @@ -293,7 +280,7 @@ Return : None. .macro RMP_AVR_EIND_SAVE IN R18,RMP_EIND PUSH R18 - LDI R18,0x00 + EOR R18,R18 OUT RMP_EIND,R18 .endm @@ -305,22 +292,16 @@ Return : None. /* Mask interrupts ***********************************************************/ .macro RMP_AVR_INT_MASK - /* Mask all low-level interrupts */ - LDI R30,lo8(RMP_PMIC_CTRL) - LDI R31,hi8(RMP_PMIC_CTRL) - LD R29,Z + LDS R29,RMP_PMIC_CTRL /* Mask low-level only */ ANDI R29,0xFE - ST Z,R29 + STS RMP_PMIC_CTRL,R29 .endm /* Unmask interrupts *********************************************************/ .macro RMP_AVR_INT_UNMASK - /* Unmask all low-level interrupts */ - LDI R30,hi8(RMP_PMIC_CTRL) - LDI R31,lo8(RMP_PMIC_CTRL) - LD R29,Z + LDS R29,RMP_PMIC_CTRL /* Unmask low-level only */ ORI R29,0x01 - ST Z,R29 + STS RMP_PMIC_CTRL,R29 .endm /* MegaAVR *******************************************************************/ @@ -376,8 +357,7 @@ _RMP_AVR_Yield_XMEGA: RMP_AVR_LOAD RMP_AVR_INT_UNMASK RMP_AVR_TEMP_LOAD - /* Use RET instead because we don't want to mess with PMIC */ - RET + RET /* RET to avoid messing PMIC up */ /* XMegaAVR with RAMP ********************************************************/ .section .text._rmp_avr_yield_xmega_ramp @@ -392,8 +372,7 @@ _RMP_AVR_Yield_XMEGA_RAMP: RMP_AVR_LOAD RMP_AVR_INT_UNMASK RMP_AVR_TEMP_LOAD - /* Use RET instead because we don't want to mess with PMIC */ - RET + RET /* RET to avoid messing PMIC up */ /* XMegaAVR with RAMP and EIND ***********************************************/ .section .text._rmp_avr_yield_xmega_eind @@ -410,8 +389,7 @@ _RMP_AVR_Yield_XMEGA_EIND: RMP_AVR_LOAD RMP_AVR_INT_UNMASK RMP_AVR_TEMP_LOAD - /* Use RET instead because we don't want to mess with PMIC */ - RET + RET /* RET to avoid messing PMIC up */ /* End Function:_RMP_Yield ***************************************************/ .end /* End Of File ***************************************************************/ diff --git a/Source/Test/rmp_benchmark.c b/Source/Test/rmp_benchmark.c index e32395de..033a6673 100644 --- a/Source/Test/rmp_benchmark.c +++ b/Source/Test/rmp_benchmark.c @@ -467,15 +467,23 @@ void Test_Mem_Pool(void) } Start=RMP_CNT_READ(); - /* Allocation tests */ + /* Allocation tests - should not fail anyway */ Mem[Alloc[0]]=RMP_Malloc(Pool, Amount[Size[0]]); + RMP_ASSERT(Mem[Alloc[0]]!=RMP_NULL); Mem[Alloc[1]]=RMP_Malloc(Pool, Amount[Size[1]]); + RMP_ASSERT(Mem[Alloc[1]]!=RMP_NULL); Mem[Alloc[2]]=RMP_Malloc(Pool, Amount[Size[2]]); + RMP_ASSERT(Mem[Alloc[2]]!=RMP_NULL); Mem[Alloc[3]]=RMP_Malloc(Pool, Amount[Size[3]]); + RMP_ASSERT(Mem[Alloc[3]]!=RMP_NULL); Mem[Alloc[4]]=RMP_Malloc(Pool, Amount[Size[4]]); + RMP_ASSERT(Mem[Alloc[4]]!=RMP_NULL); Mem[Alloc[5]]=RMP_Malloc(Pool, Amount[Size[5]]); + RMP_ASSERT(Mem[Alloc[5]]!=RMP_NULL); Mem[Alloc[6]]=RMP_Malloc(Pool, Amount[Size[6]]); + RMP_ASSERT(Mem[Alloc[6]]!=RMP_NULL); Mem[Alloc[7]]=RMP_Malloc(Pool, Amount[Size[7]]); + RMP_ASSERT(Mem[Alloc[7]]!=RMP_NULL); /* Deallocation tests */ RMP_Free(Pool,Mem[Free[0]]); @@ -491,7 +499,7 @@ void Test_Mem_Pool(void) /* This should always be successful because we deallocated everything else */ Mem[0]=RMP_Malloc(Pool, (TEST_MEM_POOL>>7)*127); - if(Mem[0]==0) + if(Mem[0]==RMP_NULL) { RMP_DBG_S("Memory test failure: "); RMP_DBG_I(Test_Count);