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