#
jne main.15 # If not F5恢复上面保存的si和标志寄存器的内容 。如果不是按键F5,则直接跳转到main.15去执行 。movb _NXTDRV(%bp),%dl # Next drive
subb $'0',%dl # number否则的话,我们选择下一个驱动器作为启动盘 。#
# load selected bootsector to the LOAD location in RAM.
# If it fails to read or isn't marked bootable, treat it
# as a bad selection.
# XXX what does %si carry?
#
main.15:
movw $LOAD,%bx # Address for read
movb $0x2,%ah # Read sector
callw intx13 # from disk
jc main.10 # If error把我们上面选择到的分区读到0x7c00处,就象我们刚刚才加电启动一样,只是活动分区改变了而已 。如果发生读错误则直接跳转到main.10 。使用户重新选择启动分区 。cmpw $MAGIC,0x1fe(%bx) # Bootable?jne main.10 # No判断引导扇区的最后两个字节是否是“0x55AA,如果不是,则表示此扇区是不可引导的,或不合法的引导扇区则直接跳转到main.10 。使用户重新选择启动分区 。pushw %si # Savemovw $crlf,%si # Leave somecallw puts # spacepopw %si # Restore打印“回车和“换行 。jmp *%bx # Invoke bootstrap跳转到我们选择的引导扇区去执行 。整个Boot Manager代码到此执行完毕 。#
# Display routines
#
putkey:
movb $'F',%al # Display
callw putchr # 'F'
movb $'1',%al # Prepare
addb %dl,%al # digit
jmp putstr.1 # Display the rest“putkey函数在屏幕上打印“F1、“F2或“F3等 。如果dl为0则打印“F1,如果dl为1则打印“F2,如果dl为3则打印“F3 。和调用“putstr在屏幕上打印es:si指向的以最高位置1为结束字符的字符串 。#
# Display the option and note that it is a valid option.
# That last point is a bit tricky..
#putx: #首先,把_MNUOPT(%bp)的第dx位(bit)置1,表示此菜单选项被显示 。然后在屏幕上打印空格和es:di指向的以最高位置1为结束字符的字符串 。btsw %dx,_MNUOPT(%bp) # Enable menu option
movw $item,%si # Display
callw putkey # key
movw %di,%si # Display the restputs: #调用“putstr在屏幕上打印es:si指向的以最高位置1为结束字符的字符串 。callw putstr # Display stringputn: #“putn打印“回车/换行后在屏幕上打印es:si指向的以最高位置1为结束字符的字符串 。movw $crlf,%si # To next line
putstr: #“putstr在屏幕上打印es:si指向的以最高位置1为结束字符的字符串 。
lodsb # Get byte
testb $0x80,%al # End of string?
jnz putstr.2 # Yes
putstr.1:
callw putchr # Display char
jmp putstr # Continue
putstr.2:
andb $~0x80,%al # Clear MSB
putchr:
pushw %bx # Save
movw $0x7,%bx# Page:attribute
movb $0xe,%ah # BIOS: Display
int $0x10 # character
popw %bx # Restore
retw # To caller“putchr在屏幕上显示“al中的字符 。# One-sector disk I/O routine
intx13:
movb 0x1(%si),%dh # Load head
movw 0x2(%si),%cx # Load cylinder:sector
movb $0x1,%al # Sector count
pushw %si # Save
movw %sp,%di # Save
testb $0x80,_FLAGS(%bp) # Use packet interface?
jz intx13.1 # No
pushl $0x0 # Set the
pushl 0x8(%si) # LBA address
pushw %es # Set the transfer
pushw %bx # buffer address
push $0x1 # Block count
push $0x10 # Packet size
movw %sp,%si # Packet pointer
decw %ax # Verify off
orb $0x40,%ah # Use disk packet
intx13.1:
int $0x13 # BIOS: Disk I/O
movw %di,%sp # Restore
popw %si # Restore
retw # To caller
# Menu strings
item:
.ascii " "; .byte ' '|0x80
prompt:
.ascii "nDefault:".byte ' '|0x80
crlf:
.ascii "r"; .byte 'n'|0x80
# Partition type tables
tables:
#
# These entries identify invalid or NON BOOT types and partitions.
推荐阅读
- FreeBSD的Loader和内核初始化
- FreeBSD系统安装与配置之准备篇
- FreeBSD的磁盘和BIOS的关系
- 浅谈FreeBSD 5.2常用操作的改变
- freebsd7.0 安装记录
- freebsd 7 pkg_add -r kde 4
- 加快FreeBSD中pkg_add的速度
- 红米note7pro中将应用自启动关掉具体操作方法
- 在FreeBSD5.0上配置DNS服务手记
- 04 FreeBSD连载:FreeBSD的相关资源
