(v0.75, 08 July 2012, latest version is always at http://www.nedprod.com/NedHAL/Docs)
Introduction | - | - | NedHAL is a modular architecture-independent multiprocessing capable
Hardware Abstraction Layer for everything from tiny embedded systems upwards. It was
designed to remedy many of the shortcomings of traditional embedded HAL's and RTOS's:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Overview | NedHAL is comprised of a number of modules written in portable C,
non-portable C and native assembler. Each module is thought of as being an object
representing something, and hence follows the object-orientated convention of having a constructor
(API to initialise the module for subsequent use), destructor (API to terminate
the use of the module) and a number of API's to alter or examine the object which that
module represents. Some modules allow multiple instances of themselves using context
blocks which hold the instance data of that module. Modules encapsulate functionality based on interoperability. For example, if you had three revisions of the same processor and each revision had slightly different ways of performing internal functions eg; flushing the cache - then you would have a "Processor" module whose API was consistent between all revisions of that processor. Hence one can change the "Processor module" for a new revision of the processor and everything which used that API would run fine. This ideology is taken further with groupings of modules as shown by the NedHAL source structure. If you place all architecture-specific modules in one place and have them expose a completely portable API, then moving from one architecture to another requires merely a rewrite of those modules. If you further extract board-specific code from the architecture-specific code, you now can port between implementations of that architecture merely by rewriting or changing the board-specific modules. All the modules which comprise NedHAL reside within NedHAL's source tree which is broken into a number of directories to logically group source files based on commonality of purpose and portability derived from the above ideology: [REPLACE THIS GRAPH WITH ONE SHOWING MODULE GROUPS BASED ON LAYERS OF MODULES]
Typically, to use NedHAL in your code, start with one of the provided templates for your particular compiler or look at the included examples. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The Documentation | The NedHAL documentation is written in HTML 3.0 and to render perfectly
requires a web browser with full support for HTML 3.0 and style sheets. Despite its
claims, no version of Netscape's Navigator web browser will correctly render this manual -
only Microsoft Internet Explorer v4.0 and later will. This is not to say that the documentation isn't usable in other web browsers. It is of course usable in all web browsers with at least table support (eg; the "simple" web browser QVT/Web for Win32 from QPC Software, http://www.qpc.com, was used to test this manual), but formatting mistakes may be made by some web browsers. This may or may not aid use. The documentation's HTML code has been written to allow use as follows (in the order of expected most likely use):
To these meet these goals, the following features are present:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Typographical conventions | A number of conventions have been used in the making of this manual to
aid consistency and ease of use. As you will have already noticed, there is a margin on
the left hand side of every page whose entries outline the context of the body text
subsequent to that entry. One may speed read through the manual more quickly by skipping
the reading of text which has unrelated content as determined by the left hand margin.
This feature is most pronounced in the API documentation where there are a consistent set
of left-margin entries for each API. This is discussed further later on. Typeface is used to indicate what the text represents:
The use of italics, bold and underlined text has been kept to traditional values for the English language except for when code is being described. In this case, code is described in monospace initially and during the description of that code certain key parts of it will be emboldened and underlined to make them stand out: typedef struct Example_t { ... int foo; ... } ExampleStruct; ... waffle ... waffle ... The member called foo describes the amount of foo-ness ... waffle ... waffle etc. This done so one can index where the structure Example is described with the left hand column and then its individual member items through what is emboldened and underlined in the following paragraphs. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Use of container acronyms (s32, u8 etc.) | As there can be differences in the sizes of the char, int and long
containers between implementations of the ANSI C language (see ANSI C specification or the
manual accompanying your C compiler for more information), NedHAL #define's acronyms used
by module header files when defined prototypes to provide consistency between
architectures:
However, strings are still referred to as char * rather that u8 * because:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Error handling (HALError) | One thing common throughout the HAL is the use of the structure HALError
to return errors to code calling HAL API's. Due to its ubiquitousness, there isn't really
any other suitable place to document its use, so hence we deal with it here before
introducing you to the layout of the module documentation.typedef struct HALError_t { union { u32 id[1]; char name[8]; } module; u32 code; char *message; } HALError; The name of the module which was the source of the error is stored in module and is encoded as two 32 bit words (id) or as an array of eight characters (name) as shown above (one could add one u64 to the union if your compiler supports it). The module-dependent error code and optional pointer to descriptive message is stored in code and message respectively. This structure is almost always passed by reference for speed but even if it needs copying around it only occupies 16 bytes on most 32-bit architectures. If you wish to take action on a reported error, compare the module name or id to the ones you wish to trap and also their error codes. If you wish to report the error, you can simply print the module name after copying it out and adding a zero byte (usually not necessary on little endian machines due to the convenient byte ordering of the u32 code entry) and then the code. You should only print the message if message is non-NULL. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Module documentation | Each module and the API's it exposes to the outside is documented in one
HTML page. Each page begins with a standard module description, whose entries and meanings
are as follows:
After the standard module description, there are individual API descriptions which list every API the module exposes to be used. The name of the API is on the right hand side because if you are looking for an API quickly in the printed documentation, you will flick the pages with your right hand if the manual is bound on the left hand side (which it usually will be). Hence you will catch the name of the API very easily as it is on the right hand side:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Printing the documentation | Most people wishing to use NedHAL will want to print out this manual in
its entirety so they may make annotations or indeed use multiple parts of the manual
simultaneously. Firstly, it is highly recommended to use Microsoft's Internet Explorer v4.0 web browser or later to print this manual (Unix or Win32 versions are fine). However, other web browsers which are fully HTML 3.0 compliant and fully support style sheets should be fine (no known version of Netscape's Navigator web browser - currently v4.72 - supports either fully). We recommend the binding of the pages in a small A4 ring-binder folder with inserted card sectionisers to logically break up the pages into sections (whichever sections you choose is up to you). The main advantage of using ring-binding is that one can open the manual out flat so the manual does not "clump" itself closed when you're not looking as traditionally bound books do. Also, one can balance the ring-bound folder on one's lap whilst coding extremely easily - again, the same cannot be said of traditionally bound books. You may need to enable printing of background colours in the options of your web browser as some items may not print correctly otherwise. You can also change the size of the fonts printed in most web browsers - set these so the left hand margin occupies around 20% of the page. Set the page to print in portrait form (where the width is less than the height) for best effect and easiest subsequent use. If you are able to set print margins and are following our recommendations for binding, set the left margin to at least 0.9" or 2cm and the others to whatever the minimum amount your printer and web browser allow. You may wish to add a custom header and footer if possible to aid quick indexing. You should order the pages in growing unportability, eg; as follows::
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Documentation Roadmap | The NedHAL documentation structure is based closely on the NedHAL source
structure given earlier, however some aberrations are required to prevent topic
subdivision being overdone. Typically, if a documentation file falls into the same section
as the equivalent source file or files, then it documents those file or files. The following image is active when viewed through a web browser: Click on the pictorial representation of the area of the source structure you wish to view more about (if there is documentation on that area): For those without image-clickable capable web browsers, or those wishing to know directly what areas of NedHAL are documented, here is a list of all the documentation concerning NedHAL:
|