wok diff syslinux/stuff/iso2exe/iso9660.c @ rev 17473

syslinux/iso2exe: add 64bits support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 27 17:56:57 2014 +0100 (2014-12-27)
parents 7d300004a3b8
children 054f70cb9bec
line diff
     1.1 --- a/syslinux/stuff/iso2exe/iso9660.c	Thu Dec 13 14:33:27 2012 +0100
     1.2 +++ b/syslinux/stuff/iso2exe/iso9660.c	Sat Dec 27 17:56:57 2014 +0100
     1.3 @@ -3,6 +3,9 @@
     1.4  #include <stdio.h>
     1.5  #include "iso9660.h"
     1.6  #define __ROCKRIDGE
     1.7 +#asm
     1.8 +		use16	86
     1.9 +#endasm
    1.10  
    1.11  char *isofilename;
    1.12  unsigned long isofileofs, isofilesize;
    1.13 @@ -121,12 +124,56 @@
    1.14  	return 0;
    1.15  }
    1.16  
    1.17 +static int cpuhaslm(void)
    1.18 +{
    1.19 +#asm
    1.20 +	pushf			// save flags
    1.21 +		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
    1.22 +		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
    1.23 +	mov	ax, #0x1000
    1.24 +	push	ax
    1.25 +	popf			// < 286 : flags[12..15] are forced 1
    1.26 +	pushf			// = 286 : flags[12..15] are forced 0
    1.27 +	pop	bx		// > 286 : only flags[15] is forced 0
    1.28 +	popf			// restore flags (IOPL)
    1.29 +	add	bh, ah		// test F0 and 00 cases
    1.30 +	cmp	bh, ah
    1.31 +	cbw
    1.32 +	jbe	not386		// C=8086/80186, Z=80286
    1.33 +	use16	386
    1.34 +	pushfd
    1.35 +	pushfd
    1.36 +	pop	ebx
    1.37 +	mov	ecx, ebx
    1.38 +	btc	ebx, #21	// toggle CPUID feature bit
    1.39 +	push	ebx
    1.40 +	popfd
    1.41 +	pushfd
    1.42 +	pop	ebx
    1.43 +	popfd
    1.44 +	xor	ebx, ecx
    1.45 +	bt	ebx, #21	// CPUID feature bit ?
    1.46 +	jnc	nocpuid
    1.47 +	mov	eax, #0x80000001	// Extended Processor Info and Feature Bits
    1.48 +	.byte	0x0F, 0xA2	// cpuid
    1.49 +	xor	ax, ax
    1.50 +	bt	edx, #29	// LM feature bit ?
    1.51 +	adc	ax, ax
    1.52 +	use16	86
    1.53 +nocpuid:
    1.54 +not386:
    1.55 +#endasm
    1.56 +}
    1.57 +
    1.58  #define IS_DIR(x)( ((x) & ~0777) == 040000)
    1.59 -int isoopen(char *name)
    1.60 +int isoopen(char *filename)
    1.61  {
    1.62  	int restart;
    1.63 -	char *s, c;
    1.64 +	char *name, *s, c;
    1.65 +	int _64bits = cpuhaslm();
    1.66  
    1.67 +retry32:
    1.68 +	name = filename;
    1.69  	while (*name == '/') {
    1.70  		name++;
    1.71  		isoreset(NULL);
    1.72 @@ -137,7 +184,14 @@
    1.73  		c = *s;
    1.74  		*s = 0;
    1.75  		for (restart = 1; isoreaddir(restart) == 0; restart = 0) {
    1.76 -			if (strcmp(name, isofilename)) continue;
    1.77 +			char *n = name, *i = isofilename;
    1.78 +			if (_64bits) {
    1.79 +				int len = strlen(name);
    1.80 +				if (strncmp(name, isofilename), len) continue;
    1.81 +				n = "64";
    1.82 +				i += len;
    1.83 +			}
    1.84 +			if (strcmp(n, i)) continue;
    1.85  			if (IS_DIR(isofilemod)) {
    1.86  				isodirofs = isofileofs;
    1.87  				isodirsize = isofilesize;
    1.88 @@ -149,6 +203,11 @@
    1.89  			}
    1.90  			return 0;
    1.91  		}
    1.92 +		if (_64bits) {
    1.93 +			_64bits = 0;
    1.94 +			*s = c;
    1.95 +			goto retry32;
    1.96 +		}
    1.97  		return -1;
    1.98  	  next: ;
    1.99  	}