#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
@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
- ( ((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
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
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
-/**\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
EFI_STATUS\r
EFIAPI\r
EfiCreateEventLegacyBoot (\r
- OUT EFI_EVENT *LegacyBootEvent\r
+ OUT EFI_EVENT *LegacyBootEvent\r
);\r
\r
/**\r
EFI_STATUS\r
EFIAPI\r
EfiCreateEventReadyToBoot (\r
- OUT EFI_EVENT *ReadyToBootEvent\r
+ OUT EFI_EVENT *ReadyToBootEvent\r
);\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
/**\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
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
UINTN AlignedAddress;\r
UINTN AlignmentMask;\r
UINTN OverAllocationSize;\r
+ UINTN RealAllocationSize;\r
VOID **FreePointer;\r
- EFI_STATUS Status;\r
\r
//\r
// Alignment must be a power of two or zero.\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
{\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
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
\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
#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
@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
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
-/**\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
This is an optional parameter and may be NULL.\r
\r
**/\r
-BOOLEAN\r
+VOID\r
EFIAPI\r
SmBusQuickWrite (\r
IN UINTN SmBusAddress,\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
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
OUT RETURN_STATUS *Status OPTIONAL\r
)\r
{\r
+ UINTN Length;\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
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
+ UINTN Length;\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
- // BugBug: Not sure whether it's all right.\r
+ // Assuming that InBuffer 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
+ InBuffer = CopyMem (InBuffer, OutBuffer, Length);\r
+ return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, InBuffer, Status);\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
@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
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
-/**\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
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
\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
This is an optional parameter and may be NULL.\r
\r
**/\r
-BOOLEAN\r
+VOID\r
EFIAPI\r
SmBusQuickWrite (\r
IN UINTN SmBusAddress,\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
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
OUT RETURN_STATUS *Status OPTIONAL\r
)\r
{\r
+ UINTN Length;\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
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
+ UINTN Length;\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
- // BugBug: Not sure whether it's all right.\r
+ // Assuming that InBuffer 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
+ InBuffer = CopyMem (InBuffer, OutBuffer, Length);\r
+ return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, InBuffer, Status);\r
}\r
EFI_STATUS\r
EFIAPI\r
EfiCreateEventLegacyBoot (\r
- OUT EFI_EVENT *LegacyBootEvent\r
+ OUT EFI_EVENT *LegacyBootEvent\r
)\r
{\r
EFI_STATUS Status;\r
EFI_STATUS\r
EFIAPI\r
EfiCreateEventReadyToBoot (\r
- IN EFI_EVENT *ReadyToBootEvent\r
+ OUT EFI_EVENT *ReadyToBootEvent\r
)\r
{\r
EFI_STATUS Status;\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
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
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
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
- 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