ChorusOS 4.0 Porting Guide

Chapter 5 System Image Configuration

This chapter explains how to define the system image configuration, in a set of configuration files. These configuration files are created in XML.

Overview

You cannot use the graphical configuration tools, ews, to define the system image configuration for a new target board. Instead, create the configuration files using a text editor. Once the files have been created, you can view them using ews, and build the system image. You can also use the mkimage tool to build the system image.

The board-specific configurations must be stored in the directory src/nucleus/bsp/family/board. For example, the board-specific configuration files for the SBC8260 board are stored in src/nucleus/bsp/powerpc/sbc8260, and those for the PC/AT are stored in src/nucleus/bsp/x86/i386at.

There are two configuration files:

Most of the examples in this chapter use the SBC8260 board. To understand the examples, the following information about the SBC8260 board is useful:

Imported Objects

The following objects are pre-defined and can be used within the board-specific configuration files:

target.xml Definition

A target.xml file contains a number of hierarchical folders:

Global Variables

The global variables folder contains definitions of global system image configuration variables.

Some of them are board-specific and used within the board-specific configuration files only. For example, a configuration for a PC/AT target defines the LOADER configuration variable, with a value specifying which of the two initial loaders (SVR4 boot and Linux LILO boot) will be used to load the system image. The format of the system image is tailored to match the requirements of the initial loader specified by LOADER.

There is one mandatory global variable, IMAGE_DIR. This variable specifies the working directory to be used by the mkimage tool to store the files created during system image generation.

Example 5-1 is an extract of the SBC8260 board-specific configuration file, and defines two global configuration variables, IMAGE_DIR and RESULT.


Example 5-1 SBC8260 Global Variable Configuration

<definition name='IMAGE_DIR'>
			<description>'mkimage' tool output repository</description>
			<string/>
			<vstring>${BUILD_DIR}/image/${BOOT_MODE}/${SYSTEM}</vstring>
</definition>

<definition name='RESULT'>
			<description>the resulting system image file pathname</description>
			<string/>
			<vstring>${BUILD_DIR}/${SYSTEM}.${BOOT_MODE}</vstring>
</definition>

The value of IMAGE_DIR specifies the mkimage working directory as a function of the BOOT_MODE and SYSTEM configuration variables. For example, the working directory for RAM-based chorus system image generation is ${BUILD_DIR}/image/RAM/chorus.

The value of RESULT specifies the filename of the resulting (bootable) system image file. The filename also depends on the BOOT_MODE and SYSTEM configuration variables. For example, the bootable RAM-based chorus system image file will be stored in ${BUILD_DIR}/chorus.RAM.

Banks

The banks folder contains definitions of the system image memory banks.

A system image memory bank is specified by an object of the type Bank. The following fields of a Bank object are defined in a target.xml file:

The board-specific configuration can define any number of memory banks. A board-specific configuration must define a Bank object named sys_bank.

For example, the SBC8260 board-specific configuration defines two memory banks trampoline_bank and sys_bank.

trampoline_bank will contain the power-up initialization (trampoline) program (see "Power-up Program Implementation"). sys_bank will contain the remains of the system image.

Example 5-2 is an extract of the SBC8260 board-specific configuration file, and defines the trampoline_bank and sys_bank objects.


Example 5-2 SBC8260 Bank Configuration

	
<folder name='Banks'>

    <description>system image memory banks</description>

    <definition name='sys_bank'>
      <description>default system image memory bank</description>
      <condition>
        <equal><var name='BOOT_MODE' /><const>RAM</const></equal>
      </condition>

      <type name='Bank' />
      <value field='ram'><true /></value>
      <value field='addr'><const>0x00100000</const></value>
      <value field='size'><const>0x00f00000</const></value>
    </definition>

    <definition name='trampoline_bank'>
      <description>memory bank for a 'trampoline' (eg. power-up) binary</description>
      <condition>
        <equal><var name='BOOT_MODE' /><const>ROM</const></equal>
      </condition>
      <type name='Bank' />
      <value field='ram'><false /></value>
      <value field='addr'><const>0xfff00000</const></value>
      <value field='size'><const>0x00001000</const></value>
    </definition>

    <definition name='sys_bank'>
      <description>default system image memory bank</description>
      <condition>
        <equal><var name='BOOT_MODE' /><const>ROM</const></equal>
      </condition>
      <type name='Bank' />
      <value field='ram'><false /></value>
      <value field='addr'><const>0xfff01000</const></value>
      <value field='size'><const>0x000ff000</const></value>
    </definition>

  </folder>

Two bank configurations are provided. The first configuration is used when the system is configured to boot from ROM. This configuration is selected when the value of the BOOT_MODE configuration variable is set to ROM. In this case, trampoline_bank will start at the address 0xfff00000 and can contain up to 4K bytes, sufficient for thetrampoline program to run. sys_bank starts immediately after trampoline_bank at the address 0xfff01000 and it can contain up to 0xff000 bytes.

The second configuration is used when the system is configured to boot from RAM. In this case, trampoline_bank is not defined. sys_bank starts at the address 0x00100000 and it can contain up to 0xf00000 bytes. The RAM occupied by the bank will be tagged as allocated when the initial state of the RAM allocator is generated, because the value of the ram field is true.

Areas

This folder contains definitions of the linking areas used during system image link-edit. A linking area is specified by an object of the type Area which defines the following fields:

The board-specific configuration can define any number of linking areas. A board-specific configuration must define an Area object named ram_area.

For example, the SBC8260 board-specific configuration defines three linking areas: ram_area, supervisor_actor_area, and user_actor_area.

When the micro-kernel is configured with the memory management module implementing the flat memory model (that is, when the value of the VIRTUAL_ADDRESS_SPACE configuration variable is false), only ram_area is defined. It is used to link-edit all non-XIP data segments.

Example 5-3 is an extract of the SBC8260 board-specific configuration file, and defines the ram_area object.


Example 5-3 SBC8260 ram_area Configuration

    <definition name='ram_area'>
      <description>default system image linking area
          (used for bss only)</description>
      <condition>
        <equal><var name='BOOT_MODE' /><const>RAM</const></equal>
      </condition>
      <type name='Area' />
      <value field='addr'><const>0x00004000</const></value>
      <value field='size'><const>0x000fc000</const></value>
      <value field='private'><false/></value>
      <value field='virtual'><false/></value>
    </definition>

    <definition name='ram_area'>
      <description>default system image linking area
          (used for data segments)</description>
      <condition>
        <equal><var name='BOOT_MODE' /><const>ROM</const></equal>
      </condition>
      <type name='Area' />
      <value field='addr'><const>0x00004000</const></value>
      <value field='size'><const>0x00ffc000</const></value>
      <value field='private'><false/></value>
      <value field='virtual'><false/></value>
    </definition>

When the microkernel is configured with one of the memory management modules implementing the virtual memory model (that is, when the value of the VIRTUAL_ADDRESS_SPACE configuration variable is true), three linking areas are defined:

Example 5-4 is an extract of the SBC2860 board-specific configuration file, and defines the supervisor_actor_area and user_actor_area objects.


Example 5-4 SBC8260 supervisor_actor_area and user_actor_area objects

   <definition name='supervisor_actor_area'>
      <description>linking area for supervisor actors</description>
      <condition><var name='VIRTUAL_ADDRESS_SPACE' /></condition>
      <type name='Area' />
      <value field='virtual'><true /></value>
      <value field='private'><false /></value>
      <value field='addr'><const>0xa0000000</const></value>
      <value field='size'><const>0x40000000</const></value>
    </definition>

    <definition name='user_actor_area'>
      <description>linking area for user actors</description>
      <condition><var name='VIRTUAL_ADDRESS_SPACE' /></condition>
      <type name='Area' />
      <value field='virtual'><true /></value>
      <value field='private'><true /></value>
      <value field='addr'><const>0x00000000</const></value>
      <value field='size'><const>0x80000000</const></value>
    </definition>

System Control Blocks

A board-specific configuration must define two references to linking area objects where global system control blocks are allocated:

For example, the SBC8260 board-specific configuration defines supervisor_context_area_ref as a reference to ram_area:

<definition name='supervisor_context_area_ref'>
			<description>reference to the address range where global system 
				control blocks must be allocated</description>
			<type name='Area' ref-only='yes' />
			<ref name='ram_area' />
</definition>

The mkimage tool will allocate an address range for supervisor address space control blocks in ram_area (as well as the address ranges for all segments link-edited into it).

Two configurations for user_context_area_ref are defined for the SBC8260 board.

Kernel Address Space

A board-specific configuration can specify the initial kernel address space layout. If specified, the object that defines it must be named ksp and is usually contained in the folder named KSP. The exact semantics and requirements for the initial kernel address space specifications are family dependent.

An MPC60x family-dependent configuration must specify the initial kernel address space layout.

The SBC8260 board-dependent configuration specifies the initial kernel address space as follows:


Example 5-5 SBC8260 board-dependent configursation

  <folder name='Kernel address SPace'>
    <description>kernel address space configurations</description>

    <definition name='ksp'>
      <description>flat memory management:           system address space layout
virtual memory management:      see PPC 60x BKI</description>

      <type name='AddrSpaceMap' />
<!--
        PowerPC 60x bus SDRAM: 0x00000000 .. 0x00ffffff
-->
      <value index='size'>
        <value field='vaddr'><const>0x00000000</const></value>
        <value field='valid'><true/></value>
        <value field='paddr'><const>0x00000000</const></value>
        <value field='attr'>
          <const>KSP_PPC60x_BAT|KSP_PPC60x_M|KSP_PPC60x_RW</const>
        </value>
      </value>
<!--
        Local bus 32-bit SDRAM: 0x02000000 .. 0x02ffffff
-->
      <value index='size'>
        <value field='vaddr'><const>0x01000000</const></value>
        <value field='valid'><false/></value>
      </value>
<!--
        8260 internal memory map (IMMR): 0x0f000000 .. 0x0f01ffff
-->
      <value index='size'>
        <value field='vaddr'><const>0x0f000000</const></value>
        <value field='valid'><true/></value>
        <value field='paddr'><const>0x0f000000</const></value>
        <value field='attr'>
          <const>KSP_PPC60x_BAT|KSP_PPC60x_G|KSP_PPC60x_I|KSP_PPC60x_RW</const>
        </value>
      </value>

      <value index='size'>
        <value field='vaddr'><const>0x0f020000</const></value>
        <value field='valid'><false/></value>
      </value>
<!--
        8-bits general purpose FLASH memory: 0xe0000000 .. 0xe0ffffff
-->
<!--
        32-bits general purpose FLASH memory.
                expandable : 0xfc000000 .. 0xfcffffff
                boot       : 0xfe000000 .. 0xffffffff
-->
      <value index='size'>
        <value field='vaddr'><const>0xfc000000</const></value>
        <value field='valid'><true/></value>
        <value field='paddr'><const>0xfc000000</const></value>
        <value field='attr'>
          <const>KSP_PPC60x_BAT|KSP_PPC60x_RO</const></value>
      </value>
    </definition>

  </folder>

According to this definition, the microkernel will initially map the RAM space from physical address 0 to 0x01000000, to the virtual address 0, using one pair of BATs. It will also map the flash memory space from physical address 0xfc000000 to 0xffffffff, to the virtual address 0xfc000000 using another pair of BATs. Finally, the microkernel will map 0x00020000 bytes of 8260 Internal Memory Mapped Registers based at the physical address 0x0f000000 to the virtual address 0x0f000000. The rest of the virtual address space will be invalid.

Link-Edit Models

The link-edit models folder contains a set of link-edit models, each one describing how to link-edit a particular type of binary file.

The models.xml file contains the standard set of link-edit models:

Usually, the board-specific configuration includes the models defined in model.xml and defines a small number of board-specific models.

A link-edit model is specified by an object of type Binary which defines the following fields:

The values of the ro, rw, and bss fields are objects of the type Segment. A Segment object specifies link-edit instructions for the set of sections held by the segment and instructions for the segment loading for execution. In the Segment object:

Therefore, if for a given segment a linking area is not defined (for instance, the segment is to be link-edited at its place in the memory bank) ,the xip attribute must be true.

If, for a segment, a linking area is defined, the xip attribute can be either:

Example 5-6 is an extract of the SBC8260 board-specific configuration file, and contains the standard link-edit models and the link-edit model definition which contains the trampoline program.


Example 5-6 SBC8260 Link-Edit Model Configuration

<folder name='Link-edit models'>
			<description>layouts of executable binary files</description>

		<folderRef href='model.xml' />  

		<folder name='Genesis2-specific link-edit models'>
			<description>layouts of executable binary files</description>

			<definition name='trampoline_model'>
				<description>trampoline (eg. power-up) program link-edit model</description>
				<type name='Binary' />
				<value field='ro'>
					<value field='xip'><true/></value>
				</value>
				<value field='strip'><const>ALL</const></value>
			</definition>
		</folder>
</folder>

The trampoline program does not contain any data and its text section must be link-edited at its place in its memory bank, trampoline_bank.

Files

The files folder contains the specification of the set of BSP files that can be included in the system image. Each file is specified by an object of the type File which contains the following fields:

Example 5-7 is an extract of the SBC8260 board-specific configuration file, and contains the definitions of the File objects.


Example 5-7 SBC8260 File Configuration

  <folder name='Files'>
    <description>files that system image can potentially contain</description>

    <definition name='powerup'>
      <description>powerup initialization program</description>
      <condition>
        <equal><var name='BOOT_MODE' /><const>ROM</const></equal>
      </condition>

      <type name='File' />
      <value field='path'>
        <vstring>${BSP_DIR}/bin/sbc8260/boot/trampoline.r</vstring>
      </value>
      <value field='bank'><ref name='trampoline_bank' /></value>
      <value field='binary'><ref name='trampoline_model' /></value>
    </definition>

    <definition name='bootstrap'>
      <description>bootstrap program</description>
      <type name='File' />
      <value field='path'>
        <vstring>${BSP_DIR}/bin/sbc8260/boot/boot.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='bootstrap_model' /></value>
    </definition>

    <definition name='debug_driver'>
      <description>system debug agent driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${BSP_DIR}/bin/sbc8260/dbg/dbgBsp.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='debug_driver_model' /></value>
    </definition>

    <definition name='debug_agent'>
      <description>system debug agent</description>
      <type name='File' />
      <value field='path'>
        <vstring>${BUILD_DIR}/obj/dbg/dbgAgent.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='debug_agent_model' /></value>
    </definition>

    <definition name='microkernel'>
      <description>ChorusOS micro-kernel</description>
        <type name='File' />
      <value field='path'>
        <vstring>${BUILD_DIR}/obj/kern/kern.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='microkernel_model' /></value>
    </definition>

    <definition name='tbdec'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_F_DIR}/bin/drv/timer/tbDec/D_tbDec.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='quicc8260'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_F_DIR}/bin/drv/quicc/8260/D_quicc8260.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='fccEther'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_DIR}/bin/drv/net/ether/fcc/D_fccEther.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='sccEther'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_DIR}/bin/drv/net/ether/scc/D_sccEther.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='quiccMii'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_DIR}/bin/drv/mii/quiccMii/D_quiccMii.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='lxt970'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_DIR}/bin/drv/phy/lxt970/D_lxt970.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='sccUart'>
      <description>built-in driver</description>
      <type name='File' />
      <value field='path'>
        <vstring>${DRV_DIR}/bin/drv/uart/scc/D_sccUart.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='driver_model' /></value>
    </definition>

    <definition name='reboot'>
      <description>reboot program</description>
      <type name='File' />
      <value field='path'>
        <vstring>${BSP_DIR}/bin/sbc8260/reboot/reboot.r</vstring>
      </value>
      <value field='bank'><ref name='sys_bank' /></value>
      <value field='binary'><ref name='reboot_model' /></value>
    </definition>
  </folder>

System Image

The system image folder contains three sub-folders:

Files

The files folder contains the definition of a BSP_files object, which is a list of references to File objects specifying the files that must be included in the system image.

A board-specific configuration must define a BSP_files object.

Example 5-8 is an extract of the SBC8260 board-specific configuration file, and contains the BSP_files definition.


Example 5-8 SBC8260 BSP_files Configuration

      <definition name='BSP_files'>
        <description>system image BSP files</description>
        <type name='FileList' />
        <value index='size'><ref name='debug_driver' /></value>
        <value index='size'><ref name='debug_agent' /></value>
        <value index='size'><ref name='bootstrap' /></value>
        <value index='size'><ref name='reboot' /></value>
        <value index='size'><ref name='microkernel' /></value>
        <value index='size'><ref name='tbdec' /></value>
        <value index='size'><ref name='quicc8260' /></value>
        <value index='size'><ref name='fccEther' /></value>
      </definition>

      <setting name='BSP_files'>
        <condition>
          <equal><var name='BOOT_MODE' /><const>ROM</const></equal>
        </condition>
        <value index='size'><ref name='powerup' /></value>
      </setting>

Files Generated Automatically

The mkimage tool generates three files:

The Auto-generated files folder contains definitions of File objects corresponding to these three files. The File objects must be named bootconf, symb, and env_file, respectively.

Example 5-9 is an extract of the SBC8260 board-specific configuration file, and contains the Auto-generated files definition.


Example 5-9 SBC8260 Auto-generated Files Configuration

      <folder name='Auto-generated files'>
        <description>system image files automatically \
         generated by 'mkimage' tool</description>

        <definition name='env_file'>
          <description>initial state of system environment \
           variables</description>
          <type name='File' />
          <value field='path'>
            <vstring>${IMAGE_DIR}/environ</vstring>
          </value>
          <value field='bank'><ref name='sys_bank' /></value>
        </definition>

        <definition name='symb'>
          <description>kernel debuger (kdb) symbols</description>
          <type name='File' />
          <value field='path'>
            <vstring>${IMAGE_DIR}/symb/${SYSTEM}_symb.r</vstring>
          </value>
          <value field='bank'><ref name='sys_bank' /></value>
          <value field='binary'><ref name='debug_agent_model' /></value>
        </definition>

        <definition name='bootconf'>
          <description>bootconf program</description>
          <type name='File' />
          <value field='path'>
            <vstring>${IMAGE_DIR}/bconf/${SYSTEM}_bconf.r</vstring>
          </value>
          <value field='bank'><ref name='sys_bank' /></value>
          <value field='binary'><ref name='bootconf_model' /></value>
        </definition>

      </folder>

Miscellaneous Information

The misc folder contains the following:

Example 5-10 is an extract of the SBC8260 board-specific configuration file, and contains the Misc definition.


Example 5-10 SBC8260 Misc Configuration

    <folder name='Misc'>
      <description>Misc configuration variables</description>
        
      <definition name='banks'>
        <description>list of system image banks</description>
        <type name='BankList'/>
      </definition>

      <definition name='heap_size'>
        <description>bootconf heap size</description>
        <int/>
        <const>0x00002000</const>
      </definition>

      <setting name='banks'>
        <condition>
          <equal><var name='BOOT_MODE' /><const>ROM</const></equal>
        </condition>
        <value index='size'><ref name='trampoline_bank' /></value>
      </setting>

      <setting name='banks'>
        <value index='size'><ref name='sys_bank' /></value>
      </setting>

    </folder>

Summary of Required Definitions

A board-specific configuration must define the following objects:

In addition, for x86 and MPC860 based platforms you must also define the space_barrier variable.