缥缈峰一座01号

梁二伯的窝

  DonewsBlog  |  Donews首页  |  Donews社区  |  Donews邮箱  |  我的首页  |  联系作者  |  聚合   |  登录
  86篇文章 :: 0篇收藏:: 27篇评论:: 0个Trackbacks

公告

Equality && Free

文章

收藏

相册

存档


正在读取评论……


较之于老版本的bootsect.S,  2.6.6里头的bootsect.S几乎就没什么东西了.

/*
 * 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.
 *
 */

#include <asm/boot.h>

SETUPSECTS = 4   /* setup程序默认扇区数 */
BOOTSEG  = 0x07C0  /* bootsect最初加载地址 */
INITSEG  = DEF_INITSEG  /* DEF_INITSEG=0x9000 而后bootsect移到此处 */
SETUPSEG = DEF_SETUPSEG  /* DEF_SETUPSEG=0x9020  setup程序起始地址 */
SYSSEG  = DEF_SYSSEG  /* DEF_SYSSEG=0x1000 system加载处0x10000 (65536) */
SYSSIZE  = DEF_SYSSIZE  /*DEF_SYSSIZE=0x7F00 system 大小, */
     /* 要加载的16字节为一单位的数 */
ROOT_DEV = 0    /* ROOT_DEV 现在由 "build"设置 */
SWAP_DEV = 0   /* SWAP_DEV 现在由 "build"设置 */

#ifndef SVGA_MODE
#define SVGA_MODE ASK_VGA
/*
* #define ASK_VGA  0xfffd  启动时询问
*/
#endif

#ifndef RAMDISK
#define RAMDISK 0
#endif

#ifndef ROOT_RDONLY
#define ROOT_RDONLY 1                //只读
#endif

.code16
.text

.global _start
_start:


 jmpl $BOOTSEG, $start2     

start2:
 movw %cs, %ax          
 movw %ax, %ds           //置ds段寄存器为 0x07c0
 movw %ax, %es           //置es寄存器为   0x07c0
 movw %ax, %ss           //置ss栈寄存器为 0x07c0
 movw $0x7c00, %sp       //置sp栈顶指针为 0x07c0 
 sti                      //开中断
 cld                      //清方向标志 向上增长

 movw $bugger_off_msg, %si        //si中存入bugger_off_msg地址

msg_loop:                           //打印bugger_off_msg字符串
 lodsb                             //载入数据到al
 andb %al, %al                    //判断是否为空
 jz die                           //为空则跳转到die
 movb $0xe, %ah
 movw $7, %bx                  
  /*  IBM PC ROMs dated 1981/4/24 and 1981/10/19 require that BH be the same
   *  as the current active page ,BL是前景色
  */
 int $0x10                        // bios 0x10中断 写光标位置字符
 jmp msg_loop

die:
 # 允许用户按键重启
 xorw %ax, %ax                   //ax 置零
 int $0x16                        //ah=00h, 从键盘读字符 al=字符ascII码 ah=扫描码
 int $0x19                        //INT 19 - SYSTEM - BOOTSTRAP LOADER  重启机器

 # 0x19号中断从不返回, ^O^ 机器都重启了怎么返回~
 # 调用 BIOS 重启代码...
 ljmp $0xf000,$0xfff0             //bios第一条指令地址              


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                         // 设段内起始地址 0x1f1
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             // 0x1fe



Trackback: http://tb.donews.net/TrackBack.aspx?PostId=474162


[点击此处收藏本文]  发表于2005年07月20日 10:56 PM




正在读取评论……

发表评论

大名:
网址:
验证码
评论