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