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