wok rev 541
etherboot: use bzImage format instead of obsolete zImage
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Apr 11 16:30:14 2008 +0000 (2008-04-11) |
parents | e0c2f4f235e9 |
children | 9df97454897b |
files | etherboot/receipt etherboot/stuff/etherboot-prefix.u |
line diff
1.1 --- a/etherboot/receipt Thu Apr 10 22:34:56 2008 +0000 1.2 +++ b/etherboot/receipt Fri Apr 11 16:30:14 2008 +0000 1.3 @@ -15,7 +15,7 @@ 1.4 cd $src/src 1.5 patch -p2 < ../../stuff/etherboot-net.u 1.6 patch -p2 < ../../stuff/etherboot-prefix.u 1.7 - make bin/etherboot-net.zlilo 1.8 + make bin/etherboot-net.bzImage 1.9 } 1.10 1.11 1.12 @@ -23,7 +23,7 @@ 1.13 genpkg_rules() 1.14 { 1.15 mkdir -p $fs/usr/share/boot 1.16 - cp $src/src/bin/etherboot-net.zlilo $fs/usr/share/boot/etherboot 1.17 + cp $src/src/bin/etherboot-net.bzImage $fs/usr/share/boot/etherboot 1.18 } 1.19 1.20 # Pre and post install commands for Tazpkg.
2.1 --- a/etherboot/stuff/etherboot-prefix.u Thu Apr 10 22:34:56 2008 +0000 2.2 +++ b/etherboot/stuff/etherboot-prefix.u Fri Apr 11 16:30:14 2008 +0000 2.3 @@ -1,6 +1,6 @@ 2.4 --- etherboot-5.4.3/src/arch/i386/prefix/liloprefix.S 2.5 +++ etherboot-5.4.3/src/arch/i386/prefix/liloprefix.S 2.6 -@@ -1,92 +1,393 @@ 2.7 +@@ -1,92 +1,377 @@ 2.8 -/* 2.9 - Copyright (C) 2000, Entity Cyber, Inc. 2.10 - 2.11 @@ -39,10 +39,7 @@ 2.12 - of setup code are contained in the image. 2.13 - 2.14 -*/ 2.15 -+/* NOTE: this boot sector contains instructions that need at least an 80186. 2.16 -+ * Yes, as86 has a bug somewhere in the valid instruction set checks. 2.17 -+ * 2.18 -+ * SYS_SIZE is the number of clicks (16 bytes) to be loaded. For Etherboot 2.19 ++/* SYS_SIZE is the number of clicks (16 bytes) to be loaded. For Etherboot 2.20 + * purposes, we need to load everything but the boot sector itself, i.e. 32 2.21 + * clicks less than the size of the entire (verbatim) image. The image size 2.22 + * is practically limited only by the available base memory size. 2.23 @@ -91,14 +88,13 @@ 2.24 + .text 2.25 + .section ".prefix", "ax", @progbits 2.26 + .code16 2.27 - 2.28 --bootsector: 2.29 -- jmp $BOOTSEG, $go - _prefix /* reload cs:ip to match relocation addr */ 2.30 ++ 2.31 + call here 2.32 +here: 2.33 + pop %ax 2.34 + cmpw $0x103, %ax /* COM entry point is cs:0x100 */ 2.35 + jne bootsector 2.36 ++ 2.37 +/* We need a real mode stack that won't be stomped on by Etherboot 2.38 + which starts at 0x20000. Choose something that's sufficiently high, 2.39 + but not in DOC territory. Note that we couldn't do this in a real 2.40 @@ -113,18 +109,14 @@ 2.41 + movw %ax, %ss 2.42 + movw $STACK_SIZE, %sp 2.43 + 2.44 -+ pushl $0 /* No parameters to preserve for exit path */ 2.45 -+ pushw $0 /* Dummy return address - use prefix_exit */ 2.46 -+ 2.47 + /* Calculate segment address of image start */ 2.48 + pushw %cs 2.49 + popw %ax 2.50 + addw $(0x100/16), %ax 2.51 -+ pushw %ax 2.52 -+ pushw $_start 2.53 -+ /* Calculated lcall to _start with %cs:0000 = image start */ 2.54 -+ lret 2.55 -+ 2.56 ++ jmp go_setup_code 2.57 + 2.58 +-bootsector: 2.59 +- jmp $BOOTSEG, $go - _prefix /* reload cs:ip to match relocation addr */ 2.60 +bootsector: 2.61 + jmp $BOOTSEG, $go /* reload cs:ip to match relocation addr */ 2.62 go: 2.63 @@ -197,15 +189,18 @@ 2.64 + * 36 sectors if sector 36 can be read, 18 sectors if sector 18 can be read, 2.65 + * 15 if sector 15 can be read. Otherwise guess 9. 2.66 + */ 2.67 -+ 2.68 + 2.69 +- movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.70 +- movb $0x0e, %ah /* write char, tty mode */ 2.71 +-prloop: 2.72 + movw $disksizes, %si /* table of sizes to try */ 2.73 + 2.74 +probe_loop: 2.75 -+ lodsb 2.76 + lodsb 2.77 ++ orb %al, %al 2.78 ++ je got_sectors /* if all else fails, try 9 */ 2.79 + cbtw /* extend to word */ 2.80 + movw %ax, sectors 2.81 -+ cmpw $disksizes+4, %si 2.82 -+ jae got_sectors /* if all else fails, try 9 */ 2.83 + xchgw %cx,%ax /* cx = track and sector */ 2.84 + xorw %dx,%dx /* drive 0, head 0 */ 2.85 + movw $0x0200, %bx /* address after boot sector */ 2.86 @@ -250,9 +245,8 @@ 2.87 + 2.88 +/* after that (everything loaded), we call to the .ROM file loaded. */ 2.89 + 2.90 -+ pushl $0 /* No parameters to preserve for exit path */ 2.91 -+ pushw $0 /* Use prefix exit path mechanism */ 2.92 -+ ljmp $SYSSEG, $_start 2.93 ++ movw $SYSSEG, %ax 2.94 ++ jmp go_setup_code 2.95 + 2.96 +/* This routine loads the system at address SYSSEG<<4, making sure no 64kB 2.97 + * boundaries are crossed. We try to load it as fast as possible, loading whole 2.98 @@ -279,13 +273,13 @@ 2.99 + movw sectors, %ax 2.100 + subw sread, %ax 2.101 + movw %ax,%cx 2.102 -+ shlw $9, %cx 2.103 ++ shlw $9, %cx /* 80186 opcode */ 2.104 + addw %bx,%cx 2.105 + jnc ok2_read 2.106 + je ok2_read 2.107 + xorw %ax,%ax 2.108 + subw %bx,%ax 2.109 -+ shrw $9, %ax 2.110 ++ shrw $9, %ax /* 80186 opcode */ 2.111 +ok2_read: 2.112 + call read_track 2.113 + movw %ax,%cx 2.114 @@ -301,7 +295,7 @@ 2.115 + xorw %ax,%ax 2.116 +ok3_read: 2.117 + movw %ax, sread 2.118 -+ shlw $9, %cx 2.119 ++ shlw $9, %cx /* 80186 opcode */ 2.120 + addw %cx,%bx 2.121 + jnc rp_read 2.122 + movw %es,%ax 2.123 @@ -311,24 +305,21 @@ 2.124 + jmp rp_read 2.125 + 2.126 +read_track: 2.127 -+ pusha 2.128 ++ pusha /* 80186 opcode */ 2.129 + pushw %ax 2.130 + pushw %bx 2.131 + pushw %bp /* just in case the BIOS is buggy */ 2.132 -+ movw $0x0e2e, %ax /* 0x2e = . */ 2.133 -+ movw $0x0007, %bx 2.134 -+ int $0x10 2.135 ++ movb $0x2e, %al /* 0x2e = . */ 2.136 ++ call print_char 2.137 + popw %bp 2.138 + popw %bx 2.139 + popw %ax 2.140 + 2.141 -+ movw track, %dx 2.142 + movw sread, %cx 2.143 + incw %cx 2.144 -+ movb %dl,%ch 2.145 -+ movw head, %dx 2.146 -+ movb %dl,%dh 2.147 -+ andw $0x0100, %dx 2.148 ++ movb track, %ch 2.149 ++ movw $0x0100, %dx 2.150 ++ andb head, %dh 2.151 + movb $2, %ah 2.152 + 2.153 + pushw %dx /* save for error dump */ 2.154 @@ -339,7 +330,7 @@ 2.155 + int $0x13 2.156 + jc bad_rt 2.157 + addw $8, %sp 2.158 -+ popa 2.159 ++ popa /* 80186 opcode */ 2.160 + ret 2.161 + 2.162 +bad_rt: pushw %ax /* save error code */ 2.163 @@ -350,7 +341,7 @@ 2.164 + int $0x13 2.165 + 2.166 + addw $10, %sp 2.167 -+ popa 2.168 ++ popa /* 80186 opcode */ 2.169 + jmp read_track 2.170 + 2.171 +/* print_all is for debugging purposes. It will print out all of the registers. 2.172 @@ -365,6 +356,7 @@ 2.173 + 2.174 +print_all: 2.175 + call print_nl /* nl for readability */ 2.176 ++ /* print_nl update ah and bx */ 2.177 + movw $5, %cx /* error code + 4 registers */ 2.178 + movw %sp,%bp 2.179 + 2.180 @@ -373,9 +365,8 @@ 2.181 + 2.182 + cmpb $5, %cl 2.183 + jae no_reg /* see if register name is needed */ 2.184 - 2.185 - movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.186 -+ movw $0xe05+0x41-1, %ax 2.187 ++ 2.188 ++ movb $0x5+0x41-1, %al 2.189 + subb %cl,%al 2.190 + int $0x10 2.191 + 2.192 @@ -389,49 +380,45 @@ 2.193 + addw $2, %bp /* next register */ 2.194 + call print_hex /* print it */ 2.195 + movb $0x20, %al /* print a space */ 2.196 -+ int $0x10 2.197 + int $0x10 2.198 + popw %cx 2.199 + loop print_loop 2.200 -+ call print_nl /* nl for readability */ 2.201 -+ ret 2.202 ++ /* nl for readability */ 2.203 ++print_nl: 2.204 ++ movb $0xd, %al /* CR */ 2.205 ++ call print_char 2.206 ++ movb $0xa, %al /* LF */ 2.207 ++ jmp print_char 2.208 ++ 2.209 + 2.210 +print_str: 2.211 -+ movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.212 - movb $0x0e, %ah /* write char, tty mode */ 2.213 - prloop: 2.214 - lodsb 2.215 - int $0x10 2.216 ++prloop: 2.217 ++ lodsb 2.218 ++ call print_char 2.219 loop prloop 2.220 -freeze: jmp freeze 2.221 + ret 2.222 + 2.223 -+print_nl: 2.224 -+ movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.225 -+ movw $0xe0d, %ax /* CR */ 2.226 -+ int $0x10 2.227 -+ movb $0xa, %al /* LF */ 2.228 -+ int $0x10 2.229 -+ ret 2.230 -+ 2.231 +/* print_hex prints the word pointed to by ss:bp in hexadecimal. */ 2.232 + 2.233 +print_hex: 2.234 + movw (%bp),%dx /* load word into dx */ 2.235 + movb $4, %cl 2.236 -+ movb $0x0e, %ah /* write char, tty mode */ 2.237 -+ movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.238 -+ call print_digit2 2.239 -+print_digit2: 2.240 ++ call print_2digits 2.241 ++print_2digits: 2.242 + call print_digit 2.243 +/* fall through */ 2.244 +print_digit: 2.245 -+ rol %cl,%dx /* rotate so that lowest 4 bits are used */ 2.246 ++ rol %cl,%dx /* rotate to use lowest 4 bits */ 2.247 + movb $0x0f, %al /* mask for nybble */ 2.248 + andb %dl,%al 2.249 -+ addb $0x90, %al /* convert al to ascii hex (four instructions) */ 2.250 -+ daa 2.251 ++ addb $0x90, %al /* convert al to ascii hex */ 2.252 ++ daa /* (four instructions) */ 2.253 + adcb $0x40, %al 2.254 + daa 2.255 ++print_char: 2.256 ++ movb $0x0e, %ah /* write char, tty mode */ 2.257 ++ movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.258 + int $0x10 2.259 + ret 2.260 + 2.261 @@ -448,11 +435,425 @@ 2.262 -why: .ascii "This image cannot be loaded from a floppy disk.\r\n" 2.263 -why_end: 2.264 +disksizes: 2.265 -+ .byte 36,18,15,9 2.266 ++ .byte 36,18,15,9,0 2.267 2.268 +msg1: 2.269 -+ .ascii "Loading ROM" 2.270 ++ .ascii "Loading ROM image" 2.271 +msg1end: 2.272 2.273 .org 497 2.274 setup_sects: 2.275 +@@ -117,15 +402,22 @@ 2.276 + whose entry point is SYSSEG:0. 2.277 + */ 2.278 + setup_code: 2.279 +- pushl $0 /* No parameters to preserve for exit path */ 2.280 +- pushw $0 /* Use prefix exit path mechanism */ 2.281 ++ movw $(SYSSEG-(PREFIXSIZE/16)), %ax 2.282 + /* Etherboot expects to be contiguous in memory once loaded. 2.283 + * LILO doesn't do this, but since we don't need any 2.284 + * information that's left in the prefix, it doesn't matter: 2.285 + * we just have to ensure that %cs:0000 is where the start of 2.286 + * the Etherboot image *would* be. 2.287 + */ 2.288 +- ljmp $(SYSSEG-(PREFIXSIZE/16)), $_start 2.289 ++go_setup_code: 2.290 ++ xorw %cx, %cx 2.291 ++ pushw %cx 2.292 ++ pushw %cx /* No parameters to preserve for exit path */ 2.293 ++ pushw %cx /* Use prefix exit path mechanism */ 2.294 ++ pushw %ax 2.295 ++ pushw $_start 2.296 ++ /* Calculated lcall to _start with %cs:0000 = image start */ 2.297 ++ lret 2.298 + 2.299 + .section ".text16", "ax", @progbits 2.300 + .globl prefix_exit 2.301 + 2.302 +--- etherboot-5.4.3/src/arch/i386/prefix/bImageprefix.S 2.303 ++++ etherboot-5.4.3/src/arch/i386/prefix/bImageprefix.S 2.304 +@@ -82,6 +82,14 @@ 2.305 + #define SIG1 0xAA55 2.306 + #define SIG2 0x5A5A 2.307 + 2.308 ++/* SYS_SIZE is the number of clicks (16 bytes) to be loaded. For Etherboot 2.309 ++ * purposes, we need to load everything but the boot sector itself, i.e. 32 2.310 ++ * clicks less than the size of the entire (verbatim) image. The image size 2.311 ++ * is practically limited only by the available base memory size. 2.312 ++ */ 2.313 ++.globl SYSSIZE 2.314 ++.equ SYSSIZE, _verbatim_size_pgh - 32 2.315 ++ 2.316 + .text 2.317 + .code16 2.318 + .arch i386 2.319 +@@ -90,40 +98,349 @@ 2.320 + .globl _prefix 2.321 + _prefix: 2.322 + 2.323 +-/* 2.324 +- This is a minimal boot sector. If anyone tries to execute it (e.g., if 2.325 +- a .lilo file is dd'ed to a floppy), print an error message. 2.326 +-*/ 2.327 ++ call here 2.328 ++here: 2.329 ++ pop %ax 2.330 ++ cmpw $0x103, %ax /* COM entry point is cs:0x100 */ 2.331 ++ jne bootsector 2.332 ++ 2.333 ++/* We need a real mode stack that won't be stomped on by Etherboot 2.334 ++ which starts at 0x20000. Choose something that's sufficiently high, 2.335 ++ but not in DOC territory. Note that we couldn't do this in a real 2.336 ++ .com program since stack variables are in the same segment as the 2.337 ++ code and data, but this isn't really a .com program, it just looks 2.338 ++ like one to make DOS load it into memory. It still has the 64kB 2.339 ++ limitation of .com files though. */ 2.340 ++#define STACK_SEG 0x7000 2.341 ++#define STACK_SIZE 0x4000 2.342 ++ /* Set up temporary stack */ 2.343 ++ movw $STACK_SEG, %ax 2.344 ++ movw %ax, %ss 2.345 ++ movw $STACK_SIZE, %sp 2.346 ++ 2.347 ++ /* Calculate segment address of image start */ 2.348 ++ pushw %cs 2.349 ++ popw %ax 2.350 ++ addw $(0x100/16), %ax 2.351 ++ jmp go_setup_code 2.352 + 2.353 +-bootsector: 2.354 +- jmp $BOOTSEG, $go - _prefix /* reload cs:ip to match relocation addr */ 2.355 ++bootsector: 2.356 ++ jmp $BOOTSEG, $go /* reload cs:ip to match relocation addr */ 2.357 + go: 2.358 +- movw $0x2000, %di /* 0x2000 is arbitrary value >= length 2.359 +- of bootsect + room for stack */ 2.360 ++ movw $0x2000-12, %di /* 0x2000 is arbitrary value >= length */ 2.361 ++ /* of bootsect + room for stack + 12 for */ 2.362 ++ /* saved disk parm block */ 2.363 + 2.364 + movw $BOOTSEG, %ax 2.365 + movw %ax,%ds 2.366 + movw %ax,%es 2.367 +- 2.368 +- cli 2.369 +- movw %ax, %ss /* put stack at BOOTSEG:0x2000. */ 2.370 ++ movw %ax,%ss /* put stack at initial position */ 2.371 + movw %di,%sp 2.372 +- sti 2.373 + 2.374 +- movw $why_end-why, %cx 2.375 +- movw $why - _prefix, %si 2.376 ++/* Many BIOS's default disk parameter tables will not recognize multi-sector 2.377 ++ * reads beyond the maximum sector number specified in the default diskette 2.378 ++ * parameter tables - this may mean 7 sectors in some cases. 2.379 ++ * 2.380 ++ * Since single sector reads are slow and out of the question, we must take care 2.381 ++ * of this by creating new parameter tables (for the first disk) in RAM. We 2.382 ++ * will set the maximum sector count to 36 - the most we will encounter on an 2.383 ++ * ED 2.88. High doesn't hurt. Low does. 2.384 ++ * 2.385 ++ * Segments are as follows: ds=es=ss=cs - BOOTSEG 2.386 ++ */ 2.387 ++ 2.388 ++ xorw %cx,%cx 2.389 ++ movw %cx,%es /* access segment 0 */ 2.390 ++ movw $0x78, %bx /* 0:bx is parameter table address */ 2.391 ++ pushw %ds /* save ds */ 2.392 ++/* 0:bx is parameter table address */ 2.393 ++ ldsw %es:(%bx),%si /* loads ds and si */ 2.394 ++ 2.395 ++ movw %ax,%es /* ax is BOOTSECT (loaded above) */ 2.396 ++ movb $6, %cl /* copy 12 bytes */ 2.397 ++ cld 2.398 ++ pushw %di /* keep a copy for later */ 2.399 ++ rep 2.400 ++ movsw /* ds:si is source, es:di is dest */ 2.401 ++ popw %di 2.402 + 2.403 +- movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.404 +- movb $0x0e, %ah /* write char, tty mode */ 2.405 +-prloop: 2.406 ++ movb $36,%es:4(%di) 2.407 ++ 2.408 ++ movw %cx,%ds /* access segment 0 */ 2.409 ++ xchgw %di,(%bx) 2.410 ++ movw %es,%si 2.411 ++ xchgw %si,2(%bx) 2.412 ++ popw %ds /* restore ds */ 2.413 ++ movw %di, dpoff /* save old parameters */ 2.414 ++ movw %si, dpseg /* to restore just before finishing */ 2.415 ++ pushw %ds 2.416 ++ popw %es /* reload es */ 2.417 ++ 2.418 ++/* Note that es is already set up. Also cx is 0 from rep movsw above. */ 2.419 ++ 2.420 ++ xorb %ah,%ah /* reset FDC */ 2.421 ++ xorb %dl,%dl 2.422 ++ int $0x13 2.423 ++ 2.424 ++/* Get disk drive parameters, specifically number of sectors/track. 2.425 ++ * 2.426 ++ * It seems that there is no BIOS call to get the number of sectors. Guess 2.427 ++ * 36 sectors if sector 36 can be read, 18 sectors if sector 18 can be read, 2.428 ++ * 15 if sector 15 can be read. Otherwise guess 9. 2.429 ++ */ 2.430 ++ 2.431 ++ movw $disksizes, %si /* table of sizes to try */ 2.432 ++ 2.433 ++probe_loop: 2.434 + lodsb 2.435 ++ orb %al, %al 2.436 ++ je got_sectors /* if all else fails, try 9 */ 2.437 ++ cbtw /* extend to word */ 2.438 ++ movw %ax, sectors 2.439 ++ xchgw %cx,%ax /* cx = track and sector */ 2.440 ++ xorw %dx,%dx /* drive 0, head 0 */ 2.441 ++ movw $0x0200, %bx /* address after boot sector */ 2.442 ++ /* (512 bytes from origin, es = cs) */ 2.443 ++ movw $0x0201, %ax /* service 2, 1 sector */ 2.444 ++ int $0x13 2.445 ++ jc probe_loop /* try next value */ 2.446 ++ 2.447 ++got_sectors: 2.448 ++ movw $msg1end-msg1, %cx 2.449 ++ movw $msg1, %si 2.450 ++ call print_str 2.451 ++ 2.452 ++/* ok, we've written the Loading... message, now we want to load the system */ 2.453 ++ 2.454 ++ pushw %es /* = ds */ 2.455 ++ movw $SYSSEG, %ax 2.456 ++ movw %ax,%es /* segment of SYSSEG<<4 */ 2.457 ++ pushw %es 2.458 ++ call read_it 2.459 ++ 2.460 ++/* This turns off the floppy drive motor, so that we enter the kernel in a 2.461 ++ * known state, and don't have to worry about it later. 2.462 ++ */ 2.463 ++ movw $0x3f2, %dx 2.464 ++ xorb %al,%al 2.465 ++ outb %al,%dx 2.466 ++ 2.467 ++ call print_nl 2.468 ++ pop %es /* = SYSSEG */ 2.469 ++ pop %es /* balance push/pop es */ 2.470 ++sigok: 2.471 ++ 2.472 ++/* Restore original disk parameters */ 2.473 ++ movw $0x78, %bx 2.474 ++ movw dpoff, %di 2.475 ++ movw dpseg, %si 2.476 ++ xorw %ax,%ax 2.477 ++ movw %ax,%ds 2.478 ++ movw %di,(%bx) 2.479 ++ movw %si,2(%bx) 2.480 ++ 2.481 ++/* after that (everything loaded), we call to the .ROM file loaded. */ 2.482 ++ 2.483 ++ movw $SYSSEG, %ax 2.484 ++go_setup_code: 2.485 ++ xorw %cx, %cx 2.486 ++ pushw %cx 2.487 ++ pushw %cx /* No parameters to preserve for exit path */ 2.488 ++ pushw %cx /* Use prefix exit path mechanism */ 2.489 ++ pushw %ax 2.490 ++ pushw $_start 2.491 ++ /* Calculated lcall to _start with %cs:0000 = image start */ 2.492 ++ lret 2.493 ++ 2.494 ++/* This routine loads the system at address SYSSEG<<4, making sure no 64kB 2.495 ++ * boundaries are crossed. We try to load it as fast as possible, loading whole 2.496 ++ * tracks whenever we can. 2.497 ++ * 2.498 ++ * in: es - starting address segment (normally SYSSEG) 2.499 ++ */ 2.500 ++read_it: 2.501 ++ movw $0,sread /* read whole image incl boot sector */ 2.502 ++ movw %es,%ax 2.503 ++ testw $0x0fff, %ax 2.504 ++die: jne die /* es must be at 64kB boundary */ 2.505 ++ xorw %bx,%bx /* bx is starting address within segment */ 2.506 ++rp_read: 2.507 ++ movw %es,%ax 2.508 ++ movw %bx,%dx 2.509 ++ movb $4, %cl 2.510 ++ shrw %cl,%dx /* bx is always divisible by 16 */ 2.511 ++ addw %dx,%ax 2.512 ++ cmpw $SYSSEG+SYSSIZE, %ax /* have we loaded all yet? */ 2.513 ++ jb ok1_read 2.514 ++ ret 2.515 ++ok1_read: 2.516 ++ movw sectors, %ax 2.517 ++ subw sread, %ax 2.518 ++ movw %ax,%cx 2.519 ++ shlw $9, %cx /* 80186 opcode */ 2.520 ++ addw %bx,%cx 2.521 ++ jnc ok2_read 2.522 ++ je ok2_read 2.523 ++ xorw %ax,%ax 2.524 ++ subw %bx,%ax 2.525 ++ shrw $9, %ax /* 80186 opcode */ 2.526 ++ok2_read: 2.527 ++ call read_track 2.528 ++ movw %ax,%cx 2.529 ++ addw sread, %ax 2.530 ++ cmpw sectors, %ax 2.531 ++ jne ok3_read 2.532 ++ movw $1, %ax 2.533 ++ subw head, %ax 2.534 ++ jne ok4_read 2.535 ++ incw track 2.536 ++ok4_read: 2.537 ++ movw %ax, head 2.538 ++ xorw %ax,%ax 2.539 ++ok3_read: 2.540 ++ movw %ax, sread 2.541 ++ shlw $9, %cx /* 80186 opcode */ 2.542 ++ addw %cx,%bx 2.543 ++ jnc rp_read 2.544 ++ movw %es,%ax 2.545 ++ addb $0x10, %ah 2.546 ++ movw %ax,%es 2.547 ++ xorw %bx,%bx 2.548 ++ jmp rp_read 2.549 ++ 2.550 ++read_track: 2.551 ++ pusha /* 80186 opcode */ 2.552 ++ pushw %ax 2.553 ++ pushw %bx 2.554 ++ pushw %bp /* just in case the BIOS is buggy */ 2.555 ++ movb $0x2e, %al /* 0x2e = . */ 2.556 ++ call print_char 2.557 ++ popw %bp 2.558 ++ popw %bx 2.559 ++ popw %ax 2.560 ++ 2.561 ++ movw sread, %cx 2.562 ++ incw %cx 2.563 ++ movb track, %ch 2.564 ++ movw $0x0100, %dx 2.565 ++ andb head, %dh 2.566 ++ movb $2, %ah 2.567 ++ 2.568 ++ pushw %dx /* save for error dump */ 2.569 ++ pushw %cx 2.570 ++ pushw %bx 2.571 ++ pushw %ax 2.572 ++ 2.573 ++ int $0x13 2.574 ++ jc bad_rt 2.575 ++ addw $8, %sp 2.576 ++ popa /* 80186 opcode */ 2.577 ++ ret 2.578 ++ 2.579 ++bad_rt: pushw %ax /* save error code */ 2.580 ++ call print_all /* ah = error, al = read */ 2.581 ++ 2.582 ++ xorb %ah,%ah 2.583 ++ xorb %dl,%dl 2.584 ++ int $0x13 2.585 ++ 2.586 ++ addw $10, %sp 2.587 ++ popa /* 80186 opcode */ 2.588 ++ jmp read_track 2.589 ++ 2.590 ++/* print_all is for debugging purposes. It will print out all of the registers. 2.591 ++ * The assumption is that this is called from a routine, with a stack frame like 2.592 ++ * dx 2.593 ++ * cx 2.594 ++ * bx 2.595 ++ * ax 2.596 ++ * error 2.597 ++ * ret <- sp 2.598 ++ */ 2.599 ++ 2.600 ++print_all: 2.601 ++ call print_nl /* nl for readability */ 2.602 ++ /* print_nl update ah and bx */ 2.603 ++ movw $5, %cx /* error code + 4 registers */ 2.604 ++ movw %sp,%bp 2.605 ++ 2.606 ++print_loop: 2.607 ++ pushw %cx /* save count left */ 2.608 ++ 2.609 ++ cmpb $5, %cl 2.610 ++ jae no_reg /* see if register name is needed */ 2.611 ++ 2.612 ++ movb $0x5+0x41-1, %al 2.613 ++ subb %cl,%al 2.614 + int $0x10 2.615 ++ 2.616 ++ movb $0x58, %al /* 'X' */ 2.617 ++ int $0x10 2.618 ++ 2.619 ++ movb $0x3A, %al /* ':' */ 2.620 ++ int $0x10 2.621 ++ 2.622 ++no_reg: 2.623 ++ addw $2, %bp /* next register */ 2.624 ++ call print_hex /* print it */ 2.625 ++ movb $0x20, %al /* print a space */ 2.626 ++ int $0x10 2.627 ++ popw %cx 2.628 ++ loop print_loop 2.629 ++ /* nl for readability */ 2.630 ++print_nl: 2.631 ++ movb $0xd, %al /* CR */ 2.632 ++ call print_char 2.633 ++ movb $0xa, %al /* LF */ 2.634 ++ jmp print_char 2.635 ++ 2.636 ++ 2.637 ++print_str: 2.638 ++prloop: 2.639 ++ lodsb 2.640 ++ call print_char 2.641 + loop prloop 2.642 +-freeze: jmp freeze 2.643 ++ ret 2.644 + 2.645 +-why: .ascii "This image cannot be loaded from a floppy disk.\r\n" 2.646 +-why_end: 2.647 ++/* print_hex prints the word pointed to by ss:bp in hexadecimal. */ 2.648 ++ 2.649 ++print_hex: 2.650 ++ movw (%bp),%dx /* load word into dx */ 2.651 ++ movb $4, %cl 2.652 ++ call print_2digits 2.653 ++print_2digits: 2.654 ++ call print_digit 2.655 ++/* fall through */ 2.656 ++print_digit: 2.657 ++ rol %cl,%dx /* rotate to use lowest 4 bits */ 2.658 ++ movb $0x0f, %al /* mask for nybble */ 2.659 ++ andb %dl,%al 2.660 ++ addb $0x90, %al /* convert al to ascii hex */ 2.661 ++ daa /* (four instructions) */ 2.662 ++ adcb $0x40, %al 2.663 ++ daa 2.664 ++print_char: 2.665 ++ movb $0x0e, %ah /* write char, tty mode */ 2.666 ++ movw $0x0007, %bx /* page 0, attribute 7 (normal) */ 2.667 ++ int $0x10 2.668 ++ ret 2.669 + 2.670 ++sread: .word 0 /* sectors read of current track */ 2.671 ++head: .word 0 /* current head */ 2.672 ++track: .word 0 /* current track */ 2.673 ++ 2.674 ++sectors: 2.675 ++ .word 0 2.676 ++ 2.677 ++dpseg: .word 0 2.678 ++dpoff: .word 0 2.679 ++ 2.680 ++disksizes: 2.681 ++ .byte 36,18,15,9,0 2.682 ++ 2.683 ++msg1: 2.684 ++ .ascii "Loading ROM image" 2.685 ++msg1end: 2.686 + 2.687 + .org 497 2.688 + setup_sects: