...
This section describes how µC/OS-II has been ported to the Intel 80x86 series of processors that provides a Floating-Point Unit (FPU). Some of the processors that can make use of this port are the Intel 80486™, Pentiums™ (all models), Xeon™, AMD Athlon™, K6™-series, ElanSC520™ and more. The port assumes the Borland C/C++ compiler V4.51 and was setup to generate code for the large memory model. The processor is assumed to be running in real mode. The code for this port is very similar to the one presented in Chapter 14 and 80x86 Port with Emulated FP Support and in some cases, I will only be presenting the differences.
...
Figure 15.1 shows the programming model of an 80x86 processor running in real mode. The integer registers are identical to those presented in Chapter 14in 80x86 Port with Emulated FP Support. In fact, they are saved and restored using the same technique. The only difference between this port and the one presented in Chapter 14 is that section is that we also need to save and restore the FPU registers which is done by using the context switch hook functions.
...
Finally, you can also adapt the port provided in this chapter section to other 80x86 compiler as long as they generate real-mode code. You will most likely have to change some of the compiler options and assembler directives if you use a different development environment.
Table 15.1 shows the Borland C/C++ compiler V4.51 options (i.e., flags) supplied on the command line. These settings were used to compile the port as well as example 4 provided in Chapter 1 Getting Started with µC/OS-II.
Table 15.2 shows the Borland Turbo Assembler V4.0 options (i.e., flags) supplied on the command line. These settings were used to assemble OS_CPU_A.ASM
.
...
Listing 15.1 shows the contents of INCLUDES.H
for this 80x86 port. It is identical to the one used in Chapter 14in 80x86 Port with Emulated FP Support.
INCLUDES.H
is not really part of the port but is described here because it is needed to compile the port files.
...
OS_CPU.H
contains processor- and implementation-specific #defines constants, macros, and typedefs. OS_CPU.H
for the 80x86 port is shown in Listing 15.2. Most of OS_CPU.H
is identical to the OS_CPU.H
of Chapter 14the section 80x86 Port with Emulated FP Support.
OS_CPU.H, OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL()
...
OS_CPU.H, Tick Rate
I also decided (see Chapter 14 for see 80x86 Port with Emulated FP Support for additional details) to change the tick rate of the PC from the standard 18.20648Hz to 200Hz (i.e., 5ms between ticks).
OS_CPU.H, Floating-Point Functions
This port defines three special functions that are specific to the floating-point capabilities of the 80x86. In other words, I had to add three new functions to the port to handle the floating-point hardware.
OS_CPU_C.C
As mentioned in Chapter 13 and 14 Porting µC/OS-II and in 80x86 Port with Emulated FP Support, µC/OS-II port requires that you write ten fairly simple C functions:
...
This function is called by OSTaskCreate
and OSTaskCreateExt
and is identical to the OSTaskStkInit
presented in section 14.01.01. You may recall that OSTaskStkInit
is called to initialize the stack frame of a task so that it looks as if an interrupt has just occurred and all of the processor integer registers were pushed onto it. Figure 15.2 (identical to Figure 14.3) shows what OSTaskStkInit
puts on the stack of the task being created. Note that the diagram doesnít show the stack frame of the code calling OSTaskStkInit
but rather, the stack frame of the task being created. Also, the stack frame only contains the contents of the integer registers, nothing about the floating point registers. Iíll discuss how we handle the FPU registers shortly.
For reference, Listing 15.3 shows the code for OSTaskStkInit
which is identical to the one shown in Chapter 14 80x86 Port with Emulated FP Support (Listing 14.3).
OSFPInit()
OSFPInit
is called by OSInitHookEnd
when OSInit
is done initializing µC/OS-IIís internal structures (I will discuss OSInitHookEnd
later). OSFPInit
is basically used to initialize the floating-point context switching mechanism presented in this chaptersection. OSFPInit
assumes that you enabled µC/OS-IIís memory management functions (i.e., you must set OS_MEM_EN
to 1 in OS_CFG.H
). The code for OSFPInit
is shown in Listing 15.4.
...
OS_CPU_C.C
doesnít do anything in this function. See Example 3 in Chapter 1 for Getting Started with µC/OS-II for an example on what you can do with OSTaskStatHook
.
...
This function is called by OSStart
to start the highest priority task ready to run. It is identical to the OSStartHighRdy
presented in Chapter 14 (see section 14.05.01)in 80x86 Port with Emulated FP Support. The code is shown again in Listing 15.14 for your convenience but will not be discussed since you can review it from section 14.05.01the section 80x86 Port with Emulated FP Support.
OSCtxSw()
A task-level context switch is accomplished on the 80x86 processor by executing a software interrupt instruction. The interrupt service routine must vector to OSCtxSw
. The sequence of events that leads µC/OS-II to vector to OSCtxSw
begins when the current task calls a service provided by µC/OS-II, which causes a higher priority task to be ready to run. At the end of the service call, µC/OS-II calls the function OS_Sched
, which concludes that the current task is no longer the most important task to run. OS_Sched
loads the address of the OS_TCB
of the highest priority task into OSTCBHighRdy
, then executes the software interrupt instruction by invoking the macro OS_TASK_SW
. Note that the variable OSTCBCur
already contains a pointer to the current taskís task control block, OS_TCB
. The code for OSCtxSw
which is identical to the one presented in Chapter 14 is 80x86 Port with Emulated FP Support is shown in Listing 15.15. OSCtxSw
will be discussed again because of the added complexity of the floating-point context switch.
...
The code is shown in Listing 15.16 and is identical to the OSIntCtxSw
presented in Chapter 14 80x86 Port with Emulated FP Support. The floating-point registers are handled by OSTaskSwHook
. Figure 15.5 shows the context switch process from OSIntCtxSw
í s point of view.
As in Chapter 14 80x86 Port with Emulated FP Support, let's assume that the processor receives an interrupt. Letís also supposed that interrupts are enabled. The processor completes the current instruction and initiates an interrupt handling procedure.
...
The only code that changed in Chapter 15 from 80x86 Port with Hardware FP Support from the code provided in Chapter 14 was in 80x86 Port with Emulated FP Support was OS_CPU_A.ASM
, OS_CPU_C.C
and OS_CPU.H
. These files add only an additional 164 of code space (ROM).
...
The spreadsheet for this port is found on the companion CD (\SOFTWARE\uCOS-II\Ix86L-FP\BC45\DOC\80x86L-FP-ROM-RAM.XLS
). You need Microsoft Excel for Office 2000 (or higher) to use this file. The spreadsheet allows you to do ìwhat-ifî scenarios based on the options you select. You can change the configuration values (in RED) and see how they affects µC/OS-IIís ROM and RAM usage on the 80x86. For the ???_EN
values, you MUST use either 0 or 1.
As with Chapter 14, I with 80x86 Port with Emulated FP Support, I setup the Borland compiler to generate the fastest code. The number of bytes shown are not meant to be accurate but are simply provided to give you a relative idea of how much code space each of the µC/OS-II group of services require.
...