Name

HAL Port — Implementation Details

Overview

This documentation explains how the eCos HAL specification has been mapped onto the MPC8309KIT hardware, and should be read in conjunction with that specification. The MPC8309KIT platform HAL package complements the PowerPC architectural HAL and the MPC83XX variant HAL. It provides functionality which is specific to the target board.

Startup

Following a hard or soft reset the HAL will initialize or reinitialize the on-chip peripherals that eCos uses. There is an exception for RAM startup applications which depend on a ROM monitor for certain services.

For ROM startup, the HAL will perform additional initialization, setting up the external RAM and programming the various internal registers. This is all done in the hal_hardware_init function in the assembler source file mpc8309kit.S.

Linker Scripts and Memory Maps

The platform HAL package provides the memory layout information needed to generate the linker script. The key memory locations are as follows:

Flash
This is located at address 0xFE000000 of the physical memory space. It is mapped by the BAR registers 1-1 to virtual address 0xFE000000 with caching enabled, and to 0x5E000000 with caching disabled. While the PowerPC reset vector is at 0xFFF00100 the chip bootstrap mechanism means that ROM applications actually boot from 0x00000100, where the flash is remapped during startup. Initialization code remaps the flash to 0xFE000000 and moves execution there.
SDRAM
This is located at address 0x00000000 of the physical memory space. The first 0x3000 bytes are used for the exception entry trampolines. The following 512 bytes contain the VSR table and the next 256 bytes are normally used for the eCos virtual vectors, allowing RAM-based applications to use services provided by the ROM monitor. For ROM and JTAG startup, all remaining SDRAM is available. For RAM startup, available RAM starts at location 0x00100000, with the bottom 1MiB reserved for use by RedBoot. The SDRAM is mapped 1-1 with cache enabled at virtual address 0x00000000 and uncached at 0x20000000.
Peripherals
All on-chip peripherals are accessed relative to the address in the IMMBAR register. Both the PEEDI configuration file and eCos itself set this to 0xE0000000.

Real-time characterization

The tm_basic kernel test gives statistics gathered about the real-time characterization and performance of the kernel. The sample output is shown here for information.

Example 356.1. mpc8309kit Real-time characterization

            Startup, main stack : stack used  1080 size  6048
             Startup :  Interrupt stack used  4064 size  4096
             Startup : Idlethread stack used   508 size  2048

eCos Kernel Timings
Notes: all times are in microseconds (.000001) unless otherwise stated

Reading the hardware clock takes 1 'ticks' overhead
... this value will be factored out of all other measurements
Clock interrupt took    2.38 microseconds (79 raw clock ticks)

Testing parameters:
   Clock samples:            32
   Threads:                  64
   Thread switches:         128
   Mutexes:                  32
   Mailboxes:                32
   Semaphores:               32
   Scheduler operations:    128
   Counters:                 32
   Flags:                    32
   Alarms:                   32


                                 Confidence
     Ave     Min     Max     Var  Ave  Min  Function
  ======  ======  ======  ====== ========== ========
   17.15   16.32   20.55    0.34   65%  14% Create thread
    0.98    0.90    3.06    0.10   95%  75% Yield thread [all suspended]
    0.92    0.84    2.31    0.10   87%  75% Suspend [suspended] thread
    0.92    0.84    1.98    0.10   87%  75% Resume thread
    1.16    1.08    3.39    0.12   85%  84% Set priority
    0.24    0.18    0.66    0.05   75%  78% Get priority
    1.91    1.74    7.26    0.21   96%  82% Kill [suspended] thread
    0.96    0.90    2.61    0.09   87%  75% Yield [no other] thread
    1.28    0.96    3.06    0.14   79%   9% Resume [suspended low prio] thread
    0.91    0.84    2.07    0.10   87%  75% Resume [runnable low prio] thread
    1.23    0.99    3.60    0.13   85%   1% Suspend [runnable] thread
    0.98    0.90    3.06    0.10   95%  75% Yield [only low prio] thread
    0.93    0.84    2.16    0.10   87%  70% Suspend [runnable->not runnable]
    1.77    1.62    6.69    0.17   96%  90% Kill [runnable] thread
    2.22    2.04    5.13    0.12   70%  43% Destroy [dead] thread
    3.31    2.88    8.94    0.21   87%  10% Destroy [runnable] thread
    8.08    6.87   14.22    0.34   76%   1% Resume [high priority] thread
    2.00    1.92    3.99    0.08   86%  75% Thread switch

    0.06    0.03    0.57    0.01   74%  25% Scheduler lock
    0.68    0.66    1.65    0.02   99%  61% Scheduler unlock [0 threads]
    0.66    0.66    1.29    0.01   99%  99% Scheduler unlock [1 suspended]
    0.68    0.66    1.23    0.02   99%  50% Scheduler unlock [many suspended]
    0.68    0.66    1.41    0.02   50%  49% Scheduler unlock [many low prio]

    0.24    0.09    1.47    0.10   75%  31% Init mutex
    1.16    0.96    3.69    0.17   75%  78% Lock [unlocked] mutex
    1.23    0.99    4.41    0.20   75%  81% Unlock [locked] mutex
    0.98    0.81    3.06    0.15   75%  84% Trylock [unlocked] mutex
    0.96    0.78    2.97    0.15   71%  71% Trylock [locked] mutex
    0.12    0.06    0.87    0.08   93%  71% Destroy mutex
    5.43    5.01   10.05    0.66   90%  90% Unlock/Lock mutex

    0.37    0.24    1.71    0.09   71%  46% Create mbox
    0.13    0.06    0.33    0.06   59%  71% Peek [empty] mbox
    1.29    1.11    3.72    0.18   68%  87% Put [first] mbox
    0.13    0.06    0.33    0.07   53%  68% Peek [1 msg] mbox
    1.33    1.20    3.90    0.18   96%  90% Put [second] mbox
    0.13    0.06    0.33    0.07   50%  71% Peek [2 msgs] mbox
    1.30    1.08    3.84    0.18   71%  81% Get [first] mbox
    1.32    1.20    3.78    0.17   96%  87% Get [second] mbox
    1.28    1.17    3.24    0.13   96%  84% Tryput [first] mbox
    1.16    1.05    2.97    0.13   93%  87% Peek item [non-empty] mbox
    1.20    1.08    3.39    0.15   96%  87% Tryget [non-empty] mbox
    1.11    0.96    3.03    0.15   68%  71% Peek item [empty] mbox
    1.09    0.93    2.91    0.14   93%  59% Tryget [empty] mbox
    0.15    0.09    0.48    0.07   87%  75% Waiting to get mbox
    0.15    0.09    0.48    0.08   81%  75% Waiting to put mbox
    0.36    0.24    1.47    0.10   62%  53% Delete mbox
    3.55    3.39    7.59    0.25   96%  96% Put/Get mbox

    0.18    0.06    1.56    0.10   78%  46% Init semaphore
    0.82    0.72    1.95    0.09   50%  46% Post [0] semaphore
    0.91    0.78    2.43    0.11   81%  46% Wait [1] semaphore
    0.83    0.72    2.01    0.10   53%  46% Trywait [0] semaphore
    0.77    0.72    1.35    0.07   90%  71% Trywait [1] semaphore
    0.16    0.06    1.20    0.09   59%  46% Peek semaphore
    0.15    0.06    1.02    0.08   46%  46% Destroy semaphore
    2.96    2.85    5.31    0.16   96%  96% Post/Wait semaphore

    0.28    0.21    1.71    0.09   96%  96% Create counter
    0.13    0.00    0.45    0.06   59%  21% Get counter value
    0.02    0.00    0.15    0.04   81%  81% Set counter value
    0.96    0.87    1.86    0.08   81%  84% Tick counter
    0.18    0.03    0.69    0.10   65%  43% Delete counter

    0.18    0.06    1.35    0.10   78%  46% Init flag
    0.87    0.72    2.40    0.12   71%  46% Destroy flag
    0.79    0.72    1.65    0.09   96%  71% Mask bits in flag
    0.88    0.75    2.01    0.09   50%  46% Set bits in flag [no waiters]
    0.99    0.87    3.12    0.15   96%  71% Wait for flag [AND]
    0.97    0.87    2.76    0.14   96%  81% Wait for flag [OR]
    0.99    0.87    3.21    0.15   96%  84% Wait for flag [AND/CLR]
    0.96    0.87    2.67    0.13   96%  84% Wait for flag [OR/CLR]
    0.03    0.00    0.24    0.05   71%  71% Peek on flag

    0.41    0.27    1.47    0.12   68%  56% Create alarm
    1.21    1.02    3.39    0.20   93%  71% Initialize alarm
    0.93    0.84    1.89    0.11   84%  71% Disable alarm
    1.19    0.99    3.48    0.21   96%  71% Enable alarm
    1.05    0.90    2.61    0.16   84%  71% Delete alarm
    0.90    0.81    1.71    0.09   93%  71% Tick counter [1 alarm]
    3.04    2.97    3.96    0.10   96%  71% Tick counter [many alarms]
    1.20    1.11    2.58    0.12   93%  84% Tick & fire counter [1 alarm]
   12.84   12.75   14.22    0.12   96%  71% Tick & fire counters [>1 together]
    3.36    3.27    4.86    0.11   96%  71% Tick & fire counters [>1 separately]
    1.51    1.50    2.79    0.02   99%  99% Alarm latency [0 threads]
    2.22    1.50    3.72    0.36   67%  14% Alarm latency [2 threads]
    7.42    5.28    9.93    1.13   47%  30% Alarm latency [many threads]
    3.83    3.78    7.95    0.10   95%  94% Alarm -> thread resume latency

    0.88    0.39    3.75    0.00            Clock/interrupt latency

    1.39    0.54    6.45    0.00            Clock DSR latency

   17      0    2024  (main stack:  6047)  Thread stack used (2024 total)
           All done, main stack : stack used  1592 size  6048
            All done :  Interrupt stack used   756 size  4096
            All done : Idlethread stack used  1172 size  2048

Timing complete - 31290 ms total

PASS:<Basic timing OK>
EXIT:<done>

Other Issues

The MPC8309KIT platform HAL does not affect the implementation of other parts of the eCos HAL specification. The MPC55XX variant HAL, and the PowerPC architectural HAL documentation should be consulted for further details.