wok view memtest/stuff/unpack.S @ rev 19946

Up vmtouch (1.3.0)
author Paul Issott <paul@slitaz.org>
date Sun May 07 15:59:20 2017 +0100 (2017-05-07)
parents 9e463ebef079
children 1421f93cc28a
line source
1 #define TOP (0x90000+_start-end)
2 #define SYSTEM 0x10000
3 #define SETUP 14
4 #define SYSSIZE 0x1F4
5 #define SETUPSIZE 0x1F1
7 #define LINUX_HEADER 0
8 #define UPDATE_SYSSIZE 1
9 #define HARDCODED_SYSSIZE 1
10 #define HARDCODED_SETUPSIZE 1
11 #define FLAT16 1
12 //#define FLAT16OUT 0
13 #define SAVEREGS 0
15 .text
16 .code16
17 .org 0
19 .globl _start
20 _start:
21 #if LINUX_HEADER
22 jmp start2
23 .ascii "HdrS" // 202 magic
24 .word 0x200 // 206 version 2.00
25 .long 0 // 208 realmode_swtch
26 .word SYSTEM/16 // 20C start_sys_seg
27 .word 0 // 20E kernel_version
28 .byte 0 // 210 type_of_loader
29 .byte 0 // 211 loadflags
30 .word 0 // 212 setup_move_size
31 .long SYSTEM // 214 code32_start
32 .long 0 // 218 ramdisk_image
33 .long 0 // 21C ramdisk_size
34 .long 0 // 220 bootsect_kludge
35 start2:
36 #endif
37 #if SAVEREGS
38 pushfw
39 pushw %cs
40 pushw $0
41 pushal
42 pushw %ds
43 cld
44 #else
45 pushw %cs
46 # if FLAT16
47 xorw %di, %di
48 pushw %di
49 # else
50 pushw $0
51 # endif
52 #endif
53 #if UPDATE_SYSSIZE
54 pushw %ds // <A>
55 #else
56 pushw %cs // <A>
57 #endif
58 #if FLAT16
59 # 1- move 9020..9020+stp -> 8000
60 pushw $0x8000
61 popw %es
62 movw $0x200, %si
63 #if SAVEREGS == 0
64 pushw %es
65 // pushw $cont
66 .byte 0x6A, cont
67 jmp jumpinto
68 #else
69 # if HARDCODED_SETUPSIZE
70 setup_word:
71 movw $SETUP*256, %cx
72 # else
73 xorw %cx, %cx
74 movb SETUPSIZE, %ch
75 movw %cx, %dx
76 # endif
77 pushw %cx // <B>
78 pushw %es
79 pushw %di
80 rep
81 movsw
82 lret
83 #endif
84 cont:
85 # 2- move 1000..1000+sys -> 8000+stp
86 pushw $0x1000
87 popw %ds
88 xorw %si, %si
89 subw %di, %cx
90 rep
91 movsb
92 # 3- unlz(8000+stp:end, 1000-stp:0)
93 pushw %es // <C>
94 # if HARDCODED_SETUPSIZE
95 setup_seg:
96 # if UPDATE_SYSSIZE
97 pushw $0x1000-(SETUP*32)-32
98 # else
99 pushw $0x1000-(SETUP*32)
100 # endif
101 popw %es
102 # else
103 # if UPDATE_SYSSIZE
104 incb %dh
105 # endif
106 shrw $3, %dx
107 movw %ds, %ax
108 subw %dx, %ax
109 movw %ax, %es
110 # endif
111 #else // FLAT16
112 # 1- move 1000..1000+sys -> 9000-sys
113 # if HARDCODED_SYSSIZE
114 packed_syssize:
115 movw $0x1000+0, %ax
116 # else
117 movw SYSSIZE, %ax
118 addw $0x1000, %ax
119 # endif
120 movw %ds, %dx
121 mvsys:
122 decw %ax
123 decw %dx
124 movw %ax, %ds
125 movw %dx, %es
126 xorw %si, %si
127 xorw %di, %di
128 movw $8, %cx
129 rep
130 movsw
131 cmpw $0x1000, %ax
132 jne mvsys
133 # 2- move 9020..9020+stp -> 9000-sys-stp
135 # if HARDCODED_SETUPSIZE
136 setup_byte:
137 movb $SETUP, %ch
138 setup_para:
139 subw $SETUP*32, %dx
140 # else
141 movb %ss:SETUPSIZE, %ch
142 movw %cx, %ax
143 shrw $3, %ax
144 subw %ax, %dx
145 # endif
146 pushw %cx // <B>
147 movw %dx, %es
148 xorw %si, %si
149 xorw %di, %di
150 rep
151 movsw %cs:(%si),%es:(%di)
152 pushw %es
153 # 3- reloc itself in 0x7C00
154 pushw $0x07C0
155 popw %es
156 movw $cont, %si
157 movw %si, %di
158 movw $end-_start, %cx
159 pushw %es
160 pushw %di
161 rep
162 movsb %cs:(%si),%es:(%di)
163 lret
164 cont:
165 # 4- unlz(9000-sys-stp:end, 1000-stp:0)
166 # if HARDCODED_SETUPSIZE
167 setup_seg:
168 # if UPDATE_SYSSIZE
169 pushw $0x1000-(SETUP*32)-32
170 # else
171 pushw $0x1000-(SETUP*32)
172 # endif
173 popw %es
174 # else
175 negw %ax
176 # if UPDATE_SYSSIZE
177 addw $0x1000-32, %ax
178 # else
179 addw $0x1000, %ax
180 # endif
181 movw %ax, %es
182 # endif
183 #endif // FLAT16
184 popw %ds // <C>
185 movw $end-_start, %si
186 #if UPDATE_SYSSIZE
187 movw $SYSSIZE, %di
188 #else
189 xorw %di, %di
190 #endif
191 pushw %di
192 pushw %es
193 call unpack
194 popw %ds
195 popw %si
196 movw %si, %di
197 # if SAVEREGS != 0
198 popw %cx // <B>
199 #if UPDATE_SYSSIZE
200 // not need with memtest movb $(512-SYSSIZE)/2, %cl
201 #endif
202 popw %es // <A>
203 # 5- move 1000-stp..1000 -> 9020
204 # else
205 popw %es // <A>
206 jumpinto:
207 # if HARDCODED_SETUPSIZE
208 setup_word:
209 movw $SETUP*256, %cx
210 # else
211 xorw %cx, %cx
212 movb %ss:SETUPSIZE, %ch
213 movw %cx, %dx
214 # endif
215 # endif
216 rep
217 movsw
218 #if SAVEREGS
219 popw %ds
220 popal
221 iret
222 #else
223 lret
224 #endif
226 unpack:
227 #define NO_LZMA_HEADER
228 #include "unlzma.S"
230 end: