rev |
line source |
pascal@13288
|
1 #define SYSTEM 0x10000
|
pascal@19404
|
2 #define SETUP 14
|
pascal@15188
|
3 #define SYSSIZE 0x1F4
|
pascal@15188
|
4 #define SETUPSIZE 0x1F1
|
pascal@13288
|
5
|
pascal@15188
|
6 #define LINUX_HEADER 0
|
pascal@15188
|
7 #define UPDATE_SYSSIZE 1
|
pascal@15188
|
8 #define HARDCODED_SYSSIZE 1
|
pascal@15188
|
9 #define HARDCODED_SETUPSIZE 1
|
pascal@25488
|
10 #define FLAT16 1 // lzma case
|
pascal@19391
|
11 //#define FLAT16OUT 0
|
pascal@19404
|
12 #define SAVEREGS 0
|
pascal@20187
|
13 #define ELKS 0
|
pascal@13269
|
14
|
pascal@13269
|
15 .text
|
pascal@13269
|
16 .code16
|
pascal@13269
|
17 .org 0
|
pascal@13269
|
18
|
pascal@20184
|
19 #if ELKS
|
pascal@20184
|
20 .arch i8086
|
pascal@20184
|
21 #define FLAT16 1
|
pascal@20184
|
22 #define LINUX_HEADER 0
|
pascal@20184
|
23 #define SAVEREGS 0
|
pascal@20184
|
24 #define TOPSEG 0x2000
|
pascal@20184
|
25 #else
|
pascal@20184
|
26 #define TOPSEG 0x8000
|
pascal@20184
|
27 #endif
|
pascal@20184
|
28
|
pascal@13269
|
29 .globl _start
|
pascal@13269
|
30 _start:
|
pascal@13289
|
31 #if LINUX_HEADER
|
pascal@13289
|
32 jmp start2
|
pascal@13289
|
33 .ascii "HdrS" // 202 magic
|
pascal@13289
|
34 .word 0x200 // 206 version 2.00
|
pascal@13289
|
35 .long 0 // 208 realmode_swtch
|
pascal@13289
|
36 .word SYSTEM/16 // 20C start_sys_seg
|
pascal@13289
|
37 .word 0 // 20E kernel_version
|
pascal@13289
|
38 .byte 0 // 210 type_of_loader
|
pascal@13289
|
39 .byte 0 // 211 loadflags
|
pascal@13289
|
40 .word 0 // 212 setup_move_size
|
pascal@13289
|
41 .long SYSTEM // 214 code32_start
|
pascal@13289
|
42 .long 0 // 218 ramdisk_image
|
pascal@13289
|
43 .long 0 // 21C ramdisk_size
|
pascal@13289
|
44 .long 0 // 220 bootsect_kludge
|
pascal@13289
|
45 start2:
|
pascal@13289
|
46 #endif
|
pascal@19404
|
47 #if SAVEREGS
|
pascal@19404
|
48 pushfw
|
pascal@13269
|
49 pushw %cs
|
pascal@15188
|
50 pushw $0
|
pascal@19404
|
51 pushal
|
pascal@19404
|
52 pushw %ds
|
pascal@19942
|
53 cld
|
pascal@15188
|
54 #else
|
pascal@25488
|
55 pushw %cs // return adress is %cs:0
|
pascal@19942
|
56 # if FLAT16
|
pascal@19942
|
57 xorw %di, %di
|
pascal@19942
|
58 pushw %di
|
pascal@19942
|
59 # else
|
pascal@19404
|
60 pushw $0
|
pascal@19942
|
61 # endif
|
pascal@15188
|
62 #endif
|
pascal@20184
|
63 #if ELKS
|
pascal@20184
|
64 movw $0x100, %ax
|
pascal@20184
|
65 pushw %ax
|
pascal@20184
|
66 #else
|
pascal@25488
|
67 # if UPDATE_SYSSIZE
|
pascal@19942
|
68 pushw %ds // <A>
|
pascal@25488
|
69 # else
|
pascal@19942
|
70 pushw %cs // <A>
|
pascal@25488
|
71 # endif
|
pascal@20184
|
72 #endif
|
pascal@19404
|
73 #if FLAT16
|
pascal@20184
|
74 # 1- move 9020..9020+stp -> TOPSEG
|
pascal@25488
|
75 # if ELKS
|
pascal@20184
|
76 movb $TOPSEG/256, %ah
|
pascal@20184
|
77 movw %ax, %es
|
pascal@25488
|
78 # else
|
pascal@20184
|
79 pushw $TOPSEG
|
pascal@25488
|
80 popw %es // %es:%di = TOPSEG:0
|
pascal@25488
|
81 # endif
|
pascal@25488
|
82 movw $0x200, %si // %ds:%si = 9000:0200
|
pascal@25488
|
83 # if SAVEREGS == 0
|
pascal@19942
|
84 pushw %es
|
pascal@25488
|
85 call jumpinto // move setup & jmp %es:cont
|
pascal@25488
|
86 # else
|
pascal@25488
|
87 # if HARDCODED_SETUPSIZE
|
pascal@19404
|
88 setup_word:
|
pascal@19404
|
89 movw $SETUP*256, %cx
|
pascal@25488
|
90 # else
|
pascal@19404
|
91 xorw %cx, %cx
|
pascal@19404
|
92 movb SETUPSIZE, %ch
|
pascal@19404
|
93 movw %cx, %dx
|
pascal@25488
|
94 # endif
|
pascal@19942
|
95 pushw %cx // <B>
|
pascal@19942
|
96 pushw %es
|
pascal@19942
|
97 pushw %di
|
pascal@19404
|
98 rep
|
pascal@19942
|
99 movsw
|
pascal@19404
|
100 lret
|
pascal@25488
|
101 # endif
|
pascal@19404
|
102 cont:
|
pascal@20184
|
103 # 2- move 1000..1000+sys -> TOPSEG+stp
|
pascal@25488
|
104 # if ELKS
|
pascal@20184
|
105 movw $0x1000, %ax
|
pascal@20184
|
106 movw %ax, %ds
|
pascal@25488
|
107 # else
|
pascal@19404
|
108 pushw $0x1000
|
pascal@19404
|
109 popw %ds
|
pascal@25488
|
110 # endif
|
pascal@25488
|
111 xorw %si, %si // %ds:%si = 1000:0
|
pascal@25488
|
112 subw %di, %cx // %cx = 64K - setupsz
|
pascal@19391
|
113 rep
|
pascal@19404
|
114 movsb
|
pascal@20184
|
115 # 3- unlz(TOPSEG+stp:end, 1000-stp:0)
|
pascal@19942
|
116 pushw %es // <C>
|
pascal@19404
|
117 # if HARDCODED_SETUPSIZE
|
pascal@19404
|
118 setup_seg:
|
pascal@25488
|
119 # if ELKS
|
pascal@25488
|
120 # if UPDATE_SYSSIZE
|
pascal@20184
|
121 movw $0x1000-(SETUP*32)-32, %ax
|
pascal@25488
|
122 # else
|
pascal@25488
|
123 movw $0x1000-(SETUP*32), %ax
|
pascal@25488
|
124 # endif
|
pascal@25488
|
125 movw %ax, %es
|
pascal@20184
|
126 # else
|
pascal@25488
|
127 # if UPDATE_SYSSIZE
|
pascal@25488
|
128 pushw $0x1000-(SETUP*32)-32
|
pascal@25488
|
129 # else
|
pascal@25488
|
130 pushw $0x1000-(SETUP*32)
|
pascal@25488
|
131 # endif
|
pascal@25488
|
132 popw %es
|
pascal@20184
|
133 # endif
|
pascal@19404
|
134 # else
|
pascal@19404
|
135 # if UPDATE_SYSSIZE
|
pascal@19404
|
136 incb %dh
|
pascal@19404
|
137 # endif
|
pascal@25488
|
138 # if ELKS
|
pascal@20184
|
139 shrw $1, %dx
|
pascal@20184
|
140 shrw $1, %dx
|
pascal@20184
|
141 shrw $1, %dx
|
pascal@25488
|
142 # else
|
pascal@19404
|
143 shrw $3, %dx
|
pascal@25488
|
144 # endif
|
pascal@19404
|
145 movw %ds, %ax
|
pascal@19404
|
146 subw %dx, %ax
|
pascal@19404
|
147 movw %ax, %es
|
pascal@25488
|
148 # endif
|
pascal@25488
|
149 # else // FLAT16
|
pascal@19404
|
150 # 1- move 1000..1000+sys -> 9000-sys
|
pascal@19404
|
151 # if HARDCODED_SYSSIZE
|
pascal@19404
|
152 packed_syssize:
|
pascal@19404
|
153 movw $0x1000+0, %ax
|
pascal@19404
|
154 # else
|
pascal@19404
|
155 movw SYSSIZE, %ax
|
pascal@19404
|
156 addw $0x1000, %ax
|
pascal@19404
|
157 # endif
|
pascal@19404
|
158 movw %ds, %dx
|
pascal@19404
|
159 mvsys:
|
pascal@19404
|
160 decw %ax
|
pascal@19404
|
161 decw %dx
|
pascal@19404
|
162 movw %ax, %ds
|
pascal@19404
|
163 movw %dx, %es
|
pascal@19404
|
164 xorw %si, %si
|
pascal@19404
|
165 xorw %di, %di
|
pascal@19404
|
166 movw $8, %cx
|
pascal@19404
|
167 rep
|
pascal@19404
|
168 movsw
|
pascal@19404
|
169 cmpw $0x1000, %ax
|
pascal@19404
|
170 jne mvsys
|
pascal@19404
|
171 # 2- move 9020..9020+stp -> 9000-sys-stp
|
pascal@19404
|
172
|
pascal@19404
|
173 # if HARDCODED_SETUPSIZE
|
pascal@19404
|
174 setup_byte:
|
pascal@19404
|
175 movb $SETUP, %ch
|
pascal@19404
|
176 setup_para:
|
pascal@19404
|
177 subw $SETUP*32, %dx
|
pascal@19404
|
178 # else
|
pascal@19404
|
179 movb %ss:SETUPSIZE, %ch
|
pascal@19404
|
180 movw %cx, %ax
|
pascal@25488
|
181 # if ELKS
|
pascal@20184
|
182 shrw $1, %ax
|
pascal@20184
|
183 shrw $1, %ax
|
pascal@20184
|
184 shrw $1, %ax
|
pascal@25488
|
185 # else
|
pascal@19404
|
186 shrw $3, %ax
|
pascal@25488
|
187 # endif
|
pascal@19404
|
188 subw %ax, %dx
|
pascal@19404
|
189 # endif
|
pascal@25488
|
190 # if SAVEREGS != 0
|
pascal@19942
|
191 pushw %cx // <B>
|
pascal@25488
|
192 # endif
|
pascal@19404
|
193 movw %dx, %es
|
pascal@25488
|
194 xorw %si, %si // %cs:%si = 9020:0
|
pascal@25488
|
195 xorw %di, %di // %es:%di = 9000-sys-stp:0
|
pascal@19404
|
196 rep
|
pascal@19404
|
197 movsw %cs:(%si),%es:(%di)
|
pascal@25488
|
198 pushw %es // <C>
|
pascal@19404
|
199 # 3- reloc itself in 0x7C00
|
pascal@19404
|
200 pushw $0x07C0
|
pascal@19404
|
201 popw %es
|
pascal@25488
|
202 movw $cont, %si // %cs:%si = 9020:cont
|
pascal@25488
|
203 movw %si, %di // %es:%di = 7C0:cont
|
pascal@13269
|
204 movw $end-_start, %cx
|
pascal@19942
|
205 pushw %es
|
pascal@19942
|
206 pushw %di
|
pascal@13269
|
207 rep
|
pascal@19404
|
208 movsb %cs:(%si),%es:(%di)
|
pascal@19404
|
209 lret
|
pascal@19404
|
210 cont:
|
pascal@19404
|
211 # 4- unlz(9000-sys-stp:end, 1000-stp:0)
|
pascal@19404
|
212 # if HARDCODED_SETUPSIZE
|
pascal@19404
|
213 setup_seg:
|
pascal@19404
|
214 # if UPDATE_SYSSIZE
|
pascal@19404
|
215 pushw $0x1000-(SETUP*32)-32
|
pascal@19404
|
216 # else
|
pascal@19404
|
217 pushw $0x1000-(SETUP*32)
|
pascal@19404
|
218 # endif
|
pascal@19404
|
219 popw %es
|
pascal@19404
|
220 # else
|
pascal@19404
|
221 negw %ax
|
pascal@19404
|
222 # if UPDATE_SYSSIZE
|
pascal@19404
|
223 addw $0x1000-32, %ax
|
pascal@19404
|
224 # else
|
pascal@19404
|
225 addw $0x1000, %ax
|
pascal@19404
|
226 # endif
|
pascal@13269
|
227 movw %ax, %es
|
pascal@19404
|
228 # endif
|
pascal@19942
|
229 #endif // FLAT16
|
pascal@19942
|
230 popw %ds // <C>
|
pascal@25488
|
231 movw $end-_start, %si // %ds:%si = TOPSSEG:compressed / 9000-sys-stp:compressed
|
pascal@19404
|
232 #if UPDATE_SYSSIZE
|
pascal@25488
|
233 movw $SYSSIZE, %di // %es:%di = 1000-setup-bootsector:SYSSIZE
|
pascal@19404
|
234 #else
|
pascal@13269
|
235 xorw %di, %di
|
pascal@19404
|
236 #endif
|
pascal@19404
|
237 pushw %di
|
pascal@19404
|
238 pushw %es
|
pascal@19404
|
239 call unpack
|
pascal@15188
|
240 popw %ds
|
pascal@25488
|
241 popw %si // %ds:%si = 1000-setup-bootsector:SYSSIZE
|
pascal@19404
|
242 movw %si, %di
|
pascal@19942
|
243 # if SAVEREGS != 0
|
pascal@19942
|
244 popw %cx // <B>
|
pascal@15188
|
245 #if UPDATE_SYSSIZE
|
pascal@19404
|
246 // not need with memtest movb $(512-SYSSIZE)/2, %cl
|
pascal@15188
|
247 #endif
|
pascal@19942
|
248 popw %es // <A>
|
pascal@19404
|
249 # 5- move 1000-stp..1000 -> 9020
|
pascal@19942
|
250 # else
|
pascal@25488
|
251 popw %es // <A> %es:%di = 9000:SYSSIZE (the last 12 bytes are missing)
|
pascal@19942
|
252 jumpinto:
|
pascal@19942
|
253 # if HARDCODED_SETUPSIZE
|
pascal@19942
|
254 setup_word:
|
pascal@19942
|
255 movw $SETUP*256, %cx
|
pascal@19942
|
256 # else
|
pascal@19942
|
257 xorw %cx, %cx
|
pascal@19942
|
258 movb %ss:SETUPSIZE, %ch
|
pascal@19942
|
259 movw %cx, %dx
|
pascal@19942
|
260 # endif
|
pascal@19942
|
261 # endif
|
pascal@19404
|
262 rep
|
pascal@19404
|
263 movsw
|
pascal@19404
|
264 #if SAVEREGS
|
pascal@13269
|
265 popw %ds
|
pascal@13269
|
266 popal
|
pascal@13269
|
267 iret
|
pascal@19404
|
268 #else
|
pascal@19404
|
269 lret
|
pascal@19404
|
270 #endif
|
pascal@13269
|
271
|
pascal@13269
|
272 unpack:
|
pascal@19403
|
273 #define NO_LZMA_HEADER
|
pascal@20184
|
274 #if ELKS
|
pascal@20184
|
275 #define ONLY8086 1
|
pascal@20184
|
276 #endif
|
pascal@25488
|
277 #include "uncompress.S"
|
pascal@13269
|
278
|
pascal@13269
|
279 end:
|