【问题标题】:What does BIOS do after loading Global/Interrupt Descriptor Table Register in JOS?在 JOS 中加载全局/中断描述符表寄存器后 BIOS 会做什么?
【发布时间】:2016-11-08 08:58:06
【问题描述】:

我分析了 BIOS 开始执行直到加载全局/中断描述符表寄存器时的第一个代码。我所说的 BIOS 是 MIT 课程“操作系统工程”中的 BIOS。我很难理解 BIOS 之后的工作方式。

[f000:fff0]    0xffff0: ljmp   $0xf000,$0xe05b
#when BIOS starts executing, jump to the address fe05bH to continue to execute
[f000:e05b]    0xfe05b: cmpl   $0x0,%cs:0x6574
[f000:e062]    0xfe062: jne    0xfd2b6
[f000:e066]    0xfe066: xor    %ax,%ax
[f000:e068]    0xfe068: mov    %ax,%ss
#set %ss to 0
[f000:e06a]    0xfe06a: mov    $0x7000,%esp
[f000:e070]    0xfe070: mov    $0xf3c24,%edx
[f000:e076]    0xfe076: jmp    0xfd124
[f000:d124]    0xfd124: mov    %eax,%ecx
[f000:d127]    0xfd127: cli
#turn off interrupt
[f000:d128]    0xfd128: cld 
# set DF flag to 0, when  DF=0, SI = SI + 1 , DI = DI + 1
[f000:d129]    0xfd129: mov    $0x8f,%eax
[f000:d12f]    0xfd12f: out    %al,$0x70
[f000:d131]    0xfd131: in     $0x71,%al
#close NMI through 70H I/O port, selecting CMOS 0xF register, and assigining 0xF register's value to %al register
[f000:d133]    0xfd133: in     $0x92,%al
[f000:d135]    0xfd135: or     $0x2,%al
[f000:d137]    0xfd137: out    %al,$0x92
#enable A20 address line
[f000:d139]    0xfd139: lidtw  %cs:0x6690
[f000:d13f]    0xfd13f: lgdtw  %cs:0x6650
#loading Global/Interrupt Descriptor Table Register
[f000:d145]    0xfd145: mov    %cr0,%eax
[f000:d148]    0xfd148: or     $0x1,%eax
[f000:d14c]    0xfd14c: mov    %eax,%cr0
#set CR0 PE=1. when PE=1 CPU is in protected mode
[f000:d14f]    0xfd14f: ljmpl  $0x8,$0xfd157
 The target architecture is assumed to be i386
 => 0xfd157:    mov    $0x10,%eax
 => 0xfd15c:    mov    %eax,%ds
 => 0xfd15e:    mov    %eax,%es
 => 0xfd160:    mov    %eax,%ss
 => 0xfd162:    mov    %eax,%fs
 => 0xfd164:    mov    %eax,%gs
 #After loading GDTR, it's necessary to reload all the segment register
 .....

在这些代码之后,我不知道 BIOS 如何执行以搜索可引导设备,例如软盘、硬盘驱动器或 CD-ROM。最终,当它找到可引导磁盘时,BIOS 会从磁盘读取引导加载程序并将控制权转移给它

【问题讨论】:

    标签: operating-system bios


    【解决方案1】:

    回复太晚了,但我有同样的问题,并在SeaBIOS source code 中找到了答案

    我链接的页面是映射到重置向量的向量的源代码。 如果您真的想解析 GDB 中 40 KB 的 BIOS 代码,请随意拿一些草稿纸,开始绘制堆栈布局和 BIOS 代码布局。在决定改为阅读源代码之前,我花了几个小时这样做;阅读源代码可能更健康。

    编辑:还可以在维基百科页面上查看this section 以获取关于选项 ROM 的 BIOS,它提供了比选项 ROM 的维基百科页面更好的关于选项 ROM 的信息。花了很长时间才弄明白。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 1970-01-01
      • 2014-11-11
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      相关资源
      最近更新 更多