linux2.6內核研讀筆記一

/*

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

 *

 */

我們處於實模式下,使用64k個段,因此段地址必須是16的倍數,爲避免衝突,線性地址用16進制頭書寫,段地址作爲偏移書寫

#include <asm/segment.h>

#include <linux/utsrelease.h>

#include <asm/boot.h>

#include <asm/e820.h>

#include <asm/page_types.h>

#include <asm/setup.h>

#include "boot.h"

#include "offsets.h"

 

BOOTSEG            = 0x07C0              /* original address of boot-sector */

SYSSEG        = 0x1000        /* historical load address >> 4 */

 

#ifndef SVGA_MODE

#define SVGA_MODE ASK_VGA

#endif

 

#ifndef RAMDISK

#define RAMDISK 0

#endif

 

#ifndef ROOT_RDONLY

#define ROOT_RDONLY 1

#endif

 

       .code16

       .section ".bstext", "ax"

 

       .global bootsect_start

bootsect_start:

 

       # Normalize the start address

       ljmp $BOOTSEG, $start2 跳到0x07c000start2的地方

 

start2:

       movw     %cs, %ax

       movw     %ax, %ds

       movw     %ax, %es

       movw     %ax, %ss

       xorw       %sp, %sp

       sti允許中斷

       cld

 

       movw     $bugger_off_msg, %si

                              

msg_loop:

       lodsbDS:[si]中的內容取到AL中,由於前邊的cldsi開始遞減

       andb       %al, %al

       jz     bs_die 如果bug信息打完,則跳轉

       AL-顯示ASCII字符
       BH
-頁號(在我們要進行的工作中,它一直是0x00)
       BL
-文本屬性(在我們將進行的工作中,它一直是0x07) 通過更改它的值可以選擇不同  的顏色等。

       movb      $0xe, %ah顯示字符

       movw     $7, %bx

       int    $0x10 INT 0x10BIOS視頻中斷

       jmp  msg_loop

 

bs_die:

       # Allow the user to press a key, then reboot

       xorw       %ax, %ax清零

       int    $0x16按任意鍵重啓

16

1

讀鍵盤緩衝區字符

 

ZF=0 AL=字符碼
     AH=
掃描碼
ZF=1
緩衝區空

 

       int    $0x19

       重新啓動系統

       # int 0x19 should never return.  In case it does anyway,

       # invoke the BIOS reset code...

       ljmp $0xf000,$0xfff0跳轉到f000,fff0

bios的重置碼

       .section ".bsdata", "a"

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章