搜尋此網誌

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

2017年3月8日 星期三

Check Legacy BIOS Image from UEFi Shell

//The program is for searching and dumping Legacy BIOS Image between 0 to 1M system Memory.
EFI_STATUS
EFIAPI
InitializeUIApplication (
    IN EFI_HANDLE           ImageHandle,
    IN EFI_SYSTEM_TABLE     *SystemTable
) {
    EFI_STATUS Status = EFI_SUCCESS;
    EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
    {
        UINT64 addr, offset;
        UINT16 count = 0, i;
        Print(L"Detecting....\n");
        //for (addr = 0xC0000; addr < 0xE0000; addr += 0x200)
        for (addr = 0x0000; addr < 0x100000; addr += 0x200)
{
    //Print(L"address=0x%x\n", addr);
            if (
                ((*(UINT16 *)(addr + 0x00)) == 0xAA55) &&
                ((*(UINT16 *)(addr + 0x20)) == 0x8086) && //Vendor ID
                //((*(UINT16 *)(addr + 0x22)) == 0x27D8) && //Device ID
                (1)) {
                    Print(L"Legacy BIOS is at:0x%08x\n", (UINT32)(UINT64)addr);
                    for (offset = 0; offset < 4; offset ++){
                        Print(L"%08x: ", (UINT32)(addr + offset * 0x10));
                        for (i = 0; i < 16; i ++) {
                            Print(L"%02x ", (UINT8)*((UINT8 *)addr + offset * 0x10 + i));
                        }
                        for (i = 0; i < 16; i ++) {
                            if (((UINT8)*((UINT8 *)(addr + offset * 0x10 +  i)) >= 0x20)
                                && ((UINT8)*((UINT8 *)(addr + offset * 0x10 +  i)) < 0x80))
                                Print(L"%c", (UINT8)*((UINT8 *)addr + offset * 0x10 + i));
                            else
                                Print(L".");
                        }
                        Print(L"\n");
                    }
                    count ++;
            }
        }
        if (count == 0)
            Print(L"No found any BIOS image.\n");
    }
    {
         Print(L"System BIOS remaining memory[0040h:0013h]=0x%x(%d KBytes)\n", *(UINT16 *)0x413, *(UINT16 *)0x413);
         Print(L"Length of EBDA[0040h:000Eh]=%xh:0000h=%dk\n", *(UINT16 *)0x40e, *(UINT8 *)((UINT32)*(UINT16 *)0x40e << 4));
    }
    return Status;
}