xref: /openbmc/qemu/docs/system/generic-loader.rst (revision 526f1f3a5c6726e3d3b893d8063d31fda091c7e0)
170f20110SAlex Bennée..
270f20110SAlex Bennée   Copyright (c) 2016, Xilinx Inc.
370f20110SAlex Bennée
470f20110SAlex Bennée   This work is licensed under the terms of the GNU GPL, version 2 or later.  See
570f20110SAlex Bennée   the COPYING file in the top-level directory.
670f20110SAlex Bennée
770f20110SAlex BennéeGeneric Loader
870f20110SAlex Bennée--------------
970f20110SAlex Bennée
1070f20110SAlex BennéeThe 'loader' device allows the user to load multiple images or values into
1170f20110SAlex BennéeQEMU at startup.
1270f20110SAlex Bennée
1370f20110SAlex BennéeLoading Data into Memory Values
1470f20110SAlex Bennée^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1570f20110SAlex BennéeThe loader device allows memory values to be set from the command line. This
1670f20110SAlex Bennéecan be done by following the syntax below::
1770f20110SAlex Bennée
1870f20110SAlex Bennée   -device loader,addr=<addr>,data=<data>,data-len=<data-len> \
1970f20110SAlex Bennée                   [,data-be=<data-be>][,cpu-num=<cpu-num>]
2070f20110SAlex Bennée
2170f20110SAlex Bennée``<addr>``
2270f20110SAlex Bennée  The address to store the data in.
2370f20110SAlex Bennée
2470f20110SAlex Bennée``<data>``
2570f20110SAlex Bennée  The value to be written to the address. The maximum size of the data
2670f20110SAlex Bennée  is 8 bytes.
2770f20110SAlex Bennée
2870f20110SAlex Bennée``<data-len>``
2970f20110SAlex Bennée  The length of the data in bytes. This argument must be included if
3070f20110SAlex Bennée  the data argument is.
3170f20110SAlex Bennée
3270f20110SAlex Bennée``<data-be>``
3370f20110SAlex Bennée  Set to true if the data to be stored on the guest should be written
3470f20110SAlex Bennée  as big endian data. The default is to write little endian data.
3570f20110SAlex Bennée
3670f20110SAlex Bennée``<cpu-num>``
3770f20110SAlex Bennée  The number of the CPU's address space where the data should be
3870f20110SAlex Bennée  loaded. If not specified the address space of the first CPU is used.
3970f20110SAlex Bennée
4070f20110SAlex BennéeAll values are parsed using the standard QemuOps parsing. This allows the user
4170f20110SAlex Bennéeto specify any values in any format supported. By default the values
4270f20110SAlex Bennéewill be parsed as decimal. To use hex values the user should prefix the number
4370f20110SAlex Bennéewith a '0x'.
4470f20110SAlex Bennée
4570f20110SAlex BennéeAn example of loading value 0x8000000e to address 0xfd1a0104 is::
4670f20110SAlex Bennée
4770f20110SAlex Bennée    -device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4
4870f20110SAlex Bennée
4970f20110SAlex BennéeSetting a CPU's Program Counter
5070f20110SAlex Bennée^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5170f20110SAlex Bennée
5270f20110SAlex BennéeThe loader device allows the CPU's PC to be set from the command line. This
5370f20110SAlex Bennéecan be done by following the syntax below::
5470f20110SAlex Bennée
5570f20110SAlex Bennée     -device loader,addr=<addr>,cpu-num=<cpu-num>
5670f20110SAlex Bennée
5770f20110SAlex Bennée``<addr>``
5870f20110SAlex Bennée  The value to use as the CPU's PC.
5970f20110SAlex Bennée
6070f20110SAlex Bennée``<cpu-num>``
6170f20110SAlex Bennée  The number of the CPU whose PC should be set to the specified value.
6270f20110SAlex Bennée
6370f20110SAlex BennéeAll values are parsed using the standard QemuOpts parsing. This allows the user
6470f20110SAlex Bennéeto specify any values in any format supported. By default the values
6570f20110SAlex Bennéewill be parsed as decimal. To use hex values the user should prefix the number
6670f20110SAlex Bennéewith a '0x'.
6770f20110SAlex Bennée
6870f20110SAlex BennéeAn example of setting CPU 0's PC to 0x8000 is::
6970f20110SAlex Bennée
7070f20110SAlex Bennée    -device loader,addr=0x8000,cpu-num=0
7170f20110SAlex Bennée
7270f20110SAlex BennéeLoading Files
7370f20110SAlex Bennée^^^^^^^^^^^^^
7470f20110SAlex Bennée
7570f20110SAlex BennéeThe loader device also allows files to be loaded into memory. It can load ELF,
7670f20110SAlex BennéeU-Boot, and Intel HEX executable formats as well as raw images.  The syntax is
7770f20110SAlex Bennéeshown below:
7870f20110SAlex Bennée
7970f20110SAlex Bennée    -device loader,file=<file>[,addr=<addr>][,cpu-num=<cpu-num>][,force-raw=<raw>]
8070f20110SAlex Bennée
8170f20110SAlex Bennée``<file>``
8270f20110SAlex Bennée  A file to be loaded into memory
8370f20110SAlex Bennée
8470f20110SAlex Bennée``<addr>``
8570f20110SAlex Bennée  The memory address where the file should be loaded. This is required
8670f20110SAlex Bennée  for raw images and ignored for non-raw files.
8770f20110SAlex Bennée
8870f20110SAlex Bennée``<cpu-num>``
8970f20110SAlex Bennée  This specifies the CPU that should be used. This is an
9070f20110SAlex Bennée  optional argument and will cause the CPU's PC to be set to the
9170f20110SAlex Bennée  memory address where the raw file is loaded or the entry point
9270f20110SAlex Bennée  specified in the executable format header. This option should only
9370f20110SAlex Bennée  be used for the boot image. This will also cause the image to be
9470f20110SAlex Bennée  written to the specified CPU's address space. If not specified, the
95*d00d739bSAxel Heider  default is CPU 0.
96*d00d739bSAxel Heider
97*d00d739bSAxel Heider``<force-raw>``
98*d00d739bSAxel Heider  Setting 'force-raw=on' forces the file to be treated as a raw image.
99*d00d739bSAxel Heider  This can be used to load supported executable formats as if they
100*d00d739bSAxel Heider  were raw.
10170f20110SAlex Bennée
10270f20110SAlex BennéeAll values are parsed using the standard QemuOpts parsing. This allows the user
10370f20110SAlex Bennéeto specify any values in any format supported. By default the values
10470f20110SAlex Bennéewill be parsed as decimal. To use hex values the user should prefix the number
10570f20110SAlex Bennéewith a '0x'.
10670f20110SAlex Bennée
10770f20110SAlex BennéeAn example of loading an ELF file which CPU0 will boot is shown below::
10870f20110SAlex Bennée
10970f20110SAlex Bennée    -device loader,file=./images/boot.elf,cpu-num=0
11070f20110SAlex Bennée
11170f20110SAlex BennéeRestrictions and ToDos
11270f20110SAlex Bennée^^^^^^^^^^^^^^^^^^^^^^
11370f20110SAlex Bennée
11470f20110SAlex BennéeAt the moment it is just assumed that if you specify a cpu-num then
11570f20110SAlex Bennéeyou want to set the PC as well. This might not always be the case. In
11670f20110SAlex Bennéefuture the internal state 'set_pc' (which exists in the generic loader
11770f20110SAlex Bennéenow) should be exposed to the user so that they can choose if the PC
11870f20110SAlex Bennéeis set or not.
11970f20110SAlex Bennée
12070f20110SAlex Bennée
121