]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Library/PeiSmbusLibSmbusPpi/PeiSmbusLib.c
Fix typo in comment.
[mirror_edk2.git] / IntelFrameworkPkg / Library / PeiSmbusLibSmbusPpi / PeiSmbusLib.c
CommitLineData
a67d1f18 1/** @file\r
b2cefd7c 2 Implementation of SmBusLib class library for PEI phase.\r
a67d1f18 3\r
4Copyright (c) 2006, Intel Corporation<BR>\r
5All rights reserved. This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
a67d1f18 13**/\r
14\r
15#include "InternalSmbusLib.h"\r
16\r
17/**\r
18 Gets Smbus PPIs.\r
19\r
20 This internal function retrieves Smbus PPI from PPI database.\r
b2cefd7c 21 If gEfiPeiSmbusPpiGuid can not be located, then ASSERT()\r
22 \r
a67d1f18 23 @return The pointer to Smbus PPI.\r
24\r
25**/\r
26EFI_PEI_SMBUS_PPI *\r
27InternalGetSmbusPpi (\r
22936e95 28 VOID\r
a67d1f18 29 ) \r
30{\r
31 EFI_STATUS Status;\r
32 EFI_PEI_SMBUS_PPI *SmbusPpi;\r
33\r
22936e95 34 Status = PeiServicesLocatePpi (&gEfiPeiSmbusPpiGuid, 0, NULL, (VOID **) &SmbusPpi);\r
a67d1f18 35 ASSERT_EFI_ERROR (Status);\r
36 ASSERT (SmbusPpi != NULL);\r
37\r
38 return SmbusPpi;\r
39}\r
40\r
41/**\r
42 Executes an SMBus operation to an SMBus controller. \r
43\r
44 This function provides a standard way to execute Smbus script\r
45 as defined in the SmBus Specification. The data can either be of\r
46 the Length byte, word, or a block of data.\r
47\r
48 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to\r
49 execute the SMBus transactions.\r
50 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
51 SMBUS Command, SMBUS Data Length, and PEC.\r
52 @param Length Signifies the number of bytes that this operation will do. The maximum number of\r
53 bytes can be revision specific and operation specific.\r
54 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations\r
55 require this argument. The length of this buffer is identified by Length.\r
56 @param Status Return status for the executed command.\r
57 This is an optional parameter and may be NULL.\r
58\r
59 @return The actual number of bytes that are executed for this operation..\r
60\r
61**/\r
62UINTN\r
63InternalSmBusExec (\r
64 IN EFI_SMBUS_OPERATION SmbusOperation,\r
65 IN UINTN SmBusAddress,\r
66 IN UINTN Length,\r
67 IN OUT VOID *Buffer,\r
68 OUT RETURN_STATUS *Status OPTIONAL\r
69 )\r
70{\r
71 EFI_PEI_SMBUS_PPI *SmbusPpi;\r
72 EFI_PEI_SERVICES **PeiServices;\r
73 RETURN_STATUS ReturnStatus;\r
74 EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;\r
75\r
76 PeiServices = GetPeiServicesTablePointer ();\r
22936e95 77 SmbusPpi = InternalGetSmbusPpi ();\r
a67d1f18 78 SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
79\r
80 ReturnStatus = SmbusPpi->Execute (\r
81 PeiServices,\r
82 SmbusPpi,\r
83 SmbusDeviceAddress,\r
84 SMBUS_LIB_COMMAND (SmBusAddress),\r
85 SmbusOperation,\r
86 SMBUS_LIB_PEC (SmBusAddress), \r
87 &Length,\r
88 Buffer\r
89 );\r
90 if (Status != NULL) {\r
91 *Status = ReturnStatus;\r
92 }\r
93\r
94 return Length;\r
95}\r