wok diff syslinux/stuff/iso2exe/bootlinux.c @ rev 14257

syslinux/iso2exe: check kernel version, add floppy bootstrap stub
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 28 11:51:42 2013 +0100 (2013-03-28)
parents 72b5cd3cb23a
children bf8be127c60b
line diff
     1.1 --- a/syslinux/stuff/iso2exe/bootlinux.c	Tue Dec 25 16:40:45 2012 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/bootlinux.c	Thu Mar 28 11:51:42 2013 +0100
     1.3 @@ -156,10 +156,17 @@
     1.4  #endasm
     1.5  }
     1.6  
     1.7 -void loadkernel(void)
     1.8 +static unsigned getcs(void)
     1.9 +{
    1.10 +#asm
    1.11 +	mov	ax, cs
    1.12 +#endasm
    1.13 +}
    1.14 +
    1.15 +unsigned long loadkernel(void)
    1.16  {
    1.17  	unsigned setup, n = BUFFERSZ;
    1.18 -	unsigned long syssize = 0;
    1.19 +	unsigned long syssize = 0, version = 0;
    1.20  
    1.21  	do {
    1.22  		isoread(buffer, n);
    1.23 @@ -181,7 +188,7 @@
    1.24  #asm
    1.25  				jmp	end_realmode_switch
    1.26  _far_realmode_switch:
    1.27 -				call	_realmode_switch
    1.28 +				call	REALMODE_SWITCH
    1.29  				cli
    1.30  				mov	al, #0x80	// Disable NMI
    1.31  				out	0x70, al
    1.32 @@ -236,7 +243,42 @@
    1.33  		n = (setup > BUFFERSZ) ? BUFFERSZ : setup;
    1.34  	} while (setup > 0);
    1.35  
    1.36 +#asm
    1.37 +		push	ds
    1.38 +		push	#SETUP_SEGMENT
    1.39 +		pop	ds
    1.40 +		mov	si, #0x200
    1.41 +		mov	eax, #0x53726448	// HdrS
    1.42 +		cdq				// clear edx
    1.43 +		cmp	[si+2], eax
    1.44 +		jne	noversion
    1.45 +		add	si, [si+14]
    1.46 +		mov	cx, #3
    1.47 +		xor	ax, ax
    1.48 +nextdigit:
    1.49 +		shl	edx, #4
    1.50 +		or	dl, al
    1.51 +next:
    1.52 +		lodsb
    1.53 +		xor	ah, #1
    1.54 +		sub	al, #0x30
    1.55 +		cmp	al, #9
    1.56 +		jbe	nextdigit
    1.57 +		shr	ah, #1
    1.58 +		jc	got2
    1.59 +		mov	al, #0xF
    1.60 +		and	al, dl
    1.61 +		and	dl, #0xF0
    1.62 +		shl	edx, #4
    1.63 +		or	dl, al
    1.64 +got2:
    1.65 +		loop	next
    1.66 +		pop	ds
    1.67 +		mov	.loadkernel.version[bp], edx
    1.68 +noversion:
    1.69 +#endasm
    1.70  	load(&kernelmem, syssize);
    1.71 +	return version;
    1.72  }
    1.73  
    1.74  void loadinitrd(void)