Focusing on the use of the UEFI Shell and its recently released formal specification, this book unlocks a wide range of usage models which can help people best utilize the shell solutions. This text also expands on the obvious intended utilization of the shell and explains how it can be used in various areas such as security, networking, configuration, and other anticipated uses such as manufacturing, diagnostics, etc. Among other topics, Harnessing the UEFI Shell demonstrates how to write Shell scripts, how to write a Shell application, how to use provisioning options and more. Since the Shell is also a UEFI component, the book will make clear how the two things interoperate and how both Shell developers as well as UEFI developers can dip into the other’s field to further expand the power of their solutions.
Harnessing the UEFI Shell is authored by the three chairs of the UEFI working sub-teams, Michael Rothman (Intel, chair of the UEFI Configuration and UEFI Shell sub-teams), Vincent Zimmer (Intel, chair of the UEFI networking sub-team and security sub-team), and Tim Lewis (Insyde Software, chair of the UEFI security sub-team). This book is perfect for any OEMs that ship UEFI-based solutions (which is all of the MNCs such as IBM, Dell, HP, Apple, etc.), software developers who are focused on delivering solutions targeted to manufacturing, diagnostics, hobbyists, or stand-alone kiosk environments.
İçerik tablosu
Preface vii
Chapter 1 Introduction 1
What is UEFI? 1
What Do We Mean by Shell? 4
A Short History of the UEFI Shell 5
Brief Overview of the UEFI Shell 5
UEFI Shell APIs 6
Command Line Interface Features 6
Why a Shell at all? 7
Chapter 2 Under the UEFI Shell 9
Shell and UEFI 9
Evolution and Revolution 13
Chapter 3 What Is the UEFI Shell? 15
What Is Contained in the UEFI Shell? 16
What Kind of Shell Do You Have? 16
What!? No Shell? No Problem! 17
Programmatic Shell Environment 19
Using UEFI Shell Commands 20
Interactive Shell Environment 22
Scripting 22
Program Launch 24
File-System Abstractions 29
Shell Script Resolves into a UEFI Firmware Action 31
Chapter 4 Why We Need an Execution Environment before the OS 33
Evolution of a Machine 33
The Platform Initialization Flow 34
UEFI Transitions 36
States of a Platform 38
Readiness of UEFI 41
Migration Using the UEFI Shell 44
Going Forward 45
Chapter 5 Manufacturing 47
Throughput 47
Manufacturing Test Tools 49
Hardware Access with Manufacturing Tools 50
Converting Manufacturing Tools 53
Conclusion 54
Chapter 6 Bare Metal Provisionig 55
Provisioning with the UEFI Shell 55
UEFI Networking Stack 56
Securing the Network 58
Speeding Up the Network 62
Example of Putting It Together 62
Summary 68
Chapter 7 Configuration of Provisioned Material 69
Initialization Timeline 69
Configuration Infrastructure Overview 71
Using the Configuration Infrastructure 72
Driver Model Interactions 73
Provisioning the Platform 75
Configuring through the UEFI Shell 76
Basic Configuration 76
Advanced Configuration Abilities 79
Chapter 8 The Use of UEFI for Diagnostics 85
Types of Diagnostics 85
SMBIOS Table Organization 87
SMBIOS Structure Table Entry Point 88
Table Organization Graph 88
Structure Standards 89
Structure Evolution and Usage Guidelines 90
Text Strings 90
Required Structures and Data 91
Features 91
User Interface Design 92
Design Guide 92
Usage 93
Examples 93
Architecture Design 94
Data Structure 95
SMBIOS_STRUCTURE_TABLE 95
SMBIOS_HEADER 97
SMBIOS_STRUCTURE_POINTER 98
STRUCTURE_STATISTICS 99
Source Code for the Utility 100
Summary 105
Chapter 9 UEFI Shell Scripting 107
Hello, World! 108
Echo 108
Echo All Parameters 109
Echo All Parameters (Improved Version) 110
Concatenate Text Files 112
List Only Selected “ls” Information 113
Install Script 115
How to Make a Shell Script Appear as a Boot Option 119
Chapter 10 UEFI Shell Programming 121
A Simple UEFI Shell Application: Hello World 121
The Source File: Hello World.c 121
The Component Information (.inf) File 123
A Simple Standard Application: Hello World2 124
The Source File: Hello World2.c 124
The Component Information (.inf) File: Hello World2.inf 125
Read Keyboard Input in UEFI Shell Scripts: Get Key 126
The Source File: Get Key.c 127
The Component Information (.inf) File: Get Key.inf 137
The Build Description (.dsc) File 139
Calculate Math Expressions: Math 139
The Source File: Math.c 140
The Component Information (.inf) File: Math.inf 154
Convert ASCII to Unicode and Back: Uni Code Decode 154
The Source File: Uni Code Decode.c 155
The Component Information (.inf) File 163
Chapter 11 Managing UEFI Drivers Using the Shell 165
Testing Specific Protocols 166
Loading and Unloading UEFI Drivers 167
Load 168
Load Pci Rom 168
Unload 169
Connecting UEFI Drivers 169
Connect 169
Disconnect 170
Reconnect 170
Driver and Device Information 171
Drivers 171
Devices 172
Dev Tree 172
Dh –d 173
Open Info 173
Testing the Driver Configuration and Driver Diagnostics Protocols 174
Drv Cfg 174
Drv Diag 174
Debugging Code Statements 175
POST Codes 177
Post Card Debug 178
Text-Mode VGA Frame Buffer 179
Other Options 179
Appendix A Security Considerations 181
UEFI Shell Binary Integrity 181
Overview 181
Signed Executable Overview 182
Digital Signature 183
Signed Executable Processing 185
Signed Executable Generation Application (Sign Tool) 185
UEFI Load Image 186
Sign Tool 186
Build Environment 186
Example usage 187
Appendix B Command Reference 189
Command Profiles and Support Levels 189
Command List 189
Standardizing Command Output 192
Command Details 193
alias 193
attrib 194
bcfg 194
cd 196
cls 197
comp 197
connect 198
cp/copy 199
date 199
dblk 200
del 200
devices 200
devtree 201
dh 201
dir/ls 202
disconnect 202
dmem 203
dmpstore 204
drivers 204
drvcfg 205
drvdiag 206
echo 206
edit 207
eficompress 207
efidecompress 207
exit 207
for 208
getmtc 209
goto 209
help 209
hexedit 210
if 210
ifconfig 214
ifconfig6 214
load 215
loadpcirom 216
ls 216
map 217
md 218
mem 218
memmap 218
mkdir 219
mm 219
mode 220
mv 220
openinfo 220
parse 221
pause 221
pci 221
ping 222
ping6 222
reconnect 223
reset 223
rm 224
sermode 224
set 225
setsize 226
setvar 226
shift 227
smbiosview 227
stall 228
time 228
time 229
touch 229
type 230
unload 230
ver 230
vol 230
Appendix C Programming Reference 233
Script-based Programming 233
Parameter Passing 233
Redirection and Piping 234
Return Codes 235
Environment Variables 236
Non-Script-based Programming 237
Shell Protocol 238
Shell Parameters Protocol 240
Appendix D UEFI Shell Library 241
Functions 241
File I/O Functions 241
Miscellaneous Functions 242
Command Line Parsing 243
Text I/O 244
String Functions 244
Shell Close File() 245
Shell Close File Meta Arg() 246
Shell Command Line Check Duplicate() 246
Shell Command Line Free Var List() 247
Shell Command Line Get Count() 247
Shell Command Line Get Flag() 248
Shell Command Line Get Value() 248
Shell Command Line Get Raw Value() 249
Shell Command Line Parse Ex() 250
Shell Copy Search And Replace() 251
Shell Convert String To Uint64() 252
Shell Create Directory() 253
Shell Delete File() 254
Shell Delete File By Name() 254
Shell Execute() 255
Shell File Exists() 257
Shell File Handle Return Line() 257
Shell File Handle Read Line() 258
Shell Find File Path() 259
Shell Find File Path Ex() 260
Shell Find First File() 260
Shell Find Next File() 261
Shell Flush File() 262
SHELL_FREE_NON_NULL() 263
Shell Get Current Dir() 263
Shell Get Environment Variable() 264
Shell Get Execution Break Flag() 265
Shell Get File Info() 265
Shell Get File Position() 266
Shell Get File Size() 266
Shell Hex Str To Uintn() 267
Shell Initialize() 268
Shell Is Decimal Digit Character() 268
Shell Is Directory() 269
Shell Is File() 269
Shell Is File In Path() 270
Shell Is Hexa Decimal Digit Character() 270
Shell Is Hex Or Decimal Number() 271
Shell Open File By Device Path() 271
Shell Open File By Name() 273
Shell Open File Meta Arg() 274
Shell Print Ex() 275
Shell Print Help() 276
Shell Print Hii Ex() 277
Shell Prompt For Response() 278
Shell Prompt For Response Hii() 279
Shell Read File() 281
Shell Set File Info() 282
Shell Set File Position() 283
Shell Set Environment Variable() 284
Shell Set Page Break Mode() 285
Shell Str To Uintn() 285
Shell Write File() 286
Strn Cat Grow() 287
Data Structures 288
Format Strings 288
Shell Parameters 289
Index 291
Yazar hakkında
Michael Rothman (Intel, chair of the UEFI Configuration and UEFI Shell sub-teams), Vincent Zimmer (Intel, chair of the UEFI networking sub-team and security sub-team), and Tim Lewis (Insyde Software, chair of the UEFI security sub-team).