Name

HAL Port — Implementation Details

Overview

This documentation explains how the eCos HAL specification has been mapped onto the AT91SAM7S-EK hardware, and should be read in conjunction with that specification. The AT91SAM7S-EK platform HAL package complements the ARM architectural HAL, the AT91 variant HAL and the AT91SAM7 processor HAL. It provides functionality which is specific to the target board.

Startup

Following a hard or soft reset, the HAL will initialize or reinitialize most of the on-chip peripherals. There is an exception for RAM startup applications which depend on a ROM monitor or JTAG device for certain services.

For ROM startup, the HAL will perform additional initialization, setting up the PLL and programming the various internal registers. This is all done in the PLATFORM_SETUP1 macro in the assembler header file hal_platform_setup.h.

Linker Scripts and Memory Maps

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

On-chip Flash
This is located at address 0x00100000 of the physical memory space.
On-chip RAM
This is located at address 0x00200000 of the physical memory space. During booting this memory is only available at this address, but during the boot process it is also remapped to location 0x00000000 in order to allow the hardware exception vectors to be in RAM. The first 32 bytes are used for hardware exception vectors. The next 32 bytes are used for 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 startup, all remaining RAM is available. For RAM startup, available RAM starts at location 0x00201000, with the bottom 4KiB reserved for use by the GDB stubs.
On-chip Peripheral Registers
These are located at address 0xFF000000 in the physical memory space.

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. The test was built in ARM mode, which provided better performance than Thumb mode.

Example 239.1. at91sam7sek Real-time characterization

            Startup, main stack : stack used   416 size  3920
             Startup :  Interrupt stack used   148 size  4096
             Startup : Idlethread stack used    84 size  2048

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

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

Testing parameters:
   Clock samples:            32
   Threads:                   2
   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
  ======  ======  ======  ====== ========== ========
   22.00   21.67   22.33    0.33  100%  50% Create thread
    4.50    4.33    4.67    0.17  100%  50% Yield thread [all suspended]
    4.67    4.67    4.67    0.00  100% 100% Suspend [suspended] thread
    5.00    5.00    5.00    0.00  100% 100% Resume thread
    7.33    7.33    7.33    0.00  100% 100% Set priority
    0.67    0.67    0.67    0.00  100% 100% Get priority
   16.67   16.67   16.67    0.00  100% 100% Kill [suspended] thread
    4.67    4.67    4.67    0.00  100% 100% Yield [no other] thread
    8.67    8.33    9.00    0.33  100%  50% Resume [suspended low prio] thread
    5.00    5.00    5.00    0.00  100% 100% Resume [runnable low prio] thread
    6.50    6.33    6.67    0.17  100%  50% Suspend [runnable] thread
    4.50    4.33    4.67    0.17  100%  50% Yield [only low prio] thread
    4.33    4.33    4.33    0.00  100% 100% Suspend [runnable->not runnable]
   16.33   16.33   16.33    0.00  100% 100% Kill [runnable] thread
   11.67   11.67   11.67    0.00  100% 100% Destroy [dead] thread
   23.67   23.67   23.67    0.00  100% 100% Destroy [runnable] thread
   33.50   31.33   35.67    2.17  100%  50% Resume [high priority] thread
   12.62   12.33   17.33    0.14   74%  25% Thread switch

    0.44    0.33    0.67    0.14   68%  68% Scheduler lock
    3.35    3.33    3.67    0.04   93%  93% Scheduler unlock [0 threads]
    3.35    3.33    3.67    0.04   93%  93% Scheduler unlock [1 suspended]
    3.35    3.33    3.67    0.04   93%  93% Scheduler unlock [many suspended]
    3.35    3.33    3.67    0.04   93%  93% Scheduler unlock [many low prio]

    1.00    1.00    1.00    0.00  100% 100% Init mutex
    4.96    4.67    5.00    0.07   87%  12% Lock [unlocked] mutex
    5.84    5.67    6.00    0.17   53%  46% Unlock [locked] mutex
    4.83    4.67    5.00    0.17  100%  50% Trylock [unlocked] mutex
    4.13    4.00    4.33    0.16   62%  62% Trylock [locked] mutex
    0.50    0.33    0.67    0.17  100%  50% Destroy mutex
   32.27   32.00   32.33    0.10   81%  18% Unlock/Lock mutex

    1.46    1.33    1.67    0.16   62%  62% Create mbox
    0.33    0.33    0.33    0.00  100% 100% Peek [empty] mbox
    5.46    5.33    5.67    0.16   62%  62% Put [first] mbox
    0.29    0.00    0.33    0.07   87%  12% Peek [1 msg] mbox
    5.46    5.33    5.67    0.16   62%  62% Put [second] mbox
    0.29    0.00    0.33    0.07   87%  12% Peek [2 msgs] mbox
    5.58    5.33    5.67    0.13   75%  25% Get [first] mbox
    5.58    5.33    5.67    0.13   75%  25% Get [second] mbox
    4.63    4.33    4.67    0.07   87%  12% Tryput [first] mbox
    4.33    4.33    4.33    0.00  100% 100% Peek item [non-empty] mbox
    5.08    5.00    5.33    0.13   75%  75% Tryget [non-empty] mbox
    4.25    4.00    4.33    0.13   75%  25% Peek item [empty] mbox
    4.42    4.33    4.67    0.13   75%  75% Tryget [empty] mbox
    0.42    0.33    0.67    0.13   75%  75% Waiting to get mbox
    0.42    0.33    0.67    0.13   75%  75% Waiting to put mbox
    1.50    1.33    1.67    0.17  100%  50% Delete mbox
   22.02   22.00   22.33    0.04   93%  93% Put/Get mbox

    0.92    0.67    1.00    0.13   75%  25% Init semaphore
    4.00    4.00    4.00    0.00  100% 100% Post [0] semaphore
    4.54    4.33    4.67    0.16   62%  37% Wait [1] semaphore
    4.00    4.00    4.00    0.00  100% 100% Trywait [0] semaphore
    4.00    4.00    4.00    0.00  100% 100% Trywait [1] semaphore
    1.00    1.00    1.00    0.00  100% 100% Peek semaphore
    0.50    0.33    0.67    0.17  100%  50% Destroy semaphore
   19.92   19.67   20.00    0.13   75%  25% Post/Wait semaphore

    1.54    1.33    1.67    0.16   62%  37% Create counter
    0.46    0.33    0.67    0.16   62%  62% Get counter value
    0.46    0.33    0.67    0.16   62%  62% Set counter value
    4.92    4.67    5.00    0.13   75%  25% Tick counter
    0.50    0.33    0.67    0.17  100%  50% Delete counter

    0.88    0.67    1.00    0.16   62%  37% Init flag
    4.38    4.33    4.67    0.07   87%  87% Destroy flag
    4.00    4.00    4.00    0.00  100% 100% Mask bits in flag
    4.33    4.33    4.33    0.00  100% 100% Set bits in flag [no waiters]
    6.92    6.67    7.00    0.13   75%  25% Wait for flag [AND]
    6.79    6.67    7.00    0.16   62%  62% Wait for flag [OR]
    6.92    6.67    7.00    0.13   75%  25% Wait for flag [AND/CLR]
    6.83    6.67    7.00    0.17  100%  50% Wait for flag [OR/CLR]
    0.33    0.33    0.33    0.00  100% 100% Peek on flag

    2.67    2.67    2.67    0.00  100% 100% Create alarm
    8.63    8.33    8.67    0.07   87%  12% Initialize alarm
    3.92    3.67    4.00    0.13   75%  25% Disable alarm
    7.92    7.67    8.00    0.13   75%  25% Enable alarm
    4.67    4.67    4.67    0.00  100% 100% Delete alarm
    5.88    5.67    6.00    0.16   62%  37% Tick counter [1 alarm]
   40.75   40.67   41.00    0.13   75%  75% Tick counter [many alarms]
   11.54   11.33   11.67    0.16   62%  37% Tick & fire counter [1 alarm]
  232.75  232.67  233.00    0.13   75%  75% Tick & fire counters [>1 together]
   46.75   46.67   47.00    0.13   75%  75% Tick & fire counters [>1 separately]
   32.33   32.33   32.33    0.00  100% 100% Alarm latency [0 threads]
   35.22   33.33   39.67    1.90   78%  78% Alarm latency [2 threads]
   35.22   32.33   39.67    1.90   77%  52% Alarm latency [many threads]
   54.37   54.33   59.00    0.07   99%  99% Alarm -> thread resume latency

    6.65    6.33    7.00    0.00            Clock/interrupt latency

   12.95   11.33   19.67    0.00            Clock DSR latency

  292    292     292  (main stack:   772)  Thread stack used (1360 total)
           All done, main stack : stack used   772 size  3920
            All done :  Interrupt stack used   208 size  4096
            All done : Idlethread stack used   248 size  2048

Timing complete - 30250 ms total

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

Other Issues

The AT91SAM7S-EK platform HAL does not affect the implementation of other parts of the eCos HAL specification. The AT91SAM7 processor HAL, AT91 variant HAL, and the ARM architectural HAL documentation should be consulted for further details.