copyright 2008 insyde software debugging under unified extensible firmware interface (uefi):...

41
Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde Software

Upload: carol-hancock

Post on 15-Jan-2016

251 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software

Debugging under Unified Extensible Firmware Interface (UEFI):

Addressing DXE Driver Challenges

Joe ChenSr. Manager, Insyde Software

Page 2: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software2

The first computer bug, a moth removed from the Mark II in 1947, is now at the Smithsonian museum

The first computer bug, a moth removed from the Mark II in 1947, is now at the Smithsonian museum

Grace Hopper, whose manyaccomplishments includedwriting the first compiler,popularized the term “Computer Bug”

Grace Hopper, whose manyaccomplishments includedwriting the first compiler,popularized the term “Computer Bug”

Debugging Then…

Page 3: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software3

Agenda• Benefits of the UEFI Architecture• Tips for Project Planning• Debugging Tools

…Debugging Now…Debugging Now

Page 4: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software4

UEFI is Architected for Modularity

• UEFI is an interface specification

• Allows Driver Encapsulation• As supported devices migrate

to new market segments, the driver can easily follow– Same driver for Mobile– For Desktop/Server– For Embedded Too!

OE

M /O

DM

D

rivers

Fram

ewo

rk D

rivers

Co

mp

atibility

Su

pp

ort

Mo

du

le A

IBV

z D

rivers

Architectural Protocols

Foundations

HardwareHardwareHardwareHardware

UEFI-UEFI-enabled enabled

OSOS

UEFI-UEFI-enabled enabled

OSOS

Pre-bootPre-bootToolsTools

Pre-bootPre-bootToolsTools

Today’sToday’sOSOS

Today’sToday’sOSOS

OptionOptionROMsROMsOptionOptionROMsROMs

IBV

D

rivers

Co

mp

atibility

Su

pp

ort

Mo

du

le

MRC - CPU

UEFI

Benefits of the UEFI ArchitectureBenefits of the UEFI Architecture

Page 5: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software5

UEFI Has a Defined Control Flow

• UEFI/Framework boot process goes through defined stages with clear rules for each stage

DXE Debug

Benefits of the UEFI ArchitectureBenefits of the UEFI Architecture

Page 6: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software6

UEFI is Architected for Debugging

• Uses clear inter-module interfaces called protocols

• Drivers often both consume and produce protocols

• Driver writer should treat platform service protocols as a ‘black-box’

Calling ModuleReferences

Protocol

Calling ModuleReferences

Protocol

Provider ModulePublishes Protocol

Provider ModulePublishes Protocol

AgreedProtocol Definition

AgreedProtocol Definition

Benefits of the UEFI ArchitectureBenefits of the UEFI Architecture

Page 7: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software7

Agenda• Benefits of the UEFI Architecture• Tips for Project Planning • Debugging Tools

Page 8: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software8

Plan Early for Debug

• When designing your board consider:1. Firmware Storage, initial load2. Debugger tool Connections 3. Serial Debug Output

• When starting driver or application project consider:

1. Utilize UEFI Modular Architecture2. Possible to test in the Shell?3. CPU modes – IA32, x64, EBC

Project Planning TipsProject Planning Tips

Page 9: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software9

Agenda• Benefits of the UEFI Architecture• Tips for Project Planning • Debugging Tools

– Hardware (Jtag) Debuggers– Software Debugger Tools– Macros from Tianocore.org

Page 10: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software10

Debugging Then…

Released in 1979, the SDK-86 was Intel’s first Reference Board. It offered a full-featured debugger in ROM with keypad and serial interface. All of its debugger commands are still used in debuggers today.

Released in 1979, the SDK-86 was Intel’s first Reference Board. It offered a full-featured debugger in ROM with keypad and serial interface. All of its debugger commands are still used in debuggers today.

Debugging ToolsDebugging Tools

Page 11: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software11

Standard Today -Source-level Debugging

• Source Level View of Target on developer desktop

• Set Breakpoints in target– – Execution - software and hardware– Hardware breakpoints for memory or I/O access

• Go/step control -> step into, step over, etc.• Dump registers and memory, dump indexed

registers, dump PCI registers, etc.• Dump UEFI tables

Debugging ToolsDebugging Tools

Page 12: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software12

American AriumJTAG Source-level Debugger

ECM-XDP3

Hardware DebuggerDebugging ToolsDebugging Tools

Page 13: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software13

American Arium- ITP Jtag Connection

Page 14: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software14

American Arium H/W Debugger Application InterfaceDebugging ToolsDebugging Tools

Page 15: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software15

Hardware Debugger Useful in All StagesDebugging ToolsDebugging Tools

Page 16: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software16

Platform Software Debugger

H2ODDT™ from Insyde Software

Hardware

UEFI

Firmware

Operating System

Debugging ToolsDebugging Tools

Page 17: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software17

H2ODDT from Insyde Software

USB0

Connects to Target USB Port 0

Target Board Developer

System

Firmware w/ H2ODDTIncluded

Debugging ToolsDebugging Tools

Page 18: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software18

H2ODDT Features and Requirements

• DDT drivers are built into the firmware image which is then flashed to the platform

• Versions for IA32 and x64• Must use target USB Port 0 (which has special

debug mode)• Debugging capability from PEI init through

DXE into boot phase• Includes debug of SMM drivers and legacy

option ROMs

Page 19: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software19

H2ODDT Gives Full Source ViewDebugging ToolsDebugging Tools

Page 20: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software20

See Your Code In Action!

Page 21: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software21

Complete Step Control Over TargetDebugging ToolsDebugging Tools

Page 22: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software22

More H2ODDT Features

Register viewer

Local and Global Variables

Memory dump viewer

Debugging ToolsDebugging Tools

Page 23: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software23

H2ODDT Platform Software Debugger Useful Throughout the Boot

Debugging ToolsDebugging Tools

Page 24: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software24

New From Insyde: Shell-level Debugger

Hardware

UEFI

Firmware

Operating System

UEFI ApplicationsUEFI Driver ++

Debugging ToolsDebugging Tools

“DDT-AD” = Debugger for Applications and Drivers“DDT-AD” = Debugger for Applications and Drivers

Page 25: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software25

“DDT-AD” Software Debugger for Shell-Level Debug

USB0

Thumb Drivew/ DDT-AD Driver

DeveloperSystem Host Board

Board needing driver

Board needing driver

Debugging ToolsDebugging Tools

Page 26: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software26

“DDT-AD” Features and Requirements

• Debug your drivers using any UEFI-compatible platform

• DDT-AD is loaded from UEFI Shell Prompt using Flash drive or other media

• Capability to debug anything that can be loaded from the Shell

• Same cable and source-level debug features as standard Insyde H2ODDT

Debugging ToolsDebugging Tools

Page 27: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software27

UEFI-COMPATIBLEPLATFORM

UEFI-COMPATIBLEPLATFORM

UEFI API INTERFACEUEFI API INTERFACE

UEFI SHELLUEFI SHELL

DDT-ADDDT-ADIH

V H

AR

DW

AR

EIH

V H

AR

DW

AR

E

IHV DRIVERIHV DRIVER

IHV APPTEST APPIHV APP

TEST APP

DDT-AT Lets You See Inside Your Driver DDT-AT Lets You See Inside Your Driver

Page 28: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software28

Strengths of “DDT-AD”

1. Easy setup – no need to build debug firmware image

2. Simple connection using USB cable3. Look inside the source of the driver or

application under test4. Debug problems on any UEFI board5. Useful for many segments – OEM/ODM and

IHV, driver and application

Page 29: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software29

• Insyde is beginning Beta-test• Is this tool interesting to your company?• Send email to [email protected]

“DDT-AD” Status

Page 30: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software30

DDT-AD Used in Shell Environment Debugging ToolsDebugging Tools

Page 31: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software3131

DEMO: DDT-AD Debugger

Page 32: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software32

Source Debuggers - Tips and Tricks

1. Compiler optimization can make source display hard to follow

– Local variables often held in registers, code order may be rearranged…

– Include this statement in your source to disable optimizer:

#pragma optimize ( “” , off )

2. Include this statement in your source to hard-code a breakpoint at any point__debugbreak() compiler intrinsic

Debugging ToolsDebugging Tools

Page 33: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software33

More Source Debugger Tips…

3. Same source can be built for native CPU or EBC binary so usually recommended to debug drivers in native first and then retest in EBC before release

4. Problems in EBC drivers can be checked with EBC Debugger

– http://www.uefi.org/events/EBC_debugger.zip

Page 34: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software34

Software Debug Macros

From www.tianocore.org

Debugging ToolsDebugging Tools

Page 35: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software35

EDK Debug Macros from tianocore.org

• DEBUG (ErrorLevel, String, …)– printf-like formatted print string if ErrorLevel is active

• ASSERT (Expression)– If Expression is FALSE, then print file name and line number and halt.

• ASSERT_EFI_ERROR (Status)– If Status is not EFI_SUCCESS, then print file name and line number and halt.

• CR (Record, Type, Field, Signature)– ASSERT()s if Data Structure Signature does not match

• EFI_BREAKPOINT ()– Generate a CPU break point instruction

These Macros Output to serial port

Debugging ToolsDebugging Tools

Page 36: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software36

Review: Debugging Tools

Board Connection

Strengths

Hardware Debugger ITP Jtag Full Source view,

break if hung

H2ODDT Platform Software Debugger

USB Port 0 Full Source view and breakpoints with no special connector

DDT-AD Shell-level

Debugger

USB Port 0 Easy to use tool for UEFI driver and application development

In-source

Macros

Serial Free but still useful in project

Debugging ToolsDebugging Tools

Page 37: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software37

Summary

1. UEFI architecture is modular and designed for debugging

2. Plan early so board design includes required debugger-support features

3. Several debugger tools available: choose the best tool for your project

ConclusionsConclusions

Page 38: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software38

Call To Action

• The industry is moving to UEFI and conversion has many benefits.

• Plan early to include debugging and make your UEFI project a success.

• Select one of these easy to use tools to increase productivity!

Page 39: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software39

Resources• Web based information:

– www.uefi.org– www.tianocore.org– www.intel.com/technology/efi/ – www.arium.com– www.insydesw.com

Page 40: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software4040

Page 41: Copyright 2008 Insyde Software Debugging under Unified Extensible Firmware Interface (UEFI): Addressing DXE Driver Challenges Joe Chen Sr. Manager, Insyde

Copyright 2008 Insyde Software4141

Questions?