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@19899
|
169 mov ax,[word _imgs+2+2] ; get pm->fallback high word
|
pascal@19515
|
170 ; self move
|
pascal@19571
|
171 ;cld
|
pascal@19538
|
172 pop es ; min 2048 bytes for stack
|
pascal@19538
|
173 xor si,si ; A000 -9000 -0800(>movedend)
|
pascal@19515
|
174 xor di,di ; set ZF
|
pascal@19538
|
175 mov cx,offset movedend
|
pascal@19515
|
176 rep
|
pascal@19515
|
177 movsb
|
pascal@20473
|
178 push ax
|
pascal@19515
|
179 push es
|
pascal@20473
|
180 dos_shutdown ; clear bx
|
pascal@20475
|
181 call near @@isbzimage ; pop cs ; ds=es=ss
|
pascal@19538
|
182 ;in al,70h
|
pascal@19538
|
183 ;or al,80h ; disable NMI
|
pascal@19538
|
184 ;out 70h,al
|
pascal@20473
|
185 pop dx
|
pascal@19515
|
186 ; move zImage pm
|
pascal@19515
|
187 mov ax,8
|
pascal@20475
|
188 cmp dx,ax ; buf > 80000h ?
|
pascal@19905
|
189 ja @@bufhigh
|
pascal@20473
|
190 sub ax,dx
|
pascal@20475
|
191 inc ax ; up to 90000h-1
|
pascal@19905
|
192 @@bufhigh:
|
pascal@19515
|
193 push ax
|
pascal@20473
|
194 push bx ; size=up to 512k
|
pascal@20473
|
195 push dx ; src ofs= pm.fallback
|
pascal@20473
|
196 push bx
|
pascal@20473
|
197 push bx ; srcseg=0
|
pascal@19636
|
198 ifdef NO386
|
pascal@20473
|
199 inc bx
|
pascal@20473
|
200 push bx ; dst
|
pascal@20473
|
201 dec bx
|
pascal@19636
|
202 else
|
pascal@19636
|
203 push 1 ; dst
|
pascal@19636
|
204 endif
|
pascal@20473
|
205 push bx ; ofs=64k
|
pascal@19515
|
206 extrn _memcpy32:near
|
pascal@19515
|
207 call _memcpy32
|
pascal@19538
|
208 add sp,14
|
pascal@19515
|
209
|
pascal@19515
|
210 ifndef noelks
|
pascal@19515
|
211 ifndef NO386
|
pascal@19515
|
212 cmp [dword 1E6h],'SKLE'
|
pascal@20473
|
213 jne @@notelks
|
pascal@20473
|
214 @@isbzimagez:
|
pascal@20473
|
215 jne @@isbzimage
|
pascal@19515
|
216 else
|
pascal@19515
|
217 cmp [word 1E6h],'LE'
|
pascal@19905
|
218 jne @@notelks
|
pascal@20473
|
219 @@isbzimagez:
|
pascal@20473
|
220 jne @@isbzimage
|
pascal@19515
|
221 cmp [word 1E8h],'SK'
|
pascal@20473
|
222 jne @@notelks
|
pascal@19515
|
223 endif
|
pascal@20475
|
224 mov cx,100h ; DS=ES=SS=0100
|
pascal@20475
|
225 mov es,cx
|
pascal@20475
|
226 mov ch,05h ; 500h mini
|
pascal@19515
|
227 xor si,si
|
pascal@19515
|
228 xor di,di
|
pascal@19515
|
229 rep
|
pascal@19515
|
230 movsw
|
pascal@19515
|
231 push es
|
pascal@19515
|
232 pop ss
|
pascal@20475
|
233 ifdef NO386
|
pascal@20475
|
234 mov ax,120h ; CS=0120
|
pascal@20475
|
235 push ax
|
pascal@20475
|
236 else
|
pascal@20475
|
237 push 120h ; CS=0120
|
pascal@20475
|
238 endif
|
pascal@20473
|
239 push cx ; IP=0000
|
pascal@19905
|
240 @@notelks:
|
pascal@19515
|
241 endif
|
pascal@19905
|
242 @@isbzimage:
|
pascal@19515
|
243 push ss
|
pascal@19515
|
244 pop ds
|
pascal@20475
|
245 push ss
|
pascal@20475
|
246 pop es
|
pascal@19636
|
247 ifndef NO386
|
pascal@19515
|
248 push ss
|
pascal@19515
|
249 pop fs
|
pascal@19515
|
250 push ss
|
pascal@19515
|
251 pop gs
|
pascal@19636
|
252 endif
|
pascal@19515
|
253 assume nothing
|
pascal@19515
|
254 assume cs:DGROUP
|
pascal@19515
|
255 retf
|
pascal@19515
|
256
|
pascal@20473
|
257 step19code
|
pascal@19515
|
258 movedend:
|
pascal@19905
|
259 endp _boot_kernel
|
pascal@19515
|
260
|
pascal@19515
|
261 ends _TEXT
|
pascal@19515
|
262
|
pascal@19515
|
263 end
|
pascal@19515
|
264
|
pascal@19515
|
265 ;###### END OF FILE ############################################
|