DxeEmuStdErrSerialPortLib.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /** @file
  2. Serial Port Lib that thunks back to Emulator services to write to StdErr.
  3. All read functions are stubed out.
  4. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  5. Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #include <PiDxe.h>
  9. #include <Library/SerialPortLib.h>
  10. #include <Library/EmuThunkLib.h>
  11. /**
  12. Initialize the serial device hardware.
  13. If no initialization is required, then return RETURN_SUCCESS.
  14. If the serial device was successfully initialized, then return RETURN_SUCCESS.
  15. If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
  16. @retval RETURN_SUCCESS The serial device was initialized.
  17. @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
  18. **/
  19. RETURN_STATUS
  20. EFIAPI
  21. SerialPortInitialize (
  22. VOID
  23. )
  24. {
  25. return RETURN_SUCCESS;
  26. }
  27. /**
  28. Write data from buffer to serial device.
  29. Writes NumberOfBytes data bytes from Buffer to the serial device.
  30. The number of bytes actually written to the serial device is returned.
  31. If the return value is less than NumberOfBytes, then the write operation failed.
  32. If Buffer is NULL, then ASSERT().
  33. If NumberOfBytes is zero, then return 0.
  34. @param Buffer The pointer to the data buffer to be written.
  35. @param NumberOfBytes The number of bytes to written to the serial device.
  36. @retval 0 NumberOfBytes is 0.
  37. @retval >0 The number of bytes written to the serial device.
  38. If this value is less than NumberOfBytes, then the read operation failed.
  39. **/
  40. UINTN
  41. EFIAPI
  42. SerialPortWrite (
  43. IN UINT8 *Buffer,
  44. IN UINTN NumberOfBytes
  45. )
  46. {
  47. if (gEmuThunk == NULL) {
  48. return NumberOfBytes;
  49. }
  50. return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
  51. }
  52. /**
  53. Read data from serial device and save the datas in buffer.
  54. Reads NumberOfBytes data bytes from a serial device into the buffer
  55. specified by Buffer. The number of bytes actually read is returned.
  56. If the return value is less than NumberOfBytes, then the rest operation failed.
  57. If Buffer is NULL, then ASSERT().
  58. If NumberOfBytes is zero, then return 0.
  59. @param Buffer The pointer to the data buffer to store the data read from the serial device.
  60. @param NumberOfBytes The number of bytes which will be read.
  61. @retval 0 Read data failed; No data is to be read.
  62. @retval >0 The actual number of bytes read from serial device.
  63. **/
  64. UINTN
  65. EFIAPI
  66. SerialPortRead (
  67. OUT UINT8 *Buffer,
  68. IN UINTN NumberOfBytes
  69. )
  70. {
  71. return 0;
  72. }
  73. /**
  74. Polls a serial device to see if there is any data waiting to be read.
  75. Polls a serial device to see if there is any data waiting to be read.
  76. If there is data waiting to be read from the serial device, then TRUE is returned.
  77. If there is no data waiting to be read from the serial device, then FALSE is returned.
  78. @retval TRUE Data is waiting to be read from the serial device.
  79. @retval FALSE There is no data waiting to be read from the serial device.
  80. **/
  81. BOOLEAN
  82. EFIAPI
  83. SerialPortPoll (
  84. VOID
  85. )
  86. {
  87. return FALSE;
  88. }