Name

HAL Port — Implementation Details

Overview

This documentation explains how the eCos HAL specification has been mapped onto the ARM Aarch32 Virtual Machine, and should be read in conjunction with that specification. The platform HAL package complements the ARM architectural HAL, the Cortex-A variant HAL and the VIRTUAL variant HAL. It provides functionality which is specific to the target board.

Startup

Following a 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.

Xvisor VM 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:

Virtual Flash
This is located at 0x00000000 and is 32MB in size. The hypervisor is responsible for loading the initial image, typically RedBoot, in to the start of this region. When the VM is kicked into life execution starts here.
RAM
This is located at address 0x40000000 of the physical memory space and is 32MiB in size. The HAL configures the MMU to retain the RAM at virtual address 0x40000000 with caching enabled. The same memory is also accessible uncached and unbuffered at virtual address 0x50000000 for use by device drivers. ROM applications can use RAM starting at 0x4000000020. Interrupt and exception vectors are placed at 0x40000000 and the virtual vectors occupy 256 bytes at 0x00000050. For ROM startup, all remaining RAM is available. RAM startup applications are loaded from location 0x40200000, reserving 2MiB.
Shared memory
A shared memory region is allocated at address 0x38000000. This area can be mapped to memory shared between the eCos VM and any other VM. It may be used to load applications into the VM using the RedBoot load command and may also be used to enable communications between applications in the eCos VM and the other VM.
Peripheral Registers
These occupy regions of memory at 0x08000000, 0x09000000 and 0x0a000000 of varying sizes. These include the GIC registers, emulated peripherals such as the PL011 UART or VirtIO devices.

The virtual address space visible to applications is summarized in the following table. Any address range not mentioned here should not be accessed and will raise an exception if it is.

BaseSize (MiB)CacheDescription
0x0000000032Disabled Virtual flash.
0x080000001DisabledGIC registers.
0x0900000016DisabledEmulated device registers.
0x0A00000016DisabledVirtIO device registers.
0x3800000016Disabled Shared memory.
0x4000000032EnabledNormal SDRAM access.
0x5000000032DisabledUncached access to RAM.

QEMU VM 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:

RAM

This is located at address 0x40000000 of the physical memory space and is 32MiB in size. The HAL configures the MMU to retain the RAM at virtual address 0x40000000 with caching enabled. The same memory is also accessible uncached and unbuffered at virtual address 0x50000000 for use by device drivers. ROM applications can use RAM starting at 0x4040000020. Interrupt and exception vectors are placed at 0x40400000 and the virtual vectors occupy 256 bytes at 0x40400050. For ROM startup, all remaining RAM is available. RAM startup applications are loaded from location 0x40500000, reserving 5MiB.

ROM applications are loaded into the bottom 4MB of RAM, at 0x40010000, which is treated like a read-only memory for this purpose. This, for example, allows RedBoot to perform a reset by jumping to 0x40010000.

Peripheral Registers
These occupy regions of memory at 0x08000000, 0x09000000 and 0x0a000000 of varying sizes. These include the GIC registers, emulated peripherals such as the PL011 UART or VirtIO devices.

The virtual address space visible to applications is summarized in the following table. Any address range not mentioned here should not be accessed and will raise an exception if it is.

BaseSize (MiB)CacheDescription
0x080000001DisabledGIC registers.
0x0900000016DisabledEmulated device registers.
0x0A00000016DisabledVirtIO device registers.
0x4000000032EnabledNormal RAM access.
0x5000000032DisabledUncached access to RAM.

Xvisor Tests

There are two test programs that may be used in conjunction with the Linux host to run performance and communication tests. These tests are built automatically if RPMSG is enabled and copied out to the bin directory of the eCos installation. They are also stripped of all debug and symbol table sectors to allow them to be loaded via RedBoot.

The rpmsg test is a simple reflector program that send any RPMSG messages it receives back to their origin. It may be used to test RPMSG functionality.

The bench test is used to run a number of performance tests. It also uses RPMSG for communication. Each RPMSG message received must contain a string consisting of a test name followed by the number of second for which the test is to be run. Each test is run for the given number of seconds and a reply message is sent containing the number of loops of the given test that were completed, and the number of nanoseconds that each loop took. Timing for these tests is done using a Rockchip timer to ensure that it uses real time rather than VM virtual time. The tests available are as follows:

NULL
A null test that performs no activity. This can be used to get an idea of the overhead of running tests.
COMP
This test performs a modest amount of integer computation per loop.
FPU
This test performs some floating point computation in each loop.
NEON
This test performs some computation using the NEON SIMD instructions.
MMUX
This test accesses a location in memory that is not mapped via the MMU. It should provoke a data access exception, which eCos should handle by printing a message on the console and continuing. The seconds parameter for this test should be set to zero.
MEMX
This test is similar to MMUX except that the location accessed is one that is memory mapped, but not backed by memory or an emulated device. This will result in an exception being delivered to Xvisor.

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 ARM32 mode and run in non-SMP mode on a VCPU bound to host CPU 3 of Xvisor running on a Pine Rockpro64.

Example 259.1. VM Real-time characterization

             Startup, main thrd : stack used   404 size  1792
             Startup :  Interrupt stack used  4096 size  4096
             Startup : Idlethread stack used    88 size  1280

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.38 microseconds (103 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
   Stack Size:             1088


                                 Confidence
     Ave     Min     Max     Var  Ave  Min  Function
  ======  ======  ======  ====== ========== ========
INFO:<Ctrl-C disabled until test completion>
    1.05    0.68    1.41    0.17   56%  20% Create thread
    0.19    0.00    0.31    0.15   60%  39% Yield thread [all suspended]
    0.31    0.00    0.68    0.07   79%  10% Suspend [suspended] thread
    0.20    0.00    0.31    0.15   62%  37% Resume thread
    0.24    0.00    0.31    0.11   76%  23% Set priority
    0.07    0.00    0.31    0.11   78%  78% Get priority
    0.50    0.31    1.04    0.19   98%  50% Kill [suspended] thread
    0.19    0.00    0.31    0.15   60%  39% Yield [no other] thread
    0.25    0.00    0.31    0.10   81%  18% Resume [suspended low prio] thread
    0.20    0.00    0.31    0.15   62%  37% Resume [runnable low prio] thread
    0.22    0.00    0.31    0.13   71%  28% Suspend [runnable] thread
    0.19    0.00    0.31    0.15   60%  39% Yield [only low prio] thread
    0.18    0.00    0.31    0.15   57%  42% Suspend [runnable->not runnable]
    0.37    0.31    0.68    0.10   84%  84% Kill [runnable] thread
    0.36    0.31    0.68    0.09   85%  85% Destroy [dead] thread
    0.65    0.31    1.04    0.06   87%   9% Destroy [runnable] thread
    1.17    1.04    1.41    0.17   64%  64% Resume [high priority] thread
    0.34    0.31    0.68    0.04   93%  93% Thread switch

    0.07    0.00    0.31    0.11   76%  76% Scheduler lock
    0.16    0.00    0.31    0.16   51%  48% Scheduler unlock [0 threads]
    0.17    0.00    0.31    0.16   53%  46% Scheduler unlock [1 suspended]
    0.17    0.00    0.31    0.16   53%  46% Scheduler unlock [many suspended]
    0.17    0.00    0.31    0.16   53%  46% Scheduler unlock [many low prio]

    0.15    0.00    0.31    0.16   53%  53% Init mutex
    0.24    0.00    0.68    0.13   68%  28% Lock [unlocked] mutex
    0.21    0.00    0.31    0.14   65%  34% Unlock [locked] mutex
    0.21    0.00    0.31    0.14   65%  34% Trylock [unlocked] mutex
    0.20    0.00    0.31    0.15   62%  37% Trylock [locked] mutex
    0.05    0.00    0.31    0.08   84%  84% Destroy mutex
    1.09    0.68    1.41    0.10   81%   3% Unlock/Lock mutex

    0.15    0.00    0.31    0.16   53%  53% Create mbox
    0.20    0.00    0.68    0.16   56%  40% Peek [empty] mbox
    0.21    0.00    0.31    0.14   65%  34% Put [first] mbox
    0.08    0.00    0.31    0.12   75%  75% Peek [1 msg] mbox
    0.19    0.00    0.31    0.15   59%  40% Put [second] mbox
    0.07    0.00    0.31    0.11   78%  78% Peek [2 msgs] mbox
    0.20    0.00    0.31    0.15   62%  37% Get [first] mbox
    0.21    0.00    0.31    0.13   68%  31% Get [second] mbox
    0.20    0.00    0.31    0.15   62%  37% Tryput [first] mbox
    0.20    0.00    0.31    0.15   62%  37% Peek item [non-empty] mbox
    0.21    0.00    0.31    0.14   65%  34% Tryget [non-empty] mbox
    0.21    0.00    0.31    0.14   65%  34% Peek item [empty] mbox
    0.19    0.00    0.31    0.15   59%  40% Tryget [empty] mbox
    0.06    0.00    0.31    0.10   81%  81% Waiting to get mbox
    0.13    0.00    0.31    0.15   59%  59% Waiting to put mbox
    0.10    0.00    0.31    0.13   68%  68% Delete mbox
    0.78    0.68    1.04    0.15   71%  71% Put/Get mbox

    0.18    0.00    0.31    0.15   56%  43% Init semaphore
    0.19    0.00    0.68    0.16   53%  43% Post [0] semaphore
    0.20    0.00    0.31    0.15   62%  37% Wait [1] semaphore
    0.18    0.00    0.31    0.15   56%  43% Trywait [0] semaphore
    0.19    0.00    0.31    0.15   59%  40% Trywait [1] semaphore
    0.08    0.00    0.31    0.12   75%  75% Peek semaphore
    0.08    0.00    0.31    0.12   75%  75% Destroy semaphore
    0.71    0.68    1.04    0.06   90%  90% Post/Wait semaphore

    0.17    0.00    0.31    0.16   53%  46% Create counter
    0.18    0.00    0.68    0.17   50%  46% Get counter value
    0.05    0.00    0.31    0.08   84%  84% Set counter value
    0.18    0.00    0.31    0.15   56%  43% Tick counter
    0.09    0.00    0.31    0.13   71%  71% Delete counter

    0.07    0.00    0.31    0.11   78%  78% Init flag
    0.19    0.00    0.31    0.15   59%  40% Destroy flag
    0.17    0.00    0.31    0.16   53%  46% Mask bits in flag
    0.20    0.00    0.31    0.15   62%  37% Set bits in flag [no waiters]
    0.21    0.00    0.31    0.14   65%  34% Wait for flag [AND]
    0.20    0.00    0.31    0.15   62%  37% Wait for flag [OR]
    0.21    0.00    0.31    0.14   65%  34% Wait for flag [AND/CLR]
    0.21    0.00    0.31    0.13   68%  31% Wait for flag [OR/CLR]
    0.07    0.00    0.31    0.11   78%  78% Peek on flag

    0.09    0.00    0.31    0.13   71%  71% Create alarm
    0.34    0.00    0.68    0.08   81%   6% Initialize alarm
    0.18    0.00    0.31    0.15   56%  43% Disable alarm
    0.24    0.00    0.68    0.13   68%  28% Enable alarm
    0.20    0.00    0.31    0.15   62%  37% Delete alarm
    0.21    0.00    0.31    0.14   65%  34% Tick counter [1 alarm]
    0.68    0.31    1.04    0.02   93%   3% Tick counter [many alarms]
    0.27    0.00    0.31    0.07   87%  12% Tick & fire counter [1 alarm]
    3.86    3.59    4.32    0.16   65%  31% Tick & fire counters [>1 together]
    0.78    0.68    1.04    0.15   71%  71% Tick & fire counters [>1 separately]
   10.87   10.21   11.93    0.28   50%  12% Alarm latency [0 threads]
    5.25    4.69    5.89    0.14   59%   2% Alarm latency [2 threads]
    5.70    5.42    6.46    0.17   49%  35% Alarm latency [many threads]
   11.61   10.89   12.66    0.28   58%   9% Alarm -> thread resume latency

    6.68    3.65   11.46    0.00            Clock/interrupt latency

    0.57    0.36    1.09    0.00            Clock DSR latency

     241     172     288                    Worker thread stack used (stack size 1088)
            All done, main thrd : stack used   892 size  1792
            All done :  Interrupt stack used   136 size  4096
            All done : Idlethread stack used   240 size  1280

Timing complete - 30960 ms total

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

Other Issues

The platform HAL does not affect the implementation of other parts of the eCos HAL specification. The ARM architectural HAL documentation should be consulted for further details.