Subversion Repositories Kolibri OS

Rev

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 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;
2
;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved.
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.
4
;; PROGRAMMING:
4
;; PROGRAMMING:
5
;; Ivan Poddubny
5
;; Ivan Poddubny
6
;; Marat Zakiyanov (Mario79)
6
;; Marat Zakiyanov (Mario79)
7
;; VaStaNi
7
;; VaStaNi
8
;; Trans
8
;; Trans
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: 3725 $
74
$Revision: 3908 $
Line 75... Line 75...
75
 
75
 
76
 
76
 
77
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
-
 
78
VESA_1_2_VIDEO  equ 0      ; enable vesa 1.2 bank switch functions
-
 
Line 79... Line 77...
79
 
77
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
80
; Enabling the next line will enable serial output console
78
VESA_1_2_VIDEO  equ 0      ; enable vesa 1.2 bank switch functions
81
;debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
79
 
82
; The following constant, if nonzero, duplicates debug output to the screen.
80
; Enabling the next line will enable serial output console
Line 83... Line 81...
83
debug_direct_print equ 0
81
;debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
-
 
82
 
-
 
83
include "proc32.inc"
-
 
84
include "kglobals.inc"
-
 
85
include "lang.inc"
-
 
86
include "encoding.inc"
-
 
87
 
-
 
88
include "const.inc"
-
 
89
 
84
 
90
iglobal
85
include "proc32.inc"
91
; The following variable, if equal to 1, duplicates debug output to the screen.
Line 86... Line -...
86
include "kglobals.inc"
-
 
87
include "lang.inc"
92
debug_direct_print db 0
88
include "encoding.inc"
93
; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no)
89
 
94
launcher_start db 1
90
include "const.inc"
95
endg
91
max_processes    equ   255
96
 
Line 263... Line 268...
263
        shr     ecx, 2
268
        shr     ecx, 2
264
        rep stosd
269
        rep stosd
Line 265... Line 270...
265
 
270
 
Line 266... Line -...
266
; SAVE & CLEAR 0-0xffff
-
 
267
 
-
 
268
        xor     esi, esi
-
 
269
        mov     edi, (BOOT_VAR-OS_BASE)
-
 
270
        mov     ecx, 0x10000 / 4
271
; SAVE & CLEAR 0-0xffff
271
        rep movsd
272
 
-
 
273
        mov     edi, 0x1000
-
 
274
        mov     ecx, 0x8000 / 4
-
 
275
        rep stosd
272
        mov     edi, 0x1000
276
        mov     edi, 0xa000
Line 273... Line 277...
273
        mov     ecx, 0xf000 / 4
277
        mov     ecx, 0x6000 / 4
274
        rep stosd
278
        rep stosd
Line 355... Line 359...
355
        call    mutex_init
359
        call    mutex_init
Line 356... Line 360...
356
 
360
 
357
        mov     ecx, application_table_mutex
361
        mov     ecx, application_table_mutex
Line -... Line 362...
-
 
362
        call    mutex_init
-
 
363
 
-
 
364
        mov     ecx, ide_mutex
-
 
365
        call    mutex_init
-
 
366
        mov     ecx, ide_channel1_mutex
-
 
367
        call    mutex_init
-
 
368
        mov     ecx, ide_channel2_mutex
358
        call    mutex_init
369
        call    mutex_init
-
 
370
;-----------------------------------------------------------------------------
-
 
371
; SAVE REAL MODE VARIABLES
359
 
372
;-----------------------------------------------------------------------------
-
 
373
save_variables_IDE_controller:
-
 
374
        xor     eax, eax
-
 
375
        mov     ax, [BOOT_VARS + BOOT_IDE_INTERR_16]
360
; SAVE REAL MODE VARIABLES
376
        mov     [IDE_Interrupt], ax
361
        xor     eax, eax
377
;--------------------------------------
-
 
378
        mov     ax, [BOOT_VARS + BOOT_IDE_PI_16]
362
        mov     ax, [BOOT_VAR + BOOT_IDE_PI_16]
379
        mov     [IDEContrProgrammingInterface], ax
363
        mov     [IDEContrProgrammingInterface], ax
380
;--------------------------------------
-
 
381
        mov     ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR]
364
        mov     ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR]
382
        mov     [IDEContrRegsBaseAddr], ax
365
        mov     [IDEContrRegsBaseAddr], ax
-
 
366
        mov     ax, [BOOT_VAR + BOOT_IDE_BAR0_16]
-
 
367
        mov     [IDE_BAR0_val], ax
383
;--------------------------------------
368
 
384
        mov     ax, [BOOT_VARS + BOOT_IDE_BAR0_16]
369
        cmp     ax, 0
-
 
370
        je      @f
385
        cmp     ax, 0
371
 
386
        je      @f
372
        cmp     ax, 1
387
        cmp     ax, 1
-
 
388
        jne     .no_PATA_BAR0
-
 
389
@@:
-
 
390
        mov     ax, 0x1F0
373
        je      @f
391
        jmp     @f
-
 
392
.no_PATA_BAR0:
374
 
393
        and     ax, 0xFFFC
375
        and     ax, 0xfff0
394
@@:
376
        mov     [StandardATABases], ax
395
        mov     [StandardATABases], ax
-
 
396
        mov     [hd_address_table], eax
-
 
397
        mov     [hd_address_table+8], eax
-
 
398
        mov     [IDE_BAR0_val], ax
-
 
399
;--------------------------------------
-
 
400
        mov     ax, [BOOT_VARS + BOOT_IDE_BAR1_16]
-
 
401
        cmp     ax, 0
-
 
402
        je      @f
-
 
403
        cmp     ax, 1
-
 
404
        jne     .no_PATA_BAR1
-
 
405
@@:
-
 
406
        mov     ax, 0x3F4
-
 
407
        jmp     @f
377
        mov     [hd_address_table], eax
408
.no_PATA_BAR1:
378
        mov     [hd_address_table+8], eax
-
 
379
@@:
409
        and     ax, 0xFFFC
-
 
410
@@:
380
        mov     ax, [BOOT_VAR + BOOT_IDE_BAR1_16]
411
        mov     [IDE_BAR1_val], ax
381
        mov     [IDE_BAR1_val], ax
-
 
382
        mov     ax, [BOOT_VAR + BOOT_IDE_BAR2_16]
-
 
383
        mov     [IDE_BAR2_val], ax
412
;--------------------------------------
384
 
413
        mov     ax, [BOOT_VARS + BOOT_IDE_BAR2_16]
385
        cmp     ax, 0
-
 
386
        je      @f
414
        cmp     ax, 0
387
 
415
        je      @f
388
        cmp     ax, 1
416
        cmp     ax, 1
-
 
417
        jne     .no_PATA_BAR2
-
 
418
@@:
-
 
419
        mov     ax, 0x170
389
        je      @f
420
        jmp     @f
-
 
421
.no_PATA_BAR2:
390
 
422
        and     ax, 0xFFFC
391
        and     ax, 0xfff0
423
@@:
392
        mov     [StandardATABases+2], ax
424
        mov     [StandardATABases+2], ax
-
 
425
        mov     [hd_address_table+16], eax
-
 
426
        mov     [hd_address_table+24], eax
-
 
427
        mov     [IDE_BAR2_val], ax
-
 
428
;--------------------------------------
-
 
429
        mov     ax, [BOOT_VARS + BOOT_IDE_BAR3_16]
-
 
430
        cmp     ax, 0
-
 
431
        je      @f
-
 
432
        cmp     ax, 1
-
 
433
        jne     .no_PATA_BAR3
-
 
434
@@:
-
 
435
        mov     ax, 0x374
-
 
436
        jmp     @f
393
        mov     [hd_address_table+16], eax
437
.no_PATA_BAR3:
394
        mov     [hd_address_table+24], eax
-
 
395
@@:
438
        and     ax, 0xFFFC
Line 396... Line 439...
396
        mov     ax, [BOOT_VAR + BOOT_IDE_BAR3_16]
439
@@:
Line 397... Line 440...
397
        mov     [IDE_BAR3_val], ax
440
        mov     [IDE_BAR3_val], ax
398
 
441
 
399
; --------------- APM ---------------------
442
; --------------- APM ---------------------
400
 
443
 
401
; init selectors
444
; init selectors
402
        mov     ebx, [BOOT_VAR+BOOT_APM_ENTRY]        ; offset of APM entry point
445
        mov     ebx, [BOOT_VARS+BOOT_APM_ENTRY]        ; offset of APM entry point
403
        movzx   eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of
446
        movzx   eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of
404
                                                      ; protected-mode 32-bit code segment
447
                                                                                ; protected-mode 32-bit code segment
Line 405... Line 448...
405
        movzx   ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of
448
        movzx   ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of
406
                                               ; protected-mode 16-bit code segment
449
                                                                                ; protected-mode 16-bit code segment
407
        movzx   edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of
450
        movzx   edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of
Line 423... Line 466...
423
        mov     [dword apm_data_16 + 4], dl
466
        mov     [dword apm_data_16 + 4], dl
Line 424... Line 467...
424
 
467
 
425
        mov     dword[apm_entry], ebx
468
        mov     dword[apm_entry], ebx
Line 426... Line 469...
426
        mov     word [apm_entry + 4], apm_code_32 - gdts
469
        mov     word [apm_entry + 4], apm_code_32 - gdts
427
 
470
 
428
        mov     eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags
471
        mov     eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags
429
        mov     [apm_vf], eax
472
        mov     [apm_vf], eax
430
; -----------------------------------------
473
; -----------------------------------------
431
        mov     al, [BOOT_VAR+BOOT_DMA]            ; DMA access
474
        mov     al, [BOOT_VARS+BOOT_DMA]            ; DMA access
432
        mov     [allow_dma_access], al
475
        mov     [allow_dma_access], al
433
        movzx   eax, byte [BOOT_VAR+BOOT_BPP]      ; bpp
476
        movzx   eax, byte [BOOT_VARS+BOOT_BPP]      ; bpp
434
        mov     [_display.bpp], eax
-
 
-
 
477
        mov     [_display.bpp], eax
-
 
478
        mov     [_display.vrefresh], 60
-
 
479
        mov     al, [BOOT_VARS+BOOT_DEBUG_PRINT]    ; If nonzero, duplicates debug output to the screen
-
 
480
        mov     [debug_direct_print], al
435
        mov     [_display.vrefresh], 60
481
        mov     al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded?
436
 
482
        mov     [launcher_start], al
437
        movzx   eax, word [BOOT_VAR+BOOT_X_RES]; X max
483
        movzx   eax, word [BOOT_VARS+BOOT_X_RES]; X max
438
        mov     [_display.width], eax
484
        mov     [_display.width], eax
439
        mov     [display_width_standard], eax
485
        mov     [display_width_standard], eax
440
        dec     eax
486
        dec     eax
441
        mov     [Screen_Max_X], eax
487
        mov     [Screen_Max_X], eax
442
        mov     [screen_workarea.right], eax
488
        mov     [screen_workarea.right], eax
443
        movzx   eax, word [BOOT_VAR+BOOT_Y_RES]; Y max
489
        movzx   eax, word [BOOT_VARS+BOOT_Y_RES]; Y max
444
        mov     [_display.height], eax
490
        mov     [_display.height], eax
445
        mov     [display_height_standard], eax
491
        mov     [display_height_standard], eax
446
        dec     eax
492
        dec     eax
447
        mov     [Screen_Max_Y], eax
493
        mov     [Screen_Max_Y], eax
448
        mov     [screen_workarea.bottom], eax
494
        mov     [screen_workarea.bottom], eax
449
        movzx   eax, word [BOOT_VAR+BOOT_VESA_MODE] ; screen mode
495
        movzx   eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode
450
        mov     dword [SCR_MODE], eax
496
        mov     dword [SCR_MODE], eax
451
;        mov     eax, [BOOT_VAR+0x9014]    ; Vesa 1.2 bnk sw add
497
;        mov     eax, [BOOT_VAR+0x9014]             ; Vesa 1.2 bnk sw add
452
;        mov     [BANK_SWITCH], eax
498
;        mov     [BANK_SWITCH], eax
453
        mov     eax, 640 *4                         ; Bytes PerScanLine
499
        mov     eax, 640 *4                         ; Bytes PerScanLine
454
        cmp     [SCR_MODE], word 0x13       ; 320x200
500
        cmp     [SCR_MODE], word 0x13               ; 320x200
455
        je      @f
501
        je      @f
456
        cmp     [SCR_MODE], word 0x12       ; VGA 640x480
502
        cmp     [SCR_MODE], word 0x12               ; VGA 640x480
457
        je      @f
503
        je      @f
458
        movzx   eax, word[BOOT_VAR+BOOT_PITCH]      ; for other modes
504
        movzx   eax, word[BOOT_VARS+BOOT_PITCH]      ; for other modes
459
@@:
505
@@:
460
        mov     [_display.pitch], eax
506
        mov     [_display.pitch], eax
461
        mov     eax, [_display.width]
507
        mov     eax, [_display.width]
Line 466... Line 512...
466
; for Qemu or non standart video cards
512
; for Qemu or non standart video cards
467
; Unfortunately [BytesPerScanLine] does not always
513
; Unfortunately [BytesPerScanLine] does not always
468
;                             equal to [_display.width] * [ScreenBPP] / 8
514
;                             equal to [_display.width] * [ScreenBPP] / 8
469
        call    calculate_fast_getting_offset_for_LFB
515
        call    calculate_fast_getting_offset_for_LFB
Line 470... Line 516...
470
 
516
 
471
        mov     esi, BOOT_VAR+0x9080
517
        mov     esi, BOOT_VARS+0x9080
472
        movzx   ecx, byte [esi-1]
518
        movzx   ecx, byte [esi-1]
473
        mov     [NumBiosDisks], ecx
519
        mov     [NumBiosDisks], ecx
474
        mov     edi, BiosDisksData
520
        mov     edi, BiosDisksData
Line 475... Line 521...
475
        rep movsd
521
        rep movsd
Line 476... Line 522...
476
 
522
 
477
; GRAPHICS ADDRESSES
523
; GRAPHICS ADDRESSES
Line 478... Line 524...
478
 
524
 
479
        mov     eax, [BOOT_VAR+BOOT_LFB]
525
        mov     eax, [BOOT_VARS+BOOT_LFB]
480
        mov     [LFBAddress], eax
526
        mov     [LFBAddress], eax
Line 707... Line 753...
707
; Try to Initialize APIC
753
; Try to Initialize APIC
708
        call    APIC_init
754
        call    APIC_init
Line 709... Line 755...
709
 
755
 
710
        mov     esi, boot_enableirq
756
        mov     esi, boot_enableirq
711
        call    boot_log
757
        call    boot_log
712
; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15)
758
; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13)
713
; they are used: when partitions are scanned, hd_read relies on timer
759
; they are used: when partitions are scanned, hd_read relies on timer
714
        call    unmask_timer
760
        call    unmask_timer
715
        stdcall enable_irq, 2               ; @#$%! PIC
-
 
716
        stdcall enable_irq, 6               ; FDD
761
        stdcall enable_irq, 2               ; @#$%! PIC
717
        stdcall enable_irq, 13              ; co-processor
-
 
718
        stdcall enable_irq, 14
-
 
Line -... Line 762...
-
 
762
        stdcall enable_irq, 13              ; co-processor
-
 
763
 
-
 
764
        cmp     [IDEContrProgrammingInterface], 0
719
        stdcall enable_irq, 15
765
        je      @f
720
 
766
 
-
 
767
        mov     esi, boot_disabling_ide
-
 
768
        call    boot_log
-
 
769
;--------------------------------------
-
 
770
; Disable IDE interrupts, because the search
-
 
771
; for IDE partitions is in the PIO mode.
721
        mov     esi, boot_enablint_ide
772
;--------------------------------------
722
        call    boot_log
773
.disable_IDE_interrupt:
-
 
774
; Disable interrupts in IDE controller for PIO
723
; Enable interrupts in IDE controller
775
        mov     al, 2
724
        mov     al, 0
776
        mov     dx, [IDE_BAR1_val] ;0x3F4
-
 
777
        add     dx, 2 ;0x3F6
725
        mov     dx, 0x3F6
778
        out     dx, al
726
        out     dx, al
779
        mov     dx, [IDE_BAR3_val] ;0x374
727
        mov     dl, 0x76
780
        add     dx, 2 ;0x376
-
 
781
        out     dx, al
728
        out     dx, al
782
@@:
729
 
783
;-----------------------------------------------------------------------------
730
;!!!!!!!!!!!!!!!!!!!!!!!!!!
784
;!!!!!!!!!!!!!!!!!!!!!!!!!!
731
;        mov     esi, boot_detectdisks
785
;        mov     esi, boot_detectdisks
732
;        call    boot_log
786
;        call    boot_log
Line 917... Line 971...
917
                [SLOT_BASE+256+APPDATA.io_map], PG_MAP
971
                [SLOT_BASE+256+APPDATA.io_map], PG_MAP
918
        stdcall map_page, tss._io_map_1, \
972
        stdcall map_page, tss._io_map_1, \
919
                [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
973
                [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
Line 920... Line 974...
920
 
974
 
921
; LOAD FIRST APPLICATION
-
 
922
        cli
-
 
923
 
-
 
924
;        cmp   byte [BOOT_VAR+0x9030],1
-
 
925
;        jne   no_load_vrr_m
-
 
926
 
-
 
927
;        mov     ebp, vrr_m
-
 
928
;        call    fs_execute_from_sysdir
-
 
929
;
975
; LOAD FIRST APPLICATION
930
;;        cmp   eax,2                  ; if vrr_m app found (PID=2)
-
 
931
;       sub   eax,2
976
        cmp     byte [launcher_start], 1        ; Check if starting LAUNCHER is selected on blue screen (1 = yes)
932
;        jz    first_app_found
-
 
933
;
-
 
Line -... Line 977...
-
 
977
        jnz     first_app_found
934
;no_load_vrr_m:
978
 
935
 
979
        cli
936
        mov     ebp, firstapp
-
 
937
        call    fs_execute_from_sysdir
-
 
938
 
980
        mov     ebp, firstapp
939
;        cmp   eax,2                  ; continue if a process has been loaded
981
        call    fs_execute_from_sysdir
Line 940... Line 982...
940
        test    eax, eax
982
        test    eax, eax
941
        jns     first_app_found
983
        jns     first_app_found
Line 987... Line 1029...
987
;        call  kb_read
1029
;        call  kb_read
988
     ;// mike.dld [
1030
     ;// mike.dld [
989
        call    set_lights
1031
        call    set_lights
990
     ;// mike.dld ]
1032
     ;// mike.dld ]
991
        stdcall attach_int_handler, 1, irq1, 0
1033
        stdcall attach_int_handler, 1, irq1, 0
-
 
1034
        DEBUGF  1, "K : IRQ1 error code %x\n", eax
992
.no_keyboard:
1035
.no_keyboard:
Line 993... Line 1036...
993
 
1036
 
Line 994... Line 1037...
994
; SET MOUSE
1037
; SET MOUSE
Line 1054... Line 1097...
1054
        DEBUGF  1, "K : BAR1 %x \n", [IDE_BAR1_val]:4
1097
        DEBUGF  1, "K : BAR1 %x \n", [IDE_BAR1_val]:4
1055
        DEBUGF  1, "K : BAR2 %x \n", [IDE_BAR2_val]:4
1098
        DEBUGF  1, "K : BAR2 %x \n", [IDE_BAR2_val]:4
1056
        DEBUGF  1, "K : BAR3 %x \n", [IDE_BAR3_val]:4
1099
        DEBUGF  1, "K : BAR3 %x \n", [IDE_BAR3_val]:4
1057
        DEBUGF  1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4
1100
        DEBUGF  1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4
1058
        DEBUGF  1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4
1101
        DEBUGF  1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4
-
 
1102
        DEBUGF  1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4
1059
; START MULTITASKING
1103
; START MULTITASKING
Line 1060... Line 1104...
1060
 
1104
 
1061
; A 'All set - press ESC to start' messages if need
1105
; A 'All set - press ESC to start' messages if need
1062
if preboot_blogesc
1106
if preboot_blogesc
Line 1066... Line 1110...
1066
        in      al, 0x60        ; wait for ESC key press
1110
        in      al, 0x60        ; wait for ESC key press
1067
        cmp     al, 129
1111
        cmp     al, 129
1068
        jne     .bll1
1112
        jne     .bll1
1069
end if
1113
end if
Line -... Line 1114...
-
 
1114
 
-
 
1115
        push    eax edx
-
 
1116
        mov     dx, [IDEContrRegsBaseAddr]
-
 
1117
        xor     eax, eax
-
 
1118
        add     dx, 2
-
 
1119
        in      al, dx
-
 
1120
        DEBUGF  1, "K : Primary Bus Master IDE Status Register %x\n", eax
-
 
1121
 
-
 
1122
        add     dx, 8
-
 
1123
        in      al, dx
-
 
1124
        DEBUGF  1, "K : Secondary Bus Master IDE Status Register %x\n", eax
-
 
1125
        pop     edx eax
1070
 
1126
 
1071
        cmp     [IDEContrRegsBaseAddr], 0
1127
        cmp     [IDEContrRegsBaseAddr], 0
Line -... Line 1128...
-
 
1128
        setnz   [dma_hdd]
-
 
1129
 
-
 
1130
        cmp     [IDEContrProgrammingInterface], 0
-
 
1131
        je      set_interrupts_for_IDE_controllers.continue
-
 
1132
 
-
 
1133
        mov     ax, [IDE_Interrupt]
-
 
1134
        cmp     al, 0xff
-
 
1135
        jne     @f
-
 
1136
 
-
 
1137
        mov     [dma_hdd], 0
-
 
1138
        jmp     set_interrupts_for_IDE_controllers.end_set_interrupts
-
 
1139
@@:
-
 
1140
;-----------------------------------------------------------------------------
-
 
1141
; set interrupts for IDE Controller
-
 
1142
;-----------------------------------------------------------------------------
-
 
1143
        mov     esi, boot_set_int_IDE
-
 
1144
        call    boot_log
-
 
1145
set_interrupts_for_IDE_controllers:
-
 
1146
        mov     ax, [IDEContrProgrammingInterface]
-
 
1147
        cmp     ax, 0x0180
-
 
1148
        je      .pata_ide
-
 
1149
 
-
 
1150
        cmp     ax, 0x018a
-
 
1151
        jne     .sata_ide
-
 
1152
;--------------------------------------
-
 
1153
.pata_ide:
-
 
1154
        cmp     [IDEContrRegsBaseAddr], 0
-
 
1155
        je      .end_set_interrupts
-
 
1156
 
-
 
1157
        stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
-
 
1158
        DEBUGF  1, "K : Set IDE IRQ14 return code %x\n", eax
-
 
1159
        stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
-
 
1160
        DEBUGF  1, "K : Set IDE IRQ15 return code %x\n", eax
-
 
1161
        jmp     .enable_IDE_interrupt
-
 
1162
;--------------------------------------
-
 
1163
.sata_ide:
-
 
1164
        cmp     ax, 0x0185
-
 
1165
        je      .sata_ide_1
-
 
1166
 
-
 
1167
        cmp     ax, 0x018f
-
 
1168
        jne     .end_set_interrupts
-
 
1169
;--------------------------------------
-
 
1170
.sata_ide_1:
-
 
1171
        cmp     [IDEContrRegsBaseAddr], 0
-
 
1172
        je      .end_set_interrupts
-
 
1173
 
-
 
1174
        mov     ax, [IDE_Interrupt]
-
 
1175
        movzx   eax, al
-
 
1176
        stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
-
 
1177
        DEBUGF  1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax
-
 
1178
;--------------------------------------
-
 
1179
.enable_IDE_interrupt:
-
 
1180
        mov     esi, boot_enabling_ide
-
 
1181
        call    boot_log
-
 
1182
; Enable interrupts in IDE controller for DMA
-
 
1183
        mov     al, 0
-
 
1184
        mov     dx, [IDE_BAR1_val] ;0x3F4
-
 
1185
        add     dx, 2 ;0x3F6
-
 
1186
        out     dx, al
-
 
1187
        mov     dx, [IDE_BAR3_val] ;0x374
-
 
1188
        add     dx, 2 ;0x376
-
 
1189
        out     dx, al
-
 
1190
;--------------------------------------
1072
        setnz   [dma_hdd]
1191
.end_set_interrupts:
1073
 
1192
;-----------------------------------------------------------------------------
1074
        cmp     [dma_hdd], 0
1193
        cmp     [dma_hdd], 0
1075
        je      .print_pio
1194
        je      .print_pio
1076
.print_dma:
1195
.print_dma:
Line 1194... Line 1313...
1194
proc osloop_has_work?
1313
proc osloop_has_work?
1195
        cmp     [osloop_nonperiodic_work], 0
1314
        cmp     [osloop_nonperiodic_work], 0
1196
        jnz     .yes
1315
        jnz     .yes
1197
        call    stack_handler_has_work?
1316
        call    stack_handler_has_work?
1198
        jnz     .yes
1317
        jnz     .yes
1199
        call    check_fdd_motor_status_has_work?
1318
;        call    check_fdd_motor_status_has_work?
1200
        jnz     .yes
1319
;        jnz     .yes
1201
        call    check_ATAPI_device_event_has_work?
1320
        call    check_ATAPI_device_event_has_work?
1202
        jnz     .yes
1321
        jnz     .yes
1203
        call    check_lights_state_has_work?
1322
        call    check_lights_state_has_work?
1204
        jnz     .yes
1323
        jnz     .yes
1205
        call    check_timers_has_work?
1324
        call    check_timers_has_work?
Line 1286... Line 1405...
1286
.fl60:
1405
.fl60:
1287
        in      al, 0x60
1406
        in      al, 0x60
1288
        loop    .fl60
1407
        loop    .fl60
1289
        push    eax
1408
        push    eax
Line 1290... Line 1409...
1290
 
1409
 
1291
        mov     ax, [BOOT_VAR+BOOT_Y_RES]
1410
        mov     ax, [BOOT_VARS+BOOT_Y_RES]
1292
        shr     ax, 1
1411
        shr     ax, 1
1293
        shl     eax, 16
1412
        shl     eax, 16
1294
        mov     ax, [BOOT_VAR+BOOT_X_RES]
1413
        mov     ax, [BOOT_VARS+BOOT_X_RES]
1295
        shr     ax, 1
1414
        shr     ax, 1
1296
        mov     [MOUSE_X], eax
1415
        mov     [MOUSE_X], eax
Line 1297... Line 1416...
1297
        call    wakeup_osloop
1416
        call    wakeup_osloop
Line 1673... Line 1792...
1673
        jnz     nsyse5
1792
        jnz     nsyse5
1674
        mov     [syslang], ecx
1793
        mov     [syslang], ecx
1675
        ret
1794
        ret
1676
   nsyse5:
1795
   nsyse5:
Line 1677... Line 1796...
1677
 
1796
 
1678
        sub     ebx, 2          ; HD BASE
1797
        sub     ebx, 2          ; HD BASE - obsolete
Line 1679... Line -...
1679
        jnz     nsyse7
-
 
1680
 
-
 
1681
        test    ecx, ecx
-
 
1682
        jz      nosethd
-
 
1683
 
-
 
1684
        cmp     ecx, 4
-
 
1685
        ja      nosethd
-
 
1686
        mov     [hd_base], cl
-
 
1687
 
-
 
1688
        cmp     ecx, 1
-
 
1689
        jnz     noprmahd
-
 
1690
        mov     eax, [hd_address_table]
-
 
1691
        mov     [hdbase], eax    ;0x1f0
-
 
1692
        and     dword [hdid], 0x0
-
 
1693
        mov     dword [hdpos], ecx
-
 
1694
;     call set_FAT32_variables
-
 
1695
   noprmahd:
-
 
1696
 
-
 
1697
        cmp     ecx, 2
-
 
1698
        jnz     noprslhd
-
 
1699
        mov     eax, [hd_address_table]
-
 
1700
        mov     [hdbase], eax  ;0x1f0
-
 
1701
        mov     [hdid], 0x10
-
 
1702
        mov     dword [hdpos], ecx
-
 
1703
;     call set_FAT32_variables
-
 
1704
   noprslhd:
-
 
1705
 
-
 
1706
        cmp     ecx, 3
-
 
1707
        jnz     nosemahd
-
 
1708
        mov     eax, [hd_address_table+16]
-
 
1709
        mov     [hdbase], eax	;0x170
-
 
1710
        and     dword [hdid], 0x0
-
 
1711
        mov     dword [hdpos], ecx
-
 
1712
;     call set_FAT32_variables
-
 
1713
   nosemahd:
-
 
1714
 
-
 
1715
        cmp     ecx, 4
-
 
1716
        jnz     noseslhd
-
 
1717
	mov	eax,[hd_address_table+16]
-
 
1718
        mov     [hdbase], eax	;0x170
-
 
1719
        mov     [hdid], 0x10
-
 
1720
        mov     dword [hdpos], ecx
-
 
1721
;     call set_FAT32_variables
-
 
1722
   noseslhd:
-
 
1723
        call    reserve_hd1
-
 
1724
        call    reserve_hd_channel
-
 
1725
        call    free_hd_channel
1798
        jnz     nsyse7
1726
        and     dword [hd1_status], 0     ; free
1799
 
Line 1727... Line -...
1727
   nosethd:
-
 
1728
        ret
-
 
1729
 
-
 
1730
iglobal
-
 
1731
hd_base db 0
1800
   nosethd:
Line 1732... Line 1801...
1732
endg
1801
        ret
1733
 
1802
 
1734
nsyse7:
1803
nsyse7:
1735
 
-
 
1736
;     cmp  eax,8                      ; HD PARTITION
-
 
1737
        dec     ebx
-
 
1738
        jnz     nsyse8
-
 
1739
        mov     [fat32part], ecx
-
 
1740
;     call set_FAT32_variables
-
 
1741
        call    reserve_hd1
-
 
1742
        call    reserve_hd_channel
-
 
1743
        call    free_hd_channel
-
 
1744
;       pusha
1804
 
Line 1745... Line 1805...
1745
        call    choice_necessity_partition_1
1805
;     cmp  eax,8                      ; HD PARTITION - obsolete
1746
;       popa
1806
        dec     ebx
1747
        and     dword [hd1_status], 0   ; free
1807
        jnz     nsyse8
Line 1843... Line 1903...
1843
        ret
1903
        ret
1844
ngsyse5:
1904
ngsyse5:
1845
;     cmp  eax,7
1905
;     cmp  eax,7
1846
        sub     ebx, 2
1906
        sub     ebx, 2
1847
        jnz     ngsyse7
1907
        jnz     ngsyse7
1848
        movzx   eax, [hd_base]
1908
        xor     eax, eax
1849
        mov     [esp+32], eax
1909
        mov     [esp+32], eax
1850
        ret
1910
        ret
1851
ngsyse7:
1911
ngsyse7:
1852
;     cmp  eax,8
1912
;     cmp  eax,8
1853
        dec     ebx
1913
        dec     ebx
Line 2176... Line 2236...
2176
sysfn_shutdown:          ; 18.9 = system shutdown
2236
sysfn_shutdown:          ; 18.9 = system shutdown
2177
        cmp     ecx, 1
2237
        cmp     ecx, 1
2178
        jl      exit_for_anyone
2238
        jl      exit_for_anyone
2179
        cmp     ecx, 4
2239
        cmp     ecx, 4
2180
        jg      exit_for_anyone
2240
        jg      exit_for_anyone
2181
        mov     [BOOT_VAR+0x9030], cl
2241
        mov     [BOOT_VARS+0x9030], cl
Line 2182... Line 2242...
2182
 
2242
 
2183
        mov     eax, [TASK_COUNT]
2243
        mov     eax, [TASK_COUNT]
2184
        mov     [SYS_SHUTDOWN], al
2244
        mov     [SYS_SHUTDOWN], al
2185
        mov     [shutdown_processes], eax
2245
        mov     [shutdown_processes], eax
Line 4831... Line 4891...
4831
        pop     ax dx
4891
        pop     ax dx
Line 4832... Line 4892...
4832
 
4892
 
Line 4833... Line 4893...
4833
end if
4893
end if
4834
 
4894
 
-
 
4895
        mov     [msg_board_data+ecx], bl
-
 
4896
; // if debug_direct_print == 1
4835
        mov     [msg_board_data+ecx], bl
4897
        cmp     byte [debug_direct_print], 1
4836
if debug_direct_print
4898
        jnz     @f
4837
        pusha
4899
        pusha
4838
iglobal
4900
iglobal
4839
msg_board_pos   dd      234*65536+10
4901
msg_board_pos   dd      (42*6)*65536+10 ; for printing debug output on the screen
4840
endg
4902
endg
4841
        lea     edx, [msg_board_data+ecx]
4903
        lea     edx, [msg_board_data+ecx]
4842
        mov     ecx, 0x40FFFFFF
4904
        mov     ecx, 0x40FFFFFF
Line 4846... Line 4908...
4846
        call    dtext
4908
        call    dtext
4847
        popa
4909
        popa
4848
        add     word [msg_board_pos+2], 6
4910
        add     word [msg_board_pos+2], 6
4849
        cmp     bl, 10
4911
        cmp     bl, 10
4850
        jnz     @f
4912
        jnz     @f
4851
        mov     word [msg_board_pos+2], 234
4913
        mov     word [msg_board_pos+2], (42*6)
4852
        add     word [msg_board_pos], 10
4914
        add     word [msg_board_pos], 10
4853
        mov     ax, word [Screen_Max_Y]
4915
        mov     ax, word [Screen_Max_Y]
4854
        cmp     word [msg_board_pos], ax
4916
        cmp     word [msg_board_pos], ax
4855
        jbe     @f
4917
        jbe     @f
4856
        mov     word [msg_board_pos], 10
4918
        mov     word [msg_board_pos], 10
4857
@@:
4919
@@:
4858
end if
4920
; // end if
-
 
4921
 
4859
if 0
4922
if 0
4860
        pusha
4923
        pusha
4861
        mov     al, bl
4924
        mov     al, bl
4862
        mov     edx, 402h
4925
        mov     edx, 402h
4863
        out     dx, al
4926
        out     dx, al
Line 5630... Line 5693...
5630
        ret
5693
        ret
Line 5631... Line 5694...
5631
 
5694
 
5632
align 4
5695
align 4
Line 5633... Line 5696...
5633
system_shutdown:          ; shut down the system
5696
system_shutdown:          ; shut down the system
5634
 
5697
 
5635
        cmp     byte [BOOT_VAR+0x9030], 1
5698
        cmp     byte [BOOT_VARS+0x9030], 1
5636
        jne     @F
5699
        jne     @F
5637
        ret
5700
        ret
5638
@@:
5701
@@:
Line 5655... Line 5718...
5655
        mov     edi, OS_BASE+0x40000
5718
        mov     edi, OS_BASE+0x40000
5656
        mov     ecx, 1000
5719
        mov     ecx, 1000
5657
        rep movsb
5720
        rep movsb
5658
end if
5721
end if
Line 5659... Line 5722...
5659
 
5722
 
5660
        mov     esi, BOOT_VAR    ; restore 0x0 - 0xffff
5723
;        mov     esi, BOOT_VAR    ; restore 0x0 - 0xffff
5661
        mov     edi, OS_BASE
5724
;        mov     edi, OS_BASE
5662
        mov     ecx, 0x10000/4
5725
;        mov     ecx, 0x10000/4
5663
        cld
5726
;        cld
Line 5664... Line 5727...
5664
        rep movsd
5727
;        rep movsd
Line 5665... Line 5728...
5665
 
5728