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

linld: add iso support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 08 20:15:35 2021 +0000 (2021-01-08)
parents 431c14b76522
children bc4b94310a29
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
16 assume cs:DGROUP,ds:DGROUP
18 segment _TEXT byte public use16 'CODE'
20 ;***************************************************************
21 ;void dos_shutdown()
22 ;***************************************************************
24 macro dos_shutdown
25 xor si,si
26 mov ds,si
27 ifndef NO386
28 push [dword si+4] ; save step
29 mov [word si+4],offset step19
30 else
31 mov ax,offset step19
32 xchg ax,[word si+4]
33 push [word si+6]
34 push ax ; save step
35 endif
36 mov [word cs:sssp],sp
37 ;cmp [byte si+7],0F0h
38 ;jnc notdos
39 mov [si+6],cs
40 pushf
41 pushf
42 pop ax
43 inc ah ; set TF
44 push ax
45 popf
46 call [dword si+4*19h]
47 notdos:
48 ifndef NO386
49 lss sp,[dword cs:sssp]
50 else
51 lds ax,[dword cs:sssp]
52 push ds
53 pop ss
54 xchg ax,sp
55 endif
56 xor si,si
57 mov ds,si
58 pop [dword si+4] ; restore step
59 endm
60 macro step19code
61 step19:
62 push si
63 push ds
64 mov si,sp
65 lds si,[dword ss:si+4] ; read cs:ip
66 cmp [word si],19CDh ; int 19h ?
67 pop ds
68 pop si
69 je notdos
70 iret
71 endm
74 ;***************************************************************
75 ;void boot_kernel();
76 ;****** Never returns
77 ;***************************************************************
78 global _boot_kernel:near
79 proc _boot_kernel near
81 ifdef NO386
82 p8086
83 else
84 p386
85 endif
86 ;cli ; we start doing destructive things to DOS
87 extrn sssp:word
88 mov ax,[sssp+2]
89 mov es,ax
90 extrn _cmdstr:word
91 _cmdline = _cmdstr+0
92 mov si,[_cmdline]
93 mov di,8000h
94 mov cx,2000h ; 4k for cmdline + 4k up to sp
95 rep
96 movsb
97 push es
98 pop ss
99 mov sp,di
101 mov dx,2000h
102 global _csip_hilo:word
103 org $-2
104 _csip_hilo dw ?
105 xchg al,dh ; 9020 / 9000
106 push ax
107 push dx ; 0000 / 0042
109 mov cl,1 ; load high ?
110 org $-1
111 global _pm_low:byte
112 _pm_low db ?
113 push cx
114 mov ax,[word ss:024Ch]
115 xor ax,2b30h ; ipxe ?
116 loopne @@notipxe
118 ; finish loading
119 extrn @last_ditch$qv:near
120 push cs
121 call @last_ditch$qv
122 dos_shutdown ; clear si; ds=0; kill VCPI
123 push cs
124 pop ds
126 @@notipxe:
127 pop cx
128 loop @@isbzimage
130 ; prepare memcpy32 size & srcofs param to move zImage pm
131 ifndef NO386
132 push 8 ; size hi
133 else
134 mov dx,8
135 push dx ; size hi
136 endif
137 push si ; size lo=up to 512k
139 include "himem.inc"
141 extrn _imgs:image_himem
142 push [_imgs.fallback] ; src ofs = pm.fallback
144 ;in al,70h
145 ;or al,80h ; disable NMI
146 ;out 70h,al
148 push si ; src seg=0
149 inc cx
150 push cx ; dst ofs hi
151 push si ; dst ofs lo : 64k
153 ; self move
154 extrn gdt_data
155 mov cx,offset gdt_data+8
156 ;xor di,di ; A000 -9000 -0800(>movedend)
158 ifdef NO386
159 mov ax,ss
160 add ax,900h
161 push ax ; topseg()+0x0900
162 else
163 push 9800h+(4096/16) ; 4096 bytes for cmdline
164 endif
165 pop es
166 push es
168 call near @@movsb@jmp ; movsb; pop cs ; ds=es=ss
170 extrn memcpy32:near
171 call memcpy32
173 ifdef MOVE_SETUP
174 mov si,0
175 global _rm_offset:word
176 org $-2
177 _rm_offset dw ?
178 ;xor di,di
179 ;mov cx,8000h
180 ;sub cx,si
181 ;rep
182 ; movsb
183 endif
185 ifndef noelks
186 ifdef MOVE_SETUP
187 ifndef NO386
188 mov eax,[dword si+1E6h]
189 xor eax,'SKLE'
190 else
191 mov ax,[si+1E6h]
192 xor ax,'LE'
193 jne @@notelks
194 mov ax,[si+1E8h]
195 xor ax,'SK'
196 endif
197 else
198 ifndef NO386
199 mov eax,[dword 1E6h]
200 xor eax,'SKLE'
201 else
202 mov ax,[1E6h]
203 xor ax,'LE'
204 jne @@notelks
205 mov ax,[1E8h]
206 xor ax,'SK'
207 endif
208 endif
209 jne @@notelks
210 mov cx,100h ; DS=ES=SS=0100
211 mov ss,cx
212 push ss
213 pop es
214 mov cl,20h ; CS=0120
215 push cx
216 push ax ; IP=0000
217 endif
218 ifdef MOVE_SETUP
219 @@notelks:
220 mov ch,7Eh
221 @@movsb@jmp:
222 xor di,di
223 rep
224 movsb
225 else
226 ifndef noelks
227 xchg ax,si
228 mov ch,7Eh ; 0Ah min, 7Eh max
229 @@movsb@jmp:
230 xor di,di
231 rep
232 movsb
233 @@notelks:
234 endif
235 endif
236 @@isbzimage:
237 push ss
238 pop ds
239 push ss
240 pop es
241 ifndef NO386
242 push ss
243 pop fs
244 push ss
245 pop gs
246 endif
247 assume nothing
248 assume cs:DGROUP
249 retf
251 step19code
253 endp _boot_kernel
255 movedend:
257 ends _TEXT
259 end
261 ;###### END OF FILE ############################################