Name

HAL Port — Implementation Details

Overview

This documentation explains how the eCos HAL specification has been mapped onto the AT91SAM9263-EK hardware, and should be read in conjunction with that specification. The AT91SAM9263-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 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 AT91SAM9263-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 AT91SAM9263, 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 AT91SAM9263. An external card slot are provided on the board which is typically used to contain RedBoot and flash configuration data.

Accesses to Dataflash are performed via the Flash API, using 0x40000000 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.

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 264.1. sam9263ek Real-time characterization

            Startup, main stack : stack used   420 size  3920
             Startup :  Interrupt stack used   528 size  4096
             Startup : Idlethread stack used    96 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    5.95 microseconds (37 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
  ======  ======  ======  ====== ========== ========
    4.89    3.20    7.84    0.85   48%  25% Create thread
    0.73    0.64    1.92    0.10   98%  54% Yield thread [all suspended]
    0.93    0.80    2.08    0.11   46%  42% Suspend [suspended] thread
    0.91    0.80    1.92    0.10   45%  46% Resume thread
    1.32    1.12    3.36    0.11   67%  14% Set priority
    0.27    0.16    0.64    0.10   42%  43% Get priority
    2.97    2.72    7.20    0.19   71%  65% Kill [suspended] thread
    0.71    0.64    0.96    0.08   56%  56% Yield [no other] thread
    1.51    1.28    3.20    0.12   87%   7% Resume [suspended low prio] thread
    0.89    0.80    1.44    0.09   95%  53% Resume [runnable low prio] thread
    1.27    1.12    2.24    0.08   60%  28% Suspend [runnable] thread
    0.72    0.64    1.44    0.09   98%  56% Yield [only low prio] thread
    0.93    0.80    1.60    0.09   57%  34% Suspend [runnable->not runnable]
    2.83    2.56    6.08    0.15   90%   4% Kill [runnable] thread
    2.27    2.08    5.44    0.14   70%  28% Destroy [dead] thread
    3.92    3.52    6.72    0.16   79%  15% Destroy [runnable] thread
    5.79    5.44    9.44    0.24   81%  48% Resume [high priority] thread
    1.88    1.76    3.68    0.09   61%  36% Thread switch

    0.08    0.00    0.32    0.08   50%  49% Scheduler lock
    0.56    0.48    1.12    0.08   99%  50% Scheduler unlock [0 threads]
    0.57    0.48    1.12    0.08   50%  49% Scheduler unlock [1 suspended]
    0.56    0.48    1.12    0.08   98%  55% Scheduler unlock [many suspended]
    0.57    0.48    1.28    0.08   99%  50% Scheduler unlock [many low prio]

    0.19    0.00    1.12    0.07   87%   6% Init mutex
    0.96    0.80    2.72    0.12   59%  37% Lock [unlocked] mutex
    1.08    0.80    2.88    0.15   87%   9% Unlock [locked] mutex
    0.86    0.64    1.92    0.12   84%  12% Trylock [unlocked] mutex
    0.76    0.64    1.28    0.08   62%  34% Trylock [locked] mutex
    0.08    0.00    0.32    0.08   96%  50% Destroy mutex
    4.95    4.80    7.68    0.23   90%  90% Unlock/Lock mutex

    0.28    0.16    1.28    0.11   53%  43% Create mbox
    0.19    0.00    0.48    0.07   71%   6% Peek [empty] mbox
    1.12    0.96    2.40    0.09   65%  28% Put [first] mbox
    0.19    0.00    0.48    0.05   81%   3% Peek [1 msg] mbox
    1.10    0.96    1.44    0.07   68%  25% Put [second] mbox
    0.21    0.00    0.64    0.08   68%   3% Peek [2 msgs] mbox
    1.17    0.96    2.56    0.12   81%  15% Get [first] mbox
    1.16    0.96    1.44    0.07   68%   6% Get [second] mbox
    0.97    0.80    1.92    0.08   71%  18% Tryput [first] mbox
    1.00    0.80    1.92    0.09   78%   6% Peek item [non-empty] mbox
    1.08    0.96    2.40    0.12   96%  50% Tryget [non-empty] mbox
    0.88    0.80    2.08    0.11   96%  71% Peek item [empty] mbox
    0.90    0.80    1.60    0.10   96%  53% Tryget [empty] mbox
    0.21    0.16    0.48    0.07   75%  75% Waiting to get mbox
    0.21    0.16    0.48    0.07   78%  78% Waiting to put mbox
    0.45    0.32    1.44    0.10   59%  37% Delete mbox
    3.50    3.36    6.56    0.20   96%  96% Put/Get mbox

    0.19    0.16    1.12    0.06   96%  96% Init semaphore
    0.73    0.64    1.76    0.12   93%  65% Post [0] semaphore
    0.81    0.64    1.76    0.08   71%  18% Wait [1] semaphore
    0.72    0.64    1.76    0.11   96%  71% Trywait [0] semaphore
    0.70    0.64    1.28    0.09   71%  71% Trywait [1] semaphore
    0.17    0.00    0.64    0.06   75%  12% Peek semaphore
    0.11    0.00    0.96    0.11   46%  46% Destroy semaphore
    3.15    3.04    5.60    0.18   93%  93% Post/Wait semaphore

    0.30    0.16    1.60    0.13   40%  46% Create counter
    0.16    0.00    0.80    0.10   46%  31% Get counter value
    0.11    0.00    0.80    0.09   56%  40% Set counter value
    0.91    0.80    1.76    0.10   50%  46% Tick counter
    0.15    0.00    0.96    0.11   46%  34% Delete counter

    0.20    0.16    1.28    0.07   93%  93% Init flag
    0.82    0.64    2.08    0.11   62%  25% Destroy flag
    0.68    0.48    1.44    0.09   68%   9% Mask bits in flag
    0.81    0.64    1.92    0.10   59%  28% Set bits in flag [no waiters]
    1.15    0.96    2.56    0.09   87%   9% Wait for flag [AND]
    1.15    1.12    1.92    0.05   96%  96% Wait for flag [OR]
    1.14    1.12    1.60    0.03   96%  96% Wait for flag [AND/CLR]
    1.14    0.96    1.76    0.06   81%   9% Wait for flag [OR/CLR]
    0.07    0.00    0.16    0.08   53%  53% Peek on flag

    0.50    0.32    1.92    0.11   65%  25% Create alarm
    1.60    1.44    4.32    0.21   96%  84% Initialize alarm
    0.85    0.64    1.92    0.11   84%   9% Disable alarm
    1.47    1.28    3.36    0.17   56%  81% Enable alarm
    1.05    0.80    2.56    0.14   87%   6% Delete alarm
    0.98    0.80    1.92    0.07   84%   9% Tick counter [1 alarm]
    4.74    4.64    5.28    0.09   96%  50% Tick counter [many alarms]
    1.74    1.60    3.04    0.11   59%  37% Tick & fire counter [1 alarm]
   29.67   29.61   30.09    0.08   71%  71% Tick & fire counters [>1 together]
    5.52    5.44    5.92    0.09   96%  59% Tick & fire counters [>1 separately]
    5.13    5.12    6.08    0.01   99%  99% Alarm latency [0 threads]
    5.64    5.12    6.24    0.36   46%  53% Alarm latency [2 threads]
    8.07    6.88    9.76    0.68   43%  37% Alarm latency [many threads]
    8.20    8.16   12.49    0.07   98%  98% Alarm -> thread resume latency

    1.45    1.28    4.00    0.00            Clock/interrupt latency

    2.13    1.60    5.28    0.00            Clock DSR latency

    6      0     312  (main stack:  1388)  Thread stack used (1360 total)
           All done, main stack : stack used  1388 size  3920
            All done :  Interrupt stack used   204 size  4096
            All done : Idlethread stack used   796 size  2048

Timing complete - 29980 ms total

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

Other Issues

The AT91SAM9263-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.