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