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

linld: spare up to 30k more for zImage
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 08 20:55:40 2019 +0100 (4 weeks ago)
parents 306a4bbdee7d
children 65ea21135647
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 ifdef MOVE_SETUP
161 mov si,0
162 global _rm_offset:word
163 org $-2
164 _rm_offset dw ?
165 endif
166 push es
167 call near @@isbzimage ; pop cs ; ds=es=ss
169 ; prepare memcpy32 size & srcofs param to move zImage pm
170 ifndef NO386
171 push 8 ; size hi
172 else
173 mov dx,8
174 push dx ; size hi
175 endif
176 push cx ; size lo=up to 512k
177 push ax ; src ofs hi = pm.fallback
179 ;in al,70h
180 ;or al,80h ; disable NMI
181 ;out 70h,al
183 push bx ; src ofs lo
184 xor di,di
185 push di ; src seg=0
186 inc cx
187 push cx ; dst ofs hi
188 push di ; dst ofs lo : 64k
189 extrn memcpy32:near
190 call memcpy32
192 ifdef MOVE_SETUP
193 ;xor di,di
194 mov cx,8000h
195 ;sub cx,si
196 rep
197 movsb
198 endif
200 ifndef noelks
201 ifndef NO386
202 cmp [dword 1E6h],'SKLE'
203 jne @@notelks
204 xor si,si
205 else
206 mov si,1E6h
207 lodsw
208 cmp ax,'LE'
209 jne @@notelks
210 lodsw
211 xor ax,'SK'
212 jne @@notelks
213 xchg ax,si
214 endif
215 mov cx,100h ; DS=ES=SS=0100
216 mov ss,cx
217 mov es,cx
218 mov cl,20h ; CS=0120
219 push cx
220 push si ; IP=0000
221 mov ch,3Fh ; 05h min, 3Fh max
222 rep
223 movsw
224 @@notelks:
225 endif
226 @@isbzimage:
227 push ss
228 pop ds
229 push ss
230 pop es
231 ifndef NO386
232 push ss
233 pop fs
234 push ss
235 pop gs
236 endif
237 assume nothing
238 assume cs:DGROUP
239 retf
241 step19code
243 endp _boot_kernel
245 movedend:
247 ends _TEXT
249 end
251 ;###### END OF FILE ############################################