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