您的位置:首页 > 产品设计 > UI/UE

UEFI应用与编程--EFI_SMBUS_HC_PROTOCOL

2018-03-15 10:47 2783 查看
SmBus.c/*
* SmBus.c
*
* Created on: 2017年12月7日
* Author:
*/

#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/SmbusHc.h>
#include <Library/SmbusLib.h>
#include <Library/UefiLib.h>

#define MY_DEBUG_ON 1

#define MY_DEBUG if(EFI_ERROR(Status) && MY_DEBUG_ON)\
{\
Print(L"%d_%r\r\n",__LINE__,Status);\
return Status;\
}

INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
)
{
EFI_STATUS Status;
EFI_SMBUS_HC_PROTOCOL *Smbus = NULL;
EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;
UINTN SmBusAddress;
UINTN Length;
UINT8 *Buffer;
UINT8 Data;
UINTN Index;

Data = 0xFF;
SmBusAddress = 0xA0;
SmbusDeviceAddress.SmbusDeviceAddress = SmBusAddress >> 1;
Buffer = &Data;
Length = 1;

Status = gBS->LocateProtocol(&gEfiSmbusHcProtocolGuid, NULL, (VOID**) &Smbus);
MY_DEBUG
for(Index = 0; Index < 256; Index++) {
Status = Smbus->Execute (
Smbus,
SmbusDeviceAddress,
Index,//commond = offset + index
EfiSmbusReadByte,
FALSE,
&Length,
Buffer
);
MY_DEBUG
if((Index + 1) % 16 == 0)
Print(L"%02x\r\n", Data);
else
Print(L"%02x ", Data);
}
return EFI_SUCCESS;

}

SmBus.inf[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SmBus
FILE_GUID = dc72d2c7-a48a-42fd-80b6-9d229d9943c8
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = ShellCEntryLib

[Sources]
SmBus.c

[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec

[LibraryClasses]
UefiLib
ShellCEntryLib
[Protocols]
gEfiSmbusHcProtocolGuid
[Ppis]

[Guids]

[BuildOptions]

[Pcd]

[PcdEx]

[FixedPcd]

[FeaturePcd]

[PatchPcd]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uefi edk2 udk bios smbus