Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping...

29
presented by Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest July 6-9, 2011 Presented by Tim Lewis (Phoenix Technologies Ltd.) UEFI Plugfest July 2011 www.uefi.org 1 Updated 2011-06-01

Transcript of Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping...

Page 1: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

presented by

Hardware Prototyping Using a Windows-Hosted UEFI environment

UEFI Summer Plugfest – July 6-9, 2011Presented by Tim Lewis (Phoenix

Technologies Ltd.)

UEFI Plugfest – July 2011 www.uefi.org 1

Updated 2011-06-01

Page 2: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Agenda

• Introduction

• SMBus and UEFI Overview

• Adding ASF, DASH & IPMI

• Debugging With Windows-Hosted Emulation

• Q & A

UEFI Plugfest – July 2011 www.uefi.org 2

Page 3: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Introduction

• Problem: UEFI BIOS is a tough development environment.– Developed before hardware available. Often

have to code blind.– Tough to debug. How to log output, set

breakpoints.– Time consuming to debug. Long turn-around

time to update.– How to unit test corner cases? Touching

hardware crashes the system.

UEFI Plugfest – July 2011 www.uefi.org 3

Page 4: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Introduction (2)

• Solution: Develop UEFI BIOS in an emulated hardware environment.– WinHost (Phoenix) or Nt32Pkg (TianoCore) offer an

emulated UEFI environment running under Windows operating systems.

– Provides UEFI abstractions for many Windows hardware resources (disk, serial, network)

– Quick-turn around and excellent debug support using Visual Studio.

• Real-Life Solution: How Phoenix used WinHost to develop ASF, DASH and IPMI using an emulated SMBus Host Controller.

UEFI Plugfest – July 2011 www.uefi.org 4

Page 5: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

What Is SMBus?

• SMBus is a low-power 2-wire multi-master bus built on top of I2C.

– Well-defined transport.

– Addressable.

– UDID gives vendor/device id similar to PCI.

• Used as the backbone of numerous platform management standards:

– ASF, DASH, IPMI

UEFI Plugfest – July 2011 www.uefi.org 5

CPU

SMBus Host Controller

Temperature

Sensor

Fan Motor

Voltage

Sensor

Managemen

t Controller

SMBus

PCIe Slot

Page 6: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

How Does UEFI Support SMBus?

• The UEFI PI Specification’s SMBus Host Controller protocol abstracts differences in hardware interface.

UEFI Plugfest – July 2011 www.uefi.org 6

typedef struct _EFI_SMBUS_HC_PROTOCOL {

EFI_SMBUS_HC_EXECUTE_OPERATION Execute;

EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE ArpDevice;

EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP GetArpMap;

EFI_SMBUS_HC_PROTOCOL_NOTIFY Notify;

} EFI_SMBUS_HC_PROTOCOL;

Page 7: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

What Was Missing?

• The UEFI Driver Model!

UEFI Plugfest – July 2011 www.uefi.org 7

Page 8: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

What Was Missing?

• The UEFI Driver Model!

UEFI Plugfest – July 2011 www.uefi.org 8

Page 9: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

What Was Missing?

• The UEFI Driver Model!

UEFI Plugfest – July 2011 www.uefi.org 9

Page 10: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

What Was Missing?

• The UEFI Driver Model!

UEFI Plugfest – July 2011 www.uefi.org 10

Page 11: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

What Was Missing?

• The UEFI Driver Model!

UEFI Plugfest – July 2011 www.uefi.org 11

Page 12: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

How To Integrate SMBus HostController Into UEFI Driver Model?

• Added Driver Binding Protocol.

• Added Device Path Protocol.

• Added Means To Connect Non-Boot Devices.

–By default, Boot Manager only connected console input, output and boot devices.

UEFI Plugfest – July 2011 www.uefi.org 12

Page 13: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Adding ASF, DASH and IPMI

UEFI Plugfest – July 2011 www.uefi.org 13

• With SMBus in UEFI driver model, standards like ASF, DASH and IPMI fit in naturally.

ASD

OS

/

AP

PS

SY

ST

EM

SIL

ICO

NH

AR

DW

AR

ESMBus Host Controller

SMBus I/O

ASF Bus

ASF I/O

ASF & SMBus

Sensor

Drivers

BMCASF Sensors

SMBus

Sensor

Device Path

Driver Binding

HII Forms

SMBus Bus

SMBus Host Controller

ASF ASD

Driver

ASF ASD

HII

Database

Setup

Page 14: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Emulate Host Controller

UEFI Plugfest – July 2011 www.uefi.org 14

• By emulating one driver, we could test and debug our ASF, DASH and IPMI stack w/o hardware.

• Easy to test setup pages, sensors, boot options, SMBIOS push and error conditions.

Page 15: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

SMBus Host Controller Driver Architecture

UEFI Plugfest – July 2011 www.uefi.org 15

Page 16: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Common Unit Test Debug Scenarios

UEFI Plugfest – July 2011 www.uefi.org 16

• Device Enumeration for Devices That:–Are not enumerable (ARP)

–Don’t identify themselves well.

• Error Check For Devices That:–Return ill-formed packets.

–Don’t support specific commands.

• Return Different SMBIOS Tables, Boot Options and Other Items.

Page 17: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Debug Using Messages or Breakpoints!

• Dump out enumeration information.

UEFI Plugfest – July 2011 www.uefi.org 17

Page 18: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Debug Using Messages or Breakpoints!

• View how commands are translated from DASH to SMBus.

UEFI Plugfest – July 2011 www.uefi.org 18

Page 19: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Debug Using Messages or Breakpoints!

• View how commands are translated from DASH to SMBus.

UEFI Plugfest – July 2011 www.uefi.org 19

Page 20: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Conclusion

UEFI Plugfest – July 2011 www.uefi.org 20

• Device Emulation Speeds Development.

• Better debug & log capabilities.

• Better unit test case.

–Once a unique device found, model it in software for regression tests.

Page 21: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Q & A

UEFI Plugfest – July 2011 www.uefi.org 21

Page 22: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Thanks for attending the UEFI Summer Plugfest 2011

For more information on the Unified EFI Forum and UEFI Specifications, visit http://www.uefi.org

presented by

UEFI Plugfest – July 2011 www.uefi.org 22

Page 23: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

But wait, there’s more …

UEFI Plugfest – July 2011 www.uefi.org 23

Wed(July 6)

• UEFI State of the Union (10:30am, Intel)

• Implementing a Secure Boot Path with UEFI 2.3.1 (1:00pm, Insyde)

• UEFI SCT Overview (2:30pm, HP/Intel)

Thu(July 7)

• Replacing VGA: GOP Implementation in UEFI (10:30am, AMD)

• UEFI prototyping using a Windows-hosted UEFI environment (1:00pm, Phoenix)

• EFI Shell Lab (2:00-4:00pm, “Thunder”, Intel)

• GOP Enabling & Testing Lab (4:30—5:30pm, “Thunder”, Intel)

Fri(July 8)

• Best Practices for UEFI Option ROM Developers (10:30am, AMI)

Download presentations after the plugfest at www.uefi.org

Page 24: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

Backup

UEFI Plugfest – July 2011 www.uefi.org 24

Page 25: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

SMBus I/O Protocol

UEFI Plugfest – July 2011 www.uefi.org 25

extern EFI_GUID gSctSmbusIoProtocolGuid;

typedef struct _SCT_SMBUS_IO_PROTOCOL {

UINT32 Size;

EFI_SMBUS_ADDRESS Addr;

SCT_SMBUS_IO_IDENTIFY Identify;

SCT_SMBUS_IO_EXECUTE Execute;

} SCT_SMBUS_IO_PROTOCOL, *PSCT_SMBUS_IO_PROTOCOL;

Page 26: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

ASF I/O Protocol

UEFI Plugfest – July 2011 www.uefi.org 26

extern EFI_GUID gSctAsfIoProtocolGuid;

typedef struct _SCT_ASF_IO_PROTOCOL {

UINT32 Size;

SCT_ASF_IO_SEND_MSG SendMessage;

} SCT_ASF_IO_PROTOCOL, *PSCT_ASF_IO_PROTOCOL;

Page 27: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

DASH MCTP I/O Protocol

UEFI Plugfest – July 2011 www.uefi.org 27

extern EFI_GUID gSctMctpIoProtocolGuid;

typedef struct _SCT_MCTP_IO_PROTOCOL {

UINT32 Size;

MCTP_EID Eid;

MCTP_MEDIUM Medium;

SCT_MCTP_SEND_MSG SendMessage;

} SCT_MCTP_IO_PROTOCOL, *PSCT_MCTP_IO_PROTOCOL;

Page 28: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

IPMI I/O Protocol

UEFI Plugfest – July 2011 www.uefi.org 28

extern EFI_GUID gSctIpmiProtocolGuid;

typedef struct _SCT_IPMI_IO_PROTOCOL {

UINT32 Size;

SCT_IPMI_SEND_REQUEST SendRequest;

} SCT_IPMI_IO_PROTOCOL, *PSCT_IPMI_IO_PROTOCOL;

Page 29: Hardware Prototyping Using a Windows-Hosted UEFI environment · 6/1/2011  · Hardware Prototyping Using a Windows-Hosted UEFI environment UEFI Summer Plugfest –July 6-9, 2011 Presented

References

• System Management Bus (SMBus) Specification, Version 2.0, August 3, 2000

• UEFI Specification, Version 2.3.1, April 6, 2011

• Platform Initialization (PI) Specification, Volume 5, Version 1.2, May 13, 2009

UEFI Plugfest – July 2011 www.uefi.org 29