Hal coding conventions, Implementation issues – Comtrol eCos User Manual

Page 323

Advertising
background image

Chapter 11. Porting Guide

Note:: When vector table console code is not used, the platform HAL must map the HAL_DIAG_INIT,
HAL_DIAG_WRITE_CHAR and HAL_DIAG_READ_CHAR macros directly to the low-level IO functions,
hardwired to use a compile-time configured channel.

Note:: On old ports the hardwired

HAL_DIAG_INIT

,

HAL_DIAG_WRITE_CHAR

and

HAL_DIAG_READ_CHAR

imple-

mentations will also contain code to O-packetize the output for GDB. This should not be adopted for new ports!
On new ports the ROM monitor is guaranteed to provide the necessary mangling via the vector table. The
hardwired configuration should be reserved for ROM startups where achieving minimal image size is crucial.

HAL Coding Conventions

To get changes and larger submissions included into the eCos source repository, we ask that you adhere to a set
of coding conventions. The conventions are defined as an attempt to make a consistent tree. Consistency makes it
easier for people to read, understand and maintain the code, which is important when many people work on the
same project.

The below is only a brief, and probably incomplete, summary of the rules. Please look through files in the area
where you are making changes to get a feel for any additional conventions. Also feel free to ask on the list if you
have specific questions.

Implementation issues

There are a few implementation issues that should be kept in mind:

HALs

HALs must be written in C and assembly only. C++ must not be used. This is in part to keep the HALs simple
since this is usually the first part of eCos a newcomer will see, and in part to maintain the existing de facto
standard.

IO access

Use HAL IO access macros for code that might be reused on different platforms than the one you are writing
it for.

MMU

If it is necessary to use the MMU (e.g., to prevent caching of IO areas), use a simple 1-1 mapping of memory if
possible. On most platforms where using the MMU is necessary, it will be possible to achieve the 1-1 mapping
using the MMU’s provision for mapping large continuous areas (hardwired TLBs or BATs). This reduces the
footprint (no MMU table) and avoids execution overhead (no MMU-related exceptions).

219

Advertising