/** @file\r
-Implementation of SmBusLib class library for PEI phase.\r
+Implementation of SmBusLib class library for DXE 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
+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
-Module Name: SmbusLib.c\r
\r
**/\r
\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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
**/\r
VOID\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
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);\r
}\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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
**/\r
-BOOLEAN\r
+VOID\r
EFIAPI\r
SmBusQuickWrite (\r
IN UINTN SmBusAddress,\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
+ ASSERT (SMBUS_LIB_RESERVED (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
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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The byte received from the SMBUS.\r
\r
\r
ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);\r
\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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The parameter of Value.\r
\r
\r
ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
Byte = Value;\r
InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);\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
+ @param Status Return status for the executed command.\r
+ This is an optional parameter and may be NULL.\r
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The byte read from the SMBUS.\r
\r
UINT8 Byte;\r
\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);\r
- \r
+\r
return Byte;\r
}\r
\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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The parameter of Value.\r
\r
UINT8 Byte;\r
\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
Byte = Value;\r
InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);\r
- \r
+\r
return Value;\r
}\r
\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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The byte read from the SMBUS.\r
\r
UINT16 Word;\r
\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);\r
- \r
+\r
return Word;\r
}\r
\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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The parameter of Value.\r
\r
UINT16 Word;\r
\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
Word = Value;\r
InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, 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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The 16-bit value returned by the process call command.\r
\r
)\r
{\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);\r
- \r
+\r
return Value;\r
}\r
\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
+ 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
+ @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
+ RETURN_SUCCESS The SMBUS command was executed.\r
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The number of bytes read.\r
\r
{\r
ASSERT (Buffer != NULL);\r
ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
- return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x1f, Buffer, Status);\r
+ return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);\r
}\r
\r
/**\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
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
+ MBUS 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
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The number of bytes written.\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
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
+ ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0);\r
\r
- return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, SMBUS_LIB_LENGTH (SmBusAddress), Buffer, Status);\r
+ Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
+ return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
}\r
\r
/**\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 OutBuffer. Bytes are then read from the SMBUS into InBuffer.\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 InBuffer is large enough for the total number of bytes read.\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 OutBuffer is NULL, then ASSERT().\r
- If InBuffer is NULL, then ASSERT().\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
-\r
- @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
- SMBUS Command, SMBUS Data Length, and PEC.\r
- @param OutBuffer Pointer to the buffer of bytes to write to the SMBUS.\r
- @param InBuffer 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
+ @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
+ RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+ RETURN_DEVICE_ERROR The request was not completed because a failure\r
+ reflected in the Host Status Register bit. Device errors are a result\r
+ of a transaction collision, illegal command field, unclaimed cycle\r
+ (host initiated), or bus errors (collisions).\r
+ RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r
+ RETURN_UNSUPPORTED The SMBus operation is not supported.\r
\r
@return The number of bytes written.\r
\r
EFIAPI\r
SmBusBlockProcessCall (\r
IN UINTN SmBusAddress,\r
- OUT VOID *OutBuffer,\r
- OUT VOID *InBuffer,\r
+ IN VOID *WriteBuffer,\r
+ OUT VOID *ReadBuffer,\r
OUT RETURN_STATUS *Status OPTIONAL\r
)\r
{\r
- ASSERT (InBuffer != NULL);\r
- ASSERT (OutBuffer != NULL);\r
- ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\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_RESERVED (SmBusAddress) == 0);\r
\r
+ Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
//\r
- // BugBug: Not sure whether it's all right.\r
+ // Assuming that ReadBuffer is large enough to save another memory copy.\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
+ ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);\r
+ return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);\r
}\r