2005-04-17 02:20:36 +04:00
/ *
* bootsect. S C o p y r i g h t ( C ) 1 9 9 1 , 1 9 9 2 L i n u s T o r v a l d s
*
* modified b y D r e w E c k h a r d t
* modified b y B r u c e E v a n s ( b d e )
* modified b y C h r i s N o e ( M a y 1 9 9 9 ) ( a s86 - > g a s )
* gutted b y H . P e t e r A n v i n ( J a n 2 0 0 3 )
*
* BIG F A T N O T E : W e ' r e i n r e a l m o d e u s i n g 6 4 k s e g m e n t s . T h e r e f o r e s e g m e n t
* addresses m u s t b e m u l t i p l i e d b y 1 6 t o o b t a i n t h e i r r e s p e c t i v e l i n e a r
* addresses. T o a v o i d c o n f u s i o n , l i n e a r a d d r e s s e s a r e w r i t t e n u s i n g l e a d i n g
* hex w h i l e s e g m e n t a d d r e s s e s a r e w r i t t e n a s s e g m e n t : o f f s e t .
*
* /
# include < a s m / b o o t . h >
SETUPSECTS = 4 / * d e f a u l t n r o f s e t u p - s e c t o r s * /
BOOTSEG = 0 x07 C 0 / * o r i g i n a l a d d r e s s o f b o o t - s e c t o r * /
INITSEG = D E F _ I N I T S E G / * w e m o v e b o o t h e r e - o u t o f t h e w a y * /
SETUPSEG = D E F _ S E T U P S E G / * s e t u p s t a r t s h e r e * /
SYSSEG = D E F _ S Y S S E G / * s y s t e m l o a d e d a t 0 x10 0 0 0 ( 6 5 5 3 6 ) * /
SYSSIZE = D E F _ S Y S S I Z E / * s y s t e m s i z e : # o f 16 - b y t e c l i c k s * /
/* to be loaded */
ROOT_ D E V = 0 / * R O O T _ D E V i s n o w w r i t t e n b y " b u i l d " * /
SWAP_ D E V = 0 / * S W A P _ D E V i s n o w w r i t t e n b y " b u i l d " * /
# ifndef S V G A _ M O D E
# define S V G A _ M O D E A S K _ V G A
# endif
# ifndef R A M D I S K
# define R A M D I S K 0
# endif
# ifndef R O O T _ R D O N L Y
# define R O O T _ R D O N L Y 1
# endif
.code16
.text
.global _start
_start :
# Normalize t h e s t a r t a d d r e s s
jmpl $ B O O T S E G , $ s t a r t 2
start2 :
movw % c s , % a x
movw % a x , % d s
movw % a x , % e s
movw % a x , % s s
movw $ 0 x7 c00 , % s p
sti
cld
movw $ b u g g e r _ o f f _ m s g , % s i
msg_loop :
lodsb
andb % a l , % a l
jz d i e
movb $ 0 x e , % a h
movw $ 7 , % b x
int $ 0 x10
jmp m s g _ l o o p
die :
# Allow t h e u s e r t o p r e s s a k e y , t h e n r e b o o t
xorw % a x , % a x
int $ 0 x16
int $ 0 x19
# int 0 x19 s h o u l d n e v e r r e t u r n . I n c a s e i t d o e s a n y w a y ,
# invoke t h e B I O S r e s e t c o d e . . .
ljmp $ 0 x f00 0 ,$ 0 x f f f0
bugger_off_msg :
.ascii " Direct b o o t i n g f r o m f l o p p y i s n o l o n g e r s u p p o r t e d . \ r \ n "
.ascii " Please u s e a b o o t l o a d e r p r o g r a m i n s t e a d . \ r \ n "
.ascii " \ n"
.ascii " Remove d i s k a n d p r e s s a n y k e y t o r e b o o t . . . \ r \ n "
.byte 0
2005-05-06 03:16:15 +04:00
2005-04-17 02:20:36 +04:00
# Kernel a t t r i b u t e s ; used by setup
.org 497
setup_sects : .byte S E T U P S E C T S
root_flags : .word R O O T _ R D O N L Y
syssize : .word S Y S S I Z E
swap_dev : .word S W A P _ D E V
ram_size : .word R A M D I S K
vid_mode : .word S V G A _ M O D E
root_dev : .word R O O T _ D E V
boot_flag : .word 0xAA55