wok view linld/stuff/src/JUMP.ASM @ rev 22179

linld: spare up to 30k more for zImage (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 09 13:26:32 2019 +0100 (4 weeks ago)
parents 10fa26e4c60d
children 664d83fb04f9
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %PAGESIZE 1000
6 %crefref
7 %noincl
8 %nomacs
9 ifdef NO386
10 p8086
11 else
12 p386
13 endif
15 group DGROUP _TEXT,_BSS
16 assume cs:DGROUP,ds:DGROUP
18 segment _BSS byte public use16 'BSS'
20 global _imgs:dword
22 ends _BSS
25 segment _TEXT byte public use16 'CODE'
27 ;***************************************************************
28 ;void dos_shutdown()
29 ;***************************************************************
31 macro dos_shutdown
32 xor si,si
33 mov ds,si
34 ifndef NO386
35 push [dword si+4] ; save step
36 mov [word si+4],offset step19
37 else
38 mov ax,offset step19
39 xchg ax,[word si+4]
40 push [word si+6]
41 push ax ; save step
42 endif
43 mov [word cs:sssp],sp
44 ;cmp [byte si+7],0F0h
45 ;jnc notdos
46 mov [si+6],cs
47 pushf
48 pushf
49 pop ax
50 inc ah ; set TF
51 push ax
52 popf
53 call [dword si+4*19h]
54 notdos:
55 ifndef NO386
56 lss sp,[dword cs:sssp]
57 else
58 lds ax,[dword cs:sssp]
59 push ds
60 pop ss
61 xchg ax,sp
62 endif
63 xor si,si
64 mov ds,si
65 pop [dword si+4] ; restore step
66 endm
67 macro step19code
68 step19:
69 push si
70 push ds
71 mov si,sp
72 lds si,[dword ss:si+4] ; read cs:ip
73 cmp [word si],19CDh ; int 19h ?
74 pop ds
75 pop si
76 je notdos
77 iret
78 endm
81 ;***************************************************************
82 ;void boot_kernel();
83 ;****** Never returns
84 ;***************************************************************
85 global _boot_kernel:near
86 proc _boot_kernel near
88 ifdef NO386
89 p8086
90 else
91 p386
92 endif
93 ;cli ; we start doing destructive things to DOS
94 extrn sssp:word
95 mov es,[sssp+2]
96 push es
97 pop ss
98 mov sp,0A000h
99 extrn _csip:dword
100 ifdef NO386
101 mov si,offset _csip
102 lodsw
103 push [word si]
104 push ax
105 else
106 push [dword _csip]
107 endif
109 ifdef NO386
110 mov cx,ss
111 add ch,9
112 push cx ; topseg()+0x0900
113 else
114 push 9800h+(4096/16) ; 4096 bytes for cmdline
115 endif
117 extrn _cmdline:word
118 mov si,[_cmdline]
119 mov di,8000h
120 mov ch,10h ; 4k
121 rep
122 movsb
124 mov cl,0 ; load high ?
125 org $-1
126 global _pm_high:byte
127 _pm_high db ?
128 inc cx
129 push cx
130 mov ax,[word ss:024Ch]
131 xor ax,2b30h ; ipxe ?
132 loopne @@notipxe
134 ; finish loading
135 extrn @last_ditch$qv:near
136 push cs
137 call @last_ditch$qv
138 dos_shutdown ; clear si; ds=0; kill VCPI
139 push cs
140 pop ds
142 @@notipxe:
143 pop cx
144 pop es ; min 2048 bytes for stack
145 loop @@isbzimage
147 ; self move
148 ;cld
149 extrn gdt_data
150 mov cx,offset gdt_data+8
151 xor di,di ; A000 -9000 -0800(>movedend)
152 rep
153 movsb
154 mov si,offset _imgs+2
155 lodsw
156 xchg ax,bx ; get pm->fallback low word
157 lodsw ; get pm->fallback high word
158 ifdef MOVE_SETUP
159 mov si,0
160 global _rm_offset:word
161 org $-2
162 _rm_offset dw ?
163 endif
164 push es
165 call near @@isbzimage ; pop cs ; ds=es=ss
167 ; prepare memcpy32 size & srcofs param to move zImage pm
168 ifndef NO386
169 push 8 ; size hi
170 else
171 mov dx,8
172 push dx ; size hi
173 endif
174 push cx ; size lo=up to 512k
175 push ax ; src ofs hi = pm.fallback
177 ;in al,70h
178 ;or al,80h ; disable NMI
179 ;out 70h,al
181 push bx ; src ofs lo
182 xor di,di
183 push di ; src seg=0
184 inc cx
185 push cx ; dst ofs hi
186 push di ; dst ofs lo : 64k
187 extrn memcpy32:near
188 call memcpy32
190 ifdef MOVE_SETUP
191 ;xor di,di
192 mov cx,8000h
193 ;sub cx,si
194 rep
195 movsb
196 endif
198 ifndef noelks
199 ifndef NO386
200 cmp [dword 1E6h],'SKLE'
201 jne @@notelks
202 xor si,si
203 else
204 mov si,1E6h
205 lodsw
206 cmp ax,'LE'
207 jne @@notelks
208 lodsw
209 xor ax,'SK'
210 jne @@notelks
211 xchg ax,si
212 endif
213 ifdef MOVE_SETUP
214 mov ch,1h ; DS=ES=SS=0100
215 else
216 mov cx,100h ; DS=ES=SS=0100
217 endif
218 mov ss,cx
219 mov es,cx
220 mov cl,20h ; CS=0120
221 push cx
222 push si ; IP=0000
223 mov ch,3Fh ; 05h min, 3Fh max
224 rep
225 movsw
226 @@notelks:
227 endif
228 @@isbzimage:
229 push ss
230 pop ds
231 push ss
232 pop es
233 ifndef NO386
234 push ss
235 pop fs
236 push ss
237 pop gs
238 endif
239 assume nothing
240 assume cs:DGROUP
241 retf
243 step19code
245 endp _boot_kernel
247 movedend:
249 ends _TEXT
251 end
253 ;###### END OF FILE ############################################