搜尋此網誌

顯示具有 EFI/UEFI開發設計 標籤的文章。 顯示所有文章
顯示具有 EFI/UEFI開發設計 標籤的文章。 顯示所有文章

2019年4月10日 星期三

Developer's UEFI Emulation (DUET) on Edk2 for Boot Disk

Developer's UEFI Emulation (DUET) on Edk2

From: https://github.com/tianocore/edk2/raw/master/DuetPkg/ReadMe.txt

A. Build DUET image on Windows Platform
========================================
1. Tools preparation

  To build DUET image, Visual Studio is required:
  1). Base on below link to create Visual Studio build environment.
      https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems

2. Build Duet Platform module

  1). run cmd.exe to open command line window.
  2). enter workspace root directory such as c:\edk2_tree
  3). set the environment variable EDK_TOOLS_BIN to point at the BaseTools binaries directory
      i.e., "set EDK_TOOLS_BIN=c:\edk2-BaseTools-win32"
  4). run "edksetup.bat"
  5). run "build -p DuetPkg\DuetPkgIa32.dsc -a IA32 -t VS2015x86" for IA32 architecture platform (using 64-bit VS2015 for example) or
          "build -p DuetPkg\DuetPkgX64.dsc -a X64 -t VS2015x86" for X64 architecture platform.

  NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command.


Create bootable disk
======================

3. Create boot disk
  The following steps are same for IA32 architecture platform or X64 architecture platform.

3.1 Create floppy boot disk
  1). enter \DuetPkg directory.
  2). Insert a floppy disk to drive
  3). run "CreateBootDisk.bat floppy a: FAT12 IA32" if floppy drive is a: disk and Arch to boot is IA32.
      or
      run "CreateBootDisk.bat floppy a: FAT12 X64" if floppy drive is a: disk and Arch to boot is X64.
3.2 Create usb boot disk
  1). enter \DuetPkg directory.
  2). Plugin usb disk
  3). run "CreateBootDisk.bat usb e: FAT16 IA32" if usb drive is e: and FAT format is FAT16 and Arch to boot is IA32.
      or "CreateBootDisk.bat usb e: FAT16 X64" if usb drive is e: and FAT format is FAT16 and Arch to boot is X64.
      or "CreateBootDisk.bat usb e: FAT32 IA32" if usb drive is e: and FAT format is FAT32 and Arch to boot is IA32.
      or "CreateBootDisk.bat usb e: FAT32 X64" if usb drive is e: and FAT format is FAT32 and Arch to boot is X64.
  4). UnPlug usb disk and plugin it again.
  5). run "CreateBootDisk.bat usb e: FAT16 IA32 step2" if usb drive is e: and FAT format is FAT16 and Arch to boot is IA32.
      or "CreateBootDisk.bat usb e: FAT16 X64 step2" if usb drive is e: and FAT format is FAT16 and Arch to boot is X64.
      or "CreateBootDisk.bat usb e: FAT32 IA32 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is IA32.
      or "CreateBootDisk.bat usb e: FAT32 X64 step2" if usb drive is e: and FAT format is FAT32 and Arch to boot is X64.

B. Build DUET image on Linux Platform
======================================
1. Tools preparation

  To build DUET image, GCC installation (4.4+) is required:
  1). Base on below link to create GCC build environment.
      https://github.com/tianocore/tianocore.github.io/wiki/Using-EDK-II-with-Native-GCC

2. Build Duet Platform module

  1). Open the terminal.
  2). enter workspace root directory such as /edk2_tree
  3). run ". edksetup.sh BaseTools"
  4). run "build -p DuetPkg/DuetPkgIa32.dsc -a IA32 -t GCC49" for IA32 architecture platform (using GCC 4.9 for example) or
          "build -p DuetPkg/DuetPkgX64.dsc -a X64 -t GCC49" for X64 architecture platform.

  NOTE: The post build script 'PostBuild.sh' will be automatically called after the build command.
        After post build action, you should check the size of EfiLdr at $WORKSPACE/Build/DuetPkgIA32(DuetPkgX64)/DEBUG_GCC49 directory, it must less than 470k.
        If not, you should manually remove some unnecessary drivers at DuetPkg.fdf file.

3. Create bootable disk
   The following steps are same for IA32 architecture platform or X64 architecture platform.

3.1 Create floppy boot disk
  1). enter /edk2_tree/DuetPkg directory.
  2). Insert a floppy disk to drive
  3). run "CreateBootDisk.sh" to build floppy drive
      such as "./CreateBootDisk.sh floppy /media/floppy0 /dev/fd0 FAT12 IA32"

3.2 Create usb boot disk
  1). enter /edk2_tree/DuetPkg directory.
  2). Plugin usb disk
  3). run "CreateBootDisk.sh" to build usb drive
      such as "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32"
  4). UnPlug usb disk and plugin it again.
  5). run "./CreateBootDisk.sh usb /media/usb0 /dev/sdb0 FAT16 IA32 step2"

2017年12月18日 星期一

UDK2017 How to Build

From: https://github.com/tianocore/tianocore.github.io/wiki/UDK2017-How-to-Build

HOW TO BUILD (WINDOWS SYSTEM)
The steps below are verified on Microsoft Windows 10 Enterprise*:

1. Setup Build Environment
  • Install Microsoft Visual Studio 2015* in the build machine and make sure that AMD64 complier was selected when installing.
  • Download NASM 2.0.7 or later from http://www.nasm.us/ and install it to C:\Nasm. Make sure C:\Nasm is added to system environment variable 'PATH'
  • Set up for using GitHub for Windows. See: https://github.com/tianocore/tianocore.github.io/wiki/Getting-Started-with-EDK-II#github-help
  • Download and install Python2.7.x https://www.python.org/ for building the BaseTools Default install directory is: C:/Python27
2. Create the full Source Code directory for the UDK2017 release
(1). Create a working space directory in the build machine, for example, C:\MyWorkspace
(2). Download the official UDK2017 release .zip file from the UDK2017 Release Page
a. Download - UDK2017 edk-vUDK2017 Workspace Source code (zip file)
b. Extract files in [edk2-vUDK2017] to the working space directory C:\MyWorkspace.
(3). OR Checkout the vUDK2017 Tag from GitHub with the following "git" command run git clone https://github.com/tianocore/edk2.git vUDK2017 Move all files and folders under "vUDK2017" to "C:\MyWorkspace" Optional (See Compile the BaseTools below) Checkout BaseTools binaries and copy them to BaseTools binary folder. Warning the Windows* Binary tools are only valid for the tip of the https://github.com/tianocore/edk2 repository.
a. Cd C:\MyWorkspace
b. Run git clone https://github.com/tianocore/edk2-BaseTools-win32.git
c. Enter folder edk2-BaseTools-win32
d. Run the command git checkout 0e088c19ab31fccd1d2f55d9e4fe0314b57c0097
e. Cd C:\MyWorkSpace
f. Rename this folder from edk2-BaseTools-win32 to win32, then copy the win32 directory into the BaseTools/Bin directory under the workspace. (e.g. "C:\MyWorkspace\BaseTools\Bin")
3. Generate OpenSSL* Crypto Library
(1). Open file "C:\MyWorkspace\CryptoPkg\Library\OpensslLib\OpenSSL-HOWTO.txt" and follow the instruction to install OpenSSL* for UEFI building. For this release, please use OpenSSL-1.1.0e.
4. Compile the BaseTools (Skip if Optional Step 2.iv was done above) See: https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems#compile-tools
(1). Open a Microsoft Visual Studio* command prompt, type cd C:\MyWorkspace to enter the workspace directory
(2). Compile the BaseTools C source tools
set PYTHON_HOME=C:\Python27
        set EDK_TOOLS_PATH=%CD%\BaseTools
        BaseTools\toolssetup.bat Rebuild
5. Build Steps *** NT32 ***
(1). Open a Microsoft Visual Studio* command prompt, type cd C:\MyWorkspace to enter the workspace directory
(2). Use edksetup.bat command to initialize the working environment. edksetup --nt32
(3). Type following command to build Nt32 platform build -t VS2015x86
(4). Upon the build completing successfully there should be the UEFI Application "HelloWorld.efi" in the C:\MyWorkspace\Build\MdeModule\DEBUG_VS2015x86\IA32 directory

2016年8月5日 星期五

Create a Pop Up box in Hii(Human Interface Infrstructure)

u16 i;
EFI_INPUT_KEY                   Key;
DEBUG_PRINT (("Key scan.........\n"));
do {
    CreatePopUp (
        EFI_LIGHTGRAY | EFI_BACKGROUND_RED,
        &Key,
        L"",
        L"Would you like to create this virtual disk?",
        L"         [Yes]               [No]         ",
        L"",
        NULL
    );
    DEBUG_PRINT (("Unicode=0x%x, ScanCode=0x%x <%c>\n", Key.UnicodeChar, Key.ScanCode, Key.UnicodeChar));
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));

Print Messages:
Unicode=0x79, ScanCode=0x0
Unicode=0x59, ScanCode=0x0
Unicode=0x6E, ScanCode=0x0
Unicode=0x4E, ScanCode=0x0

ScanCode=0x0(SCAN_NULL)

//
// EFI Console Colours
//
#define EFI_BLACK                 0x00
#define EFI_BLUE                  0x01
#define EFI_GREEN                 0x02
#define EFI_CYAN                  (EFI_BLUE | EFI_GREEN)
#define EFI_RED                   0x04
#define EFI_MAGENTA               (EFI_BLUE | EFI_RED)
#define EFI_BROWN                 (EFI_GREEN | EFI_RED)
#define EFI_LIGHTGRAY             (EFI_BLUE | EFI_GREEN | EFI_RED)
#define EFI_BRIGHT                0x08
#define EFI_DARKGRAY              (EFI_BRIGHT)
#define EFI_LIGHTBLUE             (EFI_BLUE | EFI_BRIGHT)
#define EFI_LIGHTGREEN            (EFI_GREEN | EFI_BRIGHT)
#define EFI_LIGHTCYAN             (EFI_CYAN | EFI_BRIGHT)
#define EFI_LIGHTRED              (EFI_RED | EFI_BRIGHT)
#define EFI_LIGHTMAGENTA          (EFI_MAGENTA | EFI_BRIGHT)
#define EFI_YELLOW                (EFI_BROWN | EFI_BRIGHT)
#define EFI_WHITE                 (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)

#define EFI_TEXT_ATTR(f, b)       ((f) | ((b) << 4))

#define EFI_BACKGROUND_BLACK      0x00
#define EFI_BACKGROUND_BLUE       0x10
#define EFI_BACKGROUND_GREEN      0x20
#define EFI_BACKGROUND_CYAN       (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
#define EFI_BACKGROUND_RED        0x40
#define EFI_BACKGROUND_MAGENTA    (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
#define EFI_BACKGROUND_BROWN      (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
#define EFI_BACKGROUND_LIGHTGRAY  (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)

//
// EFI Scan codes
//
#define SCAN_NULL       0x0000
#define SCAN_UP         0x0001
#define SCAN_DOWN       0x0002
#define SCAN_RIGHT      0x0003
#define SCAN_LEFT       0x0004
#define SCAN_HOME       0x0005
#define SCAN_END        0x0006
#define SCAN_INSERT     0x0007
#define SCAN_DELETE     0x0008
#define SCAN_PAGE_UP    0x0009
#define SCAN_PAGE_DOWN  0x000A
#define SCAN_F1         0x000B
#define SCAN_F2         0x000C
#define SCAN_F3         0x000D
#define SCAN_F4         0x000E
#define SCAN_F5         0x000F
#define SCAN_F6         0x0010
#define SCAN_F7         0x0011
#define SCAN_F8         0x0012
#define SCAN_F9         0x0013
#define SCAN_F10        0x0014
#define SCAN_F11        0x0015
#define SCAN_F12        0x0016

#define SCAN_ESC        0x0017

2016年1月18日 星期一

UDK2014 How to Build

UDK2014 - How to build instructions
Download the UDK2014 Release with expanded workspace directories DownLoad

UDK2014 Release Files / Directories

What is included in the Downloaded zip file
  • UDK2014.MyWorkSpace.zip
  • BaseTools(Windows).zip
  • BaseTools(Unix).tar
  • Documents
  • Notes

Windows System Configuration

Microsoft Windows 7 Ultimate 64-bit*
1. Setup Build Environment
  • 1) Install Microsoft Visual Studio 2008* SP1 in the build machine and make sure that AMD64 complier was selected when installing.
2. Extract Common Source Code
  • 1) Extract files in [UDK2014.MyWorkSpace.zip] to the working space directory (e.g C:). Note the Directory "MyWorkSpace" will be created as a result. In this case, it is C:\MyWorkspace.
  • 2) There are two BaseTools package one is for Windows system and another is for UNIX-Like system. Please make sure BaseTools(Windows).zip is used here. Expand the appropriate BaseTools to C:\MyWorkSpace
3. Generate OpenSSL* Crypto Library Note: this does not need to be done for Nt32
  • Open file "C:\MyWorkspace\CryptoPkg\Library\OpensslLib\Patch-HOWTO.txt" and follow the instruction to install OpenSSL* for UEFI building.

http://ftp.vim.org/security/openssl/

=====================================================================
                                OpenSSL-Version
=====================================================================
  Current supported OpenSSL version for UEFI Crypto Library is 1.0.2d.
    http://www.openssl.org/source/openssl-1.0.2d.tar.gz
=====================================================================
                      HOW to Install Openssl for UEFI Building
=====================================================================
1.  Download OpenSSL 1.0.2d from official website:
    http://www.openssl.org/source/openssl-1.0.2d.tar.gz

    NOTE: Some web browsers may rename the downloaded TAR file to openssl-1.0.2d.tar.tar.
          When you do the download, rename the "openssl-1.0.2d.tar.tar" to
          "openssl-1.0.2d.tar.gz" or rename the local downloaded file with ".tar.tar"
          extension to ".tar.gz".

2.  Extract TAR into CryptoPkg/Library/OpenSslLib/openssl-1.0.2d

    NOTE: If you use WinZip to unpack the openssl source in Windows, please
          uncheck the WinZip smart CR/LF conversion option (WINZIP: Options -->
          Configuration --> Miscellaneous --> "TAR file smart CR/LF conversion").

3.  Apply this patch: EDKII_openssl-1.0.2d.patch, and make installation

    For Windows Environment:
    ------------------------
    1) Make sure the patch utility has been installed in your machine.
       Install Cygwin or get the patch utility binary from
          http://gnuwin32.sourceforge.net/packages/patch.htm
    2) cd $(WORKSPACE)\CryptoPkg\Library\OpensslLib\openssl-1.0.2d
    3) patch -p0 -i ..\EDKII_openssl-1.0.2d.patch
    4) cd ..
    5) Install.cmd

    For Linux* Environment:
    -----------------------
    1) Make sure the patch utility has been installed in your machine.
       Patch utility is available from http://directory.fsf.org/project/patch/
    2) cd $(WORKSPACE)/CryptoPkg/Library/OpensslLib/openssl-1.0.2d
    3) patch -p0 -i ../EDKII_openssl-1.0.2d.patch
    4) cd ..
    5) ./Install.sh
=====================================================================

4. Build Steps *** NT32 ***
  • 1) Open a command prompt, type command "cd C:\MyWorkspace" to enter the workspace directory, and then type command
> edksetup --nt32
to initialize the working environment. See also: Windows_systems_ToolChain_Matrix for how to change the TOOL_CHAIN_TAG for supported compiler combinations.
  • 2) Type below commands to build platforms (below assumes Microsoft Visual Studio 2008)
> build -t VS2008x86
Note: There are two methods to select the tool chain (Use Microsoft Visual Studio 2008* as sample):
  • 1. Update TOOL_CHAIN_TAG in file Conf/target.txt: TOOL_CHAIN_TAG = VS2008
  • 2. Add -t build option in command line: "build -t VS2008 ... "
For 32-bit VS2008 on 64-bit WINDOWS OS, VS2008x86 should be selected instead of VS2008. Please refer to tools_def.txt for all supported tool chains and detailed descriptions. (tools_def.txt will be generated at Conf directory after running "edksetup".)
  • 3. Note Microsoft Visual Studio* 2010 is supported with -t VS2010 or -t VS2010x86


Unix-Like System Configuration

Ubuntu
DistributorID: Ubuntu*
Description: Ubuntu 10*
Release: Ubuntu 10.10*
Codename: Karmic*
1. Extract Common Source Code
  • 1) Create a working space directory in the build machine, for example, ~/src/
  • 2) Extract files in [UDK2014.MyWorkSpace.zip] the working space directory. In this case, it is ~/src/MyWorkSpace where /MyWorkSpace is created.
  • 3) There are two BaseTools packages, one is for Windows system and another is for UNIX-Like system. Please make sure BaseTools(Unix).tar is used here.
2. Generate OpenSSL* Crypto Library Note: This does not need to be done for Nt32 Open file "~/src/MyWorkspace/CryptoPkg/Library/OpensslLib/Patch-HOWTO.txt" and follow the instruction to install OpenSSL* for UEFI building.
3. See How to Set up Build environment Using EDK II with Native GCC for newer versions of Linux
  • a) Please note that here the root is "~/src/MyWorkSpace" instead of "~/src/edk2"
  • b) Make sure BaseTools is built and required software like iASL compiler is installed well.
  • c) Some operations need switch to user "root" to execute.
4. Build Steps *** Nt32 ***
  • 1) Open a terminal and type "cd ~/src/MyWorkSpace" to enter the workspace directory.
  • 2) Initialize the build environment by typing
>. edksetup.sh BaseTools
  • 3) Type below commands to build platforms
> build -t GCC44

2014年12月7日 星期日

Using EDK II with Native GCC in Ubuntu 13.04



  • The Ubuntu platform is not officially supported or tested by the edk2 project at this time.
  • Both the x86 (32-bit) and x86-64 (64-bit) Ubuntu versions will install GCC 4.8 which is capable of building UEFI for both the IA32 and X64 architectures.
  • These instructions should work for Ubuntu 10.10 as well

Open the GNOME Terminal program
These instructions will utilize Ubuntu's built in command shell (bash) via the GNOME Terminal application. To open the Terminal application, locate it under the Applications menu and the Accessories sub-menu.

Install required software from apt
Several ubuntu packages will be needed to fully set up an edk2 build environment. In order to easily install all the requirements, you need to run this command.

bash$ sudo apt-get install build-essential subversion uuid-dev iasl
bash$ sudo apt-get install nasm
Continue with common instructions

The remaining instructions are common for most UNIX-like systems.

Common instructions
A significant portion of the steps are common on the various UNIX-like platforms. You should start with the instructions for the operating system that most closely matches your platform, and it will direct you here at the appropriate time.

Get the edk2 source tree
bash$ mkdir ~/src
bash$ cd ~/src
bash$ git clone https://github.com/tianocore/edk2
======================================================
Or, download source using subversion:
If you are behind a web proxy, then you may need to configure your proxy in the ~/.subversion/servers file.
bash$ mkdir ~/src
bash$ cd ~/src
bash$ svn co https://svn.code.sf.net/p/edk2/code/trunk/edk2
======================================================
Build the EDK II BaseTools
bash$ make -C edk2/BaseTools

Setup build shell environment
bash$ cd ~/src/edk2
bash$ export EDK_TOOLS_PATH=$HOME/src/edk2/BaseTools
bash$ . edksetup.sh BaseTools

Modify Conf Files
You will need to edit the Conf/tools_def.txt and Conf/target.txt files. These changes will enable the MdeModulePkg to be built using the GCC 4.4 compiler.

Set Build Target Information
For the Conf/target.txt file, find the following lines:

ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc
TOOL_CHAIN_TAG        = MYTOOLS
And change the corresponding lines to match these:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG        = GCC48
Note: The 'gcc --version' command can be used to find out your GCC version. Use the GCC45 toolchain for gcc 4.5.* and the GCC46 toolchain for gcc 4.6.*.

Optionally, you may consider finding:

TARGET_ARCH           = IA32
...and changing it if your GCC 4.4 installation supports 64-bit builds. You can change it to either 'X64', or even 'IA32 X64' which will build both architectures.

Build Hello World! (and the rest of MdeModulePkg)
Now you should be able to simply run the build command to compile the MdeModulePkg.

bash$ build
One result of the build is that you should have the HelloWorld UEFI application:

bash$ ls Build/MdeModule/DEBUG_*/*/HelloWorld.efi
*: IA32 or X64


[Build OVMF]
Once your build environment is set up you might be interested in building the OVMF platform which is included in the main edk2 source tree. Since OVMF builds a full system firmware image this may be of interest to UEFI system firmware developers.

OVMF is an EDK II based project to enable UEFI support for Virtual Machines.

2014年11月25日 星期二

EFI Shell Protocol Information Table

Protocol Symbol
UEFI Protocol
BlkIo
Block I/O Protocol
BusSpecificDriverOverride
Bus Specific Driver Override Protocol
ComponentName
Component Name Protocol
Configuration
Driver Configuration Protocol
ConIn
Console-in Device
ConOut
Console-out Device
DebugPort
Debugport Protocol
DebugSupport
Debug Support Protocol
Decompress
Decompress Protocol
DevIo
Device I/O Protocol
Diagnostics
Driver Diagnostics Protocol
DiskIo
Disk I/O Protocol
Dpath
Device Path Protocol
DriverBinding
Driver Binding Protocol
ErrOutSplit
Error-out Splitter Protocol
Fs
Simple File System Protocol
Image
Loaded Image Protocol
IsaAcpi
ISA ACPI Protocol
IsaIo
ISA I/O Protocol
LegacyBoot
Legacy Boot Protocol
Load
Load File Protocol
Net
Simple Network Protocol
Nii
Network Interface Identifier Protocol
PciIo
PCI I/O Protocol
PciRootBridgeIo
PCI Root Bridge I/O Protocol
Pxebc
PXE Base Code Protocol
ScsiIo
SCSI I/O Protocol
ScsiPassThru
SCSI Pass Thru Protocol
SerialIo
Serial I/O Protocol
SimplePointer
Simple Pointer Protocol
StdErr
Standard Error Device
Tcp
TCP Protocol
Txtin
Simple Text-in Protocol
TxtInSplit
Text-in Splitter Protocol
Txtout
Simple Text Output Protocol
TxtOutSplit
Text-out Splitter Protocol
UgaDraw
UGA Draw Protocol
UgaIo
UGA I/O Protocol
UnicodeCollation
Unicode Collation Protocol
UsbIo
USB I/O Protocol
VgaClass
VGA Class Driver Protocol