5.UEFI Application

来源:互联网 发布:淘宝卡价格刷单 编辑:程序博客网 时间:2024/06/10 13:53

 Contents
1.Introduction

   1.1Introduction
   1.2What is UEFI Application?
2.UEFI Shell
3.UEFI Toolkit
   3.1UEFI Toolkit Components
   3.2Programming Models
   3.3UEFI Toolkit Integration
   3.4C Library
   3.5UEFI Library
   3.6Network Components
   3.7Miscellaneous
   3.8Utilities
   3.9UEFI Hello.c
   3.10C Library Hello.c
   3.11C++ Support
4 3rd Party Libraries
   4.1Portable Embedded Graphics
   4.2PEG Components
5.Summary
 

Introduction

Introduction

• EFI Applications extend firmware

–No hardware dependence

–No OS dependence

• Portable across platforms

–Intel® IA-32, EM64T, Itanium® Architecture and XScale® technology

• Enables rapid application development

 

What is UEFI Application?

• A UEFI Loadable Image

–Loaded by UEFI loader just like drivers–Does not register protocols like drivers do–Consumes protocols–Typically user driven (exits when task completed)–Same set of interfaces available as drivers have


• Can be used for

–Platform diagnostics–Factory diagnostics–Utilities–Driver prototyping–’Platform’ applications

 

UEFI Shell(类似DOS)

• A UEFI Application

• Interactive Console Interface

• Application Launch

• Load UEFI Drivers

• Scripting Capability

• Automatic execution of startup script file

• Console redirection to files

 

UEFI Toolkit(EDK)

UEFI Toolkit Components

• Utilities

• C Library

• Network Stack

• Platform Management

• Compression

• Database

Useful tools for UEFI application development

Programming Models

• Native UEFI Model

–Uses only UEFI constructs

–Access to all UEFI constructs

–Smaller code size

• Portability Model

–Familiar programming interfaces

–Easier to port ANSI/POSIX based programs

–Larger binary image

• A single program can use both

 

UEFI Toolkit Integration

 

C Library

• FreeBSD Port

• ANSI/POSIX compliant

• System I/O - open(), read(), write(), close(), stat()

• Standard I/O - fopen(), printf(), gets(), …

• String/Char - strcmp(), isascii(), atoi(), …

• Memory - malloc(), free(), realloc(), …

• Time/Date - time(), asctime(), ctime(), …

• Math - sqrt(), pow(), sin(), log(), …

 

UEFI Library

• Lite Weight” C Library like functions

–String Functions–Memory Support Functions–CRC Support Functions–Text I/O Functions–Math Functions–Spin Lock Functions


• Specific EFI functions

–Handle and Protocol Support Functions–Device Path Support Functions

 

Network Components

• Port of FreeBSD TCP/IP stack

• Supports standard protocols –IPv4, ICMP, ARP, UDP, TCP

• Socket library interface

• Implemented as an EFI protocol

 

Miscellaneous

• SMBIOS Library

–Library routines for parsing SMBIOS tables

• Database

–btree

–Hashing

• Compression

–General purpose compression/decompression

–Gzip functionality

 

Utilities

• Network utilities – FTP client and server, ping

• Text editor

• Scripting interpreter (Python)

• Sample applications

 

UEFI Hello.c

#include "efi.h"EFI_STATUSInitializeHelloApplication (   IN EFI_HANDLE           ImageHandle,   IN EFI_SYSTEM_TABLE     *SystemTable   ){   UINTN Index;   SystemTable->ConOut->OutputString(SystemTable->ConOut,          L”Hello application started");   SystemTable->ConOut->OutputString(SystemTable->ConOut,          L"Hit any key to exit this image");    SystemTable->BootServices->WaitForEvent(          1, &(SystemTable->ConIn->WaitForKey), &Index);   SystemTable->ConOut->OutputString(SystemTable->ConOut,           L"  ");   return EFI_SUCCESS;}


aewdsa saf wefrasf adsf sdaf

C Library Hello.c

#include <atk_libc.h>#include <stdio.h>EFI_STATUSInitializeHelloLibCApplication (   IN EFI_HANDLE           ImageHandle,   IN EFI_SYSTEM_TABLE     *SystemTable   ){        InitializeLib(ImageHandle, SystemTable);        printf("Hello LibC application started");        printf("Hit C/R to exit this image");       return( getchar() );}

 

#include <atk_libc.h>#include <stdio.h>int main (int argc, char **argv ){        printf("Hello LibC application started");        printf("Hit C/R to exit this image");        return( getchar() );}

C++ Support

• No direct support

–No Global constructors and destructors

• New and Delete can be mapped to malloc/free

 

3rd Party Libraries

Portable Embedded Graphics

• Portable Embedded Graphics

–Portable graphics library for UEFI–Similar windowing components (widgets)      •        Dialog boxes     •        Progress bars, scroll bars     •        Text boxes     •        Window Management     •        Fonts     •        Bitmaps, JPEG, …

• Contact Swell Software

– http://www.swellsoftware.com

 

PEG Components

 

 

Summary

• UEFI Applications extend firmware

–Provides system independence in the pre-boot space     •        Hardware     •        Operating System     •        Platform–Intel® IA-32, EM64T, Itanium® Architecture and XScale® technology


• Large library support

• UEFI Shell provides convenient launch point

 

原创粉丝点击