1*70f20110SAlex Bennée.. 2*70f20110SAlex Bennée Copyright (c) 2016, Xilinx Inc. 3*70f20110SAlex Bennée 4*70f20110SAlex BennéeThis work is licensed under the terms of the GNU GPL, version 2 or later. See 5*70f20110SAlex Bennéethe COPYING file in the top-level directory. 6*70f20110SAlex Bennée 7*70f20110SAlex BennéeGeneric Loader 8*70f20110SAlex Bennée-------------- 9*70f20110SAlex Bennée 10*70f20110SAlex BennéeThe 'loader' device allows the user to load multiple images or values into 11*70f20110SAlex BennéeQEMU at startup. 12*70f20110SAlex Bennée 13*70f20110SAlex BennéeLoading Data into Memory Values 14*70f20110SAlex Bennée^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15*70f20110SAlex BennéeThe loader device allows memory values to be set from the command line. This 16*70f20110SAlex Bennéecan be done by following the syntax below:: 17*70f20110SAlex Bennée 18*70f20110SAlex Bennée -device loader,addr=<addr>,data=<data>,data-len=<data-len> \ 19*70f20110SAlex Bennée [,data-be=<data-be>][,cpu-num=<cpu-num>] 20*70f20110SAlex Bennée 21*70f20110SAlex Bennée``<addr>`` 22*70f20110SAlex Bennée The address to store the data in. 23*70f20110SAlex Bennée 24*70f20110SAlex Bennée``<data>`` 25*70f20110SAlex Bennée The value to be written to the address. The maximum size of the data 26*70f20110SAlex Bennée is 8 bytes. 27*70f20110SAlex Bennée 28*70f20110SAlex Bennée``<data-len>`` 29*70f20110SAlex Bennée The length of the data in bytes. This argument must be included if 30*70f20110SAlex Bennée the data argument is. 31*70f20110SAlex Bennée 32*70f20110SAlex Bennée``<data-be>`` 33*70f20110SAlex Bennée Set to true if the data to be stored on the guest should be written 34*70f20110SAlex Bennée as big endian data. The default is to write little endian data. 35*70f20110SAlex Bennée 36*70f20110SAlex Bennée``<cpu-num>`` 37*70f20110SAlex Bennée The number of the CPU's address space where the data should be 38*70f20110SAlex Bennée loaded. If not specified the address space of the first CPU is used. 39*70f20110SAlex Bennée 40*70f20110SAlex BennéeAll values are parsed using the standard QemuOps parsing. This allows the user 41*70f20110SAlex Bennéeto specify any values in any format supported. By default the values 42*70f20110SAlex Bennéewill be parsed as decimal. To use hex values the user should prefix the number 43*70f20110SAlex Bennéewith a '0x'. 44*70f20110SAlex Bennée 45*70f20110SAlex BennéeAn example of loading value 0x8000000e to address 0xfd1a0104 is:: 46*70f20110SAlex Bennée 47*70f20110SAlex Bennée -device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4 48*70f20110SAlex Bennée 49*70f20110SAlex BennéeSetting a CPU's Program Counter 50*70f20110SAlex Bennée^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51*70f20110SAlex Bennée 52*70f20110SAlex BennéeThe loader device allows the CPU's PC to be set from the command line. This 53*70f20110SAlex Bennéecan be done by following the syntax below:: 54*70f20110SAlex Bennée 55*70f20110SAlex Bennée -device loader,addr=<addr>,cpu-num=<cpu-num> 56*70f20110SAlex Bennée 57*70f20110SAlex Bennée``<addr>`` 58*70f20110SAlex Bennée The value to use as the CPU's PC. 59*70f20110SAlex Bennée 60*70f20110SAlex Bennée``<cpu-num>`` 61*70f20110SAlex Bennée The number of the CPU whose PC should be set to the specified value. 62*70f20110SAlex Bennée 63*70f20110SAlex BennéeAll values are parsed using the standard QemuOpts parsing. This allows the user 64*70f20110SAlex Bennéeto specify any values in any format supported. By default the values 65*70f20110SAlex Bennéewill be parsed as decimal. To use hex values the user should prefix the number 66*70f20110SAlex Bennéewith a '0x'. 67*70f20110SAlex Bennée 68*70f20110SAlex BennéeAn example of setting CPU 0's PC to 0x8000 is:: 69*70f20110SAlex Bennée 70*70f20110SAlex Bennée -device loader,addr=0x8000,cpu-num=0 71*70f20110SAlex Bennée 72*70f20110SAlex BennéeLoading Files 73*70f20110SAlex Bennée^^^^^^^^^^^^^ 74*70f20110SAlex Bennée 75*70f20110SAlex BennéeThe loader device also allows files to be loaded into memory. It can load ELF, 76*70f20110SAlex BennéeU-Boot, and Intel HEX executable formats as well as raw images. The syntax is 77*70f20110SAlex Bennéeshown below: 78*70f20110SAlex Bennée 79*70f20110SAlex Bennée -device loader,file=<file>[,addr=<addr>][,cpu-num=<cpu-num>][,force-raw=<raw>] 80*70f20110SAlex Bennée 81*70f20110SAlex Bennée``<file>`` 82*70f20110SAlex Bennée A file to be loaded into memory 83*70f20110SAlex Bennée 84*70f20110SAlex Bennée``<addr>`` 85*70f20110SAlex Bennée The memory address where the file should be loaded. This is required 86*70f20110SAlex Bennée for raw images and ignored for non-raw files. 87*70f20110SAlex Bennée 88*70f20110SAlex Bennée``<cpu-num>`` 89*70f20110SAlex Bennée This specifies the CPU that should be used. This is an 90*70f20110SAlex Bennée optional argument and will cause the CPU's PC to be set to the 91*70f20110SAlex Bennée memory address where the raw file is loaded or the entry point 92*70f20110SAlex Bennée specified in the executable format header. This option should only 93*70f20110SAlex Bennée be used for the boot image. This will also cause the image to be 94*70f20110SAlex Bennée written to the specified CPU's address space. If not specified, the 95*70f20110SAlex Bennée default is CPU 0. <force-raw> - Setting force-raw=on forces the file 96*70f20110SAlex Bennée to be treated as a raw image. This can be used to load supported 97*70f20110SAlex Bennée executable formats as if they were raw. 98*70f20110SAlex Bennée 99*70f20110SAlex BennéeAll values are parsed using the standard QemuOpts parsing. This allows the user 100*70f20110SAlex Bennéeto specify any values in any format supported. By default the values 101*70f20110SAlex Bennéewill be parsed as decimal. To use hex values the user should prefix the number 102*70f20110SAlex Bennéewith a '0x'. 103*70f20110SAlex Bennée 104*70f20110SAlex BennéeAn example of loading an ELF file which CPU0 will boot is shown below:: 105*70f20110SAlex Bennée 106*70f20110SAlex Bennée -device loader,file=./images/boot.elf,cpu-num=0 107*70f20110SAlex Bennée 108*70f20110SAlex BennéeRestrictions and ToDos 109*70f20110SAlex Bennée^^^^^^^^^^^^^^^^^^^^^^ 110*70f20110SAlex Bennée 111*70f20110SAlex BennéeAt the moment it is just assumed that if you specify a cpu-num then 112*70f20110SAlex Bennéeyou want to set the PC as well. This might not always be the case. In 113*70f20110SAlex Bennéefuture the internal state 'set_pc' (which exists in the generic loader 114*70f20110SAlex Bennéenow) should be exposed to the user so that they can choose if the PC 115*70f20110SAlex Bennéeis set or not. 116*70f20110SAlex Bennée 117*70f20110SAlex Bennée 118