Rev 3725 | Rev 4265 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3725 | Rev 3908 | ||
---|---|---|---|
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: 3725 $ |
14 | $Revision: 3908 $ |
15 | 15 | ||
16 | 16 | ||
Line 45... | Line 45... | ||
45 | test al, al |
45 | test al, al |
46 | jnz @b |
46 | jnz @b |
47 | popa |
47 | popa |
48 | ret |
48 | ret |
Line 49... | Line -... | ||
49 | - | ||
- | 49 | ||
50 | getkey: |
50 | getkey: ; Use BIOS INT 16h to read a key from the keyboard |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
51 | ; get number in range [bl,bh] (bl,bh in ['0'..'9']) |
52 | ; in: bx=range |
52 | ; in: bx=range |
53 | ; out: ax=digit (1..9, 10 for 0) |
53 | ; out: ax=digit (1..9, 10 for 0) |
54 | mov ah, 0 |
54 | mov ah, 0 ; If 'int 16h' is called with 'ah' equal to zero, the BIOS will not return control |
55 | int 16h |
55 | int 16h ; to the caller until a key is available in the system type ahead buffer. On return, |
56 | cmp al, bl |
56 | cmp al, bl ; 'al' contains the ASCII code for the key read from the buffer and 'ah' contains |
57 | jb getkey |
57 | jb getkey ; the keyboard scan code. Here we compare 'al' with the range of accepted characters. |
58 | cmp al, bh |
58 | cmp al, bh ; If the key pressed is not in the range, continue waiting for another key. |
59 | ja getkey |
59 | ja getkey |
60 | push ax |
60 | push ax ; If the pressed key is in the accepted range, save it on the stack and echo to screen. |
61 | call putchar |
61 | call putchar |
62 | pop ax |
62 | pop ax |
63 | and ax, 0Fh |
63 | and ax, 0Fh ; ASCII code for '0' is 48 (110000b). 0F4=1111b. (110000b AND 1111b) = 0 |
64 | jnz @f |
64 | jnz @f ; So if key '0' was entered, return 10 in 'ax' |
65 | mov al, 10 |
65 | mov al, 10 |
66 | @@: |
66 | @@: |
Line 67... | Line 67... | ||
67 | ret |
67 | ret |
Line 432... | Line 432... | ||
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
432 | mov ecx, 1*10000h + 1*100h + 0x8A |
433 | mov [es:BOOT_IDE_PI_16], cx |
433 | mov [es:BOOT_IDE_PI_16], cx |
434 | xor si, si ; device index = 0 |
434 | xor si, si ; device index = 0 |
435 | int 0x1A |
435 | int 0x1A |
436 | jnc .found_1 ; Parallel IDE Controller |
436 | jnc .found_1 ; Parallel IDE Controller |
437 | - | ||
- | 437 | ; Controller not found! |
|
- | 438 | xor ax, ax |
|
- | 439 | mov [es:BOOT_IDE_PI_16], ax |
|
438 | jmp .nopci |
440 | jmp .nopci |
- | 441 | ;-------------------------------------- |
|
439 | .found_1: |
442 | .found_1: |
440 | ; get memory base BAR4 |
443 | ; get memory base BAR4 |
441 | mov ax, 0xB10A |
444 | mov ax, 0xB10A |
442 | mov di, 0x20 ; memory base is config register at 0x20 |
445 | mov di, 0x20 ; memory base is config register at 0x20 |
443 | push cx |
446 | push cx |
444 | int 0x1A |
447 | int 0x1A |
445 | jc .no_BAR4 ;.nopci |
448 | jc .no_BAR4 ;.nopci |
446 | and cx, 0xFFF0 ; clear address decode type |
449 | and cx, 0xFFFC ; clear address decode type |
447 | mov [es:BOOT_IDE_BASE_ADDR], cx |
450 | mov [es:BOOT_IDE_BASE_ADDR], cx |
448 | .no_BAR4: |
451 | .no_BAR4: |
449 | pop cx |
452 | pop cx |
- | 453 | ;-------------------------------------- |
|
450 | .found: |
454 | .found: |
- | 455 | ; get Interrupt Line |
|
- | 456 | mov ax, 0xB10A |
|
- | 457 | mov di, 0x3c ; memory base is config register at 0x3c |
|
- | 458 | push cx |
|
- | 459 | int 0x1A |
|
- | 460 | jc .no_Interrupt ;.nopci |
|
- | 461 | ||
- | 462 | mov [es:BOOT_IDE_INTERR_16], cx |
|
- | 463 | .no_Interrupt: |
|
- | 464 | pop cx |
|
- | 465 | ;-------------------------------------- |
|
451 | ; get memory base BAR0 |
466 | ; get memory base BAR0 |
452 | mov ax, 0xB10A |
467 | mov ax, 0xB10A |
453 | mov di, 0x10 ; memory base is config register at 0x10 |
468 | mov di, 0x10 ; memory base is config register at 0x10 |
454 | push cx |
469 | push cx |
455 | int 0x1A |
470 | int 0x1A |
456 | jc .no_BAR0 ;.nopci |
471 | jc .no_BAR0 ;.nopci |
- | 472 | ||
457 | mov [es:BOOT_IDE_BAR0_16], cx |
473 | mov [es:BOOT_IDE_BAR0_16], cx |
458 | .no_BAR0: |
474 | .no_BAR0: |
459 | pop cx |
475 | pop cx |
- | 476 | ;-------------------------------------- |
|
460 | ; get memory base BAR1 |
477 | ; get memory base BAR1 |
461 | mov ax, 0xB10A |
478 | mov ax, 0xB10A |
462 | mov di, 0x14 ; memory base is config register at 0x14 |
479 | mov di, 0x14 ; memory base is config register at 0x14 |
463 | push cx |
480 | push cx |
464 | int 0x1A |
481 | int 0x1A |
465 | jc .no_BAR1 ;.nopci |
482 | jc .no_BAR1 ;.nopci |
- | 483 | ||
466 | mov [es:BOOT_IDE_BAR1_16], cx |
484 | mov [es:BOOT_IDE_BAR1_16], cx |
467 | .no_BAR1: |
485 | .no_BAR1: |
468 | pop cx |
486 | pop cx |
- | 487 | ;-------------------------------------- |
|
469 | ; get memory base BAR2 |
488 | ; get memory base BAR2 |
470 | mov ax, 0xB10A |
489 | mov ax, 0xB10A |
471 | mov di, 0x18 ; memory base is config register at 0x18 |
490 | mov di, 0x18 ; memory base is config register at 0x18 |
472 | push cx |
491 | push cx |
473 | int 0x1A |
492 | int 0x1A |
474 | jc .no_BAR2 ;.nopci |
493 | jc .no_BAR2 ;.nopci |
- | 494 | ||
475 | mov [es:BOOT_IDE_BAR2_16], cx |
495 | mov [es:BOOT_IDE_BAR2_16], cx |
476 | .no_BAR2: |
496 | .no_BAR2: |
477 | pop cx |
497 | pop cx |
- | 498 | ;-------------------------------------- |
|
478 | ; get memory base BAR3 |
499 | ; get memory base BAR3 |
479 | mov ax, 0xB10A |
500 | mov ax, 0xB10A |
480 | mov di, 0x1C ; memory base is config register at 0x1c |
501 | mov di, 0x1C ; memory base is config register at 0x1c |
481 | push cx |
502 | push cx |
482 | int 0x1A |
503 | int 0x1A |
483 | jc .no_BAR3 ;.nopci |
504 | jc .no_BAR3 ;.nopci |
- | 505 | ||
484 | mov [es:BOOT_IDE_BAR3_16], cx |
506 | mov [es:BOOT_IDE_BAR3_16], cx |
485 | .no_BAR3: |
507 | .no_BAR3: |
486 | pop cx |
508 | pop cx |
- | 509 | ;-------------------------------------- |
|
487 | .nopci: |
510 | .nopci: |
488 | ; \end{Mario79} |
511 | ; \end{Mario79} |
Line 489... | Line 512... | ||
489 | 512 | ||
490 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
513 | mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
Line 571... | Line 594... | ||
571 | ; \begin{diamond}[30.11.2005] |
594 | ; \begin{diamond}[30.11.2005] |
572 | cfgmanager: |
595 | cfgmanager: |
573 | ; settings: |
596 | ; settings: |
574 | ; a) preboot_graph = graphical mode |
597 | ; a) preboot_graph = graphical mode |
575 | ; preboot_gprobe = probe this mode? |
598 | ; preboot_gprobe = probe this mode? |
576 | ; b) preboot_dma = use DMA access? |
599 | ; b) preboot_biosdisk = use BIOS disks through V86 emulation? // (earlier was: preboot_dma = use DMA access?) |
577 | ; c) preboot_vrrm = use VRR? |
600 | ; c) preboot_debug = duplicates kernel debug output to the screen // (earlier was: preboot_vrrm = use VRR?) |
- | 601 | ; // VRR is an obsolete functionality, used only with CRT monitors: increase display frequency by reducing screen resolution |
|
- | 602 | ; d) preboot_launcher = start the first app (right now it's LAUNCHER) after kernel is loaded? |
|
578 | ; d) preboot_device = from what boot? |
603 | ; e) preboot_device = from where to boot? |
Line 579... | Line 604... | ||
579 | 604 | ||
580 | ; determine default settings |
605 | ; determine default settings |
581 | if ~ defined extended_primary_loader |
606 | if ~ defined extended_primary_loader |
582 | mov [.bSettingsChanged], 0 |
607 | mov [.bSettingsChanged], 0 |
Line 607... | Line 632... | ||
607 | end if |
632 | end if |
608 | .preboot_device_inited: |
633 | .preboot_device_inited: |
609 | ; following 4 lines set variables to 1 if its current value is 0 |
634 | ; following 4 lines set variables to 1 if its current value is 0 |
610 | cmp byte [di+preboot_dma-preboot_device], 1 |
635 | cmp byte [di+preboot_dma-preboot_device], 1 |
611 | adc byte [di+preboot_dma-preboot_device], 0 |
636 | adc byte [di+preboot_dma-preboot_device], 0 |
- | 637 | cmp byte [di+preboot_launcher-preboot_device], 1 ; Start LAUNCHER by default |
|
- | 638 | adc byte [di+preboot_launcher-preboot_device], 0 |
|
612 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
639 | ; cmp byte [di+preboot_biosdisk-preboot_device], 1 |
613 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
640 | ; adc byte [di+preboot_biosdisk-preboot_device], 0 |
614 | ;; default value for VRR is OFF |
641 | ;; default value for VRR is OFF |
615 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
642 | ; cmp byte [di+preboot_vrrm-preboot_device], 0 |
616 | ; jnz @f |
643 | ; jnz @f |
Line 644... | Line 671... | ||
644 | cmp [preboot_biosdisk], 1 |
671 | cmp [preboot_biosdisk], 1 |
645 | call .say_on_off |
672 | call .say_on_off |
646 | ; mov si, vrrm_msg |
673 | ; mov si, vrrm_msg |
647 | ; cmp [preboot_vrrm], 1 |
674 | ; cmp [preboot_vrrm], 1 |
648 | ; call .say_on_off |
675 | ; call .say_on_off |
- | 676 | mov si, debug_mode_msg |
|
- | 677 | cmp [preboot_debug], 1 |
|
- | 678 | call .say_on_off |
|
- | 679 | mov si, launcher_msg |
|
- | 680 | cmp [preboot_launcher], 1 |
|
- | 681 | call .say_on_off |
|
649 | mov si, preboot_device_msg |
682 | mov si, preboot_device_msg |
650 | call print |
683 | call print |
651 | mov al, [preboot_device] |
684 | mov al, [preboot_device] |
652 | if defined extended_primary_loader |
685 | if defined extended_primary_loader |
653 | and eax, 3 |
686 | and eax, 3 |
Line 727... | Line 760... | ||
727 | pop ax |
760 | pop ax |
728 | ; switch on key |
761 | ; switch on key |
729 | cmp al, 13 |
762 | cmp al, 13 |
730 | jz .continue |
763 | jz .continue |
731 | or al, 20h |
764 | or al, 20h |
732 | cmp al, 'a' |
765 | cmp al, 'a' ; select graphical mode |
733 | jz .change_a |
766 | jz .change_a |
- | 767 | cmp al, 'q' ; Trick to make 'A' key on azerty keyboard work |
|
734 | cmp al, 'b' |
768 | je .change_a |
- | 769 | cmp al, 'b' ; use BIOS disks? // (selecting YES will make BIOS disks visible as /bd) |
|
735 | jz .change_b |
770 | jz .change_b |
- | 771 | cmp al, 'c' ; load kernel in debug mode? // (earlier was: use VRR?) |
|
736 | ; cmp al, 'c' |
772 | jz .change_c |
- | 773 | cmp al, 'd' ; start launcher after kernel is loaded? |
|
737 | ; jz .change_c |
774 | jz .change_d |
738 | cmp al, 'c' ; 'd' |
775 | cmp al, 'e' ; select boot origin |
739 | jnz .show_remarks |
776 | jnz .show_remarks |
- | 777 | ; e) preboot_device = from where to boot? |
|
740 | _setcursor 15,0 |
778 | _setcursor 16,0 |
741 | mov si, bdev |
779 | mov si, bdev |
742 | call print |
780 | call print |
743 | if defined extended_primary_loader |
781 | if defined extended_primary_loader |
744 | mov bx, '12' |
782 | mov bx, '12' ; range accepted for answer: 1-2 |
745 | else |
783 | else |
746 | mov bx, '14' |
784 | mov bx, '14' ; range accepted for answer: 1-4 |
747 | end if |
785 | end if |
748 | call getkey |
786 | call getkey |
749 | mov [preboot_device], al |
787 | mov [preboot_device], al |
750 | _setcursor 13,0 |
788 | _setcursor 14,0 |
751 | .d: |
789 | .d: |
752 | if ~ defined extended_primary_loader |
790 | if ~ defined extended_primary_loader |
753 | mov [.bSettingsChanged], 1 |
791 | mov [.bSettingsChanged], 1 |
754 | end if |
792 | end if |
755 | call clear_vmodes_table ;clear vmodes_table |
793 | call clear_vmodes_table ;clear vmodes_table |
756 | jmp .printcfg |
794 | jmp .printcfg |
757 | .change_a: |
795 | .change_a: |
- | 796 | call clear_vmodes_table ;clear vmodes_table |
|
758 | .loops: |
797 | .loops: |
759 | call draw_vmodes_table |
798 | call draw_vmodes_table |
760 | _setcursor 25,0 ; out of screen |
799 | _setcursor 25,0 ; out of screen |
761 | xor ax, ax |
800 | xor ax, ax |
762 | int 0x16 |
801 | int 0x16 |
Line 831... | Line 870... | ||
831 | pop word [number_vm] |
870 | pop word [number_vm] |
832 | mov word [preboot_graph], bp ;save choose |
871 | mov word [preboot_graph], bp ;save choose |
Line 833... | Line 872... | ||
833 | 872 | ||
Line 834... | Line 873... | ||
834 | jmp .d |
873 | jmp .d |
835 | 874 | ||
836 | .change_b: |
875 | .change_b: ; b) preboot_biosdisk = use BIOS disks through V86 emulation? |
837 | _setcursor 15,0 |
876 | _setcursor 16,0 |
838 | ; mov si, ask_dma |
877 | ; mov si, ask_dma // (earlier was: preboot_dma = use DMA access?) |
839 | ; call print |
878 | ; call print |
840 | ; mov bx, '13' |
879 | ; mov bx, '13' ; range accepted for answer: 1-3 |
841 | ; call getkey |
880 | ; call getkey |
842 | ; mov [preboot_dma], al |
881 | ; mov [preboot_dma], al |
843 | mov si, ask_bd |
882 | mov si, ask_bd |
844 | call print |
883 | call print |
845 | mov bx, '12' |
884 | mov bx, '12' ; range accepted for answer: 1-2 |
846 | call getkey |
885 | call getkey |
847 | mov [preboot_biosdisk], al |
886 | mov [preboot_biosdisk], al |
848 | _setcursor 11,0 |
887 | _setcursor 11,0 |
849 | jmp .d |
888 | jmp .d |
850 | ;.change_c: |
889 | ;.change_c: ; // VRR is an obsolete functionality, used only with CRT monitors |
851 | ; _setcursor 15,0 |
890 | ; _setcursor 16,0 |
852 | ; mov si, vrrmprint |
891 | ; mov si, vrrmprint |
853 | ; call print |
892 | ; call print |
854 | ; mov bx, '12' |
893 | ; mov bx, '12' ; range accepted for answer: 1-2 |
855 | ; call getkey |
894 | ; call getkey |
856 | ; mov [preboot_vrrm], al |
895 | ; mov [preboot_vrrm], al |
- | 896 | ; _setcursor 12,0 |
|
- | 897 | ; jmp .d |
|
- | 898 | .change_c: ; c) preboot_debug = duplicates kernel debug output to the screen |
|
- | 899 | _setcursor 16,0 |
|
- | 900 | mov si, ask_debug |
|
- | 901 | call print |
|
- | 902 | mov bx, '12' ; range accepted for answer: 1-2 |
|
- | 903 | call getkey |
|
- | 904 | mov [preboot_debug], al |
|
- | 905 | _setcursor 12,0 |
|
- | 906 | jmp .d |
|
- | 907 | .change_d: ; d) preboot_launcher = start the first app (right now it's LAUNCHER) after kernel is loaded? |
|
- | 908 | _setcursor 16,0 |
|
- | 909 | mov si, ask_launcher |
|
- | 910 | call print |
|
- | 911 | mov bx, '12' ; range accepted for answer: 1-2 |
|
- | 912 | call getkey |
|
- | 913 | mov [preboot_launcher], al |
|
857 | ; _setcursor 12,0 |
914 | _setcursor 13,0 |
858 | ; jmp .d |
915 | jmp .d |
859 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
916 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
860 | .say_on_off: |
917 | .say_on_off: |
861 | pushf |
918 | pushf |
Line 961... | Line 1018... | ||
961 | call printplain |
1018 | call printplain |
962 | call printplain |
1019 | call printplain |
963 | _setcursor 6,0 |
1020 | _setcursor 6,0 |
964 | mov si, loading_msg |
1021 | mov si, loading_msg |
965 | call print |
1022 | call print |
966 | _setcursor 15,0 |
1023 | _setcursor 16,0 |
967 | if ~ defined extended_primary_loader |
1024 | if ~ defined extended_primary_loader |
968 | cmp [.bSettingsChanged], 0 |
1025 | cmp [.bSettingsChanged], 0 |
969 | jz .load |
1026 | jz .load |
970 | cmp [.loader_block], -1 |
1027 | cmp [.loader_block], -1 |
971 | jz .load |
1028 | jz .load |
Line 1003... | Line 1060... | ||
1003 | .cont: |
1060 | .cont: |
1004 | push cs |
1061 | push cs |
1005 | pop ds |
1062 | pop ds |
1006 | mov si, space_msg |
1063 | mov si, space_msg |
1007 | mov byte [si+80], 0 |
1064 | mov byte [si+80], 0 |
1008 | _setcursor 15,0 |
1065 | _setcursor 16,0 |
1009 | call printplain |
1066 | call printplain |
1010 | _setcursor 15,0 |
1067 | _setcursor 16,0 |
1011 | .load: |
1068 | .load: |
1012 | end if |
1069 | end if |
1013 | ; \end{diamond}[02.12.2005] |
1070 | ; \end{diamond}[02.12.2005] |
Line 1014... | Line 1071... | ||
1014 | 1071 | ||
Line 1026... | Line 1083... | ||
1026 | mov [es:BOOT_DMA], al |
1083 | mov [es:BOOT_DMA], al |
Line 1027... | Line 1084... | ||
1027 | 1084 | ||
1028 | ;; VRR_M USE |
1085 | ;; VRR_M USE |
1029 | ; |
1086 | ; |
- | 1087 | ; mov al,[preboot_vrrm] |
|
- | 1088 | ; mov [es:BOOT_VRR], al ;// 0x9030 |
|
- | 1089 | ||
1030 | ; mov al,[preboot_vrrm] |
1090 | ; Set kernel DEBUG mode - if nonzero, duplicates debug output to the screen. |
- | 1091 | mov al, [preboot_debug] |
|
- | 1092 | mov [es:BOOT_DEBUG_PRINT], al ;// 0x901E |
|
- | 1093 | ||
- | 1094 | ; Start the first app (right now it's LAUNCHER) after kernel is loaded? |
|
- | 1095 | mov al, [preboot_launcher] |
|
Line 1031... | Line 1096... | ||
1031 | ; mov [es:0x9030], al |
1096 | mov [es:BOOT_LAUNCHER_START], al ;// 0x901D |
Line 1032... | Line 1097... | ||
1032 | 1097 | ||
1033 | ; BOOT DEVICE |
1098 | ; BOOT DEVICE |