ABSTRACT

This chapter examines how a typical porting layer is designed and built. It discusses the main components of the FreeRTOS porting layer. The Coldfire-V2 porting layer shows a remarkable similarity—even though the implementation details differ—because it contains the fragments of code, in portmacro.h. The first thing to be found in portmacro.h is a set of macros that maps some basic data types required by FreeRTOS into appropriate data types supported by the compiler and the underlying processor architecture. In the Cortex-M3 porting layer, the two macros just described are used directly to implement portDISABLE_INTERRUPT and portENABLE_INTERRUPT, which are invoked by FreeRTOS to disable and enable interrupts, respectively, from a task context. The function vPortExitCritical, called at the end of a critical region, first decrements the nesting counter and then reenables interrupts by calling portENABLE_INTERRUPTS only if the count is zero, that is, the calling task is about to exit from the outermost critical region.