5.UEFI Application

本文深入探讨了UEFI应用程序的开发,从基本概念出发,详细介绍了UEFI Shell、工具库(EDK)及其组件、编程模型、库支持等关键方面。同时,阐述了如何利用CLibrary、UEFILibrary、网络组件等工具进行UEFI应用开发,并提供了实际示例代码,如UEFIHello.c和CLibraryHello.c。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 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_STATUS
InitializeHelloApplication (
   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_STATUS
InitializeHelloLibCApplication (
   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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值