02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5<br />

Driver <strong>Guide</strong>lines<br />

The level of cache library support designed into a driver must be well documented<br />

in the code. This is an important issue that must not be neglected.<br />

Many of the routines and macros in cacheLib are designed to hide the details of<br />

the underlying hardware. The macros might actually call routines within<br />

cacheLib, or they might do nothing at all. Their action depends on how certain<br />

function pointers are initialized at run-time. The run-time initialization of the<br />

cacheLib is determined by the code in the <strong>BSP</strong> modules, which are where the<br />

actual details of the caching hardware are known. This hiding of details allows<br />

drivers to be broadly targeted, which increases portability.<br />

Good driver design includes portability. The following subsections assume<br />

portability is a goal and discuss target-specific applications only minimally.<br />

5<br />

Flush and Invalidate Macros<br />

Generally, you need to add the flush and invalidate macros to your driver. The<br />

macro set you implement depends on the type of memory you need to control (see<br />

Shared Memory Types, p.104). The flush macro is used on memory locations that are<br />

given to the device for subsequent reading by the device. The invalidate macro is<br />

used before the driver reads from memory locations that were written by the<br />

device.<br />

Portable drivers use flush and invalidate macros wherever needed. The macros are<br />

written to perform null operations if they are not needed on the particular target.<br />

WRITE_PIPING Attribute<br />

The cacheLib macro CACHE_PIPE_FLUSH flushes the write pipeline of the CPU.<br />

Typically, you add this macro to appropriate locations throughout your driver.<br />

Appropriate locations are after one or more commands have been written to the<br />

device. Device commands that require immediate delivery are most important.<br />

These commands are commonly found in initialization sequences or in interrupt<br />

handlers (where an interrupt condition requires clearing).<br />

Deciding when this macro needs to be used requires in-depth knowledge of the<br />

device you are programming. Some devices are not affected by the delays caused<br />

by a write pipeline. Such devices do not require the pipeline flush macro in the<br />

driver. Other devices do not function correctly without a tight synchronization<br />

with the driver. Such devices require liberal use of the pipeline flush macro<br />

throughout the driver.<br />

107

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!