]>
Commit | Line | Data |
---|---|---|
dd51a993 | 1 | /** @file\r |
2 | Implementation of SmBusLib class library for PEI phase.\r | |
3 | \r | |
58380e9c | 4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
19388d29 | 5 | This program and the accompanying materials\r |
bad46384 | 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 | |
dd51a993 | 12 | \r |
dd51a993 | 13 | **/\r |
14 | \r | |
dd51a993 | 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 | |
21 | \r | |
f38fdc74 | 22 | @param VOID\r |
dd51a993 | 23 | \r |
24 | @return The pointer to Smbus PPI.\r | |
25 | \r | |
26 | **/\r | |
27 | EFI_PEI_SMBUS2_PPI *\r | |
28 | InternalGetSmbusPpi (\r | |
1c280088 | 29 | VOID\r |
bad46384 | 30 | )\r |
dd51a993 | 31 | {\r |
32 | EFI_STATUS Status;\r | |
33 | EFI_PEI_SMBUS2_PPI *SmbusPpi;\r | |
34 | \r | |
1c280088 | 35 | Status = PeiServicesLocatePpi (&gEfiPeiSmbus2PpiGuid, 0, NULL, (VOID **) &SmbusPpi);\r |
dd51a993 | 36 | ASSERT_EFI_ERROR (Status);\r |
37 | ASSERT (SmbusPpi != NULL);\r | |
38 | \r | |
39 | return SmbusPpi;\r | |
40 | }\r | |
41 | \r | |
42 | /**\r | |
bad46384 | 43 | Executes an SMBus operation to an SMBus controller.\r |
dd51a993 | 44 | \r |
45 | This function provides a standard way to execute Smbus script\r | |
46 | as defined in the SmBus Specification. The data can either be of\r | |
47 | the Length byte, word, or a block of data.\r | |
48 | \r | |
58380e9c | 49 | @param SmbusOperation Signifies which particular SMBus hardware protocol instance \r |
50 | that it will use to execute the SMBus transactions.\r | |
2fc59a00 | 51 | @param SmBusAddress The address that encodes the SMBUS Slave Address,\r |
dd51a993 | 52 | SMBUS Command, SMBUS Data Length, and PEC.\r |
58380e9c | 53 | @param Length Signifies the number of bytes that this operation will \r |
54 | do. The maximum number of bytes can be revision specific \r | |
55 | and operation specific.\r | |
56 | @param Buffer Contains the value of data to execute to the SMBus slave \r | |
57 | device. Not all operations require this argument. The \r | |
58 | length of this buffer is identified by Length.\r | |
dd51a993 | 59 | @param Status Return status for the executed command.\r |
60 | This is an optional parameter and may be NULL.\r | |
61 | \r | |
f38fdc74 | 62 | @return The actual number of bytes that are executed for this operation.\r |
dd51a993 | 63 | \r |
64 | **/\r | |
65 | UINTN\r | |
66 | InternalSmBusExec (\r | |
67 | IN EFI_SMBUS_OPERATION SmbusOperation,\r | |
68 | IN UINTN SmBusAddress,\r | |
69 | IN UINTN Length,\r | |
70 | IN OUT VOID *Buffer,\r | |
71 | OUT RETURN_STATUS *Status OPTIONAL\r | |
72 | )\r | |
73 | {\r | |
74 | EFI_PEI_SMBUS2_PPI *SmbusPpi;\r | |
dd51a993 | 75 | RETURN_STATUS ReturnStatus;\r |
76 | EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;\r | |
77 | \r | |
1c280088 | 78 | SmbusPpi = InternalGetSmbusPpi ();\r |
dd51a993 | 79 | SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r |
80 | \r | |
81 | ReturnStatus = SmbusPpi->Execute (\r | |
82 | SmbusPpi,\r | |
83 | SmbusDeviceAddress,\r | |
84 | SMBUS_LIB_COMMAND (SmBusAddress),\r | |
85 | SmbusOperation,\r | |
bad46384 | 86 | SMBUS_LIB_PEC (SmBusAddress),\r |
dd51a993 | 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 |