Subversion Repositories Kolibri OS

Rev

Rev 4573 | Rev 4578 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4573 Rev 4575
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: 4573 $
74
$Revision: 4575 $
Line 774... Line 774...
774
; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13)
774
; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13)
775
; they are used: when partitions are scanned, hd_read relies on timer
775
; they are used: when partitions are scanned, hd_read relies on timer
776
        call    unmask_timer
776
        call    unmask_timer
777
        stdcall enable_irq, 2               ; @#$%! PIC
777
        stdcall enable_irq, 2               ; @#$%! PIC
778
        stdcall enable_irq, 13              ; co-processor
778
        stdcall enable_irq, 13              ; co-processor
-
 
779
;-----------------------------------------------------------------------------
-
 
780
; show SVN version of kernel on the message board
-
 
781
;-----------------------------------------------------------------------------
-
 
782
        mov     eax, [version_inf.rev]
-
 
783
        DEBUGF  1, "K : kernel SVN r%d\n", eax
-
 
784
;-----------------------------------------------------------------------------
-
 
785
; show CPU count on the message board
-
 
786
;-----------------------------------------------------------------------------
-
 
787
        mov     eax, [cpu_count]
-
 
788
        test    eax, eax
-
 
789
        jnz     @F
-
 
790
        mov     al, 1                             ; at least one CPU
779
 
791
@@:
-
 
792
        DEBUGF  1, "K : %d CPU detected\n", eax
-
 
793
;-----------------------------------------------------------------------------
-
 
794
; detect Floppy drives
-
 
795
;-----------------------------------------------------------------------------
-
 
796
        mov     esi, boot_detectfloppy
-
 
797
        call    boot_log
-
 
798
include 'detect/dev_fd.inc'
-
 
799
;-----------------------------------------------------------------------------
-
 
800
; START of initialisation IDE ATA code
-
 
801
;-----------------------------------------------------------------------------
780
        cmp     [IDEContrProgrammingInterface], 0
802
        cmp     [IDEContrProgrammingInterface], 0
781
        je      @f
803
        je      @f
Line 782... Line 804...
782
 
804
 
783
        mov     esi, boot_disabling_ide
805
        mov     esi, boot_disabling_ide
Line 794... Line 816...
794
        out     dx, al
816
        out     dx, al
795
        mov     dx, [IDE_BAR3_val] ;0x374
817
        mov     dx, [IDE_BAR3_val] ;0x374
796
        add     dx, 2 ;0x376
818
        add     dx, 2 ;0x376
797
        out     dx, al
819
        out     dx, al
798
@@:
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
799
;-----------------------------------------------------------------------------
829
;-----------------------------------------------------------------------------
800
;!!!!!!!!!!!!!!!!!!!!!!!!!!
-
 
801
;        mov     esi, boot_detectdisks
-
 
802
;        call    boot_log
-
 
803
;include 'detect/disks.inc'
-
 
804
        mov     esi, boot_detectfloppy
-
 
805
        call    boot_log
-
 
806
include 'detect/dev_fd.inc'
-
 
807
        mov     esi, boot_detecthdcd
830
        mov     esi, boot_detecthdcd
808
        call    boot_log
831
        call    boot_log
809
include 'detect/dev_hdcd.inc'
832
include 'detect/dev_hdcd.inc'
810
        mov     esi, boot_getcache
833
        mov     esi, boot_getcache
811
        call    boot_log
834
        call    boot_log
812
include 'detect/getcache.inc'
835
include 'detect/getcache.inc'
813
        mov     esi, boot_detectpart
836
        mov     esi, boot_detectpart
814
        call    boot_log
837
        call    boot_log
815
include 'detect/sear_par.inc'
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
;-----------------------------------------------------------------------------
-
 
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
        cmp     [IDEContrProgrammingInterface], 0
-
 
883
        je      set_interrupts_for_IDE_controllers.continue
-
 
884
;-----------------------------------------------------------------------------
-
 
885
; set interrupts for IDE Controller
-
 
886
;-----------------------------------------------------------------------------
-
 
887
        mov     esi, boot_set_int_IDE
-
 
888
        call    boot_log
-
 
889
set_interrupts_for_IDE_controllers:
-
 
890
        mov     ax, [IDEContrProgrammingInterface]
-
 
891
        cmp     ax, 0x0180
-
 
892
        je      .pata_ide
-
 
893
 
-
 
894
        cmp     ax, 0x018a
-
 
895
        jne     .sata_ide
-
 
896
;--------------------------------------
-
 
897
.pata_ide:
-
 
898
        cmp     [IDEContrRegsBaseAddr], 0
-
 
899
        je      .end_set_interrupts
-
 
900
 
-
 
901
        stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
-
 
902
        DEBUGF  1, "K : Set IDE IRQ14 return code %x\n", eax
-
 
903
        stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
-
 
904
        DEBUGF  1, "K : Set IDE IRQ15 return code %x\n", eax
-
 
905
        jmp     .enable_IDE_interrupt
-
 
906
;--------------------------------------
-
 
907
.sata_ide:
-
 
908
        cmp     ax, 0x0185
816
;!!!!!!!!!!!!!!!!!!!!!!!!!!
909
        je      .sata_ide_1
-
 
910
 
-
 
911
        cmp     ax, 0x018f
-
 
912
        jne     .end_set_interrupts
-
 
913
;--------------------------------------
-
 
914
.sata_ide_1:
-
 
915
        cmp     [IDEContrRegsBaseAddr], 0
-
 
916
        je      .end_set_interrupts
-
 
917
 
-
 
918
        mov     ax, [IDE_Interrupt]
-
 
919
        movzx   eax, al
-
 
920
        stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
-
 
921
        DEBUGF  1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax
-
 
922
;--------------------------------------
-
 
923
.enable_IDE_interrupt:
-
 
924
        mov     esi, boot_enabling_ide
-
 
925
        call    boot_log
-
 
926
; Enable interrupts in IDE controller for DMA
-
 
927
        mov     al, 0
-
 
928
        mov     ah, [DRIVE_DATA+1]
-
 
929
        test    ah, 10100000b
-
 
930
        jz      @f
-
 
931
 
-
 
932
        DEBUGF  1, "K : IDE CH1 PIO, because ATAPI drive present\n"
-
 
933
        jmp     .ch2_check
-
 
934
@@:
-
 
935
        mov     dx, [IDE_BAR1_val] ;0x3F4
-
 
936
        add     dx, 2 ;0x3F6
-
 
937
        out     dx, al
-
 
938
        DEBUGF  1, "K : IDE CH1 DMA enabled\n"
-
 
939
.ch2_check:
-
 
940
        test    ah, 1010b
-
 
941
        jz      @f
-
 
942
 
-
 
943
        DEBUGF  1, "K : IDE CH2 PIO, because ATAPI drive present\n"
-
 
944
        jmp     .end_set_interrupts
-
 
945
@@:
-
 
946
        mov     dx, [IDE_BAR3_val] ;0x374
-
 
947
        add     dx, 2 ;0x376
-
 
948
        out     dx, al
-
 
949
        DEBUGF  1, "K : IDE CH2 DMA enabled\n"
-
 
950
;--------------------------------------
-
 
951
.end_set_interrupts:
-
 
952
;-----------------------------------------------------------------------------
-
 
953
        cmp     [dma_hdd], 0
-
 
954
        je      .print_pio
-
 
955
.print_dma:
-
 
956
        DEBUGF  1, "K : IDE DMA mode\n"
-
 
957
        jmp     .continue
Line -... Line 958...
-
 
958
 
-
 
959
.print_pio:
-
 
960
        DEBUGF  1, "K : IDE PIO mode\n"
-
 
961
.continue:
-
 
962
;-----------------------------------------------------------------------------
-
 
963
; END of initialisation IDE ATA code
817
 
964
;-----------------------------------------------------------------------------
818
        mov     esi, boot_init_sys
965
        mov     esi, boot_init_sys
819
        call    boot_log
966
        call    boot_log
Line 820... Line 967...
820
        call    Parser_params
967
        call    Parser_params
Line 825... Line 972...
825
 
972
 
826
;!!!!!!!!!!!!!!!!!!!!!!!
973
;!!!!!!!!!!!!!!!!!!!!!!!
827
include 'boot/rdload.inc'
974
include 'boot/rdload.inc'
828
;!!!!!!!!!!!!!!!!!!!!!!!
975
;!!!!!!!!!!!!!!!!!!!!!!!
829
end if
-
 
Line 830... Line 976...
830
;    mov    [dma_hdd],1
976
end if
831
 
977
 
832
if 0
978
if 0
833
        mov     ax, [OS_BASE+0x10000+bx_from_load]
979
        mov     ax, [OS_BASE+0x10000+bx_from_load]
Line 879... Line 1025...
879
;        mov     esi, boot_devices
1025
;        mov     esi, boot_devices
880
;        call    boot_log
1026
;        call    boot_log
Line 881... Line 1027...
881
 
1027
 
882
        mov     [pci_access_enabled], 1
1028
        mov     [pci_access_enabled], 1
883
        call    pci_enum
-
 
884
;-----------------------------------------------------------------------------
-
 
885
        mov     dx, [IDEContrRegsBaseAddr]
-
 
886
; test whether it is our interrupt?
-
 
887
        add     dx, 2
-
 
888
        in      al, dx
-
 
889
        test    al, 100b
-
 
890
        jz      @f
-
 
891
; clear Bus Master IDE Status register
-
 
892
; clear Interrupt bit
-
 
893
        out     dx, al
1029
        call    pci_enum
894
@@:
-
 
895
        add     dx, 8
-
 
896
; test whether it is our interrupt?
-
 
897
        in      al, dx
-
 
898
        test    al, 100b
-
 
899
        jz      @f
-
 
900
; clear Bus Master IDE Status register
-
 
901
; clear Interrupt bit
-
 
902
        out     dx, al
-
 
903
@@:
-
 
904
; read status register and remove the interrupt request
-
 
905
        mov     dx, [IDE_BAR0_val] ;0x1F0
-
 
906
        add     dx, 0x7 ;0x1F7
-
 
907
        in      al, dx
-
 
908
        mov     dx, [IDE_BAR2_val] ;0x170
-
 
909
        add     dx, 0x7 ;0x177
-
 
910
        in      al, dx
-
 
911
;-----------------------------------------------------------------------------
1030
 
Line 912... Line 1031...
912
include "detect/vortex86.inc"                     ; Vortex86 SoC detection code
1031
include "detect/vortex86.inc"                     ; Vortex86 SoC detection code
Line 913... Line 1032...
913
 
1032
 
Line 1124... Line 1243...
1124
        mov     dx, debug_com_base+2
1243
        mov     dx, debug_com_base+2
1125
        mov     al, 0x7 + 1 shl 5
1244
        mov     al, 0x7 + 1 shl 5
1126
        out     dx, al
1245
        out     dx, al
Line 1127... Line 1246...
1127
 
1246
 
1128
end if
-
 
1129
 
-
 
1130
        mov     eax, [version_inf.rev]
-
 
1131
        DEBUGF  1, "K : kernel SVN r%d\n", eax
-
 
1132
 
-
 
1133
        mov     eax, [cpu_count]
-
 
1134
        test    eax, eax
-
 
1135
        jnz     @F
-
 
1136
        mov     al, 1                             ; at least one CPU
-
 
1137
@@:
-
 
1138
        DEBUGF  1, "K : %d CPU detected\n", eax
-
 
1139
 
-
 
1140
        DEBUGF  1, "K : BAR0 %x \n", [IDE_BAR0_val]:4
-
 
1141
        DEBUGF  1, "K : BAR1 %x \n", [IDE_BAR1_val]:4
-
 
1142
        DEBUGF  1, "K : BAR2 %x \n", [IDE_BAR2_val]:4
-
 
1143
        DEBUGF  1, "K : BAR3 %x \n", [IDE_BAR3_val]:4
-
 
1144
        DEBUGF  1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4
-
 
1145
        DEBUGF  1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4
-
 
1146
        DEBUGF  1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4
-
 
1147
 
1247
end if
Line 1148... Line 1248...
1148
; START MULTITASKING
1248
; START MULTITASKING
1149
 
1249
 
1150
; A 'All set - press ESC to start' messages if need
1250
; A 'All set - press ESC to start' messages if need
Line 1155... Line 1255...
1155
        in      al, 0x60        ; wait for ESC key press
1255
        in      al, 0x60        ; wait for ESC key press
1156
        cmp     al, 129
1256
        cmp     al, 129
1157
        jne     .bll1
1257
        jne     .bll1
1158
end if
1258
end if
Line 1159... Line -...
1159
 
-
 
1160
        push    eax edx
-
 
1161
        mov     dx, [IDEContrRegsBaseAddr]
-
 
1162
        xor     eax, eax
-
 
1163
        add     dx, 2
-
 
1164
        in      al, dx
-
 
1165
        DEBUGF  1, "K : Primary Bus Master IDE Status Register %x\n", eax
-
 
1166
 
-
 
1167
        add     dx, 8
-
 
1168
        in      al, dx
-
 
1169
        DEBUGF  1, "K : Secondary Bus Master IDE Status Register %x\n", eax
-
 
1170
        pop     edx eax
-
 
1171
 
-
 
1172
        cmp     [IDEContrRegsBaseAddr], 0
-
 
1173
        setnz   [dma_hdd]
-
 
1174
 
-
 
1175
        cmp     [IDEContrProgrammingInterface], 0
-
 
1176
        je      set_interrupts_for_IDE_controllers.continue
-
 
1177
;-----------------------------------------------------------------------------
-
 
1178
; set interrupts for IDE Controller
-
 
1179
;-----------------------------------------------------------------------------
-
 
1180
        mov     esi, boot_set_int_IDE
-
 
1181
        call    boot_log
-
 
1182
set_interrupts_for_IDE_controllers:
-
 
1183
        mov     ax, [IDEContrProgrammingInterface]
-
 
1184
        cmp     ax, 0x0180
-
 
1185
        je      .pata_ide
-
 
1186
 
-
 
1187
        cmp     ax, 0x018a
-
 
1188
        jne     .sata_ide
-
 
1189
;--------------------------------------
-
 
1190
.pata_ide:
-
 
1191
        cmp     [IDEContrRegsBaseAddr], 0
-
 
1192
        je      .end_set_interrupts
-
 
1193
 
-
 
1194
        stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
-
 
1195
        DEBUGF  1, "K : Set IDE IRQ14 return code %x\n", eax
-
 
1196
        stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
-
 
1197
        DEBUGF  1, "K : Set IDE IRQ15 return code %x\n", eax
-
 
1198
        jmp     .enable_IDE_interrupt
-
 
1199
;--------------------------------------
-
 
1200
.sata_ide:
-
 
1201
        cmp     ax, 0x0185
-
 
1202
        je      .sata_ide_1
-
 
1203
 
-
 
1204
        cmp     ax, 0x018f
-
 
1205
        jne     .end_set_interrupts
-
 
1206
;--------------------------------------
-
 
1207
.sata_ide_1:
-
 
1208
        cmp     [IDEContrRegsBaseAddr], 0
-
 
1209
        je      .end_set_interrupts
-
 
1210
 
-
 
1211
        mov     ax, [IDE_Interrupt]
-
 
1212
        movzx   eax, al
-
 
1213
        stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
-
 
1214
        DEBUGF  1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax
-
 
1215
;--------------------------------------
-
 
1216
.enable_IDE_interrupt:
-
 
1217
        mov     esi, boot_enabling_ide
-
 
1218
        call    boot_log
-
 
1219
; Enable interrupts in IDE controller for DMA
-
 
1220
        mov     al, 0
-
 
1221
        mov     ah, [DRIVE_DATA+1]
-
 
1222
        test    ah, 10100000b
-
 
1223
        jz      @f
-
 
1224
 
-
 
1225
        DEBUGF  1, "K : IDE CH1 PIO, because ATAPI drive present\n"
-
 
1226
        jmp     .ch2_check
-
 
1227
@@:
-
 
1228
        mov     dx, [IDE_BAR1_val] ;0x3F4
-
 
1229
        add     dx, 2 ;0x3F6
-
 
1230
        out     dx, al
-
 
1231
        DEBUGF  1, "K : IDE CH1 DMA enabled\n"
-
 
1232
.ch2_check:
-
 
1233
        test    ah, 1010b
-
 
1234
        jz      @f
-
 
1235
 
-
 
1236
        DEBUGF  1, "K : IDE CH2 PIO, because ATAPI drive present\n"
-
 
1237
        jmp     .end_set_interrupts
-
 
1238
@@:
-
 
1239
        mov     dx, [IDE_BAR3_val] ;0x374
-
 
1240
        add     dx, 2 ;0x376
-
 
1241
        out     dx, al
-
 
1242
        DEBUGF  1, "K : IDE CH2 DMA enabled\n"
-
 
1243
;--------------------------------------
-
 
1244
.end_set_interrupts:
-
 
1245
;-----------------------------------------------------------------------------
-
 
1246
        cmp     [dma_hdd], 0
-
 
1247
        je      .print_pio
-
 
1248
.print_dma:
-
 
1249
        DEBUGF  1, "K : IDE DMA mode\n"
-
 
1250
        jmp     .continue
-
 
1251
 
-
 
1252
.print_pio:
-
 
1253
        DEBUGF  1, "K : IDE PIO mode\n"
-
 
1254
.continue:
-
 
1255
 
1259
 
Line 1256... Line 1260...
1256
        mov     [timer_ticks_enable], 1         ; for cd driver
1260
        mov     [timer_ticks_enable], 1         ; for cd driver
1257
 
1261