2.6.1. Locating target peripherals in the scatter-loading description file

Conventionally, addresses of peripheral registers are hard-coded in project source or header files. You can also declare structures that map on to peripheral registers, and place these structures in the description file.

For example, a target might have a timer peripheral with two memory mapped 32-bit registers. Example 2.13 shows a C structure that maps to these registers.

Example 2.13. Mapping to a peripheral register

__attribute__ ((zero_init)) struct {
    volatile unsigned ctrl;           /* timer control */
    volatile unsigned tmr;            /* timer value   */
} timer_regs;

To place this structure at a specific address in the memory map, create a new execution region to hold the structure.

The description file shown in Example 2.14 locates the timer_regs structure at 0x40000000.

It is important that the contents of these registers are not initialized to zero during application startup, because this is likely to change the state of your system. Marking an execution region with the UNINIT attribute prevents ZI data in that region from being zero initialized.

Example 2.14. Placing the mapped structure

ROM_LOAD 0x24000000 0x04000000
{
    ; ...
    TIMER 0x40000000 UNINIT
    {
        timer_regs.o (+ZI)
    }
    ; ...
}
Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential