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