wok-next diff linux/stuff/linux-header-2.6.33.2.u @ rev 5247

Up: gcc (4.4.3) Part of new toolchain
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 11 19:28:59 2010 +0200 (2010-04-11)
parents
children a2cb144efd42
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/linux/stuff/linux-header-2.6.33.2.u	Sun Apr 11 19:28:59 2010 +0200
     1.3 @@ -0,0 +1,466 @@
     1.4 +--- linux-2.6.30.6/arch/x86/boot/header.S
     1.5 ++++ linux-2.6.30.6/arch/x86/boot/header.S
     1.6 +@@ -6,7 +6,7 @@
     1.7 +  *	Based on bootsect.S and setup.S
     1.8 +  *	modified by more people than can be counted
     1.9 +  *
    1.10 +- *	Rewritten as a common file by H. Peter Anvin (Apr 2007)
    1.11 ++ *	Rewritten Pascal Bellard (Nov 2009)
    1.12 +  *
    1.13 +  * BIG FAT NOTE: We're in real mode using 64k segments.  Therefore segment
    1.14 +  * addresses must be multiplied by 16 to obtain their respective linear
    1.15 +@@ -26,6 +26,8 @@
    1.16 + 
    1.17 + BOOTSEG		= 0x07C0		/* original address of boot-sector */
    1.18 + SYSSEG		= 0x1000		/* historical load address >> 4 */
    1.19 ++INITSEG		= 0x9000		/* boot address >> 4 */
    1.20 ++SETUPSEG	= 0x9020		/* setup address >> 4 */
    1.21 + 
    1.22 + #ifndef SVGA_MODE
    1.23 + #define SVGA_MODE ASK_VGA
    1.24 +@@ -39,53 +41,412 @@
    1.25 + #define ROOT_RDONLY 1
    1.26 + #endif
    1.27 + 
    1.28 ++/* some extra features */
    1.29 ++#define	EDIT_CMDLINE		on hotkey
    1.30 ++#define SHOW_REGS		show int13 status & parameters
    1.31 ++
    1.32 + 	.code16
    1.33 + 	.section ".bstext", "ax"
    1.34 + 
    1.35 + 	.global bootsect_start
    1.36 + bootsect_start:
    1.37 ++	cld				# assume nothing
    1.38 ++stacktop	= 0x9E00		# in 0x8000 .. 0xA000
    1.39 ++zeroed		= 48+10			# gdt + zeroed registers
    1.40 ++	movw	$stacktop-12-zeroed, %di	# stacktop is an arbitrary value >=
    1.41 ++					# length of bootsect + length of
    1.42 ++					# setup + room for stack;
    1.43 ++					# 12 is disk parm size.
    1.44 ++	pushw	$INITSEG
    1.45 ++	popw	%es			# %es = INITSEG
    1.46 + 
    1.47 +-	# Normalize the start address
    1.48 +-	ljmp	$BOOTSEG, $start2
    1.49 ++	pushw	%es
    1.50 ++	popw	%ss			# %ss and %es already contain INITSEG
    1.51 ++	movw	%di, %sp		# put stack at INITSEG:stacktop-...
    1.52 + 
    1.53 +-start2:
    1.54 +-	movw	%cs, %ax
    1.55 +-	movw	%ax, %ds
    1.56 +-	movw	%ax, %es
    1.57 +-	movw	%ax, %ss
    1.58 +-	xorw	%sp, %sp
    1.59 +-	sti
    1.60 +-	cld
    1.61 ++# Many BIOS's default disk parameter tables will not recognize
    1.62 ++# multi-sector reads beyond the maximum sector number specified
    1.63 ++# in the default diskette parameter tables - this may mean 7
    1.64 ++# sectors in some cases.
    1.65 ++#
    1.66 ++# Since single sector reads are slow and out of the question,
    1.67 ++# we must take care of this by creating new parameter tables
    1.68 ++# (for the first disk) in RAM.  We can set the maximum sector
    1.69 ++# count to 36 - the most we will encounter on an ED 2.88.  
    1.70 ++#
    1.71 ++# High doesn't hurt.  Low does.  Let's use the max: 63
    1.72 ++#
    1.73 ++# Segments are as follows: %es = %ss = INITSEG,
    1.74 + 
    1.75 +-	movw	$bugger_off_msg, %si
    1.76 ++	xorw	%ax, %ax		# %ax = 0
    1.77 ++	movw	$zeroed/2, %cx		# clear gdt + offset, %ds, limits
    1.78 ++	rep				# don't worry about cld
    1.79 ++	stosw				# already done above
    1.80 ++	popw	%bx			# offset = 0
    1.81 ++	popw	%ds			# %ds = 0
    1.82 ++	popw	%gs			# %gs = 0
    1.83 + 
    1.84 +-msg_loop:
    1.85 +-	lodsb
    1.86 +-	andb	%al, %al
    1.87 +-	jz	bs_die
    1.88 +-	movb	$0xe, %ah
    1.89 +-	movw	$7, %bx
    1.90 ++	movb	setup_sects+0x7C00, %al	# read bootsector + setup (%ds = 0)
    1.91 ++	incw	%ax
    1.92 ++
    1.93 ++	pushw	%es
    1.94 ++	pushw	%di			# %ds:%bx+0x78 is parameter table address
    1.95 ++	ldsw	0x78(%bx), %si		# %ds:%si is source
    1.96 ++	movb	$6, %cl			# copy 12 bytes
    1.97 ++	rep				# don't worry about cld
    1.98 ++	movsw				# already done above
    1.99 ++	popl	%gs:0x78(%bx)		# update parameter table address
   1.100 ++	pushw	%es
   1.101 ++	popw	%ds			# now %ds = %es = %ss = INITSEG
   1.102 ++	movb	$63, 0x4-12(%di)	# patch sector count, %di = stacktop
   1.103 ++	cli
   1.104 ++
   1.105 ++	xchg	%ax, %di		# sector count
   1.106 ++	popw	%ax			# limits = 0
   1.107 ++	incw	%cx			# cylinder 0, sector 1
   1.108 ++	call	read_first_sectors	# read setup
   1.109 ++
   1.110 ++offset_version	= 0xE
   1.111 ++	movw	$0x200,%si
   1.112 ++	addw	offset_version(%si),%si	# starting protocol 2.00, Kernel 1.3.73
   1.113 ++	call	puts			# show which kernel we are loading
   1.114 ++
   1.115 ++# The cmdline can be entered and modifed at boot time.
   1.116 ++# Only characters before the cursor are passed to the kernel.
   1.117 ++	popw	%bx			# clear %bx
   1.118 ++	orw	cmd_line_ptr, %bx
   1.119 ++	jz	nocmdline
   1.120 ++	pushw	%bx
   1.121 ++	call	read_one_sector
   1.122 ++	popw	%si
   1.123 ++	call	puts
   1.124 ++#ifdef	EDIT_CMDLINE
   1.125 ++cmdlp:
   1.126 ++	movb	$0x20, %al		# clear end of line
   1.127 ++	int	$0x10			#  with Space
   1.128 ++	movb	$8, %al			#   and BackSpace
   1.129 + 	int	$0x10
   1.130 +-	jmp	msg_loop
   1.131 ++	decw	%si
   1.132 ++cmdget:
   1.133 ++	call	wait4key
   1.134 ++	cmpb	$8, %al			# BackSpace ?
   1.135 ++	je	cmdbs
   1.136 ++	movb	%al, (%si)		# store char
   1.137 ++	lodsw				# %si += 2
   1.138 ++cmdbs:
   1.139 ++#if 1
   1.140 ++	cmpw	%si,cmd_line_ptr
   1.141 ++	je	cmdget
   1.142 ++#endif
   1.143 ++	call	putc			# set %ah and %bx
   1.144 ++	cmpb	$10, %al		# Enter ?
   1.145 ++	jne	cmdlp
   1.146 ++	movb	%bh,-2(%si)		# set end of string and remove CR
   1.147 ++endcmdline:
   1.148 ++#endif
   1.149 ++nocmdline:
   1.150 + 
   1.151 +-bs_die:
   1.152 +-	# Allow the user to press a key, then reboot
   1.153 +-	xorw	%ax, %ax
   1.154 +-	int	$0x16
   1.155 +-	int	$0x19
   1.156 ++# This routine loads the system at address SYSSEG, making sure
   1.157 ++# no 64kB boundaries are crossed. We try to load it as fast as
   1.158 ++# possible, loading whole tracks whenever we can.
   1.159 + 
   1.160 +-	# int 0x19 should never return.  In case it does anyway,
   1.161 +-	# invoke the BIOS reset code...
   1.162 +-	ljmp	$0xf000,$0xfff0
   1.163 ++ramdisk_image	=	0x0218
   1.164 ++ramdisk_size	=	0x021C
   1.165 ++	movw	%sp, %si		# for bootsect_gdt
   1.166 ++	decw	16(%si)			# bootsect_src = 64Kb
   1.167 ++	decw	24(%si)			# bootsect_dst = 64Kb
   1.168 ++	movw	$syssize, %di
   1.169 ++type_of_loader	=	0x210
   1.170 ++loadflags	=	0x211
   1.171 ++heap_end_ptr	=	0x224
   1.172 ++ksyssize	= 	500
   1.173 ++	orw	$0x80FF, type_of_loader-ksyssize(%di) # loader type = 0xFF
   1.174 ++	movw	$stacktop-0x200, heap_end_ptr-ksyssize(%di)
   1.175 ++	movb	$0x0F, %al		# destination = 0x100000
   1.176 ++	movb	$5, %cl
   1.177 ++initrdlp:
   1.178 ++	movb	$0x93,%ah
   1.179 ++	movw	%ax, 28(%si)		# bootsect_dst_base+2
   1.180 ++	movb	$(SYSSEG/4096), %al	# source = SYSSEG
   1.181 ++	movw	%ax, 20(%si)		# bootsect_src_base+2
   1.182 ++	cbw
   1.183 ++	cwde
   1.184 ++	shlw	%cl, %ax
   1.185 ++	decw	%ax
   1.186 ++	addl	(%di),%eax
   1.187 ++	shrl	%cl, %eax
   1.188 ++syslp:
   1.189 ++	pushw	$SYSSEG
   1.190 ++	popw	%es
   1.191 ++	movw	$128,%di		# 64Kb
   1.192 ++	subw	%di, %ax		# max 32M > int 15 limit
   1.193 ++	pushf
   1.194 ++	jnc	not_last
   1.195 ++	addw	%ax, %di
   1.196 ++not_last:
   1.197 ++	xorw	%bx, %bx		# clear %bx
   1.198 ++	pushw	%ax
   1.199 ++#if defined(SHOW_REGS)
   1.200 ++	pushw	%si
   1.201 ++	call	read_sectors
   1.202 ++	popw	%si
   1.203 ++#else
   1.204 ++	call	read_sectors
   1.205 ++#endif
   1.206 ++	movw	$0x8000, %cx		# full 64K
   1.207 ++	movb	$0x87, %ah
   1.208 ++	incb	28(%si)			# bootsect_dst_base+2
   1.209 ++	int	$0x15			# max 16M
   1.210 ++	popw	%ax
   1.211 ++	popf
   1.212 ++	ja	syslp
   1.213 ++	movw	ramdisk_image+2,%ax
   1.214 ++	decw	%ax
   1.215 ++	movw	$ramdisk_size,%di
   1.216 ++	movb	$9, %cl
   1.217 ++	cmpb	%al,28(%si)
   1.218 ++	jb	initrdlp
   1.219 + 
   1.220 +-	.section ".bsdata", "a"
   1.221 +-bugger_off_msg:
   1.222 +-	.ascii	"Direct booting from floppy is no longer supported.\r\n"
   1.223 +-	.ascii	"Please use a boot loader program instead.\r\n"
   1.224 +-	.ascii	"\n"
   1.225 +-	.ascii	"Remove disk and press any key to reboot . . .\r\n"
   1.226 +-	.byte	0
   1.227 ++# This procedure turns off the floppy drive motor, so
   1.228 ++# that we enter the kernel in a known state, and
   1.229 ++# don't have to worry about it later.
   1.230 + 
   1.231 ++#if 1
   1.232 ++kill_motor:
   1.233 ++	xchgw	%ax, %bx		# reset FDC
   1.234 ++	int	$0x13
   1.235 ++#else
   1.236 ++kill_motor:
   1.237 ++	movw	$0x3f2, %dx
   1.238 ++	xchgw	%ax, %bx
   1.239 ++	outb	%al, %dx
   1.240 ++#endif
   1.241 ++
   1.242 ++# After that (everything loaded), we jump to the setup-routine
   1.243 ++# loaded directly after the bootblock:
   1.244 ++# Segments are as follows: %ds = %ss = INITSEG
   1.245 ++
   1.246 ++	ljmp	$SETUPSEG, $0
   1.247 ++
   1.248 ++# read_sectors reads %di sectors into %es:0 buffer.
   1.249 ++# %es:0 is updated to the next memory location.
   1.250 ++# First, sectors are read sector by sector until
   1.251 ++# sector per track count is known. Then they are
   1.252 ++# read track by track.
   1.253 ++# Assume no error on first track.
   1.254 ++
   1.255 ++#define FLOPPY_CYLINDERS	80	/* 80 cylinders minimum */
   1.256 ++#define FLOPPY_HEADS		2	/* 2 heads minimum */
   1.257 ++#define FLOPPY_SECTORS		18	/* 18 sectors minimum */
   1.258 ++
   1.259 ++#ifdef SHOW_REGS
   1.260 ++print_loop:
   1.261 ++	movb	$0x6 + 'A' - 1, %al
   1.262 ++	subb	%cl, %al
   1.263 ++	movw	$regs, %si		# caller %si is saved
   1.264 ++	call	putcs			# putc(%al) + puts(%si)
   1.265 ++# it will print out all of the registers.
   1.266 ++	popw	%bp			# load word into %si
   1.267 ++	jmp	print_all		# print %bp (status)
   1.268 ++#endif
   1.269 ++check_limits:
   1.270 ++#ifndef SHOW_REGS
   1.271 ++	popw	%dx
   1.272 ++#endif
   1.273 ++	cmpb	$FLOPPY_SECTORS+1, %cl	# 18 sectors minimum
   1.274 ++	jb	check_head
   1.275 ++        cmpb    %al, %cl		# max sector known ?
   1.276 ++        ja	next_head		#   no -> store it
   1.277 ++check_head:
   1.278 ++	cmpb	$FLOPPY_HEADS, %dh	# 2 heads minimum
   1.279 ++	jb	check_cylinder
   1.280 ++        cmpb    %ah, %dh		# max head known ?
   1.281 ++        ja	next_cylinder		#   no -> store it
   1.282 ++check_cylinder:
   1.283 ++	pushaw
   1.284 ++#ifdef SHOW_REGS
   1.285 ++	cmpw	$0x600,%bp		# disk changed ?
   1.286 ++	je	reset_floppy
   1.287 ++	pushw	%es			# print %es (named EX)
   1.288 ++	pushw	%dx			# print %dx
   1.289 ++	pushw	%cx			# print %cx
   1.290 ++	pushw	%bx			# print %bx
   1.291 ++	xchgw	%ax, %si
   1.292 ++	movb	$2,%ah
   1.293 ++	pushw	%ax			# print %ax
   1.294 ++	movb	$6,%cl
   1.295 ++print_all:
   1.296 ++	movb	$4, %ch			# 4 hex digits
   1.297 ++print_digit:
   1.298 ++	rolw	$4, %bp			# rotate to use low 4 bits
   1.299 ++	movb	$0x0f, %al
   1.300 ++	andw	%bp, %ax		# %al = mask for nybble
   1.301 ++	addb	$0x90, %al		# convert %al to ascii hex
   1.302 ++	daa				# in only four instructions!
   1.303 ++	adcb	$0x40, %al
   1.304 ++	daa
   1.305 ++	call	putc			# set %ah and %bx
   1.306 ++	decb	%ch
   1.307 ++	jnz	print_digit
   1.308 ++	movb	$0x20, %al		# SPACE
   1.309 ++	int	$0x10
   1.310 ++	loop	print_loop
   1.311 ++	call	wait
   1.312 ++	cbw				# %ah = 0
   1.313 ++reset_floppy:
   1.314 ++#else
   1.315 ++	cbw				# %ah = 0
   1.316 ++#endif
   1.317 ++        int     $0x13			# reset controler
   1.318 ++	popaw
   1.319 ++read_sectorslp:
   1.320 ++	pushw	%dx			# some bios break dx...
   1.321 ++        pushw   %ax			# limits
   1.322 ++	subb	%cl, %al		# sectors remaining in track
   1.323 ++	ja	tolastsect
   1.324 ++	movb	$1, %al			# 1 sector mini
   1.325 ++tolastsect:
   1.326 ++	cbw
   1.327 ++	cmpw	%di, %ax
   1.328 ++	jb	more1trk
   1.329 ++	movw	%di, %ax		# sectors to read
   1.330 ++more1trk:
   1.331 ++	pushw	%ax			# save context
   1.332 ++	movb	$2, %ah			# cmd: read chs
   1.333 ++        int     $0x13
   1.334 ++#ifdef SHOW_REGS
   1.335 ++	xchgw	%ax, %bp		# status
   1.336 ++#endif
   1.337 ++# ifdef SHOW_REGS
   1.338 ++	popw	%si			# save %ax
   1.339 ++        popw    %ax			# limits
   1.340 ++	popw	%dx
   1.341 ++# else
   1.342 ++	popw	%dx			# save %ax
   1.343 ++        popw    %ax			# limits
   1.344 ++# endif
   1.345 ++	jc	check_limits
   1.346 ++# ifdef SHOW_REGS
   1.347 ++update_regs:
   1.348 ++	decw	%di			# update sector counter
   1.349 ++	incw	%cx			# next sector
   1.350 ++	addb	$2,%bh			# next location
   1.351 ++	decw	%si
   1.352 ++	jnz	update_regs
   1.353 ++# else
   1.354 ++	subw	%dx,%di			# update sector counter
   1.355 ++	addw	%dx,%cx			# next sector
   1.356 ++	addw	%dx,%dx
   1.357 ++	addb	%dl,%bh			# next location
   1.358 ++	popw	%dx
   1.359 ++# endif
   1.360 ++        cmpb    %al,%cl			# reach sector limit ?
   1.361 ++        jne     bdendlp
   1.362 ++next_head:
   1.363 ++        movb    %cl,%al
   1.364 ++        incb    %dh			# next head
   1.365 ++        movb    $1,%cl			# first sector
   1.366 ++        cmpb    %ah, %dh		# reach head limit ?
   1.367 ++        jne     bdendlp
   1.368 ++next_cylinder:
   1.369 ++        movb    %dh,%ah
   1.370 ++# NOTE : support 256 cylinders max
   1.371 ++        incb    %ch			# next cylinder
   1.372 ++read_first_sectors:
   1.373 ++        movb    $0,%dh			# first head
   1.374 ++cylinder_count	= 496
   1.375 ++	cmpb	cylinder_count, %ch
   1.376 ++        jb	bdendlp
   1.377 ++        cmpb    $FLOPPY_CYLINDERS,%ch	# reach cylinder limit ?
   1.378 ++        jb	bdendlp
   1.379 ++next_floppy:
   1.380 ++	movb	$0,%ch			# first cylinder
   1.381 ++	pushaw
   1.382 ++	movw	$swap_floppy,%si
   1.383 ++	incb	12(%si)
   1.384 ++	pushw	%bx
   1.385 ++	call	puts
   1.386 ++	popw	%bx
   1.387 ++waitfloppy:
   1.388 ++	call	wait
   1.389 ++	jne	waitfloppydone
   1.390 ++	pushw	%dx			# some bios break dx...
   1.391 ++	cbw
   1.392 ++	int	$0x13			# reset FDC
   1.393 ++	movw	$0x201,%ax
   1.394 ++#	cwd
   1.395 ++#	movw	$1,%cx
   1.396 ++	int	$0x13			# read first sector
   1.397 ++	popw	%dx
   1.398 ++	rclb	$1,%ah			# floppy changed 06=>0D no error 00
   1.399 ++	cmpb	-2(%si), %ah		# 0D then 00
   1.400 ++	jne	waitfloppy		# no => try again
   1.401 ++	incw	%si
   1.402 ++	orb	%ah,%ah			# was 00 ?
   1.403 ++	jne	waitfloppy
   1.404 ++waitfloppydone:
   1.405 ++	popaw
   1.406 ++bdendlp:
   1.407 ++	xchgw	%ax, %bp
   1.408 ++	movw	%cx, %fs
   1.409 ++read_sectors:
   1.410 ++	decw	%di
   1.411 ++read_one_sector:
   1.412 ++	movw	%fs, %cx
   1.413 ++#   al is last sector+1
   1.414 ++#   ah is last cylinder+1
   1.415 ++	movw	%bp, %ax
   1.416 ++	incw	%di
   1.417 ++        jnz	read_sectorslp
   1.418 ++	pushw	%ss
   1.419 ++	popw	%es			# restore es
   1.420 ++	movb	$0x2e+3, %al 		# loading... message 2e = .
   1.421 ++putclf:
   1.422 ++	subb	$3, %al
   1.423 ++putc:
   1.424 ++	movb	$0xe, %ah
   1.425 ++	movw	$7, %bx			#   one dot each 64k
   1.426 ++ 	int	$0x10
   1.427 ++	cmp	$0xd, %al		# CR ?
   1.428 ++	je	putclf
   1.429 ++	ret
   1.430 ++
   1.431 ++puts:
   1.432 ++	movb	$0xd, %al		# CR
   1.433 ++putcs:
   1.434 ++	call	putc
   1.435 ++	lodsb
   1.436 ++	orb	%al,%al			# end of string is \0
   1.437 ++	jnz	putcs
   1.438 ++	ret
   1.439 ++
   1.440 ++clock	= 0x46C
   1.441 ++wait:
   1.442 ++wait4key:
   1.443 ++	movw	$clock, %di
   1.444 ++#define DELAY 5
   1.445 ++	movb	$(DELAY*182)/10,%cl
   1.446 ++	addb	%gs:(%di),%cl
   1.447 ++waitkbd:
   1.448 ++	movw	$0x10D, %ax		# test keyboard, timeout => CR
   1.449 ++	cmpb	%gs:(%di),%cl
   1.450 ++	je	waitdone
   1.451 ++	int	$0x16
   1.452 ++	jz	waitkbd
   1.453 ++	cbw
   1.454 ++	int	$0x16			# eat char
   1.455 ++	movw	%di, %gs		# disable timeout
   1.456 ++	incw	%di			# clear Z
   1.457 ++waitdone:
   1.458 ++	ret
   1.459 ++
   1.460 ++#ifdef SHOW_REGS
   1.461 ++regs:	.asciz	"X:"
   1.462 ++#endif
   1.463 ++
   1.464 ++swap_floppy:	.ascii	"Insert disk 1"
   1.465 ++		.ascii	"."
   1.466 ++		.byte	7,13,0
   1.467 + 
   1.468 + 	# Kernel attributes; used by setup.  This is part 1 of the
   1.469 + 	# header, from the old boot sector.