Rev 514 | Rev 545 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
425 | victor | 1 | $Revision: 523 $ |
431 | serge | 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;; ;; |
||
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
5 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
||
6 | ;; Distributed under terms of the GNU General Public License ;; |
||
7 | ;; ;; |
||
8 | ;; BOOTCODE.INC ;; |
||
9 | ;; ;; |
||
10 | ;; KolibriOS 16-bit loader, ;; |
||
11 | ;; based on bootcode for MenuetOS ;; |
||
12 | ;; ;; |
||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1 | ha | 14 | |
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 |
||
45 | cmp al, 0 |
||
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 |
||
465 | serge | 94 | mov si, badsect |
134 | diamond | 95 | sayerr_plain: |
96 | call printplain |
||
97 | jmp $ |
||
98 | @@: |
||
99 | pop si |
||
100 | ret |
||
101 | |||
1 | ha | 102 | ;========================================================================= |
103 | ; |
||
104 | ; 16 BIT CODE |
||
105 | ; |
||
106 | ;========================================================================= |
||
107 | |||
108 | |||
109 | start_of_code: |
||
514 | diamond | 110 | cld |
29 | halyavin | 111 | ; \begin{diamond}[02.12.2005] |
514 | diamond | 112 | ; if bootloader sets ax = 'KL', then ds:si points to loader block |
113 | cmp ax, 'KL' |
||
114 | jnz @f |
||
115 | mov word [cs:cfgmanager.loader_block], si |
||
116 | mov word [cs:cfgmanager.loader_block+2], ds |
||
29 | halyavin | 117 | @@: |
118 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 119 | |
514 | diamond | 120 | ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk |
121 | ; (see comment to bx_from_load) |
||
122 | cmp cx, 'HA' |
||
123 | jnz no_hd_load |
||
124 | cmp dx,'RD' |
||
125 | jnz no_hd_load |
||
126 | mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] |
||
488 | spraid | 127 | no_hd_load: |
128 | |||
29 | halyavin | 129 | ; set up stack |
514 | diamond | 130 | mov ax, 3000h |
131 | mov ss, ax |
||
132 | mov sp, 0EC00h |
||
29 | halyavin | 133 | ; set up segment registers |
514 | diamond | 134 | push cs |
135 | pop ds |
||
136 | push cs |
||
137 | pop es |
||
1 | ha | 138 | |
29 | halyavin | 139 | ; set videomode |
514 | diamond | 140 | mov ax, 3 |
141 | int 0x10 |
||
1 | ha | 142 | |
134 | diamond | 143 | if lang eq ru |
1 | ha | 144 | ; Load & set russian VGA font (RU.INC) |
514 | diamond | 145 | mov bp, RU_FNT1 ; RU_FNT1 - First part |
146 | mov bx, 1000h ; 768 bytes |
||
147 | mov cx, 30h ; 48 symbols |
||
148 | mov dx, 80h ; 128 - position of first symbol |
||
149 | mov ax, 1100h |
||
150 | int 10h |
||
1 | ha | 151 | |
514 | diamond | 152 | mov bp, RU_FNT2 ; RU_FNT2 -Second part |
153 | mov bx, 1000h ; 512 bytes |
||
154 | mov cx, 20h ; 32 symbols |
||
155 | mov dx, 0E0h ; 224 - position of first symbol |
||
156 | mov ax, 1100h |
||
157 | int 10h |
||
1 | ha | 158 | ; End set VGA russian font |
274 | kaitz | 159 | else if lang eq et |
514 | diamond | 160 | mov bp, ET_FNT ; ET_FNT1 |
161 | mov bx, 1000h ; |
||
162 | mov cx, 255 ; 256 symbols |
||
163 | xor dx, dx ; 0 - position of first symbol |
||
164 | mov ax, 1100h |
||
165 | int 10h |
||
134 | diamond | 166 | end if |
1 | ha | 167 | |
29 | halyavin | 168 | ; draw frames |
514 | diamond | 169 | push 0xb800 |
170 | pop es |
||
171 | xor di, di |
||
172 | mov ah, 1*16+15 |
||
465 | serge | 173 | |
29 | halyavin | 174 | ; draw top |
514 | diamond | 175 | mov si, d80x25_top |
176 | mov cx, d80x25_top_num * 80 |
||
29 | halyavin | 177 | @@: |
514 | diamond | 178 | lodsb |
179 | stosw |
||
180 | loop @b |
||
29 | halyavin | 181 | ; draw spaces |
514 | diamond | 182 | mov si, space_msg |
183 | mov dx, 25 - d80x25_top_num - d80x25_bottom_num |
||
29 | halyavin | 184 | dfl1: |
514 | diamond | 185 | push si |
186 | mov cx, 80 |
||
29 | halyavin | 187 | @@: |
514 | diamond | 188 | lodsb |
189 | stosw |
||
190 | loop @b |
||
191 | pop si |
||
192 | dec dx |
||
193 | jnz dfl1 |
||
29 | halyavin | 194 | ; draw bottom |
514 | diamond | 195 | mov si, d80x25_bottom |
196 | mov cx, d80x25_bottom_num * 80 |
||
29 | halyavin | 197 | @@: |
514 | diamond | 198 | lodsb |
199 | stosw |
||
200 | loop @b |
||
1 | ha | 201 | |
514 | diamond | 202 | mov byte [space_msg+80], 0 ; now space_msg is null terminated |
1 | ha | 203 | |
514 | diamond | 204 | _setcursor d80x25_top_num,0 |
1 | ha | 205 | |
206 | |||
207 | ; TEST FOR 386+ |
||
208 | |||
514 | diamond | 209 | mov bx, 0x4000 |
1 | ha | 210 | pushf |
211 | pop ax |
||
514 | diamond | 212 | mov dx, ax |
213 | xor ax, bx |
||
1 | ha | 214 | push ax |
215 | popf |
||
216 | pushf |
||
217 | pop ax |
||
514 | diamond | 218 | and ax, bx |
219 | and dx, bx |
||
220 | cmp ax, dx |
||
1 | ha | 221 | jnz cpugood |
514 | diamond | 222 | mov si, not386 |
40 | halyavin | 223 | sayerr: |
1 | ha | 224 | call print |
225 | jmp $ |
||
226 | cpugood: |
||
227 | |||
514 | diamond | 228 | push 0 |
465 | serge | 229 | popf |
230 | sti |
||
231 | |||
29 | halyavin | 232 | ; set up esp |
514 | diamond | 233 | movzx esp, sp |
1 | ha | 234 | |
160 | diamond | 235 | push 0 |
236 | pop es |
||
237 | and word [es:0x9031], 0 |
||
164 | serge | 238 | ; \begin{Mario79} |
239 | ; find HDD IDE DMA PCI device |
||
160 | diamond | 240 | ; check for PCI BIOS |
241 | mov ax, 0xB101 |
||
242 | int 0x1A |
||
243 | jc .nopci |
||
244 | cmp edx, 'PCI ' |
||
245 | jnz .nopci |
||
246 | ; find PCI class code |
||
247 | ; class 1 = mass storage |
||
248 | ; subclass 1 = IDE controller |
||
249 | ; a) class 1, subclass 1, programming interface 0x80 |
||
250 | mov ax, 0xB103 |
||
251 | mov ecx, 1*10000h + 1*100h + 0x80 |
||
514 | diamond | 252 | xor si, si ; device index = 0 |
160 | diamond | 253 | int 0x1A |
254 | jnc .found |
||
187 | diamond | 255 | ; b) class 1, subclass 1, programming interface 0x8A |
160 | diamond | 256 | mov ax, 0xB103 |
187 | diamond | 257 | mov ecx, 1*10000h + 1*100h + 0x8A |
514 | diamond | 258 | xor si, si ; device index = 0 |
160 | diamond | 259 | int 0x1A |
260 | jnc .found |
||
187 | diamond | 261 | ; c) class 1, subclass 1, programming interface 0x85 |
160 | diamond | 262 | mov ax, 0xB103 |
187 | diamond | 263 | mov ecx, 1*10000h + 1*100h + 0x85 |
514 | diamond | 264 | xor si, si |
160 | diamond | 265 | int 0x1A |
266 | jc .nopci |
||
267 | .found: |
||
268 | ; get memory base |
||
269 | mov ax, 0xB10A |
||
270 | mov di, 0x20 ; memory base is config register at 0x20 |
||
271 | int 0x1A |
||
272 | jc .nopci |
||
273 | and cx, 0xFFF0 ; clear address decode type |
||
274 | mov [es:0x9031], cx |
||
275 | .nopci: |
||
164 | serge | 276 | ; \end{Mario79} |
160 | diamond | 277 | |
514 | diamond | 278 | mov al, 0xf6 ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå |
279 | out 0x60, al |
||
280 | xor cx, cx |
||
1 | ha | 281 | wait_loop: ; variant 2 |
282 | ; reading state of port of 8042 controller |
||
514 | diamond | 283 | in al, 64h |
284 | and al, 00000010b ; ready flag |
||
164 | serge | 285 | ; wait until 8042 controller is ready |
1 | ha | 286 | loopnz wait_loop |
287 | |||
76 | mario79 | 288 | ; --------------- APM --------------------- |
514 | diamond | 289 | and word [es:0x9044], 0 ; ver = 0.0 (APM not found) |
290 | mov ax, 0x5300 |
||
291 | xor bx, bx |
||
292 | int 0x15 |
||
293 | jc apm_end ; APM not found |
||
294 | test cx, 2 |
||
295 | jz apm_end ; APM 32-bit protected-mode interface not supported |
||
296 | mov [es:0x9044], ax ; Save APM Version |
||
297 | mov [es:0x9046], cx ; Save APM flags |
||
164 | serge | 298 | |
514 | diamond | 299 | ; Write APM ver ---- |
300 | and ax, 0xf0f |
||
301 | add ax, '00' |
||
302 | mov si, msg_apm |
||
303 | mov [si + 5], ah |
||
304 | mov [si + 7], al |
||
305 | _setcursor 0, 3 |
||
306 | call printplain |
||
307 | ; ------------------ |
||
164 | serge | 308 | |
514 | diamond | 309 | mov ax, 0x5304 ; Disconnect interface |
310 | xor bx, bx |
||
311 | int 0x15 |
||
312 | mov ax, 0x5303 ; Connect 32 bit mode interface |
||
313 | xor bx, bx |
||
314 | int 0x15 |
||
465 | serge | 315 | |
514 | diamond | 316 | mov [es:0x9040], ebx |
317 | mov [es:0x9050], ax |
||
318 | mov [es:0x9052], cx |
||
319 | mov [es:0x9054], dx |
||
465 | serge | 320 | |
76 | mario79 | 321 | apm_end: |
437 | diamond | 322 | _setcursor d80x25_top_num, 0 |
76 | mario79 | 323 | |
1 | ha | 324 | ; DISPLAY VESA INFORMATION |
325 | |||
514 | diamond | 326 | mov ax, 0x4f00 |
327 | mov di, 0xa000 |
||
1 | ha | 328 | int 0x10 |
514 | diamond | 329 | cmp ax, 0x004f |
330 | mov si, novesa |
||
331 | jnz @f |
||
332 | mov ax, [es:di+4] |
||
333 | add ax, '0'*256+'0' |
||
334 | mov si, vervesa |
||
40 | halyavin | 335 | mov [si+vervesa_off], ah |
336 | mov [si+vervesa_off+2], al |
||
29 | halyavin | 337 | @@: call print |
1 | ha | 338 | |
29 | halyavin | 339 | ; \begin{diamond}[30.11.2005] |
340 | cfgmanager: |
||
341 | ; settings: |
||
342 | ; a) preboot_graph = graphical mode |
||
343 | ; preboot_gprobe = probe this mode? |
||
514 | diamond | 344 | ; b) preboot_dma = use DMA access? |
29 | halyavin | 345 | ; c) preboot_vrrm = use VRR? |
346 | ; d) preboot_device = from what boot? |
||
514 | diamond | 347 | mov di, preboot_graph |
29 | halyavin | 348 | ; check bootloader block |
514 | diamond | 349 | cmp [.loader_block], -1 |
350 | jz .noloaderblock |
||
351 | les bx, [.loader_block] |
||
352 | cmp byte [es:bx], 1 |
||
353 | mov si, loader_block_error |
||
354 | jnz sayerr |
||
355 | test byte [es:bx+1], 1 |
||
356 | jz @f |
||
29 | halyavin | 357 | ; image in memory present |
514 | diamond | 358 | cmp [di+preboot_device-preboot_graph], 0 |
359 | jnz @f |
||
360 | mov [di+preboot_device-preboot_graph], 3 |
||
29 | halyavin | 361 | @@: |
362 | .noloaderblock: |
||
363 | ; determine default settings |
||
514 | diamond | 364 | mov [.bSettingsChanged], 0 |
365 | cmp byte [di], 0 |
||
366 | jnz .preboot_gr_end |
||
367 | mov [di+preboot_gprobe-preboot_graph], 0 |
||
368 | mov al, [vervesa+vervesa_off] |
||
369 | cmp al, 'x' |
||
370 | jz .novesa |
||
371 | cmp al, '1' |
||
372 | jz .vesa12 |
||
373 | mov [di+preboot_gprobe-preboot_graph], 2 |
||
374 | mov al, 3 |
||
375 | jmp @f |
||
29 | halyavin | 376 | .vesa12: |
514 | diamond | 377 | mov al, 7 |
378 | jmp @f |
||
29 | halyavin | 379 | .novesa: |
514 | diamond | 380 | mov al, 10 |
29 | halyavin | 381 | @@: |
514 | diamond | 382 | mov [di], al |
29 | halyavin | 383 | .preboot_gr_end: |
523 | diamond | 384 | cmp [di+preboot_dma-preboot_graph], 0 |
385 | jnz @f |
||
386 | mov [di+preboot_dma-preboot_graph], 3 ; DMA: defaults to none |
||
387 | @@: |
||
388 | ; following 4 lines set variables to 1 if its current value is 0 |
||
514 | diamond | 389 | cmp [di+preboot_vrrm-preboot_graph], 1 |
390 | adc [di+preboot_vrrm-preboot_graph], 0 |
||
391 | cmp [di+preboot_device-preboot_graph], 1 |
||
392 | adc [di+preboot_device-preboot_graph], 0 |
||
29 | halyavin | 393 | ; notify user |
514 | diamond | 394 | mov si, linef |
395 | call print |
||
396 | mov si, start_msg |
||
397 | call print |
||
398 | mov si, time_msg |
||
399 | call print |
||
29 | halyavin | 400 | ; get start time |
514 | diamond | 401 | call .gettime |
402 | mov [.starttime], eax |
||
403 | mov word [.timer], .newtimer |
||
404 | mov word [.timer+2], cs |
||
29 | halyavin | 405 | .printcfg: |
514 | diamond | 406 | _setcursor 9,0 |
407 | mov si, current_cfg_msg |
||
408 | call print |
||
409 | mov si, curvideo_msg |
||
410 | call print |
||
411 | mov al, [preboot_graph] |
||
412 | cmp al, 8 |
||
413 | ja .pnovesa |
||
414 | mov dl, al |
||
415 | and eax, 3 |
||
416 | mov si, [modes_msg+eax*2] |
||
417 | call printplain |
||
418 | mov si, modevesa20 |
||
419 | cmp dl, 4 |
||
420 | jbe @f |
||
421 | mov si, modevesa12 |
||
29 | halyavin | 422 | @@: |
514 | diamond | 423 | call printplain |
424 | cmp dl, 4 |
||
425 | ja .x |
||
426 | mov si, probeno_msg |
||
427 | cmp [preboot_gprobe], 2 |
||
428 | jnz @f |
||
429 | mov si, probeok_msg |
||
29 | halyavin | 430 | @@: |
514 | diamond | 431 | call printplain |
29 | halyavin | 432 | .x: |
514 | diamond | 433 | jmp .c |
29 | halyavin | 434 | .pnovesa: |
514 | diamond | 435 | cmp al, 9 |
436 | mov si, mode9 |
||
437 | jz @b |
||
438 | mov si, mode10 |
||
439 | jmp @b |
||
29 | halyavin | 440 | .c: |
514 | diamond | 441 | mov si, linef |
442 | call printplain |
||
443 | mov si, dma_msg |
||
444 | call print |
||
445 | cmp [preboot_dma], 2 |
||
446 | mov si, on_msg |
||
447 | jb @f |
||
448 | mov si, off_msg |
||
449 | ja @f |
||
450 | mov si, readonly_msg |
||
451 | @@: |
||
452 | call printplain |
||
453 | mov si, vrrm_msg |
||
454 | cmp [preboot_vrrm], 1 |
||
455 | call .say_on_off |
||
456 | mov si, preboot_device_msg |
||
457 | call print |
||
458 | mov al, [preboot_device] |
||
459 | and eax, 3 |
||
460 | mov si, [preboot_device_msgs+eax*2] |
||
461 | call printplain |
||
29 | halyavin | 462 | .wait: |
514 | diamond | 463 | _setcursor 25,0 ; out of screen |
34 | halyavin | 464 | ; set timer interrupt handler |
514 | diamond | 465 | cli |
466 | push 0 |
||
467 | pop es |
||
468 | mov eax, [es:8*4] |
||
469 | mov [.oldtimer], eax |
||
470 | mov eax, [.timer] |
||
471 | mov [es:8*4], eax |
||
472 | sti |
||
29 | halyavin | 473 | ; wait for keypressed |
514 | diamond | 474 | mov ah, 0 |
475 | int 16h |
||
476 | push ax |
||
29 | halyavin | 477 | ; restore timer interrupt |
514 | diamond | 478 | push 0 |
479 | pop es |
||
480 | mov eax, [.oldtimer] |
||
481 | mov [es:8*4], eax |
||
482 | mov [.timer], eax |
||
483 | _setcursor 7,0 |
||
484 | mov si, space_msg |
||
485 | call printplain |
||
486 | pop ax |
||
29 | halyavin | 487 | ; switch on key |
514 | diamond | 488 | cmp al, 13 |
489 | jz .continue |
||
490 | or al, 20h |
||
491 | cmp al, 'a' |
||
492 | jz .change_a |
||
493 | cmp al, 'b' |
||
494 | jz .change_b |
||
495 | cmp al, 'c' |
||
496 | jz .change_c |
||
497 | cmp al, 'd' |
||
498 | jnz .wait |
||
499 | _setcursor 15,0 |
||
500 | mov si, bdev |
||
501 | call print |
||
502 | mov bx, '13' |
||
503 | call getkey |
||
504 | mov [preboot_device], al |
||
505 | _setcursor 13,0 |
||
29 | halyavin | 506 | .d: |
514 | diamond | 507 | mov [.bSettingsChanged], 1 |
508 | mov si, space_msg |
||
509 | call printplain |
||
510 | _setcursor 15,0 |
||
511 | mov cx, 6 |
||
29 | halyavin | 512 | @@: |
514 | diamond | 513 | call printplain |
514 | loop @b |
||
515 | jmp .printcfg |
||
29 | halyavin | 516 | .change_a: |
514 | diamond | 517 | _setcursor 15,0 |
518 | mov si, gr_mode |
||
519 | call printplain |
||
520 | mov bx, '09' |
||
521 | call getkey |
||
522 | mov [preboot_graph], al |
||
523 | cmp al, 4 |
||
524 | ja @f |
||
525 | mov si, probetext |
||
526 | call printplain |
||
527 | mov bx, '12' |
||
528 | call getkey |
||
529 | mov [preboot_gprobe], al |
||
29 | halyavin | 530 | @@: |
514 | diamond | 531 | _setcursor 10,0 |
532 | jmp .d |
||
29 | halyavin | 533 | .change_b: |
514 | diamond | 534 | _setcursor 15,0 |
535 | mov si, ask_dma |
||
536 | call print |
||
537 | mov bx, '13' |
||
538 | call getkey |
||
539 | mov [preboot_dma], al |
||
540 | _setcursor 11,0 |
||
541 | jmp .d |
||
29 | halyavin | 542 | .change_c: |
514 | diamond | 543 | _setcursor 15,0 |
544 | mov si, vrrmprint |
||
545 | call print |
||
546 | mov bx, '12' |
||
547 | call getkey |
||
548 | mov [preboot_vrrm], al |
||
549 | _setcursor 12,0 |
||
550 | jmp .d |
||
40 | halyavin | 551 | .say_on_off: |
514 | diamond | 552 | pushf |
553 | call print |
||
554 | mov si, on_msg |
||
555 | popf |
||
556 | jz @f |
||
557 | mov si, off_msg |
||
558 | @@: jmp printplain |
||
40 | halyavin | 559 | ; novesa and vervesa strings are not used at the moment of executing this code |
560 | virtual at novesa |
||
29 | halyavin | 561 | .oldtimer dd ? |
562 | .starttime dd ? |
||
563 | .bSettingsChanged db ? |
||
34 | halyavin | 564 | .timer dd ? |
40 | halyavin | 565 | end virtual |
143 | diamond | 566 | .loader_block dd -1 |
29 | halyavin | 567 | .gettime: |
514 | diamond | 568 | mov ah, 0 |
569 | int 1Ah |
||
570 | xchg ax, cx |
||
571 | shl eax, 10h |
||
572 | xchg ax, dx |
||
573 | ret |
||
29 | halyavin | 574 | .newtimer: |
514 | diamond | 575 | push ds |
576 | push cs |
||
577 | pop ds |
||
578 | pushf |
||
579 | call [.oldtimer] |
||
580 | pushad |
||
581 | call .gettime |
||
582 | sub eax, [.starttime] |
||
583 | sub ax, 18*5 |
||
584 | jae .timergo |
||
585 | neg ax |
||
586 | add ax, 18-1 |
||
587 | mov bx, 18 |
||
588 | xor dx, dx |
||
589 | div bx |
||
29 | halyavin | 590 | if lang eq ru |
591 | ; ¯®¤®¦¤¨â¥ 5 ᥪã¤, 4/3/2 ᥪã¤ë, 1 ᥪã¤ã |
||
514 | diamond | 592 | cmp al, 5 |
593 | mov cl, ' ' |
||
594 | jae @f |
||
595 | cmp al, 1 |
||
596 | mov cl, 'ã' |
||
597 | jz @f |
||
598 | mov cl, 'ë' |
||
599 | @@: mov [time_str+9], cl |
||
274 | kaitz | 600 | else if lang eq et |
514 | diamond | 601 | cmp al, 1 |
602 | ja @f |
||
603 | mov [time_str+9], ' ' |
||
604 | mov [time_str+10],' ' |
||
381 | serge | 605 | @@: |
29 | halyavin | 606 | else |
607 | ; wait 5/4/3/2 seconds, 1 second |
||
514 | diamond | 608 | cmp al, 1 |
609 | mov cl, 's' |
||
610 | ja @f |
||
611 | mov cl, ' ' |
||
612 | @@: mov [time_str+9], cl |
||
29 | halyavin | 613 | end if |
514 | diamond | 614 | add al, '0' |
615 | mov [time_str+1], al |
||
616 | mov si, time_msg |
||
617 | _setcursor 7,0 |
||
618 | call print |
||
619 | _setcursor 25,0 |
||
620 | popad |
||
621 | pop ds |
||
622 | iret |
||
29 | halyavin | 623 | .timergo: |
514 | diamond | 624 | push 0 |
625 | pop es |
||
626 | mov eax, [.oldtimer] |
||
627 | mov [es:8*4], eax |
||
628 | mov sp, 0EC00h |
||
29 | halyavin | 629 | .continue: |
514 | diamond | 630 | sti |
631 | _setcursor 6,0 |
||
632 | mov si, space_msg |
||
633 | call printplain |
||
634 | call printplain |
||
635 | _setcursor 6,0 |
||
636 | mov si, loading_msg |
||
637 | call print |
||
638 | _setcursor 15,0 |
||
639 | cmp [.bSettingsChanged], 0 |
||
640 | jz .load |
||
641 | cmp [.loader_block], -1 |
||
642 | jz .load |
||
643 | les bx, [.loader_block] |
||
644 | mov eax, [es:bx+3] |
||
645 | push ds |
||
646 | pop es |
||
647 | test eax, eax |
||
648 | jz .load |
||
649 | push eax |
||
650 | mov si, save_quest |
||
651 | call print |
||
29 | halyavin | 652 | .waityn: |
514 | diamond | 653 | mov ah, 0 |
654 | int 16h |
||
655 | or al, 20h |
||
656 | cmp al, 'n' |
||
657 | jz .loadc |
||
658 | cmp al, 'y' |
||
659 | jnz .waityn |
||
660 | call putchar |
||
661 | mov byte [space_msg+80], 186 |
||
662 | pop eax |
||
663 | push cs |
||
664 | push .cont |
||
665 | push eax |
||
666 | retf |
||
29 | halyavin | 667 | .loadc: |
514 | diamond | 668 | pop eax |
29 | halyavin | 669 | .cont: |
514 | diamond | 670 | push cs |
671 | pop ds |
||
672 | mov si, space_msg |
||
673 | mov byte [si+80], 0 |
||
674 | _setcursor 15,0 |
||
675 | call printplain |
||
676 | _setcursor 15,0 |
||
29 | halyavin | 677 | .load: |
678 | ; \end{diamond}[02.12.2005] |
||
1 | ha | 679 | |
680 | ; ASK GRAPHICS MODE |
||
681 | |||
514 | diamond | 682 | movzx ax, [preboot_graph] |
683 | push 0 |
||
684 | pop es |
||
465 | serge | 685 | ; address is gr_table+6*(ax-1) |
514 | diamond | 686 | add ax, ax |
687 | lea si, [gr_table + eax + eax*2 - 6] |
||
688 | mov bx, [si+0] |
||
689 | mov cx, [si+2] |
||
690 | mov dx, [si+4] |
||
691 | cmp al, 9*2 |
||
692 | mov al, 32 ; BPP |
||
693 | jb @f |
||
694 | mov [es:0x9000], al |
||
695 | or dword [es:0x9018], 0xFFFFFFFF; 0x800000 |
||
696 | @@: |
||
697 | mov [es:0x9008], bx |
||
698 | mov [es:0x900A], cx |
||
699 | mov [es:0x900C], dx |
||
76 | mario79 | 700 | test bh, bh |
514 | diamond | 701 | jz nov |
1 | ha | 702 | |
703 | ; USE DEFAULTS OR PROBE |
||
704 | |||
705 | ; bx - mode : cx - x size : dx - y size |
||
514 | diamond | 706 | cmp [preboot_gprobe], 1 |
707 | jz noprobe |
||
1 | ha | 708 | |
514 | diamond | 709 | mov bx, 0x100 |
1 | ha | 710 | newprobe: |
711 | inc bx |
||
514 | diamond | 712 | cmp bx, 0x17f |
713 | mov si, prnotfnd |
||
714 | jz invalid_video_mode |
||
1 | ha | 715 | |
716 | probemore: |
||
514 | diamond | 717 | push cx |
718 | mov ax, 0x4f01 |
||
719 | mov cx, bx |
||
720 | mov di, 0xa000 |
||
1 | ha | 721 | int 0x10 |
514 | diamond | 722 | pop cx |
1 | ha | 723 | |
514 | diamond | 724 | test byte [es:di], 80h ; lfb? |
725 | jz newprobe |
||
726 | cmp [es:di+0x12], cx ; x size? |
||
727 | jnz newprobe |
||
728 | cmp [es:di+0x14], dx ; y size? |
||
729 | jnz newprobe |
||
730 | cmp byte [es:di+0x19], 32 ;24 |
||
731 | jb newprobe |
||
1 | ha | 732 | |
514 | diamond | 733 | ; add bx, 0100000000000000b |
734 | or bh, 40h |
||
735 | mov [es:0x9008], bx |
||
1 | ha | 736 | |
737 | noprobe: |
||
738 | |||
739 | |||
740 | ; FIND VESA 2.0 LFB & BPP |
||
741 | |||
514 | diamond | 742 | mov ax, 0x4f01 |
743 | mov cx, bx |
||
744 | and cx, 0xfff |
||
745 | mov di, 0xa000 |
||
1 | ha | 746 | int 0x10 |
747 | ; LFB |
||
514 | diamond | 748 | mov eax, [es:di+0x28] |
749 | mov [es:0x9018], eax |
||
1 | ha | 750 | ; ---- vbe voodoo |
381 | serge | 751 | BytesPerLine equ 0x10 |
514 | diamond | 752 | mov ax, [es:di+BytesPerLine] |
753 | mov [es:0x9001], ax |
||
29 | halyavin | 754 | ; BPP |
514 | diamond | 755 | mov al, byte [es:di+0x19] |
756 | mov [es:0x9000], al |
||
757 | nov: |
||
758 | cmp al, 24 |
||
759 | mov si, bt24 |
||
760 | jz bppl |
||
761 | cmp al, 32 |
||
762 | mov si, bt32 |
||
763 | jz bppl |
||
764 | mov si, btns |
||
765 | invalid_video_mode: |
||
1 | ha | 766 | call print |
514 | diamond | 767 | _setcursor (d80x25_top_num+2), 0 |
768 | mov si, start_msg |
||
769 | call print |
||
770 | jmp cfgmanager.printcfg |
||
771 | bppl: |
||
772 | call print |
||
1 | ha | 773 | |
774 | |||
775 | ; FIND VESA 1.2 PM BANK SWITCH ADDRESS |
||
776 | |||
514 | diamond | 777 | push es |
778 | mov ax, 0x4f0A |
||
779 | xor bx, bx |
||
1 | ha | 780 | int 0x10 |
514 | diamond | 781 | xor eax, eax |
782 | mov ax, es |
||
783 | shl eax, 4 |
||
784 | movzx ebx, di |
||
785 | add eax, ebx |
||
786 | mov bx, [es:di] |
||
787 | add eax, ebx |
||
1 | ha | 788 | pop es |
514 | diamond | 789 | mov [es:0x9014], eax |
1 | ha | 790 | |
791 | |||
792 | ; GRAPHICS ACCELERATION |
||
346 | diamond | 793 | ; force yes |
794 | mov [es:0x901C], byte 1 |
||
1 | ha | 795 | |
514 | diamond | 796 | ; DMA ACCESS TO HD |
1 | ha | 797 | |
514 | diamond | 798 | mov al, [preboot_dma] |
799 | mov [es:0x901F], al |
||
346 | diamond | 800 | |
1 | ha | 801 | ; VRR_M USE |
802 | |||
465 | serge | 803 | mov al,[preboot_vrrm] |
514 | diamond | 804 | mov [es:0x9030], al |
805 | mov [es:0x901E], byte 1 |
||
1 | ha | 806 | |
807 | ; BOOT DEVICE |
||
808 | |||
514 | diamond | 809 | mov al, [preboot_device] |
40 | halyavin | 810 | dec al |
514 | diamond | 811 | mov [boot_dev], al |
1 | ha | 812 | |
813 | ; READ DISKETTE TO MEMORY |
||
814 | |||
465 | serge | 815 | ; cmp [boot_dev],0 |
1 | ha | 816 | jne no_sys_on_floppy |
465 | serge | 817 | mov si,diskload |
1 | ha | 818 | call print |
514 | diamond | 819 | xor ax, ax ; reset drive |
820 | xor dx, dx |
||
1 | ha | 821 | int 0x13 |
134 | diamond | 822 | ; now load floppy image to memory |
823 | ; at first load boot sector and first FAT table |
||
824 | mov cx, 0x0001 ; startcyl,startsector |
||
825 | xor dx, dx ; starthead,drive |
||
826 | mov al, 1+9 ; no of sectors to read |
||
827 | mov bx, 0xB000 ; es:bx -> data area |
||
828 | call boot_read_floppy |
||
829 | ; and copy them to extended memory |
||
465 | serge | 830 | mov si, movedesc |
134 | diamond | 831 | mov [si+8*2+3], bh |
832 | push es |
||
833 | push ds |
||
834 | pop es |
||
835 | mov cx, 256*10 |
||
836 | mov ah, 0x87 |
||
837 | int 0x15 |
||
76 | mario79 | 838 | test ah, ah |
134 | diamond | 839 | jz @f |
840 | sayerr_floppy: |
||
841 | mov dx, 0x3f2 |
||
842 | mov al, 0 |
||
843 | out dx, al |
||
465 | serge | 844 | mov si, memmovefailed |
134 | diamond | 845 | jmp sayerr_plain |
846 | @@: |
||
847 | add dword [si+8*3+2], 512*10 |
||
848 | ; copy FAT to second copy |
||
849 | mov byte [si+8*2+3], 0xB2 |
||
850 | mov cx, 256*9 |
||
851 | mov ah, 0x87 |
||
852 | int 0x15 |
||
853 | pop es |
||
854 | test ah, ah |
||
855 | jnz sayerr_floppy |
||
856 | add dword [si+8*3+2], 512*9 |
||
857 | ; calculate total number of sectors to read |
||
858 | mov ax, 1+9+14 ; boot+FAT+root |
||
859 | mov di, 0xB203 |
||
860 | .calc_loop: |
||
861 | test word [es:di], 0xFFF |
||
862 | jz @f |
||
863 | inc ax |
||
864 | @@: |
||
865 | test word [es:di+1], 0xFFF0 |
||
866 | jz @f |
||
867 | inc ax |
||
868 | @@: |
||
869 | add di, 3 |
||
870 | cmp di, 0xB200+1440*3 |
||
871 | jb .calc_loop |
||
872 | push ax |
||
873 | mov bp, 1+9 ; already read sectors |
||
874 | ; now read rest |
||
875 | mov byte [si+8*2+3], 0xA0 |
||
876 | mov di, 2-14 ; absolute sector-31 |
||
877 | mov cx, 0x0002 ; cylinder=0, sector=2 |
||
878 | mov dx, 0x0100 ; head=1, disk=0 |
||
879 | .read_loop: |
||
880 | ; determine whether sector must be read |
||
881 | cmp di, 2 |
||
882 | jl .read |
||
883 | mov bx, di |
||
884 | shr bx, 1 |
||
885 | jnc .even |
||
886 | test word [es:bx+di+0xB200], 0xFFF0 |
||
887 | jmp @f |
||
888 | .even: |
||
889 | test word [es:bx+di+0xB200], 0xFFF |
||
890 | @@: |
||
891 | jz .skip |
||
892 | .read: |
||
893 | mov bx, 0xA000 |
||
894 | mov al, 1 ; 1 sector |
||
895 | call boot_read_floppy |
||
896 | inc bp |
||
76 | mario79 | 897 | push es |
898 | push ds |
||
1 | ha | 899 | pop es |
134 | diamond | 900 | pusha |
901 | mov cx, 256 |
||
902 | mov ah, 0x87 |
||
1 | ha | 903 | int 0x15 |
134 | diamond | 904 | test ah, ah |
1 | ha | 905 | popa |
134 | diamond | 906 | pop es |
907 | jnz sayerr_floppy |
||
908 | .skip: |
||
909 | add dword [si+8*3+2], 512 |
||
910 | inc cx |
||
911 | cmp cl, 19 |
||
912 | jnz @f |
||
913 | mov cl, 1 |
||
1 | ha | 914 | inc dh |
134 | diamond | 915 | cmp dh, 2 |
916 | jnz @f |
||
917 | mov dh, 0 |
||
1 | ha | 918 | inc ch |
29 | halyavin | 919 | @@: |
134 | diamond | 920 | pop ax |
921 | push ax |
||
922 | pusha |
||
923 | ; draw percentage |
||
924 | ; total sectors: ax |
||
925 | ; read sectors: bp |
||
926 | xchg ax, bp |
||
927 | mov cx, 100 |
||
928 | mul cx |
||
929 | div bp |
||
930 | aam |
||
931 | xchg al, ah |
||
932 | add ax, '00' |
||
465 | serge | 933 | mov si, pros |
134 | diamond | 934 | cmp [si], ax |
935 | jz @f |
||
936 | mov [si], ax |
||
1 | ha | 937 | call printplain |
134 | diamond | 938 | @@: |
1 | ha | 939 | popa |
134 | diamond | 940 | inc di |
941 | cmp di, 2880-31 |
||
942 | jnz .read_loop |
||
943 | |||
944 | ; mov cx, 0x0001 ; startcyl,startsector |
||
945 | ; xor dx, dx ; starthead,drive |
||
946 | ; push word 80*2 ; read no of sect |
||
947 | ; reads: |
||
948 | ; pusha |
||
949 | ; xor si,si |
||
950 | ; newread: |
||
951 | ; mov bx,0xa000 ; es:bx -> data area |
||
952 | ; mov ax,0x0200+18 ; read, no of sectors to read |
||
953 | ; int 0x13 |
||
954 | ; test ah, ah |
||
955 | ; jz goodread |
||
956 | ; inc si |
||
957 | ; cmp si,10 |
||
958 | ; jnz newread |
||
959 | ; mov si,badsect-0x10000 |
||
960 | ;sayerr_plain: |
||
961 | ; call printplain |
||
962 | ; jmp $ |
||
963 | ; goodread: |
||
964 | ; ; move -> 1mb |
||
965 | ; mov si,movedesc-0x10000 |
||
966 | ; push es |
||
967 | ; push ds |
||
968 | ; pop es |
||
969 | ; mov cx,256*18 |
||
970 | ; mov ah,0x87 |
||
971 | ; int 0x15 |
||
972 | ; pop es |
||
973 | ; |
||
974 | ; test ah,ah ; was the move successfull ? |
||
975 | ; je goodmove |
||
976 | ; mov dx,0x3f2 ; floppy motor off |
||
977 | ; mov al,0 |
||
978 | ; out dx,al |
||
979 | ; mov si,memmovefailed-0x10000 |
||
980 | ; jmp sayerr_plain |
||
981 | ; goodmove: |
||
982 | ; |
||
983 | ; add dword [movedesc-0x10000+0x18+2], 512*18 |
||
984 | ; popa |
||
985 | ; inc dh |
||
986 | ; cmp dh,2 |
||
987 | ; jnz bb2 |
||
988 | ; mov dh,0 |
||
989 | ; inc ch |
||
990 | ; pusha ; print prosentage |
||
991 | ; mov si,pros-0x10000 |
||
992 | ; shr ch, 2 |
||
993 | ; mov al, '5' |
||
994 | ; test ch, 1 |
||
995 | ; jnz @f |
||
996 | ; mov al, '0' |
||
997 | ;@@: |
||
998 | ; mov [si+1], al |
||
999 | ; shr ch, 1 |
||
1000 | ; add ch, '0' |
||
1001 | ; mov [si], ch |
||
1002 | ; call printplain |
||
1003 | ; popa |
||
1004 | ; bb2: |
||
1005 | ; pop ax |
||
1006 | ; dec ax |
||
1007 | ; push ax |
||
1008 | ; jnz reads |
||
1009 | ; readdone: |
||
1010 | ; pop ax |
||
465 | serge | 1011 | |
514 | diamond | 1012 | mov si, backspace2 |
1 | ha | 1013 | call printplain |
514 | diamond | 1014 | mov si, okt |
1 | ha | 1015 | call printplain |
514 | diamond | 1016 | no_sys_on_floppy: |
1017 | xor ax, ax ; reset drive |
||
1018 | xor dx, dx |
||
1 | ha | 1019 | int 0x13 |
514 | diamond | 1020 | mov dx, 0x3f2 ; floppy motor off |
1021 | mov al, 0 |
||
1022 | out dx, al |
||
1 | ha | 1023 | |
1024 | |||
1025 | ; SET GRAPHICS |
||
1026 | |||
514 | diamond | 1027 | xor ax, ax |
1028 | mov es, ax |
||
164 | serge | 1029 | |
514 | diamond | 1030 | mov ax, [es:0x9008] ; vga & 320x200 |
1031 | mov bx, ax |
||
1032 | cmp ax, 0x13 |
||
1 | ha | 1033 | je setgr |
514 | diamond | 1034 | cmp ax, 0x12 |
1 | ha | 1035 | je setgr |
514 | diamond | 1036 | mov ax, 0x4f02 ; Vesa |
412 | serge | 1037 | setgr: |
1 | ha | 1038 | int 0x10 |
514 | diamond | 1039 | test ah, ah |
1040 | mov si, fatalsel |
||
1041 | jnz sayerr |
||
1 | ha | 1042 | ; set mode 0x12 graphics registers: |
514 | diamond | 1043 | cmp bx, 0x12 |
1 | ha | 1044 | jne gmok2 |
1045 | |||
514 | diamond | 1046 | mov al, 0x05 |
1047 | mov dx, 0x03ce |
||
40 | halyavin | 1048 | push dx |
514 | diamond | 1049 | out dx, al ; select GDC mode register |
1050 | mov al, 0x02 |
||
1051 | inc dx |
||
1052 | out dx, al ; set write mode 2 |
||
1 | ha | 1053 | |
514 | diamond | 1054 | mov al, 0x02 |
1055 | mov dx, 0x03c4 |
||
1056 | out dx, al ; select VGA sequencer map mask register |
||
1057 | mov al, 0x0f |
||
1058 | inc dx |
||
1059 | out dx, al ; set mask for all planes 0-3 |
||
1 | ha | 1060 | |
514 | diamond | 1061 | mov al, 0x08 |
1062 | pop dx |
||
1063 | out dx, al ; select GDC bit mask register |
||
1 | ha | 1064 | ; for writes to 0x03cf |
412 | serge | 1065 | gmok2: |
76 | mario79 | 1066 | push ds |
514 | diamond | 1067 | pop es |