如何使用 Assembly (NASM) 将内核从 CD-ROM 加载到内存中

发布于 2024-07-21 09:10:41 字数 672 浏览 4 评论 0原文

我正在为自己编写一个引导程序和内核,引导程序和内核都将刻录在 CD-R 上,并将用作 CD-live。 它不是 Linux CD-Live 或其他东西,完全是我自己的引导加载程序和内核。 我不想使用其他 booloader(即 GRUB),所以请不要建议我使用它们。

这是我的问题: 在我的引导加载程序 ASM 代码中,我想从 CD-ROM(而不是从硬盘或软盘)将内核和内核条目加载到 RAM 中,并假设我们知道内核的确切位置CD-ROM 上(扇区号)。 据我所知,我必须使用 int 0x13, AH = 02h 它将从驱动器读取扇区到 RAM 中。 为了使用这个中断服务,我必须设置几个寄存器,我将在下面列出: 参数: 啊 02 点 要读取的 AL 扇区计数 CX 轨道 + 扇区 / 见备注 DH头 DL驱动器 ES:BX 缓冲区地址指针

我的问题是关于 DL 和 DH。为了指向第一个硬盘进行读取,我们可以将其设置为 80h,或者,对于软盘,我们可以将其设置为 00h。 但我想从 CD-ROM 读取,但我不知道 DH 和 DL 必须使用什么值。

为了从CD-ROM读取几个扇区到RAM,这是一个正确的中断(int 0x13)吗? 如果是,我应该为 DH 和 DL 设置什么值。

问候, 普利亚。

I'm writing a bootstrap and kernel for myself and both bootstrap and kernel will be burn on a CD-R and will function as a CD-live. It is not a linux CD-Live or something else,is totally my own bootloader and kernel. I do not want to use other booloaders (i.e. GRUB) so please don't suggest me to use them.

Here is my question:
In my bootloader ASM code, I want to load my kernel and kernel entry into the RAM from CD-ROM (not from hard disk or floppy disk), and lets assume that we know where the kernel located exactly on the CD-ROM (sector number).
As far as I know I have to use int 0x13, AH = 02h which will read sectors from Drive in to the RAM.
In order to use this interrupt service,I have to set couple of registers that I'll list bellow:
Parameters:
AH 02h
AL Sectors To Read Count
CX Track + Sector / See remark
DH Head
DL Drive
ES:BX Buffer Address Pointer

My problem is about DL and DH.In order to point to 1st hard drive to read from, we can set it to 80h or, for floppy disk we can set it to 00h. But I want to read from CD-ROM and I don't know what values I have to use for DH and DL.

In order to read from CD-ROM couple of sectors into to the RAM is it a right interrupt (int 0x13)? if yes, what value should I have to put for DH and DL.

Regards,
Pooria.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长不大的小祸害 2024-07-28 09:10:41

为了让 BIOS 从 CD 加载引导扇区,您需要使用 " 使 CD 可引导El Torito” 标准。

一旦你使用它,你有两个选择
A。 仿真 - BIOS 仿真软盘或硬盘驱动器,您可以通过设备 00 或设备 80 进行 INT13 调用来读取内核。
b. 该设备不进行模拟,您可以使用 INT13 ExtendedRead 函数直接从 CD 读取。

要了解这是如何完成的,请查看 Linux“ISOLINUX”加载器 - ISOLINUX.ASM

为了为您的问题提供更具体的起点,El Torito 规范第 5.3 节:

Once the system jumps to segment:0, the program can retrieve its boot
information by issuing INT 13, Function 4B, AL=01.  After the boot process
has been initiated the INT 13 Extensions (functions 41-48) will access the
CD using 800 byte sectors and the LBA address provided to INT 13 is an
absolute sector number. This gives any program running in no emulation mode
the ability to locate the boot catalog, and any other information on the
CD, without providing a device driver.

For the BIOS to load your boot sector from CD, you'll need to make the CD bootable by using the "El Torito" standard.

Once you use that, you have two options
a. Emulation - the BIOS emulates either a floppy or hard drive, and you can read your kernel through the INT13 calls with either device 00 or device 80.
b. The device doesn't emulate, and you can read directly from the CD using the INT13 ExtendedRead function.

To see how this is done, look at the Linux "ISOLINUX" loader - ISOLINUX.ASM

To provide a more specific starting point to your question, El Torito spec,section 5.3:

Once the system jumps to segment:0, the program can retrieve its boot
information by issuing INT 13, Function 4B, AL=01.  After the boot process
has been initiated the INT 13 Extensions (functions 41-48) will access the
CD using 800 byte sectors and the LBA address provided to INT 13 is an
absolute sector number. This gives any program running in no emulation mode
the ability to locate the boot catalog, and any other information on the
CD, without providing a device driver.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文