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

linld: hack for VCPI
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 06 21:02:18 2019 +0100 (10 months ago)
parents db46d017dfe4
children 10fa26e4c60d
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 _rm_size:word
100 ifdef NO386
101 mov si,offset _rm_size-4 ; _rm_size, _pm_high, _rm_buf
102 lodsw
103 xchg ax,bx
104 lodsw
105 push ax ; _csip high
106 push bx ; _csip low
107 lodsw ; skip _rm_size
108 else
109 mov si,offset _rm_size+2 ; _rm_size, _pm_high, _rm_buf
110 push [dword si-6] ; _csip
111 endif
112 lodsb ; _pm_high
114 ifdef NO386
115 mov cx,ss
116 add ch,9
117 push cx ; topseg()+0x0900
118 else
119 push 9800h+(4096/16) ; 4096 bytes for cmdline
120 endif
122 extrn _cmdline:word
123 mov si,[_cmdline]
124 mov di,8000h
125 mov ch,10h ; 4k
126 rep
127 movsb
129 or cl,al ; load high ?
130 inc cx
131 push cx
132 mov ax,[word ss:024Ch]
133 xor ax,2b30h ; ipxe ?
134 loopne @@notipxe
136 ; finish loading
137 extrn @last_ditch$qv:near
138 push cs
139 call @last_ditch$qv
140 dos_shutdown ; clear si; ds=0; kill VCPI
141 push cs
142 pop ds
144 @@notipxe:
145 pop cx
146 pop es ; min 2048 bytes for stack
147 loop @@isbzimage
149 ; self move
150 ;cld
151 extrn gdt_data
152 mov cx,offset gdt_data+8
153 xor di,di ; A000 -9000 -0800(>movedend)
154 rep
155 movsb
156 mov si,offset _imgs+2
157 lodsw
158 xchg ax,bx ; get pm->fallback low word
159 lodsw ; get pm->fallback high word
160 push es
161 call near @@isbzimage ; pop cs ; ds=es=ss
163 ; prepare memcpy32 size & srcofs param to move zImage pm
164 ifndef NO386
165 push 8 ; size hi
166 else
167 mov dx,8
168 push dx ; size hi
169 endif
170 push cx ; size lo=up to 512k
171 push ax ; src ofs hi = pm.fallback
173 ;in al,70h
174 ;or al,80h ; disable NMI
175 ;out 70h,al
177 push bx ; src ofs lo
178 xor di,di
179 push di ; src seg=0
180 inc cx
181 push cx ; dst ofs hi
182 push di ; dst ofs lo : 64k
183 extrn memcpy32:near
184 call memcpy32
186 ifndef noelks
187 ifndef NO386
188 cmp [dword 1E6h],'SKLE'
189 jne @@notelks
190 xor si,si
191 else
192 mov si,1E6h
193 lodsw
194 cmp ax,'LE'
195 jne @@notelks
196 lodsw
197 xor ax,'SK'
198 jne @@notelks
199 xchg ax,si
200 endif
201 mov cx,100h ; DS=ES=SS=0100
202 mov ss,cx
203 mov es,cx
204 mov cl,20h ; CS=0120
205 push cx
206 push si ; IP=0000
207 mov ch,3Fh ; 05h min, 3Fh max
208 rep
209 movsw
210 @@notelks:
211 endif
212 @@isbzimage:
213 push ss
214 pop ds
215 push ss
216 pop es
217 ifndef NO386
218 push ss
219 pop fs
220 push ss
221 pop gs
222 endif
223 assume nothing
224 assume cs:DGROUP
225 retf
227 step19code
229 endp _boot_kernel
231 movedend:
233 ends _TEXT
235 end
237 ;###### END OF FILE ############################################