USB启动加载程序 [英] USB bootloading procedure

查看:69
本文介绍了USB启动加载程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


你好, 

Hello, 


       我以前在我的课程项目中编写了自己的基本内核。现在我正在弄清楚如何编写启动加载程序。

        I have previously written my own basic kernel in my class project. Now I am figuring out how to write a boot loader.


我看过编写引导加载程序以从软盘加载操作系统的示例,但是软盘已经过去,我想学习如何访问USB,并尝试从USB加载我的内核。我知道Usb架构是最复杂的架构之一,但我很感激,如果
任何人都可以指导我找到一个好的源/示例代码(除了600页的USB 2.0 / 3.0规范手册)。如果可能的话,知道Microsoft如何引导其内核(使用ntdlr ??)会很棒。

I seen examples where boot loaders are written to load the OS from floppies, but floppies are past, and I want to learn how to access USB , and try loading my kernel from USB. I know that Usb architecture is one of the most complex, But I would appreciate if anyone could direct me to a good source/sample code (other than the 600 page of USB 2.0/3.0 specification manual). Also if possible,  it would be great to know how Microsoft boots its kernel (Using ntdlr??).

推荐答案

USB驱动器大多数时候被视为可移动硬盘。因此,从USB驱动器启动的方式与从硬盘启动的方式相同。

A USB drive is seen as a removable hard disk most of the time. So the way you would boot from a USB drive is the same way as you would boot from a hard disk.

如果您回顾过去一点点,您可以看到这一点。从USB驱动器启动Windows PE。适用于Windows 8的Windows ADK包含一个小工具可供帮助,但对于Windows 7,您必须自己执行此操作。

You can see this if you look back in time a little at the way to boot Windows PE from a USB drive. The Windows ADK for Windows 8 includes a little tool to help, but for Windows 7 you had to do this yourself.

这方面的一般说明是在USB驱动器上,清除任何分区它,创建一个主分区,格式化FAT32,然后将其设置为活动。当您将文件复制到闪存驱动器(包括Windows Vista +引导加载程序,
bootmgr)时,它只会启动。

The general instructions for this was on a USB drive, clean any partitions from it, create a primary partition, format it FAT32 and then set it as active. When you copied the files onto the flash drive, which included the Windows Vista+ boot loader, bootmgr, it would just boot.

之所以这样做是因为这种方式BIOS开始启动系统。首先,它将当前所选引导盘的扇区0加载到内存中,然后执行它。然后,这将检查哪个分区处于活动状态,然后将该分区的第一个
扇区加载到内存中,然后执行它。然后,此代码将搜索bootmgr,将其加载到内存中然后执行它。 Ntldr的工作方式与bootmgr相同。所以简单地说,如果你知道如何从硬盘启动,那么
就可以从USB驱动器启动了。

The reason why this worked was because of the way the BIOS started booting the system. First it loads sector 0 of the currently selected boot disk into memory, then executes it. This would then check to see which partition is active and then loads the first sector of that partition into memory, and then executes it. This code would then do the search for bootmgr, load it into memory and then execute it. Ntldr worked in the same way as bootmgr. So simply put, if you know how to boot off of a hard disk, you can boot off of a USB drive.

当然,这忽略了UEFI,但是这比BIOS启动简单。当它启动引导过程时,它会在当前选定的引导驱动器上的/ efi / boot中查找名为boot< platform> .efi的文件。实际上,从硬盘启动比使用EFI从USB驱动器启动要困难了。

Of course, this is ignoring UEFI, but that is simpler than the BIOS booting. When it starts the boot process, it looks in /efi/boot on the currently selected boot drive for a file with a name boot<platform>.efi. In fact, booting from a hard disk is harder than booting from a USB drive using EFI.

无论如何,对于这样的事情,我总是想看看< a href ="http://wiki.osdev.org/">
osdev wiki 。它包含许多有关编写自己的操作系统的有用信息。

Anyway, for things like this, I always like to take a look at the osdev wiki. It contains a lot of helpful information on writing your own OS.


这篇关于USB启动加载程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆