3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 PEI Smbus Lib internal functions
23 #include "PeiSmbusLibInternal.h"
28 This internal function retrieves Smbus PPI from PPI database.
30 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.
32 @return The pointer to Smbus PPI.
37 EFI_PEI_SERVICES
**PeiServices
41 EFI_PEI_SMBUS_PPI
*SmbusPpi
;
43 Status
= (*PeiServices
)->LocatePpi (PeiServices
, &gEfiPeiSmbusPpiGuid
, 0, NULL
, (VOID
**) &SmbusPpi
);
44 ASSERT_EFI_ERROR (Status
);
45 ASSERT (SmbusPpi
!= NULL
);
51 Executes an SMBus operation to an SMBus controller.
53 This function provides a standard way to execute Smbus script
54 as defined in the SmBus Specification. The data can either be of
55 the Length byte, word, or a block of data.
57 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
58 execute the SMBus transactions.
59 @param SmBusAddress Address that encodes the SMBUS Slave Address,
60 SMBUS Command, SMBUS Data Length, and PEC.
61 @param Length Signifies the number of bytes that this operation will do. The maximum number of
62 bytes can be revision specific and operation specific.
63 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
64 require this argument. The length of this buffer is identified by Length.
65 @param Status Return status for the executed command.
66 This is an optional parameter and may be NULL.
68 @return The actual number of bytes that are executed for this operation..
73 IN EFI_SMBUS_OPERATION SmbusOperation
,
74 IN UINTN SmBusAddress
,
77 OUT RETURN_STATUS
*Status OPTIONAL
80 EFI_PEI_SMBUS_PPI
*SmbusPpi
;
81 EFI_PEI_SERVICES
**PeiServices
;
82 RETURN_STATUS ReturnStatus
;
83 EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress
;
85 PeiServices
= GetPeiServicesTablePointer ();
86 SmbusPpi
= InternalGetSmbusPpi (PeiServices
);
87 SmbusDeviceAddress
.SmbusDeviceAddress
= SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress
);
89 ReturnStatus
= SmbusPpi
->Execute (
93 SMBUS_LIB_COMMAND (SmBusAddress
),
95 SMBUS_LIB_PEC (SmBusAddress
),
100 *Status
= ReturnStatus
;