diff --git a/MdePkg/Include/Library/SmbusLib.h b/MdePkg/Include/Library/SmbusLib.h index c59f0bb4cf..17b81b6f19 100644 --- a/MdePkg/Include/Library/SmbusLib.h +++ b/MdePkg/Include/Library/SmbusLib.h @@ -15,11 +15,6 @@ #ifndef __SMBUS_LIB__ #define __SMBUS_LIB__ -/// -/// PEC BIT is bit 22 in SMBUS address -/// -#define SMBUS_LIB_PEC_BIT (1 << 22) - /** Macro that converts SMBUS slave address, SMBUS command, SMBUS data length, and PEC to a value that can be passed to the SMBUS Library functions. @@ -41,6 +36,41 @@ (((Length) & 0x3f) << 16) \ ) +/** + Macro that returns the SMBUS Slave Address value from an SmBusAddress Parameter value. + + @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC +**/ +#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) + +/** + Macro that returns the SMBUS Command value from an SmBusAddress Parameter value. + + @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC +**/ +#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) + +/** + Macro that returns the SMBUS Data Length value from an SmBusAddress Parameter value. + + @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC +**/ +#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) + +/** + Macro that returns the SMBUS PEC value from an SmBusAddress Parameter value. + + @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC +**/ +#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & BIT22) != 0)) + +/** + Macro that returns the set of reserved bits from an SmBusAddress Parameter value. + + @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC +**/ +#define SMBUS_LIB_RESERVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | BIT22)) + /** Executes an SMBUS quick read command. diff --git a/MdePkg/Library/DxeSmbusLib/InternalSmbusLib.h b/MdePkg/Library/DxeSmbusLib/InternalSmbusLib.h index 8268cd821f..7a179ec83d 100644 --- a/MdePkg/Library/DxeSmbusLib/InternalSmbusLib.h +++ b/MdePkg/Library/DxeSmbusLib/InternalSmbusLib.h @@ -28,12 +28,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include -#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) -#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) -#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) -#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0)) -#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT)) - // // Declaration for internal functions // diff --git a/MdePkg/Library/DxeSmbusLib/SmbusLib.c b/MdePkg/Library/DxeSmbusLib/SmbusLib.c index 323f4926d6..e47d20d7c8 100644 --- a/MdePkg/Library/DxeSmbusLib/SmbusLib.c +++ b/MdePkg/Library/DxeSmbusLib/SmbusLib.c @@ -42,7 +42,7 @@ SmBusQuickRead ( ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status); } @@ -74,7 +74,7 @@ SmBusQuickWrite ( ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status); } @@ -109,7 +109,7 @@ SmBusReceiveByte ( ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status); @@ -148,7 +148,7 @@ SmBusSendByte ( ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Byte = Value; InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status); @@ -184,7 +184,7 @@ SmBusReadDataByte ( UINT8 Byte; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status); @@ -222,7 +222,7 @@ SmBusWriteDataByte ( UINT8 Byte; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Byte = Value; InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status); @@ -258,7 +258,7 @@ SmBusReadDataWord ( UINT16 Word; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status); @@ -296,7 +296,7 @@ SmBusWriteDataWord ( UINT16 Word; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Word = Value; InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status); @@ -333,7 +333,7 @@ SmBusProcessCall ( ) { ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status); @@ -373,7 +373,7 @@ SmBusReadBlock ( { ASSERT (Buffer != NULL); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status); } @@ -412,7 +412,7 @@ SmBusWriteBlock ( ASSERT (Buffer != NULL); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Length = SMBUS_LIB_LENGTH (SmBusAddress); return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status); @@ -457,7 +457,7 @@ SmBusBlockProcessCall ( ASSERT (ReadBuffer != NULL); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Length = SMBUS_LIB_LENGTH (SmBusAddress); // diff --git a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/InternalSmbusLib.h b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/InternalSmbusLib.h index cd472c1b83..b5d0a76262 100644 --- a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/InternalSmbusLib.h +++ b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/InternalSmbusLib.h @@ -27,12 +27,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f) -#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff) -#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f) -#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0)) -#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT)) - // // Declaration for internal functions // diff --git a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/SmbusLib.c b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/SmbusLib.c index 323f4926d6..e47d20d7c8 100644 --- a/MdePkg/Library/PeiSmbusLibSmbus2Ppi/SmbusLib.c +++ b/MdePkg/Library/PeiSmbusLibSmbus2Ppi/SmbusLib.c @@ -42,7 +42,7 @@ SmBusQuickRead ( ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status); } @@ -74,7 +74,7 @@ SmBusQuickWrite ( ASSERT (!SMBUS_LIB_PEC (SmBusAddress)); ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status); } @@ -109,7 +109,7 @@ SmBusReceiveByte ( ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status); @@ -148,7 +148,7 @@ SmBusSendByte ( ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Byte = Value; InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status); @@ -184,7 +184,7 @@ SmBusReadDataByte ( UINT8 Byte; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status); @@ -222,7 +222,7 @@ SmBusWriteDataByte ( UINT8 Byte; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Byte = Value; InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status); @@ -258,7 +258,7 @@ SmBusReadDataWord ( UINT16 Word; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status); @@ -296,7 +296,7 @@ SmBusWriteDataWord ( UINT16 Word; ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Word = Value; InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status); @@ -333,7 +333,7 @@ SmBusProcessCall ( ) { ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status); @@ -373,7 +373,7 @@ SmBusReadBlock ( { ASSERT (Buffer != NULL); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status); } @@ -412,7 +412,7 @@ SmBusWriteBlock ( ASSERT (Buffer != NULL); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Length = SMBUS_LIB_LENGTH (SmBusAddress); return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status); @@ -457,7 +457,7 @@ SmBusBlockProcessCall ( ASSERT (ReadBuffer != NULL); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1); ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32); - ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0); + ASSERT (SMBUS_LIB_RESERVED (SmBusAddress) == 0); Length = SMBUS_LIB_LENGTH (SmBusAddress); //