# HG changeset patch # User Pascal Bellard # Date 1592662509 0 # Node ID a2e843f5d9e470ae62f197f7f5de90b4986b5438 # Parent 50eb3433cb74a3f78505d6a3b0c2fa1c544987fb syslinux/bootiso.S: merge isolinux boot sector diff -r 50eb3433cb74 -r a2e843f5d9e4 linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Fri Jun 19 20:32:02 2020 -0400 +++ b/linld/stuff/src/ISO9660.CPP Sat Jun 20 14:15:09 2020 +0000 @@ -84,10 +84,15 @@ } p += len; } while (x->buffer + x->curpos + x->entrysize - 2 > p); +#ifdef ISOHOOK + *endname = 0; +#else if (endname) *endname = 0; else #endif +#endif +#ifndef ISOHOOK { p = x->buffer + 33; x->filename = p += x->curpos; p--; @@ -105,6 +110,7 @@ *p = 0; } } +#endif x->curpos += x->entrysize; return 0; } diff -r 50eb3433cb74 -r a2e843f5d9e4 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Fri Jun 19 20:32:02 2020 -0400 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Jun 20 14:15:09 2020 +0000 @@ -36,6 +36,7 @@ start0: //pushw %dx // restore %sp //incw %bp // restore %bp + movw %ds, %ax xorw %bx, %bx movw %bx, %ds movb $0x7C, %bh @@ -45,10 +46,8 @@ pushw %bx // return address pushw %di pushw %es // save %es:%di + pushw %si cld - sti - pushw %ds - popw %es call setreg rep movsw @@ -63,8 +62,10 @@ .word 0 .org 66 +start2: + pushw %ax // original %ds + sti dxloop: -start2: call readsector1 // look for the boot device repe cmpsw @@ -76,8 +77,11 @@ dxfound: call readsectorX // read isolinux boot sector cmpw (%bx), %cx + movw $moved+nobsmsg, %si jnc puts // read fail or no isohydrid boot sector call bootpartition // assume DS=SS SI=BX=7C00 CX=0100 DL= DI=table+66 + popw %ds + popw %si popw %es popw %di // isolinux boot needs %es:%di and %dx putsret: @@ -87,15 +91,10 @@ movw $7, %bx movb $0xE, %ah int $0x10 -error: +puts: lodsb - cmp $1, %al - jg putstrlp - jz putsret -puts: - movb $0x80, %ah - xchgw %ax, %si - jnc error + cmp $0, %al + jnz putstrlp halt: hlt jmp halt @@ -134,7 +133,7 @@ .org 0x01A0,0xFF readsectorX: // read isolinux boot sector - movb $0xA5, %cl // patched by installer + movb $3, %cl // isolinux/512 readsector1: andb $0x83, %dl // disk and floppy disk movw %cx, (%bx) @@ -142,10 +141,11 @@ movw $0x201, %ax int $0x13 setreg: + pushw %ds + popw %es movw %bx, %si movw $moved, %di movw $0x0100, %cx - movb $nobsmsg, %al ret .org 0x01B8,0xEE // partition table @@ -370,6 +370,254 @@ .org 0x0400,0xEE .org 0x0600,0xFF +isolinux: + .arch i486 +/* ----------------------------------------------------------------------- + * + * Copyright 2007-2009 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +HYBRID_MAGIC = 0x7078c0fb +isolinux_hybrid_signature = 0x7c00+64 +isolinux_start_hybrid = 0x7c00+64+4 + +stack = 0x7c00 +partoffset = (stack-8) +driveno = (stack-14) +heads = (stack-16) +sectors = (stack-18) +ebios_flag = (stack-20) +secpercyl = (stack-24) + +BIOS_kbdflags = 0x417 +BIOS_page = 0x462 + +_start2: + .byte 0x33, 0xed /* xorw %bp, %bp */ + + /* Check to see if we have a partition table entry */ + xorl %ebx, %ebx + xorl %ecx, %ecx +#ifdef PARTITION_SUPPORT + andw %si, %si /* %si == 0 -> no partition data */ + jz 1f + testb $0x7f, (%si) /* Invalid active flag field? */ + jnz 1f + cmpb %cl, 4(%si) /* Partition type zero == invalid? */ + je 1f + cmpl $0x58504721, %eax /* !GPT signature in EAX? */ + jne 2f + cmpb $0xed, 4(%si) /* EFI partition type? */ + jne 2f + + /* We have GPT partition information */ + movl (32+20)(%si), %ecx + movl (36+20)(%si), %ebx + jmp 1f + + /* We have non-GPT partition information */ +2: + movl 8(%si), %ecx +#endif +1: + movw %sp, %si + + /* We have no partition information */ + pushl %ebx /* -4: partoffset_hi */ + pushl %ecx /* -8: partoffset_lo */ + pushw %es /* -10: es:di -> $PnP header */ + pushw %di /* -12: es:di -> $PnP header */ + + movw %bp, %ds + movw %bp, %es + + //ADJUST_DRIVE + pushw %dx /* -14: dl -> drive number */ + + /* Copy down to 0:0x600 */ + movw $0x7c00, %si + movw $_start2, %di + movw $(512/2), %cx + rep; movsw + + ljmpw $0, $2f +2: + + /* Check to see if we have EBIOS */ + pushw %dx /* drive number */ + movb $0x41, %ah /* %al == 0 already */ + movw $0x55aa, %bx + xorw %cx, %cx + xorb %dh, %dh + stc + int $0x13 + jc 1f + cmpw $0xaa55, %bx + jne 1f + andw $1,%cx /* Bit 0 = fixed disk subset */ + jz 1f + + /* We have EBIOS; patch in the following code at + read_sector_cbios: movb $0x42, %ah ; jmp read_common */ + movl $0xeb42b4+((read_common-read_sector_cbios-4) << 24), \ + (read_sector_cbios) + jmp 2f +1: + xor %cx, %cx /* Clear EBIOS flag. */ +2: + popw %dx + pushw %cx /* EBIOS flag */ + + /* Get (C)HS geometry */ + movb $0x08, %ah + int $0x13 + popw %bx /* EBIOS flag */ + movzbw %dh, %ax /* dh = max head */ + incw %ax /* From 0-based max to count */ + pushw %ax /* -16: Save heads on the stack */ + andw $0x3f, %cx /* Sector count */ + pushw %cx /* -18: Save sectors on the stack */ + mulw %cx /* Heads*sectors -> sectors per cylinder */ + + pushw %bx /* -20: EBIOS flag */ + + /* Save sectors/cylinder on the stack */ + pushw %dx /* -22: High word */ + pushw %ax /* -24: Low word */ + + /* + * Load sectors. We do this one at a time mostly to avoid + * pitfalls and to share code with the stock MBR code. + */ + movw $0x7c00, %bx + xorl %eax, %eax + movb $17*4, %al /* EL TORITO spec */ + call read_sector + jc disk_error + movl 71(%bx), %eax /* catalog */ + shll $2, %eax + call read_sector + jc disk_error + movl 40(%bx), %eax /* boot code */ + shll $2, %eax + movw $4, %cx /* Sector count */ + +2: + call read_sector + jc disk_error + incl %eax + addb $(512 >> 8), %bh + loopw 2b + + /* + * Okay, that actually worked... update the stack pointer + * and jump into isolinux.bin... + */ + cmpl $HYBRID_MAGIC,(isolinux_hybrid_signature) + jne bad_signature + + cli + movw $ebios_flag, %sp + + /* + * Use a ljmpw here to work around a bug in some unknown version + * of gas or ld when it comes to jumping to an absolute symbol... + * + * Look more closely into it if we ever are short on space. + */ + ljmpw $0, $isolinux_start_hybrid + +bad_signature: + call error + .ascii "isolinux.bin missing or corrupt.\r\n" + +disk_error: + call error + .ascii "Operating system load error.\r\n" + +/* + * read_sector: read a single sector pointed to by %eax to %es:%bx. + * CF is set on error. All registers saved. + */ +read_sector: + pushal + xorl %edx, %edx +#ifdef PARTITION_SUPPORT + addl (partoffset), %eax + adcl (partoffset+4), %edx +#endif + pushl %edx /* MSW of LBA */ + pushl %eax /* LSW of LBA */ + pushw %es /* Buffer segment */ + pushw %bx /* Buffer offset */ + pushw $1 /* Sector count */ + pushw $16 /* Size of packet */ + movw %sp, %si + + /* This chunk is skipped if we have ebios */ + /* Do not clobber %eax before this chunk! */ + /* This also relies on %bx and %edx as set up above. */ +read_sector_cbios: + divl (secpercyl) + shlb $6, %ah + movb %ah, %cl + movb %al, %ch + xchgw %dx, %ax + divb (sectors) + movb %al, %dh + orb %ah, %cl + incw %cx /* Sectors are 1-based */ + movw $0x0201, %ax + +read_common: + movb (driveno), %dl + int $0x13 + leaw 16(%si), %sp /* Drop DAPA */ + popal + ret + +/* + * Print error messages. This is invoked with "call", with the + * error message at the return address. + */ +error: + popw %si +2: + lodsb + movb $0x0e, %ah + movb (BIOS_page), %bh + movb $0x07, %bl + int $0x10 /* May destroy %bp */ + cmpb $10, %al /* Newline? */ + jne 2b + + int $0x18 /* Boot failure */ +die: + hlt + jmp die .org 0x0750,0xBB stopmsg: .ascii "This program cannot be run in DOS mode.$" diff -r 50eb3433cb74 -r a2e843f5d9e4 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Jun 19 20:32:02 2020 -0400 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Jun 20 14:15:09 2020 +0000 @@ -100,13 +100,10 @@ 0000 0080 0178 0040 0270 0190 -0750 0028 +0600 0178 EOT i=$((0x600)) - store 417 $(($i/512)) $1 8 ### isolinux boot sector - printf "Moving syslinux hybrid boot record at %04X (336 bytes) ...\n" $i OFS=$SIZE - ddn if=$2 bs=1 count=336 of=$1 seek=$i rm -f /tmp/exe$$ /tmp/coff$$ if [ -z "$RECURSIVE_PARTITION" -a $(get 454 $1 4) -eq 0 ]; then store 448 $((1+$i/512)) $1 8 ### 446+2 SECTOR