SMBUS & UEFI

What's is SMBUS?

SMBUS: System Management Bus

The System Management Bus (SMBus) is a two-wire interface through which various system component chips and devices can communicate with each other and with the rest of the system.

OK,we don't talk electrical characteristics of SMBUS here.Then I talk usage of SMBUS in UEFI code.

We know, there are primary four phases in UEFI boot order:SEC,PEI,DXE and BDS.

SEC: not initialize

PEI:

UEFI provide a especial PPI for SMBUS in PEI service : EFI_PEI_SMBUS2_PPI

How to use it access SMBUS?

1. Declaration the GUID of EFI_PEI_SMBUS2_PPI

2.Locate PEI service PPI

3.Get SMBUS PPI

4.Call the releated function to access SMBUS

Detail as Below:

First:

#define EFI_PEI_SMBUS2_PPI_GUID \
        { 0x9ca93627, 0xb65b, 0x4324, 0xa2, 0x2, 0xc0, 0xb4, 0x61, 0x76, 0x45, 0x43}

Second:

LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);

Next:

PeiServicesLocatePpi (&gEfiPeiSmbus2PpiGuid, 0, NULL, (VOID **) &SmbusPpi);

Last:

  Status = SmbusPpi->Execute (
                      SmbusPpi,              //the SMBUS PPI located by PEI service
                      SlaveAddress,         //eg: A0  for memory SPD
                      Offset,                      //the offset to access
                      EfiSmbusReadByte,   //EfiSmbusReadByte command for read  & EfiSmbusWriteByte command for write
                      FALSE,
                      &Length,
                      value
                      );

DXE: the method to access is similar to PEi,DXE by related protocol

There is a EFI_SMBUS_HC_PROTOCOL in Boot Service

The operation as below:

1. Declaration the GUID of EFI_PEI_SMBUS2_PPI

2.Locate SMBUS protocol by Boot Service

3.Call the releated function to access SMBUS

First:

The SMBUS_HC_PROTOCOL guid:

#define EFI_SMBUS_HC_PROTOCOL_GUID \
  {0xe49d33ed, 0x513d, 0x4634, { 0xb6, 0x98, 0x6f, 0x55, 0xaa, 0x75, 0x1c, 0x1b} }

Second:

gBS->LocateProtocol(&gEfiSmbusHcProtocolGuid,NULL,&mSmbus);

Last :similar to PEI

Of course,the SMBUS command aren't only EfiSmbusReadByte & EfiSmbusWriteByte ,but also emmmm...

The UEFI defined :

typedef enum _EFI_SMBUS_OPERATION {
  EfiSmbusQuickRead,
  EfiSmbusQuickWrite,
  EfiSmbusReceiveByte,
  EfiSmbusSendByte,
  EfiSmbusReadByte,
  EfiSmbusWriteByte,
  EfiSmbusReadWord,
  EfiSmbusWriteWord,
  EfiSmbusReadBlock,
  EfiSmbusWriteBlock,
  EfiSmbusProcessCall,
  EfiSmbusBWBRProcessCall
} EFI_SMBUS_OPERATION;

 

Ok,after run time phase,We can access SMBUS by IO address,

Come here :   https://blog.csdn.net/vito_bin/article/details/52845777

See  you next blog!

 

Reference:

1.UEFI SPEC 2.6

2.SMBUS SPEC 3.1

 

                                                                             From “ I want to change something” to “ I can change something”!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值