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

linld: memcpy32 may need N_LXLSH@ & N_LXURSH@4
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Oct 20 21:17:14 2018 +0200 (2018-10-20)
parents 12f4a776eaa7
children 81a3d87e0965
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
96 ifdef NO386
97 sssp:
98 extrn _topseg:near
99 call near _topseg
100 mov cl,4
101 mov [word sssp+2],ax
102 xchg ax,bx
103 mov ax,[_heap_top]
104 shr ax,cl
105 else
106 p386
107 mov ax,[_heap_top]
108 ;shr ax,4
109 db 0C1h,0E8h
110 sssp:
111 db 4
112 mov bx,9000h
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 _csip:dword
129 push [dword _csip]
130 extrn _rm_size:word
131 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
132 lodsw
133 xchg ax,cx ; _rm_size
134 lodsb ; _pm_high
135 mov si,[si] ; _rm_buf
136 xor di,di
137 ;cld
138 rep
139 movsb
140 extrn _cmdline:word
141 mov si,[_cmdline]
142 mov di,8000h
143 mov ch,10h ; 4k
144 rep
145 movsb
146 ifdef NO386
147 add bh,9
148 endif
149 cmp al,cl ; load high ?
150 ifdef noelks
151 jne @@isbzimage
152 else
153 jne @@isbzimagez
154 endif
155 ifdef NO386
156 push bx ; topseg()+0x0900
157 else
158 push 9800h+(4096/16) ; 4096 bytes for cmdline
159 endif
160 ; finish loading
161 extrn @last_ditch$qv:near
162 push cs
163 call @last_ditch$qv
164 ; self move
165 ;cld
166 pop es ; min 2048 bytes for stack
167 mov cx,offset movedend
168 xor si,si ; A000 -9000 -0800(>movedend)
169 xor di,di ; set ZF
170 rep
171 movsb
172 mov ax,[word _imgs+2+2] ; get pm->fallback high word
174 ; prepare memcpy32 size & srcofs param to move zImage pm
175 mov dx,8
176 cmp ax,dx ; buf > 80000h ?
177 ja @@bufhigh
178 sub dx,ax
179 inc dx ; up to 90000h-1
180 @@bufhigh:
181 push dx ; size hi
182 push cx ; size lo=up to 512k
183 push ax ; src ofs ho = pm.fallback
185 push es
186 dos_shutdown ; clear di
187 call near @@isbzimage ; pop cs ; ds=es=ss
188 ;in al,70h
189 ;or al,80h ; disable NMI
190 ;out 70h,al
192 push di ; src ofs lo
193 push di ; src seg=0
194 ifdef NO386
195 inc di
196 push di ; dst ofs hi
197 dec di
198 else
199 push 1 ; dst ofs hi
200 endif
201 push di ; dst ofs lo : 64k
202 extrn _memcpy32:near
203 call _memcpy32
204 add sp,14
206 ifndef noelks
207 ifndef NO386
208 cmp [dword 1E6h],'SKLE'
209 jne @@notelks
210 xor si,si
211 else
212 mov si,1E6h
213 lodsw
214 cmp ax,'LE'
215 jne @@notelks
216 lodsw
217 xor ax,'SK'
218 jne @@notelks
219 xchg ax,si
220 endif
221 push es
222 pop ss
223 mov cx,120h ; CS=0120
224 push cx
225 push si ; IP=0000
226 mov cl,0 ; DS=ES=SS=0100
227 mov es,cx
228 mov ch,05h ; 500h mini
229 rep
230 @@isbzimagez:
231 movsw
232 @@notelks:
233 endif
234 @@isbzimage:
235 push ss
236 pop ds
237 push ss
238 pop es
239 ifndef NO386
240 push ss
241 pop fs
242 push ss
243 pop gs
244 endif
245 assume nothing
246 assume cs:DGROUP
247 retf
249 step19code
251 endp _boot_kernel
253 movedend:
255 ends _TEXT
257 end
259 ;###### END OF FILE ############################################