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