wok-next rev 5383

linux/boot: fix floppy full case
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat May 01 15:45:41 2010 +0200 (2010-05-01)
parents 9e38c2f11c48
children 38d232c76a55
files linux/stuff/linux-header-2.6.33.2.u
line diff
     1.1 --- a/linux/stuff/linux-header-2.6.33.2.u	Sat May 01 14:52:42 2010 +0200
     1.2 +++ b/linux/stuff/linux-header-2.6.33.2.u	Sat May 01 15:45:41 2010 +0200
     1.3 @@ -9,7 +9,7 @@
     1.4    *
     1.5    * BIG FAT NOTE: We're in real mode using 64k segments.  Therefore segment
     1.6    * addresses must be multiplied by 16 to obtain their respective linear
     1.7 -@@ -26,6 +26,8 @@
     1.8 +@@ -27,6 +27,8 @@
     1.9   
    1.10   BOOTSEG		= 0x07C0		/* original address of boot-sector */
    1.11   SYSSEG		= 0x1000		/* historical load address >> 4 */
    1.12 @@ -18,7 +18,7 @@
    1.13   
    1.14   #ifndef SVGA_MODE
    1.15   #define SVGA_MODE ASK_VGA
    1.16 -@@ -39,53 +41,412 @@
    1.17 +@@ -40,53 +42,412 @@
    1.18   #define ROOT_RDONLY 1
    1.19   #endif
    1.20   
    1.21 @@ -40,21 +40,11 @@
    1.22  +					# 12 is disk parm size.
    1.23  +	pushw	$INITSEG
    1.24  +	popw	%es			# %es = INITSEG
    1.25 - 
    1.26 --	# Normalize the start address
    1.27 --	ljmp	$BOOTSEG, $start2
    1.28 ++
    1.29  +	pushw	%es
    1.30  +	popw	%ss			# %ss and %es already contain INITSEG
    1.31  +	movw	%di, %sp		# put stack at INITSEG:stacktop-...
    1.32 - 
    1.33 --start2:
    1.34 --	movw	%cs, %ax
    1.35 --	movw	%ax, %ds
    1.36 --	movw	%ax, %es
    1.37 --	movw	%ax, %ss
    1.38 --	xorw	%sp, %sp
    1.39 --	sti
    1.40 --	cld
    1.41 ++
    1.42  +# Many BIOS's default disk parameter tables will not recognize
    1.43  +# multi-sector reads beyond the maximum sector number specified
    1.44  +# in the default diskette parameter tables - this may mean 7
    1.45 @@ -68,8 +58,7 @@
    1.46  +# High doesn't hurt.  Low does.  Let's use the max: 63
    1.47  +#
    1.48  +# Segments are as follows: %es = %ss = INITSEG,
    1.49 - 
    1.50 --	movw	$bugger_off_msg, %si
    1.51 ++
    1.52  +	xorw	%ax, %ax		# %ax = 0
    1.53  +	movw	$zeroed/2, %cx		# clear gdt + offset, %ds, limits
    1.54  +	rep				# don't worry about cld
    1.55 @@ -77,13 +66,7 @@
    1.56  +	popw	%bx			# offset = 0
    1.57  +	popw	%ds			# %ds = 0
    1.58  +	popw	%gs			# %gs = 0
    1.59 - 
    1.60 --msg_loop:
    1.61 --	lodsb
    1.62 --	andb	%al, %al
    1.63 --	jz	bs_die
    1.64 --	movb	$0xe, %ah
    1.65 --	movw	$7, %bx
    1.66 ++
    1.67  +	movb	setup_sects+0x7C00, %al	# read bootsector + setup (%ds = 0)
    1.68  +	incw	%ax
    1.69  +
    1.70 @@ -107,7 +90,7 @@
    1.71  +offset_version	= 0xE
    1.72  +	movw	$0x200,%si
    1.73  +	addw	offset_version(%si),%si	# starting protocol 2.00, Kernel 1.3.73
    1.74 -+	call	puts			# show which kernel we are loading
    1.75 ++	call	putstr			# show which kernel we are loading
    1.76  +
    1.77  +# The cmdline can be entered and modifed at boot time.
    1.78  +# Only characters before the cursor are passed to the kernel.
    1.79 @@ -115,16 +98,16 @@
    1.80  +	orw	cmd_line_ptr, %bx
    1.81  +	jz	nocmdline
    1.82  +	pushw	%bx
    1.83 -+	call	read_one_sector
    1.84 ++	incw	%di
    1.85 ++	call	read_sectors
    1.86  +	popw	%si
    1.87 -+	call	puts
    1.88 ++	call	putstr
    1.89  +#ifdef	EDIT_CMDLINE
    1.90  +cmdlp:
    1.91  +	movb	$0x20, %al		# clear end of line
    1.92  +	int	$0x10			#  with Space
    1.93  +	movb	$8, %al			#   and BackSpace
    1.94 - 	int	$0x10
    1.95 --	jmp	msg_loop
    1.96 ++	int	$0x10
    1.97  +	decw	%si
    1.98  +cmdget:
    1.99  +	call	wait4key
   1.100 @@ -145,18 +128,23 @@
   1.101  +#endif
   1.102  +nocmdline:
   1.103   
   1.104 --bs_die:
   1.105 --	# Allow the user to press a key, then reboot
   1.106 --	xorw	%ax, %ax
   1.107 --	int	$0x16
   1.108 --	int	$0x19
   1.109 +-	# Normalize the start address
   1.110 +-	ljmp	$BOOTSEG, $start2
   1.111 +-
   1.112 +-start2:
   1.113 +-	movw	%cs, %ax
   1.114 +-	movw	%ax, %ds
   1.115 +-	movw	%ax, %es
   1.116 +-	movw	%ax, %ss
   1.117 +-	xorw	%sp, %sp
   1.118 +-	sti
   1.119 +-	cld
   1.120 +-
   1.121 +-	movw	$bugger_off_msg, %si
   1.122  +# This routine loads the system at address SYSSEG, making sure
   1.123  +# no 64kB boundaries are crossed. We try to load it as fast as
   1.124  +# possible, loading whole tracks whenever we can.
   1.125 - 
   1.126 --	# int 0x19 should never return.  In case it does anyway,
   1.127 --	# invoke the BIOS reset code...
   1.128 --	ljmp	$0xf000,$0xfff0
   1.129 ++
   1.130  +ramdisk_image	=	0x0218
   1.131  +ramdisk_size	=	0x021C
   1.132  +	movw	%sp, %si		# for bootsect_gdt
   1.133 @@ -213,18 +201,11 @@
   1.134  +	movb	$9, %cl
   1.135  +	cmpb	%al,28(%si)
   1.136  +	jb	initrdlp
   1.137 - 
   1.138 --	.section ".bsdata", "a"
   1.139 --bugger_off_msg:
   1.140 --	.ascii	"Direct booting from floppy is no longer supported.\r\n"
   1.141 --	.ascii	"Please use a boot loader program instead.\r\n"
   1.142 --	.ascii	"\n"
   1.143 --	.ascii	"Remove disk and press any key to reboot . . .\r\n"
   1.144 --	.byte	0
   1.145 ++
   1.146  +# This procedure turns off the floppy drive motor, so
   1.147  +# that we enter the kernel in a known state, and
   1.148  +# don't have to worry about it later.
   1.149 - 
   1.150 ++
   1.151  +#if 1
   1.152  +kill_motor:
   1.153  +	xchgw	%ax, %bx		# reset FDC
   1.154 @@ -235,7 +216,13 @@
   1.155  +	xchgw	%ax, %bx
   1.156  +	outb	%al, %dx
   1.157  +#endif
   1.158 -+
   1.159 + 
   1.160 +-msg_loop:
   1.161 +-	lodsb
   1.162 +-	andb	%al, %al
   1.163 +-	jz	bs_die
   1.164 +-	movb	$0xe, %ah
   1.165 +-	movw	$7, %bx
   1.166  +# After that (everything loaded), we jump to the setup-routine
   1.167  +# loaded directly after the bootblock:
   1.168  +# Segments are as follows: %ds = %ss = INITSEG
   1.169 @@ -258,7 +245,7 @@
   1.170  +	movb	$0x6 + 'A' - 1, %al
   1.171  +	subb	%cl, %al
   1.172  +	movw	$regs, %si		# caller %si is saved
   1.173 -+	call	putcs			# putc(%al) + puts(%si)
   1.174 ++	call	putcs			# putc(%al) + putstr(%si)
   1.175  +# it will print out all of the registers.
   1.176  +	popw	%bp			# load word into %si
   1.177  +	jmp	print_all		# print %bp (status)
   1.178 @@ -303,7 +290,12 @@
   1.179  +	decb	%ch
   1.180  +	jnz	print_digit
   1.181  +	movb	$0x20, %al		# SPACE
   1.182 -+	int	$0x10
   1.183 + 	int	$0x10
   1.184 +-	jmp	msg_loop
   1.185 +-
   1.186 +-bs_die:
   1.187 +-	# Allow the user to press a key, then reboot
   1.188 +-	xorw	%ax, %ax
   1.189  +	loop	print_loop
   1.190  +	call	wait
   1.191  +	cbw				# %ah = 0
   1.192 @@ -340,20 +332,27 @@
   1.193  +        popw    %ax			# limits
   1.194  +# endif
   1.195  +	jc	check_limits
   1.196 ++	xchgw	%ax, %bp
   1.197  +# ifdef SHOW_REGS
   1.198  +update_regs:
   1.199 ++	incw	%cx			# next sector
   1.200 ++	movw	%cx, %fs
   1.201 ++	addb	$2,%bh			# next location
   1.202  +	decw	%di			# update sector counter
   1.203 -+	incw	%cx			# next sector
   1.204 -+	addb	$2,%bh			# next location
   1.205 ++	jz	putcdot
   1.206  +	decw	%si
   1.207  +	jnz	update_regs
   1.208  +# else
   1.209 ++	addw	%dx,%cx			# next sector
   1.210 ++	addb	%dl,%bh
   1.211 ++	addb	%dl,%bh			# next location
   1.212  +	subw	%dx,%di			# update sector counter
   1.213 -+	addw	%dx,%cx			# next sector
   1.214 -+	addw	%dx,%dx
   1.215 -+	addb	%dl,%bh			# next location
   1.216  +	popw	%dx
   1.217 ++	jz	putcdot
   1.218  +# endif
   1.219 ++read_sectors:
   1.220 ++	movw	%fs, %cx
   1.221 ++	xchgw	%ax, %bp
   1.222  +        cmpb    %al,%cl			# reach sector limit ?
   1.223  +        jne     bdendlp
   1.224  +next_head:
   1.225 @@ -369,17 +368,17 @@
   1.226  +read_first_sectors:
   1.227  +        movb    $0,%dh			# first head
   1.228  +cylinder_count	= 496
   1.229 ++        cmpb    $FLOPPY_CYLINDERS,%ch	# reach cylinder limit ?
   1.230 ++        jb	bdendlp
   1.231  +	cmpb	cylinder_count, %ch
   1.232  +        jb	bdendlp
   1.233 -+        cmpb    $FLOPPY_CYLINDERS,%ch	# reach cylinder limit ?
   1.234 -+        jb	bdendlp
   1.235  +next_floppy:
   1.236  +	movb	$0,%ch			# first cylinder
   1.237  +	pushaw
   1.238  +	movw	$swap_floppy,%si
   1.239  +	incb	12(%si)
   1.240  +	pushw	%bx
   1.241 -+	call	puts
   1.242 ++	call	putstr
   1.243  +	popw	%bx
   1.244  +waitfloppy:
   1.245  +	call	wait
   1.246 @@ -401,17 +400,9 @@
   1.247  +waitfloppydone:
   1.248  +	popaw
   1.249  +bdendlp:
   1.250 -+	xchgw	%ax, %bp
   1.251 -+	movw	%cx, %fs
   1.252 -+read_sectors:
   1.253 -+	decw	%di
   1.254 -+read_one_sector:
   1.255 -+	movw	%fs, %cx
   1.256 -+#   al is last sector+1
   1.257 -+#   ah is last cylinder+1
   1.258 -+	movw	%bp, %ax
   1.259 -+	incw	%di
   1.260 -+        jnz	read_sectorslp
   1.261 ++        jmp	read_sectorslp
   1.262 ++
   1.263 ++putcdot:
   1.264  +	pushw	%ss
   1.265  +	popw	%es			# restore es
   1.266  +	movb	$0x2e+3, %al 		# loading... message 2e = .
   1.267 @@ -425,7 +416,7 @@
   1.268  +	je	putclf
   1.269  +	ret
   1.270  +
   1.271 -+puts:
   1.272 ++putstr:
   1.273  +	movb	$0xd, %al		# CR
   1.274  +putcs:
   1.275  +	call	putc
   1.276 @@ -445,7 +436,8 @@
   1.277  +	movw	$0x10D, %ax		# test keyboard, timeout => CR
   1.278  +	cmpb	%gs:(%di),%cl
   1.279  +	je	waitdone
   1.280 -+	int	$0x16
   1.281 + 	int	$0x16
   1.282 +-	int	$0x19
   1.283  +	jz	waitkbd
   1.284  +	cbw
   1.285  +	int	$0x16			# eat char
   1.286 @@ -453,11 +445,22 @@
   1.287  +	incw	%di			# clear Z
   1.288  +waitdone:
   1.289  +	ret
   1.290 -+
   1.291 + 
   1.292 +-	# int 0x19 should never return.  In case it does anyway,
   1.293 +-	# invoke the BIOS reset code...
   1.294 +-	ljmp	$0xf000,$0xfff0
   1.295 +-
   1.296 +-	.section ".bsdata", "a"
   1.297 +-bugger_off_msg:
   1.298 +-	.ascii	"Direct booting from floppy is no longer supported.\r\n"
   1.299 +-	.ascii	"Please use a boot loader program instead.\r\n"
   1.300 +-	.ascii	"\n"
   1.301 +-	.ascii	"Remove disk and press any key to reboot . . .\r\n"
   1.302 +-	.byte	0
   1.303  +#ifdef SHOW_REGS
   1.304 -+regs:	.asciz	"X:"
   1.305 ++regs:		.asciz	"X:"
   1.306  +#endif
   1.307 -+
   1.308 + 
   1.309  +swap_floppy:	.ascii	"Insert disk 1"
   1.310  +		.ascii	"."
   1.311  +		.byte	7,13,0