arm.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Misc ARM declarations
  3. *
  4. * Copyright (c) 2006 CodeSourcery.
  5. * Written by Paul Brook
  6. *
  7. * This code is licensed under the LGPL.
  8. *
  9. */
  10. #ifndef HW_ARM_H
  11. #define HW_ARM_H
  12. #include "exec/memory.h"
  13. #include "target-arm/cpu-qom.h"
  14. #include "hw/irq.h"
  15. #include "qemu/notify.h"
  16. typedef enum {
  17. ARM_ENDIANNESS_UNKNOWN = 0,
  18. ARM_ENDIANNESS_LE,
  19. ARM_ENDIANNESS_BE8,
  20. ARM_ENDIANNESS_BE32,
  21. } arm_endianness;
  22. /* armv7m.c */
  23. DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
  24. const char *kernel_filename, const char *cpu_model);
  25. /*
  26. * struct used as a parameter of the arm_load_kernel machine init
  27. * done notifier
  28. */
  29. typedef struct {
  30. Notifier notifier; /* actual notifier */
  31. ARMCPU *cpu; /* handle to the first cpu object */
  32. } ArmLoadKernelNotifier;
  33. /* arm_boot.c */
  34. struct arm_boot_info {
  35. uint64_t ram_size;
  36. const char *kernel_filename;
  37. const char *kernel_cmdline;
  38. const char *initrd_filename;
  39. const char *dtb_filename;
  40. hwaddr loader_start;
  41. /* multicore boards that use the default secondary core boot functions
  42. * need to put the address of the secondary boot code, the boot reg,
  43. * and the GIC address in the next 3 values, respectively. boards that
  44. * have their own boot functions can use these values as they want.
  45. */
  46. hwaddr smp_loader_start;
  47. hwaddr smp_bootreg_addr;
  48. hwaddr gic_cpu_if_addr;
  49. int nb_cpus;
  50. int board_id;
  51. /* ARM machines that support the ARM Security Extensions use this field to
  52. * control whether Linux is booted as secure(true) or non-secure(false).
  53. */
  54. bool secure_boot;
  55. int (*atag_board)(const struct arm_boot_info *info, void *p);
  56. /* multicore boards that use the default secondary core boot functions
  57. * can ignore these two function calls. If the default functions won't
  58. * work, then write_secondary_boot() should write a suitable blob of
  59. * code mimicking the secondary CPU startup process used by the board's
  60. * boot loader/boot ROM code, and secondary_cpu_reset_hook() should
  61. * perform any necessary CPU reset handling and set the PC for the
  62. * secondary CPUs to point at this boot blob.
  63. */
  64. void (*write_secondary_boot)(ARMCPU *cpu,
  65. const struct arm_boot_info *info);
  66. void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
  67. const struct arm_boot_info *info);
  68. /* if a board is able to create a dtb without a dtb file then it
  69. * sets get_dtb. This will only be used if no dtb file is provided
  70. * by the user. On success, sets *size to the length of the created
  71. * dtb, and returns a pointer to it. (The caller must free this memory
  72. * with g_free() when it has finished with it.) On failure, returns NULL.
  73. */
  74. void *(*get_dtb)(const struct arm_boot_info *info, int *size);
  75. /* if a board needs to be able to modify a device tree provided by
  76. * the user it should implement this hook.
  77. */
  78. void (*modify_dtb)(const struct arm_boot_info *info, void *fdt);
  79. /* machine init done notifier executing arm_load_dtb */
  80. ArmLoadKernelNotifier load_kernel_notifier;
  81. /* Used internally by arm_boot.c */
  82. int is_linux;
  83. hwaddr initrd_start;
  84. hwaddr initrd_size;
  85. hwaddr entry;
  86. /* Boot firmware has been loaded, typically at address 0, with -bios or
  87. * -pflash. It also implies that fw_cfg_find() will succeed.
  88. */
  89. bool firmware_loaded;
  90. /* Address at which board specific loader/setup code exists. If enabled,
  91. * this code-blob will run before anything else. It must return to the
  92. * caller via the link register. There is no stack set up. Enabled by
  93. * defining write_board_setup, which is responsible for loading the blob
  94. * to the specified address.
  95. */
  96. hwaddr board_setup_addr;
  97. void (*write_board_setup)(ARMCPU *cpu,
  98. const struct arm_boot_info *info);
  99. /* If set, the board specific loader/setup blob will be run from secure
  100. * mode, regardless of secure_boot. The blob becomes responsible for
  101. * changing to non-secure state if implementing a non-secure boot
  102. */
  103. bool secure_board_setup;
  104. arm_endianness endianness;
  105. };
  106. /**
  107. * arm_load_kernel - Loads memory with everything needed to boot
  108. *
  109. * @cpu: handle to the first CPU object
  110. * @info: handle to the boot info struct
  111. * Registers a machine init done notifier that copies to memory
  112. * everything needed to boot, depending on machine and user options:
  113. * kernel image, boot loaders, initrd, dtb. Also registers the CPU
  114. * reset handler.
  115. *
  116. * In case the machine file supports the platform bus device and its
  117. * dynamically instantiable sysbus devices, this function must be called
  118. * before sysbus-fdt arm_register_platform_bus_fdt_creator. Indeed the
  119. * machine init done notifiers are called in registration reverse order.
  120. */
  121. void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info);
  122. /* Write a secure board setup routine with a dummy handler for SMCs */
  123. void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
  124. const struct arm_boot_info *info,
  125. hwaddr mvbar_addr);
  126. /* Multiplication factor to convert from system clock ticks to qemu timer
  127. ticks. */
  128. extern int system_clock_scale;
  129. #endif /* HW_ARM_H */