linux2.6.11启动代码之bootsect.s
来源:互联网 发布:个性淘宝女装店名 编辑:程序博客网 时间:2024/05/01 21:27
/*
* bootsect.S Copyright (C) 1991, 1992 Linus Torvalds
*
* modified by Drew Eckhardt
* modified by Bruce Evans (bde)
* modified by Chris Noe (May 1999) (as86 -> gas)
* gutted by H. Peter Anvin (Jan 2003)
*
* BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment
* addresses must be multiplied by 16 to obtain their respective linear
* addresses. To avoid confusion, linear addresses are written using leading
* hex while segment addresses are written as segment:offset.
*
*/
这段代码首先是有bios系统调用装入的,应该是LILO的一部分。
这部分主要实现了一个显示bugger_off_msg的过程,主要有3个比较重要的bios调用,int 10
Int 16 和int 19,下面详细的讲一下这三个系统调用的意思:
(1) Int 0x10
所用到的寄存器的解释:
AH = 0Eh
AL = 要显示的字符
BH = 页号(开启页机制的情况下)
BL = 前景色 (仅在图形模式下用)
Return: nothing
功能:display a character on the screen, advancing the cursor and scrolling
the screen as necessary
(2) Int 0x16
Inp.:
AH = 00h
Return: AH = BIOS scan code
AL = ASCII character
(3) Int 0x19
This interrupt reboots the system without clearing memory or restoring
interrupt vectors. Because interrupt vectors are preserved, this
interrupt usually causes a system hang if any TSRs have hooked
vectors from 00h through 1Ch, particularly INT 08.
/***********************************************************************
#include <asm/boot.h>
SETUPSECTS = 4 /* default nr of setup-sectors */
BOOTSEG = 0x07C0 /* original address of boot-sector */
INITSEG = DEF_INITSEG /* we move boot here - out of the way 0x9000*/
SETUPSEG = DEF_SETUPSEG /*setup starts here 0x9020*/
SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
/* to be loaded */
ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
#ifndef SVGA_MODE
#define SVGA_MODE ASK_VGA //0xfffd
#endif
#ifndef RAMDISK
#define RAMDISK 0
#endif
#ifndef ROOT_RDONLY
#define ROOT_RDONLY 1
#endif
.code16
.text
.global _start
_start:
# Normalize the start address
jmpl $BOOTSEG, $start2
start2:
movw %cs, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
movw $0x7c00, %sp
sti //设置中断
cld //清除方向标志,cld即告诉程序si,di
//向前移动,std指令为设置方向,告诉程
//序si,di向后移动
movw $bugger_off_msg, %si //si指向要显示的字符
/*********************************************
逐字符的显示bugger_off_msg中的内容
**************************************************************/
msg_loop:
lodsb // LODSB的功能是将DS:[si]中的内容取到AL中,然后SI<=SI+/-1
andb %al, %al
jz die // je是jump if zero的意思,jz是jump if equal的意思,两者都是结果为
//0(相等),即zF=1时,转移,
movb $0xe, %ah
movw $7, %bx
int $0x10 //显示
jmp msg_loop
die:
# Allow the user to press a key, then reboot
xorw %ax, %ax
int $0x16 //键盘中断 在ah中接收基本键盘输入功能信号
int $0x19
//int 19一般是不会执行的,因为在int 16之后系统将会跳到用户选择的系统运行,也就//是说如果用户不选择的话,系统将会重启,然后执行下面的跳转代码
# int 0x19 should never return. In case it does anyway,
# invoke the BIOS reset code...
ljmp $0xf000,$0xfff0 //
bugger_off_msg:
.ascii "Direct booting from floppy is no longer supported./r/n"
.ascii "Please use a boot loader program instead./r/n"
.ascii "/n"
.ascii "Remove disk and press any key to reboot . . ./r/n"
.byte 0
# Kernel attributes; used by setup
.org 497
setup_sects: .byte SETUPSECTS
root_flags: .word ROOT_RDONLY
syssize: .word SYSSIZE
swap_dev: .word SWAP_DEV
ram_size: .word RAMDISK
vid_mode: .word SVGA_MODE
root_dev: .word ROOT_DEV
boot_flag: .word 0xAA55
- linux2.6.11启动代码之bootsect.s
- linux2.6.11启动代码之bootsect.s
- linux0.11内核代码之bootsect.s
- bootsect.s代码注释
- Linux0.11内核--启动引导代码分析bootsect.s
- Linux0.11内核--启动引导代码分析bootsect.s
- linux 0.11 version 启动代码分析(bootsect.s)
- bootsect启动代码分析
- linux0.11系列之(二): 启动引导 bootsect.s
- linux2.4 启动代码head.S分析
- linux2.4 启动代码head.S分析
- linux0.11启动第一步:bootsect.s
- bootsect.s
- bootsect.S
- linux0.11源码阅读笔记1-启动流程-bootsect.s
- Linux 0.1 版本内核 bootsect.s 代码解析
- Linux启动分析(2)— bootsect.S、setup.S、head.S分析
- Linux启动分析(2)— bootsect.S、setup.S、head.S分析
- Circular list example -- Josephus problem
- Oracle:由临时表空间
- 平时留意的一些短句【不断增加中】
- 关于子线程的进度条
- 算法题目1——闭合篱笆
- linux2.6.11启动代码之bootsect.s
- 中文乱码
- ORA-01653: unable to extend table string.string by string in tablespace string
- VB Timer时钟的准确性
- Bash 实例
- 越来越强大的SAFS/STAF/STAX自动化测试框架
- WINFORM播放WAV
- jsp页面打印方法
- struts学习总结1