wok-current rev 13269
memtest: compression (-76K)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Aug 19 08:06:36 2012 +0200 (2012-08-19) |
parents | 4cba4433d0b7 |
children | 42fe21299957 |
files | memtest/receipt memtest/stuff/pack memtest/stuff/unlz4.S memtest/stuff/unpack.S qemacs-tiny/receipt |
line diff
1.1 --- a/memtest/receipt Fri Aug 17 15:30:50 2012 +0000 1.2 +++ b/memtest/receipt Sun Aug 19 08:06:36 2012 +0200 1.3 @@ -10,17 +10,24 @@ 1.4 WEB_SITE="http://www.memtest.org/" 1.5 WGET_URL="${WEB_SITE}download/$VERSION/$TARBALL" 1.6 1.7 +BUILD_DEPENDS="lz4" 1.8 + 1.9 # Rules to configure and make the package. 1.10 compile_rules() 1.11 { 1.12 cd $src 1.13 make 1.14 + cp $stuff/*.S $stuff/pack . 1.15 + cc -o unpack.o -Wa,-a=unpack.lst -c unpack.S 1.16 + objcopy -O binary unpack.o unpack.bin 1.17 + ./pack --build unpack.bin 1.18 + ./pack memtest.bin memtest.packed 1.19 } 1.20 1.21 1.22 # Rules to gen a SliTaz package suitable for Tazpkg. 1.23 genpkg_rules() 1.24 { 1.25 - mkdir -p $fs/boot 1.26 - cp $src/memtest.bin $fs/boot/memtest 1.27 + mkdir -p $fs/boot 1.28 + cp $src/memtest.packed $fs/boot/memtest 1.29 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/memtest/stuff/pack Sun Aug 19 08:06:36 2012 +0200 2.3 @@ -0,0 +1,41 @@ 2.4 +#!/bin/sh 2.5 +if [ "$1" == "--build" ]; then 2.6 + cat >> $0 <<EOM 2.7 +$(gzip -9 < ${2:-unpack.bin} | uuencode -m -) 2.8 +EOT 2.9 +EOM 2.10 + sed -i '/--build/,/^fi/d' $0 2.11 + exit 2.12 +fi 2.13 + 2.14 +store() 2.15 +{ 2.16 + n=$1 2.17 + for i in $(seq 1 $4); do 2.18 + printf '\\\\x%02X' $(($n & 255)) 2.19 + n=$(($n >> 8)) 2.20 + done | xargs echo -en | dd conv=notrunc bs=1 of=$2 seek=$3 2.21 +} 2.22 + 2.23 +setup="$(dd bs=1 count=1 if=$1 skip=497 | hexdump -e '"" 1/1 "%d" "\n"')" 2.24 +syssize="$(dd bs=1 count=2 if=$1 skip=500 | hexdump -e '"" 1/2 "%d" "\n"')" 2.25 + 2.26 +compress() 2.27 +{ 2.28 + lz4demo -c1 stdin stdout 2.29 + echo -en "\x00\x00\x00\x00" 2.30 +} 2.31 + 2.32 +main() 2.33 +{ 2.34 + dd if=$1 bs=512 count=1 >$2 2.35 + uudecode | gunzip >>$2 2.36 + dd if=$1 bs=512 count=$setup skip=1 | compress >>$2 2.37 + dd if=$1 bs=16 count=$syssize skip=$((32*(1+$setup))) | compress >>$2 2.38 + size=$(stat -c %s $2) 2.39 + store $((($size-512)/16)) $2 520 2 2.40 + store $((($size-2560)/16)) $2 500 2 2.41 + store 4 $2 497 1 2.42 +} 2.43 + 2.44 +main $1 $2 2>/dev/null <<EOT
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/memtest/stuff/unlz4.S Sun Aug 19 08:06:36 2012 +0200 3.3 @@ -0,0 +1,105 @@ 3.4 +/* 3.5 + * Lz4Decode: 3.6 +#ifndef FLAT32 3.7 + * input ds:si=inStream, es:di=outStream 3.8 + * output outStream[], ds:si, es:di 3.9 + .code16 3.10 +#else 3.11 + * input esi=inStream, edi=outStream 3.12 + * output outStream[], esi, edi 3.13 + .code32 3.14 +#endif 3.15 + */ 3.16 + 3.17 +#define ARCHIVE_MAGICNUMBER 0x184C2102 3.18 + 3.19 +lz4main: 3.20 + cld 3.21 + lodsl // get chunkSize 3.22 + cmpl $ARCHIVE_MAGICNUMBER, %eax 3.23 + je lz4main 3.24 + orl %eax, %eax // end of file ? 3.25 + je lz4quit 3.26 + xchgl %eax, %edx 3.27 +lz4chunk: // uncompress chunk 3.28 + lodsb // get token 3.29 + decl %edx 3.30 + movzbl %al, %ebx 3.31 + shrb $4, %al 3.32 + call lz4len // get literal length, %eax < 255 3.33 + incl %ecx 3.34 + stc 3.35 + sbbl %ecx, %edx 3.36 + pushf 3.37 + call lz4mov // copy literals 3.38 + popf 3.39 + js lz4main 3.40 + lodsw // get string address 3.41 +#ifndef FLAT32 3.42 + pushw %bx 3.43 + movw %di, %bx 3.44 + subl %eax, %ebx 3.45 + popw %ax 3.46 + call lz4len // get string length 3.47 + pushw %ds 3.48 + pushw %si 3.49 + pushw %es 3.50 + popw %ds 3.51 + movw $0xF, %si 3.52 + andw %bx, %si 3.53 + shrl $4, %ebx 3.54 + addl $4+1, %ecx 3.55 + movw %bx, %bp 3.56 + call lz4mov2 // copy string 3.57 + popw %si 3.58 + popw %ds 3.59 +#else 3.60 + negl %eax 3.61 + xchgl %eax, %ebx 3.62 + addl %edi, %ebx 3.63 + call lz4len // get string length 3.64 + pushl %esi 3.65 + xchgl %ebx, %esi 3.66 + call lz4mov // copy string 3.67 + popl %esi 3.68 +#endif 3.69 + jmp lz4chunk 3.70 + 3.71 +lz4len: // get length in %ecx 3.72 + andl $0xF, %eax 3.73 + movl %eax, %ecx 3.74 + cmpb $0xF, %al 3.75 + jne lz4quit 3.76 +lz4len2: 3.77 + lodsb 3.78 + decl %edx // remaining chunk size 3.79 + addl %eax, %ecx 3.80 + cmpb $0xFF, %al 3.81 + je lz4len2 3.82 +lz4quit: 3.83 + ret 3.84 + 3.85 +lz4movlp: 3.86 + movsb 3.87 +#ifndef FLAT32 3.88 + movw $0x800, %bp 3.89 + orw %di, %di 3.90 + jns lz4di 3.91 + subw $0x8000, %di 3.92 + movw %es, %ax 3.93 + addw %bp, %ax 3.94 + movw %ax, %es 3.95 +lz4di: 3.96 + orw %si, %si 3.97 + jns lz4si 3.98 + subw $0x8000, %si 3.99 +lz4mov2: 3.100 + movw %ds, %ax 3.101 + addw %bp, %ax 3.102 + movw %ax, %ds 3.103 +lz4si: 3.104 +#endif 3.105 +lz4mov: 3.106 + decl %ecx 3.107 + jnz lz4movlp 3.108 + ret
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/memtest/stuff/unpack.S Sun Aug 19 08:06:36 2012 +0200 4.3 @@ -0,0 +1,83 @@ 4.4 +#define TOP 0x8FF00 4.5 +#define SYSTEM 0x10000 4.6 +#define SETUP 4 4.7 + 4.8 + .text 4.9 + .code16 4.10 + .org 0 4.11 + 4.12 + .globl _start 4.13 +_start: 4.14 + pushf 4.15 + pushw %cs 4.16 + call getip 4.17 +getip: 4.18 + pushal 4.19 + movw $0, %bx // packed sizes 4.20 + movw %sp, %bp 4.21 +#define START_IP 32(%bp) 4.22 + pushw %ds 4.23 + pushw %es 4.24 + subw $getip-_start, START_IP 4.25 + 4.26 + cld 4.27 + pushw %cs 4.28 + popw %ds 4.29 + movw $TOP/16, %ax 4.30 + movw %ax, %es 4.31 + subw %bx, %ax // moved packed data 4.32 + movw START_IP, %si 4.33 + movw $moved-_start, %di 4.34 + addw %si, %di 4.35 + pushw %ds // save setup seg 4.36 + pushw %es // moved 4.37 + pushw %di // unpack code 4.38 + movw %si, %di 4.39 + movw $end-_start, %cx 4.40 + rep 4.41 + movsb // move upack code to $TOP 4.42 + pushw %si // data offset 4.43 + movw %ax, %es 4.44 + movw $SETUP*512, %cx 4.45 + subw $SETUP*32, %bx 4.46 + xorw %si, %si 4.47 + xorw %di, %di 4.48 + rep 4.49 + movsb // move header part 4.50 + pushw $SYSTEM/16 4.51 + popw %ds 4.52 +movlp: 4.53 + xorw %si, %si 4.54 + movw $8, %cx 4.55 + rep 4.56 + movsw // move system part 4.57 + subw $16, %di 4.58 + movw %ds, %cx 4.59 + incw %cx 4.60 + movw %cx, %ds 4.61 + movw %es, %cx 4.62 + incw %cx 4.63 + movw %cx, %es 4.64 + decw %bx 4.65 + jns movlp 4.66 + popw %si // data offset 4.67 + movw %ax, %ds 4.68 + retf 4.69 + 4.70 +moved: 4.71 + popw %es // restore setup seg 4.72 + movw START_IP, %di 4.73 + call unpack // unpack setup 4.74 + pushw $SYSTEM/16 4.75 + popw %es 4.76 + xorw %di,%di 4.77 + call unpack // unpack system 4.78 + popw %es 4.79 + popw %ds 4.80 + popal 4.81 + iret 4.82 + 4.83 +unpack: 4.84 +#include "unlz4.S" 4.85 + 4.86 +end:
5.1 --- a/qemacs-tiny/receipt Fri Aug 17 15:30:50 2012 +0000 5.2 +++ b/qemacs-tiny/receipt Sun Aug 19 08:06:36 2012 +0200 5.3 @@ -18,7 +18,7 @@ 5.4 compile_rules() 5.5 { 5.6 cd $src 5.7 - export CFLAGS="-Wno-error=unused-but-set-variable" 5.8 + export CFLAGS="-Wno-error=unused-but-set-variable -O2" 5.9 sed -i 's/\(define SAVED_DATA_SIZE \).*/\1 __builtin_offsetof(EditState,end_of_saved_data)/' qe.h 5.10 ./configure --prefix=/usr --enable-tiny && make qe 5.11 }