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

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