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@19667
|
8 ifdef NO386
|
pascal@19667
|
9 p8086
|
pascal@19667
|
10 else
|
pascal@19515
|
11 p386
|
pascal@19667
|
12 endif
|
pascal@19515
|
13
|
pascal@20198
|
14 group DGROUP _TEXT,_DATA,_BSS
|
pascal@19515
|
15 assume cs:DGROUP,ds:DGROUP
|
pascal@19515
|
16
|
pascal@20198
|
17 segment _DATA byte public use16 'DATA'
|
pascal@20198
|
18
|
pascal@20198
|
19 overflow db "Loaded too close to 9000:0",0
|
pascal@20198
|
20
|
pascal@20198
|
21 ends _DATA
|
pascal@20198
|
22
|
pascal@19515
|
23 segment _BSS byte public use16 'BSS'
|
pascal@19515
|
24
|
pascal@20198
|
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@19515
|
32 ;***************************************************************
|
pascal@20198
|
33 ;void boot_kernel();
|
pascal@19515
|
34 ;****** Never returns
|
pascal@19515
|
35 ;***************************************************************
|
pascal@20198
|
36 global _boot_kernel:near
|
pascal@20198
|
37 proc _boot_kernel near
|
pascal@20198
|
38
|
pascal@20198
|
39 ; Shrink stack: we won't need much of it now and have no malloc() plans
|
pascal@20198
|
40 extrn _heap_top:word
|
pascal@20198
|
41 mov ax,[_heap_top]
|
pascal@20198
|
42 inc ah
|
pascal@20198
|
43 cmp ax,sp
|
pascal@20198
|
44 ja @@samesp
|
pascal@20198
|
45 xchg ax,sp
|
pascal@20198
|
46 @@samesp:
|
pascal@19667
|
47 ifdef NO386
|
pascal@19667
|
48 extrn _topseg:near
|
pascal@19667
|
49 call near _topseg
|
pascal@19667
|
50 mov es,ax
|
pascal@19667
|
51 xchg ax,bx
|
pascal@20198
|
52 mov cl,4
|
pascal@20198
|
53 mov ax,sp
|
pascal@20198
|
54 shr ax,cl
|
pascal@19667
|
55 else
|
pascal@20198
|
56 mov bx,9000h
|
pascal@20198
|
57 mov es,bx
|
pascal@20198
|
58 mov ax,sp
|
pascal@20198
|
59 shr ax,4
|
pascal@19667
|
60 endif
|
pascal@20198
|
61 mov dx,cs
|
pascal@20198
|
62 add ax,dx
|
pascal@20198
|
63 cmp ax,bx
|
pascal@20198
|
64 jb @@nooverflow
|
pascal@20198
|
65 ; Oops! We can stomp on our toes... better stop now
|
pascal@20198
|
66 mov bx,offset overflow
|
pascal@20198
|
67 extrn die:near
|
pascal@20198
|
68 jmp near die
|
pascal@20198
|
69 @@nooverflow:
|
pascal@19667
|
70 cli ; we start doing destructive things to DOS
|
pascal@19667
|
71 push es
|
pascal@19667
|
72 pop ss
|
pascal@19667
|
73 mov sp,0A000h
|
pascal@20198
|
74 extrn _csip:dword
|
pascal@20198
|
75 push [dword _csip]
|
pascal@19667
|
76 extrn _rm_size:word
|
pascal@19667
|
77 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
|
pascal@19667
|
78 lodsw
|
pascal@19667
|
79 xchg ax,cx ; _rm_size
|
pascal@19667
|
80 lodsb ; _pm_high
|
pascal@19667
|
81 mov si,[si] ; _rm_buf
|
pascal@19667
|
82 xor di,di
|
pascal@19667
|
83 ;cld
|
pascal@19667
|
84 rep
|
pascal@19667
|
85 movsb
|
pascal@19667
|
86 extrn _cmdline:word
|
pascal@19667
|
87 mov si,[_cmdline]
|
pascal@19667
|
88 mov di,8000h
|
pascal@19667
|
89 mov ch,10h ; 4k
|
pascal@19667
|
90 rep
|
pascal@19667
|
91 movsb
|
pascal@19667
|
92 cmp al,cl ; load high ?
|
pascal@20198
|
93 jne @@isbzimage
|
pascal@19667
|
94 ifdef NO386
|
pascal@19667
|
95 add bh,9
|
pascal@19667
|
96 push bx ; topseg()+0x0900
|
pascal@19667
|
97 else
|
pascal@20198
|
98 push 9800h+(4096/16) ; 4096 bytes for cmdline
|
pascal@19667
|
99 endif
|
pascal@19515
|
100 ; finish loading
|
pascal@19515
|
101 extrn @last_ditch$qv:near
|
pascal@19515
|
102 push cs
|
pascal@19515
|
103 call @last_ditch$qv
|
pascal@20198
|
104 mov ax,[word _imgs+2+2] ; get pm->fallback high word
|
pascal@19515
|
105 ; self move
|
pascal@19667
|
106 ;cld
|
pascal@19538
|
107 pop es ; min 2048 bytes for stack
|
pascal@19538
|
108 xor si,si ; A000 -9000 -0800(>movedend)
|
pascal@19515
|
109 xor di,di ; set ZF
|
pascal@19538
|
110 mov cx,offset movedend
|
pascal@19515
|
111 rep
|
pascal@19515
|
112 movsb
|
pascal@19515
|
113 push es
|
pascal@20198
|
114 call near @@doretf ; mov cs,es
|
pascal@19667
|
115 push ss
|
pascal@19667
|
116 pop es
|
pascal@19515
|
117 push cs
|
pascal@19515
|
118 pop ds
|
pascal@19667
|
119 push ax
|
pascal@20198
|
120 extrn dos_shutdown:near
|
pascal@19515
|
121 call near dos_shutdown
|
pascal@19538
|
122 ;in al,70h
|
pascal@19538
|
123 ;or al,80h ; disable NMI
|
pascal@19538
|
124 ;out 70h,al
|
pascal@19538
|
125 pop bx
|
pascal@19515
|
126 ; move zImage pm
|
pascal@19515
|
127 mov ax,8
|
pascal@20198
|
128 cwd ; clear dx
|
pascal@19515
|
129 cmp bx,ax
|
pascal@20198
|
130 ja @@bufhigh
|
pascal@19515
|
131 sub ax,bx
|
pascal@19515
|
132 inc ax
|
pascal@20198
|
133 @@bufhigh:
|
pascal@19515
|
134 push ax
|
pascal@19515
|
135 push dx ; size=up to 512k
|
pascal@19515
|
136 push bx ; src ofs= pm.fallback
|
pascal@19515
|
137 push dx
|
pascal@19515
|
138 push dx ; srcseg=0
|
pascal@19667
|
139 ifdef NO386
|
pascal@19667
|
140 inc dx
|
pascal@19667
|
141 push dx ; dst
|
pascal@19667
|
142 dec dx
|
pascal@19667
|
143 else
|
pascal@19667
|
144 push 1 ; dst
|
pascal@19667
|
145 endif
|
pascal@19515
|
146 push dx ; ofs=64k
|
pascal@19515
|
147 extrn _memcpy32:near
|
pascal@19515
|
148 call _memcpy32
|
pascal@19538
|
149 add sp,14
|
pascal@19515
|
150
|
pascal@19515
|
151 ifndef noelks
|
pascal@19515
|
152 push ss
|
pascal@19515
|
153 pop ds
|
pascal@19515
|
154 ifndef NO386
|
pascal@19515
|
155 cmp [dword 1E6h],'SKLE'
|
pascal@19515
|
156 else
|
pascal@19515
|
157 cmp [word 1E6h],'LE'
|
pascal@20198
|
158 jne @@notelks
|
pascal@19515
|
159 cmp [word 1E8h],'SK'
|
pascal@19515
|
160 endif
|
pascal@20198
|
161 jne @@notelks
|
pascal@19667
|
162 ifdef NO386
|
pascal@19667
|
163 mov cx,120h
|
pascal@19667
|
164 push cx
|
pascal@19667
|
165 mov cl,0h
|
pascal@19667
|
166 push cx
|
pascal@19667
|
167 else
|
pascal@19667
|
168 push 120h
|
pascal@19515
|
169 push 100h
|
pascal@19667
|
170 endif
|
pascal@19515
|
171 pop es
|
pascal@19515
|
172 xor si,si
|
pascal@19515
|
173 xor di,di
|
pascal@19515
|
174 mov ch,05h
|
pascal@19515
|
175 rep
|
pascal@19515
|
176 movsw
|
pascal@19515
|
177 push es
|
pascal@19515
|
178 pop ss
|
pascal@19667
|
179 push cx
|
pascal@20198
|
180 @@notelks:
|
pascal@19515
|
181 endif
|
pascal@20198
|
182 @@isbzimage:
|
pascal@19515
|
183 push ss
|
pascal@19515
|
184 pop ds
|
pascal@19667
|
185 ;push ss
|
pascal@19667
|
186 ;pop es
|
pascal@19667
|
187 ifndef NO386
|
pascal@19515
|
188 push ss
|
pascal@19515
|
189 pop fs
|
pascal@19515
|
190 push ss
|
pascal@19515
|
191 pop gs
|
pascal@19667
|
192 endif
|
pascal@19515
|
193 assume nothing
|
pascal@19515
|
194 assume cs:DGROUP
|
pascal@20198
|
195 @@doretf:
|
pascal@19515
|
196 retf
|
pascal@19515
|
197
|
pascal@19515
|
198 movedend:
|
pascal@20198
|
199 endp _boot_kernel
|
pascal@19515
|
200
|
pascal@19515
|
201 ends _TEXT
|
pascal@19515
|
202
|
pascal@19515
|
203 end
|
pascal@19515
|
204
|
pascal@19515
|
205 ;###### END OF FILE ############################################
|