Eboot and OAL by stariya

VIEWS: 3 PAGES: 8

									     Exploring BootLoader and OEM Abstraction
                                     Layer Code
1 lab 1: BootLoader code study

1.1 Objectives:

In this lab, you will learn:
    Understand the structure of BootLoader

    Understand the work flow of BootLoader

    How OEM works


1.2 Prerequisites:

Before this project, please make sure you have the following preliminary knowledge:

    Platform Builder installed in your computer

    Understand how to use Eboot and how it works


1.3 Anticipated Time

      30 Minutes


1.4 Detailed Steps

1.   Launch Platform Builder

2.   Choose “Find in Files…” under “Edit”, use “Find in Files” function to search these codes

3.   Navigate to $(_WINCEROOT)\PLATFORM\CEPC\EBOOT, select the file category *.*,

     Once you have found the Startup function, examine how this function jump to another

     function written by C.

4.   Examine the SOURCES file under Eboot folder, know how Eboot established.

5.   Check all the lib files in SOURCES file, the function connected with Startup function is
     among them, find that lib.

Hint: Most of the source code of blcommon lib is under Windows CE folder of

$(_WINCEROOT)\PUBLIC\COMMON\OAK\DRIVERS\ETHDBG\BLCOMMON. And                               let’s

check the source code in BLCOMMON folder.

6.   Examine BootloaderMain() function. This is the main function of BootLoader and it carries

     on the whole process of BootLoader. Read the code and write 5 function as required:

     initialize serial UART debugging output: ________________________

     Initialize the hardware platform: ______________________

     Predowload function specific to the OEM: __________________

     Download OS image: _____________________

     Jumping to and launching the run-time image: ______________________

7.   Search the source code of download part. We know BootloaderMain() calling

     DownloadImage() for downloading the kernel, so find the function called by DownloadImage,

     and tracking it.

8.   Track the code comments as below, try to understand how the function write/read data

     package.
{
// read the 7 byte "magic number"
// read image start/length
// give the OEM a chance to verify memory
// check for flash image. Start erasing if it is.
// read records (start with address, length, and
checksum)
// check for last record
// update launch address
// write to flash if it's flash image
// finish the flash erase
// map the record address (FLASH data is cached, for
example)
// read data block
// verify partial checksum
}
9.   Under x86 CSP folder $(_WINCEROOT)\public\common\oak\csp\i486\romboot, find

     OEMWriteFlash() function. We know the function of writing Flash does not exist under x86

     platform, because CEPC does not contain any Flash part. But we can find the implement of
    this function in BSP under any other CPU structure. (such as ARMINTEGRATOR, it has

    Intel Strata Flash)

10. Open file $(_WINCEROOT)\PLATFORM\CEPC\EBOOT\boot.bib,check memory usage of

    Boot Loader.


1.5 Homework:

Analysis and Draw a sequence diagram for function’s calling in BootLoader, separate the

functions provided by OEM and MS, please use Rational Rose or any other similar tools.
2 Lab2 Check OAL


2.1 Objectives:

In this lab, you will learn:

    Basic structure of OAL

    Understand the functions of different parts in OAL


2.2 Prerequisites

Basic functionalityy of OAL in Windows CE


2.3 Anticipated Time

90-120 Minutes


2.4 Detailed Steps

2.4.1    Browse OAL Source Codes


In this lab, you need to search the source codes of kernel of OAL, including:

    Initialization Codes

    Interrupting Codes

    Debugging I/O Codes

Hint: The source codes concern with OAL in CEPC mostly under these two folders, you only

need to search within these two folders.

$(_WINCEROOT)\PLATFORM\CEPC\KERNEL\HAL

$(_WINCEROOT)\PUBLIC\COMMON\OAK\CSP\I486\OAL

OAL initialization codes:

1.   Launch Platform Builder

2.   Select “Find in Files…” under “Edit” Menu, search the following codes.
3.   Search the Startup function, this is a function written in assembly language, after

     BootLoader download kernel image, it will jump here and run this function. Startup is the

     first function in OAL. Change the search file category as “*.ASM” in “Find in Files”

     window,         and          then          change      the       search         folder       as

     $(_WINCEROOT)\PUBLIC\COMMON\OAK\CSP\I486\OAL.

4.   We               can                find            Startup             function              in

     $(_WINCEROOT)\PUBLIC\COMMON\OAK\CSP\I486\OAL\OEMINIT.ASM file. There is

     a double bottom line in front of the function, double click oeminit.asm to open this file, read

     the content of this function.

5.   The second function is KernelInitialize. Startup function will jump to this function. Sorry

     we cannot find the source codes of this function, and MS use binary code to implement

     KernelInitialize function.

Notice: The name of this function is sensitive with platform, in other platform (such as ARM), the

equivalent function is KernelStart.

6.   The third function is OEMInit. Its main task is to do the initialization, and it is written in C

     language. Specify the search file category as “*.c” in “Find in Files” window, and change

     the                             search                        folder                         as

     $(_WINCEROOT)\PUBLIC\COMMON\OAK\CSP\I486\OAL\CFWPC.C, you may find this

     function.

7.   The last function is OEMGetExtensionDRAM, same it is in CFWPC.C file. This function

     let the kernel know how many memory left except those memory defined in NK.Bin.


--> Interrupt Service Code of OAL
8. Search OEMInterruptEnable function in CFWPC.C. When interrupt service thread call
     InterruptInitialize function, the kernel call this function to inform OAL active the interrupt.
9. Search OEMInterruptDisable function in CFWPC.C. When interrupt occurs, the kernel call
     OAL to use this function to turn off the interrupt in hardware level
10. earch OEMInterruptDone function in CFWPC.C. This function is for re-active all the
     interrupts after the former interruption for debugging. The driven program call
     InterrruptDone which awake the kernel call OEMInterruptDone function.

--> Functions for debugging of I/O
11. Search these two functions for series port debugging.
OEMInitDebugSerial

OEMWriteDebugString
You may find them in $(_WINCEROOT)\PUBLIC\COMMON\OAK\CSP\I486\OAL\DEBUG.C.
12. Search these two functions for parallel port debugging,

OEMParallelPortInit

OEMParallelPortSendByte
You may find them in
$(_WINCEROOT)\PUBLIC\COMMON\OAK\CSP\I486\OAL\MDPPFS.C.
13. Find these two functions for Ethernet network debugging

OEMEthInit

OEMEthSendFrame
You may find them in $(_WINCEROOT)\PLATFORM\CEPC\KERNEL\HAL\HALETHER.C.




2.4.2   Homework:


Draw a sequence diagram for function’s calling in OAL, separate the functions provided by OEM

and MS, please use Rational Rose or any other similar tools.


2.4.3   Create new I/O Control Code


In this part, you will create some new I/O codes, and the application can use them to interact with

OAL directly.

    Find OEMIoControl function

    Add/delete new control codes

    Create application for testing



-->Search OEMIoControl function

1.   Use “Find in Files…” in “Edit” Menu of PB, search OEMIoControl, and you will find this

     function in $(_WINCEROOT)\PLATFORM\CEPC\KERNEL\HAL\OEMIOCTL.C. Check

     how this function organizes its huge switch command.
--> Add some new Control Codes

1.   Set a new global variable in the starting of the file.
static DWORD dwControlCounter = 0;
2.   Give the new control counter a new integer never been used before. As below:
#define IOCTL_HAL_INC_COUNTER CTL_CODE(                       FILE_DEVICE_HAL,0x1000,
METHOD_BUFFERED, FILE_ANY_ACCESS)
3.   Add a case statement in OEMIoControl function, carry out the function of counter and send

     out the present value of counter to debugger by RETAILMSG Macro.
case IOCTL_HAL_INC_COUNTER:
dwControlCounter++;
RETAILMSG(1,(_T("Lab: Count is now %u\n\r"),dwControlCounter));
if (nOutBufSize < sizeof(dwControlCounter))
{
SetLastError(ERROR_INVALID_PARAMETER);
retval = FALSE;
}
else
{
memcpy(lpOutBuf, &dwControlCounter, sizeof(dwControlCounter));
*lpBytesReturned = sizeof(dwControlCounter);
retval = TRUE;
}
break;



--> Create an application to test I/O control function

1.   Create a new CEPC platform via Platform Builder

2.   Create an application based on command by Project Wizard.

3.   Remember to include kfuncs.h file.
#include <kfuncs.h>
4.   Add the definition of OAL control code.
#define IOCTL_HAL_INC_COUNTER CTL_CODE(                       FILE_DEVICE_HAL,0x1000,
METHOD_BUFFERED, FILE_ANY_ACCESS)
5.   Call I/O in OAL by KernelIoControl function.
KernelIoControl(IOCTL_HAL_INC_COUNTER,    NULL,    0,                               &dwCount,
sizeof(dwCount), &dwNumRead);
RETAILMSG(1, (_T(“CALLOAL: Count is %u\n\r”),dwCount));
Notice: Before compiling and running the code, please define the WINCEOEM and the reference

path. And the reference path is:
$(_PROJECTROOT)\cesysgen\oak\inc
$(_TARGETPLATROOT)\inc
6.   Compile and run the test program, check the output.

								
To top