免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 726 | 回复: 0
打印 上一主题 下一主题

kernel.2.6.11.bootsect.s analysis [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-06 12:36 |只看该作者 |倒序浏览

                /*
*    src/arch/i386/boot/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.
*
*
* [color="#006666"]Commented by lucas.isac
*/
#include  /* [color="#006666"]this file define the fllowing DEF_* */
SETUPSECTS    = 4            /* default nr of setup-sectors */
BOOTSEG        = 0x07C0        /* original address of boot-sector */
INITSEG        = DEF_INITSEG        /* [color="#006666"]0x9000 we move boot here - out of the way */
SETUPSEG    = DEF_SETUPSEG        /* [color="#006666"]0x9020 setup starts here */
SYSSEG        = DEF_SYSSEG        /* [color="#006666"]0x1000 system loaded at 0x10000 (65536) */
SYSSIZE  
     = DEF_SYSSIZE      
/* 0x7F00;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
#endif
#ifndef RAMDISK
#define RAMDISK 0
#endif
#ifndef ROOT_RDONLY
#define ROOT_RDONLY 1
#endif
.code16
.text
        /*[color="#006666"]the bootsect(origined by this file) */
.global _start  /*[color="#006666"]was copied by BIOS to addres:0x07c0(segment) */
_start:/*[color="#006666"]then jump to this address, excute the fllowing instruction*/
    # Normalize the start address /*[color="#006666"]this is the first instuction */
    jmpl    $BOOTSEG, $start2 /*[color="#006666"]this instruction change cs=BOOTSEG ip=start2 */
start2:
    movw    %cs, %ax
    movw    %ax, %ds /*[color="#006666"]set segment ds=0x07c0*/
    movw    %ax, %es /*[color="#006666"]set segment es=0x07c0*/
    movw    %ax, %ss /*[color="#006666"]set segment ss=0x07c0*/
    movw    $0x7c00, %sp
    sti    /*[color="#006666"]ready to service interupt */
    cld    /*[color="#006666"]increment*/
    movw    $bugger_off_msg, %si /*[color="#006666"]make source index point ro buffer_off_msg */
msg_loop:/*[color="#006666"]this loop display the bugger_off_msg on screen */
    lodsb    /*[color="#006666"]load one byte indicated by %si to %al ,%si++ automaticly*/
    andb    %al, %al
    jz    die    /*[color="#006666"]if the last instruction`s result is zero then jmp,else nop*/
    movb    $0xe, %ah/* [color="#006666"]the flowing three instruction */
    movw    $7, %bx /*[color="#006666"]act as a unit to display a char*/
    int    $0x10
    jmp    msg_loop
die:/*the bugger_off_msg has been displaid*/
    # Allow the user to press a key, then reboot
    xorw    %ax, %ax
    int    $0x16 /*[color="#006666"]read char from keyboard*/
    int    $0x19 /**/
    # 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
  
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/35387/showart_272073.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP