wok rev 23867
syslinux/bootiso.S: merge isolinux boot sector
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jun 20 14:15:09 2020 +0000 (2020-06-20) |
parents | 50eb3433cb74 |
children | 9096d6788292 |
files | linld/stuff/src/ISO9660.CPP syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/linld/stuff/src/ISO9660.CPP Fri Jun 19 20:32:02 2020 -0400 1.2 +++ b/linld/stuff/src/ISO9660.CPP Sat Jun 20 14:15:09 2020 +0000 1.3 @@ -84,10 +84,15 @@ 1.4 } 1.5 p += len; 1.6 } while (x->buffer + x->curpos + x->entrysize - 2 > p); 1.7 +#ifdef ISOHOOK 1.8 + *endname = 0; 1.9 +#else 1.10 if (endname) 1.11 *endname = 0; 1.12 else 1.13 #endif 1.14 +#endif 1.15 +#ifndef ISOHOOK 1.16 { 1.17 p = x->buffer + 33; x->filename = p += x->curpos; 1.18 p--; 1.19 @@ -105,6 +110,7 @@ 1.20 *p = 0; 1.21 } 1.22 } 1.23 +#endif 1.24 x->curpos += x->entrysize; 1.25 return 0; 1.26 }
2.1 --- a/syslinux/stuff/iso2exe/bootiso.S Fri Jun 19 20:32:02 2020 -0400 2.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Jun 20 14:15:09 2020 +0000 2.3 @@ -36,6 +36,7 @@ 2.4 start0: 2.5 //pushw %dx // restore %sp 2.6 //incw %bp // restore %bp 2.7 + movw %ds, %ax 2.8 xorw %bx, %bx 2.9 movw %bx, %ds 2.10 movb $0x7C, %bh 2.11 @@ -45,10 +46,8 @@ 2.12 pushw %bx // return address 2.13 pushw %di 2.14 pushw %es // save %es:%di 2.15 + pushw %si 2.16 cld 2.17 - sti 2.18 - pushw %ds 2.19 - popw %es 2.20 call setreg 2.21 rep 2.22 movsw 2.23 @@ -63,8 +62,10 @@ 2.24 .word 0 2.25 2.26 .org 66 2.27 +start2: 2.28 + pushw %ax // original %ds 2.29 + sti 2.30 dxloop: 2.31 -start2: 2.32 call readsector1 // look for the boot device 2.33 repe 2.34 cmpsw 2.35 @@ -76,8 +77,11 @@ 2.36 dxfound: 2.37 call readsectorX // read isolinux boot sector 2.38 cmpw (%bx), %cx 2.39 + movw $moved+nobsmsg, %si 2.40 jnc puts // read fail or no isohydrid boot sector 2.41 call bootpartition // assume DS=SS SI=BX=7C00 CX=0100 DL=<drive> DI=table+66 2.42 + popw %ds 2.43 + popw %si 2.44 popw %es 2.45 popw %di // isolinux boot needs %es:%di and %dx 2.46 putsret: 2.47 @@ -87,15 +91,10 @@ 2.48 movw $7, %bx 2.49 movb $0xE, %ah 2.50 int $0x10 2.51 -error: 2.52 +puts: 2.53 lodsb 2.54 - cmp $1, %al 2.55 - jg putstrlp 2.56 - jz putsret 2.57 -puts: 2.58 - movb $0x80, %ah 2.59 - xchgw %ax, %si 2.60 - jnc error 2.61 + cmp $0, %al 2.62 + jnz putstrlp 2.63 halt: 2.64 hlt 2.65 jmp halt 2.66 @@ -134,7 +133,7 @@ 2.67 2.68 .org 0x01A0,0xFF 2.69 readsectorX: // read isolinux boot sector 2.70 - movb $0xA5, %cl // patched by installer 2.71 + movb $3, %cl // isolinux/512 2.72 readsector1: 2.73 andb $0x83, %dl // disk and floppy disk 2.74 movw %cx, (%bx) 2.75 @@ -142,10 +141,11 @@ 2.76 movw $0x201, %ax 2.77 int $0x13 2.78 setreg: 2.79 + pushw %ds 2.80 + popw %es 2.81 movw %bx, %si 2.82 movw $moved, %di 2.83 movw $0x0100, %cx 2.84 - movb $nobsmsg, %al 2.85 ret 2.86 .org 0x01B8,0xEE // partition table 2.87 2.88 @@ -370,6 +370,254 @@ 2.89 2.90 .org 0x0400,0xEE 2.91 .org 0x0600,0xFF 2.92 +isolinux: 2.93 + .arch i486 2.94 +/* ----------------------------------------------------------------------- 2.95 + * 2.96 + * Copyright 2007-2009 H. Peter Anvin - All Rights Reserved 2.97 + * Copyright 2009 Intel Corporation; author: H. Peter Anvin 2.98 + * 2.99 + * Permission is hereby granted, free of charge, to any person 2.100 + * obtaining a copy of this software and associated documentation 2.101 + * files (the "Software"), to deal in the Software without 2.102 + * restriction, including without limitation the rights to use, 2.103 + * copy, modify, merge, publish, distribute, sublicense, and/or 2.104 + * sell copies of the Software, and to permit persons to whom 2.105 + * the Software is furnished to do so, subject to the following 2.106 + * conditions: 2.107 + * 2.108 + * The above copyright notice and this permission notice shall 2.109 + * be included in all copies or substantial portions of the Software. 2.110 + * 2.111 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2.112 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 2.113 + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2.114 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 2.115 + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 2.116 + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2.117 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2.118 + * OTHER DEALINGS IN THE SOFTWARE. 2.119 + * 2.120 + * ----------------------------------------------------------------------- */ 2.121 + 2.122 +HYBRID_MAGIC = 0x7078c0fb 2.123 +isolinux_hybrid_signature = 0x7c00+64 2.124 +isolinux_start_hybrid = 0x7c00+64+4 2.125 + 2.126 +stack = 0x7c00 2.127 +partoffset = (stack-8) 2.128 +driveno = (stack-14) 2.129 +heads = (stack-16) 2.130 +sectors = (stack-18) 2.131 +ebios_flag = (stack-20) 2.132 +secpercyl = (stack-24) 2.133 + 2.134 +BIOS_kbdflags = 0x417 2.135 +BIOS_page = 0x462 2.136 + 2.137 +_start2: 2.138 + .byte 0x33, 0xed /* xorw %bp, %bp */ 2.139 + 2.140 + /* Check to see if we have a partition table entry */ 2.141 + xorl %ebx, %ebx 2.142 + xorl %ecx, %ecx 2.143 +#ifdef PARTITION_SUPPORT 2.144 + andw %si, %si /* %si == 0 -> no partition data */ 2.145 + jz 1f 2.146 + testb $0x7f, (%si) /* Invalid active flag field? */ 2.147 + jnz 1f 2.148 + cmpb %cl, 4(%si) /* Partition type zero == invalid? */ 2.149 + je 1f 2.150 + cmpl $0x58504721, %eax /* !GPT signature in EAX? */ 2.151 + jne 2f 2.152 + cmpb $0xed, 4(%si) /* EFI partition type? */ 2.153 + jne 2f 2.154 + 2.155 + /* We have GPT partition information */ 2.156 + movl (32+20)(%si), %ecx 2.157 + movl (36+20)(%si), %ebx 2.158 + jmp 1f 2.159 + 2.160 + /* We have non-GPT partition information */ 2.161 +2: 2.162 + movl 8(%si), %ecx 2.163 +#endif 2.164 +1: 2.165 + movw %sp, %si 2.166 + 2.167 + /* We have no partition information */ 2.168 + pushl %ebx /* -4: partoffset_hi */ 2.169 + pushl %ecx /* -8: partoffset_lo */ 2.170 + pushw %es /* -10: es:di -> $PnP header */ 2.171 + pushw %di /* -12: es:di -> $PnP header */ 2.172 + 2.173 + movw %bp, %ds 2.174 + movw %bp, %es 2.175 + 2.176 + //ADJUST_DRIVE 2.177 + pushw %dx /* -14: dl -> drive number */ 2.178 + 2.179 + /* Copy down to 0:0x600 */ 2.180 + movw $0x7c00, %si 2.181 + movw $_start2, %di 2.182 + movw $(512/2), %cx 2.183 + rep; movsw 2.184 + 2.185 + ljmpw $0, $2f 2.186 +2: 2.187 + 2.188 + /* Check to see if we have EBIOS */ 2.189 + pushw %dx /* drive number */ 2.190 + movb $0x41, %ah /* %al == 0 already */ 2.191 + movw $0x55aa, %bx 2.192 + xorw %cx, %cx 2.193 + xorb %dh, %dh 2.194 + stc 2.195 + int $0x13 2.196 + jc 1f 2.197 + cmpw $0xaa55, %bx 2.198 + jne 1f 2.199 + andw $1,%cx /* Bit 0 = fixed disk subset */ 2.200 + jz 1f 2.201 + 2.202 + /* We have EBIOS; patch in the following code at 2.203 + read_sector_cbios: movb $0x42, %ah ; jmp read_common */ 2.204 + movl $0xeb42b4+((read_common-read_sector_cbios-4) << 24), \ 2.205 + (read_sector_cbios) 2.206 + jmp 2f 2.207 +1: 2.208 + xor %cx, %cx /* Clear EBIOS flag. */ 2.209 +2: 2.210 + popw %dx 2.211 + pushw %cx /* EBIOS flag */ 2.212 + 2.213 + /* Get (C)HS geometry */ 2.214 + movb $0x08, %ah 2.215 + int $0x13 2.216 + popw %bx /* EBIOS flag */ 2.217 + movzbw %dh, %ax /* dh = max head */ 2.218 + incw %ax /* From 0-based max to count */ 2.219 + pushw %ax /* -16: Save heads on the stack */ 2.220 + andw $0x3f, %cx /* Sector count */ 2.221 + pushw %cx /* -18: Save sectors on the stack */ 2.222 + mulw %cx /* Heads*sectors -> sectors per cylinder */ 2.223 + 2.224 + pushw %bx /* -20: EBIOS flag */ 2.225 + 2.226 + /* Save sectors/cylinder on the stack */ 2.227 + pushw %dx /* -22: High word */ 2.228 + pushw %ax /* -24: Low word */ 2.229 + 2.230 + /* 2.231 + * Load sectors. We do this one at a time mostly to avoid 2.232 + * pitfalls and to share code with the stock MBR code. 2.233 + */ 2.234 + movw $0x7c00, %bx 2.235 + xorl %eax, %eax 2.236 + movb $17*4, %al /* EL TORITO spec */ 2.237 + call read_sector 2.238 + jc disk_error 2.239 + movl 71(%bx), %eax /* catalog */ 2.240 + shll $2, %eax 2.241 + call read_sector 2.242 + jc disk_error 2.243 + movl 40(%bx), %eax /* boot code */ 2.244 + shll $2, %eax 2.245 + movw $4, %cx /* Sector count */ 2.246 + 2.247 +2: 2.248 + call read_sector 2.249 + jc disk_error 2.250 + incl %eax 2.251 + addb $(512 >> 8), %bh 2.252 + loopw 2b 2.253 + 2.254 + /* 2.255 + * Okay, that actually worked... update the stack pointer 2.256 + * and jump into isolinux.bin... 2.257 + */ 2.258 + cmpl $HYBRID_MAGIC,(isolinux_hybrid_signature) 2.259 + jne bad_signature 2.260 + 2.261 + cli 2.262 + movw $ebios_flag, %sp 2.263 + 2.264 + /* 2.265 + * Use a ljmpw here to work around a bug in some unknown version 2.266 + * of gas or ld when it comes to jumping to an absolute symbol... 2.267 + * 2.268 + * Look more closely into it if we ever are short on space. 2.269 + */ 2.270 + ljmpw $0, $isolinux_start_hybrid 2.271 + 2.272 +bad_signature: 2.273 + call error 2.274 + .ascii "isolinux.bin missing or corrupt.\r\n" 2.275 + 2.276 +disk_error: 2.277 + call error 2.278 + .ascii "Operating system load error.\r\n" 2.279 + 2.280 +/* 2.281 + * read_sector: read a single sector pointed to by %eax to %es:%bx. 2.282 + * CF is set on error. All registers saved. 2.283 + */ 2.284 +read_sector: 2.285 + pushal 2.286 + xorl %edx, %edx 2.287 +#ifdef PARTITION_SUPPORT 2.288 + addl (partoffset), %eax 2.289 + adcl (partoffset+4), %edx 2.290 +#endif 2.291 + pushl %edx /* MSW of LBA */ 2.292 + pushl %eax /* LSW of LBA */ 2.293 + pushw %es /* Buffer segment */ 2.294 + pushw %bx /* Buffer offset */ 2.295 + pushw $1 /* Sector count */ 2.296 + pushw $16 /* Size of packet */ 2.297 + movw %sp, %si 2.298 + 2.299 + /* This chunk is skipped if we have ebios */ 2.300 + /* Do not clobber %eax before this chunk! */ 2.301 + /* This also relies on %bx and %edx as set up above. */ 2.302 +read_sector_cbios: 2.303 + divl (secpercyl) 2.304 + shlb $6, %ah 2.305 + movb %ah, %cl 2.306 + movb %al, %ch 2.307 + xchgw %dx, %ax 2.308 + divb (sectors) 2.309 + movb %al, %dh 2.310 + orb %ah, %cl 2.311 + incw %cx /* Sectors are 1-based */ 2.312 + movw $0x0201, %ax 2.313 + 2.314 +read_common: 2.315 + movb (driveno), %dl 2.316 + int $0x13 2.317 + leaw 16(%si), %sp /* Drop DAPA */ 2.318 + popal 2.319 + ret 2.320 + 2.321 +/* 2.322 + * Print error messages. This is invoked with "call", with the 2.323 + * error message at the return address. 2.324 + */ 2.325 +error: 2.326 + popw %si 2.327 +2: 2.328 + lodsb 2.329 + movb $0x0e, %ah 2.330 + movb (BIOS_page), %bh 2.331 + movb $0x07, %bl 2.332 + int $0x10 /* May destroy %bp */ 2.333 + cmpb $10, %al /* Newline? */ 2.334 + jne 2b 2.335 + 2.336 + int $0x18 /* Boot failure */ 2.337 +die: 2.338 + hlt 2.339 + jmp die 2.340 .org 0x0750,0xBB 2.341 stopmsg: 2.342 .ascii "This program cannot be run in DOS mode.$"
3.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Jun 19 20:32:02 2020 -0400 3.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Jun 20 14:15:09 2020 +0000 3.3 @@ -100,13 +100,10 @@ 3.4 0000 0080 3.5 0178 0040 3.6 0270 0190 3.7 -0750 0028 3.8 +0600 0178 3.9 EOT 3.10 i=$((0x600)) 3.11 - store 417 $(($i/512)) $1 8 ### isolinux boot sector 3.12 - printf "Moving syslinux hybrid boot record at %04X (336 bytes) ...\n" $i 3.13 OFS=$SIZE 3.14 - ddn if=$2 bs=1 count=336 of=$1 seek=$i 3.15 rm -f /tmp/exe$$ /tmp/coff$$ 3.16 if [ -z "$RECURSIVE_PARTITION" -a $(get 454 $1 4) -eq 0 ]; then 3.17 store 448 $((1+$i/512)) $1 8 ### 446+2 SECTOR