sp_min_setup.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <string.h>
  8. #include <platform_def.h>
  9. #include <arch_helpers.h>
  10. #include <common/bl_common.h>
  11. #include <common/debug.h>
  12. #include <drivers/arm/gic_common.h>
  13. #include <drivers/arm/gicv2.h>
  14. #include <drivers/console.h>
  15. #include <lib/mmio.h>
  16. #include <lib/xlat_tables/xlat_tables_v2.h>
  17. #include <plat/common/platform.h>
  18. #include "../qemu_private.h"
  19. #if RESET_TO_SP_MIN
  20. #error qemu does not support RESET_TO_SP_MIN
  21. #endif
  22. static entry_point_info_t bl33_image_ep_info;
  23. /******************************************************************************
  24. * On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
  25. * interrupts.
  26. *****************************************************************************/
  27. #define PLATFORM_G1S_PROPS(grp) \
  28. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, \
  29. grp, GIC_INTR_CFG_LEVEL), \
  30. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, \
  31. grp, GIC_INTR_CFG_LEVEL), \
  32. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, \
  33. grp, GIC_INTR_CFG_LEVEL), \
  34. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, \
  35. grp, GIC_INTR_CFG_LEVEL), \
  36. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, \
  37. grp, GIC_INTR_CFG_LEVEL), \
  38. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, \
  39. grp, GIC_INTR_CFG_LEVEL), \
  40. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, \
  41. grp, GIC_INTR_CFG_LEVEL), \
  42. INTR_PROP_DESC(QEMU_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, \
  43. grp, GIC_INTR_CFG_LEVEL)
  44. #define PLATFORM_G0_PROPS(grp)
  45. static const interrupt_prop_t stih410_interrupt_props[] = {
  46. PLATFORM_G1S_PROPS(GICV2_INTR_GROUP0),
  47. PLATFORM_G0_PROPS(GICV2_INTR_GROUP0)
  48. };
  49. static unsigned int target_mask_array[PLATFORM_CORE_COUNT];
  50. static const struct gicv2_driver_data plat_gicv2_driver_data = {
  51. .gicd_base = GICD_BASE,
  52. .gicc_base = GICC_BASE,
  53. .interrupt_props = stih410_interrupt_props,
  54. .interrupt_props_num = ARRAY_SIZE(stih410_interrupt_props),
  55. .target_masks = target_mask_array,
  56. .target_masks_num = ARRAY_SIZE(target_mask_array),
  57. };
  58. /*******************************************************************************
  59. * Return a pointer to the 'entry_point_info' structure of the next image for
  60. * the security state specified. BL33 corresponds to the non-secure image type
  61. * while BL32 corresponds to the secure image type. A NULL pointer is returned
  62. * if the image does not exist.
  63. ******************************************************************************/
  64. entry_point_info_t *sp_min_plat_get_bl33_ep_info(void)
  65. {
  66. entry_point_info_t *next_image_info = &bl33_image_ep_info;
  67. /*
  68. * None of the images on the ARM development platforms can have 0x0
  69. * as the entrypoint
  70. */
  71. if (next_image_info->pc)
  72. return next_image_info;
  73. else
  74. return NULL;
  75. }
  76. void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1,
  77. u_register_t arg2, u_register_t arg3)
  78. {
  79. bl_params_t *params_from_bl2 = (bl_params_t *)arg0;
  80. /* Initialize the console to provide early debug support */
  81. qemu_console_init();
  82. ERROR("qemu sp_min, console init\n");
  83. /*
  84. * Check params passed from BL2
  85. */
  86. assert(params_from_bl2);
  87. assert(params_from_bl2->h.type == PARAM_BL_PARAMS);
  88. assert(params_from_bl2->h.version >= VERSION_2);
  89. bl_params_node_t *bl_params = params_from_bl2->head;
  90. /*
  91. * Copy BL33 entry point information from BL2's address space.
  92. */
  93. while (bl_params) {
  94. if (bl_params->image_id == BL33_IMAGE_ID)
  95. bl33_image_ep_info = *bl_params->ep_info;
  96. bl_params = bl_params->next_params_info;
  97. }
  98. if (!bl33_image_ep_info.pc)
  99. panic();
  100. }
  101. void sp_min_plat_arch_setup(void)
  102. {
  103. qemu_configure_mmu_svc_mon(BL32_RO_BASE, BL32_END - BL32_RO_BASE,
  104. BL_CODE_BASE, BL_CODE_END,
  105. BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_END);
  106. }
  107. void sp_min_platform_setup(void)
  108. {
  109. /* Initialize the gic cpu and distributor interfaces */
  110. gicv2_driver_init(&plat_gicv2_driver_data);
  111. gicv2_distif_init();
  112. gicv2_pcpu_distif_init();
  113. gicv2_cpuif_enable();
  114. }
  115. unsigned int plat_get_syscnt_freq2(void)
  116. {
  117. return SYS_COUNTER_FREQ_IN_TICKS;
  118. }
  119. void sp_min_plat_fiq_handler(uint32_t id)
  120. {
  121. VERBOSE("[sp_min] interrupt #%d\n", id);
  122. }