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