I. Overview: 0. Why this article
Honestly, at the beginning of 2016, I started to write an operating system idea, but this for me a rookie, like the sky.
Since you want to write, even if the last do not finish, also do not regret.
Holding this idea, I began to look at a variety of writing operating system books, and finally I came to the conclusion that first try to write a bootloader, so as the BIOS successor, UEFI into my research scope.
Why choose Uefi, there are two main considerations:
One is that UEFI has a very powerful function
Another is that this is a new technology, mastered it, perhaps for the future work and other opportunities to provide some help!
1. Book Introduction:
The book looks like this:
If you are interested, you can also read, the money to buy, no money on the library to borrow, and then the Internet search PDF format self-download.
The difference between 2.BIOS and UEFI
When you read this, I don't know if you're familiar with some of the processes and problems with the system, but it's good to say something more in this place.
Since WINDOWS8, if you use the original Microsoft image installed and your machine itself support EFI, the default will be installed in UEFI mode, which is prone to problems,
The premise is that the original machine installed in the old version of the Windows system and the motherboard default on the EFI function, you adjust the boot entry for the installation of media (CD, USB, etc.), the computer is open, then the PC reads the BOOTMGR.EFI in the media, such as
Without your knowledge, choose to continue, the installer may prompt you, the partition you want to install is not GPT format? Unable to continue ...
The main reason for this is that the original computer is using the BIOS+MBR installation method, but you use the UEFI+GPT installation, the simplest way is to turn off the UEFI function to let the computer load bootmgr by default, Instead of Bootmgr.efi, about how the BIOS set this problem, it is not here to repeat, self-baidu brain repair!
From here we derive two combinations:
Bios+mbr
Uefi+gpt
Yes, you can think of them as complementary, the former traditional and the latter more advanced.
The advanced nature here has its advantages, transcription time to O (∩_∩) o haha ~
1. High development efficiency
2. High scalability
3. More powerful performance
4. Higher security
5. More adaptable to 64-bit platforms
Want to find more advantages can find books, or ask Niang, than I said in detail.
Attach a picture of the book as an understanding of the UEFI startup process:
UEFI defines the interface between the operating system and the platform firmware. The Uefi interface can be divided into the following two sections:
1) Start-up service: Mainly includes event service, memory management, Protocol management, Protocol service, drive management, image management, and exitbootservices service.
2) Runtime Services: Time service, services that read and write UEFI system variables, virtual memory services, service to restart the system.
The overview of Uefi says so much, too many words are not easy to remember, and do not help to understand.
Second, the construction of the environment
I am using WINDOWS10 Enterprise and vs2013, in addition to the following Software SDK, EDK2 (UDK2015), IASL compiler
The recommended steps are as follows:
1. Download the decompression configuration EDK2:
Download page: https://sourceforge.net/projects/edk2/files/UDK2015_Releases/UDK2015/
: Https://sourceforge.net/projects/edk2/files/UDK2015_Releases/UDK2015/UDK2015.Complete.MyWorkSpace.zip/download
After the download is complete, the internal structure is as follows:
In the figure, Basetools (Windows). zip and UDK2015.MyWorkSpace.zip are what we will use, and the order of decompression is as follows:
Create a folder in the root directory of the C drive: EDK2
Unzip the files in the two compressed packages to EDK2
Edksetup.bat in the EDK2 directory, the configuration file is generated in conf in the directory
In Target.txt, modify the behavior of Tool_chain_tag this way:
Tool_chain_tag = VS2013
Then open Tools_def.txt and find the following information about the SDK:
# Microsoft Visual Studio Professional Edition
DEFINE winsdk8_bin = C:\Program Files\Windows kits\8.0\bin\x86\
DEFINE Winsdk8x86_bin = C:\Program Files (x86) \ Windows kits\8.0\bin\x64
From here you can see that we should download and install sdk8.0
But the Microsoft website gives the following description:
The Windows Software Development Kit (SDK) contains headers, libraries, and tools can use when you create apps that Ru N on Windows operating systems. With the Windows SDK, you can begin building Universal Windows apps and desktop apps for Windows, Version 1511. This SDK also supports building Windows apps and desktop applications for Windows 8.1, Windows 8, Windows 7, Windows Vista Windows Server, Windows Server R2, and Windows Server 2008.
From here we know to download Win10 SDK.
2. Installing the SDK for Windows
: HTTPS://DEVELOPER.MICROSOFT.COM/EN-US/WINDOWS/DOWNLOADS/WINDOWS-10-SDK
After the installation is complete, I proceed to the next step
3. Install the IASL compiler:
Official website: https://www.acpica.org/downloads
Open a date on the right:
Pull to the bottom of the page, we can find the compiler download link
: Https://acpica.org/sites/acpica/files/iasl-win-20160422.zip
After that, unzip the tools inside to C:/ASL (create a new folder).
4. Continue to the EDK settings:
Locate Tools_def.txt in the Conf folder, and then modify the following items:
DEFINE vs2013_bin = D:\soft\Microsoft Visual Studio 12.0\vc\bin
DEFINE Vs2013_dll = D:\soft\Microsoft Visual Studio 12.0\common7\ide;def (vs2012_bin)
DEFINE vs2013_binx64 = DEF (vs2013_bin) \x86_amd64
DEFINE vs2013x86_bin = D:\soft\Microsoft Visual Studio 12.0\vc\bin
DEFINE Vs2013x86_dll = D:\soft\Microsoft Visual Studio 12.0\common7\ide;def (vs2013x86_bin)
DEFINE vs2013x86_binx64 = DEF (vs2013x86_bin) \x86_amd64
DEFINE Win_asl_bin_dir = C:\ASL
Of course I vs2013 installed in the D disk, IASL placed in the C drive, so there will be, change the path after the save.
5. Compiling the UEFI emulator and engineering
Locate the VS2013 folder in the Start menu and open the "VS2013 developer Tips"
Switch to the EDK2 directory:
If you compile nt32pkg
Perform:
Edksetup.bat--nt32
Build
If you compile the NT32PKG project
Perform
Edksetup.bat
Build plus the required parameters
At this point, the environment is well equipped!
6. Run the emulator:
Using the command build run
Come to Zhang:
"Reading notes" UEFI Principles and Programming (1) Overview and construction of the development environment