console_macros.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef CONSOLE_MACROS_S
  7. #define CONSOLE_MACROS_S
  8. #include <drivers/console.h>
  9. /*
  10. * This macro encapsulates the common setup that has to be done at the end of
  11. * a console driver's register function. It will register all of the driver's
  12. * callbacks in the console_t structure and initialize the flags field (by
  13. * default consoles are enabled for the "boot" and "crash" states, this can be
  14. * changed after registration with the console_set_scope() function). It ends
  15. * with a tail call that will include return to the caller.
  16. * REQUIRES console_t pointer in r0 and a valid return address in lr.
  17. */
  18. .macro finish_console_register _driver, putc=0, getc=0, flush=0
  19. /*
  20. * If any of the callback is not specified or set as 0, then the
  21. * corresponding callback entry in console_t is set to 0.
  22. */
  23. .ifne \putc
  24. ldr r1, =console_\_driver\()_putc
  25. .else
  26. mov r1, #0
  27. .endif
  28. str r1, [r0, #CONSOLE_T_PUTC]
  29. /*
  30. * If ENABLE_CONSOLE_GETC support is disabled, but a getc callback is
  31. * specified nonetheless, the assembler will abort on encountering the
  32. * CONSOLE_T_GETC macro, which is undefined.
  33. */
  34. .ifne \getc
  35. ldr r1, =console_\_driver\()_getc
  36. str r1, [r0, #CONSOLE_T_GETC]
  37. .else
  38. #if ENABLE_CONSOLE_GETC
  39. mov r1, #0
  40. str r1, [r0, #CONSOLE_T_GETC]
  41. #endif
  42. .endif
  43. .ifne \flush
  44. ldr r1, =console_\_driver\()_flush
  45. .else
  46. mov r1, #0
  47. .endif
  48. str r1, [r0, #CONSOLE_T_FLUSH]
  49. mov r1, #(CONSOLE_FLAG_BOOT | CONSOLE_FLAG_CRASH)
  50. str r1, [r0, #CONSOLE_T_FLAGS]
  51. b console_register
  52. .endm
  53. #endif /* CONSOLE_MACROS_S */