wok diff ipxe/stuff/bootloader.S @ rev 20184

memtest, ipxe: update bootsector
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 01 12:59:51 2018 +0100 (2018-02-01)
parents d74b8b5a78d0
children ccdba9b27403
line diff
     1.1 --- a/ipxe/stuff/bootloader.S	Sat Jan 27 12:56:10 2018 +0100
     1.2 +++ b/ipxe/stuff/bootloader.S	Thu Feb 01 12:59:51 2018 +0100
     1.3 @@ -1,8 +1,6 @@
     1.4  // Image/zImage & tiny bzImage linux kernel boot sector, (C) SliTaz, GPL2.
     1.5  
     1.6  SYSSEG		= 0x1000
     1.7 -INITSEG		= 0x9000
     1.8 -SETUPSEG	= 0x9020
     1.9  setup_sects	= 497
    1.10  syssize		= 500
    1.11  cmd_line_ptr	= 0x228
    1.12 @@ -15,35 +13,77 @@
    1.13  
    1.14  #define CODESZ 512		/* patched by installer */
    1.15  
    1.16 +// Default kernel format is 386 Image/zImage
    1.17  #define BZIMAGE 0x207		/* setup version ; for bzImage < 512 Kb only */
    1.18 +//#define ELKS			/* 8086/286 linux port */
    1.19  
    1.20  /* some extra features */
    1.21 -#define EXE_SUPPORT		real mode dos .exe file support
    1.22 -#define CMDLINE			kernel cmdline support	
    1.23 -#define VCPI			VCPI 4.0 support
    1.24 -#define SHUTDOWNDOS		shutdown DOS services
    1.25 +#define EXE_SUPPORT		real mode dos .exe file support	+208/264
    1.26 +#define  CMDLINE		dos kernel cmdline support	+45
    1.27 +#define  VCPI			VCPI 4.0 support (386+)		+109
    1.28 +#define  SHUTDOWNDOS		shutdown DOS services		+29
    1.29  
    1.30  /* some contraints to reduce the code size */
    1.31 -//#define FLOPPY_1440K_ONLY	1.44M floppies support only	-33
    1.32 -//#define FLOPPY_HAS_2_SIDES	hardcoded heads count to 2	-13
    1.33 -//#define NO_CMDLINE_SHRINK	remove heading spaces ?		-6-20
    1.34 -//#define NO_CMDLINE_FILE	remove @cmdline file support ?	-20
    1.35 -#define NO_DOTS		show progression dots ?		-8
    1.36 +//#define FLOPPY_1440K_ONLY	1.44M floppies support only	-26
    1.37 +//#define FLOPPY_HAS_2_SIDES	hardcoded heads count to 2	-15
    1.38 +//#define NO_CMDLINE_SHRINK	remove heading spaces ?		-6-21
    1.39 +//#define  NO_CMDLINE_FILE	remove @cmdline file support ?	-21
    1.40 +//#define NO_DOTS		show progression dots ?		-5
    1.41  #ifndef BZIMAGE
    1.42 +//#define TINY_ZIMAGE		system < 64Kb ?			-11
    1.43  //#defime NO_MINSETUP		default setup (dos only) ?	-4
    1.44  //#define NO_CURSOR_DEFINITION					-8
    1.45  #endif
    1.46  
    1.47 +#ifdef ELKS
    1.48 +	.arch	i8086
    1.49 +INITSEG		= 0x0100
    1.50 +SETUPSEG	= 0x0120
    1.51 +#define ONLY8086
    1.52 +#undef BZIMAGE
    1.53 +#undef VCPI
    1.54 +#else
    1.55 +INITSEG		= 0x9000
    1.56 +SETUPSEG	= 0x9020
    1.57 +#endif
    1.58 +
    1.59 +.macro	shlclw cnt,obj
    1.60 +#ifdef ONLY8086
    1.61 +	movb	\cnt,%cl
    1.62 +	shlw	%cl,\obj
    1.63 +#else
    1.64 +	shlw	\cnt,\obj
    1.65 +#endif
    1.66 +.endm
    1.67 +
    1.68 +.macro	shrclw cnt,obj
    1.69 +#ifdef ONLY8086
    1.70 +	movb	\cnt,%cl
    1.71 +	shrw	%cl,\obj
    1.72 +#else
    1.73 +	shrw	\cnt,\obj
    1.74 +#endif
    1.75 +.endm
    1.76 +
    1.77  #ifdef EXE_SUPPORT
    1.78  #define EXEADRS(x)	(x+0xE0)
    1.79  #define FLAT20(x)	(x+16*INITSEG)
    1.80  
    1.81  .macro	trace_int19
    1.82 +#ifdef ONLY8086
    1.83 +	xorw	%si, %si
    1.84 +	movw	%si, %ds
    1.85 +	pushw	4+2(%si)
    1.86 +	pushw	4(%si)
    1.87 +	movw	$step19, 4(%si)
    1.88 +	movw	$INITSEG, 4+2(%si)
    1.89 +#else
    1.90  	pushl	$4
    1.91  	popw	%si
    1.92  	popw	%ds
    1.93  	pushl	(%si)
    1.94  	movl	$step19+(INITSEG<<16), (%si)
    1.95 +#endif
    1.96  	pushfw
    1.97  	popw	%ax
    1.98  	incb	%ah			# set TF
    1.99 @@ -68,17 +108,19 @@
   1.100  	.word	0xFFF0			// Initial (relative) CS value
   1.101  //	.word	0x001C			// File address of relocation table
   1.102  //	.word	0,0,0			// Overlay number
   1.103 +#else
   1.104 +#undef VCPI
   1.105  #endif
   1.106  start:
   1.107  	xorw	%ax, %ax		# %ax = 0
   1.108 -#ifdef BZIMAGE
   1.109 -zeroed		= 14			# zeroed registers
   1.110 -#else
   1.111  zeroed		= 12			# zeroed registers
   1.112 -#endif
   1.113  	movw	$zeroed/2, %cx		# clear gdt + offset, %ds, limits
   1.114  stacktop	= 0x9E00		# in 0x8000 .. 0xA000 (+zeroed+12)
   1.115 +#ifdef ONLY8086
   1.116 +	movw	$INITSEG, %bx
   1.117 +#else
   1.118  	pushw	$INITSEG
   1.119 +#endif
   1.120  end_header:
   1.121  	cld				# assume nothing
   1.122  #if defined(BZIMAGE) && BZIMAGE >= 0x202
   1.123 @@ -90,6 +132,9 @@
   1.124  					# length of bootsect + length of
   1.125  					# setup + room for stack;
   1.126  					# 12 is disk parm size.
   1.127 +# ifdef ONLY8086
   1.128 +	pushw	%bx
   1.129 +# endif
   1.130  	popw	%es			# %es contain INITSEG
   1.131  #endif
   1.132  	pushw	%es
   1.133 @@ -115,7 +160,6 @@
   1.134  	stosw				# already done above
   1.135  	popw	%bx			# offset = 0
   1.136  	popw	%ds			# %ds = 0
   1.137 -	popw	%fs			# %fs = 0
   1.138  
   1.139  	movb	setup_sects+0x7C00, %al	# read bootsector + setup (%ds = 0)
   1.140  	incw	%ax
   1.141 @@ -123,14 +167,20 @@
   1.142  	ldsw	0x78(%bx), %si		# %ds:%bx+0x78 is parameter table address
   1.143  	pushw	%es
   1.144  	pushw	%di
   1.145 +	pushw	%ds
   1.146  	movb	$6, %cl			# copy 12 bytes
   1.147  	rep				# don't worry about cld
   1.148  	movsw				# already done above
   1.149 +	popw	%ds
   1.150 +#ifdef ONLY8086
   1.151 +	popw	0x78(%bx)		# update parameter table address
   1.152 +	popw	0x78+2(%bx)
   1.153 +#else
   1.154 +	popl	0x78(%bx)		# update parameter table address
   1.155 +#endif
   1.156  	pushw	%ss
   1.157  	popw	%ds			# now %ds = %es = %ss = INITSEG
   1.158 -	popl	%fs:0x78(%bx)		# update parameter table address
   1.159  	movb	$63, 0x4-12(%di)	# patch sector count, %di = stacktop
   1.160 -	cli
   1.161  
   1.162  	xchg	%ax, %di		# sector count
   1.163  	popw	%ax			# limits = 0
   1.164 @@ -141,12 +191,9 @@
   1.165  # no 64kB boundaries are crossed. We try to load it as fast as
   1.166  # possible, loading whole tracks whenever we can.
   1.167  
   1.168 -#ifndef NO_DOTS
   1.169 -	popw	%bx			# clear %bx
   1.170 -#endif
   1.171  	movw	syssize, %di
   1.172  	decw	%di
   1.173 -	shrw	$9-4, %di
   1.174 +	shrclw	$9-4, %di
   1.175  	incw	%di
   1.176  	movw	$SYSSEG, %cx
   1.177  #ifdef BZIMAGE
   1.178 @@ -206,6 +253,7 @@
   1.179  	jne	syslp
   1.180  #endif
   1.181  jmp_setup:
   1.182 +	cli
   1.183  	ljmp	$SETUPSEG, $0
   1.184  
   1.185  #ifdef EXE_SUPPORT
   1.186 @@ -226,16 +274,44 @@
   1.187  	pushw	%cs
   1.188  	popw	%ss
   1.189  	movw	$stacktop-4-16, %sp
   1.190 +#ifdef ONLY8086
   1.191 +	popw	4(%si)
   1.192 +	popw	4+2(%si)
   1.193 +	popw	%bp
   1.194 +	popw	%di
   1.195 +	popw	%si
   1.196 +	popw	%dx
   1.197 +	popw	%cx
   1.198 +	popw	%bx
   1.199 +	popw	%ax
   1.200 +#else
   1.201  	popl	4(%si)
   1.202  	popaw
   1.203 +#endif
   1.204  #ifdef BZIMAGE
   1.205  	jmp	movesys
   1.206  #endif
   1.207  #endif
   1.208  #ifndef BZIMAGE
   1.209  movesys:				// %ax = SYSSEG, %bx = DS, %si
   1.210 -	shrw	$4, %si
   1.211 +	shrclw	$4, %si
   1.212  	addw	%si, %bx
   1.213 +#ifdef TINY_ZIMAGE
   1.214 +	movw	$0xFFFF, %cx
   1.215 +	xorw	%si, %si
   1.216 +	xorw	%di, %di
   1.217 +	cmpw	%ax, %bx
   1.218 +	jc	forward
   1.219 +	decw	%si
   1.220 +	decw	%di
   1.221 +	std
   1.222 +forward:
   1.223 +	movw	%ax, %es
   1.224 +	movw	%bx, %ds
   1.225 +	rep
   1.226 +	  movsb
   1.227 +	cld
   1.228 +#else
   1.229  	subw	%ax, %bx
   1.230  	jnc	forward
   1.231  	movb	$0x90, %ah
   1.232 @@ -255,6 +331,7 @@
   1.233  	rep
   1.234  	  movsb
   1.235  	jns	forward
   1.236 +#endif
   1.237  #ifndef NO_CURSOR_DEFINITION
   1.238  	movb	$1, %ah
   1.239  	movb	$0, %bh
   1.240 @@ -267,7 +344,12 @@
   1.241  #endif
   1.242  comstart:
   1.243  	cld				# assume nothing
   1.244 +#ifdef ONLY8086
   1.245 +	movw	$INITSEG, %ax
   1.246 +	pushw	%ax
   1.247 +#else
   1.248  	pushw	$INITSEG
   1.249 +#endif
   1.250  	popw	%es
   1.251  #ifdef CMDLINE
   1.252  	movw	%sp, %di
   1.253 @@ -345,7 +427,6 @@
   1.254  	int	$0x67
   1.255  	movl	$FLAT20(sw2pm_params),%esi
   1.256  	movb	$0x0C,%al	// DE0C switchpm(ESI)
   1.257 -	cli
   1.258  	jmp	call_vcpi
   1.259  pm_code:
   1.260  	movl	%cr0,%eax
   1.261 @@ -362,7 +443,17 @@
   1.262  # endif
   1.263  #else
   1.264  # ifdef SHUTDOWNDOS
   1.265 +#  ifdef ONLY8086
   1.266 +	pushw	%ax
   1.267 +	pushw	%bx
   1.268 +	pushw	%cx
   1.269 +	pushw	%dx
   1.270 +	pushw	%si
   1.271 +	pushw	%di
   1.272 +	pushw	%bp
   1.273 +#  else
   1.274  	pushaw
   1.275 +#  endif
   1.276  	trace_int19
   1.277  # endif
   1.278  	retf
   1.279 @@ -386,7 +477,6 @@
   1.280  return:
   1.281  #ifndef NO_DOTS
   1.282  	movw	$0xE2E,%ax
   1.283 -	movb	$7,%bl
   1.284  	int	$0x10
   1.285  #endif
   1.286  	ret
   1.287 @@ -405,21 +495,26 @@
   1.288          ja	next_cylinder		#   no -> store it
   1.289  check_cylinder:
   1.290  #endif
   1.291 -#endif
   1.292 -	pushaw
   1.293 -#ifndef FLOPPY_1440K_ONLY
   1.294 +	pushw	%ax
   1.295  	cbw				# %ah = 0
   1.296 +#else
   1.297 +	pushw	%dx
   1.298  #endif
   1.299          int     $0x13			# reset controler
   1.300 -	popaw
   1.301 +#ifndef FLOPPY_1440K_ONLY
   1.302 +	popw	%ax
   1.303  	movb	$1, %al			# sector by sector...
   1.304 +#else
   1.305 +	movw	$1, %ax
   1.306 +	jmp	more1trk
   1.307 +#endif
   1.308  read_sectorslp:
   1.309  	pushw	%dx			# some bios break dx...
   1.310  #ifndef FLOPPY_1440K_ONLY
   1.311          pushw   %ax			# limits
   1.312  	subb	%cl, %al		# sectors remaining in track
   1.313  	ja	tolastsect
   1.314 -	movb	$1, %al			# 1 sector mini
   1.315 +	movb	$1, %al			# first track sector by sector
   1.316  tolastsect:
   1.317  #else
   1.318  	movb	$FLOPPY_SECTORS+1, %al
   1.319 @@ -444,20 +539,20 @@
   1.320  #ifndef FLOPPY_1440K_ONLY
   1.321  	xchgw	%ax, %bp
   1.322  	addw	%dx,%cx			# next sector
   1.323 -	movw	%cx, %gs
   1.324 +	movw	%cx, %si
   1.325 +	pushw	%dx
   1.326 +	shlclw	$5, %dx
   1.327  	movw	%es, %cx
   1.328 -	pushw	%dx
   1.329 -	shlw	$5, %dx
   1.330  	addw	%dx, %cx
   1.331  	popw	%dx
   1.332  	subw	%dx,%di			# update sector counter
   1.333  	popw	%dx
   1.334  #else
   1.335  	addw	%ax,%cx			# next sector
   1.336 -	movw	%cx, %gs
   1.337 +	movw	%cx, %si
   1.338 +	pushw	%ax
   1.339 +	shlclw	$5, %ax
   1.340  	movw	%es, %cx
   1.341 -	pushw	%ax
   1.342 -	shlw	$5, %ax
   1.343  	addw	%ax, %cx
   1.344  	popw	%ax
   1.345  	subw	%ax,%di			# update sector counter
   1.346 @@ -466,10 +561,10 @@
   1.347  	movw	%cx, %es		# next location
   1.348  	jz	return
   1.349  read_sectors:
   1.350 -	movw	%gs, %cx
   1.351 +	movw	%si, %cx
   1.352  #ifndef FLOPPY_1440K_ONLY
   1.353  #   al is last sector+1
   1.354 -#   ah is last cylinder+1
   1.355 +#   ah is last head+1
   1.356  	xchgw	%ax, %bp
   1.357  #endif
   1.358  #ifndef FLOPPY_1440K_ONLY
   1.359 @@ -552,3 +647,8 @@
   1.360  	.word	stacktop-4-16-4,INITSEG
   1.361  # endif
   1.362  #endif
   1.363 +#ifdef ELKS
   1.364 +	.org	0x1E3
   1.365 +	.byte	13,10,7
   1.366 +	.asciz	"ELKS Boot"
   1.367 +#endif