wok-next annotate memtest/stuff/unpack.S @ rev 14166
Add fossil
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Mar 08 09:07:03 2013 +0100 (2013-03-08) |
parents | 1d5a6d3ed1f5 |
children | b0e9e83532e2 |
rev | line source |
---|---|
pascal@13288 | 1 #define TOP 0x8FD00 |
pascal@13288 | 2 #define SYSTEM 0x10000 |
pascal@13288 | 3 #define SETUP 4 |
pascal@13288 | 4 |
pascal@13288 | 5 #define CHANGE_STACK 1 |
pascal@13289 | 6 #define LINUX_HEADER 0 |
pascal@13269 | 7 |
pascal@13269 | 8 .text |
pascal@13269 | 9 .code16 |
pascal@13269 | 10 .org 0 |
pascal@13269 | 11 |
pascal@13269 | 12 .globl _start |
pascal@13269 | 13 _start: |
pascal@13289 | 14 #if LINUX_HEADER |
pascal@13289 | 15 jmp start2 |
pascal@13289 | 16 .ascii "HdrS" // 202 magic |
pascal@13289 | 17 .word 0x200 // 206 version 2.00 |
pascal@13289 | 18 .long 0 // 208 realmode_swtch |
pascal@13289 | 19 .word SYSTEM/16 // 20C start_sys_seg |
pascal@13289 | 20 .word 0 // 20E kernel_version |
pascal@13289 | 21 .byte 0 // 210 type_of_loader |
pascal@13289 | 22 .byte 0 // 211 loadflags |
pascal@13289 | 23 .word 0 // 212 setup_move_size |
pascal@13289 | 24 .long SYSTEM // 214 code32_start |
pascal@13289 | 25 .long 0 // 218 ramdisk_image |
pascal@13289 | 26 .long 0 // 21C ramdisk_size |
pascal@13289 | 27 .long 0 // 220 bootsect_kludge |
pascal@13289 | 28 start2: |
pascal@13289 | 29 #endif |
pascal@13269 | 30 pushf |
pascal@13269 | 31 pushw %cs |
pascal@13269 | 32 call getip |
pascal@13269 | 33 getip: |
pascal@13269 | 34 pushal |
pascal@13269 | 35 movw $0, %bx // packed sizes |
pascal@13269 | 36 movw %sp, %bp |
pascal@13269 | 37 #define START_IP 32(%bp) |
pascal@13269 | 38 pushw %ds |
pascal@13269 | 39 pushw %es |
pascal@13269 | 40 subw $getip-_start, START_IP |
pascal@13269 | 41 |
pascal@13269 | 42 cld |
pascal@13269 | 43 pushw %cs |
pascal@13269 | 44 popw %ds |
pascal@13269 | 45 movw $TOP/16, %ax |
pascal@13269 | 46 movw %ax, %es |
pascal@13269 | 47 subw %bx, %ax // moved packed data |
pascal@13269 | 48 movw START_IP, %si |
pascal@13269 | 49 movw $moved-_start, %di |
pascal@13269 | 50 addw %si, %di |
pascal@13269 | 51 pushw %ds // save setup seg |
pascal@13269 | 52 pushw %es // moved |
pascal@13269 | 53 pushw %di // unpack code |
pascal@13269 | 54 movw %si, %di |
pascal@13269 | 55 movw $end-_start, %cx |
pascal@13269 | 56 rep |
pascal@13269 | 57 movsb // move upack code to $TOP |
pascal@13269 | 58 pushw %si // data offset |
pascal@13269 | 59 movw %ax, %es |
pascal@13269 | 60 movw $SETUP*512, %cx |
pascal@13269 | 61 subw $SETUP*32, %bx |
pascal@13269 | 62 xorw %si, %si |
pascal@13269 | 63 xorw %di, %di |
pascal@13269 | 64 rep |
pascal@13269 | 65 movsb // move header part |
pascal@13269 | 66 pushw $SYSTEM/16 |
pascal@13269 | 67 popw %ds |
pascal@13269 | 68 movlp: |
pascal@13269 | 69 xorw %si, %si |
pascal@13269 | 70 movw $8, %cx |
pascal@13269 | 71 rep |
pascal@13269 | 72 movsw // move system part |
pascal@13269 | 73 subw $16, %di |
pascal@13269 | 74 movw %ds, %cx |
pascal@13269 | 75 incw %cx |
pascal@13269 | 76 movw %cx, %ds |
pascal@13269 | 77 movw %es, %cx |
pascal@13269 | 78 incw %cx |
pascal@13269 | 79 movw %cx, %es |
pascal@13269 | 80 decw %bx |
pascal@13269 | 81 jns movlp |
pascal@13269 | 82 popw %si // data offset |
pascal@13269 | 83 movw %ax, %ds |
pascal@13269 | 84 retf |
pascal@13269 | 85 |
pascal@13269 | 86 moved: |
pascal@13269 | 87 popw %es // restore setup seg |
pascal@13269 | 88 movw START_IP, %di |
pascal@13288 | 89 #if CHANGE_STACK |
pascal@13288 | 90 movw $0xFFFE, %ax |
pascal@13288 | 91 movw %ss, %bx |
pascal@13288 | 92 pushw $0 |
pascal@13288 | 93 popw %ss |
pascal@13288 | 94 xchgw %ax, %sp |
pascal@13288 | 95 pushw %bx // %ss |
pascal@13288 | 96 pushw %ax // %sp |
pascal@13288 | 97 #endif |
pascal@13269 | 98 call unpack // unpack setup |
pascal@13269 | 99 pushw $SYSTEM/16 |
pascal@13269 | 100 popw %es |
pascal@13269 | 101 xorw %di,%di |
pascal@13269 | 102 call unpack // unpack system |
pascal@13288 | 103 #if CHANGE_STACK |
pascal@13288 | 104 popw %ax // %sp |
pascal@13288 | 105 popw %ss |
pascal@13288 | 106 xchgw %ax, %sp |
pascal@13288 | 107 #endif |
pascal@13269 | 108 popw %es |
pascal@13269 | 109 popw %ds |
pascal@13269 | 110 popal |
pascal@13269 | 111 iret |
pascal@13269 | 112 |
pascal@13269 | 113 unpack: |
pascal@13288 | 114 #include "unlzma.S" |
pascal@13269 | 115 |
pascal@13269 | 116 end: |