wok-current view linld/stuff/src/JUMP.ASM @ rev 21628
linld: more ram for zImage (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon May 27 23:23:13 2019 +0200 (2019-05-27) |
parents | 15e8d94fc34f |
children | 2373992ff751 |
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 si,si
38 mov ds,si
39 ifndef NO386
40 push [dword si+4] ; save step
41 mov [word si+4],offset step19
42 else
43 mov ax,offset step19
44 xchg ax,[word si+4]
45 push [word si+6]
46 push ax ; save step
47 endif
48 mov [word cs:sssp],sp
49 ;cmp [byte si+7],0F0h
50 ;jnc notdos
51 mov [si+6],cs
52 pushf
53 pushf
54 pop ax
55 inc ah ; set TF
56 push ax
57 popf
58 call [dword si+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 si,si
69 mov ds,si
70 pop [dword si+4] ; restore step
71 endm
72 macro step19code
73 step19:
74 push si
75 push ds
76 mov si,sp
77 lds si,[dword ss:si+4] ; read cs:ip
78 cmp [word si],19CDh ; int 19h ?
79 pop ds
80 pop si
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 si; 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 di,di ; A000 -9000 -0800(>movedend)
181 rep
182 movsb
183 mov si,offset _imgs+2
184 lodsw
185 xchg ax,bx ; get pm->fallback low word
186 lodsw ; get pm->fallback high word
187 push es
188 call near @@isbzimage ; pop cs ; ds=es=ss
190 ; prepare memcpy32 size & srcofs param to move zImage pm
191 mov dx,8
192 cmp ax,dx ; buf > 80000h ?
193 ja @@bufhigh
194 sub dx,ax
195 inc dx ; up to 90000h-1
196 @@bufhigh:
197 push dx ; size hi
198 push cx ; size lo=up to 512k
199 push ax ; src ofs hi = pm.fallback
201 ;in al,70h
202 ;or al,80h ; disable NMI
203 ;out 70h,al
205 push bx ; src ofs lo
206 xor di,di
207 push di ; src seg=0
208 inc cx
209 push cx ; dst ofs hi
210 push di ; dst ofs lo : 64k
211 extrn memcpy32:near
212 call memcpy32
214 ifndef noelks
215 ifndef NO386
216 cmp [dword 1E6h],'SKLE'
217 jne @@notelks
218 xor si,si
219 else
220 mov si,1E6h
221 lodsw
222 cmp ax,'LE'
223 jne @@notelks
224 lodsw
225 xor ax,'SK'
226 jne @@notelks
227 xchg ax,si
228 endif
229 push es
230 pop ss
231 mov cx,120h ; CS=0120
232 push cx
233 push si ; IP=0000
234 mov cl,0 ; DS=ES=SS=0100
235 mov es,cx
236 mov ch,05h ; 500h mini
237 rep
238 movsw
239 @@notelks:
240 endif
241 @@isbzimage:
242 push ss
243 pop ds
244 push ss
245 pop es
246 ifndef NO386
247 push ss
248 pop fs
249 push ss
250 pop gs
251 endif
252 assume nothing
253 assume cs:DGROUP
254 retf
256 step19code
258 endp _boot_kernel
260 movedend:
262 ends _TEXT
264 end
266 ;###### END OF FILE ############################################