arm_console.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2018-2022, 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 <common/debug.h>
  9. #include <drivers/arm/pl011.h>
  10. #include <drivers/console.h>
  11. #include <plat/arm/common/plat_arm.h>
  12. #pragma weak arm_console_runtime_init
  13. #pragma weak arm_console_runtime_end
  14. /*******************************************************************************
  15. * Functions that set up the console
  16. ******************************************************************************/
  17. static console_t arm_boot_console;
  18. static console_t arm_runtime_console;
  19. /* Initialize the console to provide early debug support */
  20. void __init arm_console_boot_init(void)
  21. {
  22. /* If the console was initialized already, don't initialize again */
  23. if (arm_boot_console.base == PLAT_ARM_BOOT_UART_BASE) {
  24. return;
  25. }
  26. int rc = console_pl011_register(PLAT_ARM_BOOT_UART_BASE,
  27. PLAT_ARM_BOOT_UART_CLK_IN_HZ,
  28. ARM_CONSOLE_BAUDRATE,
  29. &arm_boot_console);
  30. if (rc == 0) {
  31. /*
  32. * The crash console doesn't use the multi console API, it uses
  33. * the core console functions directly. It is safe to call panic
  34. * and let it print debug information.
  35. */
  36. panic();
  37. }
  38. console_set_scope(&arm_boot_console, CONSOLE_FLAG_BOOT);
  39. }
  40. void arm_console_boot_end(void)
  41. {
  42. console_flush();
  43. (void)console_unregister(&arm_boot_console);
  44. }
  45. /* Initialize the runtime console */
  46. void arm_console_runtime_init(void)
  47. {
  48. int rc = console_pl011_register(PLAT_ARM_RUN_UART_BASE,
  49. PLAT_ARM_RUN_UART_CLK_IN_HZ,
  50. ARM_CONSOLE_BAUDRATE,
  51. &arm_runtime_console);
  52. if (rc == 0)
  53. panic();
  54. console_set_scope(&arm_runtime_console, CONSOLE_FLAG_RUNTIME);
  55. }
  56. void arm_console_runtime_end(void)
  57. {
  58. console_flush();
  59. }