debug.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. This module implements debug UART support for UEFI platforms.
  7. Author:
  8. Evan Green 26-Feb-2014
  9. Environment:
  10. Firmware
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include "uefifw.h"
  16. #include "dev/omapuart.h"
  17. #include <minoca/soc/omap4.h>
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. //
  25. // Define the hard-coded debug serial port.
  26. //
  27. #define EFI_PANDA_BOARD_DEBUG_SERIAL_BASE (VOID *)OMAP4430_UART3_BASE
  28. //
  29. // ------------------------------------------------------ Data Type Definitions
  30. //
  31. //
  32. // ----------------------------------------------- Internal Function Prototypes
  33. //
  34. //
  35. // -------------------------------------------------------------------- Globals
  36. //
  37. //
  38. // Define the context for the debug UART.
  39. //
  40. OMAP_UART_CONTEXT EfiPandaBoardDebugUart;
  41. //
  42. // ------------------------------------------------------------------ Functions
  43. //
  44. EFI_STATUS
  45. EfiPlatformDebugDeviceReset (
  46. UINT32 BaudRate
  47. )
  48. /*++
  49. Routine Description:
  50. This routine attempts to initialize the serial UART used for debugging.
  51. Arguments:
  52. BaudRate - Supplies the desired baud rate.
  53. Return Value:
  54. EFI_SUCCESS on success.
  55. EFI_DEVICE_ERROR if a device error occurred while resetting the device.
  56. EFI_UNSUPPORTED if the given baud rate cannot be achieved.
  57. --*/
  58. {
  59. EFI_STATUS Status;
  60. Status = EfipUartOmapComputeDivisor(
  61. BaudRate,
  62. &(EfiPandaBoardDebugUart.BaudRateRegister));
  63. if (EFI_ERROR(Status)) {
  64. return Status;
  65. }
  66. EfiPandaBoardDebugUart.UartBase = EFI_PANDA_BOARD_DEBUG_SERIAL_BASE;
  67. return EfipUartOmapInitialize(&EfiPandaBoardDebugUart);
  68. }
  69. EFI_STATUS
  70. EfiPlatformDebugDeviceTransmit (
  71. VOID *Data,
  72. UINTN Size
  73. )
  74. /*++
  75. Routine Description:
  76. This routine transmits data from the host out through the debug device.
  77. Arguments:
  78. Data - Supplies a pointer to the data to write.
  79. Size - Supplies the size to write, in bytes.
  80. Return Value:
  81. EFI_SUCCESS on success.
  82. EFI_DEVICE_ERROR if a device error occurred.
  83. --*/
  84. {
  85. return EfipUartOmapTransmit(&EfiPandaBoardDebugUart, Data, Size);
  86. }
  87. EFI_STATUS
  88. EfiPlatformDebugDeviceReceive (
  89. VOID *Data,
  90. UINTN *Size
  91. )
  92. /*++
  93. Routine Description:
  94. This routine receives incoming data from the debug device.
  95. Arguments:
  96. Data - Supplies a pointer where the read data will be returned on success.
  97. Size - Supplies a pointer that on input contains the size of the receive
  98. buffer. On output, returns the number of bytes read.
  99. Return Value:
  100. EFI_SUCCESS on success.
  101. EFI_NOT_READY if there was no data to be read at the current time.
  102. EFI_DEVICE_ERROR if a device error occurred.
  103. --*/
  104. {
  105. return EfipUartOmapReceive(&EfiPandaBoardDebugUart, Data, Size);
  106. }
  107. EFI_STATUS
  108. EfiPlatformDebugDeviceGetStatus (
  109. BOOLEAN *ReceiveDataAvailable
  110. )
  111. /*++
  112. Routine Description:
  113. This routine returns the current device status.
  114. Arguments:
  115. ReceiveDataAvailable - Supplies a pointer where a boolean will be returned
  116. indicating whether or not receive data is available.
  117. Return Value:
  118. EFI_SUCCESS on success.
  119. EFI_DEVICE_ERROR if a device error occurred.
  120. --*/
  121. {
  122. return EfipUartOmapGetStatus(&EfiPandaBoardDebugUart, ReceiveDataAvailable);
  123. }
  124. VOID
  125. EfiPlatformDebugDeviceDisconnect (
  126. VOID
  127. )
  128. /*++
  129. Routine Description:
  130. This routine disconnects a device, taking it offline.
  131. Arguments:
  132. None.
  133. Return Value:
  134. None.
  135. --*/
  136. {
  137. return;
  138. }
  139. //
  140. // --------------------------------------------------------- Internal Functions
  141. //