generic-loader.rst 3.9 KB

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