wok-current view plop/stuff/unpack.S @ rev 25444
Up firefox-official (104.0)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Sep 04 18:56:05 2022 +0000 (2022-09-04) |
parents | |
children | 7f7bd3c9775e |
line source
1 #define SYSTEM 0x10000
2 #define SETUP 14
3 #define SYSSIZE 0x1F4
4 #define SETUPSIZE 0x1F1
6 #define KEEP_BOOTSECTOR 1
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 1
13 #define SAVEREGS 0
14 #define ELKS 0
16 .text
17 .code16
18 .org 0
20 #if KEEP_BOOTSECTOR
21 #undef UPDATE_SYSSIZE
22 #define UPDATE_SYSSIZE 0
23 #endif
24 #if defined(FLAT16OUT) && FLAT16OUT == 0
25 #undef FLAT16OUT
26 #endif
27 #if ELKS
28 .arch i8086
29 #define FLAT16 1
30 #define LINUX_HEADER 0
31 #define SAVEREGS 0
32 #define TOPSEG 0x2000
33 #else
34 #define TOPSEG 0x8000
35 #endif
37 .globl _start
38 _start:
39 #if LINUX_HEADER
40 jmp start2
41 .ascii "HdrS" // 202 magic
42 .word 0x200 // 206 version 2.00
43 .long 0 // 208 realmode_swtch
44 .word SYSTEM/16 // 20C start_sys_seg
45 .word 0 // 20E kernel_version
46 .byte 0 // 210 type_of_loader
47 .byte 0 // 211 loadflags
48 .word 0 // 212 setup_move_size
49 .long SYSTEM // 214 code32_start
50 .long 0 // 218 ramdisk_image
51 .long 0 // 21C ramdisk_size
52 .long 0 // 220 bootsect_kludge
53 start2:
54 #endif
55 #if SAVEREGS
56 pushfw
57 pushw %cs
58 pushw $0
59 pushal
60 pushw %ds
61 cld
62 #else
63 pushw %cs
64 # if FLAT16
65 xorw %di, %di
66 pushw %di
67 # else
68 pushw $0
69 # endif
70 #endif
71 #if ELKS
72 movw $0x100, %ax
73 pushw %ax
74 #else
75 # if UPDATE_SYSSIZE || KEEP_BOOTSECTOR
76 pushw %ds // <A>
77 # else
78 pushw %cs // <A>
79 # endif
80 #endif
81 #if FLAT16
82 # 1- move 9000/9020..9020+stp -> TOPSEG
83 #if ELKS
84 movb $TOPSEG/256, %ah
85 movw %ax, %es
86 #else
87 pushw $TOPSEG
88 popw %es
89 #endif
90 #if KEEP_BOOTSECTOR
91 xorw %si, %si
92 #else
93 movw $0x200, %si
94 #endif
95 #if SAVEREGS == 0
96 pushw %es
97 #if ELKS
98 # if KEEP_BOOTSECTOR
99 movw $cont+0x200, %ax
100 # else
101 movw $cont, %ax
102 # endif
103 pushw %ax
104 #else
105 # if KEEP_BOOTSECTOR
106 pushw $cont+0x200
107 # else
108 // pushw $cont
109 .byte 0x6A, cont
110 # endif
111 #endif
112 jmp jumpinto
113 #else
114 # if HARDCODED_SETUPSIZE
115 setup_word:
116 # if KEEP_BOOTSECTOR
117 # else
118 movw $SETUP*256, %cx
119 # endif
120 # else
121 # if KEEP_BOOTSECTOR
122 movw $0x100, %cx
123 addb SETUPSIZE, %ch
124 # else
125 xorw %cx, %cx
126 movb SETUPSIZE, %ch
127 # endif
128 movw %cx, %dx
129 # endif
130 pushw %cx // <B>
131 pushw %es
132 pushw %di
133 rep
134 movsw
135 lret
136 #endif
137 cont:
138 # 2- move 1000..1000+sys -> TOPSEG+stp
139 #if ELKS
140 movw $0x1000, %ax
141 movw %ax, %ds
142 #else
143 pushw $0x1000
144 popw %ds
145 #endif
146 xorw %si, %si
147 subw %di, %cx
148 rep
149 movsb
150 # 3- unlz(TOPSEG+stp:end, 1000-stp:0)
151 pushw %es // <C>
152 # if HARDCODED_SETUPSIZE
153 setup_seg:
154 #if ELKS
155 # if KEEP_BOOTSECTOR
156 # if UPDATE_SYSSIZE
157 movw $0x1000-(SETUP*32)-32-32, %ax
158 # else
159 movw $0x1000-(SETUP*32)-32, %ax
160 # endif
161 # else
162 # if UPDATE_SYSSIZE
163 movw $0x1000-(SETUP*32)-32, %ax
164 # else
165 movw $0x1000-(SETUP*32), %ax
166 # endif
167 # endif
168 movw %ax, %es
169 #else
170 # if KEEP_BOOTSECTOR
171 # if UPDATE_SYSSIZE
172 pushw $0x1000-(SETUP*32)-32-32
173 # else
174 pushw $0x1000-(SETUP*32)-32
175 # endif
176 # else
177 # if UPDATE_SYSSIZE
178 pushw $0x1000-(SETUP*32)-32
179 # else
180 pushw $0x1000-(SETUP*32)
181 # endif
182 # endif
183 popw %es
184 #endif
185 # else
186 # if UPDATE_SYSSIZE
187 incb %dh
188 # endif
189 #if ELKS
190 shrw $1, %dx
191 shrw $1, %dx
192 shrw $1, %dx
193 #else
194 shrw $3, %dx
195 #endif
196 movw %ds, %ax
197 subw %dx, %ax
198 movw %ax, %es
199 # endif
200 #else // FLAT16
201 # 1- move 1000..1000+sys -> 9000-sys
202 # if HARDCODED_SYSSIZE
203 packed_syssize:
204 movw $0x1000+0, %ax
205 # else
206 movw SYSSIZE, %ax
207 addw $0x1000, %ax
208 # endif
209 movw %ds, %dx
210 mvsys:
211 decw %ax
212 decw %dx
213 movw %ax, %ds
214 movw %dx, %es
215 xorw %si, %si
216 xorw %di, %di
217 movw $8, %cx
218 rep
219 movsw
220 cmpw $0x1000, %ax
221 jne mvsys
222 # 2- move 9000/9020..9020+stp -> 9000-sys-stp
224 # if HARDCODED_SETUPSIZE
225 # if KEEP_BOOTSECTOR
226 setup_byte:
227 movb $SETUP+1, %ch
228 setup_para:
229 subw $SETUP*32+32, %dx
230 # else
231 setup_byte:
232 movb $SETUP, %ch
233 setup_para:
234 subw $SETUP*32, %dx
235 # endif
236 # else
237 movb %ss:SETUPSIZE, %ch
238 # if KEEP_BOOTSECTOR
239 incb $ch
240 # endif
241 movw %cx, %ax
242 #if ELKS
243 shrw $1, %ax
244 shrw $1, %ax
245 shrw $1, %ax
246 #else
247 shrw $3, %ax
248 #endif
249 subw %ax, %dx
250 # endif
251 pushw %cx // <B>
252 movw %dx, %es
253 xorw %si, %si
254 xorw %di, %di
255 rep
256 movsw %cs:(%si),%es:(%di)
257 pushw %es
258 # 3- reloc itself in 0x7C00
259 pushw $0x07C0
260 popw %es
261 movw $cont, %si
262 movw %si, %di
263 movw $end-_start, %cx
264 pushw %es
265 pushw %di
266 rep
267 movsb %cs:(%si),%es:(%di)
268 lret
269 cont:
270 # 4- unlz(9000-sys-stp:end, 1000-stp:0)
271 # if HARDCODED_SETUPSIZE
272 setup_seg:
273 # if KEEP_BOOTSECTOR
274 # if UPDATE_SYSSIZE
275 pushw $0x1000-(SETUP*32)-32-32
276 # else
277 pushw $0x1000-(SETUP*32)-32
278 # endif
279 # else
280 # if UPDATE_SYSSIZE
281 pushw $0x1000-(SETUP*32)-32
282 # else
283 pushw $0x1000-(SETUP*32)
284 # endif
285 # endif
286 popw %es
287 # else
288 negw %ax
289 # if UPDATE_SYSSIZE
290 addw $0x1000-32, %ax
291 # else
292 addw $0x1000, %ax
293 # endif
294 movw %ax, %es
295 # endif
296 #endif // FLAT16
297 popw %ds // <C>
298 #if KEEP_BOOTSECTOR
299 movw $0x200+end-_start, %si
300 #else
301 movw $end-_start, %si
302 #endif
303 #if UPDATE_SYSSIZE
304 movw $SYSSIZE, %di
305 #else
306 xorw %di, %di
307 #endif
308 pushw %di
309 pushw %es
310 call unpack
311 popw %ds
312 popw %si
313 # if KEEP_BOOTSECTOR
314 setup_keep:
315 xorw %di, %di
316 # else
317 movw %si, %di
318 # endif
319 # if SAVEREGS != 0
320 popw %cx // <B>
321 #if UPDATE_SYSSIZE
322 // not need with memtest movb $(512-SYSSIZE)/2, %cl
323 #endif
324 popw %es // <A>
325 # 5- move 1000-stp..1000 -> 9020
326 # else
327 popw %es // <A>
328 jumpinto:
329 # if HARDCODED_SETUPSIZE
330 setup_word:
331 # if KEEP_BOOTSECTOR
332 movw $SETUP*256+256, %cx
333 # else
334 movw $SETUP*256, %cx
335 # endif
336 # else
337 # if KEEP_BOOTSECTOR
338 movw $0x100, %cx
339 addb %ss:SETUPSIZE, %ch
340 # else
341 xorw %cx, %cx
342 movb %ss:SETUPSIZE, %ch
343 # endif
344 movw %cx, %dx
345 # endif
346 # endif
347 rep
348 movsw
349 #if SAVEREGS
350 popw %ds
351 popal
352 iret
353 #else
354 lret
355 #endif
357 unpack:
358 #define NO_LZMA_HEADER
359 #if ELKS
360 #define ONLY8086 1
361 #endif
362 #include "unlzma.S"
364 end: