wok-6.x rev 15368

Up ipxe (1.0.0-20130925)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Oct 14 13:38:36 2013 +0000 (2013-10-14)
parents 8267887ae7af
children 4ae7c7dde4e2
files ipxe/receipt ipxe/stuff/ipxe.cmd ipxe/stuff/lkrnprefix.S
line diff
     1.1 --- a/ipxe/receipt	Sat Oct 12 12:04:33 2013 +0000
     1.2 +++ b/ipxe/receipt	Mon Oct 14 13:38:36 2013 +0000
     1.3 @@ -1,8 +1,8 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="ipxe"
     1.7 -VERSION="1.0.0-20121001"
     1.8 -GIT_TAG="d23db2848813a9d872e1d71272e7f41df7d0d01c"
     1.9 +VERSION="1.0.0-20130925"
    1.10 +GIT_TAG="7405685df2bea9a457970d8b5a63ede08fcda6f7"
    1.11  CATEGORY="system-tools"
    1.12  SHORT_DESC="Open source network boot firmware."
    1.13  MAINTAINER="pascal.bellard@slitaz.org"
    1.14 @@ -18,6 +18,7 @@
    1.15  compile_rules()
    1.16  {
    1.17  	cd $src/src
    1.18 +	cp $stuff/lkrnprefix.S arch/i386/prefix
    1.19  	make bin/undionly.kpxe bin/ipxe.lkrn
    1.20  }
    1.21  
    1.22 @@ -26,41 +27,12 @@
    1.23  {
    1.24  	mkdir $fs/boot
    1.25  	cp -a $src/src/bin/ipxe.lkrn $fs/boot/ipxe
    1.26 -	cat > $fs/boot/ipxe.cmd <<EOT
    1.27 -#!ipxe
    1.28 -
    1.29 -dhcp
    1.30 -
    1.31 -:menu
    1.32 -menu SliTaz net boot menu
    1.33 -item lan	Your PXE boot
    1.34 -item web	SliTaz WEB boot
    1.35 -item rolling	SliTaz development version
    1.36 -item config	iPXE configuration
    1.37 -item exit	iPXE command line
    1.38 -choose --default web --timeout 3000 target && goto ${target}
    1.39 -
    1.40 -:exit
    1.41 -help
    1.42 -shell
    1.43 -goto menu
    1.44 -
    1.45 -:web
    1.46 -chain http://mirror.slitaz.org/pxe/pxelinux.0
    1.47 -chain http://mirror.switch.ch/ftp/mirror/pxe/pxelinux.0
    1.48 -chain http://download.tuxfamily.org/slitaz/pxe/pxelinux.0
    1.49 -goto menu
    1.50 -
    1.51 -:lan
    1.52 -autoboot
    1.53 -goto menu
    1.54 -
    1.55 -:rolling
    1.56 -sanboot http://mirror.slitaz.org/iso/rolling/slitaz-rolling.iso
    1.57 -goto menu
    1.58 -
    1.59 -:config
    1.60 -config
    1.61 -goto menu
    1.62 +	OFS=$((0x28B))
    1.63 +	dd if=$stuff/ipxe.cmd bs=1 of=$fs/boot/ipxe conv=notrunc \
    1.64 +		seek=$OFS count=$((0xA00-$OFS))
    1.65 +	OFS=$((0x151))
    1.66 +	unix2dos <<EOT | dd bs=1 of=$fs/boot/ipxe conv=notrunc \
    1.67 +		seek=$OFS count=$((0x1F0-$OFS))
    1.68 +$SHORT_DESC
    1.69  EOT
    1.70  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/ipxe/stuff/ipxe.cmd	Mon Oct 14 13:38:36 2013 +0000
     2.3 @@ -0,0 +1,43 @@
     2.4 +#!ipxe
     2.5 +
     2.6 +set menu-timeout 3000
     2.7 +dhcp
     2.8 +
     2.9 +:menu
    2.10 +menu SliTaz net boot menu
    2.11 +item --key l lan	Your PXE boot
    2.12 +item --key w web	SliTaz WEB boot
    2.13 +item --key r rolling	SliTaz development version
    2.14 +item --key c config	iPXE configuration
    2.15 +item --key e exit	iPXE command line
    2.16 +choose --timeout ${menu-timeout} --default web target || goto exit
    2.17 +set menu-timeout 0
    2.18 +goto ${target}
    2.19 +
    2.20 +:exit
    2.21 +help
    2.22 +echo Type 'exit' to get the back to the menu
    2.23 +shell
    2.24 +goto menu
    2.25 +
    2.26 +:web
    2.27 +imgfree
    2.28 +set weburl http://mirror.slitaz.org/pxe/
    2.29 +set 210:string ${weburl} && chain ${weburl}pxelinux.0 && boot ||
    2.30 +set weburl http://mirror.switch.ch/ftp/mirror/slitaz/pxe/
    2.31 +set 210:string ${weburl} && chain ${weburl}pxelinux.0 && boot ||
    2.32 +set weburl http://download.tuxfamily.org/slitaz/pxe/
    2.33 +set 210:string ${weburl} && chain ${weburl}pxelinux.0 && boot ||
    2.34 +goto menu
    2.35 +
    2.36 +:lan
    2.37 +autoboot ||
    2.38 +goto menu
    2.39 +
    2.40 +:rolling
    2.41 +sanboot http://mirror.slitaz.org/iso/rolling/slitaz-rolling.iso ||
    2.42 +goto menu
    2.43 +
    2.44 +:config
    2.45 +config
    2.46 +goto menu
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/ipxe/stuff/lkrnprefix.S	Mon Oct 14 13:38:36 2013 +0000
     3.3 @@ -0,0 +1,644 @@
     3.4 +/*
     3.5 +	Copyright (C) 2000, Entity Cyber, Inc.
     3.6 +
     3.7 +	Authors: Gary Byers (gb@thinguin.org)
     3.8 +		 Marty Connor (mdc@thinguin.org)
     3.9 +
    3.10 +	This software may be used and distributed according to the terms
    3.11 +	of the GNU Public License (GPL), incorporated herein by reference.
    3.12 +
    3.13 +	Description:	
    3.14 +
    3.15 +	This is just a little bit of code and data that can get prepended
    3.16 +	to a ROM image in order to allow bootloaders to load the result
    3.17 +	as if it were a Linux kernel image.
    3.18 +
    3.19 +	A real Linux kernel image consists of a one-sector boot loader
    3.20 +	(to load the image from a floppy disk), followed a few sectors
    3.21 +	of setup code, followed by the kernel code itself.  There's
    3.22 +	a table in the first sector (starting at offset 497) that indicates
    3.23 +	how many sectors of setup code follow the first sector and which
    3.24 +	contains some other parameters that aren't interesting in this
    3.25 +	case.
    3.26 +
    3.27 +	When a bootloader loads the sectors that comprise a kernel image,
    3.28 +	it doesn't execute the code in the first sector (since that code
    3.29 +	would try to load the image from a floppy disk.)  The code in the
    3.30 +	first sector below doesn't expect to get executed (and prints an
    3.31 +	error message if it ever -is- executed.)
    3.32 +
    3.33 +	We don't require much in the way of setup code.  Historically, the
    3.34 +	Linux kernel required at least 4 sectors of setup code.
    3.35 +	Therefore, at least 4 sectors must be present even though we don't
    3.36 +	use them.
    3.37 +
    3.38 +*/
    3.39 +
    3.40 +FILE_LICENCE ( GPL_ANY )
    3.41 +
    3.42 +#define	SETUPSECS 4		/* Minimal nr of setup-sectors */
    3.43 +#define PREFIXSIZE ((SETUPSECS+1)*512)
    3.44 +#define PREFIXPGH (PREFIXSIZE / 16 )
    3.45 +#define	BOOTSEG  0x07C0		/* original address of boot-sector */
    3.46 +#define	INITSEG  0x9000		/* we move boot here - out of the way */
    3.47 +#define	SETUPSEG 0x9020		/* setup starts here */
    3.48 +#define SYSSEG   0x1000		/* system loaded at 0x10000 (65536). */
    3.49 +
    3.50 +	.text
    3.51 +	.code16
    3.52 +	.arch i386
    3.53 +	.org	0
    3.54 +	.section ".prefix", "ax", @progbits
    3.55 +	.globl	_lkrn_start
    3.56 +_lkrn_start:
    3.57 +
    3.58 +bootsector: 
    3.59 +_start:
    3.60 +
    3.61 +/* some extra features */
    3.62 +#define EXE_SUPPORT		real mode dos .exe file support
    3.63 +
    3.64 +#define EXEADRS(x)	(x+0xE0)
    3.65 +
    3.66 +/* some contraints to reduce the size */
    3.67 +//#define FLOPPY_1440K_ONLY	1.44M floppies support only
    3.68 +
    3.69 +#ifdef EXE_SUPPORT
    3.70 +/* Initial temporary stack size */
    3.71 +#define EXE_STACK_SIZE 0x400
    3.72 +
    3.73 +/* Temporary decompression area (avoid DOS high memory area) */
    3.74 +#define EXE_DECOMPRESS_ADDRESS 0x110000
    3.75 +
    3.76 +/* Fields within the Program Segment Prefix */
    3.77 +#define PSP_CMDLINE_LEN 0x80
    3.78 +#define PSP_CMDLINE_START 0x81
    3.79 +
    3.80 +#define HEADER_SIZE	0x20
    3.81 +
    3.82 +signature:
    3.83 +	decw	%bp			// Magic number: MZ
    3.84 +	popw	%dx
    3.85 +	jmp	start			// Bytes on last page of file
    3.86 +blocks:
    3.87 +	.word	0			// Pages in file
    3.88 +	.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
    3.89 +	.ascii	"ADDW"
    3.90 +	.long	blocks
    3.91 +	.long	512
    3.92 +	.long	0
    3.93 +	.previous
    3.94 +	.word	0			// Relocations
    3.95 +	.word	( HEADER_SIZE / 16 )	// Size of header in paragraphs
    3.96 +	.word	( EXE_STACK_SIZE / 16 )	// Minimum extra paragraphs needed
    3.97 +	.word	( EXE_STACK_SIZE / 16 )	// Maximum extra paragraphs needed
    3.98 +init_ss:
    3.99 +	.word	-( ( _exe_start - signature ) / 16 )	// Initial (relative) SS value
   3.100 +	.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
   3.101 +	.ascii	"ADDW"
   3.102 +	.long	init_ss
   3.103 +	.long	16
   3.104 +	.long	0
   3.105 +	.previous
   3.106 +	.word	EXE_STACK_SIZE		// Initial SP value
   3.107 +	.word	0			// Checksum
   3.108 +	.word	_exe_start		// Initial IP value
   3.109 +	/* Initial code segment (relative to start of executable) */
   3.110 +	//.word	-( ( _exe_start - signature ) / 16 )	// Initial (relative) CS value
   3.111 +	.word	-( HEADER_SIZE / 16 )	// Initial (relative) CS value
   3.112 +//	.word	0x001C			// File address of relocation table
   3.113 +//	.word	0,0,0			// Overlay number
   3.114 +
   3.115 +start:
   3.116 +	pushw	%dx
   3.117 +	xorw	%dx, %dx
   3.118 +#endif
   3.119 +	cld				# assume nothing
   3.120 +stacktop	= 0x9E00		# in 0x8000 .. 0xA000
   3.121 +zeroed		= 12			# zeroed registers
   3.122 +	movw	$stacktop-12-zeroed, %di	# stacktop is an arbitrary value >=
   3.123 +					# length of bootsect + length of
   3.124 +					# setup + room for stack;
   3.125 +					# 12 is disk parm size.
   3.126 +	pushw	$INITSEG
   3.127 +	popw	%ss			# %ss contain INITSEG
   3.128 +	movw	%di, %sp		# put stack at INITSEG:stacktop-...
   3.129 +
   3.130 +# Many BIOS's default disk parameter tables will not recognize
   3.131 +# multi-sector reads beyond the maximum sector number specified
   3.132 +# in the default diskette parameter tables - this may mean 7
   3.133 +# sectors in some cases.
   3.134 +#
   3.135 +# Since single sector reads are slow and out of the question,
   3.136 +# we must take care of this by creating new parameter tables
   3.137 +# (for the first disk) in RAM.  We can set the maximum sector
   3.138 +# count to 36 - the most we will encounter on an ED 2.88.  
   3.139 +#
   3.140 +# High doesn't hurt.  Low does.  Let's use the max: 63
   3.141 +
   3.142 +	pushw	%ss
   3.143 +	popw	%es			# %es = %ss = INITSEG
   3.144 +	xorw	%ax, %ax		# %ax = 0
   3.145 +	movw	$zeroed/2, %cx		# clear gdt + offset, %ds, limits
   3.146 +	rep				# don't worry about cld
   3.147 +	stosw				# already done above
   3.148 +	popw	%bx			# offset = 0
   3.149 +	popw	%ds			# %ds = 0
   3.150 +	popw	%fs			# %fs = 0
   3.151 +
   3.152 +	movb	setup_sects+0x7C00, %al	# read bootsector + setup (%ds = 0)
   3.153 +	incw	%ax
   3.154 +
   3.155 +	ldsw	0x78(%bx), %si		# %ds:%bx+0x78 is parameter table address
   3.156 +	pushw	%es
   3.157 +	pushw	%di
   3.158 +	movb	$6, %cl			# copy 12 bytes
   3.159 +	rep				# don't worry about cld
   3.160 +	movsw				# already done above
   3.161 +	pushw	%ss
   3.162 +	popw	%ds			# now %ds = %es = %ss = INITSEG
   3.163 +	popl	%fs:0x78(%bx)		# update parameter table address
   3.164 +	movb	$63, 0x4-12(%di)	# patch sector count, %di = stacktop
   3.165 +	cli
   3.166 +
   3.167 +	xchg	%ax, %di		# sector count
   3.168 +	popw	%ax			# limits = 0
   3.169 +	incw	%cx			# cylinder 0, sector 1, clear Z
   3.170 +	call	read_first_sectors	# read setup
   3.171 +
   3.172 +# This routine loads the system at address LOADSEG, making sure
   3.173 +# no 64kB boundaries are crossed. We try to load it as fast as
   3.174 +# possible, loading whole tracks whenever we can.
   3.175 +
   3.176 +	popw	%bx			# clear %bx
   3.177 +	movw	syssize, %di
   3.178 +	addw	$(512/16)-1, %di
   3.179 +	shrw	$9-4, %di
   3.180 +	movw	$SYSSEG, %cx
   3.181 +	call	read_sectorsCX
   3.182 +
   3.183 +# This procedure turns off the floppy drive motor, so
   3.184 +# that we enter the kernel in a known state, and
   3.185 +# don't have to worry about it later.
   3.186 +
   3.187 +kill_motor:
   3.188 +	xchgw	%ax, %di		# reset FDC (%di < 128)
   3.189 +	int	$0x13
   3.190 +
   3.191 +# After that (everything loaded), we jump to the setup-routine
   3.192 +# loaded directly after the bootblock:
   3.193 +# Segments are as follows: %ds = %ss = INITSEG
   3.194 +
   3.195 +	ljmp	$SETUPSEG, $0
   3.196 +
   3.197 +#ifdef EXE_SUPPORT
   3.198 +dosexit:
   3.199 +	movw	$0x4c00, %ax
   3.200 +	int	$0x21
   3.201 +
   3.202 +_exe_start:
   3.203 +	pushw	$dosexit
   3.204 +	movw	$EXEADRS(need386), %si
   3.205 +	pushfw			// save flags
   3.206 +		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
   3.207 +		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
   3.208 +	movb	$0x10, %ah	// DF = IF = TF = 0
   3.209 +	pushw	%ax
   3.210 +	popfw			// < 286 : flags[12..15] are forced 1
   3.211 +	pushfw			// = 286 : flags[12..15] are forced 0
   3.212 +	popw	%cx		// > 286 : only flags[15] is forced 0
   3.213 +	popfw			// restore flags
   3.214 +	addb	%ah, %ch	// test F0 and 00 cases
   3.215 +	cmpb	%ah, %ch
   3.216 +	jbe	puts		// C=8086/80186, Z=80286
   3.217 +//	smsww	%ax
   3.218 +//	andb	$1, %al
   3.219 +//	jne	puts
   3.220 +
   3.221 +	/* Terminate command line with a NUL */
   3.222 +	movzbw	PSP_CMDLINE_LEN, %si
   3.223 +	movb	$0, PSP_CMDLINE_START(%si)
   3.224 +	cmpb	$'?', PSP_CMDLINE_START-1(%si)
   3.225 +	je	help
   3.226 +	pushw	%si
   3.227 +
   3.228 +	/* Install iPXE.  Use a fixed temporary decompression area to
   3.229 +	 * avoid trashing the DOS high memory area.
   3.230 +	 */
   3.231 +	call	alloc_basemem
   3.232 +	movl	$EXE_DECOMPRESS_ADDRESS, %edi
   3.233 +	stc
   3.234 +	sbbl	%ebp, %ebp		/* Allow arbitrary relocation */
   3.235 +	xorl	%esi, %esi
   3.236 +	call	install_prealloc
   3.237 +
   3.238 +	xorl	%ebp, %ebp
   3.239 +	xorl	%ecx, %ecx
   3.240 +
   3.241 +	/* Calculate command line physical address */
   3.242 +	xorl	%edx, %edx
   3.243 +	movw	%ds, %dx
   3.244 +	shll	$4, %edx
   3.245 +	popw	%si
   3.246 +	orw	%si, %si
   3.247 +	jne	gotarg
   3.248 +	movw	$EXEADRS(default_config), %bp
   3.249 +	addl	%edx, %ebp
   3.250 +	movw	$0xA00-default_config, %cx
   3.251 +gotarg:
   3.252 +	addl	$PSP_CMDLINE_START, %edx
   3.253 +	
   3.254 +	jmp	start_ipxe
   3.255 +
   3.256 +help:
   3.257 +	movw	$EXEADRS(helpmsg), %si
   3.258 +puts:
   3.259 +	lodsb
   3.260 +	orb	%al, %al
   3.261 +	je	exit
   3.262 +	call	putc
   3.263 +	jmp	puts
   3.264 +#endif
   3.265 +
   3.266 +putcdot:
   3.267 +	movb	$0x2E, %al
   3.268 +putc:
   3.269 +	movb	$0xE, %ah
   3.270 +	movw	$7, %bx
   3.271 +	int	$0x10
   3.272 +exit:
   3.273 +	ret
   3.274 +
   3.275 +
   3.276 +# read_sectors reads %di sectors into %es:0 buffer.
   3.277 +# %es:0 is updated to the next memory location.
   3.278 +# First, sectors are read sector by sector until
   3.279 +# sector per track count is known. Then they are
   3.280 +# read track by track.
   3.281 +# Assume no error on first track.
   3.282 +
   3.283 +#ifdef FLOPPY_1440K_ONLY
   3.284 +#define FLOPPY_HEADS		2	/* 2 heads */
   3.285 +#define FLOPPY_SECTORS		18	/* 18 sectors */
   3.286 +#else
   3.287 +#define FLOPPY_HEADS		2	/* 2 heads minimum */
   3.288 +#define FLOPPY_SECTORS		9	/* 9 sectors minimum */
   3.289 +#endif
   3.290 +
   3.291 +check_limits:
   3.292 +#ifndef FLOPPY_1440K_ONLY
   3.293 +	popw	%dx
   3.294 +#ifdef FLOPPY_SECTORS
   3.295 +	cmpb	$FLOPPY_SECTORS+1, %cl	# minimum sector count
   3.296 +	jb	check_head
   3.297 +#endif
   3.298 +        cmpb    %al, %cl		# max sector known ?
   3.299 +        ja	next_head		#   no -> store it
   3.300 +check_head:
   3.301 +#ifdef FLOPPY_HEADS
   3.302 +	cmpb	$FLOPPY_HEADS, %dh	# 2 heads minimum
   3.303 +	jb	check_cylinder
   3.304 +#endif
   3.305 +        cmpb    %ah, %dh		# max head known ?
   3.306 +        ja	next_cylinder		#   no -> store it
   3.307 +check_cylinder:
   3.308 +#endif
   3.309 +	pushaw
   3.310 +#ifndef FLOPPY_1440K_ONLY
   3.311 +	cbw				# %ah = 0
   3.312 +#endif
   3.313 +        int     $0x13			# reset controler
   3.314 +	popaw
   3.315 +	movb	$1, %al			# sector by sector...
   3.316 +read_sectorslp:
   3.317 +	pushw	%dx			# some bios break dx...
   3.318 +#ifndef FLOPPY_1440K_ONLY
   3.319 +        pushw   %ax			# limits
   3.320 +	subb	%cl, %al		# sectors remaining in track
   3.321 +	ja	tolastsect
   3.322 +	movb	$1, %al			# 1 sector mini
   3.323 +tolastsect:
   3.324 +#else
   3.325 +	mov	$FLOPPY_SECTORS+1, %al
   3.326 +	subb	%cl, %al		# sectors remaining in track
   3.327 +#endif
   3.328 +	cbw
   3.329 +	cmpw	%di, %ax
   3.330 +	jb	more1trk
   3.331 +	movw	%di, %ax		# sectors to read
   3.332 +more1trk:
   3.333 +	pushw	%ax			# save context
   3.334 +	movb	$2, %ah			# cmd: read chs
   3.335 +        int     $0x13
   3.336 +#ifndef FLOPPY_1440K_ONLY
   3.337 +	popw	%dx			# save %ax
   3.338 +        popw    %ax			# limits
   3.339 +#else
   3.340 +	popw	%ax			# restore context
   3.341 +	popw	%dx
   3.342 +#endif
   3.343 +	jc	check_limits
   3.344 +#ifndef FLOPPY_1440K_ONLY
   3.345 +	xchgw	%ax, %bp
   3.346 +	addw	%dx,%cx			# next sector
   3.347 +	movw	%cx, %gs
   3.348 +	movw	%es, %cx
   3.349 +	pushw	%dx
   3.350 +	shlw	$5, %dx
   3.351 +	addw	%dx, %cx
   3.352 +	popw	%dx
   3.353 +	subw	%dx,%di			# update sector counter
   3.354 +	popw	%dx
   3.355 +read_sectorsCX:
   3.356 +	movw	%cx, %es		# next location
   3.357 +	jz	putcdot
   3.358 +#else
   3.359 +	addw	%ax,%cx			# next sector
   3.360 +	movw	%cx, %gs
   3.361 +	movw	%es, %cx
   3.362 +	pushw	%ax
   3.363 +	shlw	$5, %ax
   3.364 +	addw	%ax, %cx
   3.365 +	popw	%ax
   3.366 +	subw	%ax,%di			# update sector counter
   3.367 +read_sectorsCX:
   3.368 +	movw	%cx, %es		# next location
   3.369 +	jz	putcdot
   3.370 +#endif
   3.371 +read_sectors:
   3.372 +	movw	%gs, %cx
   3.373 +#ifndef FLOPPY_1440K_ONLY
   3.374 +#   al is last sector+1
   3.375 +#   ah is last cylinder+1
   3.376 +	xchgw	%ax, %bp
   3.377 +#endif
   3.378 +#ifndef FLOPPY_1440K_ONLY
   3.379 +        cmpb    %al,%cl			# reach sector limit ?
   3.380 +        jne     bdendlp
   3.381 +next_head:
   3.382 +        movb    %cl,%al
   3.383 +#else
   3.384 +        cmpb    $FLOPPY_SECTORS+1,%cl	# reach sector limit ?
   3.385 +        jne     bdendlp
   3.386 +#endif
   3.387 +        incb    %dh			# next head
   3.388 +        movb    $1,%cl			# first sector
   3.389 +#ifndef FLOPPY_1440K_ONLY
   3.390 +        cmpb    %ah, %dh		# reach head limit ?
   3.391 +        jne     bdendlp
   3.392 +next_cylinder:
   3.393 +        movb    %dh,%ah
   3.394 +#else
   3.395 +        cmpb    %cl,%dh			# reach head limit ?
   3.396 +        je	bdendlp
   3.397 +#endif
   3.398 +# NOTE : support 256 cylinders max
   3.399 +        incb    %ch			# next cylinder
   3.400 +read_first_sectors:
   3.401 +        movb    $0,%dh			# first head
   3.402 +bdendlp:
   3.403 +        jmp	read_sectorslp
   3.404 +
   3.405 +#ifdef EXE_SUPPORT
   3.406 +need386:
   3.407 +	.ascii	"No 386+."
   3.408 +	.byte	13,10
   3.409 +	.byte	0
   3.410 +helpmsg:
   3.411 +	.ascii	"No help available."
   3.412 +	.byte	13,10
   3.413 +	.byte	0
   3.414 +#endif
   3.415 +
   3.416 +/*
   3.417 +	The following header is documented in the Linux source code at
   3.418 +	Documentation/x86/boot.txt
   3.419 +*/
   3.420 +	.org	497
   3.421 +setup_sects: 
   3.422 +	.byte	SETUPSECS
   3.423 +root_flags: 
   3.424 +	.word	0
   3.425 +syssize: 
   3.426 +	.long	-PREFIXPGH
   3.427 +
   3.428 +	.section ".zinfo.fixup", "a", @progbits	/* Compressor fixups */
   3.429 +	.ascii	"ADDL"
   3.430 +	.long	syssize
   3.431 +	.long	16
   3.432 +	.long	0
   3.433 +	.previous
   3.434 +	
   3.435 +ram_size: 
   3.436 +	.word	0
   3.437 +vid_mode: 
   3.438 +	.word	0
   3.439 +root_dev: 
   3.440 +	.word	0
   3.441 +boot_flag: 
   3.442 +	.word	0xAA55
   3.443 +jump:
   3.444 +	/* Manually specify a two-byte jmp instruction here rather
   3.445 +	 * than leaving it up to the assembler. */
   3.446 +	.byte	0xeb
   3.447 +	.byte	setup_code - header
   3.448 +header:
   3.449 +	.byte	'H', 'd', 'r', 'S'
   3.450 +version:
   3.451 +	.word	0x0207 /* 2.07 */
   3.452 +realmode_swtch:
   3.453 +	.long	0
   3.454 +start_sys:
   3.455 +	.word	0
   3.456 +kernel_version:
   3.457 +	.word	0
   3.458 +type_of_loader:
   3.459 +	.byte	0
   3.460 +loadflags:
   3.461 +	.byte	0
   3.462 +setup_move_size:
   3.463 +	.word	0
   3.464 +code32_start:
   3.465 +	.long	SYSSEG*16
   3.466 +ramdisk_image:
   3.467 +	.long	0
   3.468 +ramdisk_size:
   3.469 +	.long	0
   3.470 +bootsect_kludge:
   3.471 +	.long	0
   3.472 +heap_end_ptr:
   3.473 +	.word	0
   3.474 +pad1:
   3.475 +	.word	0
   3.476 +cmd_line_ptr:
   3.477 +	.long	0
   3.478 +initrd_addr_max:
   3.479 +	/* We don't use an initrd but some bootloaders (e.g. SYSLINUX) have
   3.480 +	 * been known to require this field.  Set the value to 2 GB.  This
   3.481 +	 * value is also used by the Linux kernel. */
   3.482 +	.long	0x7fffffff
   3.483 +kernel_alignment:
   3.484 +	.long	0
   3.485 +relocatable_kernel:
   3.486 +	.byte	0
   3.487 +pad2:
   3.488 +	.byte	0, 0, 0
   3.489 +cmdline_size:
   3.490 +	.long	0x7ff
   3.491 +hardware_subarch:
   3.492 +	.long	0
   3.493 +hardware_subarch_data:
   3.494 +	.byte	0, 0, 0, 0, 0, 0, 0, 0
   3.495 +
   3.496 +/*
   3.497 +	We don't need to do too much setup.
   3.498 +
   3.499 +	This code gets loaded at SETUPSEG:0.  It wants to start
   3.500 +	executing the image that's loaded at SYSSEG:0 and
   3.501 +	whose entry point is SYSSEG:0.
   3.502 +*/
   3.503 +setup_code:
   3.504 +	movl	ramdisk_image, %eax
   3.505 +	orl	%eax, %eax
   3.506 +	jnz	setup_done
   3.507 +
   3.508 +	movw	$default_config, %di
   3.509 +	movw	$-1, %bx
   3.510 +
   3.511 +	movw	$9, %cx
   3.512 +1:
   3.513 +	pushw	%ax
   3.514 +	loop	1b
   3.515 +	pushw	$0x9310
   3.516 +	pushw	%ax
   3.517 +	pushw	%bx
   3.518 +	pushw	%ax
   3.519 +	pushw	$0x9300+(INITSEG>>12)
   3.520 +	pushw	%di
   3.521 +	pushw	%bx
   3.522 +	movb	$8, %cl
   3.523 +1:
   3.524 +	pushw	%ax
   3.525 +	loop	1b
   3.526 +1:
   3.527 +	incw	%bx
   3.528 +	cmpb	%al, (%bx,%di)
   3.529 +	jne	1b
   3.530 +	movw	%bx, ramdisk_size
   3.531 +	movb	$0x10, ramdisk_image+2
   3.532 +
   3.533 +	pushw	%ss
   3.534 +	popw	%es
   3.535 +	movw	%sp, %si
   3.536 +	movb	$0x87, %ah
   3.537 +	movw	$(run_ipxe-default_config)/2+1, %cx
   3.538 +	int	$0x15
   3.539 +
   3.540 +setup_done:
   3.541 +	/* We expect to be contiguous in memory once loaded.  The Linux image
   3.542 +	 * boot process requires that setup code is loaded separately from
   3.543 +	 * "non-real code".  Since we don't need any information that's left
   3.544 +	 * in the prefix, it doesn't matter: we just have to ensure that
   3.545 +	 * %cs:0000 is where the start of the image *would* be.
   3.546 +	 */
   3.547 +	ljmp	$(SYSSEG-(PREFIXSIZE/16)), $run_ipxe
   3.548 +
   3.549 +default_config:
   3.550 +
   3.551 +	.org	PREFIXSIZE
   3.552 +/*
   3.553 +	We're now at the beginning of the kernel proper.
   3.554 + */
   3.555 +run_ipxe:
   3.556 +	/* Set up stack just below 0x7c00 and clear direction flag */
   3.557 +	xorw	%ax, %ax
   3.558 +	movw	%ax, %ss
   3.559 +	movw	$0x7c00, %sp
   3.560 +	cld
   3.561 +
   3.562 +	/* Retrieve command-line pointer */
   3.563 +	movl	%ds:cmd_line_ptr, %edx
   3.564 +	testl	%edx, %edx
   3.565 +	jz	no_cmd_line
   3.566 +
   3.567 +	/* Set up %es:%di to point to command line */
   3.568 +	movl	%edx, %edi
   3.569 +	andl	$0xf, %edi
   3.570 +	rorl	$4, %edx
   3.571 +	movw	%dx, %es
   3.572 +
   3.573 +	/* Find length of command line */
   3.574 +	pushw	%di
   3.575 +	movw	$0xffff, %cx
   3.576 +	repnz scasb
   3.577 +	notw	%cx
   3.578 +	popw	%si
   3.579 +
   3.580 +	/* Make space for command line on stack */
   3.581 +	movw	%sp, %di
   3.582 +	subw	%cx, %di
   3.583 +	andw	$~0xf, %di
   3.584 +	movw	%di, %sp
   3.585 +
   3.586 +	/* Copy command line to stack */
   3.587 +	pushw	%ds
   3.588 +	pushw	%es
   3.589 +	popw	%ds
   3.590 +	pushw	%ss
   3.591 +	popw	%es
   3.592 +	rep movsb
   3.593 +	popw	%ds
   3.594 +
   3.595 +	/* Store new command-line pointer */
   3.596 +	movzwl	%sp, %edx
   3.597 +no_cmd_line:
   3.598 +
   3.599 +	/* Calculate maximum relocation address */
   3.600 +	movl	ramdisk_image, %ebp
   3.601 +	testl	%ebp, %ebp
   3.602 +	jnz	1f
   3.603 +	decl	%ebp		/* Allow arbitrary relocation if no initrd */
   3.604 +1:
   3.605 +
   3.606 +	/* Install iPXE */
   3.607 +	call	alloc_basemem
   3.608 +	xorl	%esi, %esi
   3.609 +	xorl	%edi, %edi
   3.610 +	call	install_prealloc
   3.611 +
   3.612 +	/* Retrieve initrd pointer and size */
   3.613 +	movl	ramdisk_image, %ebp
   3.614 +	movl	ramdisk_size, %ecx
   3.615 +
   3.616 +start_ipxe:
   3.617 +	/* Set up real-mode stack */
   3.618 +	movw	%bx, %ss
   3.619 +	movw	$_estack16, %sp
   3.620 +
   3.621 +	/* Jump to .text16 segment */
   3.622 +	pushw	%ax
   3.623 +	pushw	$1f
   3.624 +	lret
   3.625 +	.section ".text16", "awx", @progbits
   3.626 +1:
   3.627 +	/* Set up %ds for access to .data16 */
   3.628 +	movw	%bx, %ds
   3.629 +
   3.630 +	/* Store command-line pointer */
   3.631 +	movl	%edx, cmdline_phys
   3.632 +
   3.633 +	/* Store initrd pointer and size */
   3.634 +	movl	%ebp, initrd_phys
   3.635 +	movl	%ecx, initrd_len
   3.636 +
   3.637 +	/* Run iPXE */
   3.638 +	pushl	$main
   3.639 +	pushw	%cs
   3.640 +	call	prot_call
   3.641 +	popl	%ecx /* discard */
   3.642 +
   3.643 +	/* Uninstall iPXE */
   3.644 +	call	uninstall
   3.645 +
   3.646 +	/* Boot next device */
   3.647 +	int $0x18