]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PeiSmbusLib & DxeSmbusLib
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Apr 2006 05:51:23 +0000 (05:51 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Apr 2006 05:51:23 +0000 (05:51 +0000)
Remove Arp Related interfaces
Change the return type of SmbusQuickWrite from “BOOLEAN” to “VOID”
Complete interface SmBusBlockProcessCall()
Make the PEC bit “bit 21” of SMBUS address. If data show that MSB helps to save code size in BaseSmbusLib, we may simply redefine it to be MAX_BIT.
UefiLib
Modify the interfaces in UefiNotTiano.c to sync with spec
MemoryAllocationLib
Add extra checking in “Aligned” Memory services to prevent “AllocationSize + OverAllocation” overflow in DxeMemoryAllocationLib.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@23 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/SmbusLib.h
MdePkg/Include/Library/UefiLib.h
MdePkg/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
MdePkg/Library/DxeSmbusLib/DxeSmbusLib.c
MdePkg/Library/DxeSmbusLib/InternalSmbusLib.h
MdePkg/Library/DxeSmbusLib/SmbusLib.c
MdePkg/Library/PeiSmbusLib/InternalSmbusLib.h
MdePkg/Library/PeiSmbusLib/PeiSmbusLib.c
MdePkg/Library/PeiSmbusLib/SmbusLib.c
MdePkg/Library/UefiLib/UefiNotTiano.c

index 55aae1211ed677995ed33f77aeb63bad98f0c0e4..484ab90144caf9f3378c55cb56895af0a3140b9f 100644 (file)
 #ifndef __SMBUS_LIB__\r
 #define __SMBUS_LIB__\r
 \r
 #ifndef __SMBUS_LIB__\r
 #define __SMBUS_LIB__\r
 \r
+//\r
+// PEC BIT is bit 21 in SMBUS address\r
+//\r
+#define SMBUS_LIB_PEC_BIT   (1 << 21)\r
+\r
 /**\r
   Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r
   and PEC to a value that can be passed to the SMBUS Library functions.\r
 /**\r
   Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r
   and PEC to a value that can be passed to the SMBUS Library functions.\r
   \r
   @param  SlaveAddress    SMBUS Slave Address.  Range 0..127.\r
   @param  Command         SMBUS Command.  Range 0..255.\r
   \r
   @param  SlaveAddress    SMBUS Slave Address.  Range 0..127.\r
   @param  Command         SMBUS Command.  Range 0..255.\r
-  @param  Length          SMBUS Data Length.  Range 0..32.\r
+  @param  Length          SMBUS Data Length.  Range 0..31.\r
   @param  Pec             TRUE if Packet Error Checking is enabled.  Otherwise FALSE.\r
 \r
 **/\r
 #define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec)  \\r
   @param  Pec             TRUE if Packet Error Checking is enabled.  Otherwise FALSE.\r
 \r
 **/\r
 #define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec)  \\r
-  ( ((Pec) ? MAX_BIT : 0)          | \\r
-    (((SlaveAddress) & 0x7f) << 1) | \\r
-    (((Command) & 0xff) << 8)      | \\r
-    (((Length) & 0x1f) << 16)        \\r
+  ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0)      | \\r
+    (((SlaveAddress) & 0x7f) << 1)      | \\r
+    (((Command)      & 0xff) << 8)      | \\r
+    (((Length)       & 0x1f) << 16)       \\r
   )\r
 \r
 /**\r
   )\r
 \r
 /**\r
@@ -80,7 +85,7 @@ SmBusQuickRead (
                           This is an optional parameter and may be NULL.\r
 \r
 **/\r
                           This is an optional parameter and may be NULL.\r
 \r
 **/\r
-BOOLEAN\r
+VOID\r
 EFIAPI\r
 SmBusQuickWrite (\r
   IN  UINTN                     SmBusAddress,\r
 EFIAPI\r
 SmBusQuickWrite (\r
   IN  UINTN                     SmBusAddress,\r
@@ -373,102 +378,10 @@ UINTN
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
-  OUT VOID           *OutBuffer,\r
+  IN  VOID           *OutBuffer,\r
   OUT VOID           *InBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 ;\r
 \r
   OUT VOID           *InBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 ;\r
 \r
-/**\r
-  Enumerates the SMBUS and assigns slave addresses.\r
-\r
-  Executes the SMBUS enumeration algorithm and assigns a valid address to all SMBUS slave devices.\r
-  The total number of SMBUS slave devices detected is returned.\r
-  The status of the executed command is returned.\r
-  If Slave Address in SmBusAddress is not zero, then ASSERT().\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusArpAll (\r
-  IN UINTN  SmBusAddress\r
-  )\r
-;\r
-\r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusArpDevice (\r
-  IN UINTN       SmBusAddress,\r
-  IN CONST GUID  *Uuid\r
-  )\r
-;\r
-\r
-/**\r
-  Retrieves the UUID associated with an SMBUS slave device.\r
-\r
-  Retrieves the UUID associated with the slave address specified\r
-  by SmBusAddress and returns the UUID in Uuid.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, then ASSERT().\r
-  If Uuid 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  Uuid                Pointer to the UUID retrieved from the SMBUS slave device.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusGetUuid (\r
-  IN  UINTN  SmBusAddress,\r
-  OUT GUID   *Uuid\r
-  )\r
-;\r
-\r
 #endif\r
 #endif\r
index 73b761f790660df617fe0b49d9feb574343bbec4..fd3bdac53e5af7b01fd3ef923272b4b9d9e04557 100644 (file)
@@ -412,7 +412,7 @@ EfiSignalEventLegacyBoot (
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventLegacyBoot (\r
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventLegacyBoot (\r
-  OUT  EFI_EVENT   *LegacyBootEvent\r
+  OUT EFI_EVENT  *LegacyBootEvent\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -434,7 +434,7 @@ EfiCreateEventLegacyBoot (
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventReadyToBoot (\r
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventReadyToBoot (\r
-  OUT  EFI_EVENT   *ReadyToBootEvent\r
+  OUT EFI_EVENT  *ReadyToBootEvent\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -454,8 +454,8 @@ EfiCreateEventReadyToBoot (
 VOID\r
 EFIAPI\r
 EfiInitializeFwVolDevicepathNode (\r
 VOID\r
 EFIAPI\r
 EfiInitializeFwVolDevicepathNode (\r
-  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode,\r
-  IN EFI_GUID                               *NameGuid\r
+  IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode,\r
+  IN CONST EFI_GUID                         *NameGuid\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -479,7 +479,7 @@ EfiInitializeFwVolDevicepathNode (
 EFI_GUID *\r
 EFIAPI\r
 EfiGetNameGuidFromFwVolDevicePathNode (\r
 EFI_GUID *\r
 EFIAPI\r
 EfiGetNameGuidFromFwVolDevicePathNode (\r
-  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode\r
+  IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode\r
   );\r
 \r
 \r
   );\r
 \r
 \r
index a9bdf60aa1e0e1f2351e31e1684182533823c39a..ef643eed4296d2252506098a5bc5b18922425dc6 100644 (file)
@@ -168,6 +168,13 @@ InternalAllocateAlignedPages (
     //\r
     AlignmentMask  = Alignment - 1;\r
     RealPages      = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
     //\r
     AlignmentMask  = Alignment - 1;\r
     RealPages      = Pages + EFI_SIZE_TO_PAGES (Alignment);\r
+    if (RealPages <= Pages) {\r
+      //\r
+      // This extra checking is to make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow. \r
+      //\r
+      return NULL;\r
+    }\r
+\r
     Status         = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);\r
     if (EFI_ERROR (Status)) {\r
       return NULL;\r
     Status         = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);\r
     if (EFI_ERROR (Status)) {\r
       return NULL;\r
@@ -576,8 +583,8 @@ InternalAllocateAlignedPool (
   UINTN       AlignedAddress;\r
   UINTN       AlignmentMask;\r
   UINTN       OverAllocationSize;\r
   UINTN       AlignedAddress;\r
   UINTN       AlignmentMask;\r
   UINTN       OverAllocationSize;\r
+  UINTN       RealAllocationSize;\r
   VOID        **FreePointer;\r
   VOID        **FreePointer;\r
-  EFI_STATUS  Status;\r
 \r
   //\r
   // Alignment must be a power of two or zero.\r
 \r
   //\r
   // Alignment must be a power of two or zero.\r
@@ -593,8 +600,15 @@ InternalAllocateAlignedPool (
   // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address. \r
   //\r
   OverAllocationSize  = sizeof (RawAddress) + AlignmentMask;\r
   // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address. \r
   //\r
   OverAllocationSize  = sizeof (RawAddress) + AlignmentMask;\r
-  Status = gBS->AllocatePool (PoolType, AllocationSize + OverAllocationSize, &RawAddress);\r
-  if (EFI_ERROR (Status)) {\r
+  RealAllocationSize  = AllocationSize + OverAllocationSize;\r
+  if (RealAllocationSize <= AllocationSize ) {\r
+    //\r
+    // This extra checking is to make sure that AllocationSize plus OverAllocationSize does not overflow. \r
+    //\r
+    return NULL;\r
+  }\r
+  RawAddress = InternalAllocatePool (PoolType, RealAllocationSize);\r
+  if (RawAddress == NULL) {\r
     return NULL;\r
   }\r
   AlignedAddress      = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;\r
     return NULL;\r
   }\r
   AlignedAddress      = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;\r
index 4c888370ebcc18bcccf9daa6cad477dd5a4ebc7b..2991350e24b0ee159b63393b1ec7c6ab1d347b04 100644 (file)
@@ -43,11 +43,7 @@ SmbusLibConstructor (
 {\r
   EFI_STATUS  Status;\r
   \r
 {\r
   EFI_STATUS  Status;\r
   \r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiCpuIoProtocolGuid,\r
-                  NULL,\r
-                  (VOID**) &mSmbus\r
-                  );\r
+  Status = gBS->LocateProtocol (&gEfiSmbusProtocolGuid, NULL, (VOID**) &mSmbus);\r
   ASSERT_EFI_ERROR (Status);\r
   ASSERT (mSmbus != NULL);\r
 \r
   ASSERT_EFI_ERROR (Status);\r
   ASSERT (mSmbus != NULL);\r
 \r
@@ -80,7 +76,7 @@ InternalSmBusExec (
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
-  IN     VOID                       *Buffer,\r
+  IN OUT VOID                       *Buffer,\r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   )\r
 {\r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   )\r
 {\r
@@ -104,65 +100,3 @@ InternalSmBusExec (
 \r
   return Length;\r
 }\r
 \r
   return Length;\r
 }\r
-\r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-\r
-  @param  SmBusAddress        Address that encodes the SMBUS Slave Address,\r
-                              SMBUS Command, SMBUS Data Length, and PEC.\r
-  @param  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-                              It will assign to all SMBUS slave devices if it is NULL.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalSmBusArpDevice (\r
-  IN UINTN          SmBusAddress,\r
-  IN CONST GUID     *Uuid       OPTIONAL \r
-  )\r
-{\r
-  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;\r
-\r
-  SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
-  return (RETURN_STATUS) mSmbus->ArpDevice (\r
-                                   mSmbus,\r
-                                   (BOOLEAN) (Uuid == NULL),\r
-                                   (EFI_SMBUS_UDID *) Uuid,\r
-                                   &SmbusDeviceAddress\r
-                                   );\r
-}\r
-\r
-/**\r
-  Retrieves the mapping of all the SMBus devices.\r
-\r
-  The GetArpMap() function returns the mapping of all the SMBus devices \r
-  that are enumerated by the SMBus host driver. \r
\r
-  @param  Length              Size of the buffer that contains the SMBus device map.\r
-  @param  SmbusDeviceMap      The pointer to the device map as enumerated by the SMBus controller driver.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalGetArpMap (\r
-  OUT UINTN                         *Length,\r
-  OUT EFI_SMBUS_DEVICE_MAP          **SmbusDeviceMap\r
-  )\r
-{\r
-  return (RETURN_STATUS) mSmbus->GetArpMap (mSmbus, Length, SmbusDeviceMap);\r
-}\r
index 3c0b597fc5f64caf9e828da6b25b4e159d0f0ccd..bd6d57f2d307d422ea03fdafe526b9b397348eda 100644 (file)
@@ -18,11 +18,11 @@ Module Name: SmbusLib.c
 #ifndef __INTERNAL_SMBUS_LIB_H\r
 #define __INTERNAL_SMBUS_LIB_H\r
 \r
 #ifndef __INTERNAL_SMBUS_LIB_H\r
 #define __INTERNAL_SMBUS_LIB_H\r
 \r
-#define SMBUS_LIB_PEC(SmBusAddress)           ((BOOLEAN) ((SmBusAddress) & 0x01))\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)    & 0x1f)\r
-#define SMBUS_LIB_RESEARVED(SmBusAddress)     (((SmBusAddress) >> 21))\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) & 0x1f)\r
+#define SMBUS_LIB_PEC(SmBusAddress)     ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))\r
+#define SMBUS_LIB_RESEARVED(SmBusAddress)          ((SmBusAddress) & ~(((1 << 21) - 2) | SMBUS_LIB_PEC_BIT))\r
 \r
 //\r
 // Declaration for internal functions\r
 \r
 //\r
 // Declaration for internal functions\r
@@ -45,7 +45,7 @@ Module Name: SmbusLib.c
   @param  Status          Return status for the executed command.\r
                           This is an optional parameter and may be NULL.\r
 \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
+  @return The actual number of bytes that are executed for this operation.\r
 \r
 **/\r
 UINTN\r
 \r
 **/\r
 UINTN\r
@@ -53,60 +53,8 @@ InternalSmBusExec (
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
-  IN     VOID                       *Buffer,\r
+  IN OUT VOID                       *Buffer,\r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   );\r
 \r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   );\r
 \r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-                              It will assign to all SMBUS slave devices if it is NULL.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalSmBusArpDevice (\r
-  IN UINTN          SmBusAddress,\r
-  IN CONST GUID     *Uuid       OPTIONAL \r
-  );\r
-\r
-/**\r
-  Retrieves the mapping of all the SMBus devices.\r
-\r
-  The GetArpMap() function returns the mapping of all the SMBus devices \r
-  that are enumerated by the SMBus host driver. \r
\r
-  @param  Length              Size of the buffer that contains the SMBus device map.\r
-  @param  SmbusDeviceMap      The pointer to the device map as enumerated by the SMBus controller driver.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalGetArpMap (\r
-  OUT UINTN                         *Length,\r
-  OUT EFI_SMBUS_DEVICE_MAP          **SmbusDeviceMap\r
-  );\r
-\r
 #endif\r
 #endif\r
index da29fab5a3d1585cee842cc4b35bc99e99a58267..e71f11bef81b7c535b1222197eebc9952f5cf037 100644 (file)
@@ -66,7 +66,7 @@ SmBusQuickRead (
                           This is an optional parameter and may be NULL.\r
 \r
 **/\r
                           This is an optional parameter and may be NULL.\r
 \r
 **/\r
-BOOLEAN\r
+VOID\r
 EFIAPI\r
 SmBusQuickWrite (\r
   IN  UINTN                     SmBusAddress,\r
 EFIAPI\r
 SmBusQuickWrite (\r
   IN  UINTN                     SmBusAddress,\r
@@ -79,10 +79,6 @@ SmBusQuickWrite (
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
-  //\r
-  // Bugbug: Undefined return value in spec\r
-  //\r
-  return TRUE;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -381,7 +377,7 @@ SmBusReadBlock (
   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
-  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x1f, Buffer, Status);\r
+  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -413,10 +409,13 @@ SmBusWriteBlock (
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
+  UINTN  Length;\r
+\r
   ASSERT (Buffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   ASSERT (Buffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
-  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, SMBUS_LIB_LENGTH (SmBusAddress), Buffer, Status);\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress) + 1;\r
+  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -447,151 +446,21 @@ UINTN
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
-  OUT VOID           *OutBuffer,\r
+  IN  VOID           *OutBuffer,\r
   OUT VOID           *InBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
   OUT VOID           *InBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
+  UINTN   Length;\r
+\r
   ASSERT (InBuffer  != NULL);\r
   ASSERT (OutBuffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   ASSERT (InBuffer  != NULL);\r
   ASSERT (OutBuffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
+  Length   = SMBUS_LIB_LENGTH (SmBusAddress) + 1;\r
   //\r
   //\r
-  // BugBug: Not sure whether it's all right.\r
+  // Assuming that InBuffer is large enough to save another memory copy.\r
   //\r
   //\r
-  InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, SMBUS_LIB_LENGTH (SmBusAddress), OutBuffer, Status);\r
-\r
-  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 1, InBuffer, Status);\r
-}\r
-\r
-/**\r
-  Enumerates the SMBUS and assigns slave addresses.\r
-\r
-  Executes the SMBUS enumeration algorithm and assigns a valid address to all SMBUS slave devices.\r
-  The total number of SMBUS slave devices detected is returned.\r
-  The status of the executed command is returned.\r
-  If Slave Address in SmBusAddress is not zero, then ASSERT().\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusArpAll (\r
-  IN UINTN  SmBusAddress\r
-  )\r
-{\r
-  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
-  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)       == 0);\r
-  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress)     == 0);\r
-  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)        == 0);\r
-  ASSERT (SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress) == 0);\r
-\r
-  return InternalSmBusArpDevice (SmBusAddress, NULL);\r
-}\r
-\r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusArpDevice (\r
-  IN UINTN       SmBusAddress,\r
-  IN CONST GUID  *Uuid\r
-  )\r
-{\r
-  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
-  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
-  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
-  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
-\r
-  return InternalSmBusArpDevice (SmBusAddress, Uuid);\r
-}\r
-\r
-/**\r
-  Retrieves the UUID associated with an SMBUS slave device.\r
-\r
-  Retrieves the UUID associated with the slave address specified\r
-  by SmBusAddress and returns the UUID in Uuid.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, then ASSERT().\r
-  If Uuid 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  Uuid                Pointer to the UUID retrieved from the SMBUS slave device.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusGetUuid (\r
-  IN  UINTN  SmBusAddress,\r
-  OUT GUID   *Uuid\r
-  )\r
-{\r
-  UINTN                     Length;\r
-  EFI_SMBUS_DEVICE_MAP      *SmBusDeviceMap;\r
-  RETURN_STATUS             ReturnStatus;\r
-  UINTN                     SmbusDeviceAddress;\r
-  UINTN                     Index;\r
-\r
-  ASSERT (Uuid != NULL);\r
-  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
-  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
-  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
-  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
-\r
-  ReturnStatus = InternalGetArpMap (&Length, &SmBusDeviceMap);\r
-  if (!RETURN_ERROR (ReturnStatus)) {\r
-    SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
-    for (Index = 0; Index < Length; Index++) {\r
-      if (SmBusDeviceMap[Index].SmbusDeviceAddress.SmbusDeviceAddress == SmbusDeviceAddress) {\r
-        CopyMem (Uuid, &SmBusDeviceMap[Index].SmbusDeviceUdid, sizeof (EFI_SMBUS_UDID));\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  return ReturnStatus;\r
+  InBuffer = CopyMem (InBuffer, OutBuffer, Length);\r
+  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, InBuffer, Status);\r
 }\r
 }\r
index 3c0b597fc5f64caf9e828da6b25b4e159d0f0ccd..bd6d57f2d307d422ea03fdafe526b9b397348eda 100644 (file)
@@ -18,11 +18,11 @@ Module Name: SmbusLib.c
 #ifndef __INTERNAL_SMBUS_LIB_H\r
 #define __INTERNAL_SMBUS_LIB_H\r
 \r
 #ifndef __INTERNAL_SMBUS_LIB_H\r
 #define __INTERNAL_SMBUS_LIB_H\r
 \r
-#define SMBUS_LIB_PEC(SmBusAddress)           ((BOOLEAN) ((SmBusAddress) & 0x01))\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)    & 0x1f)\r
-#define SMBUS_LIB_RESEARVED(SmBusAddress)     (((SmBusAddress) >> 21))\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) & 0x1f)\r
+#define SMBUS_LIB_PEC(SmBusAddress)     ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))\r
+#define SMBUS_LIB_RESEARVED(SmBusAddress)          ((SmBusAddress) & ~(((1 << 21) - 2) | SMBUS_LIB_PEC_BIT))\r
 \r
 //\r
 // Declaration for internal functions\r
 \r
 //\r
 // Declaration for internal functions\r
@@ -45,7 +45,7 @@ Module Name: SmbusLib.c
   @param  Status          Return status for the executed command.\r
                           This is an optional parameter and may be NULL.\r
 \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
+  @return The actual number of bytes that are executed for this operation.\r
 \r
 **/\r
 UINTN\r
 \r
 **/\r
 UINTN\r
@@ -53,60 +53,8 @@ InternalSmBusExec (
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
-  IN     VOID                       *Buffer,\r
+  IN OUT VOID                       *Buffer,\r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   );\r
 \r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   );\r
 \r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-                              It will assign to all SMBUS slave devices if it is NULL.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalSmBusArpDevice (\r
-  IN UINTN          SmBusAddress,\r
-  IN CONST GUID     *Uuid       OPTIONAL \r
-  );\r
-\r
-/**\r
-  Retrieves the mapping of all the SMBus devices.\r
-\r
-  The GetArpMap() function returns the mapping of all the SMBus devices \r
-  that are enumerated by the SMBus host driver. \r
\r
-  @param  Length              Size of the buffer that contains the SMBus device map.\r
-  @param  SmbusDeviceMap      The pointer to the device map as enumerated by the SMBus controller driver.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalGetArpMap (\r
-  OUT UINTN                         *Length,\r
-  OUT EFI_SMBUS_DEVICE_MAP          **SmbusDeviceMap\r
-  );\r
-\r
 #endif\r
 #endif\r
index 3ada624f682993f457f2a35ca15ca87716165ba3..db28021d58c228d053cf81baa02372799bcc000e 100644 (file)
@@ -68,7 +68,7 @@ InternalSmBusExec (
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
   IN     EFI_SMBUS_OPERATION        SmbusOperation,\r
   IN     UINTN                      SmBusAddress,\r
   IN     UINTN                      Length,\r
-  IN     VOID                       *Buffer,\r
+  IN OUT VOID                       *Buffer,\r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   )\r
 {\r
      OUT RETURN_STATUS              *Status        OPTIONAL\r
   )\r
 {\r
@@ -97,81 +97,3 @@ InternalSmBusExec (
 \r
   return Length;\r
 }\r
 \r
   return Length;\r
 }\r
-\r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-                              It will assign to all SMBUS slave devices if it is NULL.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalSmBusArpDevice (\r
-  IN UINTN          SmBusAddress,\r
-  IN CONST GUID     *Uuid       OPTIONAL \r
-  )\r
-{\r
-  EFI_PEI_SMBUS_PPI         *SmbusPpi;\r
-  EFI_PEI_SERVICES          **PeiServices;\r
-  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;\r
-\r
-  PeiServices = GetPeiServicesTablePointer ();\r
-  SmbusPpi    = InternalGetSmbusPpi (PeiServices);\r
-\r
-  SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
-  return (RETURN_STATUS) SmbusPpi->ArpDevice (\r
-                                     PeiServices,\r
-                                     SmbusPpi,\r
-                                     (BOOLEAN) (Uuid == NULL),\r
-                                     (EFI_SMBUS_UDID *) Uuid,\r
-                                     &SmbusDeviceAddress\r
-                                     );\r
-}\r
-\r
-/**\r
-  Retrieves the mapping of all the SMBus devices.\r
-\r
-  The GetArpMap() function returns the mapping of all the SMBus devices \r
-  that are enumerated by the SMBus host driver. \r
\r
-  @param  Length              Size of the buffer that contains the SMBus device map.\r
-  @param  SmbusDeviceMap      The pointer to the device map as enumerated by the SMBus controller driver.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-InternalGetArpMap (\r
-  OUT UINTN                         *Length,\r
-  OUT EFI_SMBUS_DEVICE_MAP          **SmbusDeviceMap\r
-  )\r
-{\r
-  EFI_PEI_SMBUS_PPI         *SmbusPpi;\r
-  EFI_PEI_SERVICES          **PeiServices;\r
-\r
-  PeiServices  = GetPeiServicesTablePointer ();\r
-  SmbusPpi     = InternalGetSmbusPpi (PeiServices);\r
-  \r
-  return (RETURN_STATUS) SmbusPpi->GetArpMap (PeiServices, SmbusPpi, Length, SmbusDeviceMap);\r
-}\r
index da29fab5a3d1585cee842cc4b35bc99e99a58267..e71f11bef81b7c535b1222197eebc9952f5cf037 100644 (file)
@@ -66,7 +66,7 @@ SmBusQuickRead (
                           This is an optional parameter and may be NULL.\r
 \r
 **/\r
                           This is an optional parameter and may be NULL.\r
 \r
 **/\r
-BOOLEAN\r
+VOID\r
 EFIAPI\r
 SmBusQuickWrite (\r
   IN  UINTN                     SmBusAddress,\r
 EFIAPI\r
 SmBusQuickWrite (\r
   IN  UINTN                     SmBusAddress,\r
@@ -79,10 +79,6 @@ SmBusQuickWrite (
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);\r
-  //\r
-  // Bugbug: Undefined return value in spec\r
-  //\r
-  return TRUE;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -381,7 +377,7 @@ SmBusReadBlock (
   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
-  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x1f, Buffer, Status);\r
+  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -413,10 +409,13 @@ SmBusWriteBlock (
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
+  UINTN  Length;\r
+\r
   ASSERT (Buffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   ASSERT (Buffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
-  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, SMBUS_LIB_LENGTH (SmBusAddress), Buffer, Status);\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress) + 1;\r
+  return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -447,151 +446,21 @@ UINTN
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
-  OUT VOID           *OutBuffer,\r
+  IN  VOID           *OutBuffer,\r
   OUT VOID           *InBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
   OUT VOID           *InBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
+  UINTN   Length;\r
+\r
   ASSERT (InBuffer  != NULL);\r
   ASSERT (OutBuffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   ASSERT (InBuffer  != NULL);\r
   ASSERT (OutBuffer != NULL);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
+  Length   = SMBUS_LIB_LENGTH (SmBusAddress) + 1;\r
   //\r
   //\r
-  // BugBug: Not sure whether it's all right.\r
+  // Assuming that InBuffer is large enough to save another memory copy.\r
   //\r
   //\r
-  InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, SMBUS_LIB_LENGTH (SmBusAddress), OutBuffer, Status);\r
-\r
-  return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 1, InBuffer, Status);\r
-}\r
-\r
-/**\r
-  Enumerates the SMBUS and assigns slave addresses.\r
-\r
-  Executes the SMBUS enumeration algorithm and assigns a valid address to all SMBUS slave devices.\r
-  The total number of SMBUS slave devices detected is returned.\r
-  The status of the executed command is returned.\r
-  If Slave Address in SmBusAddress is not zero, then ASSERT().\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusArpAll (\r
-  IN UINTN  SmBusAddress\r
-  )\r
-{\r
-  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
-  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)       == 0);\r
-  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress)     == 0);\r
-  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)        == 0);\r
-  ASSERT (SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress) == 0);\r
-\r
-  return InternalSmBusArpDevice (SmBusAddress, NULL);\r
-}\r
-\r
-/**\r
-  Assigns an SMBUS slave addresses.\r
-\r
-  Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, 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  Uuid                Pointer to the UUID of the device to assign a slave address.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusArpDevice (\r
-  IN UINTN       SmBusAddress,\r
-  IN CONST GUID  *Uuid\r
-  )\r
-{\r
-  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
-  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
-  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
-  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
-\r
-  return InternalSmBusArpDevice (SmBusAddress, Uuid);\r
-}\r
-\r
-/**\r
-  Retrieves the UUID associated with an SMBUS slave device.\r
-\r
-  Retrieves the UUID associated with the slave address specified\r
-  by SmBusAddress and returns the UUID in Uuid.\r
-  The status of the executed command is returned.\r
-  If Command in SmBusAddress is not zero, then ASSERT().\r
-  If Length in SmBusAddress is not zero, then ASSERT().\r
-  If PEC in SmBusAddress is set, then ASSERT().\r
-  If Uuid 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  Uuid                Pointer to the UUID retrieved from the SMBUS slave device.\r
-\r
-  @retval RETURN_SUCCESS      The SMBUS command was executed.\r
-  @retval RETURN_TIMEOUT      A timeout occurred while executing the SMBUS command.\r
-  @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected\r
-                              in the Host Status Register bit.\r
-                              Device errors are a result of a transaction collision, illegal command field,\r
-                              unclaimed cycle (host initiated), or bus errors (collisions).\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-SmBusGetUuid (\r
-  IN  UINTN  SmBusAddress,\r
-  OUT GUID   *Uuid\r
-  )\r
-{\r
-  UINTN                     Length;\r
-  EFI_SMBUS_DEVICE_MAP      *SmBusDeviceMap;\r
-  RETURN_STATUS             ReturnStatus;\r
-  UINTN                     SmbusDeviceAddress;\r
-  UINTN                     Index;\r
-\r
-  ASSERT (Uuid != NULL);\r
-  ASSERT (!SMBUS_LIB_PEC (SmBusAddress));\r
-  ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);\r
-  ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
-  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);\r
-\r
-  ReturnStatus = InternalGetArpMap (&Length, &SmBusDeviceMap);\r
-  if (!RETURN_ERROR (ReturnStatus)) {\r
-    SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
-    for (Index = 0; Index < Length; Index++) {\r
-      if (SmBusDeviceMap[Index].SmbusDeviceAddress.SmbusDeviceAddress == SmbusDeviceAddress) {\r
-        CopyMem (Uuid, &SmBusDeviceMap[Index].SmbusDeviceUdid, sizeof (EFI_SMBUS_UDID));\r
-        break;\r
-      }\r
-    }\r
-  }\r
-\r
-  return ReturnStatus;\r
+  InBuffer = CopyMem (InBuffer, OutBuffer, Length);\r
+  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, InBuffer, Status);\r
 }\r
 }\r
index 2ac12f1b3a7734e47f7c7fd48ad7b94ffdd62887..f883c1d3c6247233ac44ff55647978f2ceb4795b 100644 (file)
@@ -37,7 +37,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventLegacyBoot (\r
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventLegacyBoot (\r
-  OUT  EFI_EVENT   *LegacyBootEvent\r
+  OUT EFI_EVENT  *LegacyBootEvent\r
   )\r
 {\r
   EFI_STATUS    Status;\r
   )\r
 {\r
   EFI_STATUS    Status;\r
@@ -92,7 +92,7 @@ EfiCreateEventLegacyBoot (
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventReadyToBoot (\r
 EFI_STATUS\r
 EFIAPI\r
 EfiCreateEventReadyToBoot (\r
-  IN  EFI_EVENT   *ReadyToBootEvent\r
+  OUT EFI_EVENT  *ReadyToBootEvent\r
   )\r
 {\r
   EFI_STATUS    Status;\r
   )\r
 {\r
   EFI_STATUS    Status;\r
@@ -196,7 +196,7 @@ EfiSignalEventLegacyBoot (
 EFI_GUID *\r
 EFIAPI\r
 EfiGetNameGuidFromFwVolDevicePathNode (\r
 EFI_GUID *\r
 EFIAPI\r
 EfiGetNameGuidFromFwVolDevicePathNode (\r
-  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH   *FvDevicePathNode\r
+  IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode\r
   )\r
 {\r
   ASSERT (FvDevicePathNode != NULL);\r
   )\r
 {\r
   ASSERT (FvDevicePathNode != NULL);\r
@@ -207,7 +207,7 @@ EfiGetNameGuidFromFwVolDevicePathNode (
   //\r
   if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH ||\r
       DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
   //\r
   if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH ||\r
       DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
-    return &FvDevicePathNode->NameGuid;\r
+    return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
   }\r
 \r
 #else\r
   }\r
 \r
 #else\r
@@ -218,7 +218,7 @@ EfiGetNameGuidFromFwVolDevicePathNode (
       FvDevicePathNode->Piwg.Header.SubType == MEDIA_VENDOR_DP) {\r
     if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r
       if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
       FvDevicePathNode->Piwg.Header.SubType == MEDIA_VENDOR_DP) {\r
     if (CompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {\r
       if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {\r
-        return &FvDevicePathNode->NameGuid;\r
+        return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
       }\r
     }\r
   }\r
       }\r
     }\r
   }\r
@@ -237,15 +237,15 @@ EfiGetNameGuidFromFwVolDevicePathNode (
   is compiled to conform with the UEFI 2.0 specification use the new device path\r
   else use the old form for backwards compatability.\r
 \r
   is compiled to conform with the UEFI 2.0 specification use the new device path\r
   else use the old form for backwards compatability.\r
 \r
-  @param FvDevicePathNode   Pointer to a FV device path node to initialize\r
-  @param NameGuid           FV file name to use in FvDevicePathNode\r
+  @param  FvDevicePathNode  Pointer to a FV device path node to initialize\r
+  @param  NameGuid          FV file name to use in FvDevicePathNode\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 EfiInitializeFwVolDevicepathNode (\r
 \r
 **/\r
 VOID\r
 EFIAPI\r
 EfiInitializeFwVolDevicepathNode (\r
-  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode,\r
-  IN EFI_GUID                               *NameGuid\r
+  IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  *FvDevicePathNode,\r
+  IN CONST EFI_GUID                         *NameGuid\r
   )\r
 {\r
   ASSERT (FvDevicePathNode  != NULL);\r
   )\r
 {\r
   ASSERT (FvDevicePathNode  != NULL);\r