Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1304747
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4833
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2018-01-17 16:47:37

http://blog.csdn.net/u014089131/article/details/73617716
UEFI在高通平台实现
标签:

UEFI(Unified extensible firmware interface)统一的可扩展固件接口,是一种详细描述类型接口的标准。

可扩展固件接口(Extensible Firmware InterfaceEFI)是 Intel PC 固件的体系结构、接口和服务提出的建议标准。其主要目的是为了提供一组在 OS 加载之前(启动前)在所有平台上一致的、正确指定的启动服务,被看做是有近20多年历史的 BIOS 的继任者。

 

既然UEFI是为了取代BIOS的,自然有他自己的优势。

BIOS是汇编实现的,采用的是16bit 实模式寻址方式,最大支持的内存只有1M,代码易读性以及实现的功能都受到限制,而且移植起来不方便。BIOS支持的最大磁盘空间不超过2TB

UEFI克服了上述的所有缺点,采用C语言实现,分层,模块化设计,实现了CPU以及驱动的无关性。UEFI可以理解为一个完整的系统,包含了上电时序,驱动实现,os环境建立(这个os可以理解为UEFI运行独有的os,非linuxwindows),应用程序。其中应用程序支持网络配置,类shell环境,fastbootlinux loader等。


其中UEFI中涉及的名词缩写:

Unified extensible firmware interface (UEFI)

SECsecurity

PEIpre EFI initialization

DXEdriver execution Environment

BDSBoot Dev Select

TSLTransient System Load

RT runtime

ALafter life

GUIDGlobally Unique Identifier

CSM : Compatibility Support Module

TCGTrusted Computing Group

PEportable executable

COFF:Common object file format

FV:Firmware Volume


对于高通的平台UEFI的实现分成了两部分:

1.    XBL包含了芯片相关的协议和关键的应用(例如充电)

2.    ABL包含了芯片无关的应用,比如fastbootlinuxloader

UEFI代码中大量使用了protocol概念,这个protocol其实指的是驱动,包含了驱动函数指针和数据。以rampatition为例:

boot_images/QcomPkg/Include/Protocol/EFIRamPartition.h中声明了了rampatition protocol

typedef

EFI_STATUS

(EFIAPI *EFI_RAMPARTITION_GETRAMPARTITIONS)(

   INEFI_RAMPARTITION_PROTOCOL* This,

   OUTRamPartitionEntry         *RamPartitions,

   IN OUT UINT32                 *NumPartition

   );struct_EFI_RAMPARTITION_PROTOCOL {

   UINT64                                  Revision;

  EFI_RAMPARTITION_GETRAMPARTITIONVERSION GetRamPartitionVersion;

  EFI_RAMPARTITION_GETHIGHESTBANKBIT     GetHighestBankBit;

   EFI_RAMPARTITION_GETRAMPARTITIONS       GetRamPartitions;

};

在boot_images/QcomPkg/Drivers/EnvDxe/EnvDxe.c中实现了该协议

STATIC EFI_RAMPARTITION_PROTOCOL RamPartitionProtocol =

{

  EFI_RAMPARTITION_PROTOCOL_REVISION,

  EFI_GetRamPartitionVersion,

  EFI_GetHighestBankBit,

  EFI_GetRamPartitions

};

在XBL中实现了protocol,也就是驱动,在ABL中可以直接使用。


UEFI启动流程:


对于高通平台启动过程依次为PBL->XBL->ABL.


一般用户定制化主要集中在ABL中,这部分代码树如下:

Andrioid代码路径bootable/bootloader/edk2/QcomModulePkg

├── Application

│   └── LinuxLoader

│      ├── LinuxLoader.c

│      └── LinuxLoader.inf

├── Include

│   ├── Library

│   │   ├──BoardCustom.h

│   │   ├── Board.h

│   │   ├──BootImage.h

│   │   ├──BootLinux.h

│   │   ├──BootStats.h

│   │   ├──Decompress.h

│   │   ├──DeviceInfo.h

│   │   ├── DrawUI.h

│   │   ├──FastbootMenu.h

│   │   ├── Fonts.h

│   │   ├── KeyPad.h

│   │   ├──LinuxLoaderLib.h

│   │   ├── list.h

│   │   ├──LocateDeviceTree.h

│   │   ├──MenuKeysDetection.h

│   │   ├──PartitionTableUpdate.h

│   │   ├── Recovery.h

│   │   ├── Reg.h

│   │   ├──ShutdownServices.h

│   │   ├──StackCanary.h

│   │   ├──UnlockMenu.h

│   │   ├──UpdateCmdLine.h

│   │   ├──UpdateDeviceTree.h

│   │   └──VerifiedBootMenu.h

│   └── Protocol

│      ├── EFICardInfo.h

│      ├── EFIChargerEx.h

│      ├── EFIChipInfo.h

│      ├── EFIChipInfoTypes.h

│      ├── EFIEraseBlock.h

│      ├── EFILimits.h

│      ├── EFIMdtp.h

│      ├── EFIPlatformInfo.h

│      ├── EFIPlatformInfoTypes.h

│      ├── EFIPmicPon.h

│      ├── EFIPmicVersion.h

│      ├── EFIQseecom.h

│      ├── EFIRamPartition.h

│      ├── EFIResetReason.h

│      ├── EFIRng.h

│      ├── EFIScmModeSwitch.h

│      ├── EFIUsbDevice.h

│      ├── EFIUsbEx.h

│      ├── EFIVerifiedBoot.h

│      └── UsbEx.h

├── Library

│   ├── BootLib

│   │   ├── Board.c

│   │   ├──BootLib.inf

│   │   ├──BootLinux.c

│   │   ├──BootStats.c

│   │   ├──Decompress.c

│   │   ├──DeviceInfo.c

│   │   ├── DrawUI.c

│   │   ├──FastbootMenu.c

│   │   ├── KeyPad.c

│   │   ├──LinuxLoaderLib.c

│   │   ├──LocateDeviceTree.c

│   │   ├──MenuKeysDetection.c

│   │   ├──PartitionTableUpdate.c

│   │   ├── Recovery.c

│   │   ├──ShutdownServices.c

│   │   ├──UnlockMenu.c

│   │   ├──UpdateCmdLine.c

│   │   ├──UpdateDeviceTree.c

│   │   └──VerifiedBootMenu.c

│   ├── FastbootLib

│   │   ├──FastbootCmds.c

│   │   ├──FastbootCmds.h

│   │   ├──FastbootLib.inf

│   │   ├──FastbootMain.c

│   │   ├──FastbootMain.h

│   │   ├──MetaFormat.h

│   │   ├──SparseFormat.h

│   │   ├──UsbDescriptors.c

│   │   └──UsbDescriptors.h

│   ├── StackCanary

│   │   ├──StackCanary.c

│   │   └──StackCanary.inf

│   └── zlib

│      ├── adler32.c

│      ├── inffast.c

│      ├── inffast.h

│      ├── inffixed.h

│      ├── inflate.c

│      ├── inflate.h

│      ├── inftrees.c

│      ├── inftrees.h

│      ├── zconf.h

│      ├── zlib.h

│      ├── zlib.inf

│      ├── zutil.c

│      └── zutil.h

├──QcomModulePkg.dec

├──QcomModulePkg.dsc

├──QcomModulePkg.fdf

└── Tools

    ├── app_path_set.cmm

    ├── check_paths.cmm

    ├── debug_app.cmm

    ├── elf_tools.py

    ├── image_header.py

    ├── load_uefi_dump.cmm

    ├── log_save.cmm

    ├── symbol_Load.cmm

    └── uefi_core_path_set.cmm


这部分里面主要是支持linuxloader 用来加载linux,以及fastboot。用户修改主要集中在这两个部分,入口函数LinuxLoaderEntry。

UEFI中用到几种后缀格式的文件说明:

fdf:flash definitionfile,描述flash分区地址范围

dec:package declarationfile,定义了不同模块的GUID信息

dsc:description file,主要包含需要用到的所有inf文件

inf:单个模块的编译信息,类似makefile

efi :最终编译生成的UEFI可执行文件

阅读(4204) | 评论(0) | 转发(0) |
0

上一篇:高通平台资料

下一篇:高通android bootloader

给主人留下些什么吧!~~