arm_trp_setup.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/bl_common.h>
  7. #include <common/debug.h>
  8. #include <drivers/arm/pl011.h>
  9. #include <drivers/console.h>
  10. #include <services/rmm_core_manifest.h>
  11. #include <services/rmmd_svc.h>
  12. #include <services/trp/platform_trp.h>
  13. #include <trp_helpers.h>
  14. #include <plat/arm/common/plat_arm.h>
  15. #include <platform_def.h>
  16. /*******************************************************************************
  17. * Received from boot manifest and populated here
  18. ******************************************************************************/
  19. extern uint32_t trp_boot_manifest_version;
  20. /*******************************************************************************
  21. * Initialize the UART
  22. ******************************************************************************/
  23. static console_t arm_trp_runtime_console;
  24. static int arm_trp_process_manifest(struct rmm_manifest *manifest)
  25. {
  26. /* padding field on the manifest must be RES0 */
  27. assert(manifest->padding == 0U);
  28. /* Verify the Boot Manifest Version. Only the Major is considered */
  29. if (RMMD_MANIFEST_VERSION_MAJOR !=
  30. RMMD_GET_MANIFEST_VERSION_MAJOR(manifest->version)) {
  31. return E_RMM_BOOT_MANIFEST_VERSION_NOT_SUPPORTED;
  32. }
  33. trp_boot_manifest_version = manifest->version;
  34. flush_dcache_range((uintptr_t)manifest, sizeof(struct rmm_manifest));
  35. return 0;
  36. }
  37. void arm_trp_early_platform_setup(struct rmm_manifest *manifest)
  38. {
  39. int rc;
  40. rc = arm_trp_process_manifest(manifest);
  41. if (rc != 0) {
  42. trp_boot_abort(rc);
  43. }
  44. /*
  45. * Initialize a different console than already in use to display
  46. * messages from trp
  47. */
  48. rc = console_pl011_register(PLAT_ARM_TRP_UART_BASE,
  49. PLAT_ARM_TRP_UART_CLK_IN_HZ,
  50. ARM_CONSOLE_BAUDRATE,
  51. &arm_trp_runtime_console);
  52. if (rc == 0) {
  53. panic();
  54. }
  55. console_set_scope(&arm_trp_runtime_console,
  56. CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
  57. }
  58. void trp_early_platform_setup(struct rmm_manifest *manifest)
  59. {
  60. arm_trp_early_platform_setup(manifest);
  61. }