EcLib.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /** @file
  2. EC library functions and definitions.
  3. This library provides basic EC interface.
  4. There may be different libraries for different environments (PEI, BS, RT, SMM).
  5. Make sure you meet the requirements for the library (protocol dependencies, use
  6. restrictions, etc).
  7. Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
  8. SPDX-License-Identifier: BSD-2-Clause-Patent
  9. **/
  10. #ifndef _BASE_EC_LIB_H_
  11. #define _BASE_EC_LIB_H_
  12. //
  13. // Include files
  14. //
  15. #include <Base.h>
  16. #include <Uefi.h>
  17. #include <EcCommands.h>
  18. //
  19. // Function declarations
  20. //
  21. /**
  22. Send a command to the Keyboard System Controller.
  23. @param[in] Command Command byte to send
  24. @retval EFI_SUCCESS Command success
  25. @retval EFI_TIMEOUT Command timeout
  26. @retval Other Command failed
  27. **/
  28. EFI_STATUS
  29. SendEcCommand (
  30. IN UINT8 Command
  31. );
  32. /**
  33. Sends data to Keyboard System Controller.
  34. @param[in] Data Data byte to send
  35. @retval EFI_SUCCESS Success
  36. @retval EFI_TIMEOUT Timeout
  37. @retval Other Failed
  38. **/
  39. EFI_STATUS
  40. SendEcData (
  41. IN UINT8 Data
  42. );
  43. /**
  44. Receives data from Keyboard System Controller.
  45. @param[out] Data Data byte received
  46. @retval EFI_SUCCESS Read success
  47. @retval EFI_TIMEOUT Read timeout
  48. @retval Other Read failed
  49. **/
  50. EFI_STATUS
  51. ReceiveEcData (
  52. OUT UINT8 *Data
  53. );
  54. /**
  55. Receives status from Keyboard System Controller.
  56. @param[out] Status Status byte to receive
  57. @retval EFI_SUCCESS Success
  58. @retval Other Failed
  59. **/
  60. EFI_STATUS
  61. ReceiveEcStatus (
  62. OUT UINT8 *EcStatus
  63. );
  64. /**
  65. Send data to EC through LPC interface.
  66. @param[in] Command Command value to send to the EC
  67. @param[in][out] DataSize Size of data to send to the EC.
  68. If the command retuned data - size of buffer returned by the EC.
  69. Be aware of the DataSize must euqal to size of DataBuffer and cannot smaller
  70. than number of send data or number of receive data, whichever is the grater.
  71. @param[in][out] DataBuffer Pointer to the data buffer including data to be sent to the EC.
  72. If the command returned data - pointer to the buffer including the data.
  73. The buffer size should be the max of receive and transmit data.
  74. @retval EFI_SUCCESS Success
  75. @retval Other Failed - EFI_TIMEOUT, EFI_INVALID_PARAMETER, EFI_UNSUPPORTED,
  76. EFI_BUFFER_TOO_SMALL, etc.
  77. **/
  78. EFI_STATUS
  79. LpcEcInterface (
  80. IN UINT8 Command,
  81. IN OUT UINT8 *DataSize,
  82. IN OUT UINT8 *DataBuffer
  83. );
  84. /**
  85. Read a byte of EC RAM.
  86. @param[in] Address Address to read
  87. @param[out] Data Data received
  88. @retval EFI_SUCCESS Command success
  89. @retval EFI_INVALID_PARAMETER Data is NULL
  90. @retval EFI_DEVICE_ERROR Command error
  91. @retval EFI_TIMEOUT Command timeout
  92. **/
  93. EFI_STATUS
  94. EcRead (
  95. IN UINT8 Address,
  96. OUT UINT8 *Data
  97. );
  98. /**
  99. Write a byte of EC RAM.
  100. @param[in] Address Address to write
  101. @param[in] Data Data to write
  102. @retval EFI_SUCCESS Command success
  103. @retval EFI_DEVICE_ERROR Command error
  104. @retval EFI_TIMEOUT Command timeout
  105. **/
  106. EFI_STATUS
  107. EcWrite (
  108. IN UINT8 Address,
  109. IN UINT8 Data
  110. );
  111. #endif