2024年5月31日发(作者:)

Bootsect.s(1-9)

!

! SYS_SIZE is the number of clicks (16 bytes) to be loaded.

! 0x3000 is 0x30000 bytes = 196kB, more than enough for current

! versions of linux ! SYS_SIZE 是要加载的节数(16 字节为1 节)。0x3000 共为

1 2 3 4 5 6

0x7c00

0x0000

0x90000

0x10000

0xA0000

system 模块

代码执行位置线路

0x90200

! 0x30000 字节=192 kB(上面Linus 估算错了),对于当前的版本空间已足够了。

!

SYSSIZE = 0x3000 ! 指编译连接后system 模块的大小。参见列表1.2 中第92 的说明。

! 这里给出了一个最大默认值。

!

! bootsect.s (C) 1991 Linus Torvalds

!

! bootsect.s is loaded at 0x7c00 by the bios-startup routines, and moves

! iself out of the way to address 0x90000, and jumps there.

!

! It then loads 'setup' directly after itself (0x90200), and the system

! at 0x10000, using BIOS interrupts.

!

! NOTE! currently system is at most 8*65536 bytes long. This should be no

! problem, even in the future. I want to keep it simple. This 512 kB

! kernel size should be enough, especially as this doesn't contain the

! buffer cache as in minix

!

! The loader has been made as simple as possible, and continuos

! read errors will result in a unbreakable loop. Reboot by hand. It

! loads pretty fast by getting whole sectors at a time whenever possible.

!

! 以下是前面这些文字的翻译:

! bootsect.s (C) 1991 Linus Torvalds 版权所有

!

! bootsect.s 被bios-启动子程序加载至0x7c00 (31k)处,并将自己

! 移到了地址0x90000 (576k)处,并跳转至那里。

!

1

! 它然后使用BIOS 中断将'setup'直接加载到自己的后面(0x90200)(576.5k),

! 并将system 加载到地址0x10000 处。

!

! 注意! 目前的内核系统最大长度限制为(8*65536)(512k)字节,即使是在

! 将来这也应该没有问题的。我想让它保持简单明了。这样512k 的最大内核长度应该

! 足够了,尤其是这里没有象minix 中一样包含缓冲区高速缓冲。

!

! 加载程序已经做的够简单了,所以持续的读出错将导致死循环。只能手工重启。

! 只要可能,通过一次取取所有的扇区,加载过程可以做的很快的。

.globl begtext, begdata, begbss, endtext, enddata, endbss ! 定义了6 个全局标识符;

.text ! 文本段;

begtext:

.data ! 数据段;

begdata:

.bss ! 堆栈段;

begbss:

.text ! 文本段;

SETUPLEN = 4 ! nr of setup-sectors

! setup 程序的扇区数(setup-sectors)值;

BOOTSEG = 0x07c0 ! original address of boot-sector

! bootsect 的原始地址(是段地址,以下同);

INITSEG = 0x9000 ! we move boot here - out of the way

! 将bootsect 移到这里 -- 避开;

SETUPSEG = 0x9020 ! setup starts here

! setup 程序从这里开始;

SYSSEG = 0x1000 ! system loaded at 0x10000 (65536).

! system 模块加载到0x10000(64 kB)处;

ENDSEG = SYSSEG + SYSSIZE ! where to stop loading

! 停止加载的段地址;

! ROOT_DEV: 0x000 - same type of floppy as boot.

! 根文件系统设备使用与引导时同样的软驱设备;

! 0x301 - first partition on first drive etc

! 根文件系统设备在第一个硬盘的第一个分区上,等等;

ROOT_DEV = 0x306 ! 指定根文件系统设备是第2 个硬盘的第1 个分区。这是Linux 老式

的硬盘命名

! 方式,具体值的含义如下:

! 设备号=主设备号*256 + 次设备号(也即dev_no = (major<<8) + minor )

! (主设备号:1-内存,2-磁盘,3-硬盘,4-ttyx,5-tty,6-并行口,7-非命名管道)

! 0x300 - /dev/hd0 - 代表整个第1 个硬盘;

! 0x301 - /dev/hd1 - 第1 个盘的第1 个分区;

! …

2