wok-current rev 15203
linux: update boot sector
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Sep 08 22:26:29 2013 +0000 (2013-09-08) |
parents | 223b265f40fd |
children | bb8582ed7012 |
files | linux/stuff/linux-header.u |
line diff
1.1 --- a/linux/stuff/linux-header.u Sat Sep 07 22:59:13 2013 +0000 1.2 +++ b/linux/stuff/linux-header.u Sun Sep 08 22:26:29 2013 +0000 1.3 @@ -1,6 +1,6 @@ 1.4 --- linux-3.2.14/arch/x86/boot/header.S 1.5 +++ linux-3.2.14/arch/x86/boot/header.S 1.6 -@@ -7,6 +7,7 @@ 1.7 +@@ -7,12 +7,14 @@ 1.8 * modified by more people than can be counted 1.9 * 1.10 * Rewritten as a common file by H. Peter Anvin (Apr 2007) 1.11 @@ -8,23 +8,97 @@ 1.12 * 1.13 * BIG FAT NOTE: We're in real mode using 64k segments. Therefore segment 1.14 * addresses must be multiplied by 16 to obtain their respective linear 1.15 -@@ -27,7 +28,12 @@ 1.16 + * addresses. To avoid confusion, linear addresses are written using leading 1.17 + * hex while segment addresses are written as segment:offset. 1.18 + * 1.19 ++ * Assume protocol 2.00+ (kernel >= 1.3.73) 1.20 + */ 1.21 + 1.22 + #include <asm/segment.h> 1.23 +@@ -27,6 +29,8 @@ 1.24 1.25 BOOTSEG = 0x07C0 /* original address of boot-sector */ 1.26 SYSSEG = 0x1000 /* historical load address >> 4 */ 1.27 +INITSEG = 0x9000 /* boot address >> 4 */ 1.28 +SETUPSEG = 0x9020 /* setup address >> 4 */ 1.29 1.30 -+#define LOADSEG 0x0800 1.31 -+#define LOADSZ (LOADSEG*0x10) 1.32 -+ 1.33 #ifndef SVGA_MODE 1.34 #define SVGA_MODE ASK_VGA 1.35 +@@ -40,53 +44,476 @@ 1.36 + #define ROOT_RDONLY 1 1.37 #endif 1.38 -@@ -45,48 +51,362 @@ 1.39 + 1.40 ++setup_sects = 497 1.41 ++syssize = 500 1.42 ++cmd_line_ptr = 0x228 1.43 ++ 1.44 ++/* some extra features */ 1.45 ++#define EXE_SUPPORT real mode dos .exe file support (no himem.sys) 1.46 ++#define CMDLINE kernel >= 2.4 1.47 ++#define OLDCMDLINE kernel < 2.4 1.48 ++#define HELP display version for ? argument 1.49 ++#define MORETHAN16M up to 4Gb RAM, not 16Mb 1.50 ++#define KEYBOARDLESS_SUPPORT scan floppy swap each 5 seconds 1.51 ++#define FULL_ZIMAGE Up to 512K system zImage 1.52 ++ 1.53 ++/* some limitations to reduce code size */ 1.54 ++//#define FLOPPY_1440K_ONLY 1.44M floppies support only 1.55 ++ 1.56 + .code16 1.57 + .section ".bstext", "ax" 1.58 1.59 .global bootsect_start 1.60 bootsect_start: 1.61 + 1.62 +- # Normalize the start address 1.63 +- ljmp $BOOTSEG, $start2 1.64 ++#ifdef EXE_SUPPORT 1.65 ++#define CODESZ 0x8000 1.66 ++#define EXEADRS(x) x+0xE0 1.67 ++stacktop = 0x9E00 # in 0x8000 .. 0xA000 1.68 ++ decw %bp // Magic number: MZ 1.69 ++ popw %dx 1.70 ++ jmp start // Bytes on last page of file 1.71 ++ .word (CODESZ+511)/512 // Pages in file 1.72 ++ .word 0 // Relocations 1.73 ++ .word 2 // Size of header in paragraphs 1.74 ++ .word 4096 // Minimum extra paragraphs needed 1.75 ++ .word -1 // Maximum extra paragraphs needed 1.76 ++ .word (CODESZ+15)/16 // Initial (relative) SS value 1.77 ++ .word stacktop // Initial SP value 1.78 ++ .word 0 // Checksum 1.79 ++ .word EXEADRS(comstart) // Initial IP value 1.80 ++ .word 0xFFF0 // Initial (relative) CS value 1.81 ++// .word 0x001C // File address of relocation table 1.82 ++// .word 0,0,0 // Overlay number 1.83 ++swap_floppy: 1.84 ++ .ascii "Next!" 1.85 ++ .byte 7,13,0 # swap detection needs 13, 0 1.86 ++#ifdef OLDCMDLINE 1.87 ++ .word 0xA33F 1.88 ++ .word stacktop 1.89 ++#endif 1.90 ++start: 1.91 ++ pushw %dx 1.92 ++#endif 1.93 + 1.94 +-start2: 1.95 +- movw %cs, %ax 1.96 +- movw %ax, %ds 1.97 +- movw %ax, %es 1.98 +- movw %ax, %ss 1.99 +- xorw %sp, %sp 1.100 +- sti 1.101 +- cld 1.102 ++#ifdef FULL_ZIMAGE 1.103 ++#define LOADSEG 0x8800 // Up to 512K zImage 1.104 ++#else 1.105 ++#define LOADSEG 0x8000 // 0x1000 multiple, up to 480K zImage 1.106 ++#endif 1.107 ++#define LOADSZ 0x8000 1.108 + 1.109 +- movw $bugger_off_msg, %si 1.110 ++bootsect_start: 1.111 + cld # assume nothing 1.112 +stacktop = 0x9E00 # in 0x8000 .. 0xA000 1.113 +zeroed = 48+12 # gdt + zeroed registers 1.114 @@ -35,9 +109,7 @@ 1.115 + pushw $INITSEG 1.116 + popw %ss # %ss contain INITSEG 1.117 + movw %di, %sp # put stack at INITSEG:stacktop-... 1.118 - 1.119 -- # Normalize the start address 1.120 -- ljmp $BOOTSEG, $start2 1.121 ++ 1.122 +# Many BIOS's default disk parameter tables will not recognize 1.123 +# multi-sector reads beyond the maximum sector number specified 1.124 +# in the default diskette parameter tables - this may mean 7 1.125 @@ -49,35 +121,23 @@ 1.126 +# count to 36 - the most we will encounter on an ED 2.88. 1.127 +# 1.128 +# High doesn't hurt. Low does. Let's use the max: 63 1.129 - 1.130 --start2: 1.131 -- movw %cs, %ax 1.132 -- movw %ax, %ds 1.133 -- movw %ax, %es 1.134 -- movw %ax, %ss 1.135 -- xorw %sp, %sp 1.136 -- sti 1.137 -- cld 1.138 ++ 1.139 + pushw %ss 1.140 + popw %es # %es = %ss = INITSEG 1.141 + xorw %ax, %ax # %ax = 0 1.142 ++#ifdef EXE_SUPPORT 1.143 ++ cwd # floppy = head = 0 1.144 ++#endif 1.145 + movw $zeroed/2, %cx # clear gdt + offset, %ds, limits 1.146 + rep # don't worry about cld 1.147 + stosw # already done above 1.148 + popw %bx # offset = 0 1.149 + popw %ds # %ds = 0 1.150 + popw %fs # %fs = 0 1.151 - 1.152 -- movw $bugger_off_msg, %si 1.153 ++ 1.154 + movb setup_sects+0x7C00, %al # read bootsector + setup (%ds = 0) 1.155 + incw %ax 1.156 - 1.157 --msg_loop: 1.158 -- lodsb 1.159 -- andb %al, %al 1.160 -- jz bs_die 1.161 -- movb $0xe, %ah 1.162 -- movw $7, %bx 1.163 ++ 1.164 + ldsw 0x78(%bx), %si # %ds:%bx+0x78 is parameter table address 1.165 + pushw %es 1.166 + pushw %di 1.167 @@ -94,131 +154,94 @@ 1.168 + popw %ax # limits = 0 1.169 + incw %cx # cylinder 0, sector 1, clear Z 1.170 + call read_first_sectors # read setup 1.171 -+ 1.172 ++loadsys: 1.173 + movw $0x200,%si 1.174 -+#define kernel_version 0xE 1.175 +type_of_loader = 0x10 1.176 +loadflags = 0x11 1.177 +heap_end_ptr = 0x24 1.178 + orw $0x8020, type_of_loader(%si) # loader type = 0x20 = bootsect-loader 1.179 + movb $(stacktop-0x300)/256, heap_end_ptr+1(%si) 1.180 -+ addw kernel_version(%si),%si # starting protocol 2.00, Kernel 1.3.73 1.181 -+ call puts # show which kernel we are loading 1.182 ++ call puts_version # show which kernel we are loading 1.183 + 1.184 -+# The cmdline can be entered and modifed at boot time. 1.185 -+# Only characters before the cursor are passed to the kernel. 1.186 -+ popw %bx # clear %bx 1.187 -+ orw cmd_line_ptr, %bx 1.188 -+ jz nocmdline 1.189 -+ pushw %bx 1.190 -+ incw %di 1.191 -+ call read_sectors 1.192 -+ popw %si 1.193 -+ call puts 1.194 -+cmdlp: 1.195 -+ movb $0x20, %al # clear end of line 1.196 -+ int $0x10 # with Space 1.197 -+ movb $8, %al # and BackSpace 1.198 - int $0x10 1.199 -- jmp msg_loop 1.200 -+ decw %si 1.201 -+cmdget: 1.202 -+ call wait4key 1.203 -+ cmpb $8, %al # BackSpace ? 1.204 -+ je cmdbs 1.205 -+ movb %al, (%si) # store char 1.206 -+ lodsw # %si += 2 1.207 -+cmdbs: 1.208 -+ cmpw %si,cmd_line_ptr 1.209 -+ je cmdget 1.210 -+ call putc # set %ah and %bx 1.211 -+ cmpb $10, %al # Enter ? 1.212 -+ jne cmdlp 1.213 -+ movb %bh,-2(%si) # set end of string and remove CR 1.214 -+endcmdline: 1.215 -+nocmdline: 1.216 - 1.217 --bs_die: 1.218 -- # Allow the user to press a key, then reboot 1.219 -- xorw %ax, %ax 1.220 -- int $0x16 1.221 -- int $0x19 1.222 +# This routine loads the system at address LOADSEG, making sure 1.223 +# no 64kB boundaries are crossed. We try to load it as fast as 1.224 +# possible, loading whole tracks whenever we can. 1.225 - 1.226 -- # int 0x19 should never return. In case it does anyway, 1.227 -- # invoke the BIOS reset code... 1.228 -- ljmp $0xf000,$0xfff0 1.229 ++ 1.230 +ramdisk_image = 0x0218 1.231 +ramdisk_size = 0x021C 1.232 +bootsect_src_limit = 16 1.233 +bootsect_dst_limit = 24 1.234 +bootsect_src_base = 18 1.235 -+bootsect_dst_base = 26 1.236 ++bootsect_dst_base = 26 # bits 0..23 1.237 ++bootsect_dst_base_hi = 31 # bits 24..31 1.238 + popw %bx # clear %bx 1.239 + movw %sp, %si # for bootsect_gdt 1.240 +init_gdt: 1.241 + decw bootsect_src_limit(%bx,%si) # max 64Kb 1.242 -+ movb $0x93, bootsect_src_base+3(%bx,%si) 1.243 ++#if LOADSEG % 0x1000 == 0 1.244 ++ movw $0x9300+(LOADSEG/0x1000), bootsect_src_base+2(%bx,%si) 1.245 ++#else 1.246 ++ movl $0x93000000+(LOADSEG*0x10), bootsect_src_base(%bx,%si) 1.247 ++#endif 1.248 + xorb $bootsect_dst_limit-bootsect_src_limit, %bl 1.249 + jne init_gdt 1.250 -+ movw $syssize, %bx 1.251 +code32_start = 0x214 1.252 ++#ifdef MORETHAN16M 1.253 ++ movb code32_start+3, %al # destination = 0x00100000 or 0x00010000 1.254 ++ movb %al, bootsect_dst_base_hi(%si) # load high (> 16M) ? 1.255 ++#endif 1.256 + movw code32_start+1, %ax # destination = 0x00100000 or 0x00010000 1.257 -+ movb $5, %cl 1.258 -+initrdlp: 1.259 -+ movl (%bx),%ebx 1.260 ++ movl syssize, %ebx 1.261 + decl %ebx 1.262 -+ shrl %cl, %ebx 1.263 -+ incw %bx 1.264 ++ shrl $5, %ebx 1.265 ++ incl %ebx 1.266 +syslp: 1.267 -+ pushw $LOADSEG 1.268 -+ popw %es 1.269 -+ movw $LOADSZ/256,%di # size in pages 1.270 -+ movw %di, bootsect_src_base+1(%si) # assume LOADSZ == LOADSEG*16 1.271 + movw %ax, bootsect_dst_base+1(%si) 1.272 -+ addw %di, %ax # next dest 1.273 -+ shrw $1, %di # pages to sectors 1.274 -+ subw %di, %bx # max 32M > int 15 limit 1.275 ++ movw $LOADSZ/512, %di # size in sectors 1.276 ++ subl $LOADSZ/512, %ebx 1.277 + pushf 1.278 + jnc not_last 1.279 + addw %bx, %di 1.280 +not_last: 1.281 + pushw %ax 1.282 -+ pushw %di 1.283 + pushw %si 1.284 + pushw %bx 1.285 + xorw %bx,%bx 1.286 ++ pushw $LOADSEG 1.287 ++ popw %es 1.288 ++patchcall: 1.289 + call read_sectors # update %bp 1.290 + popw %bx 1.291 + popw %si 1.292 -+ popw %cx # sectors to word count: 1.293 -+ xchgb %cl, %ch # %cx <<= 8 1.294 ++ movw $LOADSZ/2, %cx # word count 1.295 + movb $0x87, %ah 1.296 + pushw %ss 1.297 + popw %es # restore es 1.298 -+ int $0x15 # max 16M 1.299 ++ int $0x15 # max 16M, maybe more... 1.300 + popw %ax 1.301 ++ addw $LOADSZ/256, %ax # next dest 1.302 ++#ifdef MORETHAN16M 1.303 ++ adcb %cl, bootsect_dst_base_hi(%si) # breaks 16M limit ? 1.304 ++#endif 1.305 + popf 1.306 + ja syslp 1.307 -+ movw ramdisk_image+1,%ax 1.308 -+ movw $ramdisk_size,%bx 1.309 -+ movb $9, %cl 1.310 -+ cmpw %ax, bootsect_dst_base+1(%si) 1.311 -+ jb initrdlp 1.312 1.313 -- .section ".bsdata", "a" 1.314 --bugger_off_msg: 1.315 -- .ascii "Direct booting from floppy is no longer supported.\r\n" 1.316 -- .ascii "Please use a boot loader program instead.\r\n" 1.317 -- .ascii "\n" 1.318 -- .ascii "Remove disk and press any key to reboot . . .\r\n" 1.319 -- .byte 0 1.320 +-msg_loop: 1.321 +- lodsb 1.322 +- andb %al, %al 1.323 +- jz bs_die 1.324 +- movb $0xe, %ah 1.325 +- movw $7, %bx 1.326 +- int $0x10 1.327 +- jmp msg_loop 1.328 +- 1.329 +-bs_die: 1.330 +- # Allow the user to press a key, then reboot 1.331 +- xorw %ax, %ax 1.332 +# This procedure turns off the floppy drive motor, so 1.333 +# that we enter the kernel in a known state, and 1.334 +# don't have to worry about it later. 1.335 - 1.336 ++ 1.337 +kill_motor: 1.338 + xchgw %ax, %di # reset FDC (%di < 128) 1.339 + int $0x13 1.340 @@ -240,15 +263,9 @@ 1.341 +#define FLOPPY_HEADS 2 /* 2 heads minimum */ 1.342 +#define FLOPPY_SECTORS 18 /* 18 sectors minimum */ 1.343 + 1.344 -+print_loop: 1.345 -+ movb $0x6 + 'A' - 1, %al 1.346 -+ subb %cl, %al 1.347 -+ movw $regs, %si # caller %si is saved 1.348 -+ call putcs # putc(%al) + puts(%si) 1.349 -+# it will print out all of the registers. 1.350 -+ popw %bp # load word into %si 1.351 -+ jmp print_all # print %bp (status) 1.352 +check_limits: 1.353 ++#ifndef FLOPPY_1440K_ONLY 1.354 ++ popw %dx 1.355 + cmpb $FLOPPY_SECTORS+1, %cl # 18 sectors minimum 1.356 + jb check_head 1.357 + cmpb %al, %cl # max sector known ? 1.358 @@ -259,45 +276,28 @@ 1.359 + cmpb %ah, %dh # max head known ? 1.360 + ja next_cylinder # no -> store it 1.361 +check_cylinder: 1.362 ++#endif 1.363 + pushaw 1.364 -+ cmpw $0x600,%bp # disk changed ? 1.365 -+ je reset_floppy 1.366 -+ pushw %es # print %es (named EX) 1.367 -+ pushw %dx # print %dx 1.368 -+ pushw %cx # print %cx 1.369 -+ pushw %bx # print %bx 1.370 -+ xchgw %ax, %si 1.371 -+ movb $2,%ah 1.372 -+ pushw %ax # print %ax 1.373 -+ movb $6,%cl 1.374 -+print_all: 1.375 -+ movb $4, %ch # 4 hex digits 1.376 -+print_digit: 1.377 -+ rolw $4, %bp # rotate to use low 4 bits 1.378 -+ movb $0x0f, %al 1.379 -+ andw %bp, %ax # %al = mask for nybble 1.380 -+ addb $0x90, %al # convert %al to ascii hex 1.381 -+ daa # in only four instructions! 1.382 -+ adcb $0x40, %al 1.383 -+ daa 1.384 -+ call putc # set %ah and %bx 1.385 -+ decb %ch 1.386 -+ jnz print_digit 1.387 -+ movb $0x20, %al # SPACE 1.388 -+ int $0x10 1.389 -+ loop print_loop 1.390 -+ call wait 1.391 ++#ifndef FLOPPY_1440K_ONLY 1.392 + cbw # %ah = 0 1.393 -+reset_floppy: 1.394 ++#endif 1.395 + int $0x13 # reset controler 1.396 ++ stc 1.397 ++ call putcdot # print '-' 1.398 ++read_sectorslp: 1.399 + popaw 1.400 -+read_sectorslp: 1.401 ++bdendlp: 1.402 + pushw %dx # some bios break dx... 1.403 ++#ifndef FLOPPY_1440K_ONLY 1.404 + pushw %ax # limits 1.405 + subb %cl, %al # sectors remaining in track 1.406 + ja tolastsect 1.407 + movb $1, %al # 1 sector mini 1.408 +tolastsect: 1.409 ++#else 1.410 ++ mov $FLOPPY_SECTORS+1, %al 1.411 ++ subb %cl, %al # sectors remaining in track 1.412 ++#endif 1.413 + cbw 1.414 + cmpw %di, %ax 1.415 + jb more1trk 1.416 @@ -306,46 +306,69 @@ 1.417 + pushw %ax # save context 1.418 + movb $2, %ah # cmd: read chs 1.419 + int $0x13 1.420 -+ xchgw %ax, %bp # status 1.421 -+ popw %si # save %ax 1.422 ++#ifndef FLOPPY_1440K_ONLY 1.423 ++ popw %dx # save %ax 1.424 + popw %ax # limits 1.425 ++#else 1.426 ++ popw %ax # restore context 1.427 + popw %dx 1.428 ++#endif 1.429 + jc check_limits 1.430 ++#ifndef FLOPPY_1440K_ONLY 1.431 + xchgw %ax, %bp 1.432 -+update_regs: 1.433 -+ incw %cx # next sector 1.434 ++ addw %dx,%cx # next sector 1.435 + movw %cx, %gs 1.436 -+ addb $2,%bh # next location 1.437 -+ decw %di # update sector counter 1.438 ++ addb %dl,%bh 1.439 ++ addb %dl,%bh # next location 1.440 ++ subw %dx,%di # update sector counter 1.441 ++ popw %dx 1.442 + jz putcdot 1.443 -+ decw %si 1.444 -+ jnz update_regs 1.445 ++#else 1.446 ++ addw %ax,%cx # next sector 1.447 ++ movw %cx, %gs 1.448 ++ addb %al,%bh 1.449 ++ addb %al,%bh # next location 1.450 ++ subw %ax,%di # update sector counter 1.451 ++ jz putcdot 1.452 ++#endif 1.453 +read_sectors: 1.454 + movw %gs, %cx 1.455 ++#ifndef FLOPPY_1440K_ONLY 1.456 +# al is last sector+1 1.457 +# ah is last cylinder+1 1.458 + xchgw %ax, %bp 1.459 ++#endif 1.460 ++#ifndef FLOPPY_1440K_ONLY 1.461 + cmpb %al,%cl # reach sector limit ? 1.462 + jne bdendlp 1.463 +next_head: 1.464 + movb %cl,%al 1.465 ++#else 1.466 ++ cmpb $FLOPPY_SECTORS+1,%cl # reach sector limit ? 1.467 ++ jne bdendlp 1.468 ++#endif 1.469 + incb %dh # next head 1.470 + movb $1,%cl # first sector 1.471 ++#ifndef FLOPPY_1440K_ONLY 1.472 + cmpb %ah, %dh # reach head limit ? 1.473 + jne bdendlp 1.474 +next_cylinder: 1.475 + movb %dh,%ah 1.476 ++#else 1.477 ++ cmpb %cl,%dh # reach head limit ? 1.478 ++ je bdendlp 1.479 ++#endif 1.480 +# NOTE : support 256 cylinders max 1.481 + incb %ch # next cylinder 1.482 -+ cmpb $FLOPPY_CYLINDERS, %ch # reach cylinder limit ? 1.483 +read_first_sectors: 1.484 ++ cmpb $FLOPPY_CYLINDERS,%ch # reach cylinder limit ? 1.485 + movb $0,%dh # first head 1.486 + jne bdendlp 1.487 +next_floppy: 1.488 + movb $0,%ch # first cylinder 1.489 + pushaw 1.490 + movw $swap_floppy,%si 1.491 -+ incb 12(%si) 1.492 ++#ifdef KEYBOARDLESS_SUPPORT 1.493 + pushw %bx 1.494 + call puts 1.495 + popw %bx 1.496 @@ -362,17 +385,46 @@ 1.497 + cmpb -2(%si), %ah # 0D then 00 1.498 + jne waitfloppy # no => try again 1.499 + incw %si 1.500 -+ orb %ah,%ah # was 00 ? 1.501 ++ decw %ax # was 0001 ? 1.502 + jne waitfloppy 1.503 +waitfloppydone: 1.504 -+ popaw 1.505 -+bdendlp: 1.506 ++#else 1.507 ++ call puts 1.508 ++ cbw # %ah = 0, get keyboard character 1.509 + int $0x16 1.510 +- int $0x19 1.511 ++#endif 1.512 + jmp read_sectorslp 1.513 + 1.514 ++#ifdef EXE_SUPPORT 1.515 ++read_sectors_dos: 1.516 ++ pushw %es 1.517 ++ popw %ds 1.518 ++ movb $0x3F, %ah // read 1.519 ++ cwd // write to %ds:%dx, not %es:%bx 1.520 ++ movw %di, %cx 1.521 ++ shlw $9, %cx // byte count 1.522 ++ movw %bp, %bx 1.523 ++ int $0x21 1.524 ++ pushw %ss 1.525 ++ popw %ds 1.526 ++#endif 1.527 + 1.528 +- # int 0x19 should never return. In case it does anyway, 1.529 +- # invoke the BIOS reset code... 1.530 +- ljmp $0xf000,$0xfff0 1.531 +- 1.532 +- .section ".bsdata", "a" 1.533 +-bugger_off_msg: 1.534 +- .ascii "Direct booting from floppy is no longer supported.\r\n" 1.535 +- .ascii "Please use a boot loader program instead.\r\n" 1.536 +- .ascii "\n" 1.537 +- .ascii "Remove disk and press any key to reboot . . .\r\n" 1.538 +- .byte 0 1.539 +putcdot: 1.540 -+ movb $0x2e+3, %al # loading... message 2e = . 1.541 ++ movb $'.'+3, %al // . = success, - = failure 1.542 +putclf: 1.543 -+ subb $3, %al 1.544 ++ sbbb $3, %al 1.545 +putc: 1.546 + movb $0xe, %ah 1.547 + movw $7, %bx # one dot each 64k 1.548 @@ -381,25 +433,16 @@ 1.549 + je putclf 1.550 + ret 1.551 + 1.552 -+puts: 1.553 -+ movb $0xd, %al # CR 1.554 -+putcs: 1.555 -+ call putc 1.556 -+ lodsb 1.557 -+ orb %al,%al # end of string is \0 1.558 -+ jnz putcs 1.559 -+ ret 1.560 -+ 1.561 ++#ifdef KEYBOARDLESS_SUPPORT 1.562 +clock = 0x46C 1.563 +wait: 1.564 +wait4key: 1.565 + movw $clock, %di 1.566 +#define DELAY 5 1.567 -+ movb $(DELAY*182)/10,%cl 1.568 -+ addb %fs:(%di),%cl 1.569 ++ movb $257-(DELAY*182)/10, %fs:(%di) 1.570 +waitkbd: 1.571 + movw $0x10D, %ax # test keyboard, timeout => CR 1.572 -+ cmpb %fs:(%di),%cl 1.573 ++ cmpb %fs:(%di),%ah 1.574 + je waitdone 1.575 + int $0x16 1.576 + jz waitkbd 1.577 @@ -409,11 +452,87 @@ 1.578 + incw %di # clear Z 1.579 +waitdone: 1.580 + ret 1.581 -+ 1.582 -+regs: .asciz "X:" 1.583 -+ 1.584 -+swap_floppy: .ascii "Insert disk 1" 1.585 -+ .byte 7,13,0 1.586 ++#endif 1.587 + 1.588 ++#ifdef EXE_SUPPORT 1.589 ++comstart: 1.590 ++ cld # assume nothing 1.591 ++ pushw $INITSEG 1.592 ++ popw %es 1.593 ++ pushw %es 1.594 ++ popw %ss 1.595 ++#ifdef CMDLINE 1.596 ++ movw %sp, %di 1.597 ++ movw $0x80, %si 1.598 ++ lodsb 1.599 ++ cbw 1.600 ++ xchgw %ax, %cx 1.601 ++ rep 1.602 ++ movsb 1.603 ++ movb $(48+2)/2, %cl 1.604 ++ xorw %bx, %bx 1.605 ++clearstacklp: 1.606 ++ pushw %bx 1.607 ++ loop clearstacklp 1.608 ++# ifdef HELP 1.609 ++ cmpb $'?', -1(%si) 1.610 ++ movw $EXEADRS(0x200), %si 1.611 ++ movw setup_sects-0x200(%si), %di // bits 0..6 1.612 ++ je puts_version 1.613 ++ smsww %ax 1.614 ++ andb $1, %al 1.615 ++ jne puts_version // real mode only... 1.616 ++# endif 1.617 ++#else 1.618 ++ movw $(48+2)/2, %cx 1.619 ++ xorw %bx, %bx 1.620 ++clearstacklp: 1.621 ++ pushw %bx 1.622 ++ loop clearstacklp 1.623 ++#endif 1.624 ++#if !defined(CMDLINE) || !defined(HELP) 1.625 ++ movw EXEADRS(setup_sects), %di // bits 0..6 1.626 ++ movb $0, %al // access = RO 1.627 ++#endif 1.628 ++ movw 0x2C(%bx), %ds // DOS 3.0+ 1.629 ++loop1: 1.630 ++ incw %bx 1.631 ++ cmpw %cx, (%bx) 1.632 ++ jne loop1 1.633 ++ leaw 4(%bx), %dx // %ds:%dx filename 1.634 ++ movb $0x3D, %ah // open, access = RO 1.635 ++ int $0x21 1.636 ++ jc dosexit 1.637 ++ xchgw %ax, %bp // fd 1.638 ++ incw %di 1.639 ++ call read_sectors_dos // update %ds 1.640 ++ addb $read_sectors_dos-read_sectors, patchcall+1 1.641 ++#ifdef CMDLINE 1.642 ++# ifdef OLDCMDLINE 1.643 ++ movw $0x202, %bx 1.644 ++ cmpw %bx, 0x206-0x202(%bx) 1.645 ++ jb oldcmdline 1.646 ++ movw $INITSEG/16+stacktop/256, cmd_line_ptr+1-0x202(%bx) 1.647 ++oldcmdline: 1.648 ++# else 1.649 ++ movw $INITSEG/16+stacktop/256, cmd_line_ptr+1 1.650 ++# endif 1.651 ++#endif 1.652 ++ ljmp $INITSEG, $loadsys 1.653 ++#endif 1.654 ++ 1.655 ++#define kernel_version 0xE 1.656 ++puts_version: 1.657 ++ addw kernel_version(%si),%si # starting protocol 2.00, Kernel 1.3.73 1.658 ++puts: 1.659 ++ movb $0xd, %al # CR 1.660 ++putcs: 1.661 ++ call putc 1.662 ++ lodsb 1.663 ++ cmpb $0, %al # end of string is any byte <= 0 1.664 ++ jg putcs 1.665 ++dosexit: 1.666 ++ ret 1.667 1.668 # Kernel attributes; used by setup. This is part 1 of the 1.669 # header, from the old boot sector.