Remove the EDK prefix from library instance folder's name
[mirror_edk2.git] / IntelFrameworkPkg / Library / PeiSmbusLibSmbus / InternalSmbusLib.h
1 /** @file
2 Internal header file for Smbus library.
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
16 #ifndef __INTERNAL_SMBUS_LIB_H
17 #define __INTERNAL_SMBUS_LIB_H
18
19 //
20 // The package level header files this module uses
21 //
22 #include <PiPei.h>
23 #include <FrameworkPei.h>
24 //
25 // The protocols, PPI and GUID defintions for this module
26 //
27 #include <Ppi/Smbus.h>
28 //
29 // The Library classes this module consumes
30 //
31 #include <Library/SmbusLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/PeiServicesTablePointerLib.h>
34 #include <Library/BaseMemoryLib.h>
35
36 #define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)
37 #define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)
38 #define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f)
39 #define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))
40 #define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))
41
42 //
43 // Declaration for internal functions
44 //
45
46 /**
47 Gets Smbus PPIs.
48
49 This internal function retrieves Smbus PPI from PPI database.
50
51 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.
52
53 @return The pointer to Smbus PPI.
54
55 **/
56 EFI_PEI_SMBUS_PPI *
57 InternalGetSmbusPpi (
58 EFI_PEI_SERVICES **PeiServices
59 );
60
61 /**
62 Executes an SMBus operation to an SMBus controller.
63
64 This function provides a standard way to execute Smbus script
65 as defined in the SmBus Specification. The data can either be of
66 the Length byte, word, or a block of data.
67
68 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
69 execute the SMBus transactions.
70 @param SmBusAddress Address that encodes the SMBUS Slave Address,
71 SMBUS Command, SMBUS Data Length, and PEC.
72 @param Length Signifies the number of bytes that this operation will do. The maximum number of
73 bytes can be revision specific and operation specific.
74 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
75 require this argument. The length of this buffer is identified by Length.
76 @param Status Return status for the executed command.
77 This is an optional parameter and may be NULL.
78
79 @return The actual number of bytes that are executed for this operation.
80
81 **/
82 UINTN
83 InternalSmBusExec (
84 IN EFI_SMBUS_OPERATION SmbusOperation,
85 IN UINTN SmBusAddress,
86 IN UINTN Length,
87 IN OUT VOID *Buffer,
88 OUT RETURN_STATUS *Status OPTIONAL
89 );
90
91 #endif