Rev 4611 | Rev 4641 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4611 | Rev 4624 | ||
---|---|---|---|
Line 69... | Line 69... | ||
69 | format binary as "mnt" |
69 | format binary as "mnt" |
Line 70... | Line 70... | ||
70 | 70 | ||
71 | include 'macros.inc' |
71 | include 'macros.inc' |
Line 72... | Line 72... | ||
72 | include 'struct.inc' |
72 | include 'struct.inc' |
Line 73... | Line 73... | ||
73 | 73 | ||
74 | $Revision: 4611 $ |
74 | $Revision: 4624 $ |
Line 370... | Line 370... | ||
370 | mov ecx, ide_channel2_mutex |
370 | mov ecx, ide_channel2_mutex |
371 | call mutex_init |
371 | call mutex_init |
372 | ;----------------------------------------------------------------------------- |
372 | ;----------------------------------------------------------------------------- |
373 | ; SAVE REAL MODE VARIABLES |
373 | ; SAVE REAL MODE VARIABLES |
374 | ;----------------------------------------------------------------------------- |
374 | ;----------------------------------------------------------------------------- |
375 | save_variables_IDE_controller: |
- | |
376 | xor eax, eax |
- | |
377 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
- | |
378 | mov [IDE_Interrupt], ax |
- | |
379 | ;-------------------------------------- |
- | |
380 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
- | |
381 | mov [IDEContrProgrammingInterface], ax |
- | |
382 | ;-------------------------------------- |
- | |
383 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
- | |
384 | mov [IDEContrRegsBaseAddr], ax |
- | |
385 | ;-------------------------------------- |
- | |
386 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
- | |
387 | cmp ax, 0 |
- | |
388 | je @f |
- | |
389 | cmp ax, 1 |
- | |
390 | jne .no_PATA_BAR0 |
- | |
391 | @@: |
- | |
392 | mov ax, 0x1F0 |
- | |
393 | jmp @f |
- | |
394 | .no_PATA_BAR0: |
- | |
395 | and ax, 0xFFFC |
- | |
396 | @@: |
- | |
397 | mov [StandardATABases], ax |
- | |
398 | mov [hd_address_table], eax |
- | |
399 | mov [hd_address_table+8], eax |
- | |
400 | mov [IDE_BAR0_val], ax |
- | |
401 | ;-------------------------------------- |
- | |
402 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
- | |
403 | cmp ax, 0 |
- | |
404 | je @f |
- | |
405 | cmp ax, 1 |
- | |
406 | jne .no_PATA_BAR1 |
- | |
407 | @@: |
- | |
408 | mov ax, 0x3F4 |
- | |
409 | jmp @f |
- | |
410 | .no_PATA_BAR1: |
- | |
411 | and ax, 0xFFFC |
- | |
412 | @@: |
- | |
413 | mov [IDE_BAR1_val], ax |
- | |
414 | ;-------------------------------------- |
- | |
415 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
- | |
416 | cmp ax, 0 |
- | |
417 | je @f |
- | |
418 | cmp ax, 1 |
- | |
419 | jne .no_PATA_BAR2 |
- | |
420 | @@: |
- | |
421 | mov ax, 0x170 |
- | |
422 | jmp @f |
- | |
423 | .no_PATA_BAR2: |
- | |
424 | and ax, 0xFFFC |
- | |
425 | @@: |
- | |
426 | mov [StandardATABases+2], ax |
- | |
427 | mov [hd_address_table+16], eax |
- | |
428 | mov [hd_address_table+24], eax |
- | |
429 | mov [IDE_BAR2_val], ax |
- | |
430 | ;-------------------------------------- |
- | |
431 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
- | |
432 | cmp ax, 0 |
- | |
433 | je @f |
- | |
434 | cmp ax, 1 |
- | |
435 | jne .no_PATA_BAR3 |
- | |
436 | @@: |
- | |
437 | mov ax, 0x374 |
- | |
438 | jmp @f |
- | |
439 | .no_PATA_BAR3: |
- | |
440 | and ax, 0xFFFC |
- | |
441 | @@: |
- | |
442 | mov [IDE_BAR3_val], ax |
- | |
443 | - | ||
444 | ; --------------- APM --------------------- |
375 | ; --------------- APM --------------------- |
Line 445... | Line 376... | ||
445 | 376 | ||
446 | ; init selectors |
377 | ; init selectors |
447 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
378 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
Line 795... | Line 726... | ||
795 | ;----------------------------------------------------------------------------- |
726 | ;----------------------------------------------------------------------------- |
796 | mov esi, boot_detectfloppy |
727 | mov esi, boot_detectfloppy |
797 | call boot_log |
728 | call boot_log |
798 | include 'detect/dev_fd.inc' |
729 | include 'detect/dev_fd.inc' |
799 | ;----------------------------------------------------------------------------- |
730 | ;----------------------------------------------------------------------------- |
800 | ; START of initialisation IDE ATA code |
731 | ; create pci-devices list |
801 | ;----------------------------------------------------------------------------- |
732 | ;----------------------------------------------------------------------------- |
802 | cmp [IDEContrProgrammingInterface], 0 |
- | |
803 | je set_interrupts_for_IDE_controllers.continue |
- | |
804 | - | ||
805 | mov esi, boot_disabling_ide |
733 | mov [pci_access_enabled], 1 |
806 | call boot_log |
- | |
807 | ;-------------------------------------- |
- | |
808 | ; Disable IDE interrupts, because the search |
- | |
809 | ; for IDE partitions is in the PIO mode. |
- | |
810 | ;-------------------------------------- |
- | |
811 | .disable_IDE_interrupt: |
- | |
812 | ; Disable interrupts in IDE controller for PIO |
- | |
813 | mov al, 2 |
- | |
814 | mov dx, [IDE_BAR1_val] ;0x3F4 |
- | |
815 | add dx, 2 ;0x3F6 |
- | |
816 | out dx, al |
- | |
817 | mov dx, [IDE_BAR3_val] ;0x374 |
- | |
818 | add dx, 2 ;0x376 |
- | |
819 | out dx, al |
- | |
820 | @@: |
- | |
821 | ; show base variables of IDE controller |
- | |
822 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
- | |
823 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
- | |
824 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
- | |
825 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
- | |
826 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
- | |
827 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
- | |
828 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
- | |
829 | ;----------------------------------------------------------------------------- |
- | |
830 | mov esi, boot_detecthdcd |
- | |
831 | call boot_log |
- | |
832 | include 'detect/dev_hdcd.inc' |
- | |
833 | mov esi, boot_getcache |
- | |
834 | call boot_log |
- | |
835 | include 'detect/getcache.inc' |
- | |
836 | mov esi, boot_detectpart |
- | |
837 | call boot_log |
734 | call pci_enum |
838 | include 'detect/sear_par.inc' |
- | |
839 | ;----------------------------------------------------------------------------- |
- | |
840 | mov dx, [IDEContrRegsBaseAddr] |
- | |
841 | ; test whether it is our interrupt? |
- | |
842 | add dx, 2 |
- | |
843 | in al, dx |
- | |
844 | test al, 100b |
- | |
845 | jz @f |
- | |
846 | ; clear Bus Master IDE Status register |
- | |
847 | ; clear Interrupt bit |
- | |
848 | out dx, al |
- | |
849 | @@: |
- | |
850 | add dx, 8 |
- | |
851 | ; test whether it is our interrupt? |
- | |
852 | in al, dx |
- | |
853 | test al, 100b |
- | |
854 | jz @f |
- | |
855 | ; clear Bus Master IDE Status register |
- | |
856 | ; clear Interrupt bit |
- | |
857 | out dx, al |
- | |
858 | @@: |
- | |
859 | ; read status register and remove the interrupt request |
- | |
860 | mov dx, [IDE_BAR0_val] ;0x1F0 |
- | |
861 | add dx, 0x7 ;0x1F7 |
- | |
862 | in al, dx |
- | |
863 | mov dx, [IDE_BAR2_val] ;0x170 |
- | |
864 | add dx, 0x7 ;0x177 |
- | |
865 | in al, dx |
- | |
866 | ;----------------------------------------------------------------------------- |
735 | ;----------------------------------------------------------------------------- |
867 | push eax edx |
- | |
868 | mov dx, [IDEContrRegsBaseAddr] |
- | |
869 | xor eax, eax |
- | |
870 | add dx, 2 |
- | |
871 | in al, dx |
- | |
872 | DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax |
- | |
873 | - | ||
874 | add dx, 8 |
- | |
875 | in al, dx |
- | |
876 | DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax |
- | |
877 | pop edx eax |
- | |
878 | - | ||
879 | cmp [IDEContrRegsBaseAddr], 0 |
- | |
880 | setnz [dma_hdd] |
- | |
881 | ;----------------------------------------------------------------------------- |
- | |
882 | ; set interrupts for IDE Controller |
736 | ; initialisation IDE ATA code |
883 | ;----------------------------------------------------------------------------- |
- | |
884 | mov esi, boot_set_int_IDE |
- | |
885 | call boot_log |
- | |
886 | set_interrupts_for_IDE_controllers: |
- | |
887 | mov ax, [IDEContrProgrammingInterface] |
- | |
888 | cmp ax, 0x0180 |
- | |
889 | je .pata_ide |
- | |
890 | - | ||
891 | cmp ax, 0x018a |
- | |
892 | jne .sata_ide |
- | |
893 | ;-------------------------------------- |
- | |
894 | .pata_ide: |
- | |
895 | cmp [IDEContrRegsBaseAddr], 0 |
- | |
896 | je .end_set_interrupts |
- | |
897 | - | ||
898 | stdcall attach_int_handler, 14, IDE_irq_14_handler, 0 |
- | |
899 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
- | |
900 | stdcall attach_int_handler, 15, IDE_irq_15_handler, 0 |
- | |
901 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
- | |
902 | jmp .enable_IDE_interrupt |
- | |
903 | ;-------------------------------------- |
- | |
904 | .sata_ide: |
- | |
905 | cmp ax, 0x0185 |
- | |
906 | je .sata_ide_1 |
- | |
907 | - | ||
908 | cmp ax, 0x018f |
- | |
909 | jne .end_set_interrupts |
- | |
910 | ;-------------------------------------- |
- | |
911 | .sata_ide_1: |
- | |
912 | cmp [IDEContrRegsBaseAddr], 0 |
- | |
913 | je .end_set_interrupts |
- | |
914 | - | ||
915 | mov ax, [IDE_Interrupt] |
- | |
916 | movzx eax, al |
- | |
917 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
- | |
918 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax |
- | |
919 | ;-------------------------------------- |
- | |
920 | .enable_IDE_interrupt: |
- | |
921 | mov esi, boot_enabling_ide |
- | |
922 | call boot_log |
- | |
923 | ; Enable interrupts in IDE controller for DMA |
- | |
924 | mov al, 0 |
- | |
925 | mov ah, [DRIVE_DATA+1] |
- | |
926 | test ah, 10100000b |
- | |
927 | jz @f |
- | |
928 | - | ||
929 | DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n" |
- | |
930 | jmp .ch2_check |
- | |
931 | @@: |
- | |
932 | mov dx, [IDE_BAR1_val] ;0x3F4 |
- | |
933 | add dx, 2 ;0x3F6 |
- | |
934 | out dx, al |
- | |
935 | DEBUGF 1, "K : IDE CH1 DMA enabled\n" |
- | |
936 | .ch2_check: |
- | |
937 | test ah, 1010b |
- | |
938 | jz @f |
- | |
939 | - | ||
940 | DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n" |
- | |
941 | jmp .end_set_interrupts |
- | |
942 | @@: |
- | |
943 | mov dx, [IDE_BAR3_val] ;0x374 |
- | |
944 | add dx, 2 ;0x376 |
- | |
945 | out dx, al |
- | |
946 | DEBUGF 1, "K : IDE CH2 DMA enabled\n" |
- | |
947 | ;-------------------------------------- |
- | |
948 | .end_set_interrupts: |
- | |
949 | ;----------------------------------------------------------------------------- |
- | |
950 | cmp [dma_hdd], 0 |
- | |
951 | je .print_pio |
- | |
952 | .print_dma: |
- | |
953 | DEBUGF 1, "K : IDE DMA mode\n" |
- | |
954 | jmp .continue |
- | |
955 | - | ||
956 | .print_pio: |
- | |
957 | DEBUGF 1, "K : IDE PIO mode\n" |
- | |
958 | .continue: |
- | |
959 | ;----------------------------------------------------------------------------- |
737 | ;----------------------------------------------------------------------------- |
960 | ; END of initialisation IDE ATA code |
738 | include 'detect/init_ata.inc' |
961 | ;----------------------------------------------------------------------------- |
739 | ;----------------------------------------------------------------------------- |
962 | mov esi, boot_init_sys |
740 | mov esi, boot_init_sys |
963 | call boot_log |
741 | call boot_log |
964 | call Parser_params |
742 | call Parser_params |
Line 1020... | Line 798... | ||
1020 | ; call build_scheduler; sys32.inc |
798 | ; call build_scheduler; sys32.inc |
Line 1021... | Line 799... | ||
1021 | 799 | ||
1022 | ; mov esi, boot_devices |
800 | ; mov esi, boot_devices |
Line 1023... | Line -... | ||
1023 | ; call boot_log |
- | |
1024 | - | ||
1025 | mov [pci_access_enabled], 1 |
801 | ; call boot_log |
Line 1026... | Line 802... | ||
1026 | call pci_enum |
802 | |
Line 1027... | Line 803... | ||
1027 | call clear_pci_ide_interrupts |
803 | call clear_pci_ide_interrupts |