]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/DxeSmbusLib/DxeSmbusLib.c
Update the copyright notice format
[mirror_edk2.git] / MdePkg / Library / DxeSmbusLib / DxeSmbusLib.c
CommitLineData
dd51a993 1/** @file\r
484c7785 2Implementation of SmBusLib class library for DXE phase.\r
dd51a993 3\r
19388d29
HT
4Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
bad46384 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
13\r
dd51a993 14**/\r
15\r
bad46384 16\r
dd51a993 17#include "InternalSmbusLib.h"\r
18\r
dd51a993 19\r
20//\r
21// Globle varible to cache pointer to Smbus protocol.\r
22//\r
fe467413 23EFI_SMBUS_HC_PROTOCOL *mSmbus = NULL;\r
dd51a993 24\r
25/**\r
26 The constructor function caches the pointer to Smbus protocol.\r
bad46384 27\r
dd51a993 28 The constructor function locates Smbus protocol from protocol database.\r
bad46384 29 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.\r
dd51a993 30\r
31 @param ImageHandle The firmware allocated handle for the EFI image.\r
32 @param SystemTable A pointer to the EFI System Table.\r
bad46384 33\r
dd51a993 34 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
35\r
36**/\r
37EFI_STATUS\r
38EFIAPI\r
39SmbusLibConstructor (\r
40 IN EFI_HANDLE ImageHandle,\r
41 IN EFI_SYSTEM_TABLE *SystemTable\r
42 )\r
43{\r
44 EFI_STATUS Status;\r
bad46384 45\r
dd51a993 46 Status = gBS->LocateProtocol (&gEfiSmbusHcProtocolGuid, NULL, (VOID**) &mSmbus);\r
47 ASSERT_EFI_ERROR (Status);\r
48 ASSERT (mSmbus != NULL);\r
49\r
50 return Status;\r
51}\r
52\r
53/**\r
bad46384 54 Executes an SMBus operation to an SMBus controller.\r
dd51a993 55\r
56 This function provides a standard way to execute Smbus script\r
57 as defined in the SmBus Specification. The data can either be of\r
58 the Length byte, word, or a block of data.\r
59\r
60 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to\r
61 execute the SMBus transactions.\r
62 @param SmBusAddress Address that encodes the SMBUS Slave Address,\r
63 SMBUS Command, SMBUS Data Length, and PEC.\r
64 @param Length Signifies the number of bytes that this operation will do. The maximum number of\r
65 bytes can be revision specific and operation specific.\r
66 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations\r
67 require this argument. The length of this buffer is identified by Length.\r
68 @param Status Return status for the executed command.\r
69 This is an optional parameter and may be NULL.\r
70\r
070a76b1 71 @return The actual number of bytes that are executed for this operation.\r
dd51a993 72\r
73**/\r
74UINTN\r
75InternalSmBusExec (\r
76 IN EFI_SMBUS_OPERATION SmbusOperation,\r
77 IN UINTN SmBusAddress,\r
78 IN UINTN Length,\r
79 IN OUT VOID *Buffer,\r
80 OUT RETURN_STATUS *Status OPTIONAL\r
81 )\r
82{\r
83 RETURN_STATUS ReturnStatus;\r
84 EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;\r
85\r
86 SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);\r
87\r
88 ReturnStatus = mSmbus->Execute (\r
89 mSmbus,\r
90 SmbusDeviceAddress,\r
91 SMBUS_LIB_COMMAND (SmBusAddress),\r
92 SmbusOperation,\r
bad46384 93 SMBUS_LIB_PEC (SmBusAddress),\r
dd51a993 94 &Length,\r
95 Buffer\r
96 );\r
97 if (Status != NULL) {\r
98 *Status = ReturnStatus;\r
99 }\r
100\r
101 return Length;\r
102}\r