Rev 1635 | Rev 2010 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1635 | Rev 1638 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | ;; |
55 | ;; |
56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
56 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 57... | Line 57... | ||
57 | 57 | ||
Line 58... | Line 58... | ||
58 | include 'macros.inc' |
58 | include 'macros.inc' |
Line 59... | Line 59... | ||
59 | 59 | ||
Line 60... | Line 60... | ||
60 | $Revision: 1591 $ |
60 | $Revision: 1638 $ |
Line 589... | Line 589... | ||
589 | mov ecx, 0x10000/32 |
589 | mov ecx, 0x10000/32 |
590 | rep stosd |
590 | rep stosd |
Line 591... | Line 591... | ||
591 | 591 | ||
Line 592... | Line 592... | ||
592 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
592 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
Line 593... | Line 593... | ||
593 | 593 | ||
594 | call rerouteirqs |
594 | call PIC_init |
Line 595... | Line 595... | ||
595 | 595 | ||
- | 596 | ; Initialize system V86 machine |
|
Line 596... | Line -... | ||
596 | ; Initialize system V86 machine |
- | |
597 | call init_sys_v86 |
- | |
598 | - | ||
599 | ; TIMER SET TO 1/100 S |
597 | call init_sys_v86 |
600 | - | ||
601 | mov al,0x34 ; set to 100Hz |
598 | |
Line 602... | Line 599... | ||
602 | out 0x43,al |
599 | ; Initialize system timer (IRQ0) |
603 | mov al,0x9b ; lsb 1193180 / 1193 |
600 | call PIT_init |
604 | out 0x40,al |
- | |
605 | mov al,0x2e ; msb |
- | |
606 | out 0x40,al |
- | |
607 | 601 | ||
608 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
602 | ; Try to Initialize APIC |
609 | ; they are used: when partitions are scanned, hd_read relies on timer |
603 | call APIC_init |
Line 610... | Line 604... | ||
610 | ; Also enable IRQ2, because in some configurations |
604 | |
611 | ; IRQs from slave controller are not delivered until IRQ2 on master is enabled |
605 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
612 | mov al, 0xFA |
606 | ; they are used: when partitions are scanned, hd_read relies on timer |
613 | out 0x21, al |
607 | call unmask_timer |
Line 660... | Line 654... | ||
660 | stdcall read_file, char2, FONT_II, 0, 2560 |
654 | stdcall read_file, char2, FONT_II, 0, 2560 |
Line 661... | Line 655... | ||
661 | 655 | ||
662 | mov esi,boot_fonts |
656 | mov esi,boot_fonts |
Line -... | Line 657... | ||
- | 657 | call boot_log |
|
- | 658 | ||
- | 659 | ; Display APIC status |
|
- | 660 | mov esi, boot_APIC_found |
|
- | 661 | test dword[APIC], 0xffffffff |
|
- | 662 | jnz @f |
|
- | 663 | mov esi, boot_APIC_nfound |
|
663 | call boot_log |
664 | @@: call boot_log |
664 | 665 | ||
665 | ; PRINT AMOUNT OF MEMORY |
666 | ; PRINT AMOUNT OF MEMORY |
Line 666... | Line 667... | ||
666 | mov esi, boot_memdetect |
667 | mov esi, boot_memdetect |
Line 777... | Line 778... | ||
777 | sub eax,ecx |
778 | sub eax,ecx |
778 | shl eax,2 |
779 | shl eax,2 |
779 | mov [CPU_FREQ],eax ; save tsc / sec |
780 | mov [CPU_FREQ],eax ; save tsc / sec |
780 | ; mov ebx, 1000000 |
781 | ; mov ebx, 1000000 |
781 | ; div ebx |
782 | ; div ebx |
782 | ; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì®áâì ¢ ¤ ®¬ ª®ªà¥â®¬ ¬¥á⥠|
- | |
783 | ; ᮢ¥à襮 ¥ªà¨â¨ç , ® çâ®¡ë § âªãâì «î¡¨â¥«¥© |
- | |
784 | ; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ ... |
- | |
785 | mov edx, 2251799814 |
783 | mov edx, 2251799814 |
786 | mul edx |
784 | mul edx |
787 | shr edx, 19 |
785 | shr edx, 19 |
788 | mov [stall_mcs], edx |
786 | mov [stall_mcs], edx |
789 | ; PRINT CPU FREQUENCY |
787 | ; PRINT CPU FREQUENCY |
Line 803... | Line 801... | ||
803 | 801 | ||
Line 804... | Line 802... | ||
804 | call set_variables |
802 | call set_variables |
Line 805... | Line -... | ||
805 | - | ||
806 | ; SET MOUSE |
803 | |
807 | 804 | ; SET MOUSE |
|
Line 808... | Line 805... | ||
808 | ;call detect_devices |
805 | |
809 | stdcall load_driver, szPS2MDriver |
806 | stdcall load_driver, szPS2MDriver |
Line 902... | Line 899... | ||
902 | @@: |
899 | @@: |
903 | in al,64h |
900 | in al,64h |
904 | and al,00000010b |
901 | and al,00000010b |
905 | loopnz @b |
902 | loopnz @b |
Line 906... | Line 903... | ||
906 | 903 | ||
907 | ; mov al, 0xED ; svetodiody - only for testing! |
904 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
908 | ; call kb_write |
905 | ; call kb_write |
909 | ; call kb_read |
906 | ; call kb_read |
910 | ; mov al, 111b |
907 | ; mov al, 111b |
911 | ; call kb_write |
908 | ; call kb_write |
Line 961... | Line 958... | ||
961 | out dx, al |
958 | out dx, al |
Line 962... | Line 959... | ||
962 | 959 | ||
Line 963... | Line 960... | ||
963 | 960 | ||
Line -... | Line 961... | ||
- | 961 | end if |
|
964 | end if |
962 | |
965 | 963 | ;-=-=-=-=-=-=- START MULTITASKING -=-=-=-=-=-=-=-=- |
|
966 | ; START MULTITASKING |
964 | |
967 | 965 | ; A 'All set - press ESC to start' messages if need |
|
968 | if preboot_blogesc |
966 | if preboot_blogesc |
969 | mov esi, boot_tasking |
967 | mov esi, boot_tasking |
970 | call boot_log |
968 | call boot_log |
Line 971... | Line -... | ||
971 | .bll1: in al, 0x60 ; wait for ESC key press |
- | |
Line 972... | Line 969... | ||
972 | cmp al, 129 |
969 | .bll1: in al, 0x60 ; wait for ESC key press |
Line 973... | Line 970... | ||
973 | jne .bll1 |
970 | cmp al, 129 |
974 | end if |
971 | jne .bll1 |
Line 992... | Line 989... | ||
992 | ; mov al,0x20 ; ready for irqs |
989 | ; mov al,0x20 ; ready for irqs |
993 | ; out 0x20,al |
990 | ; out 0x20,al |
994 | ; out 0xa0,al |
991 | ; out 0xa0,al |
995 | ; |
992 | ; |
996 | ; loop ready_for_irqs ; flush the queue |
993 | ; loop ready_for_irqs ; flush the queue |
- | 994 | cli ;guarantee forbidance of interrupts. |
|
- | 995 | stdcall enable_irq, 2 ; @#$%! PIC |
|
- | 996 | stdcall enable_irq, 6 ; FDD |
|
- | 997 | stdcall enable_irq, 13 ; co-processor |
|
Line 997... | Line 998... | ||
997 | 998 | ||
Line 998... | Line 999... | ||
998 | stdcall attach_int_handler, 1, irq1, 0 |
999 | stdcall attach_int_handler, dword 1, irq1, dword 0 ; keyboard |
999 | 1000 | ||
1000 | ; mov [dma_hdd],1 |
1001 | ; mov [dma_hdd],1 |
1001 | cmp [IDEContrRegsBaseAddr], 0 |
1002 | cmp [IDEContrRegsBaseAddr], 0 |
Line 1005... | Line 1006... | ||
1005 | sti |
1006 | sti |
1006 | call change_task |
1007 | call change_task |
Line 1007... | Line 1008... | ||
1007 | 1008 | ||
Line 1008... | Line -... | ||
1008 | jmp osloop |
- | |
Line 1009... | Line 1009... | ||
1009 | 1009 | jmp osloop |
|
Line 1010... | Line 1010... | ||
1010 | ; jmp $ ; wait here for timer to take control |
1010 | |
1011 | 1011 | ||
Line 1148... | Line 1148... | ||
1148 | 1148 | ||
Line 1149... | Line 1149... | ||
1149 | ret |
1149 | ret |
Line 1150... | Line 1150... | ||
1150 | 1150 | ||
1151 | setirqreadports: |
1151 | setirqreadports: |
1152 | 1152 | ||
1153 | mov [irq12read+0],dword 0x60 + 0x01000000 ; read port 0x60 , byte |
1153 | mov [irq00read+12*4*16],dword 0x60 + 0x01000000 ; read port 0x60 , byte |
1154 | and dword [irq12read+4],0 ; end of port list |
1154 | and dword [irq00read+12*4*16],0 ; end of port list |
1155 | ; mov [irq12read+4],dword 0 ; end of port list |
1155 | ; mov [irq12read+4],dword 0 ; end of port list |
1156 | ;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
1156 | ;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
Line 3742... | Line 3742... | ||
3742 | cmp ecx, 16 |
3742 | cmp ecx, 16 |
3743 | jae ril1 |
3743 | jae ril1 |
Line 3744... | Line 3744... | ||
3744 | 3744 | ||
3745 | push ecx |
3745 | push ecx |
3746 | lea ecx, [irq_owner + 4 * ecx] |
3746 | lea ecx, [irq_owner + 4 * ecx] |
3747 | mov edx, [ecx] |
3747 | mov edx, [ecx] ; IRQ owner PID |
3748 | mov eax, [TASK_BASE] |
3748 | mov eax, [TASK_BASE] |
3749 | mov edi, [eax + TASKDATA.pid] |
3749 | mov edi, [eax + TASKDATA.pid] ; current task PID |
3750 | pop eax |
3750 | pop eax |
3751 | dec ebx |
3751 | dec ebx |
3752 | jnz reserve_irq |
3752 | jnz reserve_irq |
3753 | 3753 | ; free irq |
|
3754 | cmp edx, edi |
3754 | cmp edx, edi ; check owner |
3755 | jne ril1 |
3755 | jne ril1 |
3756 | dec esi |
3756 | dec esi |
Line 3757... | Line 3757... | ||
3757 | mov [ecx], esi |
3757 | mov [ecx], esi ; esi = 0 |
Line 3758... | Line 3758... | ||
3758 | 3758 | ||
Line 3759... | Line 3759... | ||
3759 | jmp ril1 |
3759 | jmp ril1 ; return successful |
3760 | 3760 | ||
Line 3791... | Line 3791... | ||
3791 | dd 0x0 |
3791 | dd 0x0 |
3792 | dd 0x0 |
3792 | dd 0x0 |
3793 | dd p_irq14 |
3793 | dd p_irq14 |
3794 | dd p_irq15 |
3794 | dd p_irq15 |
Line -... | Line 3795... | ||
- | 3795 | ||
- | 3796 | ; I don`t known how to use IRQ_RESERVE |
|
- | 3797 | if IRQ_RESERVE > 16 |
|
- | 3798 | dd p_irq16 |
|
- | 3799 | dd p_irq17 |
|
- | 3800 | dd p_irq18 |
|
- | 3801 | dd p_irq19 |
|
- | 3802 | dd p_irq20 |
|
- | 3803 | dd p_irq21 |
|
- | 3804 | dd p_irq22 |
|
- | 3805 | dd p_irq23 |
|
- | 3806 | end if |
|
3795 | 3807 | ||
Line 3796... | Line 3808... | ||
3796 | endg |
3808 | endg |
3797 | 3809 | ||
3798 | drawbackground: |
3810 | drawbackground: |
Line 4284... | Line 4296... | ||
4284 | mov edx,0xffffffff |
4296 | mov edx,0xffffffff |
4285 | mov eax,0xffffffff |
4297 | mov eax,0xffffffff |
4286 | ret |
4298 | ret |
4287 | end if |
4299 | end if |
Line 4288... | Line -... | ||
4288 | - | ||
4289 | rerouteirqs: |
- | |
4290 | - | ||
4291 | cli |
- | |
4292 | - | ||
4293 | mov al,0x11 ; icw4, edge triggered |
- | |
4294 | out 0x20,al |
- | |
4295 | call pic_delay |
- | |
4296 | out 0xA0,al |
- | |
4297 | call pic_delay |
- | |
4298 | - | ||
4299 | mov al,0x20 ; generate 0x20 + |
- | |
4300 | out 0x21,al |
- | |
4301 | call pic_delay |
- | |
4302 | mov al,0x28 ; generate 0x28 + |
- | |
4303 | out 0xA1,al |
- | |
4304 | call pic_delay |
- | |
4305 | - | ||
4306 | mov al,0x04 ; slave at irq2 |
- | |
4307 | out 0x21,al |
- | |
4308 | call pic_delay |
- | |
4309 | mov al,0x02 ; at irq9 |
- | |
4310 | out 0xA1,al |
- | |
4311 | call pic_delay |
- | |
4312 | - | ||
4313 | mov al,0x01 ; 8086 mode |
- | |
4314 | out 0x21,al |
- | |
4315 | call pic_delay |
- | |
4316 | out 0xA1,al |
- | |
4317 | call pic_delay |
- | |
4318 | - | ||
4319 | mov al,255 ; mask all irq's |
- | |
4320 | out 0xA1,al |
- | |
4321 | call pic_delay |
- | |
4322 | out 0x21,al |
- | |
4323 | call pic_delay |
- | |
4324 | - | ||
4325 | mov ecx,0x1000 |
- | |
4326 | cld |
- | |
4327 | picl1: call pic_delay |
- | |
4328 | loop picl1 |
- | |
4329 | - | ||
4330 | mov al,255 ; mask all irq's |
- | |
4331 | out 0xA1,al |
- | |
4332 | call pic_delay |
- | |
4333 | out 0x21,al |
- | |
4334 | call pic_delay |
- | |
4335 | - | ||
4336 | cli |
- | |
4337 | - | ||
4338 | ret |
- | |
4339 | - | ||
4340 | - | ||
4341 | pic_delay: |
- | |
4342 | - | ||
4343 | jmp pdl1 |
- | |
4344 | pdl1: ret |
- | |
4345 | - | ||
4346 | 4300 | ||
Line 4347... | Line 4301... | ||
4347 | sys_msg_board_str: |
4301 | sys_msg_board_str: |
4348 | 4302 | ||
4349 | pushad |
4303 | pushad |
Line 5116... | Line 5070... | ||
5116 | cld |
5070 | cld |
5117 | rep movsd |
5071 | rep movsd |
Line 5118... | Line 5072... | ||
5118 | 5072 | ||
Line 5119... | Line -... | ||
5119 | call restorefatchain |
- | |
5120 | - | ||
5121 | mov al, 0xFF |
5073 | call restorefatchain |
Line 5122... | Line 5074... | ||
5122 | out 0x21, al |
5074 | |
5123 | out 0xA1, al |
5075 | call IRQ_mask_all |
5124 | 5076 |