[edk2-devel] [edk2-platforms][PATCH v3 1/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/BoardEcLib: Check for NULL
Benjamin Doron
benjamin.doron00 at gmail.com
Fri Sep 3 05:32:40 UTC 2021
Check that Data pointer is not NULL. Also update some notes on this
library.
The documented return values are updated.
Cc: Chasel Chiu <chasel.chiu at intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Signed-off-by: Benjamin Doron <benjamin.doron00 at gmail.com>
---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library/BoardEcLib.h | 11 +++----
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEcLib/EcCommands.c | 31 +++++++++++++-------
2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library/BoardEcLib.h b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library/BoardEcLib.h
index 2e7e0573900a..6b8d92ce056b 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library/BoardEcLib.h
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Include/Library/BoardEcLib.h
@@ -12,12 +12,13 @@
/**
Reads a byte of EC RAM.
- @param[in] Address Address to read
- @param[out] Data Data received
+ @param[in] Address Address to read
+ @param[out] Data Data received
- @retval EFI_SUCCESS Command success
- @retval EFI_DEVICE_ERROR Command error
- @retval EFI_TIMEOUT Command timeout
+ @retval EFI_SUCCESS Command success
+ @retval EFI_INVALID_PARAMETER Data is NULL
+ @retval EFI_DEVICE_ERROR Command error
+ @retval EFI_TIMEOUT Command timeout
**/
EFI_STATUS
EcCmd90Read (
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEcLib/EcCommands.c b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEcLib/EcCommands.c
index 09b2b5ee9180..b779717f410e 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEcLib/EcCommands.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardEcLib/EcCommands.c
@@ -12,18 +12,22 @@
#include <Library/EcLib.h>
#include <Library/IoLib.h>
-/* TODO - Implement:
+/* Notes:
+ * - ACPI "CMDB": Writing to this offset is equivalent to sending commands.
+ * The CMDx bytes contain the command parameters.
+ *
+ * TODO - Implement:
* - Commands: 0x58, 0xE1 and 0xE2
* - 0x51, 0x52: EC flash write?
* - ACPI CMDB: 0x63 and 0x64, 0xC7
* - 0x0B: Flash write (Boolean argument? Set in offset 0x0B?)
*
- * NB: Consider that if a vendor's UEFI driver consumes
- * unimplemented PPI/protocol, the driver is dead code.
+ * Reversing vendor's protocols:
+ * - Only read and write are used.
+ * - Query, ACPI "CMDB" processing and command 58 are unused.
+ * - Equivalent KbcPeim is an unused PPI.
*
- * NOTE: Check protocol use.
- * - Commands delivered across vendor's modules
- * - EC writes also control behaviour
+ * NB: Also look for potential EC library
*/
#define EC_INDEX_IO_PORT 0x1200
@@ -34,12 +38,13 @@
/**
Reads a byte of EC RAM.
- @param[in] Address Address to read
- @param[out] Data Data received
+ @param[in] Address Address to read
+ @param[out] Data Data received
- @retval EFI_SUCCESS Command success
- @retval EFI_DEVICE_ERROR Command error
- @retval EFI_TIMEOUT Command timeout
+ @retval EFI_SUCCESS Command success
+ @retval EFI_INVALID_PARAMETER Data is NULL
+ @retval EFI_DEVICE_ERROR Command error
+ @retval EFI_TIMEOUT Command timeout
**/
EFI_STATUS
EcCmd90Read (
@@ -49,6 +54,10 @@ EcCmd90Read (
{
EFI_STATUS Status;
+ if (Data == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
Status = SendEcCommand (0x90);
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a(): SendEcCommand(0x90) failed!\n", __FUNCTION__));
--
2.31.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80200): https://edk2.groups.io/g/devel/message/80200
Mute This Topic: https://groups.io/mt/85345650/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list