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