wok-6.x view linld/stuff/src/JUMP.ASM @ rev 23806
linld: add isoboot
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun May 24 16:16:52 2020 +0000 (2020-05-24) |
parents | 664d83fb04f9 |
children | fc88d0826de4 |
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 ISOHOOK
89 extrn iso_cleanup_hack:word
90 call [iso_cleanup_hack] ; or ret
91 endif
92 ifdef NO386
93 p8086
94 else
95 p386
96 endif
97 ;cli ; we start doing destructive things to DOS
98 extrn sssp:word
99 mov ax,[sssp+2]
100 mov es,ax
101 extrn _cmdline:word
102 mov si,[_cmdline]
103 mov di,8000h
104 mov cx,2000h ; 4k for cmdline + 4k up to sp
105 rep
106 movsb
107 push es
108 pop ss
109 mov sp,di
111 mov dx,2000h
112 global _csip_hilo:word
113 org $-2
114 _csip_hilo dw ?
115 xchg al,dh ; 9020 / 9000
116 push ax
117 push dx ; 0000 / 0042
119 mov cl,1 ; load high ?
120 org $-1
121 global _pm_low:byte
122 _pm_low db ?
123 push cx
124 mov ax,[word ss:024Ch]
125 xor ax,2b30h ; ipxe ?
126 loopne @@notipxe
128 ; finish loading
129 extrn @last_ditch$qv:near
130 push cs
131 call @last_ditch$qv
132 dos_shutdown ; clear si; ds=0; kill VCPI
133 push cs
134 pop ds
136 @@notipxe:
137 pop cx
138 loop @@isbzimage
140 ; prepare memcpy32 size & srcofs param to move zImage pm
141 ifndef NO386
142 push 8 ; size hi
143 else
144 mov dx,8
145 push dx ; size hi
146 endif
147 push si ; size lo=up to 512k
148 push [dword _imgs+2] ; src ofs = pm.fallback
150 ;in al,70h
151 ;or al,80h ; disable NMI
152 ;out 70h,al
154 push si ; src seg=0
155 inc cx
156 push cx ; dst ofs hi
157 push si ; dst ofs lo : 64k
159 ; self move
160 extrn gdt_data
161 mov cx,offset gdt_data+8
162 ;xor di,di ; A000 -9000 -0800(>movedend)
164 ifdef NO386
165 mov ax,ss
166 add ax,900h
167 push ax ; topseg()+0x0900
168 else
169 push 9800h+(4096/16) ; 4096 bytes for cmdline
170 endif
171 pop es
172 push es
174 call near @@movsb@jmp ; movsb; pop cs ; ds=es=ss
176 extrn memcpy32:near
177 call memcpy32
179 ifdef MOVE_SETUP
180 mov si,0
181 global _rm_offset:word
182 org $-2
183 _rm_offset dw ?
184 ;xor di,di
185 ;mov cx,8000h
186 ;sub cx,si
187 ;rep
188 ; movsb
189 endif
191 ifndef noelks
192 ifdef MOVE_SETUP
193 ifndef NO386
194 mov eax,[dword si+1E6h]
195 xor eax,'SKLE'
196 else
197 mov ax,[si+1E6h]
198 xor ax,'LE'
199 jne @@notelks
200 mov ax,[si+1E8h]
201 xor ax,'SK'
202 endif
203 else
204 ifndef NO386
205 mov eax,[dword 1E6h]
206 xor eax,'SKLE'
207 else
208 mov ax,[1E6h]
209 xor ax,'LE'
210 jne @@notelks
211 mov ax,[1E8h]
212 xor ax,'SK'
213 endif
214 endif
215 jne @@notelks
216 mov cx,100h ; DS=ES=SS=0100
217 mov ss,cx
218 push ss
219 pop es
220 mov cl,20h ; CS=0120
221 push cx
222 push ax ; IP=0000
223 endif
224 ifdef MOVE_SETUP
225 @@notelks:
226 mov ch,7Eh
227 @@movsb@jmp:
228 xor di,di
229 rep
230 movsb
231 else
232 ifndef noelks
233 xchg ax,si
234 mov ch,7Eh ; 0Ah min, 7Eh max
235 @@movsb@jmp:
236 xor di,di
237 rep
238 movsb
239 @@notelks:
240 endif
241 endif
242 @@isbzimage:
243 push ss
244 pop ds
245 push ss
246 pop es
247 ifndef NO386
248 push ss
249 pop fs
250 push ss
251 pop gs
252 endif
253 assume nothing
254 assume cs:DGROUP
255 retf
257 step19code
259 endp _boot_kernel
261 movedend:
263 ends _TEXT
265 end
267 ;###### END OF FILE ############################################