# HG changeset patch # User Pascal Bellard # Date 1465738449 -7200 # Node ID 1c8a113c536a35bd391b23866a05b80b5eece743 # Parent 55f1b37cebe1a26f7aa03629ecd9eb7cfcbfb257 linld/tobzimage: add elks support diff -r 55f1b37cebe1 -r 1c8a113c536a linld/stuff/tobzimage --- a/linld/stuff/tobzimage Sun Jun 12 09:23:56 2016 +0200 +++ b/linld/stuff/tobzimage Sun Jun 12 15:34:09 2016 +0200 @@ -1,6 +1,11 @@ #!/bin/sh if [ "$1" == "--build" ]; then #install-begin + for i in elks linux001 ; do + i=${i}_patch + n=$(sed "/$i\$/!d;s/.*text:0*\\([^ ]*\\).*/\\1/" tobzimage.lst) + [ -n "$n" ] && sed -i "s/$i/$((0x200 + 0x$n))/" $0 + done cat tobzimage.bin | gzip -9 | uuencode -m - | sed \ -e '/^tobzimage$/r/dev/stdin' -e '/^tobzimage$/d' \ -e '/install-begin$/,/install-end$/d' -i $0 @@ -35,6 +40,8 @@ create_bzImage() { ddq bs=512 count=1 of=$1 + [ " $(get 0x1E6 $1 4)" == " 1397443653" ] && iselks=1 + [ " $(get 0x3F $1 2)" == " 15080" ] && islinux001=1 && cp $1 $1$$ # from http://hg.slitaz.org/wok/file/7184ec55b1aa/linux/stuff/linux-header.u uudecode <> $1 tobzimage EOT - if [ "$2" ]; then - s="$2" - [ -s "$2" ] && s="$(cat "$2")" - echo -e "\n$2" | tr '\n' '\r' | cat - /dev/zero | \ - dd conv=notrunc of=$1 bs=1 seek=768 count=255 - fi + s="$2" + [ -s "$s" ] && s="$(cat "$s")" + [ -z "$s" ] && s="$(basename "$1")" + echo -e "\n$s" | tr '\n' '\r' | cat - /dev/zero | \ + ddq conv=notrunc of=$1 bs=1 seek=768 count=255 setupsz=$(get 497 $1 1) [ $setupsz -eq 0 ] && setupsz=4 - ddq bs=512 count=$setupsz >> $1 + if [ "$islinux001" == "1" ]; then + cat $1$$ /dev/zero | ddq bs=512 count=$setupsz >> $1 + rm -f $1$$ + else + ddq bs=512 count=$setupsz >> $1 + fi store 8 497 $(($setupsz+1)) $1 + syssz=$(get 500 $1 2) + [ $syssz -eq 0 ] && syssz=$((($filesz+15-512)/16-($setupsz*32))) + [ "$islinux001" == "1" ] && syssz=$((($filesz+15-512)/16)) + store 16 500 $syssz $1 + [ "$iselks" == "1" ] && store 16 elks_patch 37008 $1 + [ "$islinux001" == "1" ] && store 16 linux001_patch 37008 $1 ddq >> $1 } +filesz=$(stat -c %s $1) create_bzImage $2 "$3" < $1 diff -r 55f1b37cebe1 -r 1c8a113c536a linld/stuff/tobzimage.S --- a/linld/stuff/tobzimage.S Sun Jun 12 09:23:56 2016 +0200 +++ b/linld/stuff/tobzimage.S Sun Jun 12 15:34:09 2016 +0200 @@ -1,5 +1,8 @@ + #define REALMODE_SWITCH #define SHUTDOWNDOS +#define ELKS_SUPPORT +#define LINUX001_SUPPORT .code16 .org 0 @@ -21,8 +24,6 @@ .word 0 # heap_end_ptr 2.01+, patched by bootloader start: - cli - cld pushf pushw %cs pushw $0 @@ -32,6 +33,7 @@ rep movsw popaw +doiret: iret pushw %ds pushw %di @@ -46,10 +48,10 @@ #ifdef SHUTDOWNDOS xorw %si, %si - movw %sp, loadsp19+0x201 movw %si, %ds # %ds = 0 pushl 4(%si) - cmpw $0xF000, 6(%si) + movw %sp, %cs:loadsp19+1(%si) + cmpb $0xF0, 7(%si) jnb notdos movw $step19, 4(%si) movw %cs, 6(%si) @@ -59,8 +61,6 @@ pushw %ax popfw ljmp *4*0x19(%si) -stepagain19: - iret step19: pushw %si pushw %ds @@ -69,20 +69,22 @@ cmpw $0x19CD, (%si) popw %ds popw %si - jne stepagain19 + jne doiret xorw %si, %si mov %si, %ds popl 4*0x19(%si) notdos: loadsp19: - movw $0, %bp - leaw -4(%bp), %sp + movw $0, %sp popl 4(%si) pushw %ss popw %ds +#else + xorw %si, %si #endif - -// xorw %si, %si +#if defined(ELKS_SUPPORT) || defined(LINUX001_SUPPORT) + movw %sp, %bx +#endif movw $9, %cx z1: pushw %si # 0000 0000 0000 0000 0000 0000 0000 0000 0000 @@ -90,12 +92,12 @@ movw $0x9301, %ax cwd pushw %ax # 9301 - pushw %cx # 0000 + pushw %si # 0000 pushw %dx # FFFF - pushw %cx # 0000 + pushw %si # 0000 movb 0x216, %al pushw %ax # 93xx - pushw %cx # 0000 + pushw %si # 0000 pushw %dx # FFFF movb $8, %cl z2: @@ -112,14 +114,41 @@ int $0x15 incw 20(%si) incw 28(%si) - subw $0x1000, %dx + subb $0x10, %dh ja mvlp addw $48, %sp +#ifdef ELKS_SUPPORT + //cmpl $0x534B4C45, -26(%di) +elks_patch: + jmp notelks + movw $0x100, %cx + movb %ch, 23(%bx) + movw %cx, %es + pushw %di + xorw %di, %di + xorw %si, %si + movb $0x6, %ch + rep + movsw + popw %di + pushw %es + popw %ds +notelks: +#endif + movw $0x400, %si decb -15(%di) -sysmoved: - movw $0x400, %si - xorw %cx, %cx movb -15(%di), %ch +#ifdef LINUX001_SUPPORT + //cmpw $0x3AE8, 0x3F(%si) +linux001_patch: + jmp notlnx001 + movb $0x42, (%bx) + xorw %di, %di + movw $0x100, %cx + rep + movsw +notlnx001: +#endif lret endcode: