Rev 3774 | Rev 3796 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3774 | Rev 3777 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;; ;; |
6 | ;; ;; |
7 | ;; BOOTCODE.INC ;; |
7 | ;; BOOTCODE.INC ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
10 | ;; based on bootcode for MenuetOS ;; |
10 | ;; based on bootcode for MenuetOS ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | 13 | ||
14 | $Revision: 3774 $ |
14 | $Revision: 3777 $ |
15 | 15 | ||
16 | 16 | ||
17 | ;========================================================================== |
17 | ;========================================================================== |
18 | ; |
18 | ; |
19 | ; 16 BIT FUNCTIONS |
19 | ; 16 BIT FUNCTIONS |
20 | ; |
20 | ; |
21 | ;========================================================================== |
21 | ;========================================================================== |
22 | 22 | ||
23 | 23 | ||
24 | putchar: |
24 | putchar: |
25 | ; in: al=character |
25 | ; in: al=character |
26 | mov ah, 0Eh |
26 | mov ah, 0Eh |
27 | mov bh, 0 |
27 | mov bh, 0 |
28 | int 10h |
28 | int 10h |
29 | ret |
29 | ret |
30 | 30 | ||
31 | print: |
31 | print: |
32 | ; in: si->string |
32 | ; in: si->string |
33 | mov al, 186 |
33 | mov al, 186 |
34 | call putchar |
34 | call putchar |
35 | mov al, ' ' |
35 | mov al, ' ' |
36 | call putchar |
36 | call putchar |
37 | 37 | ||
38 | printplain: |
38 | printplain: |
39 | ; in: si->string |
39 | ; in: si->string |
40 | pusha |
40 | pusha |
41 | lodsb |
41 | lodsb |
42 | @@: |
42 | @@: |
43 | call putchar |
43 | call putchar |
44 | lodsb |
44 | lodsb |
45 | test al, al |
45 | test al, al |
46 | jnz @b |
46 | jnz @b |
47 | popa |
47 | popa |
48 | ret |
48 | ret |
49 | 49 | ||
50 | getkey: |
50 | getkey: |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
52 | ; in: bx=range |
52 | ; in: bx=range |
53 | ; out: ax=digit (1..9, 10 for 0) |
53 | ; out: ax=digit (1..9, 10 for 0) |
54 | mov ah, 0 |
54 | mov ah, 0 |
55 | int 16h |
55 | int 16h |
56 | cmp al, bl |
56 | cmp al, bl |
57 | jb getkey |
57 | jb getkey |
58 | cmp al, bh |
58 | cmp al, bh |
59 | ja getkey |
59 | ja getkey |
60 | push ax |
60 | push ax |
61 | call putchar |
61 | call putchar |
62 | pop ax |
62 | pop ax |
63 | and ax, 0Fh |
63 | and ax, 0Fh |
64 | jnz @f |
64 | jnz @f |
65 | mov al, 10 |
65 | mov al, 10 |
66 | @@: |
66 | @@: |
67 | ret |
67 | ret |
68 | 68 | ||
69 | setcursor: |
69 | setcursor: |
70 | ; in: dl=column, dh=row |
70 | ; in: dl=column, dh=row |
71 | mov ah, 2 |
71 | mov ah, 2 |
72 | mov bh, 0 |
72 | mov bh, 0 |
73 | int 10h |
73 | int 10h |
74 | ret |
74 | ret |
75 | 75 | ||
76 | macro _setcursor row,column |
76 | macro _setcursor row,column |
77 | { |
77 | { |
78 | mov dx, row*256 + column |
78 | mov dx, row*256 + column |
79 | call setcursor |
79 | call setcursor |
80 | } |
80 | } |
81 | 81 | ||
82 | boot_read_floppy: |
82 | boot_read_floppy: |
83 | push si |
83 | push si |
84 | xor si, si |
84 | xor si, si |
85 | mov ah, 2 ; read |
85 | mov ah, 2 ; read |
86 | @@: |
86 | @@: |
87 | push ax |
87 | push ax |
88 | int 0x13 |
88 | int 0x13 |
89 | pop ax |
89 | pop ax |
90 | jnc @f |
90 | jnc @f |
91 | inc si |
91 | inc si |
92 | cmp si, 10 |
92 | cmp si, 10 |
93 | jb @b |
93 | jb @b |
94 | sayerr_badsect: |
94 | sayerr_badsect: |
95 | mov si, badsect |
95 | mov si, badsect |
96 | sayerr_plain: |
96 | sayerr_plain: |
97 | call printplain |
97 | call printplain |
98 | jmp $ |
98 | jmp $ |
99 | @@: |
99 | @@: |
100 | pop si |
100 | pop si |
101 | ret |
101 | ret |
102 | 102 | ||
103 | ; convert abs. sector number (AX) to BIOS T:H:S |
103 | ; convert abs. sector number (AX) to BIOS T:H:S |
104 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
104 | ; sector number = (abs.sector%BPB_SecPerTrk)+1 |
105 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
105 | ; pre.track number = (abs.sector/BPB_SecPerTrk) |
106 | ; head number = pre.track number%BPB_NumHeads |
106 | ; head number = pre.track number%BPB_NumHeads |
107 | ; track number = pre.track number/BPB_NumHeads |
107 | ; track number = pre.track number/BPB_NumHeads |
108 | ; Return: cl - sector number |
108 | ; Return: cl - sector number |
109 | ; ch - track number |
109 | ; ch - track number |
110 | ; dl - drive number (0 = a:) |
110 | ; dl - drive number (0 = a:) |
111 | ; dh - head number |
111 | ; dh - head number |
112 | conv_abs_to_THS: |
112 | conv_abs_to_THS: |
113 | push bx |
113 | push bx |
114 | mov bx, word [BPB_SecPerTrk] |
114 | mov bx, word [BPB_SecPerTrk] |
115 | xor dx, dx |
115 | xor dx, dx |
116 | div bx |
116 | div bx |
117 | inc dx |
117 | inc dx |
118 | mov cl, dl ; cl = sector number |
118 | mov cl, dl ; cl = sector number |
119 | mov bx, word [BPB_NumHeads] |
119 | mov bx, word [BPB_NumHeads] |
120 | xor dx, dx |
120 | xor dx, dx |
121 | div bx |
121 | div bx |
122 | ; !!!!!!! ax = track number, dx = head number |
122 | ; !!!!!!! ax = track number, dx = head number |
123 | mov ch, al ; ch=track number |
123 | mov ch, al ; ch=track number |
124 | xchg dh, dl ; dh=head number |
124 | xchg dh, dl ; dh=head number |
125 | mov dl, 0 ; dl=0 (drive 0 (a:)) |
125 | mov dl, 0 ; dl=0 (drive 0 (a:)) |
126 | pop bx |
126 | pop bx |
127 | retn |
127 | retn |
128 | ; needed variables |
128 | ; needed variables |
129 | BPB_SecPerTrk dw 0 ; sectors per track |
129 | BPB_SecPerTrk dw 0 ; sectors per track |
130 | BPB_NumHeads dw 0 ; number of heads |
130 | BPB_NumHeads dw 0 ; number of heads |
131 | BPB_FATSz16 dw 0 ; size of FAT |
131 | BPB_FATSz16 dw 0 ; size of FAT |
132 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
132 | BPB_RootEntCnt dw 0 ; count of root dir. entries |
133 | BPB_BytsPerSec dw 0 ; bytes per sector |
133 | BPB_BytsPerSec dw 0 ; bytes per sector |
134 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
134 | BPB_RsvdSecCnt dw 0 ; number of reserved sectors |
135 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
135 | BPB_TotSec16 dw 0 ; count of the sectors on the volume |
136 | BPB_SecPerClus db 0 ; number of sectors per cluster |
136 | BPB_SecPerClus db 0 ; number of sectors per cluster |
137 | BPB_NumFATs db 0 ; number of FAT tables |
137 | BPB_NumFATs db 0 ; number of FAT tables |
138 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
138 | abs_sector_adj dw 0 ; adjustment to make abs. sector number |
139 | end_of_FAT dw 0 ; end of FAT table |
139 | end_of_FAT dw 0 ; end of FAT table |
140 | FirstDataSector dw 0 ; begin of data |
140 | FirstDataSector dw 0 ; begin of data |
141 | 141 | ||
142 | ;========================================================================= |
142 | ;========================================================================= |
143 | ; |
143 | ; |
144 | ; 16 BIT CODE |
144 | ; 16 BIT CODE |
145 | ; |
145 | ; |
146 | ;========================================================================= |
146 | ;========================================================================= |
147 | 147 | ||
148 | include 'bootvesa.inc' ;Include source for boot vesa |
148 | include 'bootvesa.inc' ;Include source for boot vesa |
149 | if defined extended_primary_loader |
149 | if defined extended_primary_loader |
150 | include 'parsers.inc' |
150 | include 'parsers.inc' |
151 | end if |
151 | end if |
152 | 152 | ||
153 | start_of_code: |
153 | start_of_code: |
154 | 154 | ||
155 | if defined extended_primary_loader |
155 | if defined extended_primary_loader |
156 | ; save data from primary loader |
156 | ; save data from primary loader |
157 | mov word [cs:bootcallback], si |
157 | mov word [cs:bootcallback], si |
158 | mov word [cs:bootcallback+2], ds |
158 | mov word [cs:bootcallback+2], ds |
159 | push cs |
159 | push cs |
160 | pop ds |
160 | pop ds |
161 | mov [bootdevice], ax |
161 | mov [bootdevice], ax |
162 | mov [bootfs], bx |
162 | mov [bootfs], bx |
163 | 163 | ||
164 | ; set up stack |
164 | ; set up stack |
165 | mov ax, 3000h |
165 | mov ax, 3000h |
166 | mov ss, ax |
166 | mov ss, ax |
167 | mov sp, 0EC00h |
167 | mov sp, 0EC00h |
168 | 168 | ||
169 | ; try to load configuration file |
169 | ; try to load configuration file |
170 | mov ax, 1 |
170 | mov ax, 1 |
171 | mov di, config_file_struct |
171 | mov di, config_file_struct |
172 | call [bootcallback] |
172 | call [bootcallback] |
173 | cld |
173 | cld |
174 | push cs |
174 | push cs |
175 | pop es |
175 | pop es |
176 | ; bx=0 - ok, bx=1 - part of file loaded, assume this is ok |
176 | ; bx=0 - ok, bx=1 - part of file loaded, assume this is ok |
177 | cmp bx, 1 |
177 | cmp bx, 1 |
178 | ja .config_bad |
178 | ja .config_bad |
179 | ; configuration file was loaded, parse |
179 | ; configuration file was loaded, parse |
180 | ; if length is too big, use first 0FFFFh bytes |
180 | ; if length is too big, use first 0FFFFh bytes |
181 | test dx, dx |
181 | test dx, dx |
182 | jz @f |
182 | jz @f |
183 | mov ax, 0FFFFh |
183 | mov ax, 0FFFFh |
184 | @@: |
184 | @@: |
185 | ; ds:si will be pointer to current data, dx = limit |
185 | ; ds:si will be pointer to current data, dx = limit |
186 | xchg ax, dx |
186 | xchg ax, dx |
187 | push 4000h |
187 | push 4000h |
188 | pop ds |
188 | pop ds |
189 | xor si, si |
189 | xor si, si |
190 | .parse_loop: |
190 | .parse_loop: |
191 | ; skip spaces |
191 | ; skip spaces |
192 | cmp si, dx |
192 | cmp si, dx |
193 | jae .parse_done |
193 | jae .parse_done |
194 | lodsb |
194 | lodsb |
195 | cmp al, ' ' |
195 | cmp al, ' ' |
196 | jbe .parse_loop |
196 | jbe .parse_loop |
197 | dec si |
197 | dec si |
198 | ; loop over all possible configuration values |
198 | ; loop over all possible configuration values |
199 | mov bx, config_file_variables |
199 | mov bx, config_file_variables |
200 | .find_variant: |
200 | .find_variant: |
201 | ; get length |
201 | ; get length |
202 | mov cx, [es:bx] |
202 | mov cx, [es:bx] |
203 | ; zero length = end of list |
203 | ; zero length = end of list |
204 | jecxz .find_newline |
204 | jecxz .find_newline |
205 | ; skip over length |
205 | ; skip over length |
206 | inc bx |
206 | inc bx |
207 | inc bx |
207 | inc bx |
208 | mov di, bx |
208 | mov di, bx |
209 | ; skip over string |
209 | ; skip over string |
210 | add bx, cx |
210 | add bx, cx |
211 | ; test whether we have at least cx symbols left |
211 | ; test whether we have at least cx symbols left |
212 | mov ax, cx |
212 | mov ax, cx |
213 | add ax, si |
213 | add ax, si |
214 | jc .next_variant1 |
214 | jc .next_variant1 |
215 | cmp ax, dx |
215 | cmp ax, dx |
216 | jae .next_variant1 |
216 | jae .next_variant1 |
217 | ; save current position |
217 | ; save current position |
218 | push si |
218 | push si |
219 | ; compare strings |
219 | ; compare strings |
220 | repz cmpsb |
220 | repz cmpsb |
221 | jnz .next_variant2 |
221 | jnz .next_variant2 |
222 | ; strings are equal; look for "=" with possible spaces before and after |
222 | ; strings are equal; look for "=" with possible spaces before and after |
223 | @@: |
223 | @@: |
224 | cmp si, dx |
224 | cmp si, dx |
225 | jae .next_variant2 |
225 | jae .next_variant2 |
226 | lodsb |
226 | lodsb |
227 | cmp al, ' ' |
227 | cmp al, ' ' |
228 | jbe @b |
228 | jbe @b |
229 | cmp al, '=' |
229 | cmp al, '=' |
230 | jnz .next_variant2 |
230 | jnz .next_variant2 |
231 | ; ok, we found the true variant |
231 | ; ok, we found the true variant |
232 | ; ignore saved position on the stack |
232 | ; ignore saved position on the stack |
233 | pop ax |
233 | pop ax |
234 | ; call the parser |
234 | ; call the parser |
235 | call word [es:bx] |
235 | call word [es:bx] |
236 | ; line parsed, find next |
236 | ; line parsed, find next |
237 | .find_newline: |
237 | .find_newline: |
238 | cmp si, dx |
238 | cmp si, dx |
239 | jae .parse_done |
239 | jae .parse_done |
240 | lodsb |
240 | lodsb |
241 | cmp al, 13 |
241 | cmp al, 13 |
242 | jz .parse_loop |
242 | jz .parse_loop |
243 | cmp al, 10 |
243 | cmp al, 10 |
244 | jz .parse_loop |
244 | jz .parse_loop |
245 | jmp .find_newline |
245 | jmp .find_newline |
246 | .next_variant2: |
246 | .next_variant2: |
247 | ; continue to the next variant, restoring current position |
247 | ; continue to the next variant, restoring current position |
248 | pop si |
248 | pop si |
249 | .next_variant1: |
249 | .next_variant1: |
250 | ; continue to the next variant |
250 | ; continue to the next variant |
251 | ; skip over the parser |
251 | ; skip over the parser |
252 | inc bx |
252 | inc bx |
253 | inc bx |
253 | inc bx |
254 | jmp .find_variant |
254 | jmp .find_variant |
255 | .parse_done: |
255 | .parse_done: |
256 | .config_bad: |
256 | .config_bad: |
257 | 257 | ||
258 | ; set up segment registers |
258 | ; set up segment registers |
259 | push cs |
259 | push cs |
260 | pop ds |
260 | pop ds |
261 | else |
261 | else |
262 | cld |
262 | cld |
263 | ; \begin{diamond}[02.12.2005] |
263 | ; \begin{diamond}[02.12.2005] |
264 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
264 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
265 | cmp ax, 'KL' |
265 | cmp ax, 'KL' |
266 | jnz @f |
266 | jnz @f |
267 | mov word [cs:cfgmanager.loader_block], si |
267 | mov word [cs:cfgmanager.loader_block], si |
268 | mov word [cs:cfgmanager.loader_block+2], ds |
268 | mov word [cs:cfgmanager.loader_block+2], ds |
269 | @@: |
269 | @@: |
270 | ; \end{diamond}[02.12.2005] |
270 | ; \end{diamond}[02.12.2005] |
271 | 271 | ||
272 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
272 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
273 | ; (see comment to bx_from_load) |
273 | ; (see comment to bx_from_load) |
274 | cmp cx, 'HA' |
274 | cmp cx, 'HA' |
275 | jnz no_hd_load |
275 | jnz no_hd_load |
276 | cmp dx, 'RD' |
276 | cmp dx, 'RD' |
277 | jnz no_hd_load |
277 | jnz no_hd_load |
278 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
278 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
279 | no_hd_load: |
279 | no_hd_load: |
280 | 280 | ||
281 | ; set up stack |
281 | ; set up stack |
282 | mov ax, 3000h |
282 | mov ax, 3000h |
283 | mov ss, ax |
283 | mov ss, ax |
284 | mov sp, 0EC00h |
284 | mov sp, 0EC00h |
285 | ; set up segment registers |
285 | ; set up segment registers |
286 | push cs |
286 | push cs |
287 | pop ds |
287 | pop ds |
288 | push cs |
288 | push cs |
289 | pop es |
289 | pop es |
290 | end if |
290 | end if |
291 | 291 | ||
292 | ; set videomode |
292 | ; set videomode |
293 | mov ax, 3 |
293 | mov ax, 3 |
294 | int 0x10 |
294 | int 0x10 |
295 | 295 | ||
296 | if lang eq ru |
296 | if lang eq ru |
297 | ; Load & set russian VGA font (RU.INC) |
297 | ; Load & set russian VGA font (RU.INC) |
298 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
298 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
299 | mov bx, 1000h ; 768 bytes |
299 | mov bx, 1000h ; 768 bytes |
300 | mov cx, 30h ; 48 symbols |
300 | mov cx, 30h ; 48 symbols |
301 | mov dx, 80h ; 128 - position of first symbol |
301 | mov dx, 80h ; 128 - position of first symbol |
302 | mov ax, 1100h |
302 | mov ax, 1100h |
303 | int 10h |
303 | int 10h |
304 | 304 | ||
305 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
305 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
306 | mov bx, 1000h ; 512 bytes |
306 | mov bx, 1000h ; 512 bytes |
307 | mov cx, 20h ; 32 symbols |
307 | mov cx, 20h ; 32 symbols |
308 | mov dx, 0E0h ; 224 - position of first symbol |
308 | mov dx, 0E0h ; 224 - position of first symbol |
309 | mov ax, 1100h |
309 | mov ax, 1100h |
310 | int 10h |
310 | int 10h |
311 | ; End set VGA russian font |
311 | ; End set VGA russian font |
312 | else if lang eq et |
312 | else if lang eq et |
313 | mov bp, ET_FNT ; ET_FNT1 |
313 | mov bp, ET_FNT ; ET_FNT1 |
314 | mov bx, 1000h ; |
314 | mov bx, 1000h ; |
315 | mov cx, 255 ; 256 symbols |
315 | mov cx, 255 ; 256 symbols |
316 | xor dx, dx ; 0 - position of first symbol |
316 | xor dx, dx ; 0 - position of first symbol |
317 | mov ax, 1100h |
317 | mov ax, 1100h |
318 | int 10h |
318 | int 10h |
319 | end if |
319 | end if |
320 | 320 | ||
321 | ; draw frames |
321 | ; draw frames |
322 | push 0xb800 |
322 | push 0xb800 |
323 | pop es |
323 | pop es |
324 | xor di, di |
324 | xor di, di |
325 | mov ah, 1*16+15 |
325 | mov ah, 1*16+15 |
326 | 326 | ||
327 | ; draw top |
327 | ; draw top |
328 | mov si, d80x25_top |
328 | mov si, d80x25_top |
329 | mov cx, d80x25_top_num * 80 |
329 | mov cx, d80x25_top_num * 80 |
330 | @@: |
330 | @@: |
331 | lodsb |
331 | lodsb |
332 | stosw |
332 | stosw |
333 | loop @b |
333 | loop @b |
334 | ; draw spaces |
334 | ; draw spaces |
335 | mov si, space_msg |
335 | mov si, space_msg |
336 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
336 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
337 | dfl1: |
337 | dfl1: |
338 | push si |
338 | push si |
339 | mov cx, 80 |
339 | mov cx, 80 |
340 | @@: |
340 | @@: |
341 | lodsb |
341 | lodsb |
342 | stosw |
342 | stosw |
343 | loop @b |
343 | loop @b |
344 | pop si |
344 | pop si |
345 | dec dx |
345 | dec dx |
346 | jnz dfl1 |
346 | jnz dfl1 |
347 | ; draw bottom |
347 | ; draw bottom |
348 | mov si, d80x25_bottom |
348 | mov si, d80x25_bottom |
349 | mov cx, d80x25_bottom_num * 80 |
349 | mov cx, d80x25_bottom_num * 80 |
350 | @@: |
350 | @@: |
351 | lodsb |
351 | lodsb |
352 | stosw |
352 | stosw |
353 | loop @b |
353 | loop @b |
354 | 354 | ||
355 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
355 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
356 | 356 | ||
357 | _setcursor d80x25_top_num,0 |
357 | _setcursor d80x25_top_num,0 |
358 | 358 | ||
359 | 359 | ||
360 | ; TEST FOR 386+ |
360 | ; TEST FOR 386+ |
361 | 361 | ||
362 | mov bx, 0x4000 |
362 | mov bx, 0x4000 |
363 | pushf |
363 | pushf |
364 | pop ax |
364 | pop ax |
365 | mov dx, ax |
365 | mov dx, ax |
366 | xor ax, bx |
366 | xor ax, bx |
367 | push ax |
367 | push ax |
368 | popf |
368 | popf |
369 | pushf |
369 | pushf |
370 | pop ax |
370 | pop ax |
371 | and ax, bx |
371 | and ax, bx |
372 | and dx, bx |
372 | and dx, bx |
373 | cmp ax, dx |
373 | cmp ax, dx |
374 | jnz cpugood |
374 | jnz cpugood |
375 | mov si, not386 |
375 | mov si, not386 |
376 | sayerr: |
376 | sayerr: |
377 | call print |
377 | call print |
378 | jmp $ |
378 | jmp $ |
379 | cpugood: |
379 | cpugood: |
380 | 380 | ||
381 | push 0 |
381 | push 0 |
382 | popf |
382 | popf |
383 | sti |
383 | sti |
384 | 384 | ||
385 | ; set up esp |
385 | ; set up esp |
386 | movzx esp, sp |
386 | movzx esp, sp |
387 | 387 | ||
388 | push 0 |
388 | push 0 |
389 | pop es |
389 | pop es |
390 | xor ax, ax |
390 | xor ax, ax |
391 | and word [es:BOOT_IDE_BASE_ADDR], ax ;0 |
391 | and word [es:BOOT_IDE_BASE_ADDR], ax ;0 |
392 | and word [es:BOOT_IDE_BAR0_16], ax ;0 |
392 | and word [es:BOOT_IDE_BAR0_16], ax ;0 |
393 | and word [es:BOOT_IDE_BAR1_16], ax ;0 |
393 | and word [es:BOOT_IDE_BAR1_16], ax ;0 |
394 | and word [es:BOOT_IDE_BAR2_16], ax ;0 |
394 | and word [es:BOOT_IDE_BAR2_16], ax ;0 |
395 | and word [es:BOOT_IDE_BAR3_16], ax ;0 |
395 | and word [es:BOOT_IDE_BAR3_16], ax ;0 |
396 | ; \begin{Mario79} |
396 | ; \begin{Mario79} |
397 | ; find HDD IDE DMA PCI device |
397 | ; find HDD IDE DMA PCI device |
398 | ; check for PCI BIOS |
398 | ; check for PCI BIOS |
399 | mov ax, 0xB101 |
399 | mov ax, 0xB101 |
400 | int 0x1A |
400 | int 0x1A |
401 | jc .nopci |
401 | jc .nopci |
402 | cmp edx, 'PCI ' |
402 | cmp edx, 'PCI ' |
403 | jnz .nopci |
403 | jnz .nopci |
404 | ; find PCI class code |
404 | ; find PCI class code |
405 | ; class 1 = mass storage |
405 | ; class 1 = mass storage |
406 | ; subclass 1 = IDE controller |
406 | ; subclass 1 = IDE controller |
407 | ; a) class 1, subclass 1, programming interface 0x80 |
407 | ; a) class 1, subclass 1, programming interface 0x80 |
408 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
408 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
409 | mov ax, 0xB103 |
409 | mov ax, 0xB103 |
410 | mov ecx, 1*10000h + 1*100h + 0x80 |
410 | mov ecx, 1*10000h + 1*100h + 0x80 |
411 | mov [es:BOOT_IDE_PI_16], cx |
411 | mov [es:BOOT_IDE_PI_16], cx |
412 | xor si, si ; device index = 0 |
412 | xor si, si ; device index = 0 |
413 | int 0x1A |
413 | int 0x1A |
414 | jnc .found_1 ; Parallel IDE Controller |
414 | jnc .found_1 ; Parallel IDE Controller |
415 | ; b) class 1, subclass 1, programming interface 0x8f |
415 | ; b) class 1, subclass 1, programming interface 0x8f |
416 | mov ax, 0xB103 |
416 | mov ax, 0xB103 |
417 | mov ecx, 1*10000h + 1*100h + 0x8f |
417 | mov ecx, 1*10000h + 1*100h + 0x8f |
418 | mov [es:BOOT_IDE_PI_16], cx |
418 | mov [es:BOOT_IDE_PI_16], cx |
419 | xor si, si ; device index = 0 |
419 | xor si, si ; device index = 0 |
420 | int 0x1A |
420 | int 0x1A |
421 | jnc .found |
421 | jnc .found |
422 | ; c) class 1, subclass 1, programming interface 0x85 |
422 | ; c) class 1, subclass 1, programming interface 0x85 |
423 | mov ax, 0xB103 |
423 | mov ax, 0xB103 |
424 | mov ecx, 1*10000h + 1*100h + 0x85 |
424 | mov ecx, 1*10000h + 1*100h + 0x85 |
425 | mov [es:BOOT_IDE_PI_16], cx |
425 | mov [es:BOOT_IDE_PI_16], cx |
426 | xor si, si ; device index = 0 |
426 | xor si, si ; device index = 0 |
427 | int 0x1A |
427 | int 0x1A |
428 | jnc .found |
428 | jnc .found |
429 | ; d) class 1, subclass 1, programming interface 0x8A |
429 | ; d) class 1, subclass 1, programming interface 0x8A |
430 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
430 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
431 | mov ax, 0xB103 |
431 | mov ax, 0xB103 |
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
433 | mov [es:BOOT_IDE_PI_16], cx |
433 | mov [es:BOOT_IDE_PI_16], cx |
434 | xor si, si ; device index = 0 |
434 | xor si, si ; device index = 0 |
435 | int 0x1A |
435 | int 0x1A |
436 | jnc .found_1 ; Parallel IDE Controller |
436 | jnc .found_1 ; Parallel IDE Controller |
437 | ; Controller not found! |
437 | ; Controller not found! |
438 | xor ax, ax |
438 | xor ax, ax |
439 | mov [es:BOOT_IDE_PI_16], ax |
439 | mov [es:BOOT_IDE_PI_16], ax |
440 | jmp .nopci |
440 | jmp .nopci |
441 | ;-------------------------------------- |
441 | ;-------------------------------------- |
442 | .found_1: |
442 | .found_1: |
443 | ; get memory base BAR4 |
443 | ; get memory base BAR4 |
444 | mov ax, 0xB10A |
444 | mov ax, 0xB10A |
445 | mov di, 0x20 ; memory base is config register at 0x20 |
445 | mov di, 0x20 ; memory base is config register at 0x20 |
446 | push cx |
446 | push cx |
447 | int 0x1A |
447 | int 0x1A |
448 | jc .no_BAR4 ;.nopci |
448 | jc .no_BAR4 ;.nopci |
449 | and cx, 0xFFFC ; clear address decode type |
449 | and cx, 0xFFFC ; clear address decode type |
450 | mov [es:BOOT_IDE_BASE_ADDR], cx |
450 | mov [es:BOOT_IDE_BASE_ADDR], cx |
451 | .no_BAR4: |
451 | .no_BAR4: |
452 | pop cx |
452 | pop cx |
453 | ;-------------------------------------- |
453 | ;-------------------------------------- |
454 | .found: |
454 | .found: |
455 | ; get Interrupt Line |
455 | ; get Interrupt Line |
456 | mov ax, 0xB10A |
456 | mov ax, 0xB10A |
457 | mov di, 0x3c ; memory base is config register at 0x3c |
457 | mov di, 0x3c ; memory base is config register at 0x3c |
458 | push cx |
458 | push cx |
459 | int 0x1A |
459 | int 0x1A |
460 | jc .no_Interrupt ;.nopci |
460 | jc .no_Interrupt ;.nopci |
461 | 461 | ||
462 | mov [es:BOOT_IDE_INTERR_16], cx |
462 | mov [es:BOOT_IDE_INTERR_16], cx |
463 | .no_Interrupt: |
463 | .no_Interrupt: |
464 | pop cx |
464 | pop cx |
465 | ;-------------------------------------- |
465 | ;-------------------------------------- |
466 | ; get memory base BAR0 |
466 | ; get memory base BAR0 |
467 | mov ax, 0xB10A |
467 | mov ax, 0xB10A |
468 | mov di, 0x10 ; memory base is config register at 0x10 |
468 | mov di, 0x10 ; memory base is config register at 0x10 |
469 | push cx |
469 | push cx |
470 | int 0x1A |
470 | int 0x1A |
471 | jc .no_BAR0 ;.nopci |
471 | jc .no_BAR0 ;.nopci |
472 | 472 | ||
473 | mov [es:BOOT_IDE_BAR0_16], cx |
473 | mov [es:BOOT_IDE_BAR0_16], cx |
474 | .no_BAR0: |
474 | .no_BAR0: |
475 | pop cx |
475 | pop cx |
476 | ;-------------------------------------- |
476 | ;-------------------------------------- |
477 | ; get memory base BAR1 |
477 | ; get memory base BAR1 |
478 | mov ax, 0xB10A |
478 | mov ax, 0xB10A |
479 | mov di, 0x14 ; memory base is config register at 0x14 |
479 | mov di, 0x14 ; memory base is config register at 0x14 |
480 | push cx |
480 | push cx |
481 | int 0x1A |
481 | int 0x1A |
482 | jc .no_BAR1 ;.nopci |
482 | jc .no_BAR1 ;.nopci |
483 | 483 | ||
484 | mov [es:BOOT_IDE_BAR1_16], cx |
484 | mov [es:BOOT_IDE_BAR1_16], cx |
485 | .no_BAR1: |
485 | .no_BAR1: |
486 | pop cx |
486 | pop cx |
487 | ;-------------------------------------- |
487 | ;-------------------------------------- |
488 | ; get memory base BAR2 |
488 | ; get memory base BAR2 |
489 | mov ax, 0xB10A |
489 | mov ax, 0xB10A |
490 | mov di, 0x18 ; memory base is config register at 0x18 |
490 | mov di, 0x18 ; memory base is config register at 0x18 |
491 | push cx |
491 | push cx |
492 | int 0x1A |
492 | int 0x1A |
493 | jc .no_BAR2 ;.nopci |
493 | jc .no_BAR2 ;.nopci |
494 | 494 | ||
495 | mov [es:BOOT_IDE_BAR2_16], cx |
495 | mov [es:BOOT_IDE_BAR2_16], cx |
496 | .no_BAR2: |
496 | .no_BAR2: |
497 | pop cx |
497 | pop cx |
498 | ;-------------------------------------- |
498 | ;-------------------------------------- |
499 | ; get memory base BAR3 |
499 | ; get memory base BAR3 |
500 | mov ax, 0xB10A |
500 | mov ax, 0xB10A |
501 | mov di, 0x1C ; memory base is config register at 0x1c |
501 | mov di, 0x1C ; memory base is config register at 0x1c |
502 | push cx |
502 | push cx |
503 | int 0x1A |
503 | int 0x1A |
504 | jc .no_BAR3 ;.nopci |
504 | jc .no_BAR3 ;.nopci |
505 | 505 | ||
506 | mov [es:BOOT_IDE_BAR3_16], cx |
506 | mov [es:BOOT_IDE_BAR3_16], cx |
507 | .no_BAR3: |
507 | .no_BAR3: |
508 | pop cx |
508 | pop cx |
509 | ;-------------------------------------- |
509 | ;-------------------------------------- |
510 | .nopci: |
510 | .nopci: |
511 | ; \end{Mario79} |
511 | ; \end{Mario79} |
512 | 512 | ||
513 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
513 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
514 | out 0x60, al |
514 | out 0x60, al |
515 | xor cx, cx |
515 | xor cx, cx |
516 | wait_loop: ; variant 2 |
516 | wait_loop: ; variant 2 |
517 | ; reading state of port of 8042 controller |
517 | ; reading state of port of 8042 controller |
518 | in al, 64h |
518 | in al, 64h |
519 | and al, 00000010b ; ready flag |
519 | and al, 00000010b ; ready flag |
520 | ; wait until 8042 controller is ready |
520 | ; wait until 8042 controller is ready |
521 | loopnz wait_loop |
521 | loopnz wait_loop |
522 | 522 | ||
523 | ;;;/diamond today 5.02.2008 |
523 | ;;;/diamond today 5.02.2008 |
524 | ; set keyboard typematic rate & delay |
524 | ; set keyboard typematic rate & delay |
525 | mov al, 0xf3 |
525 | mov al, 0xf3 |
526 | out 0x60, al |
526 | out 0x60, al |
527 | xor cx, cx |
527 | xor cx, cx |
528 | @@: |
528 | @@: |
529 | in al, 64h |
529 | in al, 64h |
530 | test al, 2 |
530 | test al, 2 |
531 | loopnz @b |
531 | loopnz @b |
532 | mov al, 0 |
532 | mov al, 0 |
533 | out 0x60, al |
533 | out 0x60, al |
534 | xor cx, cx |
534 | xor cx, cx |
535 | @@: |
535 | @@: |
536 | in al, 64h |
536 | in al, 64h |
537 | test al, 2 |
537 | test al, 2 |
538 | loopnz @b |
538 | loopnz @b |
539 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
539 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
540 | ; --------------- APM --------------------- |
540 | ; --------------- APM --------------------- |
541 | and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
541 | and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
542 | mov ax, 0x5300 |
542 | mov ax, 0x5300 |
543 | xor bx, bx |
543 | xor bx, bx |
544 | int 0x15 |
544 | int 0x15 |
545 | jc apm_end ; APM not found |
545 | jc apm_end ; APM not found |
546 | test cx, 2 |
546 | test cx, 2 |
547 | jz apm_end ; APM 32-bit protected-mode interface not supported |
547 | jz apm_end ; APM 32-bit protected-mode interface not supported |
548 | mov [es:BOOT_APM_VERSION], ax ; Save APM Version |
548 | mov [es:BOOT_APM_VERSION], ax ; Save APM Version |
549 | mov [es:BOOT_APM_FLAGS], cx ; Save APM flags |
549 | mov [es:BOOT_APM_FLAGS], cx ; Save APM flags |
550 | 550 | ||
551 | ; Write APM ver ---- |
551 | ; Write APM ver ---- |
552 | and ax, 0xf0f |
552 | and ax, 0xf0f |
553 | add ax, '00' |
553 | add ax, '00' |
554 | mov si, msg_apm |
554 | mov si, msg_apm |
555 | mov [si + 5], ah |
555 | mov [si + 5], ah |
556 | mov [si + 7], al |
556 | mov [si + 7], al |
557 | _setcursor 0, 3 |
557 | _setcursor 0, 3 |
558 | call printplain |
558 | call printplain |
559 | ; ------------------ |
559 | ; ------------------ |
560 | 560 | ||
561 | mov ax, 0x5304 ; Disconnect interface |
561 | mov ax, 0x5304 ; Disconnect interface |
562 | xor bx, bx |
562 | xor bx, bx |
563 | int 0x15 |
563 | int 0x15 |
564 | mov ax, 0x5303 ; Connect 32 bit mode interface |
564 | mov ax, 0x5303 ; Connect 32 bit mode interface |
565 | xor bx, bx |
565 | xor bx, bx |
566 | int 0x15 |
566 | int 0x15 |
567 | 567 | ||
568 | mov [es:BOOT_APM_ENTRY], ebx |
568 | mov [es:BOOT_APM_ENTRY], ebx |
569 | mov [es:BOOT_APM_CODE_32], ax |
569 | mov [es:BOOT_APM_CODE_32], ax |
570 | mov [es:BOOT_APM_CODE_16], cx |
570 | mov [es:BOOT_APM_CODE_16], cx |
571 | mov [es:BOOT_APM_DATA_16], dx |
571 | mov [es:BOOT_APM_DATA_16], dx |
572 | 572 | ||
573 | apm_end: |
573 | apm_end: |
574 | _setcursor d80x25_top_num, 0 |
574 | _setcursor d80x25_top_num, 0 |
575 | 575 | ||
576 | if ~ defined extended_primary_loader |
576 | if ~ defined extended_primary_loader |
577 | ;CHECK current of code |
577 | ;CHECK current of code |
578 | cmp [cfgmanager.loader_block], -1 |
578 | cmp [cfgmanager.loader_block], -1 |
579 | jz noloaderblock |
579 | jz noloaderblock |
580 | les bx, [cfgmanager.loader_block] |
580 | les bx, [cfgmanager.loader_block] |
581 | cmp byte [es:bx], 1 |
581 | cmp byte [es:bx], 1 |
582 | mov si, loader_block_error |
582 | mov si, loader_block_error |
583 | jnz sayerr |
583 | jnz sayerr |
584 | push 0 |
584 | push 0 |
585 | pop es |
585 | pop es |
586 | end if |
586 | end if |
587 | 587 | ||
588 | noloaderblock: |
588 | noloaderblock: |
589 | ; DISPLAY VESA INFORMATION |
589 | ; DISPLAY VESA INFORMATION |
590 | call print_vesa_info |
590 | call print_vesa_info |
591 | call calc_vmodes_table |
591 | call calc_vmodes_table |
592 | call check_first_parm ;check and enable cursor_pos |
592 | call check_first_parm ;check and enable cursor_pos |
593 | 593 | ||
594 | ; \begin{diamond}[30.11.2005] |
594 | ; \begin{diamond}[30.11.2005] |
595 | cfgmanager: |
595 | cfgmanager: |
596 | ; settings: |
596 | ; settings: |
597 | ; a) preboot_graph = graphical mode |
597 | ; a) preboot_graph = graphical mode |
598 | ; preboot_gprobe = probe this mode? |
598 | ; preboot_gprobe = probe this mode? |
599 | ; b) preboot_dma = use DMA access? |
599 | ; b) preboot_biosdisk = use BIOS disks through V86 emulation? // (earlier was: preboot_dma = use DMA access?) |
600 | ; c) preboot_vrrm = use VRR? |
600 | ; c) preboot_debug = duplicates kernel debug output to the screen // (earlier was: preboot_vrrm = use VRR?) |
- | 601 | ; // VRR is an obsolete functionality, used only with CRT monitors: increase display frequency by reducing screen resolution |
|
- | 602 | ; d) preboot_launcher = start the first app (right now it's LAUNCHER) after kernel is loaded? |
|
601 | ; d) preboot_device = from what boot? |
603 | ; e) preboot_device = from where to boot? |
602 | 604 | ||
603 | ; determine default settings |
605 | ; determine default settings |
604 | if ~ defined extended_primary_loader |
606 | if ~ defined extended_primary_loader |
605 | mov [.bSettingsChanged], 0 |
607 | mov [.bSettingsChanged], 0 |
606 | end if |
608 | end if |
607 | 609 | ||
608 | ;.preboot_gr_end: |
610 | ;.preboot_gr_end: |
609 | mov di, preboot_device |
611 | mov di, preboot_device |
610 | ; if image in memory is present and [preboot_device] is uninitialized, |
612 | ; if image in memory is present and [preboot_device] is uninitialized, |
611 | ; set it to use this preloaded image |
613 | ; set it to use this preloaded image |
612 | cmp byte [di], 0 |
614 | cmp byte [di], 0 |
613 | jnz .preboot_device_inited |
615 | jnz .preboot_device_inited |
614 | if defined extended_primary_loader |
616 | if defined extended_primary_loader |
615 | inc byte [di] |
617 | inc byte [di] |
616 | cmp byte [bootdevice], 'f' ; floppy? |
618 | cmp byte [bootdevice], 'f' ; floppy? |
617 | jz .preboot_device_inited |
619 | jz .preboot_device_inited |
618 | inc byte [di] |
620 | inc byte [di] |
619 | else |
621 | else |
620 | cmp [.loader_block], -1 |
622 | cmp [.loader_block], -1 |
621 | jz @f |
623 | jz @f |
622 | les bx, [.loader_block] |
624 | les bx, [.loader_block] |
623 | test byte [es:bx+1], 1 |
625 | test byte [es:bx+1], 1 |
624 | jz @f |
626 | jz @f |
625 | mov byte [di], 3 |
627 | mov byte [di], 3 |
626 | jmp .preboot_device_inited |
628 | jmp .preboot_device_inited |
627 | @@: |
629 | @@: |
628 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
630 | ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) |
629 | mov byte [di], 1 |
631 | mov byte [di], 1 |
630 | end if |
632 | end if |
631 | .preboot_device_inited: |
633 | .preboot_device_inited: |
632 | ; following 4 lines set variables to 1 if its current value is 0 |
634 | ; following 4 lines set variables to 1 if its current value is 0 |
633 | cmp byte [di+preboot_dma-preboot_device], 1 |
635 | cmp byte [di+preboot_dma-preboot_device], 1 |
634 | adc byte [di+preboot_dma-preboot_device], 0 |
636 | adc byte [di+preboot_dma-preboot_device], 0 |
- | 637 | cmp byte [di+preboot_launcher-preboot_device], 1 ; Start LAUNCHER by default |
|
- | 638 | adc byte [di+preboot_launcher-preboot_device], 0 |
|
635 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
639 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
636 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
640 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
637 | ;; default value for VRR is OFF |
641 | ;; default value for VRR is OFF |
638 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
642 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
639 | ; jnz @f |
643 | ; jnz @f |
640 | ; mov byte [di+preboot_vrrm-preboot_device], 2 |
644 | ; mov byte [di+preboot_vrrm-preboot_device], 2 |
641 | ;@@: |
645 | ;@@: |
642 | ; notify user |
646 | ; notify user |
643 | _setcursor 5,2 |
647 | _setcursor 5,2 |
644 | 648 | ||
645 | mov si, linef |
649 | mov si, linef |
646 | call printplain |
650 | call printplain |
647 | mov si, start_msg |
651 | mov si, start_msg |
648 | call print |
652 | call print |
649 | mov si, time_msg |
653 | mov si, time_msg |
650 | call print |
654 | call print |
651 | ; get start time |
655 | ; get start time |
652 | call .gettime |
656 | call .gettime |
653 | mov [.starttime], eax |
657 | mov [.starttime], eax |
654 | mov word [.timer], .newtimer |
658 | mov word [.timer], .newtimer |
655 | mov word [.timer+2], cs |
659 | mov word [.timer+2], cs |
656 | .printcfg: |
660 | .printcfg: |
657 | 661 | ||
658 | _setcursor 9,0 |
662 | _setcursor 9,0 |
659 | mov si, current_cfg_msg |
663 | mov si, current_cfg_msg |
660 | call print |
664 | call print |
661 | mov si, curvideo_msg |
665 | mov si, curvideo_msg |
662 | call print |
666 | call print |
663 | 667 | ||
664 | call draw_current_vmode |
668 | call draw_current_vmode |
665 | 669 | ||
666 | mov si, usebd_msg |
670 | mov si, usebd_msg |
667 | cmp [preboot_biosdisk], 1 |
671 | cmp [preboot_biosdisk], 1 |
668 | call .say_on_off |
672 | call .say_on_off |
669 | ; mov si, vrrm_msg |
673 | ; mov si, vrrm_msg |
670 | ; cmp [preboot_vrrm], 1 |
674 | ; cmp [preboot_vrrm], 1 |
671 | ; call .say_on_off |
675 | ; call .say_on_off |
- | 676 | mov si, debug_mode_msg |
|
- | 677 | cmp [preboot_debug], 1 |
|
- | 678 | call .say_on_off |
|
- | 679 | mov si, launcher_msg |
|
- | 680 | cmp [preboot_launcher], 1 |
|
- | 681 | call .say_on_off |
|
672 | mov si, preboot_device_msg |
682 | mov si, preboot_device_msg |
673 | call print |
683 | call print |
674 | mov al, [preboot_device] |
684 | mov al, [preboot_device] |
675 | if defined extended_primary_loader |
685 | if defined extended_primary_loader |
676 | and eax, 3 |
686 | and eax, 3 |
677 | else |
687 | else |
678 | and eax, 7 |
688 | and eax, 7 |
679 | end if |
689 | end if |
680 | mov si, [preboot_device_msgs+eax*2] |
690 | mov si, [preboot_device_msgs+eax*2] |
681 | call printplain |
691 | call printplain |
682 | .show_remarks: |
692 | .show_remarks: |
683 | ; show remarks in gray color |
693 | ; show remarks in gray color |
684 | mov di, ((21-num_remarks)*80 + 2)*2 |
694 | mov di, ((21-num_remarks)*80 + 2)*2 |
685 | push 0xB800 |
695 | push 0xB800 |
686 | pop es |
696 | pop es |
687 | mov cx, num_remarks |
697 | mov cx, num_remarks |
688 | mov si, remarks |
698 | mov si, remarks |
689 | .write_remarks: |
699 | .write_remarks: |
690 | lodsw |
700 | lodsw |
691 | push si |
701 | push si |
692 | xchg ax, si |
702 | xchg ax, si |
693 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
703 | mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) |
694 | push di |
704 | push di |
695 | .write_remark: |
705 | .write_remark: |
696 | lodsb |
706 | lodsb |
697 | test al, al |
707 | test al, al |
698 | jz @f |
708 | jz @f |
699 | stosw |
709 | stosw |
700 | jmp .write_remark |
710 | jmp .write_remark |
701 | @@: |
711 | @@: |
702 | pop di |
712 | pop di |
703 | pop si |
713 | pop si |
704 | add di, 80*2 |
714 | add di, 80*2 |
705 | loop .write_remarks |
715 | loop .write_remarks |
706 | .wait: |
716 | .wait: |
707 | _setcursor 25,0 ; out of screen |
717 | _setcursor 25,0 ; out of screen |
708 | ; set timer interrupt handler |
718 | ; set timer interrupt handler |
709 | cli |
719 | cli |
710 | push 0 |
720 | push 0 |
711 | pop es |
721 | pop es |
712 | push dword [es:8*4] |
722 | push dword [es:8*4] |
713 | pop dword [.oldtimer] |
723 | pop dword [.oldtimer] |
714 | push dword [.timer] |
724 | push dword [.timer] |
715 | pop dword [es:8*4] |
725 | pop dword [es:8*4] |
716 | ; mov eax, [es:8*4] |
726 | ; mov eax, [es:8*4] |
717 | ; mov [.oldtimer], eax |
727 | ; mov [.oldtimer], eax |
718 | ; mov eax, [.timer] |
728 | ; mov eax, [.timer] |
719 | ; mov [es:8*4], eax |
729 | ; mov [es:8*4], eax |
720 | sti |
730 | sti |
721 | ; wait for keypressed |
731 | ; wait for keypressed |
722 | xor ax, ax |
732 | xor ax, ax |
723 | int 16h |
733 | int 16h |
724 | push ax |
734 | push ax |
725 | ; restore timer interrupt |
735 | ; restore timer interrupt |
726 | ; push 0 |
736 | ; push 0 |
727 | ; pop es |
737 | ; pop es |
728 | mov eax, [.oldtimer] |
738 | mov eax, [.oldtimer] |
729 | mov [es:8*4], eax |
739 | mov [es:8*4], eax |
730 | mov [.timer], eax |
740 | mov [.timer], eax |
731 | 741 | ||
732 | _setcursor 7,0 |
742 | _setcursor 7,0 |
733 | mov si, space_msg |
743 | mov si, space_msg |
734 | call printplain |
744 | call printplain |
735 | ; clear remarks and restore normal attributes |
745 | ; clear remarks and restore normal attributes |
736 | push es |
746 | push es |
737 | mov di, ((21-num_remarks)*80 + 2)*2 |
747 | mov di, ((21-num_remarks)*80 + 2)*2 |
738 | push 0xB800 |
748 | push 0xB800 |
739 | pop es |
749 | pop es |
740 | mov cx, num_remarks |
750 | mov cx, num_remarks |
741 | mov ax, ' ' + (1*16 + 15)*100h |
751 | mov ax, ' ' + (1*16 + 15)*100h |
742 | @@: |
752 | @@: |
743 | push cx |
753 | push cx |
744 | mov cx, 76 |
754 | mov cx, 76 |
745 | rep stosw |
755 | rep stosw |
746 | pop cx |
756 | pop cx |
747 | add di, 4*2 |
757 | add di, 4*2 |
748 | loop @b |
758 | loop @b |
749 | pop es |
759 | pop es |
750 | pop ax |
760 | pop ax |
751 | ; switch on key |
761 | ; switch on key |
752 | cmp al, 13 |
762 | cmp al, 13 |
753 | jz .continue |
763 | jz .continue |
754 | or al, 20h |
764 | or al, 20h |
755 | cmp al, 'a' |
765 | cmp al, 'a' ; select graphical mode |
756 | jz .change_a |
766 | jz .change_a |
757 | cmp al, 'q' ; Trick to make 'A' key on azerty keyboard work |
767 | cmp al, 'q' ; Trick to make 'A' key on azerty keyboard work |
758 | je .change_a |
768 | je .change_a |
759 | cmp al, 'b' |
769 | cmp al, 'b' ; use BIOS disks? // (selecting YES will make BIOS disks visible as /bd) |
760 | jz .change_b |
770 | jz .change_b |
- | 771 | cmp al, 'c' ; load kernel in debug mode? // (earlier was: use VRR?) |
|
761 | ; cmp al, 'c' |
772 | jz .change_c |
- | 773 | cmp al, 'd' ; start launcher after kernel is loaded? |
|
762 | ; jz .change_c |
774 | jz .change_d |
763 | cmp al, 'c' ; 'd' |
775 | cmp al, 'e' ; select boot origin |
764 | jnz .show_remarks |
776 | jnz .show_remarks |
- | 777 | ; e) preboot_device = from where to boot? |
|
765 | _setcursor 15,0 |
778 | _setcursor 16,0 |
766 | mov si, bdev |
779 | mov si, bdev |
767 | call print |
780 | call print |
768 | if defined extended_primary_loader |
781 | if defined extended_primary_loader |
769 | mov bx, '12' |
782 | mov bx, '12' |
770 | else |
783 | else |
771 | mov bx, '14' |
784 | mov bx, '14' |
772 | end if |
785 | end if |
773 | call getkey |
786 | call getkey |
774 | mov [preboot_device], al |
787 | mov [preboot_device], al |
775 | _setcursor 13,0 |
788 | _setcursor 14,0 |
776 | .d: |
789 | .d: |
777 | if ~ defined extended_primary_loader |
790 | if ~ defined extended_primary_loader |
778 | mov [.bSettingsChanged], 1 |
791 | mov [.bSettingsChanged], 1 |
779 | end if |
792 | end if |
780 | call clear_vmodes_table ;clear vmodes_table |
793 | call clear_vmodes_table ;clear vmodes_table |
781 | jmp .printcfg |
794 | jmp .printcfg |
782 | .change_a: |
795 | .change_a: |
783 | .loops: |
796 | .loops: |
784 | call draw_vmodes_table |
797 | call draw_vmodes_table |
785 | _setcursor 25,0 ; out of screen |
798 | _setcursor 25,0 ; out of screen |
786 | xor ax, ax |
799 | xor ax, ax |
787 | int 0x16 |
800 | int 0x16 |
788 | ; call clear_table_cursor ;clear current position of cursor |
801 | ; call clear_table_cursor ;clear current position of cursor |
789 | 802 | ||
790 | mov si, word [cursor_pos] |
803 | mov si, word [cursor_pos] |
791 | 804 | ||
792 | cmp ah, 0x48;x,0x48E0 ; up |
805 | cmp ah, 0x48;x,0x48E0 ; up |
793 | jne .down |
806 | jne .down |
794 | cmp si, modes_table |
807 | cmp si, modes_table |
795 | jbe .loops |
808 | jbe .loops |
796 | sub word [cursor_pos], size_of_step |
809 | sub word [cursor_pos], size_of_step |
797 | jmp .loops |
810 | jmp .loops |
798 | 811 | ||
799 | .down: |
812 | .down: |
800 | cmp ah, 0x50;x,0x50E0 ; down |
813 | cmp ah, 0x50;x,0x50E0 ; down |
801 | jne .pgup |
814 | jne .pgup |
802 | cmp word[es:si+10], -1 |
815 | cmp word[es:si+10], -1 |
803 | je .loops |
816 | je .loops |
804 | add word [cursor_pos], size_of_step |
817 | add word [cursor_pos], size_of_step |
805 | jmp .loops |
818 | jmp .loops |
806 | 819 | ||
807 | .pgup: |
820 | .pgup: |
808 | cmp ah, 0x49 ; page up |
821 | cmp ah, 0x49 ; page up |
809 | jne .pgdn |
822 | jne .pgdn |
810 | sub si, size_of_step*long_v_table |
823 | sub si, size_of_step*long_v_table |
811 | cmp si, modes_table |
824 | cmp si, modes_table |
812 | jae @f |
825 | jae @f |
813 | mov si, modes_table |
826 | mov si, modes_table |
814 | @@: |
827 | @@: |
815 | mov word [cursor_pos], si |
828 | mov word [cursor_pos], si |
816 | mov si, word [home_cursor] |
829 | mov si, word [home_cursor] |
817 | sub si, size_of_step*long_v_table |
830 | sub si, size_of_step*long_v_table |
818 | cmp si, modes_table |
831 | cmp si, modes_table |
819 | jae @f |
832 | jae @f |
820 | mov si, modes_table |
833 | mov si, modes_table |
821 | @@: |
834 | @@: |
822 | mov word [home_cursor], si |
835 | mov word [home_cursor], si |
823 | jmp .loops |
836 | jmp .loops |
824 | 837 | ||
825 | .pgdn: |
838 | .pgdn: |
826 | cmp ah, 0x51 ; page down |
839 | cmp ah, 0x51 ; page down |
827 | jne .enter |
840 | jne .enter |
828 | mov ax, [end_cursor] |
841 | mov ax, [end_cursor] |
829 | add si, size_of_step*long_v_table |
842 | add si, size_of_step*long_v_table |
830 | cmp si, ax |
843 | cmp si, ax |
831 | jb @f |
844 | jb @f |
832 | mov si, ax |
845 | mov si, ax |
833 | sub si, size_of_step |
846 | sub si, size_of_step |
834 | @@: |
847 | @@: |
835 | mov word [cursor_pos], si |
848 | mov word [cursor_pos], si |
836 | mov si, word [home_cursor] |
849 | mov si, word [home_cursor] |
837 | sub ax, size_of_step*long_v_table |
850 | sub ax, size_of_step*long_v_table |
838 | add si, size_of_step*long_v_table |
851 | add si, size_of_step*long_v_table |
839 | cmp si, ax |
852 | cmp si, ax |
840 | jb @f |
853 | jb @f |
841 | mov si, ax |
854 | mov si, ax |
842 | @@: |
855 | @@: |
843 | mov word [home_cursor], si |
856 | mov word [home_cursor], si |
844 | jmp .loops |
857 | jmp .loops |
845 | 858 | ||
846 | .enter: |
859 | .enter: |
847 | cmp al, 0x0D;x,0x1C0D ; enter |
860 | cmp al, 0x0D;x,0x1C0D ; enter |
848 | jne .loops |
861 | jne .loops |
849 | push word [cursor_pos] |
862 | push word [cursor_pos] |
850 | pop bp |
863 | pop bp |
851 | push word [es:bp] |
864 | push word [es:bp] |
852 | pop word [x_save] |
865 | pop word [x_save] |
853 | push word [es:bp+2] |
866 | push word [es:bp+2] |
854 | pop word [y_save] |
867 | pop word [y_save] |
855 | push word [es:bp+6] |
868 | push word [es:bp+6] |
856 | pop word [number_vm] |
869 | pop word [number_vm] |
857 | mov word [preboot_graph], bp ;save choose |
870 | mov word [preboot_graph], bp ;save choose |
858 | 871 | ||
859 | jmp .d |
872 | jmp .d |
860 | 873 | ||
861 | .change_b: |
874 | .change_b: ; b) preboot_biosdisk = use BIOS disks through V86 emulation? |
862 | _setcursor 15,0 |
875 | _setcursor 16,0 |
863 | ; mov si, ask_dma |
876 | ; mov si, ask_dma // (earlier was: preboot_dma = use DMA access?) |
864 | ; call print |
877 | ; call print |
865 | ; mov bx, '13' |
878 | ; mov bx, '13' |
866 | ; call getkey |
879 | ; call getkey |
867 | ; mov [preboot_dma], al |
880 | ; mov [preboot_dma], al |
868 | mov si, ask_bd |
881 | mov si, ask_bd |
869 | call print |
882 | call print |
870 | mov bx, '12' |
883 | mov bx, '12' |
871 | call getkey |
884 | call getkey |
872 | mov [preboot_biosdisk], al |
885 | mov [preboot_biosdisk], al |
873 | _setcursor 11,0 |
886 | _setcursor 11,0 |
874 | jmp .d |
887 | jmp .d |
875 | ;.change_c: |
888 | ;.change_c: ; // VRR is an obsolete functionality, used only with CRT monitors |
876 | ; _setcursor 15,0 |
889 | ; _setcursor 16,0 |
877 | ; mov si, vrrmprint |
890 | ; mov si, vrrmprint |
878 | ; call print |
891 | ; call print |
879 | ; mov bx, '12' |
892 | ; mov bx, '12' |
880 | ; call getkey |
893 | ; call getkey |
881 | ; mov [preboot_vrrm], al |
894 | ; mov [preboot_vrrm], al |
882 | ; _setcursor 12,0 |
895 | ; _setcursor 12,0 |
883 | ; jmp .d |
896 | ; jmp .d |
- | 897 | .change_c: ; c) preboot_debug = duplicates kernel debug output to the screen |
|
- | 898 | _setcursor 16,0 |
|
- | 899 | mov si, ask_debug |
|
- | 900 | call print |
|
- | 901 | mov bx, '12' |
|
- | 902 | call getkey |
|
- | 903 | mov [preboot_debug], al |
|
- | 904 | _setcursor 12,0 |
|
- | 905 | jmp .d |
|
- | 906 | .change_d: ; d) preboot_launcher = start the first app (right now it's LAUNCHER) after kernel is loaded? |
|
- | 907 | _setcursor 16,0 |
|
- | 908 | mov si, ask_launcher |
|
- | 909 | call print |
|
- | 910 | mov bx, '12' |
|
- | 911 | call getkey |
|
- | 912 | mov [preboot_launcher], al |
|
- | 913 | _setcursor 13,0 |
|
- | 914 | jmp .d |
|
884 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
915 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
885 | .say_on_off: |
916 | .say_on_off: |
886 | pushf |
917 | pushf |
887 | call print |
918 | call print |
888 | mov si, on_msg |
919 | mov si, on_msg |
889 | popf |
920 | popf |
890 | jz @f |
921 | jz @f |
891 | mov si, off_msg |
922 | mov si, off_msg |
892 | @@: |
923 | @@: |
893 | jmp printplain |
924 | jmp printplain |
894 | ; novesa and vervesa strings are not used at the moment of executing this code |
925 | ; novesa and vervesa strings are not used at the moment of executing this code |
895 | virtual at novesa |
926 | virtual at novesa |
896 | .oldtimer dd ? |
927 | .oldtimer dd ? |
897 | .starttime dd ? |
928 | .starttime dd ? |
898 | if ~ defined extended_primary_loader |
929 | if ~ defined extended_primary_loader |
899 | .bSettingsChanged db ? |
930 | .bSettingsChanged db ? |
900 | end if |
931 | end if |
901 | .timer dd ? |
932 | .timer dd ? |
902 | end virtual |
933 | end virtual |
903 | if ~ defined extended_primary_loader |
934 | if ~ defined extended_primary_loader |
904 | .loader_block dd -1 |
935 | .loader_block dd -1 |
905 | end if |
936 | end if |
906 | .gettime: |
937 | .gettime: |
907 | mov ah, 0 |
938 | mov ah, 0 |
908 | int 1Ah |
939 | int 1Ah |
909 | xchg ax, cx |
940 | xchg ax, cx |
910 | shl eax, 10h |
941 | shl eax, 10h |
911 | xchg ax, dx |
942 | xchg ax, dx |
912 | ret |
943 | ret |
913 | .newtimer: |
944 | .newtimer: |
914 | push ds |
945 | push ds |
915 | push cs |
946 | push cs |
916 | pop ds |
947 | pop ds |
917 | pushf |
948 | pushf |
918 | call [.oldtimer] |
949 | call [.oldtimer] |
919 | pushad |
950 | pushad |
920 | call .gettime |
951 | call .gettime |
921 | sub eax, [.starttime] |
952 | sub eax, [.starttime] |
922 | if defined extended_primary_loader |
953 | if defined extended_primary_loader |
923 | sub ax, [preboot_timeout] |
954 | sub ax, [preboot_timeout] |
924 | else |
955 | else |
925 | sub ax, 18*5 |
956 | sub ax, 18*5 |
926 | end if |
957 | end if |
927 | jae .timergo |
958 | jae .timergo |
928 | neg ax |
959 | neg ax |
929 | add ax, 18-1 |
960 | add ax, 18-1 |
930 | mov bx, 18 |
961 | mov bx, 18 |
931 | xor dx, dx |
962 | xor dx, dx |
932 | div bx |
963 | div bx |
933 | if lang eq ru |
964 | if lang eq ru |
934 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
965 | ; подождите 5 секунд, 4/3/2 секунды, 1 секунду |
935 | cmp al, 5 |
966 | cmp al, 5 |
936 | mov cl, ' ' |
967 | mov cl, ' ' |
937 | jae @f |
968 | jae @f |
938 | cmp al, 1 |
969 | cmp al, 1 |
939 | mov cl, 0xE3 ; 'у' in cp866 |
970 | mov cl, 0xE3 ; 'у' in cp866 |
940 | jz @f |
971 | jz @f |
941 | mov cl, 0xEB ; 'ы' in cp866 |
972 | mov cl, 0xEB ; 'ы' in cp866 |
942 | @@: |
973 | @@: |
943 | mov [time_str+9], cl |
974 | mov [time_str+9], cl |
944 | else if lang eq et |
975 | else if lang eq et |
945 | cmp al, 1 |
976 | cmp al, 1 |
946 | ja @f |
977 | ja @f |
947 | mov byte [time_str+9], ' ' |
978 | mov byte [time_str+9], ' ' |
948 | mov byte [time_str+10], ' ' |
979 | mov byte [time_str+10], ' ' |
949 | @@: |
980 | @@: |
950 | else if lang eq sp |
981 | else if lang eq sp |
951 | ; esperar 5/4/3/2 segundos, 1 segundo |
982 | ; esperar 5/4/3/2 segundos, 1 segundo |
952 | cmp al, 1 |
983 | cmp al, 1 |
953 | mov cl, 's' |
984 | mov cl, 's' |
954 | ja @f |
985 | ja @f |
955 | mov cl, ' ' |
986 | mov cl, ' ' |
956 | @@: |
987 | @@: |
957 | mov [time_str+10], cl |
988 | mov [time_str+10], cl |
958 | else |
989 | else |
959 | ; wait 5/4/3/2 seconds, 1 second |
990 | ; wait 5/4/3/2 seconds, 1 second |
960 | cmp al, 1 |
991 | cmp al, 1 |
961 | mov cl, 's' |
992 | mov cl, 's' |
962 | ja @f |
993 | ja @f |
963 | mov cl, ' ' |
994 | mov cl, ' ' |
964 | @@: |
995 | @@: |
965 | mov [time_str+9], cl |
996 | mov [time_str+9], cl |
966 | end if |
997 | end if |
967 | add al, '0' |
998 | add al, '0' |
968 | mov [time_str+1], al |
999 | mov [time_str+1], al |
969 | mov si, time_msg |
1000 | mov si, time_msg |
970 | _setcursor 7,0 |
1001 | _setcursor 7,0 |
971 | call print |
1002 | call print |
972 | _setcursor 25,0 |
1003 | _setcursor 25,0 |
973 | popad |
1004 | popad |
974 | pop ds |
1005 | pop ds |
975 | iret |
1006 | iret |
976 | .timergo: |
1007 | .timergo: |
977 | push 0 |
1008 | push 0 |
978 | pop es |
1009 | pop es |
979 | mov eax, [.oldtimer] |
1010 | mov eax, [.oldtimer] |
980 | mov [es:8*4], eax |
1011 | mov [es:8*4], eax |
981 | mov sp, 0EC00h |
1012 | mov sp, 0EC00h |
982 | .continue: |
1013 | .continue: |
983 | sti |
1014 | sti |
984 | _setcursor 6,0 |
1015 | _setcursor 6,0 |
985 | mov si, space_msg |
1016 | mov si, space_msg |
986 | call printplain |
1017 | call printplain |
987 | call printplain |
1018 | call printplain |
988 | _setcursor 6,0 |
1019 | _setcursor 6,0 |
989 | mov si, loading_msg |
1020 | mov si, loading_msg |
990 | call print |
1021 | call print |
991 | _setcursor 15,0 |
1022 | _setcursor 16,0 |
992 | if ~ defined extended_primary_loader |
1023 | if ~ defined extended_primary_loader |
993 | cmp [.bSettingsChanged], 0 |
1024 | cmp [.bSettingsChanged], 0 |
994 | jz .load |
1025 | jz .load |
995 | cmp [.loader_block], -1 |
1026 | cmp [.loader_block], -1 |
996 | jz .load |
1027 | jz .load |
997 | les bx, [.loader_block] |
1028 | les bx, [.loader_block] |
998 | mov eax, [es:bx+3] |
1029 | mov eax, [es:bx+3] |
999 | push ds |
1030 | push ds |
1000 | pop es |
1031 | pop es |
1001 | test eax, eax |
1032 | test eax, eax |
1002 | jz .load |
1033 | jz .load |
1003 | push eax |
1034 | push eax |
1004 | mov si, save_quest |
1035 | mov si, save_quest |
1005 | call print |
1036 | call print |
1006 | .waityn: |
1037 | .waityn: |
1007 | mov ah, 0 |
1038 | mov ah, 0 |
1008 | int 16h |
1039 | int 16h |
1009 | or al, 20h |
1040 | or al, 20h |
1010 | cmp al, 'n' |
1041 | cmp al, 'n' |
1011 | jz .loadc |
1042 | jz .loadc |
1012 | if lang eq sp |
1043 | if lang eq sp |
1013 | cmp al, 's' |
1044 | cmp al, 's' |
1014 | else |
1045 | else |
1015 | cmp al, 'y' |
1046 | cmp al, 'y' |
1016 | end if |
1047 | end if |
1017 | jnz .waityn |
1048 | jnz .waityn |
1018 | call putchar |
1049 | call putchar |
1019 | mov byte [space_msg+80], 186 |
1050 | mov byte [space_msg+80], 186 |
1020 | 1051 | ||
1021 | pop eax |
1052 | pop eax |
1022 | push cs |
1053 | push cs |
1023 | push .cont |
1054 | push .cont |
1024 | push eax |
1055 | push eax |
1025 | retf ;call back |
1056 | retf ;call back |
1026 | .loadc: |
1057 | .loadc: |
1027 | pop eax |
1058 | pop eax |
1028 | .cont: |
1059 | .cont: |
1029 | push cs |
1060 | push cs |
1030 | pop ds |
1061 | pop ds |
1031 | mov si, space_msg |
1062 | mov si, space_msg |
1032 | mov byte [si+80], 0 |
1063 | mov byte [si+80], 0 |
1033 | _setcursor 15,0 |
1064 | _setcursor 16,0 |
1034 | call printplain |
1065 | call printplain |
1035 | _setcursor 15,0 |
1066 | _setcursor 16,0 |
1036 | .load: |
1067 | .load: |
1037 | end if |
1068 | end if |
1038 | ; \end{diamond}[02.12.2005] |
1069 | ; \end{diamond}[02.12.2005] |
1039 | 1070 | ||
1040 | ; ASK GRAPHICS MODE |
1071 | ; ASK GRAPHICS MODE |
1041 | 1072 | ||
1042 | call set_vmode |
1073 | call set_vmode |
1043 | 1074 | ||
1044 | ; GRAPHICS ACCELERATION |
1075 | ; GRAPHICS ACCELERATION |
1045 | ; force yes |
1076 | ; force yes |
1046 | mov [es:BOOT_MTRR], byte 1 |
1077 | mov [es:BOOT_MTRR], byte 1 |
1047 | 1078 | ||
1048 | ; DMA ACCESS TO HD |
1079 | ; DMA ACCESS TO HD |
1049 | 1080 | ||
1050 | mov al, [preboot_dma] |
1081 | mov al, [preboot_dma] |
1051 | mov [es:BOOT_DMA], al |
1082 | mov [es:BOOT_DMA], al |
1052 | 1083 | ||
1053 | ;; VRR_M USE |
1084 | ;; VRR_M USE |
1054 | ; |
1085 | ; |
1055 | ; mov al,[preboot_vrrm] |
1086 | ; mov al,[preboot_vrrm] |
- | 1087 | ; mov [es:BOOT_VRR], al ;// 0x9030 |
|
- | 1088 | ||
- | 1089 | ; Set kernel DEBUG mode - if nonzero, duplicates debug output to the screen. |
|
1056 | ; mov [es:0x9030], al |
1090 | mov al, [preboot_debug] |
- | 1091 | mov [es:BOOT_DEBUG_PRINT], al ;// 0x901E |
|
- | 1092 | ||
- | 1093 | ; Start the first app (right now it's LAUNCHER) after kernel is loaded? |
|
- | 1094 | mov al, [preboot_launcher] |
|
- | 1095 | mov [es:BOOT_LAUNCHER_START], al ;// 0x901D |
|
1057 | 1096 | ||
1058 | ; BOOT DEVICE |
1097 | ; BOOT DEVICE |
1059 | 1098 | ||
1060 | mov al, [preboot_device] |
1099 | mov al, [preboot_device] |
1061 | dec al |
1100 | dec al |
1062 | mov [boot_dev], al |
1101 | mov [boot_dev], al |
1063 | 1102 | ||
1064 | ; GET MEMORY MAP |
1103 | ; GET MEMORY MAP |
1065 | include '../detect/biosmem.inc' |
1104 | include '../detect/biosmem.inc' |
1066 | 1105 | ||
1067 | ; READ DISKETTE TO MEMORY |
1106 | ; READ DISKETTE TO MEMORY |
1068 | 1107 | ||
1069 | cmp [boot_dev], 0 |
1108 | cmp [boot_dev], 0 |
1070 | jne no_sys_on_floppy |
1109 | jne no_sys_on_floppy |
1071 | mov si, diskload |
1110 | mov si, diskload |
1072 | call print |
1111 | call print |
1073 | xor ax, ax ; reset drive |
1112 | xor ax, ax ; reset drive |
1074 | xor dx, dx |
1113 | xor dx, dx |
1075 | int 0x13 |
1114 | int 0x13 |
1076 | ; do we boot from CD-ROM? |
1115 | ; do we boot from CD-ROM? |
1077 | mov ah, 41h |
1116 | mov ah, 41h |
1078 | mov bx, 55AAh |
1117 | mov bx, 55AAh |
1079 | xor dx, dx |
1118 | xor dx, dx |
1080 | int 0x13 |
1119 | int 0x13 |
1081 | jc .nocd |
1120 | jc .nocd |
1082 | cmp bx, 0AA55h |
1121 | cmp bx, 0AA55h |
1083 | jnz .nocd |
1122 | jnz .nocd |
1084 | mov ah, 48h |
1123 | mov ah, 48h |
1085 | push ds |
1124 | push ds |
1086 | push es |
1125 | push es |
1087 | pop ds |
1126 | pop ds |
1088 | mov si, 0xa000 |
1127 | mov si, 0xa000 |
1089 | mov word [si], 30 |
1128 | mov word [si], 30 |
1090 | int 0x13 |
1129 | int 0x13 |
1091 | pop ds |
1130 | pop ds |
1092 | jc .nocd |
1131 | jc .nocd |
1093 | push ds |
1132 | push ds |
1094 | lds si, [es:si+26] |
1133 | lds si, [es:si+26] |
1095 | test byte [ds:si+10], 40h |
1134 | test byte [ds:si+10], 40h |
1096 | pop ds |
1135 | pop ds |
1097 | jz .nocd |
1136 | jz .nocd |
1098 | ; yes - read all floppy by 18 sectors |
1137 | ; yes - read all floppy by 18 sectors |
1099 | 1138 | ||
1100 | ; TODO: !!!! read only first sector and set variables !!!!! |
1139 | ; TODO: !!!! read only first sector and set variables !!!!! |
1101 | ; ... |
1140 | ; ... |
1102 | ; TODO: !!! then read flippy image track by track |
1141 | ; TODO: !!! then read flippy image track by track |
1103 | 1142 | ||
1104 | mov cx, 0x0001 ; startcyl,startsector |
1143 | mov cx, 0x0001 ; startcyl,startsector |
1105 | .a1: |
1144 | .a1: |
1106 | push cx dx |
1145 | push cx dx |
1107 | mov al, 18 |
1146 | mov al, 18 |
1108 | mov bx, 0xa000 |
1147 | mov bx, 0xa000 |
1109 | call boot_read_floppy |
1148 | call boot_read_floppy |
1110 | mov si, movedesc |
1149 | mov si, movedesc |
1111 | push es |
1150 | push es |
1112 | push ds |
1151 | push ds |
1113 | pop es |
1152 | pop es |
1114 | mov cx, 256*18 |
1153 | mov cx, 256*18 |
1115 | mov ah, 0x87 |
1154 | mov ah, 0x87 |
1116 | int 0x15 |
1155 | int 0x15 |
1117 | pop es |
1156 | pop es |
1118 | pop dx cx |
1157 | pop dx cx |
1119 | test ah, ah |
1158 | test ah, ah |
1120 | jnz sayerr_floppy |
1159 | jnz sayerr_floppy |
1121 | add dword [si+8*3+2], 512*18 |
1160 | add dword [si+8*3+2], 512*18 |
1122 | inc dh |
1161 | inc dh |
1123 | cmp dh, 2 |
1162 | cmp dh, 2 |
1124 | jnz .a1 |
1163 | jnz .a1 |
1125 | mov dh, 0 |
1164 | mov dh, 0 |
1126 | inc ch |
1165 | inc ch |
1127 | cmp ch, 80 |
1166 | cmp ch, 80 |
1128 | jae ok_sys_on_floppy |
1167 | jae ok_sys_on_floppy |
1129 | pusha |
1168 | pusha |
1130 | mov al, ch |
1169 | mov al, ch |
1131 | shr ch, 2 |
1170 | shr ch, 2 |
1132 | add al, ch |
1171 | add al, ch |
1133 | aam |
1172 | aam |
1134 | xchg al, ah |
1173 | xchg al, ah |
1135 | add ax, '00' |
1174 | add ax, '00' |
1136 | mov si, pros |
1175 | mov si, pros |
1137 | mov [si], ax |
1176 | mov [si], ax |
1138 | call printplain |
1177 | call printplain |
1139 | popa |
1178 | popa |
1140 | jmp .a1 |
1179 | jmp .a1 |
1141 | .nocd: |
1180 | .nocd: |
1142 | ; no - read only used sectors from floppy |
1181 | ; no - read only used sectors from floppy |
1143 | ; now load floppy image to memory |
1182 | ; now load floppy image to memory |
1144 | ; at first load boot sector and first FAT table |
1183 | ; at first load boot sector and first FAT table |
1145 | 1184 | ||
1146 | ; read only first sector and fill variables |
1185 | ; read only first sector and fill variables |
1147 | mov cx, 0x0001 ; first logical sector |
1186 | mov cx, 0x0001 ; first logical sector |
1148 | xor dx, dx ; head = 0, drive = 0 (a:) |
1187 | xor dx, dx ; head = 0, drive = 0 (a:) |
1149 | mov al, 1 ; read one sector |
1188 | mov al, 1 ; read one sector |
1150 | mov bx, 0xB000 ; es:bx -> data area |
1189 | mov bx, 0xB000 ; es:bx -> data area |
1151 | call boot_read_floppy |
1190 | call boot_read_floppy |
1152 | ; fill the necessary parameters to work with a floppy |
1191 | ; fill the necessary parameters to work with a floppy |
1153 | mov ax, word [es:bx+24] |
1192 | mov ax, word [es:bx+24] |
1154 | mov word [BPB_SecPerTrk], ax |
1193 | mov word [BPB_SecPerTrk], ax |
1155 | mov ax, word [es:bx+26] |
1194 | mov ax, word [es:bx+26] |
1156 | mov word [BPB_NumHeads], ax |
1195 | mov word [BPB_NumHeads], ax |
1157 | mov ax, word [es:bx+17] |
1196 | mov ax, word [es:bx+17] |
1158 | mov word [BPB_RootEntCnt], ax |
1197 | mov word [BPB_RootEntCnt], ax |
1159 | mov ax, word [es:bx+14] |
1198 | mov ax, word [es:bx+14] |
1160 | mov word [BPB_RsvdSecCnt], ax |
1199 | mov word [BPB_RsvdSecCnt], ax |
1161 | mov ax, word [es:bx+19] |
1200 | mov ax, word [es:bx+19] |
1162 | mov word [BPB_TotSec16], ax |
1201 | mov word [BPB_TotSec16], ax |
1163 | mov al, byte [es:bx+13] |
1202 | mov al, byte [es:bx+13] |
1164 | mov byte [BPB_SecPerClus], al |
1203 | mov byte [BPB_SecPerClus], al |
1165 | mov al, byte [es:bx+16] |
1204 | mov al, byte [es:bx+16] |
1166 | mov byte [BPB_NumFATs], al |
1205 | mov byte [BPB_NumFATs], al |
1167 | ; |
1206 | ; |
1168 | mov ax, word [es:bx+22] |
1207 | mov ax, word [es:bx+22] |
1169 | mov word [BPB_FATSz16], ax |
1208 | mov word [BPB_FATSz16], ax |
1170 | mov cx, word [es:bx+11] |
1209 | mov cx, word [es:bx+11] |
1171 | mov word [BPB_BytsPerSec], cx |
1210 | mov word [BPB_BytsPerSec], cx |
1172 | 1211 | ||
1173 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
1212 | ; count of clusters in FAT12 ((size_of_FAT*2)/3) |
1174 | ; mov ax, word [BPB_FATSz16] |
1213 | ; mov ax, word [BPB_FATSz16] |
1175 | ; mov cx, word [BPB_BytsPerSec] |
1214 | ; mov cx, word [BPB_BytsPerSec] |
1176 | ;end |
1215 | ;end |
1177 | xor dx, dx |
1216 | xor dx, dx |
1178 | mul cx |
1217 | mul cx |
1179 | shl ax, 1 |
1218 | shl ax, 1 |
1180 | mov cx, 3 |
1219 | mov cx, 3 |
1181 | div cx ; now ax - number of clusters in FAT12 |
1220 | div cx ; now ax - number of clusters in FAT12 |
1182 | mov word [end_of_FAT], ax |
1221 | mov word [end_of_FAT], ax |
1183 | 1222 | ||
1184 | ; load first FAT table |
1223 | ; load first FAT table |
1185 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
1224 | mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! |
1186 | xor dx, dx ; starthead,drive |
1225 | xor dx, dx ; starthead,drive |
1187 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
1226 | mov al, byte [BPB_FATSz16] ; no of sectors to read |
1188 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
1227 | add bx, word [BPB_BytsPerSec] ; es:bx -> data area |
1189 | call boot_read_floppy |
1228 | call boot_read_floppy |
1190 | mov bx, 0xB000 |
1229 | mov bx, 0xB000 |
1191 | 1230 | ||
1192 | ; and copy them to extended memory |
1231 | ; and copy them to extended memory |
1193 | mov si, movedesc |
1232 | mov si, movedesc |
1194 | mov [si+8*2+3], bh ; from |
1233 | mov [si+8*2+3], bh ; from |
1195 | 1234 | ||
1196 | mov ax, word [BPB_BytsPerSec] |
1235 | mov ax, word [BPB_BytsPerSec] |
1197 | shr ax, 1 ; words per sector |
1236 | shr ax, 1 ; words per sector |
1198 | mov cx, word [BPB_RsvdSecCnt] |
1237 | mov cx, word [BPB_RsvdSecCnt] |
1199 | add cx, word [BPB_FATSz16] |
1238 | add cx, word [BPB_FATSz16] |
1200 | mul cx |
1239 | mul cx |
1201 | push ax ; save to stack count of words in boot+FAT |
1240 | push ax ; save to stack count of words in boot+FAT |
1202 | xchg ax, cx |
1241 | xchg ax, cx |
1203 | 1242 | ||
1204 | push es |
1243 | push es |
1205 | push ds |
1244 | push ds |
1206 | pop es |
1245 | pop es |
1207 | mov ah, 0x87 |
1246 | mov ah, 0x87 |
1208 | int 0x15 |
1247 | int 0x15 |
1209 | pop es |
1248 | pop es |
1210 | test ah, ah |
1249 | test ah, ah |
1211 | jz @f |
1250 | jz @f |
1212 | sayerr_floppy: |
1251 | sayerr_floppy: |
1213 | mov dx, 0x3f2 |
1252 | mov dx, 0x3f2 |
1214 | mov al, 0 |
1253 | mov al, 0 |
1215 | out dx, al |
1254 | out dx, al |
1216 | sayerr_memmove: |
1255 | sayerr_memmove: |
1217 | mov si, memmovefailed |
1256 | mov si, memmovefailed |
1218 | jmp sayerr_plain |
1257 | jmp sayerr_plain |
1219 | @@: |
1258 | @@: |
1220 | pop ax ; restore from stack count of words in boot+FAT |
1259 | pop ax ; restore from stack count of words in boot+FAT |
1221 | shl ax, 1 ; make bytes count from count of words |
1260 | shl ax, 1 ; make bytes count from count of words |
1222 | and eax, 0ffffh |
1261 | and eax, 0ffffh |
1223 | add dword [si+8*3+2], eax |
1262 | add dword [si+8*3+2], eax |
1224 | 1263 | ||
1225 | ; copy first FAT to second copy |
1264 | ; copy first FAT to second copy |
1226 | ; TODO: BPB_NumFATs !!!!! |
1265 | ; TODO: BPB_NumFATs !!!!! |
1227 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
1266 | add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! |
1228 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
1267 | mov byte [si+8*2+3], bh ; bx - begin of FAT |
1229 | 1268 | ||
1230 | mov ax, word [BPB_BytsPerSec] |
1269 | mov ax, word [BPB_BytsPerSec] |
1231 | shr ax, 1 ; words per sector |
1270 | shr ax, 1 ; words per sector |
1232 | mov cx, word [BPB_FATSz16] |
1271 | mov cx, word [BPB_FATSz16] |
1233 | mul cx |
1272 | mul cx |
1234 | mov cx, ax ; cx - count of words in FAT |
1273 | mov cx, ax ; cx - count of words in FAT |
1235 | 1274 | ||
1236 | push es |
1275 | push es |
1237 | push ds |
1276 | push ds |
1238 | pop es |
1277 | pop es |
1239 | mov ah, 0x87 |
1278 | mov ah, 0x87 |
1240 | int 0x15 |
1279 | int 0x15 |
1241 | pop es |
1280 | pop es |
1242 | test ah, ah |
1281 | test ah, ah |
1243 | jnz sayerr_floppy |
1282 | jnz sayerr_floppy |
1244 | 1283 | ||
1245 | mov ax, cx |
1284 | mov ax, cx |
1246 | shl ax, 1 |
1285 | shl ax, 1 |
1247 | and eax, 0ffffh ; ax - count of bytes in FAT |
1286 | and eax, 0ffffh ; ax - count of bytes in FAT |
1248 | add dword [si+8*3+2], eax |
1287 | add dword [si+8*3+2], eax |
1249 | 1288 | ||
1250 | ; reading RootDir |
1289 | ; reading RootDir |
1251 | ; TODO: BPB_NumFATs |
1290 | ; TODO: BPB_NumFATs |
1252 | add bx, ax |
1291 | add bx, ax |
1253 | add bx, 100h |
1292 | add bx, 100h |
1254 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
1293 | and bx, 0ff00h ; bx - place in buffer to write RootDir |
1255 | push bx |
1294 | push bx |
1256 | 1295 | ||
1257 | mov bx, word [BPB_BytsPerSec] |
1296 | mov bx, word [BPB_BytsPerSec] |
1258 | shr bx, 5 ; divide bx by 32 |
1297 | shr bx, 5 ; divide bx by 32 |
1259 | mov ax, word [BPB_RootEntCnt] |
1298 | mov ax, word [BPB_RootEntCnt] |
1260 | xor dx, dx |
1299 | xor dx, dx |
1261 | div bx |
1300 | div bx |
1262 | push ax ; ax - count of RootDir sectors |
1301 | push ax ; ax - count of RootDir sectors |
1263 | 1302 | ||
1264 | mov ax, word [BPB_FATSz16] |
1303 | mov ax, word [BPB_FATSz16] |
1265 | xor cx, cx |
1304 | xor cx, cx |
1266 | mov cl, byte [BPB_NumFATs] |
1305 | mov cl, byte [BPB_NumFATs] |
1267 | mul cx |
1306 | mul cx |
1268 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1307 | add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir |
1269 | 1308 | ||
1270 | mov word [FirstDataSector], ax |
1309 | mov word [FirstDataSector], ax |
1271 | pop bx |
1310 | pop bx |
1272 | push bx |
1311 | push bx |
1273 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1312 | add word [FirstDataSector], bx ; Begin of data region of floppy |
1274 | 1313 | ||
1275 | ; read RootDir |
1314 | ; read RootDir |
1276 | call conv_abs_to_THS |
1315 | call conv_abs_to_THS |
1277 | pop ax |
1316 | pop ax |
1278 | pop bx ; place in buffer to write |
1317 | pop bx ; place in buffer to write |
1279 | push ax |
1318 | push ax |
1280 | call boot_read_floppy ; read RootDir into buffer |
1319 | call boot_read_floppy ; read RootDir into buffer |
1281 | ; copy RootDir |
1320 | ; copy RootDir |
1282 | mov byte [si+8*2+3], bh ; from buffer |
1321 | mov byte [si+8*2+3], bh ; from buffer |
1283 | pop ax ; ax = count of RootDir sectors |
1322 | pop ax ; ax = count of RootDir sectors |
1284 | mov cx, word [BPB_BytsPerSec] |
1323 | mov cx, word [BPB_BytsPerSec] |
1285 | mul cx |
1324 | mul cx |
1286 | shr ax, 1 |
1325 | shr ax, 1 |
1287 | mov cx, ax ; count of words to copy |
1326 | mov cx, ax ; count of words to copy |
1288 | push es |
1327 | push es |
1289 | push ds |
1328 | push ds |
1290 | pop es |
1329 | pop es |
1291 | mov ah, 0x87 |
1330 | mov ah, 0x87 |
1292 | int 0x15 |
1331 | int 0x15 |
1293 | pop es |
1332 | pop es |
1294 | 1333 | ||
1295 | mov ax, cx |
1334 | mov ax, cx |
1296 | shl ax, 1 |
1335 | shl ax, 1 |
1297 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1336 | and eax, 0ffffh ; ax - count of bytes in RootDir |
1298 | add dword [si+8*3+2], eax ; add count of bytes copied |
1337 | add dword [si+8*3+2], eax ; add count of bytes copied |
1299 | 1338 | ||
1300 | ; Reading data clusters from floppy |
1339 | ; Reading data clusters from floppy |
1301 | mov byte [si+8*2+3], bh |
1340 | mov byte [si+8*2+3], bh |
1302 | push bx |
1341 | push bx |
1303 | 1342 | ||
1304 | mov di, 2 ; First data cluster |
1343 | mov di, 2 ; First data cluster |
1305 | .read_loop: |
1344 | .read_loop: |
1306 | mov bx, di |
1345 | mov bx, di |
1307 | shr bx, 1 ; bx+di = di*1.5 |
1346 | shr bx, 1 ; bx+di = di*1.5 |
1308 | jnc .even |
1347 | jnc .even |
1309 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1348 | test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! |
1310 | jmp @f |
1349 | jmp @f |
1311 | .even: |
1350 | .even: |
1312 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1351 | test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! |
1313 | 1352 | ||
1314 | @@: |
1353 | @@: |
1315 | jz .skip |
1354 | jz .skip |
1316 | ; read cluster di |
1355 | ; read cluster di |
1317 | ;.read: |
1356 | ;.read: |
1318 | ;conv cluster di to abs. sector ax |
1357 | ;conv cluster di to abs. sector ax |
1319 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1358 | ; ax = (N-2) * BPB_SecPerClus + FirstDataSector |
1320 | mov ax, di |
1359 | mov ax, di |
1321 | sub ax, 2 |
1360 | sub ax, 2 |
1322 | xor bx, bx |
1361 | xor bx, bx |
1323 | mov bl, byte [BPB_SecPerClus] |
1362 | mov bl, byte [BPB_SecPerClus] |
1324 | mul bx |
1363 | mul bx |
1325 | add ax, word [FirstDataSector] |
1364 | add ax, word [FirstDataSector] |
1326 | call conv_abs_to_THS |
1365 | call conv_abs_to_THS |
1327 | pop bx |
1366 | pop bx |
1328 | push bx |
1367 | push bx |
1329 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1368 | mov al, byte [BPB_SecPerClus] ; number of sectors in cluster |
1330 | call boot_read_floppy |
1369 | call boot_read_floppy |
1331 | push es |
1370 | push es |
1332 | push ds |
1371 | push ds |
1333 | pop es |
1372 | pop es |
1334 | pusha |
1373 | pusha |
1335 | ; |
1374 | ; |
1336 | mov ax, word [BPB_BytsPerSec] |
1375 | mov ax, word [BPB_BytsPerSec] |
1337 | xor cx, cx |
1376 | xor cx, cx |
1338 | mov cl, byte [BPB_SecPerClus] |
1377 | mov cl, byte [BPB_SecPerClus] |
1339 | mul cx |
1378 | mul cx |
1340 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1379 | shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 |
1341 | mov cx, ax ; number of words to copy (count words in cluster) |
1380 | mov cx, ax ; number of words to copy (count words in cluster) |
1342 | ; |
1381 | ; |
1343 | mov ah, 0x87 |
1382 | mov ah, 0x87 |
1344 | int 0x15 ; copy data |
1383 | int 0x15 ; copy data |
1345 | test ah, ah |
1384 | test ah, ah |
1346 | popa |
1385 | popa |
1347 | pop es |
1386 | pop es |
1348 | jnz sayerr_floppy |
1387 | jnz sayerr_floppy |
1349 | ; skip cluster di |
1388 | ; skip cluster di |
1350 | .skip: |
1389 | .skip: |
1351 | mov ax, word [BPB_BytsPerSec] |
1390 | mov ax, word [BPB_BytsPerSec] |
1352 | xor cx, cx |
1391 | xor cx, cx |
1353 | mov cl, byte [BPB_SecPerClus] |
1392 | mov cl, byte [BPB_SecPerClus] |
1354 | mul cx |
1393 | mul cx |
1355 | and eax, 0ffffh ; ax - count of bytes in cluster |
1394 | and eax, 0ffffh ; ax - count of bytes in cluster |
1356 | add dword [si+8*3+2], eax |
1395 | add dword [si+8*3+2], eax |
1357 | 1396 | ||
1358 | mov ax, word [end_of_FAT] ; max cluster number |
1397 | mov ax, word [end_of_FAT] ; max cluster number |
1359 | pusha |
1398 | pusha |
1360 | ; draw percentage |
1399 | ; draw percentage |
1361 | ; total clusters: ax |
1400 | ; total clusters: ax |
1362 | ; read clusters: di |
1401 | ; read clusters: di |
1363 | xchg ax, di |
1402 | xchg ax, di |
1364 | mov cx, 100 |
1403 | mov cx, 100 |
1365 | mul cx |
1404 | mul cx |
1366 | div di |
1405 | div di |
1367 | aam |
1406 | aam |
1368 | xchg al, ah |
1407 | xchg al, ah |
1369 | add ax, '00' |
1408 | add ax, '00' |
1370 | mov si, pros |
1409 | mov si, pros |
1371 | cmp [si], ax |
1410 | cmp [si], ax |
1372 | jz @f |
1411 | jz @f |
1373 | mov [si], ax |
1412 | mov [si], ax |
1374 | call printplain |
1413 | call printplain |
1375 | @@: |
1414 | @@: |
1376 | popa |
1415 | popa |
1377 | inc di |
1416 | inc di |
1378 | cmp di, word [end_of_FAT] ; max number of cluster |
1417 | cmp di, word [end_of_FAT] ; max number of cluster |
1379 | jnz .read_loop |
1418 | jnz .read_loop |
1380 | pop bx ; clear stack |
1419 | pop bx ; clear stack |
1381 | 1420 | ||
1382 | ok_sys_on_floppy: |
1421 | ok_sys_on_floppy: |
1383 | mov si, backspace2 |
1422 | mov si, backspace2 |
1384 | call printplain |
1423 | call printplain |
1385 | mov si, okt |
1424 | mov si, okt |
1386 | call printplain |
1425 | call printplain |
1387 | no_sys_on_floppy: |
1426 | no_sys_on_floppy: |
1388 | xor ax, ax ; reset drive |
1427 | xor ax, ax ; reset drive |
1389 | xor dx, dx |
1428 | xor dx, dx |
1390 | int 0x13 |
1429 | int 0x13 |
1391 | mov dx, 0x3f2 ; floppy motor off |
1430 | mov dx, 0x3f2 ; floppy motor off |
1392 | mov al, 0 |
1431 | mov al, 0 |
1393 | out dx, al |
1432 | out dx, al |
1394 | 1433 | ||
1395 | if defined extended_primary_loader |
1434 | if defined extended_primary_loader |
1396 | cmp [boot_dev], 1 |
1435 | cmp [boot_dev], 1 |
1397 | jne no_sys_from_primary |
1436 | jne no_sys_from_primary |
1398 | ; load kolibri.img using callback from primary loader |
1437 | ; load kolibri.img using callback from primary loader |
1399 | and word [movedesc + 24 + 2], 0 |
1438 | and word [movedesc + 24 + 2], 0 |
1400 | mov byte [movedesc + 24 + 4], 10h |
1439 | mov byte [movedesc + 24 + 4], 10h |
1401 | ; read in blocks of 64K until file is fully loaded |
1440 | ; read in blocks of 64K until file is fully loaded |
1402 | mov ax, 1 |
1441 | mov ax, 1 |
1403 | .repeat: |
1442 | .repeat: |
1404 | mov di, image_file_struct |
1443 | mov di, image_file_struct |
1405 | call [bootcallback] |
1444 | call [bootcallback] |
1406 | push cs |
1445 | push cs |
1407 | pop ds |
1446 | pop ds |
1408 | push cs |
1447 | push cs |
1409 | pop es |
1448 | pop es |
1410 | cmp bx, 1 |
1449 | cmp bx, 1 |
1411 | ja sayerr_badsect |
1450 | ja sayerr_badsect |
1412 | push bx |
1451 | push bx |
1413 | mov si, movedesc |
1452 | mov si, movedesc |
1414 | and word [si + 16 + 2], 0 |
1453 | and word [si + 16 + 2], 0 |
1415 | mov byte [si + 16 + 4], 4 |
1454 | mov byte [si + 16 + 4], 4 |
1416 | mov ah, 87h |
1455 | mov ah, 87h |
1417 | mov cx, 8000h |
1456 | mov cx, 8000h |
1418 | int 15h |
1457 | int 15h |
1419 | pop bx |
1458 | pop bx |
1420 | test ah, ah |
1459 | test ah, ah |
1421 | jnz sayerr_memmove |
1460 | jnz sayerr_memmove |
1422 | inc byte [si + 24 + 4] |
1461 | inc byte [si + 24 + 4] |
1423 | test bx, bx |
1462 | test bx, bx |
1424 | jz no_sys_from_primary |
1463 | jz no_sys_from_primary |
1425 | mov ax, 2 |
1464 | mov ax, 2 |
1426 | jmp .repeat |
1465 | jmp .repeat |
1427 | no_sys_from_primary: |
1466 | no_sys_from_primary: |
1428 | end if |
1467 | end if |
1429 | 1468 | ||
1430 | ; SET GRAPHICS |
1469 | ; SET GRAPHICS |
1431 | 1470 | ||
1432 | xor ax, ax |
1471 | xor ax, ax |
1433 | mov es, ax |
1472 | mov es, ax |
1434 | 1473 | ||
1435 | mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 |
1474 | mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200 |
1436 | mov bx, ax |
1475 | mov bx, ax |
1437 | cmp ax, 0x13 |
1476 | cmp ax, 0x13 |
1438 | je setgr |
1477 | je setgr |
1439 | cmp ax, 0x12 |
1478 | cmp ax, 0x12 |
1440 | je setgr |
1479 | je setgr |
1441 | mov ax, 0x4f02 ; Vesa |
1480 | mov ax, 0x4f02 ; Vesa |
1442 | setgr: |
1481 | setgr: |
1443 | int 0x10 |
1482 | int 0x10 |
1444 | test ah, ah |
1483 | test ah, ah |
1445 | mov si, fatalsel |
1484 | mov si, fatalsel |
1446 | jnz v_mode_error |
1485 | jnz v_mode_error |
1447 | ; set mode 0x12 graphics registers: |
1486 | ; set mode 0x12 graphics registers: |
1448 | cmp bx, 0x12 |
1487 | cmp bx, 0x12 |
1449 | jne gmok2 |
1488 | jne gmok2 |
1450 | 1489 | ||
1451 | mov al, 0x05 |
1490 | mov al, 0x05 |
1452 | mov dx, 0x03ce |
1491 | mov dx, 0x03ce |
1453 | push dx |
1492 | push dx |
1454 | out dx, al ; select GDC mode register |
1493 | out dx, al ; select GDC mode register |
1455 | mov al, 0x02 |
1494 | mov al, 0x02 |
1456 | inc dx |
1495 | inc dx |
1457 | out dx, al ; set write mode 2 |
1496 | out dx, al ; set write mode 2 |
1458 | 1497 | ||
1459 | mov al, 0x02 |
1498 | mov al, 0x02 |
1460 | mov dx, 0x03c4 |
1499 | mov dx, 0x03c4 |
1461 | out dx, al ; select VGA sequencer map mask register |
1500 | out dx, al ; select VGA sequencer map mask register |
1462 | mov al, 0x0f |
1501 | mov al, 0x0f |
1463 | inc dx |
1502 | inc dx |
1464 | out dx, al ; set mask for all planes 0-3 |
1503 | out dx, al ; set mask for all planes 0-3 |
1465 | 1504 | ||
1466 | mov al, 0x08 |
1505 | mov al, 0x08 |
1467 | pop dx |
1506 | pop dx |
1468 | out dx, al ; select GDC bit mask register |
1507 | out dx, al ; select GDC bit mask register |
1469 | ; for writes to 0x03cf |
1508 | ; for writes to 0x03cf |
1470 | gmok2: |
1509 | gmok2: |
1471 | push ds |
1510 | push ds |
1472 | pop es |
1511 | pop es |