- 论坛徽章:
- 0
|
/*
* 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 |
|