# HG changeset patch # User Pascal Bellard # Date 1419699417 -3600 # Node ID 6aed6fc5819d2087a912a5aaabc07c95ac64df29 # Parent c8d2616c785e1ad390a501ea198aaf1e43a0acdd syslinux/iso2exe: add 64bits support diff -r c8d2616c785e -r 6aed6fc5819d ipxe/stuff/lkrnprefix.S --- a/ipxe/stuff/lkrnprefix.S Sat Dec 27 17:44:46 2014 +0200 +++ b/ipxe/stuff/lkrnprefix.S Sat Dec 27 17:56:57 2014 +0100 @@ -101,6 +101,7 @@ .word -( HEADER_SIZE / 16 ) // Initial (relative) CS value // .word 0x001C // File address of relocation table // .word 0,0,0 // Overlay number + .ascii "(SliTaz)" start: pushw %dx diff -r c8d2616c785e -r 6aed6fc5819d syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Sat Dec 27 17:44:46 2014 +0200 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Dec 27 17:56:57 2014 +0100 @@ -90,9 +90,7 @@ dxfound: movw %dx, 10(%bp) call checkboot -noboot: .ascii "No isolinux mbr." -noboot_end: .org 0x0080 ////////////////////////////// EXE/PE header ////////////////////////////////// @@ -109,13 +107,12 @@ iret error: - movw $noboot_end-noboot, %cx -putsloop: lodsb movw $7, %bx movb $0xE, %ah int $0x10 - loop putsloop + cmp $'.', %al + jne error halt: hlt jmp halt @@ -128,10 +125,13 @@ cld movw $0x100, %si movw -127(%si), %ax + cmpb $0x2F, %al + je ishelp + cmpw $0x2F20, %ax +ishelp: + movw $0x3000+EXESTR(help), %ax cwd // clear dx pushw %dx // dos exit() - cmpw $0x2F20, %ax - movw $0x3000+EXESTR(help), %ax je abort int $0x21 // get DOS version cmpb $3, %al @@ -197,9 +197,9 @@ movw $0x0100, %di movw comstart-end_header(%di), %si // .com address pushw %di - movb $0x7D, %ch + movb $0x7C/2, %ch // 31K-31.5K, > com length rep - movsb + movsw moveret: ret @@ -213,12 +213,13 @@ movw %dx, %ds // %dx = 0 movw 0x67*4+2, %ds movw $10, %si - lodsl + lodsw xorw $0x4D45, %ax // EM(MX) or EM(MQ) - lodsl + lodsw + lodsw popw %ds jne NoVCPI - xorl $0x30585858, %eax // XXX0 + xorw $0x5858, %ax // XX(X0) movw $EXEADRS(CmdVCPI), %si ChkVCPI: NoVCPI: @@ -237,11 +238,10 @@ .byte 0x46 // version .byte 0 -// ------------------------------------------------------------------- - -help: - .ascii "SliTaz GNU/L" // SliTaz GNU/Linux boot loader - .byte EXESTR(iloader) +// --------------- Must be in 7F40 7FFF range ------------------------ +//noloader: +// .ascii "No isol" // No isolinux boot loader +// .byte EXESTR(iloader) no386: .ascii "No 386" // No 386+ .byte EXESTR(plus) @@ -258,20 +258,12 @@ .ascii "Invalid: paging + " // Invalid: paging + real mode. realmodemsg: .ascii "real" // real mode. -// --------------- Must be in 00C0 013F range ------------------------ +// --------------- Must be in 7FC0 7FFF range ------------------------ mode: .ascii " mod" eeol: .ascii "e" .byte EXESTR(eol) -//noloader: -// .ascii "No isol" // No isolinux boot loader -iloader: - .ascii "inux boot loader" -eol: - .ascii "." -eol2: - .asciz "\r\n" noDOS3: .ascii "No DOS 3" // No DOS 3.0+ dot0: @@ -279,6 +271,14 @@ plus: .ascii "+" .byte EXESTR(eol2) +help: + .ascii "SliTaz GNU/L" // SliTaz GNU/Linux boot loader +iloader: + .ascii "inux boot loader" +eol: + .ascii "." +eol2: + .asciz "\r\n" .org 0x8000 ////////////////////////// ISO9660 header ///////////////////////////////////// diff -r c8d2616c785e -r 6aed6fc5819d syslinux/stuff/iso2exe/bootlinux.c --- a/syslinux/stuff/iso2exe/bootlinux.c Sat Dec 27 17:44:46 2014 +0200 +++ b/syslinux/stuff/iso2exe/bootlinux.c Sat Dec 27 17:56:57 2014 +0100 @@ -1,6 +1,9 @@ #include #include "libdos.h" #include "iso9660.h" +#asm + use16 86 +#endasm #define ELKSSIG 0x1E6 #define SETUPSECTORS 0x1F1 @@ -47,8 +50,10 @@ mov ax, _iselks dec ax je fakerealmode // elks may run on a 8086 + use16 286 smsw ax // 286+ and ax, #1 // 0:realmode 1:vm86 + use16 86 fakerealmode: #endasm } @@ -95,20 +100,23 @@ movw jmp movedone movehiz: // 30 + use16 286 // more than 1Mb => 286+ mov cx, #9 // 2E..1E zero1: push ax loop zero1 - push dword [si] // 1A mem.base + push word [si+2] + push word [si] // 1A mem.base push #-1 // 18 push ax // 16 - cwde - cdq - mov dx, ds - shl edx, #4 - mov ax, #_buffer - add edx, eax - push edx // 12 linear_address(buffer) + mov ax, ds + mov dx, ax + shl ax, #4 + shr dx, #12 + add ax, #_buffer + adc dx, #0 + push dx + push ax push #-1 // 10 mov cl, #8 // 0E..00 zero2: @@ -124,6 +132,7 @@ xchg [si+0x1F], al // bits 24..31 int 0x15 add sp, #0x30 + use16 86 movedone: pop di pop si @@ -427,11 +436,13 @@ mvdown: mov [si+0x12+2], bx // srce mov [si+0x1A+2], cx // dest - pusha // more than 1Mb => 286+ + use16 286 // more than 1Mb => 286+ + pusha mov cx, #0x8000 mov ah, #0x87 int 0x15 popa + use16 86 inc bx inc cx cmp dl, bl diff -r c8d2616c785e -r 6aed6fc5819d syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Sat Dec 27 17:44:46 2014 +0200 +++ b/syslinux/stuff/iso2exe/init Sat Dec 27 17:56:57 2014 +0100 @@ -33,6 +33,13 @@ umount /proc } +bytes2bin() +{ + for i in $@ ; do + printf '\\\\x%02X' $(($i&255)) | xargs echo -en + done +} + words2bin() { for i in $@ ; do @@ -218,7 +225,7 @@ if [ -d /media/cdrom/fs ]; then cp -a /media/cdrom/fs/. /mnt/slitaz elif is_loram ; then - for i in /media/cdrom/boot/rootfs?.* ; do + for i in /media/cdrom/boot/rootfs?*.* ; do [ -s $(basename $i) ] && continue cpio -i $i done @@ -393,6 +400,31 @@ cp /media/cdrom/boot/memtest /mnt/memtest.exe } +mkfloppy() +{ + ddq if=$1 of=/dev/fd0 + [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return + J=$(($(get 3 $1 1) + 0x02)) + R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32)) + [ $R -lt 2500 ] || return + [ $((($(get 500 $file)-1) & 31)) -lt 30 ] && + dd if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0 + G="18 0 2 0 0 0 0 0" + [ $J -gt 25 ] || G="" + F=0 + for i in 1 2 3; do + F=$((((2880-$R-$F-$F)*3+1023)/1024)) + done + bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \ + 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \ + $G | ddq bs=1 of=/dev/fd0 + ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0 + for i in $R $(($R+$F)) ; do + bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0 + done + echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0 +} + fdmemtest() { $DIALOG --clear \ @@ -403,8 +435,7 @@ miss many of the failures that are detected by Memtest86.\n\n Please insert a blank disk in floppy drive.\n " 12 70 - [ $? -eq 0 ] || return - ddq if=/media/cdrom/boot/memtest of=/dev/fd0 + [ $? -eq 0 ] && mkfloppy /media/cdrom/boot/memtest } pxe() @@ -433,8 +464,7 @@ from the Web using PXE and HTTP protocols.\n\n Please insert a blank disk in floppy drive.\n " 12 70 - [ $? -eq 0 ] || return - ddq if=/media/cdrom/boot/?pxe of=/dev/fd0 + [ $? -eq 0 ] && mkfloppy /media/cdrom/boot/?pxe } gotposixovl() diff -r c8d2616c785e -r 6aed6fc5819d syslinux/stuff/iso2exe/iso9660.c --- a/syslinux/stuff/iso2exe/iso9660.c Sat Dec 27 17:44:46 2014 +0200 +++ b/syslinux/stuff/iso2exe/iso9660.c Sat Dec 27 17:56:57 2014 +0100 @@ -3,6 +3,9 @@ #include #include "iso9660.h" #define __ROCKRIDGE +#asm + use16 86 +#endasm char *isofilename; unsigned long isofileofs, isofilesize; @@ -121,12 +124,56 @@ return 0; } +static int cpuhaslm(void) +{ +#asm + pushf // save flags + // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF + mov ax, #0x1000 + push ax + popf // < 286 : flags[12..15] are forced 1 + pushf // = 286 : flags[12..15] are forced 0 + pop bx // > 286 : only flags[15] is forced 0 + popf // restore flags (IOPL) + add bh, ah // test F0 and 00 cases + cmp bh, ah + cbw + jbe not386 // C=8086/80186, Z=80286 + use16 386 + pushfd + pushfd + pop ebx + mov ecx, ebx + btc ebx, #21 // toggle CPUID feature bit + push ebx + popfd + pushfd + pop ebx + popfd + xor ebx, ecx + bt ebx, #21 // CPUID feature bit ? + jnc nocpuid + mov eax, #0x80000001 // Extended Processor Info and Feature Bits + .byte 0x0F, 0xA2 // cpuid + xor ax, ax + bt edx, #29 // LM feature bit ? + adc ax, ax + use16 86 +nocpuid: +not386: +#endasm +} + #define IS_DIR(x)( ((x) & ~0777) == 040000) -int isoopen(char *name) +int isoopen(char *filename) { int restart; - char *s, c; + char *name, *s, c; + int _64bits = cpuhaslm(); +retry32: + name = filename; while (*name == '/') { name++; isoreset(NULL); @@ -137,7 +184,14 @@ c = *s; *s = 0; for (restart = 1; isoreaddir(restart) == 0; restart = 0) { - if (strcmp(name, isofilename)) continue; + char *n = name, *i = isofilename; + if (_64bits) { + int len = strlen(name); + if (strncmp(name, isofilename), len) continue; + n = "64"; + i += len; + } + if (strcmp(n, i)) continue; if (IS_DIR(isofilemod)) { isodirofs = isofileofs; isodirsize = isofilesize; @@ -149,6 +203,11 @@ } return 0; } + if (_64bits) { + _64bits = 0; + *s = c; + goto retry32; + } return -1; next: ; } diff -r c8d2616c785e -r 6aed6fc5819d syslinux/stuff/iso2exe/libdos.c --- a/syslinux/stuff/iso2exe/libdos.c Sat Dec 27 17:44:46 2014 +0200 +++ b/syslinux/stuff/iso2exe/libdos.c Sat Dec 27 17:56:57 2014 +0100 @@ -1,4 +1,7 @@ #include "libdos.h" +#asm + use16 86 +#endasm char *progname(void) { @@ -165,7 +168,10 @@ pop si jne stepagain seg cs - lss sp, stack + lds di, stack + push ds + pop ss + mov sp, di pop ds pop di pop si