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]
* 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应用与编程--EFI_USB2_HC_PROTOCOL
- UEFI应用与编程--Handle&EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
- UEFI应用与编程--EFI_SMBIOS_PROTOCOL
- UEFI应用与编程--EFI_DISK_INFO_PROTOCOL
- UEFI应用与编程--EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
- UEFI应用与编程--HelloWorld(03)
- UEFI应用与编程--SmBios
- UEFI应用与编程--AcpiTable
- UEFI应用与编程--HelloWorld(02)
- UEFI应用与编程--ShowBootDevice
- UEFI应用与编程--HelloWorld(01)
- UEFI应用与编程--IndexIo
- UEFI应用与编程--解析命令行参数
- UEFI应用与编程--BootOrder
- UEFI应用与编程--8042 Kbc
- UEFI应用与编程--ReadCmos
- UEFI应用与编程--显示文件信息
- UEFI应用与编程--读写Pci配置空间
- UEFI应用与编程--WriteCmos
- UEFI应用与编程--ReadSpd