eCosPro® Reference Manual
Prev |  | Next

# The HAL Port

## Name

HAL Port -- Implementation Details

## Overview

This documentation explains how the eCos HAL specification has been mapped onto the AT91SAM9260-EK hardware, and should be read in conjunction with that specification. The AT91SAM9260-EK platform HAL package complements the ARM architectural HAL, the ARM9 variant HAL and the SAM9 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 for certain services.

For ROM startup, the HAL will perform additional initialization. This is all done in the `PLATFORM_SETUP1` macro in the assembler header file `hal_platform_setup.h`.

## 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:

SDRAM

  This is located at address 0x20000000 of the physical memory space. The HAL configures the MMU to retain the SDRAM at virtual address 0x20000000, but in order to assign hardware exception vectors vectors at address 0x00000000, the HAL also uses the MMU to create a clone of this memory at virtual address 0x00000000. The same memory is also accessible uncached and unbuffered at virtual location 0x30000000 for use by devices. 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. Memory is required for the MMU tables, and must be aligned on a 16Kbyte boundary. These therefore occupy memory from 0x4000 to 0x8000. For ROM startup, all remaining SDRAM is available. For RAM startup, available RAM starts at virtual location 0x20040000, with the bottom 256kB reserved for use by RedBoot.

On-chip SRAM

  This is located at address 0x00200000 of the physical memory space. However the HAL uses the MMU to relocate this to virtual address 0x70000000. The same memory is also accessible uncached and unbuffered at virtual location 0x70100000 for use by devices. At present this memory is unused by eCos and is available for application use.

On-chip ROM

  This is located at address 0x00100000 of the physical memory space. However the HAL uses the MMU to relocate this to virtual address 0x71000000. The same memory is also accessible uncached and unbuffered at virtual location 0x71800000.

USB host port

  The USB host port (UHP) registers are located at address 0x00300000 of the physical memory space. However the HAL uses the MMU to relocate this to virtual address 0x72800000. Memory accessed at this address is uncached and unbuffered. There is no cached variant.

SPI dataflash

  SPI Dataflash media can only be accessed with the Flash API. For the purposes of this API a placeholder address range has been allocated as if the Flash is present at this address. The base of this address range is 0x40000000 for the on-board flash and 0x50000000 for the dataflash slot, the extent will clearly depend on the Dataflash capacity. This reserved range is not real memory and any attempt to access it directly by the processor other than via the Flash API will result in a memory address exception.

On-chip Peripheral Registers

  These are located at address 0xFF000000 in the physical memory space. When the MMU is enabled, it sets up a direct, uncached, unbuffered mapping so that these registers remain accessible at their physical locations.

Off-chip Peripherals

  eCos uses the SDRAM, ethernet PHY, MCI, and SPI dataflash facilities on the AT91SAM9260-EK board. eCos does not currently make any use of any other off-chip peripherals present on this board.

## Advanced Interrupt Controller

This port has been designed to exploit benefits of the Advanced Interrupt Controller of the AT91SAM9260, using the facilities of the SAM9 processor HAL. Consult the documentation in that package for details.

## SPI Dataflash

eCos supports SPI access to Dataflash on the AT91SAM9260-EK. An on-board device and an external card slot are provided on the board. The on-chip device is typically used to contain RedBoot and flash configuration data. The external slot is available for application use.

Accesses to Dataflash are performed via the Flash API, using 0x40000000 or 0x50000000 as the nominal address of the device, although it does not truly exist in the processor address space. For the external card slot, on driver initialisation, eCos and RedBoot can detect the presence of a card in the socket. In particular, on reset RedBoot will indicate the presence of Flash at the 0x40000000 address range in its startup banner if it has been successfully detected. Hot swapping is not possible.

Since Dataflash is not directly addressable, access from RedBoot is only possible using fis command operations.

The MCI driver cannot be enabled simultaneously with the SPI driver, as the drivers need differing pin configurations for the same pins on this board due to the shared socket.

## 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.

                Startup, main stack : stack used   420 size  3920
                 Startup :  Interrupt stack used   528 size  4096
                 Startup : Idlethread stack used    80 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    6.28 microseconds (38 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
      ======  ======  ======  ====== ========== ========
        5.07    3.38    8.70    0.87   46%  29% Create thread
        0.86    0.81    2.26    0.08   81%  81% Yield thread [all suspended]
        1.06    0.97    2.58    0.11   95%  56% Suspend [suspended] thread
        1.05    0.97    2.26    0.11   92%  67% Resume thread
        1.47    1.29    3.87    0.12   62%  25% Set priority
        0.41    0.16    0.81    0.10   92%   1% Get priority
        3.18    2.90    9.02    0.25   64%  62% Kill [suspended] thread
        0.85    0.81    1.93    0.08   79%  79% Yield [no other] thread
        1.65    1.45    3.54    0.13   73%  23% Resume [suspended low prio] thread
        1.06    0.97    2.42    0.11   95%  60% Resume [runnable low prio] thread
        1.45    1.29    3.70    0.09   64%  28% Suspend [runnable] thread
        0.87    0.81    2.09    0.09   73%  73% Yield [only low prio] thread
        1.06    0.97    2.42    0.11   92%  60% Suspend [runnable->not runnable]
        3.09    2.74    9.18    0.26   84%  54% Kill [runnable] thread
        2.42    2.09    5.80    0.15   39%   1% Destroy [dead] thread
        4.27    3.87   10.47    0.29   84%  42% Destroy [runnable] thread
        6.09    5.48   11.44    0.35   75%  45% Resume [high priority] thread
        2.00    1.93    4.51    0.09   73%  73% Thread switch

        0.16    0.16    0.64    0.01   99%  99% Scheduler lock
        0.68    0.64    0.97    0.05   80%  80% Scheduler unlock [0 threads]
        0.68    0.64    0.97    0.05   80%  80% Scheduler unlock [1 suspended]
        0.68    0.64    1.13    0.05   80%  80% Scheduler unlock [many suspended]
        0.68    0.64    0.97    0.05   80%  80% Scheduler unlock [many low prio]

        0.29    0.16    1.13    0.09   62%  34% Init mutex
        1.05    0.81    2.09    0.13   84%   9% Lock [unlocked] mutex
        1.20    0.97    2.90    0.15   81%  15% Unlock [locked] mutex
        1.00    0.81    2.42    0.12   62%  21% Trylock [unlocked] mutex
        0.93    0.81    1.93    0.11   53%  43% Trylock [locked] mutex
        0.20    0.16    0.64    0.07   81%  81% Destroy mutex
        5.72    5.32    7.73    0.21   68%  21% Unlock/Lock mutex

        0.43    0.32    1.61    0.12   96%  53% Create mbox
        0.33    0.16    0.64    0.07   65%  18% Peek [empty] mbox
        1.26    1.13    2.42    0.16   81%  81% Put [first] mbox
        0.32    0.16    0.64    0.06   65%  18% Peek [1 msg] mbox
        1.27    1.13    2.74    0.13   43%  46% Put [second] mbox
        0.32    0.16    0.64    0.07   65%  21% Peek [2 msgs] mbox
        1.32    1.13    3.22    0.16   62%  34% Get [first] mbox
        1.33    1.13    3.22    0.15   75%  21% Get [second] mbox
        1.11    0.97    2.09    0.12   43%  40% Tryput [first] mbox
        1.12    0.97    2.09    0.13   37%  43% Peek item [non-empty] mbox
        1.21    0.97    2.42    0.14   84%   6% Tryget [non-empty] mbox
        0.99    0.81    1.77    0.08   71%  12% Peek item [empty] mbox
        1.04    0.97    2.26    0.11   96%  75% Tryget [empty] mbox
        0.33    0.16    0.81    0.10   56%  25% Waiting to get mbox
        0.35    0.16    0.64    0.07   71%   9% Waiting to put mbox
        0.60    0.48    1.93    0.13   93%  56% Delete mbox
        4.33    3.87    8.70    0.37   84%  71% Put/Get mbox

        0.31    0.16    1.29    0.08   68%  28% Init semaphore
        0.87    0.81    2.09    0.10   96%  84% Post [0] semaphore
        0.95    0.81    2.09    0.11   56%  37% Wait [1] semaphore
        0.85    0.64    2.09    0.10   78%   9% Trywait [0] semaphore
        0.82    0.64    1.29    0.03   93%   3% Trywait [1] semaphore
        0.31    0.16    0.97    0.08   65%  25% Peek semaphore
        0.22    0.16    0.81    0.09   75%  75% Destroy semaphore
        3.43    3.06    5.96    0.22   87%  37% Post/Wait semaphore

        0.42    0.32    1.61    0.12   96%  62% Create counter
        0.29    0.16    0.97    0.09   62%  34% Get counter value
        0.24    0.16    0.81    0.11   90%  65% Set counter value
        1.06    0.81    2.09    0.13   84%   9% Tick counter
        0.30    0.16    1.45    0.11   56%  37% Delete counter

        0.28    0.16    1.29    0.11   50%  46% Init flag
        0.96    0.81    2.74    0.13   50%  43% Destroy flag
        0.82    0.64    1.93    0.12   53%  28% Mask bits in flag
        0.97    0.81    2.09    0.10   56%  31% Set bits in flag [no waiters]
        1.28    1.13    2.74    0.10   62%  34% Wait for flag [AND]
        1.28    1.13    2.90    0.11   62%  34% Wait for flag [OR]
        1.28    1.13    2.90    0.12   56%  37% Wait for flag [AND/CLR]
        1.26    1.13    2.90    0.13   96%  50% Wait for flag [OR/CLR]
        0.17    0.16    0.32    0.01   96%  96% Peek on flag

        0.60    0.48    1.93    0.13   93%  53% Create alarm
        1.70    1.45    4.35    0.20   75%  71% Initialize alarm
        0.98    0.81    2.42    0.10   68%  25% Disable alarm
        1.65    1.45    4.99    0.22   96%  90% Enable alarm
        1.16    0.97    2.74    0.13   71%  21% Delete alarm
        1.07    0.97    1.45    0.09   56%  40% Tick counter [1 alarm]
        4.89    4.83    5.96    0.10   81%  81% Tick counter [many alarms]
        1.89    1.77    3.06    0.13   93%  56% Tick & fire counter [1 alarm]
       29.89   29.80   30.93    0.11   96%  62% Tick & fire counters [>1 together]
        5.70    5.64    7.25    0.11   96%  87% Tick & fire counters [>1 separately]
        5.66    5.64    7.73    0.04   97%  97% Alarm latency [0 threads]
        6.43    5.80    8.54    0.37   54%  37% Alarm latency [2 threads]
       14.05   12.56   15.79    0.81   46%  33% Alarm latency [many threads]
        8.96    8.86   15.14    0.15   96%  78% Alarm -> thread resume latency

        2.26    1.45    6.12    0.00            Clock/interrupt latency

        2.69    1.77    6.93    0.00            Clock DSR latency

       33      0     292  (main stack:  1388)  Thread stack used (8016 total)
               All done, main stack : stack used  1388 size  3920
                All done :  Interrupt stack used   208 size  4096
                All done : Idlethread stack used   268 size  2048

    Timing complete - 30140 ms total

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

## Other Issues

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

Prev | Home | Next
JTAG debugging support | Up | Atmel AT91SAM9261 Evaluation Kit Board Support