开发一个bootloader的大会 [英] Develop a Bootloader In Assembly

查看:197
本文介绍了开发一个bootloader的大会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了我在大会OS的一部分,但现在我想建立一个自己的引导程序对它来说太不是使用G​​RUB的。当我在开发大会我的测试OS我记得我引导它是这样的:

I've already done a part of my OS in Assembly, but now I want to build a own bootloader for it too instead of using GRUB. When I was developing my test OS in Assembly I remember that I boot it like this:

org 0x7c00
bits 16

; OS Kernel Here

times 510 - ($-$$) db 0
dw 0xAA55

这我已经知道了。现在,我想用这个和执行真正的操作系统,这将是写入软盘的第二个扇区中的* .bin文件。然后,我想知道有些事情

This I've already know. Now I want to use this and execute the "real" OS that will be a *.bin file written to the 2nd sector of the floppy. Then I want to know somethings


  • 如何做一个大会引导程序来执行什么将在软盘的第二个扇区首发?

  • 我需要什么添加到将放在软盘的第二个扇区大会来源?

推荐答案

您使用 INT 0x13 中的所需数量的扇区加载并跳到你有地方的位置新的code。有没有需要在第二阶段的事,但你会希望确保您设置 DS 是有效的,无论你加载code

You use int 0x13 to load in the required number of sectors and jump to the location you have place the new code. There is nothing you need to do in the second stage, but you will want to make sure that you set DS to be valid for wherever you load the code.

这是我的小OS归档示例:

Example from my little OS archive:

  /* BIOS loads the sectors into es:bx */
  pushw    $STAGE1_WORKSEG
  popw     %es
  movw     $STAGE1_OFFSET, %bx

read_stage1:

  /* Try to read in a few sectors */
  movb     $0x2, %cl      /* Sector */
  movb     $0x0, %ch      /* Cylinder */
  movb     $0x0, %dh      /* Head */
  movb     $0x0, %dl      /* Drive */
  movb     $0x2, %ah      /* BIOS read function */

  /* How many sectors to load */
  movb     $STAGE1_SIZE, %al 
  int      $0x13
  jnc      read_stage1_done

  /* Reset drive */
  xorw     %ax, %ax
  int      $0x13
  jmp      read_stage1


read_stage1_done:

  /* Perform a long jump into stage1 */
  ljmp     $STAGE1_WORKSEG, $STAGE1_OFFSET

  call     halt

halt:
    /*
    * Function: halt
    * Synopsis: Sends the processor into a permanent halted status
    * Notes:
    *    The only way out of this is to manually reboot
    */
    hlt                     /* Halt the processor */
    jmp      halt

这就是气格式,所以你要扭转操作顺序,因为它看起来像你使用NASM从指令。变量名应该是不言自明的。

That's in GAS format so you'll want to reverse the operand order because it looks like you're using NASM from the times instruction. The variable names should be self-explanatory.

如果你正在开发一个爱好OS则 http://forum.osdev.org/ 是一个好地方让别人做同样的事情的支持。它比计算器更专业化一点,很多东西的操作系统可以很深奥的。

If you're developing a hobby OS then http://forum.osdev.org/ is a good place to get support from others doing the same thing. It's a bit more specialised than stackoverflow and a lot of OS stuff can be quite esoteric.

这篇关于开发一个bootloader的大会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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