qemu_bl1_setup.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <platform_def.h>
  8. #include <arch.h>
  9. #include <arch_helpers.h>
  10. #include <common/bl_common.h>
  11. #include "qemu_private.h"
  12. #define MAP_BL1_TOTAL MAP_REGION_FLAT( \
  13. bl1_tzram_layout.total_base, \
  14. bl1_tzram_layout.total_size, \
  15. MT_MEMORY | MT_RW | EL3_PAS)
  16. #define MAP_BL1_RO MAP_REGION_FLAT( \
  17. BL_CODE_BASE, \
  18. BL1_CODE_END - BL_CODE_BASE, \
  19. MT_CODE | EL3_PAS), \
  20. MAP_REGION_FLAT( \
  21. BL1_RO_DATA_BASE, \
  22. BL1_RO_DATA_END \
  23. - BL_RO_DATA_BASE, \
  24. MT_RO_DATA | EL3_PAS)
  25. #if USE_COHERENT_MEM
  26. #define MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
  27. BL_COHERENT_RAM_BASE, \
  28. BL_COHERENT_RAM_END \
  29. - BL_COHERENT_RAM_BASE, \
  30. MT_DEVICE | MT_RW | EL3_PAS)
  31. #endif
  32. /* Data structure which holds the extents of the trusted SRAM for BL1*/
  33. static meminfo_t bl1_tzram_layout;
  34. meminfo_t *bl1_plat_sec_mem_layout(void)
  35. {
  36. return &bl1_tzram_layout;
  37. }
  38. /*******************************************************************************
  39. * Perform any BL1 specific platform actions.
  40. ******************************************************************************/
  41. void bl1_early_platform_setup(void)
  42. {
  43. /* Initialize the console to provide early debug support */
  44. qemu_console_init();
  45. /* Allow BL1 to see the whole Trusted RAM */
  46. bl1_tzram_layout.total_base = BL_RAM_BASE;
  47. bl1_tzram_layout.total_size = BL_RAM_SIZE;
  48. }
  49. /******************************************************************************
  50. * Perform the very early platform specific architecture setup. This only
  51. * does basic initialization. Later architectural setup (bl1_arch_setup())
  52. * does not do anything platform specific.
  53. *****************************************************************************/
  54. #ifdef __aarch64__
  55. #define QEMU_CONFIGURE_BL1_MMU(...) qemu_configure_mmu_el3(__VA_ARGS__)
  56. #else
  57. #define QEMU_CONFIGURE_BL1_MMU(...) qemu_configure_mmu_svc_mon(__VA_ARGS__)
  58. #endif
  59. void bl1_plat_arch_setup(void)
  60. {
  61. const mmap_region_t bl_regions[] = {
  62. MAP_BL1_TOTAL,
  63. MAP_BL1_RO,
  64. #if USE_COHERENT_MEM
  65. MAP_BL_COHERENT_RAM,
  66. #endif
  67. {0}
  68. };
  69. setup_page_tables(bl_regions, plat_qemu_get_mmap());
  70. #ifdef __aarch64__
  71. enable_mmu_el3(0);
  72. #else
  73. enable_mmu_svc_mon(0);
  74. #endif
  75. }
  76. void bl1_platform_setup(void)
  77. {
  78. plat_qemu_io_setup();
  79. }