wok-current rev 17223
memtest: fix bootloader EXE case
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Oct 14 22:40:53 2014 +0200 (2014-10-14) |
parents | 44cb6517e19a |
children | b5bb376d98ad |
files | memtest/receipt memtest/stuff/bootloader.S memtest/stuff/pack |
line diff
1.1 --- a/memtest/receipt Tue Oct 14 20:07:21 2014 +0300 1.2 +++ b/memtest/receipt Tue Oct 14 22:40:53 2014 +0200 1.3 @@ -24,6 +24,7 @@ 1.4 cc -o $i.o -Wa,-a=$i.lst -c $i.S 1.5 objcopy -O binary $i.o $i.bin 1.6 done 1.7 + sed -i "s/VERSION/$VERSION/" pack 1.8 ./pack --build bootloader.bin unpack.bin 1.9 ./pack memtest.bin memtest.packed 1.10 sed -i -e 's/SERIAL_CONSOLE_DEFAULT 0/SERIAL_CONSOLE_DEFAULT 1/' \
2.1 --- a/memtest/stuff/bootloader.S Tue Oct 14 20:07:21 2014 +0300 2.2 +++ b/memtest/stuff/bootloader.S Tue Oct 14 22:40:53 2014 +0200 2.3 @@ -2,9 +2,6 @@ 2.4 INITSEG = 0x9000 2.5 SETUPSEG = 0x9020 2.6 2.7 -setup_sects = 497 2.8 -syssize = 500 2.9 - 2.10 .text 2.11 .code16 2.12 .org 0 2.13 @@ -82,7 +79,6 @@ 2.14 #ifdef CHECK_REALMODE 2.15 #define PUTS 2.16 movw $EXEADRS(realmode_expected), %si 2.17 - pushfw // save flags 2.18 // bits 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 2.19 // flags 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF 2.20 //movb $0x10, %ah // DF = IF = TF = 0 2.21 @@ -90,18 +86,23 @@ 2.22 popfw // < 286 : flags[12..15] are forced 1 2.23 pushfw // = 286 : flags[12..15] are forced 0 2.24 popw %dx // > 286 : only flags[15] is forced 0 2.25 - popfw // restore flags 2.26 cmpb %ah, %dh // test Fx and 0x cases 2.27 jsputs: 2.28 js puts // S= not 386+ 2.29 smsww %dx 2.30 shrw $1, %dx 2.31 jc puts 2.32 + //movw syssize-realmode_expected(%si), %bp 2.33 + .byte 0x8B, 0x6C, syssize-realmode_expected 2.34 + //movb setup_sects-realmode_expected(%si), %ch 2.35 + .byte 0x8A, 0x6C, setup_sects-realmode_expected 2.36 +#else 2.37 + movw EXEADRS(syssize), %bp 2.38 + movb EXEADRS(setup_sects), %ch 2.39 #endif 2.40 + movb $(512-(end_header-_start))/2, %cl 2.41 movw $0x100, %si 2.42 movw $end_header, %di 2.43 - movb EXEADRS(setup_sects), %ch 2.44 - movb $(512-(end_header-_start))/2, %cl 2.45 rep 2.46 movsw 2.47 ljmp $INITSEG, $movesys 2.48 @@ -174,8 +175,9 @@ 2.49 2.50 popw %bx # clear %bx 2.51 movw syssize, %di 2.52 - addw $(512/16)-1, %di 2.53 + decw %di 2.54 shrw $9-4, %di 2.55 + incw %di 2.56 movw $SYSSEG, %cx 2.57 call read_sectorsCX 2.58 2.59 @@ -205,29 +207,27 @@ 2.60 int $0x20 // dos exit 2.61 #endif 2.62 #ifdef EXE_SUPPORT 2.63 -movesys: 2.64 +movesys: // %ax = SYSSEG 2.65 pushw %es 2.66 popw %ss 2.67 - movw EXEADRS(syssize), %bp // %ds untouched 2.68 movw %ds, %bx 2.69 - cwd 2.70 - incw %dx 2.71 - cmpw %ax, %bx 2.72 + subw %ax, %bx 2.73 jnc forward 2.74 - negw %dx 2.75 addw %bp, %ax 2.76 - addw %bp, %bx 2.77 forward: 2.78 movw %ax, %es 2.79 - movw %bx, %ds 2.80 + movw %ax, %dx 2.81 + addw %bx, %dx 2.82 + movw %dx, %ds 2.83 + sbbw %dx, %dx // %dx = 0 : -1 2.84 + cmc // C = 1 : 0 2.85 + adcw %dx, %ax 2.86 xorw %di, %di 2.87 movb $8, %cl 2.88 pushw %si 2.89 rep 2.90 movsw 2.91 popw %si 2.92 - addw %dx, %ax 2.93 - addw %dx, %bx 2.94 decw %bp 2.95 jns forward 2.96 #ifndef NO_CURSOR_DEFINITION 2.97 @@ -380,15 +380,23 @@ 2.98 bdendlp: 2.99 jmp read_sectorslp 2.100 2.101 -#ifdef CHECK_REALMODE 2.102 -realmode_expected: 2.103 - .ascii "386+ real mode only." 2.104 - .byte 13,10,0 2.105 -#endif 2.106 #ifdef HELP 2.107 helpmsg: 2.108 .ascii "No help available." 2.109 .byte 13,10 2.110 .byte 0 2.111 #endif 2.112 +#ifdef CHECK_REALMODE 2.113 + .org 475 2.114 +realmode_expected: 2.115 +helpend: 2.116 + .ascii "386 real mode only." 2.117 + .byte 13,10,0 2.118 +#endif 2.119 .org 497 2.120 +setup_sects: 2.121 + .byte 0 2.122 + .org 500 2.123 +syssize: 2.124 + .word 0 2.125 +
3.1 --- a/memtest/stuff/pack Tue Oct 14 20:07:21 2014 +0300 3.2 +++ b/memtest/stuff/pack Tue Oct 14 22:40:53 2014 +0200 3.3 @@ -1,10 +1,6 @@ 3.4 #!/bin/sh 3.5 if [ "$1" == "--build" ]; then 3.6 set -- ${2:-bootloader.bin} ${3:-unpack.bin} 3.7 - cat >> $0 <<EOM 3.8 -$(dd if=$1 bs=512 count=1 conv=sync | cat - $2 | gzip -9 | uuencode -m -) 3.9 -EOT 3.10 -EOM 3.11 x=$(grep -s packed_syssize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 3.12 [ -n "$x" ] && sed -i "s/XXXP/$((513+0x$x))/" $0 || sed -i s="/XXXP$/d" $0 3.13 x=$(grep -s original_syssize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 3.14 @@ -12,8 +8,13 @@ 3.15 x=$(grep -s original_setupsize ${2/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/') 3.16 [ -n "$x" ] && sed -i "s/XXXS/$((516+0x$x))/" $0 || sed -i s="/XXXS$/d" $0 3.17 helpmsg=$(sed '/helpmsg:/!d{n;s/ [0-9]* \([^ ]*\).*/\1/}' ${1/.bin/.lst} | sed '$!d') 3.18 + helpend=$(sed '/helpend:/!d{n;s/ [0-9]* \([^ ]*\).*/\1/}' ${1/.bin/.lst} | sed '$!d') 3.19 sed -i "s/YYY/$((0x$helpmsg))/" $0 3.20 - sed -i "s/ZZZ/$((496-0x$helpmsg))/" $0 3.21 + sed -i "s/ZZZ/$((0x$helpend-0x$helpmsg))/" $0 3.22 + cat >> $0 <<EOM 3.23 +$(dd if=$1 bs=512 count=1 conv=sync | cat - $2 | gzip -9 | uuencode -m -) 3.24 +EOT 3.25 +EOM 3.26 sed -i '/--build/,/^fi/d' $0 3.27 exit 3.28 fi 3.29 @@ -54,8 +55,8 @@ 3.30 } 3.31 3.32 HELP="$(unix2dos <<EOT 3.33 -Memtest86+ is an endless advanced memory diagnostic tool released under the 3.34 -terms of the Gnu Public License (GPL). 3.35 +Memtest86+ VERSION is an endless advanced memory diagnostic tool released under 3.36 +the terms of the free Gnu Public License (GPL). 3.37 3.38 EOT 3.39 )"