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