Rev 2050 | Rev 2130 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2050 | Rev 2106 | ||
---|---|---|---|
Line 66... | Line 66... | ||
66 | ;; |
66 | ;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 68... | Line 68... | ||
68 | 68 | ||
Line 69... | Line 69... | ||
69 | include 'macros.inc' |
69 | include 'macros.inc' |
Line 70... | Line 70... | ||
70 | 70 | ||
Line 71... | Line 71... | ||
71 | $Revision: 2050 $ |
71 | $Revision: 2106 $ |
Line 559... | Line 559... | ||
559 | call init_events |
559 | call init_events |
560 | mov eax, srv.fd-SRV_FD_OFFSET |
560 | mov eax, srv.fd-SRV_FD_OFFSET |
561 | mov [srv.fd], eax |
561 | mov [srv.fd], eax |
562 | mov [srv.bk], eax |
562 | mov [srv.bk], eax |
Line 563... | Line -... | ||
563 | - | ||
564 | mov edi, irq_tab |
- | |
565 | xor eax, eax |
- | |
566 | mov ecx, IRQ_RESERVE |
- | |
567 | rep stosd |
- | |
568 | 563 | ||
569 | ;Set base of graphic segment to linear address of LFB |
564 | ;Set base of graphic segment to linear address of LFB |
570 | mov eax,[LFBAddress] ; set for gs |
565 | mov eax,[LFBAddress] ; set for gs |
571 | mov [graph_data_l+2],ax |
566 | mov [graph_data_l+2],ax |
572 | shr eax,16 |
567 | shr eax,16 |
Line 613... | Line 608... | ||
613 | ; Try to Initialize APIC |
608 | ; Try to Initialize APIC |
614 | call APIC_init |
609 | call APIC_init |
Line 615... | Line 610... | ||
615 | 610 | ||
Line -... | Line 611... | ||
- | 611 | call pci_irq_fixup |
|
- | 612 | ||
- | 613 | call unmask_timer |
|
- | 614 | ||
- | 615 | ; SET KEYBOARD PARAMETERS |
|
- | 616 | mov al, 0xf6 ; reset keyboard, scan enabled |
|
- | 617 | call kb_write |
|
- | 618 | ||
- | 619 | ; wait until 8042 is ready |
|
- | 620 | xor ecx,ecx |
|
- | 621 | @@: |
|
- | 622 | in al,64h |
|
- | 623 | and al,00000010b |
|
- | 624 | loopnz @b |
|
- | 625 | ||
- | 626 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
|
- | 627 | ; call kb_write |
|
- | 628 | ; call kb_read |
|
- | 629 | ; mov al, 111b |
|
- | 630 | ; call kb_write |
|
- | 631 | ; call kb_read |
|
- | 632 | ||
- | 633 | mov al, 0xF3 ; set repeat rate & delay |
|
- | 634 | call kb_write |
|
- | 635 | ; call kb_read |
|
- | 636 | mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
|
- | 637 | call kb_write |
|
- | 638 | ; call kb_read |
|
- | 639 | ;// mike.dld [ |
|
- | 640 | call set_lights |
|
- | 641 | stdcall attach_int_handler, 1, irq1, 0 |
|
- | 642 | ||
- | 643 | ;// mike.dld ] |
|
616 | call pci_irq_fixup |
644 | |
617 | 645 | ||
618 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
- | |
619 | ; they are used: when partitions are scanned, hd_read relies on timer |
- | |
- | 646 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
|
620 | call unmask_timer |
647 | ; they are used: when partitions are scanned, hd_read relies on timer |
621 | stdcall enable_irq, 12 |
648 | |
622 | stdcall enable_irq, 1 |
649 | stdcall enable_irq, 6 ; FDD |
Line 623... | Line 650... | ||
623 | stdcall enable_irq, 14 |
650 | stdcall enable_irq, 14 |
624 | stdcall enable_irq, 15 |
651 | stdcall enable_irq, 15 |
Line 723... | Line 750... | ||
723 | 750 | ||
724 | mov esi,boot_resirqports |
751 | mov esi,boot_resirqports |
725 | call boot_log |
752 | call boot_log |
Line 726... | Line -... | ||
726 | call reserve_irqs_ports |
- | |
727 | - | ||
728 | ; SET PORTS FOR IRQ HANDLERS |
- | |
729 | - | ||
730 | ;mov esi,boot_setrports |
- | |
731 | ;call boot_log |
- | |
732 | ;call setirqreadports |
753 | call reserve_irqs_ports |
Line 733... | Line 754... | ||
733 | 754 | ||
734 | ; SET UP OS TASK |
755 | ; SET UP OS TASK |
Line 909... | Line 930... | ||
909 | 930 | ||
910 | ;mov [TASK_COUNT],dword 2 |
931 | ;mov [TASK_COUNT],dword 2 |
911 | push 1 |
932 | push 1 |
Line 912... | Line -... | ||
912 | pop dword [CURRENT_TASK] ; set OS task fisrt |
- | |
913 | - | ||
914 | ; SET KEYBOARD PARAMETERS |
- | |
915 | mov al, 0xf6 ; reset keyboard, scan enabled |
- | |
916 | call kb_write |
- | |
917 | - | ||
918 | ; wait until 8042 is ready |
- | |
919 | xor ecx,ecx |
- | |
920 | @@: |
- | |
921 | in al,64h |
- | |
922 | and al,00000010b |
- | |
923 | loopnz @b |
- | |
924 | - | ||
925 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
- | |
926 | ; call kb_write |
- | |
927 | ; call kb_read |
- | |
928 | ; mov al, 111b |
- | |
929 | ; call kb_write |
- | |
930 | ; call kb_read |
- | |
931 | - | ||
932 | mov al, 0xF3 ; set repeat rate & delay |
- | |
933 | call kb_write |
- | |
934 | ; call kb_read |
- | |
935 | mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
- | |
936 | call kb_write |
- | |
937 | ; call kb_read |
- | |
938 | ;// mike.dld [ |
- | |
939 | call set_lights |
- | |
Line 940... | Line 933... | ||
940 | ;// mike.dld ] |
933 | pop dword [CURRENT_TASK] ; set OS task fisrt |
Line 941... | Line 934... | ||
941 | 934 | ||
Line 992... | Line 985... | ||
992 | jne .bll1 |
985 | jne .bll1 |
993 | end if |
986 | end if |
Line 994... | Line 987... | ||
994 | 987 | ||
995 | cli ;guarantee forbidance of interrupts. |
988 | cli ;guarantee forbidance of interrupts. |
996 | stdcall enable_irq, 2 ; @#$%! PIC |
- | |
997 | stdcall enable_irq, 6 ; FDD |
989 | stdcall enable_irq, 2 ; @#$%! PIC |
998 | stdcall enable_irq, 13 ; co-processor |
- | |
999 | stdcall attach_int_handler_ex, 1, irq1, 0 |
990 | stdcall enable_irq, 13 ; co-processor |
1000 | cmp [IDEContrRegsBaseAddr], 0 |
991 | cmp [IDEContrRegsBaseAddr], 0 |
1001 | setnz [dma_hdd] |
992 | setnz [dma_hdd] |
Line 1002... | Line 993... | ||
1002 | mov [timer_ticks_enable],1 ; for cd driver |
993 | mov [timer_ticks_enable],1 ; for cd driver |
Line 1103... | Line 1094... | ||
1103 | ; ; |
1094 | ; ; |
1104 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1095 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 1105... | Line 1096... | ||
1105 | 1096 | ||
Line 1106... | Line -... | ||
1106 | reserve_irqs_ports: |
- | |
1107 | - | ||
1108 | push eax |
- | |
1109 | xor eax,eax |
- | |
1110 | inc eax |
- | |
1111 | mov byte [irq_owner+4*0],al ;1 ; timer |
- | |
1112 | ;mov [irq_owner+4*1], 1 ; keyboard |
- | |
1113 | mov byte [irq_owner+4*6],al ;1 ; floppy diskette |
- | |
1114 | mov byte [irq_owner+4*13],al ;1 ; math co-pros |
- | |
1115 | mov byte [irq_owner+4*14],al ;1 ; ide I |
- | |
Line 1116... | Line 1097... | ||
1116 | mov byte [irq_owner+4*15],al ;1 ; ide II |
1097 | reserve_irqs_ports: |
1117 | pop eax |
- | |
1118 | 1098 | ||
- | 1099 | ||
Line 1119... | Line -... | ||
1119 | ; RESERVE PORTS |
- | |
1120 | push 4 |
1100 | ; RESERVE PORTS |
1121 | pop dword [RESERVED_PORTS] ;,edi |
- | |
1122 | - | ||
Line 1123... | Line -... | ||
1123 | push 1 |
- | |
1124 | pop dword [RESERVED_PORTS+16+0] ;,dword 1 |
- | |
1125 | and dword [RESERVED_PORTS+16+4],0 ;,dword 0x0 |
1101 | mov eax, RESERVED_PORTS |
1126 | mov dword [RESERVED_PORTS+16+8],0x2d ;,dword 0x2d |
1102 | mov ecx, 1 |
1127 | - | ||
1128 | push 1 |
1103 | |
1129 | pop dword [RESERVED_PORTS+32+0] ;,dword 1 |
1104 | mov [eax], dword 4 |
1130 | push 0x30 |
- | |
1131 | pop dword [RESERVED_PORTS+32+4] ;,dword 0x30 |
1105 | |
1132 | push 0x4d |
- | |
1133 | pop dword [RESERVED_PORTS+32+8] ;,dword 0x4d |
1106 | mov [eax+16], ecx |
1134 | 1107 | mov [eax+16+4], dword 0 |
|
1135 | push 1 |
1108 | mov [eax+16+4], dword 0x2D |
1136 | pop dword [RESERVED_PORTS+48+0] ;,dword 1 |
1109 | |
- | 1110 | mov [eax+32], ecx |
|
1137 | push 0x50 |
1111 | mov [eax+32+4], dword 0x30 |
1138 | pop dword [RESERVED_PORTS+48+4] ;,dword 0x50 |
1112 | mov [eax+32+8], dword 0x4D |
- | 1113 | ||
1139 | mov dword [RESERVED_PORTS+48+8],0xdf ;,dword 0xdf |
1114 | mov [eax+48], ecx |
1140 | 1115 | mov [eax+48+4], dword 0x50 |
|
Line 1141... | Line 1116... | ||
1141 | push 1 |
1116 | mov [eax+28+8], dword 0xDF |
Line 1142... | Line -... | ||
1142 | pop dword [RESERVED_PORTS+64+0] ;,dword 1 |
- | |
1143 | - | ||
1144 | mov dword [RESERVED_PORTS+64+4],0xe5 ;,dword 0xe5 |
- | |
1145 | mov dword [RESERVED_PORTS+64+8],0xff ;,dword 0xff |
- | |
1146 | - | ||
1147 | ret |
- | |
1148 | - | ||
1149 | setirqreadports: |
- | |
1150 | - | ||
1151 | mov [irq00read+12*4*16],dword 0x60 + 0x01000000 ; read port 0x60 , byte |
- | |
1152 | and dword [irq00read+12*4*16],0 ; end of port list |
- | |
Line 1153... | Line 1117... | ||
1153 | ; mov [irq12read+4],dword 0 ; end of port list |
1117 | |
1154 | ;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
1118 | mov [eax+64], ecx |
1155 | ;mov [irq04read+4],dword 0 ; end of port list |
1119 | mov [eax+64+4], dword 0xE5 |
Line 3466... | Line 3430... | ||
3466 | ; ret |
3430 | ; ret |
Line 3467... | Line 3431... | ||
3467 | 3431 | ||
3468 | - | ||
3469 | - | ||
3470 | align 4 |
- | |
3471 | - | ||
3472 | sys_programirq: |
- | |
3473 | - | ||
3474 | mov eax, [TASK_BASE] |
- | |
3475 | add ebx, [eax + TASKDATA.mem_start] |
- | |
3476 | - | ||
3477 | cmp ecx, 16 |
- | |
3478 | jae .not_owner |
- | |
3479 | mov edi, [eax + TASKDATA.pid] |
- | |
3480 | cmp edi, [irq_owner + 4 * ecx] |
- | |
3481 | je .spril1 |
- | |
3482 | .not_owner: |
- | |
3483 | xor ecx, ecx |
- | |
3484 | inc ecx |
- | |
3485 | jmp .end |
- | |
3486 | .spril1: |
- | |
3487 | - | ||
3488 | shl ecx, 6 |
- | |
3489 | mov esi, ebx |
- | |
3490 | lea edi, [irq00read + ecx] |
- | |
3491 | push 16 |
- | |
3492 | pop ecx |
- | |
3493 | - | ||
3494 | cld |
- | |
3495 | rep movsd |
- | |
3496 | .end: |
- | |
3497 | mov [esp+32], ecx |
- | |
3498 | ret |
- | |
3499 | - | ||
3500 | - | ||
3501 | align 4 |
- | |
3502 | - | ||
3503 | get_irq_data: |
- | |
3504 | movzx esi, bh ; save number of subfunction, if bh = 1, return data size, otherwise, read data |
- | |
3505 | xor bh, bh |
- | |
3506 | cmp ebx, 16 |
- | |
3507 | jae .not_owner |
- | |
3508 | mov edx, [4 * ebx + irq_owner] ; check for irq owner |
- | |
3509 | - | ||
3510 | mov eax,[TASK_BASE] |
- | |
3511 | - | ||
3512 | cmp edx,[eax+TASKDATA.pid] |
- | |
3513 | je gidril1 |
- | |
3514 | .not_owner: |
- | |
3515 | xor edx, edx |
- | |
3516 | dec edx |
- | |
3517 | jmp gid1 |
- | |
3518 | - | ||
3519 | gidril1: |
- | |
3520 | - | ||
3521 | shl ebx, 12 |
- | |
3522 | lea eax, [ebx + IRQ_SAVE] ; calculate address of the beginning of buffer + 0x0 - data size |
- | |
3523 | mov edx, [eax] ; + 0x4 - data offset |
- | |
3524 | dec esi |
- | |
3525 | jz gid1 |
- | |
3526 | test edx, edx ; check if buffer is empty |
- | |
3527 | jz gid1 |
- | |
3528 | - | ||
3529 | mov ebx, [eax + 0x4] |
- | |
3530 | mov edi, ecx |
- | |
3531 | - | ||
3532 | mov ecx, 4000 ; buffer size, used frequently |
- | |
3533 | - | ||
3534 | cmp ebx, ecx ; check for the end of buffer, if end of buffer, begin cycle again |
- | |
3535 | jb @f |
- | |
3536 | - | ||
3537 | xor ebx, ebx |
- | |
3538 | - | ||
3539 | @@: |
- | |
3540 | - | ||
3541 | lea esi, [ebx + edx] ; calculate data size and offset |
- | |
3542 | cld |
- | |
3543 | cmp esi, ecx ; if greater than the buffer size, begin cycle again |
- | |
3544 | jbe @f |
- | |
3545 | - | ||
3546 | sub ecx, ebx |
- | |
3547 | sub edx, ecx |
- | |
3548 | - | ||
3549 | lea esi, [eax + ebx + 0x10] |
- | |
3550 | rep movsb |
- | |
3551 | - | ||
3552 | xor ebx, ebx |
- | |
3553 | @@: |
- | |
3554 | lea esi, [eax + ebx + 0x10] |
- | |
3555 | mov ecx, edx |
- | |
3556 | add ebx, edx |
- | |
3557 | - | ||
3558 | rep movsb |
- | |
3559 | mov edx, [eax] |
- | |
3560 | mov [eax], ecx ; set data size to zero |
- | |
3561 | mov [eax + 0x4], ebx ; set data offset |
- | |
3562 | - | ||
3563 | gid1: |
- | |
3564 | mov [esp+32], edx ; eax |
- | |
3565 | ret |
3432 | |
3566 | 3433 | ||
3567 | 3434 | align 4 |
|
3568 | set_io_access_rights: |
3435 | set_io_access_rights: |
3569 | push edi eax |
3436 | push edi eax |
Line 3574... | Line 3441... | ||
3574 | ; add edi,eax |
3441 | ; add edi,eax |
3575 | ; mov ebx,1 |
3442 | ; mov ebx,1 |
3576 | ; shl ebx,cl |
3443 | ; shl ebx,cl |
3577 | test ebp,ebp |
3444 | test ebp,ebp |
3578 | ; cmp ebp,0 ; enable access - ebp = 0 |
3445 | ; cmp ebp,0 ; enable access - ebp = 0 |
3579 | jnz siar1 |
3446 | jnz .siar1 |
3580 | ; not ebx |
3447 | ; not ebx |
3581 | ; and [edi],byte bl |
3448 | ; and [edi],byte bl |
3582 | btr [edi], eax |
3449 | btr [edi], eax |
3583 | pop eax edi |
3450 | pop eax edi |
3584 | ret |
3451 | ret |
3585 | siar1: |
3452 | .siar1: |
3586 | bts [edi], eax |
3453 | bts [edi], eax |
3587 | ; or [edi],byte bl ; disable access - ebp = 1 |
3454 | ; or [edi],byte bl ; disable access - ebp = 1 |
3588 | pop eax edi |
3455 | pop eax edi |
3589 | ret |
3456 | ret |
3590 | ;reserve/free group of ports |
3457 | ;reserve/free group of ports |
Line 3735... | Line 3602... | ||
3735 | ; popad ; end disable io map |
3602 | ; popad ; end disable io map |
3736 | xor eax, eax |
3603 | xor eax, eax |
3737 | ret |
3604 | ret |
Line 3738... | Line -... | ||
3738 | - | ||
3739 | - | ||
3740 | reserve_free_irq: |
- | |
3741 | - | ||
3742 | xor esi, esi |
- | |
3743 | inc esi |
- | |
3744 | cmp ecx, 16 |
- | |
3745 | jae ril1 |
- | |
3746 | - | ||
3747 | push ecx |
- | |
3748 | lea ecx, [irq_owner + 4 * ecx] |
- | |
3749 | mov edx, [ecx] ; IRQ owner PID |
- | |
3750 | mov eax, [TASK_BASE] |
- | |
3751 | mov edi, [eax + TASKDATA.pid] ; current task PID |
- | |
3752 | pop eax |
- | |
3753 | dec ebx |
- | |
3754 | jnz reserve_irq |
- | |
3755 | ; free irq |
- | |
3756 | cmp edx, edi ; check owner |
- | |
3757 | jne ril1 |
- | |
3758 | dec esi |
- | |
3759 | mov [ecx], esi ; esi = 0 |
- | |
3760 | - | ||
3761 | jmp ril1 ; return successful |
- | |
3762 | - | ||
3763 | reserve_irq: |
- | |
3764 | - | ||
3765 | cmp dword [ecx], 0 |
- | |
3766 | jne ril1 |
- | |
3767 | - | ||
3768 | mov ebx, [f_irqs + 4 * eax] |
- | |
3769 | - | ||
3770 | stdcall attach_int_handler_ex, eax, ebx, dword 0 |
- | |
3771 | - | ||
3772 | mov [ecx], edi |
- | |
3773 | - | ||
3774 | dec esi |
- | |
3775 | ril1: |
- | |
3776 | mov [esp+32], esi ; return in eax |
- | |
3777 | ret |
- | |
3778 | 3605 | ||
3779 | iglobal |
- | |
3780 | f_irqs: |
- | |
3781 | dd 0x0 |
- | |
3782 | dd 0x0 |
- | |
3783 | dd p_irq2 |
- | |
3784 | dd p_irq3 |
- | |
3785 | dd p_irq4 |
- | |
3786 | dd p_irq5 |
- | |
3787 | dd p_irq6 |
- | |
3788 | dd p_irq7 |
- | |
3789 | dd p_irq8 |
- | |
3790 | dd p_irq9 |
- | |
3791 | dd p_irq10 |
- | |
3792 | dd p_irq11 |
- | |
3793 | dd 0x0 |
- | |
3794 | dd 0x0 |
- | |
3795 | dd p_irq14 |
- | |
3796 | dd p_irq15 |
- | |
3797 | - | ||
3798 | ; I don`t known how to use IRQ_RESERVE |
- | |
3799 | if IRQ_RESERVE > 16 |
- | |
3800 | dd p_irq16 |
- | |
3801 | dd p_irq17 |
- | |
3802 | dd p_irq18 |
- | |
3803 | dd p_irq19 |
- | |
3804 | dd p_irq20 |
- | |
3805 | dd p_irq21 |
- | |
3806 | dd p_irq22 |
- | |
3807 | dd p_irq23 |
- | |
3808 | end if |
- | |
3809 | - | ||
3810 | endg |
3606 | |
3811 | 3607 | align 4 |
|
3812 | drawbackground: |
3608 | drawbackground: |
3813 | inc [mouse_pause] |
3609 | inc [mouse_pause] |
3814 | cmp [SCR_MODE],word 0x12 |
3610 | cmp [SCR_MODE],word 0x12 |
Line 4834... | Line 4630... | ||
4834 | xor edi, edi |
4630 | xor edi, edi |
4835 | add ebx, ebp |
4631 | add ebx, ebp |
4836 | mov ecx, edx |
4632 | mov ecx, edx |
4837 | jmp [draw_line] |
4633 | jmp [draw_line] |
Line 4838... | Line -... | ||
4838 | - | ||
4839 | align 4 |
- | |
4840 | - | ||
Line 4841... | Line -... | ||
4841 | syscall_getirqowner: ; GetIrqOwner |
- | |
4842 | - | ||
4843 | cmp ebx,16 |
- | |
4844 | jae .err |
- | |
4845 | - | ||
4846 | cmp [irq_rights + 4 * ebx], dword 2 |
- | |
4847 | je .err |
- | |
4848 | - | ||
4849 | mov eax,[4 * ebx + irq_owner] |
- | |
4850 | mov [esp+32],eax |
- | |
4851 | - | ||
4852 | ret |
- | |
4853 | .err: |
- | |
Line 4854... | Line 4634... | ||
4854 | or dword [esp+32], -1 |
4634 | |
4855 | ret |
- | |
4856 | 4635 | ||
Line 4857... | Line 4636... | ||
4857 | align 4 |
4636 | |
4858 | 4637 | align 4 |
|
4859 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
4638 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
Line 4860... | Line 4639... | ||
4860 | 4639 | ||
4861 | call r_f_port_area |
- | |
4862 | mov [esp+32],eax |
4640 | call r_f_port_area |
4863 | ret |
4641 | mov [esp+32],eax |
4864 | 4642 | ret |
|
4865 | align 4 |
4643 | |
4866 | 4644 | align 4 |