Nested headers, Platform hal porting – Comtrol eCos User Manual

Page 325

Advertising
background image

Chapter 11. Porting Guide

(set-variable ’add-log-full-name "Your Name")

(set-variable ’add-log-mailing-address "Your email address"))

(setq auto-mode-alist

(append ’(("/local/ecc/.*\\.C$"

. ecos-c-mode)

("/local/ecc/.*\\.cc$"

. ecos-c-mode)

("/local/ecc/.*\\.cpp$" . ecos-c-mode)

("/local/ecc/.*\\.inl$" . ecos-c-mode)

("/local/ecc/.*\\.c$"

. ecos-c-mode)

("/local/ecc/.*\\.h$"

. ecos-c-mode)

("/local/ecc/.*\\.S$"

. ecos-asm-mode)

("/local/ecc/.*\\.inc$" . ecos-asm-mode)

("/local/ecc/.*\\.cdl$" . tcl-mode)

) auto-mode-alist))

Nested Headers

In order to allow platforms to define all necessary details, while still maintaining the ability to share code between
common platforms, all HAL headers are included in a nested fashion.

The architecture header (usually

hal_XXX.h

) includes the variant equivalent of the header (

var_XXX.h

) which in

turn includes the platform equivalent of the header (

plf_XXX.h

).

All definitions that may need to be overridden by a platform are then only conditionally defined, depending on
whether a lower layer has already made the definition:

hal_intr.h:

#include

<

var_intr.h

>

#ifndef MACRO_DEFINED

# define MACRO ...

# define MACRO_DEFINED

#endif

var_intr.h:

#include

<

plf_intr.h

>

#ifndef MACRO_DEFINED

# define MACRO ...

# define MACRO_DEFINED

#endif

plf_intr.h:

# define MACRO ...

# define MACRO_DEFINED

This means a platform can opt to rely on the variant or architecture implementation of a feature, or implement it
itself.

221

Advertising