2 Implementation of SmBusLib class library for PEI phase.
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "InternalSmbusLib.h"
20 This internal function retrieves Smbus PPI from PPI database.
24 @return The pointer to Smbus PPI.
33 EFI_PEI_SMBUS2_PPI
*SmbusPpi
;
35 Status
= PeiServicesLocatePpi (&gEfiPeiSmbus2PpiGuid
, 0, NULL
, (VOID
**) &SmbusPpi
);
36 ASSERT_EFI_ERROR (Status
);
37 ASSERT (SmbusPpi
!= NULL
);
43 Executes an SMBus operation to an SMBus controller.
45 This function provides a standard way to execute Smbus script
46 as defined in the SmBus Specification. The data can either be of
47 the Length byte, word, or a block of data.
49 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
50 execute the SMBus transactions.
51 @param SmBusAddress Address that encodes the SMBUS Slave Address,
52 SMBUS Command, SMBUS Data Length, and PEC.
53 @param Length Signifies the number of bytes that this operation will do. The maximum number of
54 bytes can be revision specific and operation specific.
55 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
56 require this argument. The length of this buffer is identified by Length.
57 @param Status Return status for the executed command.
58 This is an optional parameter and may be NULL.
60 @return The actual number of bytes that are executed for this operation.
65 IN EFI_SMBUS_OPERATION SmbusOperation
,
66 IN UINTN SmBusAddress
,
69 OUT RETURN_STATUS
*Status OPTIONAL
72 EFI_PEI_SMBUS2_PPI
*SmbusPpi
;
73 RETURN_STATUS ReturnStatus
;
74 EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress
;
76 SmbusPpi
= InternalGetSmbusPpi ();
77 SmbusDeviceAddress
.SmbusDeviceAddress
= SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress
);
79 ReturnStatus
= SmbusPpi
->Execute (
82 SMBUS_LIB_COMMAND (SmBusAddress
),
84 SMBUS_LIB_PEC (SmBusAddress
),
89 *Status
= ReturnStatus
;