Common files for the HAL
From ErikaWiki
Intro
During the porting of Mico32 someone thought that it could be possible to reuse a substantial part of the code of the HAL among many architectures. The files contained in ee/pkg/cpu/common can be used both as a part of a new porting, by including them, or as a base to derive code specific to a particular architecture.
All the files in cpu/common are written in standard C; they should work as they are on almost any platform or compiler. The should be decoupled enough so that if a porting requires a custom implementation of some parts, the rest could be used with no modification. A new porting should use the common implementation when possible, or an ad-hoc implementation under cpu/XXX otherwise.
Please do not modify these files to accommodate some quirks of your architecture. Instead, make a copy of them and create a branch under your cpu/XXX directory or whatever. Implementations that can potentially be useful on many platforms are welcome; e.g., ee/pkg/cpu/common/inc/ee_compiler_gcc.h works only for Gcc, but it should work across all platforms where Gcc is available.
The common layer is used by following portings:
- EnSilica eSi-RISC
- Lattice Mico32
- Freescale PPC e200 (MPC 56xx)
- TI MSP430
- Microchip dsPIC
- Renesas RX200
- ARM Cortex MX
- Atmel AVR8
Content
cpu/common contains a practically complete monostack version of Erika without interrupts, with support for the multistack version and interrupts. There is one context-changing function (instead of the two of previous portings). Where possible, all parts have been written so that there is one implementation in C for all versions (mono or multistack); this is accomplished through the use of macros or small inline functions that are defined differently depending on the version. See the inline definition of EE_hal_ready2stacked() in ee/pkg/cpu/common/inc/ee_context.h for an example.
- README.txt
- cfg/cfg.mk
- inc/README.txt
- inc/ee_compiler_gcc.h Definitions for the Gnu C compiler
- inc/ee_compiler_ccrx.h Definitions for the Renesas RX C compiler
- inc/ee_compiler_ccs.h Definitions for the Texas Instruments CCSv4 tms470 C compiler
- inc/ee_compiler_codewarrior.h Definitions for the Freescale Codewarrior C compiler
- inc/ee_compiler_diab.h Definitions for the Wind River Diab C compiler
- inc/ee_compiler_iar.h Definitions for the IAR C compiler
- inc/ee_compiler_keil.h Definitions for the ARM Keil C compiler
- inc/ee_compiler_tasking.h Definitions for the TASKING C compiler
- inc/ee_context.h Definitions related to stack- and context-changing functions
- inc/ee_hal_structs.h Common structure declarations
- inc/ee_irqstub.h Functions possibly useful for IRQ post-stub
- inc/ee_primitives.h Inline functions used in kernel primitives
- inc/ee_stdint.h Definitions of (some) ISO types
- inc/ee_types.h Definition of Erika types based on limits.h
- src/ee_context.c Stack- and context-changing functions
- src/ee_hal_structs.c Definitions of common structures
Porting to a new architecture
See Porting ERIKA Enterprise and RT-Druid to a new microcontroller for the general instructions.
- Create the architecture-specific directory ee/pkg/cpu/XXX
- Create the files inc/ee_cpu.h and inc/ee_internal.h in the above directory. They should include all the files cpu/common/inc/ee_*.h suitable for your architecture. Write any architecture-specific definition or declaration in them.
- Modify the files ee/pkg/ee.h and ee/pkg/ee_internal.h to include your newly create files.
- Modify the file cpu/common/cfg/cfg.mk to compile the common C source files suitable for your architecture.
- Create or modify any additional file you need.
- Run make and enjoy.