wok-6.x view linld/stuff/src/JUMP.ASM @ rev 21332
Up libltdl (2.4.6), mtp-tools (1.1.16)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Apr 19 15:52:41 2019 +0200 (2019-04-19) |
parents | cbcb33ee9044 |
children | 15e8d94fc34f |
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 ifdef NO386
9 p8086
10 else
11 p386
12 endif
14 group DGROUP _TEXT,_DATA,_BSS
15 assume cs:DGROUP,ds:DGROUP
17 segment _DATA byte public use16 'DATA'
19 overflow db "Loaded too close to 9000:0",0
21 ends _DATA
23 segment _BSS byte public use16 'BSS'
25 global _imgs:dword
27 ends _BSS
30 segment _TEXT byte public use16 'CODE'
32 ;***************************************************************
33 ;void dos_shutdown()
34 ;***************************************************************
36 macro dos_shutdown
37 xor di,di
38 mov ds,di
39 ifndef NO386
40 push [dword di+4] ; save step
41 mov [word di+4],offset step19
42 else
43 mov ax,offset step19
44 xchg ax,[word di+4]
45 push [word di+6]
46 push ax ; save step
47 endif
48 mov [word cs:sssp],sp
49 ;cmp [byte di+7],0F0h
50 ;jnc notdos
51 mov [di+6],cs
52 pushf
53 pushf
54 pop ax
55 inc ah ; set TF
56 push ax
57 popf
58 call [dword di+4*19h]
59 notdos:
60 ifndef NO386
61 lss sp,[dword cs:sssp]
62 else
63 lds ax,[dword cs:sssp]
64 push ds
65 pop ss
66 xchg ax,sp
67 endif
68 xor di,di
69 mov ds,di
70 pop [dword di+4] ; restore step
71 endm
72 macro step19code
73 step19:
74 push di
75 push ds
76 mov di,sp
77 lds di,[dword ss:di+4] ; read cs:ip
78 cmp [word di],19CDh ; int 19h ?
79 pop ds
80 pop di
81 je notdos
82 iret
83 endm
86 ;***************************************************************
87 ;void boot_kernel();
88 ;****** Never returns
89 ;***************************************************************
90 global _boot_kernel:near
91 proc _boot_kernel near
93 p8086
94 extrn _heap_top:word
95 global sssp:dword
96 ifdef NO386
97 extrn _topseg:near
98 call near _topseg
99 mov cl,4
100 org $-4
101 sssp dd ?
102 mov [word sssp+2],ax
103 xchg ax,bx
104 mov ax,[_heap_top]
105 shr ax,cl
106 else
107 p386
108 mov ax,[_heap_top]
109 shr ax,4
110 mov bx,9000h
111 org $-4
112 sssp dd ?
113 endif
114 mov es,bx
115 mov dx,cs
116 add ax,dx
117 cmp ax,bx
118 jb @@nooverflow
119 ; Oops! We can stomp on our toes... better stop now
120 mov bx,offset overflow
121 extrn die:near
122 call near die
123 @@nooverflow:
124 ;cli ; we start doing destructive things to DOS
125 push es
126 pop ss
127 mov sp,0A000h
128 extrn _rm_size:word
129 ifdef NO386
130 mov si,offset _rm_size-2 ; _rm_size, _pm_high, _rm_buf
131 lodsw
132 push ax ; _csip high
133 push [word si-4] ; _csip low
134 else
135 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
136 push [dword si-4] ; _csip
137 endif
138 lodsw
139 xchg ax,cx ; _rm_size
140 lodsb ; _pm_high
141 mov si,[si] ; _rm_buf
142 xor di,di
143 ;cld
144 rep
145 movsb
146 extrn _cmdline:word
147 mov si,[_cmdline]
148 mov di,8000h
149 mov ch,10h ; 4k
150 rep
151 movsb
152 ifdef NO386
153 add bh,9
154 push bx ; topseg()+0x0900
155 else
156 push 9800h+(4096/16) ; 4096 bytes for cmdline
157 endif
158 cmp al,cl ; load high ?
159 pushf
160 ; finish loading
161 extrn @last_ditch$qv:near
162 mov ax,[ss:024Ch]
163 jne @@notzimage
164 @@isipxe:
165 push cs
166 call @last_ditch$qv
167 dos_shutdown ; clear di; ds=0
168 push cs
169 pop ds
170 @@notzimage:
171 xor ax,2b30h
172 je @@isipxe
173 popf
174 ; self move
175 ;cld
176 pop es ; min 2048 bytes for stack
177 jne @@isbzimage
178 extrn gdt_data
179 mov cx,offset gdt_data+8
180 xor si,si ; A000 -9000 -0800(>movedend)
181 rep
182 movsb
183 mov ax,[word _imgs+2+2] ; get pm->fallback high word
184 push es
185 call near @@isbzimage ; pop cs ; ds=es=ss
187 ; prepare memcpy32 size & srcofs param to move zImage pm
188 mov dx,8
189 cmp ax,dx ; buf > 80000h ?
190 ja @@bufhigh
191 sub dx,ax
192 inc dx ; up to 90000h-1
193 @@bufhigh:
194 push dx ; size hi
195 push cx ; size lo=up to 512k
196 push ax ; src ofs ho = pm.fallback
198 ;in al,70h
199 ;or al,80h ; disable NMI
200 ;out 70h,al
202 xor di,di
203 push di ; src ofs lo
204 push di ; src seg=0
205 ifdef NO386
206 inc di
207 push di ; dst ofs hi
208 dec di
209 else
210 push 1 ; dst ofs hi
211 endif
212 push di ; dst ofs lo : 64k
213 extrn memcpy32:near
214 call memcpy32
216 ifndef noelks
217 ifndef NO386
218 cmp [dword 1E6h],'SKLE'
219 jne @@notelks
220 xor si,si
221 else
222 mov si,1E6h
223 lodsw
224 cmp ax,'LE'
225 jne @@notelks
226 lodsw
227 xor ax,'SK'
228 jne @@notelks
229 xchg ax,si
230 endif
231 push es
232 pop ss
233 mov cx,120h ; CS=0120
234 push cx
235 push si ; IP=0000
236 mov cl,0 ; DS=ES=SS=0100
237 mov es,cx
238 mov ch,05h ; 500h mini
239 rep
240 movsw
241 @@notelks:
242 endif
243 @@isbzimage:
244 push ss
245 pop ds
246 push ss
247 pop es
248 ifndef NO386
249 push ss
250 pop fs
251 push ss
252 pop gs
253 endif
254 assume nothing
255 assume cs:DGROUP
256 retf
258 step19code
260 endp _boot_kernel
262 movedend:
264 ends _TEXT
266 end
268 ;###### END OF FILE ############################################