]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/PeiSmbusLibSmbus2Ppi/PeiSmbusLib.c
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / PeiSmbusLibSmbus2Ppi / PeiSmbusLib.c
CommitLineData
dd51a993 1/** @file\r
2Implementation of SmBusLib class library for PEI phase.\r
3\r
373ade0e 4Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
bad46384 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
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
27EFI_PEI_SMBUS2_PPI *\r
28InternalGetSmbusPpi (\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
49 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to\r
50 execute the SMBus transactions.\r
51 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
52 SMBUS Command, SMBUS Data Length, and PEC.\r
53 @param Length Signifies the number of bytes that this operation will do. The maximum number of\r
54 bytes can be revision specific and operation specific.\r
55 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations\r
56 require this argument. The length of this buffer is identified by Length.\r
57 @param Status Return status for the executed command.\r
58 This is an optional parameter and may be NULL.\r
59\r
f38fdc74 60 @return The actual number of bytes that are executed for this operation.\r
dd51a993 61\r
62**/\r
63UINTN\r
64InternalSmBusExec (\r
65 IN EFI_SMBUS_OPERATION SmbusOperation,\r
66 IN UINTN SmBusAddress,\r
67 IN UINTN Length,\r
68 IN OUT VOID *Buffer,\r
69 OUT RETURN_STATUS *Status OPTIONAL\r
70 )\r
71{\r
72 EFI_PEI_SMBUS2_PPI *SmbusPpi;\r
dd51a993 73 RETURN_STATUS ReturnStatus;\r
74 EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;\r
75\r
1c280088 76 SmbusPpi = InternalGetSmbusPpi ();\r
dd51a993 77 SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
78\r
79 ReturnStatus = SmbusPpi->Execute (\r
80 SmbusPpi,\r
81 SmbusDeviceAddress,\r
82 SMBUS_LIB_COMMAND (SmBusAddress),\r
83 SmbusOperation,\r
bad46384 84 SMBUS_LIB_PEC (SmBusAddress),\r
dd51a993 85 &Length,\r
86 Buffer\r
87 );\r
88 if (Status != NULL) {\r
89 *Status = ReturnStatus;\r
90 }\r
91\r
92 return Length;\r
93}\r