wok-6.x rev 19206
linld/tobzimage: add elks support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jun 12 15:34:09 2016 +0200 (2016-06-12) |
parents | 55f1b37cebe1 |
children | 60776d829b2a |
files | linld/stuff/tobzimage linld/stuff/tobzimage.S |
line diff
1.1 --- a/linld/stuff/tobzimage Sun Jun 12 09:23:56 2016 +0200 1.2 +++ b/linld/stuff/tobzimage Sun Jun 12 15:34:09 2016 +0200 1.3 @@ -1,6 +1,11 @@ 1.4 #!/bin/sh 1.5 1.6 if [ "$1" == "--build" ]; then #install-begin 1.7 + for i in elks linux001 ; do 1.8 + i=${i}_patch 1.9 + n=$(sed "/$i\$/!d;s/.*text:0*\\([^ ]*\\).*/\\1/" tobzimage.lst) 1.10 + [ -n "$n" ] && sed -i "s/$i/$((0x200 + 0x$n))/" $0 1.11 + done 1.12 cat tobzimage.bin | gzip -9 | uuencode -m - | sed \ 1.13 -e '/^tobzimage$/r/dev/stdin' -e '/^tobzimage$/d' \ 1.14 -e '/install-begin$/,/install-end$/d' -i $0 1.15 @@ -35,6 +40,8 @@ 1.16 create_bzImage() 1.17 { 1.18 ddq bs=512 count=1 of=$1 1.19 + [ " $(get 0x1E6 $1 4)" == " 1397443653" ] && iselks=1 1.20 + [ " $(get 0x3F $1 2)" == " 15080" ] && islinux001=1 && cp $1 $1$$ 1.21 # from http://hg.slitaz.org/wok/file/7184ec55b1aa/linux/stuff/linux-header.u 1.22 uudecode <<EOT | ddq of=$1 conv=notrunc 1.23 begin-base64 644 - 1.24 @@ -56,17 +63,28 @@ 1.25 uudecode <<EOT | gunzip >> $1 1.26 tobzimage 1.27 EOT 1.28 - if [ "$2" ]; then 1.29 - s="$2" 1.30 - [ -s "$2" ] && s="$(cat "$2")" 1.31 - echo -e "\n$2" | tr '\n' '\r' | cat - /dev/zero | \ 1.32 - dd conv=notrunc of=$1 bs=1 seek=768 count=255 1.33 - fi 1.34 + s="$2" 1.35 + [ -s "$s" ] && s="$(cat "$s")" 1.36 + [ -z "$s" ] && s="$(basename "$1")" 1.37 + echo -e "\n$s" | tr '\n' '\r' | cat - /dev/zero | \ 1.38 + ddq conv=notrunc of=$1 bs=1 seek=768 count=255 1.39 setupsz=$(get 497 $1 1) 1.40 [ $setupsz -eq 0 ] && setupsz=4 1.41 - ddq bs=512 count=$setupsz >> $1 1.42 + if [ "$islinux001" == "1" ]; then 1.43 + cat $1$$ /dev/zero | ddq bs=512 count=$setupsz >> $1 1.44 + rm -f $1$$ 1.45 + else 1.46 + ddq bs=512 count=$setupsz >> $1 1.47 + fi 1.48 store 8 497 $(($setupsz+1)) $1 1.49 + syssz=$(get 500 $1 2) 1.50 + [ $syssz -eq 0 ] && syssz=$((($filesz+15-512)/16-($setupsz*32))) 1.51 + [ "$islinux001" == "1" ] && syssz=$((($filesz+15-512)/16)) 1.52 + store 16 500 $syssz $1 1.53 + [ "$iselks" == "1" ] && store 16 elks_patch 37008 $1 1.54 + [ "$islinux001" == "1" ] && store 16 linux001_patch 37008 $1 1.55 ddq >> $1 1.56 } 1.57 1.58 +filesz=$(stat -c %s $1) 1.59 create_bzImage $2 "$3" < $1
2.1 --- a/linld/stuff/tobzimage.S Sun Jun 12 09:23:56 2016 +0200 2.2 +++ b/linld/stuff/tobzimage.S Sun Jun 12 15:34:09 2016 +0200 2.3 @@ -1,5 +1,8 @@ 2.4 + 2.5 #define REALMODE_SWITCH 2.6 #define SHUTDOWNDOS 2.7 +#define ELKS_SUPPORT 2.8 +#define LINUX001_SUPPORT 2.9 2.10 .code16 2.11 .org 0 2.12 @@ -21,8 +24,6 @@ 2.13 .word 0 # heap_end_ptr 2.01+, patched by bootloader 2.14 2.15 start: 2.16 - cli 2.17 - cld 2.18 pushf 2.19 pushw %cs 2.20 pushw $0 2.21 @@ -32,6 +33,7 @@ 2.22 rep 2.23 movsw 2.24 popaw 2.25 +doiret: 2.26 iret 2.27 pushw %ds 2.28 pushw %di 2.29 @@ -46,10 +48,10 @@ 2.30 2.31 #ifdef SHUTDOWNDOS 2.32 xorw %si, %si 2.33 - movw %sp, loadsp19+0x201 2.34 movw %si, %ds # %ds = 0 2.35 pushl 4(%si) 2.36 - cmpw $0xF000, 6(%si) 2.37 + movw %sp, %cs:loadsp19+1(%si) 2.38 + cmpb $0xF0, 7(%si) 2.39 jnb notdos 2.40 movw $step19, 4(%si) 2.41 movw %cs, 6(%si) 2.42 @@ -59,8 +61,6 @@ 2.43 pushw %ax 2.44 popfw 2.45 ljmp *4*0x19(%si) 2.46 -stepagain19: 2.47 - iret 2.48 step19: 2.49 pushw %si 2.50 pushw %ds 2.51 @@ -69,20 +69,22 @@ 2.52 cmpw $0x19CD, (%si) 2.53 popw %ds 2.54 popw %si 2.55 - jne stepagain19 2.56 + jne doiret 2.57 xorw %si, %si 2.58 mov %si, %ds 2.59 popl 4*0x19(%si) 2.60 notdos: 2.61 loadsp19: 2.62 - movw $0, %bp 2.63 - leaw -4(%bp), %sp 2.64 + movw $0, %sp 2.65 popl 4(%si) 2.66 pushw %ss 2.67 popw %ds 2.68 +#else 2.69 + xorw %si, %si 2.70 #endif 2.71 - 2.72 -// xorw %si, %si 2.73 +#if defined(ELKS_SUPPORT) || defined(LINUX001_SUPPORT) 2.74 + movw %sp, %bx 2.75 +#endif 2.76 movw $9, %cx 2.77 z1: 2.78 pushw %si # 0000 0000 0000 0000 0000 0000 0000 0000 0000 2.79 @@ -90,12 +92,12 @@ 2.80 movw $0x9301, %ax 2.81 cwd 2.82 pushw %ax # 9301 2.83 - pushw %cx # 0000 2.84 + pushw %si # 0000 2.85 pushw %dx # FFFF 2.86 - pushw %cx # 0000 2.87 + pushw %si # 0000 2.88 movb 0x216, %al 2.89 pushw %ax # 93xx 2.90 - pushw %cx # 0000 2.91 + pushw %si # 0000 2.92 pushw %dx # FFFF 2.93 movb $8, %cl 2.94 z2: 2.95 @@ -112,14 +114,41 @@ 2.96 int $0x15 2.97 incw 20(%si) 2.98 incw 28(%si) 2.99 - subw $0x1000, %dx 2.100 + subb $0x10, %dh 2.101 ja mvlp 2.102 addw $48, %sp 2.103 +#ifdef ELKS_SUPPORT 2.104 + //cmpl $0x534B4C45, -26(%di) 2.105 +elks_patch: 2.106 + jmp notelks 2.107 + movw $0x100, %cx 2.108 + movb %ch, 23(%bx) 2.109 + movw %cx, %es 2.110 + pushw %di 2.111 + xorw %di, %di 2.112 + xorw %si, %si 2.113 + movb $0x6, %ch 2.114 + rep 2.115 + movsw 2.116 + popw %di 2.117 + pushw %es 2.118 + popw %ds 2.119 +notelks: 2.120 +#endif 2.121 + movw $0x400, %si 2.122 decb -15(%di) 2.123 -sysmoved: 2.124 - movw $0x400, %si 2.125 - xorw %cx, %cx 2.126 movb -15(%di), %ch 2.127 +#ifdef LINUX001_SUPPORT 2.128 + //cmpw $0x3AE8, 0x3F(%si) 2.129 +linux001_patch: 2.130 + jmp notlnx001 2.131 + movb $0x42, (%bx) 2.132 + xorw %di, %di 2.133 + movw $0x100, %cx 2.134 + rep 2.135 + movsw 2.136 +notlnx001: 2.137 +#endif 2.138 lret 2.139 endcode: 2.140