Introduction
------------

When running a LINUX build inside the LINUX source-tree for SPARC the
output is an image <linux-base>/arch/sparc/boot/image. This image however
cannot be run directly and it is linked to virtual addresses. The image
expects among other things an initalized romvector and the MMU to be switched
on. The script mklinuximg sets up such an enviroment. The outut of mklinuximg
can be uploaded using GRMON, simulated in TSIM or serve as input to MKPROM2
for PROM bootloader generation.

Invocation
----------

Usage:
mklinuximg <linux-image> <out-file> [-freq <frequency>] [-base <baseaddr>] [-cmdline <string>] [-amp <string>] [-ethmac <string>] [-ipi <irq_num>] [-ioarea <ioarea>]
  <linux-image> linux image, normally <linux-dir>/arch/sparc/boot/image.
  <out-file>    output image that can be uploaded using GRMON or run in TSIM.

 optional parameters:
  -base <baseaddr>  optional baseaddress. The default is 0x40000000.
  -cmdline <string> kernel parameter string. Default is "console=ttyS0,38400".
  -freq <frequency> optional frequency parameter in case if it cannot be retrived from the Timer scalar.
  -amp <string>     optional string of format <idx0>=<val0>:<idx1>=<val1>:... that sets for core index
                    n property ampopts to value n. Example 0=4:1=6 will set core index 0's ampopts to 4
                      and core index 1's ampopts to 6.
  -ethmac <string>  set the ethernet mac address as 12 dgt hex. Default: 00007ccc0145
  -ipi <irq_num>    IRQ number used by Linux SMP for IPIs. May not be shared. Allowed values: 1..14
  -ioarea <ioarea>  GRLIB AMBA Plug&Play I/O AREA Base address. Defaults to 0xfff00000
  -xml <file>       Specify a xml file that adds extra properties and nodes to the device tree."
                    The -xml switch only functions if the -allocinmem switch is choosen."
  -flat             Create a flat device-tree."

Files
-----

 mklinuximg    Script that create config files and build environment for the
               sources in src/ and include/.
 
 mklinuximg.S  the linker script template. 
 pgt_gen.c     helperprogram that generates a root page table.
 prom_stage2.c the setup program that intalizes the system.
 

Linux
-----

The LINUX version has to be newer than 2.6.36.

Extra tree nodes
----------------

Using the option "-xml <file>" extra properties and extra node subtrees can be added
to the prom node tree generation.

 The xml files format:
 tags:
   add-property
   add-node
   property

 <add-property>:
   Add properties to a choosen node(s).
   There are 2 variants to:
    <add-property vendor="0x1" device="0xc" idx="0" >
     selects the node to add properties to by vendor:device:idx
     where <idx> is the amba-scan index
    <add-property parent="4" >
     selects the node to add properties to by amba-scan index <parent>

 <add-node>:
   Add node subtree to a choosen node(s) as child.
   There are 2 variants to:
    <add-node vendor="0x1" device="0xc" idx="0" >
     selects the node to add node subtree to by vendor:device:idx
     where <idx> is the amba-scan index
    <add-node parent="4" >
     selects the node to add node subtree to by amba-scan index <parent>

 <property name="[name]" type="[int|str]" value="val" >:
   Add a property by name=value. 2 types are supported:
   "int" : adds a integer, specified by "value"
   "str" : adds a string, specified by "value"

 
# example xml:
# --------------------- start ----------------------------
#<!-- add property by vendor:device:idx -->
#<add-property vendor="0x1" device="0xc" idx="0" >
#  <property name="add-prop-1.c.test1" type="int" value="1024"/>
#  <property name="add-prop-1.c.test2" type="str" >teststr</property>
#</add-property>
#
#<!-- add property by scan idx -->
#<add-property parent="4"  >
#  <property name="add-prop-p4.test1" type="int" value="1024"/>
#  <property name="add-prop-p4.test2" type="str" >teststr</property>
#</add-property>
#
#<!-- add subtree by vendor:device:idx -->
#<add-node name="newnode-add-node-1-c" vendor="0x1" device="0xc" idx="0" >
#  <property name="newnode-1-p1" type="int" value="5"/>
#  <property name="newnode-1-p2" type="int" value="6"/>
#  <add-node name="newnode-1-1" >
#    <property name="newnode-1-1-p1" type="int" value="7"/>
#    <property name="newnode-1-1-p2" type="int" value="8"/>
#  </add-node>
#  <add-node name="newnode-1-2" >
#    <property name="newnode-1-2-p1" type="int" value="9"/>
#    <property name="newnode-1-2-p2" type="int" value="10"/>
#  </add-node>
#</add-node>
#
#<!-- add subtree by scan idx -->
#<add-node name="newnode-add-p4" parent="4" >
#  <property name="newnode-p1" type="int" value="1"/>
#  <property name="newnode-p2" type="int" value="2"/>
#  <add-node name="newnode-2-1" >
#    <property name="newnode-2-1-p1" type="int" value="3"/>
#    <property name="newnode-2-1-p2" type="int" value="4"/>
#    <property name="newnode-2-1-p2-2" type="int" value="5"/>
#  </add-node>
#</add-node>
# ---------------------  end  ----------------------------
