]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add Framework version of PeiSmbusLib instance: depending on Smbus PPI.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Jul 2007 02:16:31 +0000 (02:16 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Jul 2007 02:16:31 +0000 (02:16 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3087 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkPkg/IntelFrameworkPkg.dsc
IntelFrameworkPkg/Library/PeiSmbusLibSmbus/InternalSmbusLib.h [new file with mode: 0644]
IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.c [new file with mode: 0644]
IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.inf [new file with mode: 0644]
IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.msa [new file with mode: 0644]
IntelFrameworkPkg/Library/PeiSmbusLibSmbus/SmbusLib.c [new file with mode: 0644]

index 91431348d66c3be1285e1e36d6ff9cf0b60fb183..e7d475fc8bf512713a01ddd1e292572bbd6aad11 100644 (file)
@@ -67,4 +67,5 @@
   ${WORKSPACE}/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DxeSmmDriverEntryPoint.inf\r
   ${WORKSPACE}/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf\r
   ${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
   ${WORKSPACE}/IntelFrameworkPkg/Library/DxeSmmDriverEntryPoint/DxeSmmDriverEntryPoint.inf\r
   ${WORKSPACE}/IntelFrameworkPkg/Library/HiiLibFramework/HiiLib.inf\r
   ${WORKSPACE}/IntelFrameworkPkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf\r
-  ${WORKSPACE}/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf
\ No newline at end of file
+  ${WORKSPACE}/IntelFrameworkPkg/Library/IfrSupportLibFramework/IfrSupportLib.inf\r
+  ${WORKSPACE}/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.inf\r
diff --git a/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/InternalSmbusLib.h b/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/InternalSmbusLib.h
new file mode 100644 (file)
index 0000000..794c6ee
--- /dev/null
@@ -0,0 +1,91 @@
+/** @file\r
+Internal header file for Smbus library.\r
+\r
+Copyright (c) 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+**/\r
+\r
+#ifndef __INTERNAL_SMBUS_LIB_H\r
+#define __INTERNAL_SMBUS_LIB_H\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+#include <FrameworkPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/Smbus.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/SmbusLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress)      (((SmBusAddress) >> 1)  & 0x7f)\r
+#define SMBUS_LIB_COMMAND(SmBusAddress)            (((SmBusAddress) >> 8)  & 0xff)\r
+#define SMBUS_LIB_LENGTH(SmBusAddress)             (((SmBusAddress) >> 16) & 0x3f)\r
+#define SMBUS_LIB_PEC(SmBusAddress)     ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))\r
+#define SMBUS_LIB_RESEARVED(SmBusAddress)          ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))\r
+\r
+//\r
+// Declaration for internal functions\r
+//\r
+\r
+/**\r
+  Gets Smbus PPIs.\r
+\r
+  This internal function retrieves Smbus PPI from PPI database.\r
+\r
+  @param  PeiServices   An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.\r
+\r
+  @return The pointer to Smbus PPI.\r
+\r
+**/\r
+EFI_PEI_SMBUS_PPI *\r
+InternalGetSmbusPpi (\r
+  EFI_PEI_SERVICES      **PeiServices\r
+  );\r
+\r
+/**\r
+  Executes an SMBus operation to an SMBus controller. \r
+\r
+  This function provides a standard way to execute Smbus script\r
+  as defined in the SmBus Specification. The data can either be of\r
+  the Length byte, word, or a block of data.\r
+\r
+  @param  SmbusOperation  Signifies which particular SMBus hardware protocol instance that it will use to\r
+                          execute the SMBus transactions.\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Length          Signifies the number of bytes that this operation will do. The maximum number of\r
+                          bytes can be revision specific and operation specific.\r
+  @param  Buffer          Contains the value of data to execute to the SMBus slave device. Not all operations\r
+                          require this argument. The length of this buffer is identified by Length.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The actual number of bytes that are executed for this operation.\r
+\r
+**/\r
+UINTN\r
+InternalSmBusExec (\r
+  IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
+  IN     UINTN                      SmBusAddress,\r
+  IN     UINTN                      Length,\r
+  IN OUT VOID                       *Buffer,\r
+     OUT RETURN_STATUS              *Status        OPTIONAL\r
+  );\r
+\r
+#endif\r
diff --git a/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.c b/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.c
new file mode 100644 (file)
index 0000000..db28021
--- /dev/null
@@ -0,0 +1,99 @@
+/** @file\r
+Implementation of SmBusLib class library for PEI phase.\r
+\r
+Copyright (c) 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name: PeiSmbusLib.c\r
+\r
+**/\r
+\r
+#include "InternalSmbusLib.h"\r
+\r
+/**\r
+  Gets Smbus PPIs.\r
+\r
+  This internal function retrieves Smbus PPI from PPI database.\r
+\r
+  @param  PeiServices   An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.\r
+\r
+  @return The pointer to Smbus PPI.\r
+\r
+**/\r
+EFI_PEI_SMBUS_PPI *\r
+InternalGetSmbusPpi (\r
+  EFI_PEI_SERVICES      **PeiServices\r
+  ) \r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_SMBUS_PPI     *SmbusPpi;\r
+\r
+  Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPeiSmbusPpiGuid, 0, NULL, (VOID **) &SmbusPpi);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (SmbusPpi != NULL);\r
+\r
+  return SmbusPpi;\r
+}\r
+\r
+/**\r
+  Executes an SMBus operation to an SMBus controller. \r
+\r
+  This function provides a standard way to execute Smbus script\r
+  as defined in the SmBus Specification. The data can either be of\r
+  the Length byte, word, or a block of data.\r
+\r
+  @param  SmbusOperation  Signifies which particular SMBus hardware protocol instance that it will use to\r
+                          execute the SMBus transactions.\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Length          Signifies the number of bytes that this operation will do. The maximum number of\r
+                          bytes can be revision specific and operation specific.\r
+  @param  Buffer          Contains the value of data to execute to the SMBus slave device. Not all operations\r
+                          require this argument. The length of this buffer is identified by Length.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The actual number of bytes that are executed for this operation..\r
+\r
+**/\r
+UINTN\r
+InternalSmBusExec (\r
+  IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
+  IN     UINTN                      SmBusAddress,\r
+  IN     UINTN                      Length,\r
+  IN OUT VOID                       *Buffer,\r
+     OUT RETURN_STATUS              *Status        OPTIONAL\r
+  )\r
+{\r
+  EFI_PEI_SMBUS_PPI         *SmbusPpi;\r
+  EFI_PEI_SERVICES          **PeiServices;\r
+  RETURN_STATUS             ReturnStatus;\r
+  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;\r
+\r
+  PeiServices = GetPeiServicesTablePointer ();\r
+  SmbusPpi    = InternalGetSmbusPpi (PeiServices);\r
+  SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
+\r
+  ReturnStatus = SmbusPpi->Execute (\r
+                             PeiServices,\r
+                             SmbusPpi,\r
+                             SmbusDeviceAddress,\r
+                             SMBUS_LIB_COMMAND (SmBusAddress),\r
+                             SmbusOperation,\r
+                             SMBUS_LIB_PEC (SmBusAddress),  \r
+                             &Length,\r
+                             Buffer\r
+                             );\r
+  if (Status != NULL) {\r
+    *Status = ReturnStatus;\r
+  }\r
+\r
+  return Length;\r
+}\r
diff --git a/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.inf b/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.inf
new file mode 100644 (file)
index 0000000..1fd119d
--- /dev/null
@@ -0,0 +1,85 @@
+#/** @file\r
+# Component description file for Pei Smbus Library.\r
+#\r
+# SMBUS library that layers on top of the SMBUS PPI.\r
+# Copyright (c) 2006 - 2007, Intel Corporation\r
+#\r
+#  All rights reserved. This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiSmbusLib\r
+  FILE_GUID                      = 51C4C059-67F0-4e3c-9A55-FF42A8291C8C\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SmbusLib|PEIM \r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  SmbusLib.c\r
+  PeiSmbusLib.c\r
+  InternalSmbusLib.h\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  PeiServicesTablePointerLib\r
+  DebugLib\r
+\r
+\r
+################################################################################\r
+#\r
+# PPI C Name Section - list of PPI and PPI Notify C Names that this module\r
+#                      uses or produces.\r
+#\r
+################################################################################\r
+\r
+[Ppis]\r
+  gEfiPeiSmbusPpiGuid                           # PPI ALWAYS_CONSUMED\r
+\r
diff --git a/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.msa b/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/PeiSmbusLib.msa
new file mode 100644 (file)
index 0000000..517ada2
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>PeiSmbusLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>51C4C059-67F0-4e3c-9A55-FF42A8291C8C</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>Component description file for Pei Smbus Library.</Abstract>\r
+    <Description>SMBUS library that layers on top of the SMBUS PPI.</Description>\r
+    <Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials\r
+      are licensed and made available under the terms and conditions of the BSD License\r
+      which accompanies this distribution.  The full text of the license may be found at\r
+      http://opensource.org/licenses/bsd-license.php\r
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>PeiSmbusLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM">\r
+      <Keyword>SmbusLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>DebugLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeiServicesTablePointerLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>BaseMemoryLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>InternalSmbusLib.h</Filename>\r
+    <Filename>PeiSmbusLib.c</Filename>\r
+    <Filename>SmbusLib.c</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="1E73767F-8F52-4603-AEB4-F29B510B6766"/>\r
+    <Package PackageGuid="2759ded5-bb57-4b06-af4f-c398fa552719"/>\r
+  </PackageDependencies>\r
+  <PPIs>\r
+    <Ppi Usage="ALWAYS_CONSUMED">\r
+      <PpiCName>gEfiPeiSmbusPpiGuid</PpiCName>\r
+    </Ppi>\r
+  </PPIs>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>\r
diff --git a/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/SmbusLib.c b/IntelFrameworkPkg/Library/PeiSmbusLibSmbus/SmbusLib.c
new file mode 100644 (file)
index 0000000..93fadb6
--- /dev/null
@@ -0,0 +1,470 @@
+/** @file\r
+Implementation of SmBusLib class library for PEI phase.\r
+\r
+Copyright (c) 2006, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+\r
+Module Name: SmbusLib.c\r
+\r
+**/\r
+\r
+#include "InternalSmbusLib.h"\r
+\r
+/**\r
+  Executes an SMBUS quick read command.\r
+\r
+  Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickRead (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+{\r
+  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS quick write command.\r
+\r
+  Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SmBusQuickWrite (\r
+  IN  UINTN                     SmBusAddress,\r
+  OUT RETURN_STATUS             *Status       OPTIONAL\r
+  )\r
+{\r
+  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS receive byte command.\r
+\r
+  Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  The byte received from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte received from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReceiveByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)  == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);\r
+\r
+  return Byte;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS send byte command.\r
+\r
+  Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
+  The byte specified by Value is sent.\r
+  Only the SMBUS slave address field of SmBusAddress is required.  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to send.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusSendByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Byte   = Value;\r
+  InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read data byte command.\r
+\r
+  Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 8-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusReadDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);\r
+  \r
+  return Byte;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write data byte command.\r
+\r
+  Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
+  The 8-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 8-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+SmBusWriteDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT8   Byte;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Byte = Value;\r
+  InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read data word command.\r
+\r
+  Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+  \r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The byte read from the SMBUS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusReadDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT16  Word;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);\r
+  \r
+  return Word;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write data word command.\r
+\r
+  Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The parameter of Value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusWriteDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINT16  Word;\r
+\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Word = Value;\r
+  InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS process call command.\r
+\r
+  Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value returned by the process call command is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Value           The 16-bit value to write.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The 16-bit value returned by the process call command.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+SmBusProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Executes an SMBUS read block command.\r
+\r
+  Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Bytes are read from the SMBUS and stored in Buffer.\r
+  The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes read.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusReadBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS write block command.\r
+\r
+  Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from Buffer.\r
+  The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.  \r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  Buffer          Pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusWriteBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINTN  Length;\r
+\r
+  ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
+}\r
+\r
+/**\r
+  Executes an SMBUS block process call command.\r
+\r
+  Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from WriteBuffer.  Bytes are then read from the SMBUS into ReadBuffer.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If WriteBuffer is NULL, then ASSERT().\r
+  If ReadBuffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
+                          SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param  WriteBuffer     Pointer to the buffer of bytes to write to the SMBUS.\r
+  @param  ReadBuffer      Pointer to the buffer of bytes to read from the SMBUS.\r
+  @param  Status          Return status for the executed command.\r
+                          This is an optional parameter and may be NULL.\r
+\r
+  @return The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SmBusBlockProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  VOID           *WriteBuffer,\r
+  OUT VOID           *ReadBuffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  )\r
+{\r
+  UINTN   Length;\r
+\r
+  ASSERT (WriteBuffer != NULL);\r
+  ASSERT (ReadBuffer  != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+  //\r
+  // Assuming that ReadBuffer is large enough to save another memory copy.\r
+  //\r
+  ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);\r
+  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);\r
+}\r