Rev 4423 | Rev 5565 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4423 | Rev 5201 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | ;; KolibriOS 16-bit loader, ;; |
9 | ;; KolibriOS 16-bit loader, ;; |
10 | ;; based on bootcode for MenuetOS ;; |
10 | ;; based on bootcode for MenuetOS ;; |
11 | ;; ;; |
11 | ;; ;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 13... | Line 13... | ||
13 | 13 | ||
Line 14... | Line 14... | ||
14 | $Revision: 4423 $ |
14 | $Revision: 5201 $ |
15 | 15 | ||
16 | 16 | ||
Line 392... | Line 392... | ||
392 | jmp $ |
392 | jmp $ |
393 | cpugood: |
393 | cpugood: |
Line 394... | Line 394... | ||
394 | 394 | ||
395 | push 0 |
395 | push 0 |
396 | popf |
- | |
Line 397... | Line 396... | ||
397 | sti |
396 | popf |
398 | 397 | ||
Line 399... | Line 398... | ||
399 | ; set up esp |
398 | ; set up esp |
400 | movzx esp, sp |
399 | movzx esp, sp |
401 | - | ||
402 | push 0 |
- | |
403 | pop es |
- | |
404 | xor ax, ax |
- | |
405 | and word [es:BOOT_IDE_BASE_ADDR], ax ;0 |
- | |
406 | and word [es:BOOT_IDE_BAR0_16], ax ;0 |
- | |
407 | and word [es:BOOT_IDE_BAR1_16], ax ;0 |
- | |
408 | and word [es:BOOT_IDE_BAR2_16], ax ;0 |
- | |
409 | and word [es:BOOT_IDE_BAR3_16], ax ;0 |
- | |
410 | ; \begin{Mario79} |
- | |
411 | ; find HDD IDE DMA PCI device |
- | |
412 | ; check for PCI BIOS |
- | |
413 | mov ax, 0xB101 |
- | |
414 | int 0x1A |
- | |
415 | jc .nopci |
- | |
416 | cmp edx, 'PCI ' |
- | |
417 | jnz .nopci |
- | |
418 | ; find PCI class code |
- | |
419 | ; class 1 = mass storage |
- | |
420 | ; subclass 1 = IDE controller |
- | |
421 | ; a) class 1, subclass 1, programming interface 0x80 |
- | |
422 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
- | |
423 | mov ax, 0xB103 |
- | |
424 | mov ecx, 1*10000h + 1*100h + 0x80 |
- | |
425 | mov [es:BOOT_IDE_PI_16], cx |
- | |
426 | xor si, si ; device index = 0 |
- | |
427 | int 0x1A |
- | |
428 | jnc .found_1 ; Parallel IDE Controller |
- | |
429 | ; b) class 1, subclass 1, programming interface 0x8f |
- | |
430 | mov ax, 0xB103 |
- | |
431 | mov ecx, 1*10000h + 1*100h + 0x8f |
- | |
432 | mov [es:BOOT_IDE_PI_16], cx |
- | |
433 | xor si, si ; device index = 0 |
- | |
434 | int 0x1A |
- | |
435 | jnc .found_1 |
- | |
436 | ; c) class 1, subclass 1, programming interface 0x85 |
- | |
437 | mov ax, 0xB103 |
- | |
438 | mov ecx, 1*10000h + 1*100h + 0x85 |
- | |
439 | mov [es:BOOT_IDE_PI_16], cx |
- | |
440 | xor si, si ; device index = 0 |
- | |
441 | int 0x1A |
- | |
442 | jnc .found_1 |
- | |
443 | ; d) class 1, subclass 1, programming interface 0x8A |
- | |
444 | ; This is a Parallel IDE Controller which uses IRQs 14 and 15. |
- | |
445 | mov ax, 0xB103 |
- | |
446 | mov ecx, 1*10000h + 1*100h + 0x8A |
- | |
447 | mov [es:BOOT_IDE_PI_16], cx |
- | |
448 | xor si, si ; device index = 0 |
- | |
449 | int 0x1A |
- | |
450 | jnc .found_1 ; Parallel IDE Controller |
- | |
451 | ; Controller not found! |
- | |
452 | xor ax, ax |
- | |
453 | mov [es:BOOT_IDE_PI_16], ax |
- | |
454 | jmp .nopci |
- | |
455 | ;-------------------------------------- |
- | |
456 | .found_1: |
- | |
457 | ; get memory base BAR4 |
- | |
458 | mov ax, 0xB10A |
- | |
459 | mov di, 0x20 ; memory base is config register at 0x20 |
- | |
460 | push cx |
- | |
461 | int 0x1A |
- | |
462 | jc .no_BAR4 ;.nopci |
- | |
463 | and cx, 0xFFFC ; clear address decode type |
- | |
464 | mov [es:BOOT_IDE_BASE_ADDR], cx |
- | |
465 | .no_BAR4: |
- | |
466 | pop cx |
- | |
467 | ;-------------------------------------- |
- | |
468 | .found: |
- | |
469 | ; get Interrupt Line |
- | |
470 | mov ax, 0xB10A |
- | |
471 | mov di, 0x3c ; memory base is config register at 0x3c |
- | |
472 | push cx |
- | |
473 | int 0x1A |
- | |
474 | jc .no_Interrupt ;.nopci |
- | |
475 | - | ||
476 | mov [es:BOOT_IDE_INTERR_16], cx |
- | |
477 | .no_Interrupt: |
- | |
478 | pop cx |
- | |
479 | ;-------------------------------------- |
- | |
480 | ; get memory base BAR0 |
- | |
481 | mov ax, 0xB10A |
- | |
482 | mov di, 0x10 ; memory base is config register at 0x10 |
- | |
483 | push cx |
400 | |
484 | int 0x1A |
- | |
485 | jc .no_BAR0 ;.nopci |
- | |
486 | 401 | push 0 |
|
487 | mov [es:BOOT_IDE_BAR0_16], cx |
- | |
488 | .no_BAR0: |
- | |
489 | pop cx |
- | |
490 | ;-------------------------------------- |
- | |
491 | ; get memory base BAR1 |
- | |
492 | mov ax, 0xB10A |
- | |
493 | mov di, 0x14 ; memory base is config register at 0x14 |
- | |
494 | push cx |
402 | pop es |
495 | int 0x1A |
- | |
496 | jc .no_BAR1 ;.nopci |
- | |
497 | - | ||
498 | mov [es:BOOT_IDE_BAR1_16], cx |
- | |
499 | .no_BAR1: |
- | |
500 | pop cx |
- | |
501 | ;-------------------------------------- |
- | |
502 | ; get memory base BAR2 |
- | |
503 | mov ax, 0xB10A |
403 | |
504 | mov di, 0x18 ; memory base is config register at 0x18 |
- | |
505 | push cx |
- | |
506 | int 0x1A |
- | |
507 | jc .no_BAR2 ;.nopci |
- | |
508 | - | ||
509 | mov [es:BOOT_IDE_BAR2_16], cx |
- | |
510 | .no_BAR2: |
- | |
511 | pop cx |
- | |
512 | ;-------------------------------------- |
- | |
513 | ; get memory base BAR3 |
- | |
514 | mov ax, 0xB10A |
404 | xor cx, cx |
515 | mov di, 0x1C ; memory base is config register at 0x1c |
- | |
516 | push cx |
- | |
517 | int 0x1A |
- | |
518 | jc .no_BAR3 ;.nopci |
- | |
519 | 405 | @@: |
|
520 | mov [es:BOOT_IDE_BAR3_16], cx |
- | |
521 | .no_BAR3: |
- | |
522 | pop cx |
- | |
Line 523... | Line 406... | ||
523 | ;-------------------------------------- |
406 | in al, 64h |
524 | .nopci: |
407 | test al, 2 |
525 | ; \end{Mario79} |
408 | loopnz @b |
526 | 409 | ||
527 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
- | |
528 | out 0x60, al |
410 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
529 | xor cx, cx |
411 | out 0x60, al |
530 | wait_loop: ; variant 2 |
412 | xor cx, cx |
531 | ; reading state of port of 8042 controller |
413 | @@: |
Line 532... | Line 414... | ||
532 | in al, 64h |
414 | in al, 64h |
533 | and al, 00000010b ; ready flag |
415 | test al, 1 |
534 | ; wait until 8042 controller is ready |
416 | loopz @b |
535 | loopnz wait_loop |
417 | in al, 0x60 |
536 | 418 | ||
537 | ;;;/diamond today 5.02.2008 |
419 | ;;;/diamond today 5.02.2008 |
538 | ; set keyboard typematic rate & delay |
420 | ; set keyboard typematic rate & delay |
539 | mov al, 0xf3 |
421 | mov al, 0xf3 |
540 | out 0x60, al |
422 | out 0x60, al |
- | 423 | xor cx, cx |
|
541 | xor cx, cx |
424 | @@: |
542 | @@: |
425 | in al, 64h |
543 | in al, 64h |
426 | test al, 1 |
544 | test al, 2 |
427 | loopz @b |
545 | loopnz @b |
428 | in al, 0x60 |
546 | mov al, 0 |
429 | mov al, 0 |
547 | out 0x60, al |
430 | out 0x60, al |
- | 431 | xor cx, cx |
|
548 | xor cx, cx |
432 | @@: |
- | 433 | in al, 64h |
|
549 | @@: |
434 | test al, 1 |
550 | in al, 64h |
435 | loopz @b |
551 | test al, 2 |
436 | in al, 0x60 |
552 | loopnz @b |
437 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
553 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
438 | sti |