“boot”
boot.s
|
| boot.s
|
| boot.s is loaded at 0x7c00 by the bios-startup routines, and moves itself
| out of the way to address 0x90000, and jumps there.
|
| It then loads the system at 0x10000, using BIOS interrupts. Thereafter
| it disables all interrupts, moves the system down to 0x0000, changes
| to protected mode, and calls the start of system. System then must
| RE-initialize the protected mode in it’s own tables, and enable
| interrupts as needed.
|
| 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 - in fact more would mean we’d have to move
| not just these start-up routines, but also do something about the cache-
| memory (block IO devices). The area left over in the lower 640 kB is meant
| for these. No other memory is assumed to be “physical”, ie all memory
| over 1Mb is demand-paging. All addresses under 1Mb are guaranteed to match
| their physical addresses.
|
| NOTE1 abouve is no longer valid in it’s entirety. cache-memory is allocated
| above the 1Mb mark as well as below. Otherwise it is mainly correct.
|
| NOTE 2! The boot disk type must be set at compile-time, by setting
| the following equ. Having the boot-up procedure hunt for the right
| disk type is severe brain-damage.
| The loader has been made as simple as possible (had to, to get it
| in 512 bytes with the code to move to protected mode), 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.

| 1.44Mb disks:
sectors = 18
| 1.2Mb disks:
| sectors = 15
| 720kB disks:
| sectors = 9

.globl begtext, begdata, begbss, endtext, enddata, endbss
.text
begtext:
.data
begdata:
.bss
begbss:
.text

BOOTSEG = 0x07c0
INITSEG = 0x9000
SYSSEG = 0x1000 | system loaded at 0x10000 (65536).
ENDSEG = SYSSEG + SYSSIZE

entry start
start:
mov ax,#BOOTSEG
mov ds,ax
mov ax,#INITSEG
mov es,ax
mov cx,#256
sub si,si
sub di,di
rep
movw
jmpi go,INITSEG
go: mov ax,cs
mov ds,ax
mov es,ax
mov ss,ax
mov sp,#0x400 | arbitrary value >>512

mov  ah,#0x03    | read cursor pos
xor bh,bh
int 0x10mov cx,#24
mov bx,#0x0007  | page 0, attribute 7 (normal)
mov bp,#msg1
mov ax,#0x1301  | write string, move cursor
int 0x10

| ok, we’ve written the message, now
| we want to load the system (at 0x10000)

mov  ax,#SYSSEG
mov es,ax       | segment of 0x010000
call    read_it
call    kill_motor

| if the read went well we get current cursor position ans save it for
| posterity.

mov  ah,#0x03    | read cursor pos
xor bh,bh
int 0x10        | save it in known place, con_init fetches
mov [510],dx    | it from 0x90510.

| now we want to move to protected mode …

cli          | no interrupts allowed !

| first we move the system to it’s rightful place

mov  ax,#0x0000
cld         | 'direction'=0, movs moves forward

do_move:
mov es,ax | destination segment
add ax,#0x1000
cmp ax,#0x9000
jz end_move
mov ds,ax | source segment
sub di,di
sub si,si
mov cx,#0x8000
rep
movsw
j do_move

| then we load the segment descriptors

end_move:

mov  ax,cs       | right, forgot this at first. didn't work :-)
mov ds,ax
lidt    idt_48      | load idt with 0,0
lgdt    gdt_48      | load gdt with whatever appropriate

| that was painless, now we enable A20

call empty_8042
mov al,#0xD1        | command write
out #0x64,al
call    empty_8042
mov al,#0xDF        | A20 on
out #0x60,al
call    empty_8042

| well, that went ok, I hope. Now we have to reprogram the interrupts

linux源代码剖析之二boot相关推荐

  1. linux源码0.11解析pdf,linux0.11 赵炯的Linux源代码剖析中的带中文注释的源代码 - 下载 - 搜珍网...

    linux内核0.11注释版/boot/bootsect.s linux内核0.11注释版/boot/head.s linux内核0.11注释版/boot/setup.s linux内核0.11注释版 ...

  2. linux源代码剖析之kernel

    kernel asm.s /* asm.s contains the low-level code for most hardware faults. page_exception is handle ...

  3. linux源代码剖析之三fs

    fs bitmap.c /* bitmap.c contains the code that handles the inode and block bitmaps */ #include <s ...

  4. linux源代码剖析之一

    boot fs include include-asm include-linux include-sys init kernel lib mm tools Makefile

  5. linux源代码剖析之lib

    lib _exit.c #define LIBRARY #include <unistd.h> volatile void _exit(int exit_code) { asm(" ...

  6. linux源代码剖析之include-asm

    include-asm 汇编 io.h #define outb(value,port) asm ("outb %%al,%%dx"::"a" (value), ...

  7. linux文件系统dentry_NFS 文件系统源代码剖析

    NFS 文件系统概述 NFS(Network File System,网络文件系统)是一种基于网络的文件系统.它可以将远端服务器文件系统的目录挂载到本地文件系统的目录上,允许用户或者应用程序像访问本地 ...

  8. WCF技术剖析之二十八:自己动手获取元数据[附源代码下载]

    WCF技术剖析之二十八:自己动手获取元数据[附源代码下载] 原文:WCF技术剖析之二十八:自己动手获取元数据[附源代码下载] 元数据的发布方式决定了元数据的获取行为,WCF服务元数据架构体系通过Ser ...

  9. WCF技术剖析之二十九:换种不同的方式调用WCF服务[提供源代码下载]

    原文:WCF技术剖析之二十九:换种不同的方式调用WCF服务[提供源代码下载] 我们有两种典型的WCF调用方式:通过SvcUtil.exe(或者添加Web引用)导入发布的服务元数据生成服务代理相关的代码 ...

最新文章

  1. 最小二乘法+牛顿法+拟牛顿法+梯度下降法+梯度上升法+共轭梯度法
  2. 代码跑得慢?分分钟教你如何给代码提速30%!!!
  3. 用Vue来实现图片上传多种方式
  4. 操作系统习题6—存储管理2
  5. GDCM:Dicom文件重复的PCDE测试程序
  6. android webView 与 JS交互方式
  7. Docker学习总结(34)——新手使用Docker的11条准则
  8. SVN+MAVEN项目打包
  9. 设计一个长方形类。成员变量包括:长度和宽度,成员函数除包括计算周长和计算面积外, 还包括用set方法来设置长方形的长度和宽度,以及用get的方法来获得长方形的长度和宽度 最后,编写一个测试程序来测试所
  10. Vue3项目运行时报错,提示Use // eslint-disable-next-line to ignore the next line.
  11. javax.mail实现收发邮件
  12. 【内核笔记】博文2021回顾-2022规划
  13. 【模板】最小费用最大流【费用流】
  14. java实现拆分元素,java-将列表沿元素拆分为子列表
  15. 深度学习框架智能时代的操作系统是什么?
  16. 单片机c语言交通信号灯设计,基于51单片机的交通信号灯设计毕业设计.pdf
  17. 大容量文件服务器备份方案
  18. 查看NAND Flash空间大小
  19. 郑大跨专业考研计算机,多所985/211大学计算机考研禁止跨考!新乡寄宿考研
  20. 计算机进位计数制实训课教案,计算机组成原理的教与学

热门文章

  1. adb server version (31) doesn‘t match this client (39) 解决方案
  2. Vue整合nginx:(1)开发环境npm run dev下,通过nginx解决前后端分离造成的跨域问题
  3. 如何在gradle上仅运行一个测试类
  4. 子集数据帧中的丢包因子级别
  5. 在Objective-C中,如何测试对象类型?
  6. 将参数传递给Bash函数
  7. Git最好的CRLF(回车,换行)处理策略是什么?
  8. 标准Android按钮具有不同的颜色
  9. 电脑系统还原怎么操作?这个方法在电脑设置里就可以还原
  10. win11环境变量如何打开 Windows11查看环境变量的步骤方法