Subversion Repositories Kolibri OS

Rev

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

Rev 4993 Rev 5116
Line 72... Line 72...
72
include 'struct.inc'
72
include 'struct.inc'
Line 73... Line 73...
73
 
73
 
Line 74... Line -...
74
$Revision: 4381 $
-
 
75
 
-
 
76
 
74
$Revision: 4381 $
77
USE_FIX_FOR_INVALID_MS_VIRTUAL_PC_2007 equ 0
75
 
Line 78... Line 76...
78
 
76
 
79
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
77
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
Line 281... Line 279...
281
 
279
 
282
use16
280
use16
283
org $-0x10000
281
org $-0x10000
284
include "boot/shutdown.inc" ; shutdown or restart
282
include "boot/shutdown.inc" ; shutdown or restart
-
 
283
org $+0x10000
-
 
284
 
-
 
285
ap_init16:
-
 
286
        cli
-
 
287
        lgdt    [cs:gdts_ap-ap_init16]
-
 
288
        mov     eax, [cs:cr3_ap-ap_init16]
-
 
289
        mov     cr3, eax
-
 
290
        mov     eax, [cs:cr4_ap-ap_init16]
-
 
291
        mov     cr4, eax
-
 
292
        mov     eax, CR0_PE+CR0_PG+CR0_WP
-
 
293
        mov     cr0, eax
-
 
294
        jmp     pword os_code:ap_init_high
-
 
295
align 16
-
 
296
gdts_ap:
-
 
297
        dw     gdte-gdts-1
-
 
298
        dd     gdts
-
 
299
        dw     0
-
 
300
cr3_ap  dd     ?
-
 
301
cr4_ap  dd     ?
285
org $+0x10000
302
ap_init16_size = $ - ap_init16
Line 286... Line 303...
286
use32
303
use32
287
 
304
 
288
__DEBUG__ fix 1
305
__DEBUG__ fix 1
Line 666... Line 683...
666
        mov     dword [CURRENT_TASK], 2
683
        mov     dword [CURRENT_TASK], 2
667
        mov     dword [TASK_COUNT], 2
684
        mov     dword [TASK_COUNT], 2
668
        mov     dword [current_slot], SLOT_BASE + 256*2
685
        mov     dword [current_slot], SLOT_BASE + 256*2
669
        mov     dword [TASK_BASE], CURRENT_TASK + 32*2
686
        mov     dword [TASK_BASE], CURRENT_TASK + 32*2
Line -... Line 687...
-
 
687
 
-
 
688
; Move other CPUs to deep sleep, if it is useful
-
 
689
uglobal
-
 
690
use_mwait_for_idle db 0
-
 
691
endg
-
 
692
        cmp     [cpu_vendor+8], 'ntel'
-
 
693
        jnz     .no_wake_cpus
-
 
694
        bt      [cpu_caps+4], CAPS_MONITOR-32
-
 
695
        jnc     .no_wake_cpus
-
 
696
        dbgstr 'using mwait for idle loop'
-
 
697
        inc     [use_mwait_for_idle]
-
 
698
        mov     ebx, [cpu_count]
-
 
699
        cmp     ebx, 1
-
 
700
        jbe     .no_wake_cpus
-
 
701
        call    create_trampoline_pgmap
-
 
702
        mov     [cr3_ap+OS_BASE], eax
-
 
703
        mov     eax, cr4
-
 
704
        mov     [cr4_ap+OS_BASE], eax
-
 
705
        mov     esi, OS_BASE + ap_init16
-
 
706
        mov     edi, OS_BASE + 8000h
-
 
707
        mov     ecx, (ap_init16_size + 3) / 4
-
 
708
        rep movsd
-
 
709
        stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE
-
 
710
        mov     [LAPIC_BASE], eax
-
 
711
        lea     edi, [eax+300h]
-
 
712
        mov     esi, smpt+4
-
 
713
        dec     ebx
-
 
714
.wake_cpus_loop:
-
 
715
        lodsd
-
 
716
        push    esi
-
 
717
        xor     esi, esi
-
 
718
        inc     esi
-
 
719
        shl     eax, 24
-
 
720
        mov     [edi+10h], eax
-
 
721
; assert INIT IPI
-
 
722
        mov     dword [edi], 0C500h
-
 
723
        call    delay_ms
-
 
724
@@:
-
 
725
        test    dword [edi], 1000h
-
 
726
        jnz     @b
-
 
727
; deassert INIT IPI
-
 
728
        mov     dword [edi], 8500h
-
 
729
        call    delay_ms
-
 
730
@@:
-
 
731
        test    dword [edi], 1000h
-
 
732
        jnz     @b
-
 
733
; send STARTUP IPI
-
 
734
        mov     dword [edi], 600h + (8000h shr 12)
-
 
735
        call    delay_ms
-
 
736
@@:
-
 
737
        test    dword [edi], 1000h
-
 
738
        jnz     @b
-
 
739
        pop     esi
-
 
740
        dec     ebx
-
 
741
        jnz     .wake_cpus_loop
-
 
742
        mov     eax, [cpu_count]
-
 
743
        dec     eax
-
 
744
@@:
-
 
745
        cmp     [ap_initialized], eax
-
 
746
        jnz     @b
-
 
747
        mov     eax, [cr3_ap+OS_BASE]
-
 
748
        call    free_page
-
 
749
.no_wake_cpus:
Line 670... Line 750...
670
 
750
 
671
 
751
 
672
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
752
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
673
        mov     esi, boot_initirq
753
        mov     esi, boot_initirq
Line 679... Line 759...
679
        call    PIC_init
759
        call    PIC_init
Line 680... Line 760...
680
 
760
 
681
        mov     esi, boot_v86machine
761
        mov     esi, boot_v86machine
682
        call    boot_log
762
        call    boot_log
683
; Initialize system V86 machine
-
 
684
;        call    init_sys_v86
-
 
685
 
-
 
686
        xchg    bx, bx
-
 
687
 
-
 
688
;        call    v86_init
763
; Initialize system V86 machine
Line 689... Line 764...
689
        call    init_sys_v86
764
        call    init_sys_v86
690
 
765
 
691
        mov     esi, boot_inittimer
766
        mov     esi, boot_inittimer
Line 836... Line 911...
836
 
911
 
Line 837... Line 912...
837
        call    clear_pci_ide_interrupts
912
        call    clear_pci_ide_interrupts
Line 838... Line 913...
838
 
913
 
Line 839... Line 914...
839
include "detect/vortex86.inc"                     ; Vortex86 SoC detection code
914
include "detect/vortex86.inc"                     ; Vortex86 SoC detection code
Line 840... Line 915...
840
 
915
 
Line 875... Line 950...
875
        rdtsc
950
        rdtsc
876
        mov     ecx, eax
951
        mov     ecx, eax
877
        mov     esi, 250            ; wait 1/4 a second
952
        mov     esi, 250            ; wait 1/4 a second
878
        call    delay_ms
953
        call    delay_ms
879
        rdtsc
954
        rdtsc
-
 
955
        sti
Line 880... Line 956...
880
 
956
 
881
        sub     eax, ecx
957
        sub     eax, ecx
882
        xor     edx, edx
958
        xor     edx, edx
883
        shld    edx, eax, 2
959
        shld    edx, eax, 2
Line 942... Line 1018...
942
        stdcall map_page, tss._io_map_0, \
1018
        stdcall map_page, tss._io_map_0, \
943
                [SLOT_BASE+256+APPDATA.io_map], PG_MAP
1019
                [SLOT_BASE+256+APPDATA.io_map], PG_MAP
944
        stdcall map_page, tss._io_map_1, \
1020
        stdcall map_page, tss._io_map_1, \
945
                [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
1021
                [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
Line 946... Line -...
946
 
-
 
947
; LOAD FIRST APPLICATION
-
 
948
        cmp     byte [launcher_start], 1        ; Check if starting LAUNCHER is selected on blue screen (1 = yes)
-
 
949
        jnz     first_app_found
-
 
950
 
-
 
951
        cli
-
 
952
        mov     ebp, firstapp
-
 
953
        call    fs_execute_from_sysdir
-
 
954
        test    eax, eax
-
 
955
        jns     first_app_found
-
 
956
 
-
 
957
        mov     esi, boot_failed
-
 
958
        call    boot_log
-
 
959
 
-
 
960
        mov     eax, 0xDEADBEEF      ; otherwise halt
-
 
961
        hlt
-
 
962
 
-
 
963
first_app_found:
-
 
964
 
-
 
965
        cli
-
 
966
 
1022
 
967
; SET KEYBOARD PARAMETERS
1023
; SET KEYBOARD PARAMETERS
968
        mov     al, 0xf6       ; reset keyboard, scan enabled
1024
        mov     al, 0xf6       ; reset keyboard, scan enabled
969
        call    kb_write
1025
        call    kb_write_wait_ack
970
        test    ah, ah
1026
        test    ah, ah
Line 971... Line -...
971
        jnz     .no_keyboard
-
 
972
 
-
 
973
        ; wait until 8042 is ready
-
 
974
        xor     ecx, ecx
-
 
975
      @@:
-
 
976
        in      al, 64h
-
 
977
        and     al, 00000010b
-
 
978
        loopnz  @b
1027
        jnz     .no_keyboard
979
 
1028
 
980
iglobal
1029
iglobal
981
align 4
1030
align 4
982
ps2_keyboard_functions:
1031
ps2_keyboard_functions:
983
        dd      .end - $
1032
        dd      .end - $
984
        dd      0       ; no close
1033
        dd      0       ; no close
985
        dd      ps2_set_lights
1034
        dd      ps2_set_lights
986
.end:
1035
.end:
987
endg
1036
endg
988
        stdcall register_keyboard, ps2_keyboard_functions, 0
1037
        stdcall register_keyboard, ps2_keyboard_functions, 0
989
       ; mov   al, 0xED       ; Keyboard LEDs - only for testing!
-
 
990
       ; call  kb_write
1038
       ; mov   al, 0xED       ; Keyboard LEDs - only for testing!
991
       ; call  kb_read
1039
       ; call  kb_write_wait_ack
992
       ; mov   al, 111b
-
 
Line 993... Line 1040...
993
       ; call  kb_write
1040
       ; mov   al, 111b
994
       ; call  kb_read
1041
       ; call  kb_write_wait_ack
995
 
-
 
996
        mov     al, 0xF3     ; set repeat rate & delay
1042
 
997
        call    kb_write
1043
        mov     al, 0xF3     ; set repeat rate & delay
998
;        call  kb_read
-
 
999
        mov     al, 0; 30 250 ;00100010b ; 24 500  ;00100100b  ; 20 500
1044
        call    kb_write_wait_ack
1000
        call    kb_write
1045
        mov     al, 0; 30 250 ;00100010b ; 24 500  ;00100100b  ; 20 500
1001
;        call  kb_read
1046
        call    kb_write_wait_ack
1002
     ;// mike.dld [
1047
     ;// mike.dld [
1003
        call    set_lights
1048
        call    set_lights
1004
     ;// mike.dld ]
1049
     ;// mike.dld ]
Line 1005... Line 1050...
1005
        stdcall attach_int_handler, 1, irq1, 0
1050
        stdcall attach_int_handler, 1, irq1, 0
Line 1006... Line 1051...
1006
        DEBUGF  1, "K : IRQ1 return code %x\n", eax
1051
        DEBUGF  1, "K : IRQ1 return code %x\n", eax
Line 1007... Line 1052...
1007
.no_keyboard:
1052
.no_keyboard:
1008
 
1053
 
1009
; Load PS/2 mouse driver
1054
; Load PS/2 mouse driver
Line -... Line 1055...
-
 
1055
 
-
 
1056
        stdcall load_pe_driver, szPS2MDriver, 0
-
 
1057
 
-
 
1058
        mov     esi, boot_setmouse
-
 
1059
        call    boot_log
-
 
1060
        call    setmouse
-
 
1061
 
-
 
1062
; LOAD FIRST APPLICATION
-
 
1063
        cmp     byte [launcher_start], 1        ; Check if starting LAUNCHER is selected on blue screen (1 = yes)
-
 
1064
        jnz     first_app_found
-
 
1065
 
-
 
1066
        cli
-
 
1067
        mov     ebp, firstapp
-
 
1068
        call    fs_execute_from_sysdir
-
 
1069
        test    eax, eax
-
 
1070
        jns     first_app_found
-
 
1071
 
-
 
1072
        mov     esi, boot_failed
1010
 
1073
        call    boot_log
Line 1011... Line 1074...
1011
        stdcall load_driver, szPS2MDriver
1074
 
1012
 
1075
        mov     eax, 0xDEADBEEF      ; otherwise halt
1013
        mov     esi, boot_setmouse
1076
        hlt
Line 1035... Line 1098...
1035
        jmp     osloop
1098
        jmp     osloop
Line 1036... Line 1099...
1036
 
1099
 
Line -... Line 1100...
-
 
1100
 
-
 
1101
        ; Fly :)
-
 
1102
 
-
 
1103
uglobal
-
 
1104
align 4
-
 
1105
ap_initialized  dd      0
-
 
1106
endg
-
 
1107
 
-
 
1108
ap_init_high:
-
 
1109
        mov     ax, os_stack
-
 
1110
        mov     bx, app_data
-
 
1111
        mov     cx, app_tls
-
 
1112
        mov     ss, ax
-
 
1113
        mov     ds, bx
-
 
1114
        mov     es, bx
-
 
1115
        mov     fs, cx
-
 
1116
        mov     gs, bx
-
 
1117
        xor     esp, esp
-
 
1118
        mov     eax, sys_proc-OS_BASE+PROC.pdt_0
-
 
1119
        mov     cr3, eax
-
 
1120
        lock inc [ap_initialized]
1037
 
1121
        jmp     idle_loop
Line 1038... Line 1122...
1038
        ; Fly :)
1122
 
1039
 
1123
 
1040
include 'unpacker.inc'
1124
include 'unpacker.inc'
Line 1169... Line 1253...
1169
uglobal
1253
uglobal
1170
align 4
1254
align 4
1171
osloop_nonperiodic_work dd      ?
1255
osloop_nonperiodic_work dd      ?
1172
endg
1256
endg
Line -... Line 1257...
-
 
1257
 
1173
 
1258
uglobal
-
 
1259
align 64
-
 
1260
idle_addr       rb      64
-
 
1261
endg
1174
align 4
1262
 
1175
idle_thread:
1263
idle_thread:
-
 
1264
        sti
-
 
1265
 
-
 
1266
; The following code can be executed by all CPUs in the system.
-
 
1267
; All other parts of the kernel do not expect multi-CPU.
-
 
1268
; Also, APs don't even have a stack here.
1176
        sti
1269
; Beware. Don't do anything here. Anything at all.
-
 
1270
idle_loop:
-
 
1271
        cmp     [use_mwait_for_idle], 0
-
 
1272
        jnz     idle_loop_mwait
-
 
1273
 
1177
idle_loop:
1274
idle_loop_hlt:
1178
        hlt
1275
        hlt
Line -... Line 1276...
-
 
1276
        jmp     idle_loop_hlt
-
 
1277
 
-
 
1278
idle_loop_mwait:
-
 
1279
        mov     eax, idle_addr
-
 
1280
        xor     ecx, ecx
-
 
1281
        xor     edx, edx
-
 
1282
        monitor
-
 
1283
        xor     ecx, ecx
-
 
1284
        mov     eax, 20h        ; or 10h
Line 1179... Line 1285...
1179
        jmp     idle_loop
1285
        mwait
1180
 
1286
        jmp     idle_loop_mwait
1181
 
1287
 
Line 2244... Line 2350...
2244
; removed here by 
2350
; removed here by 
2245
;     call  mouse_centered
2351
;     call  mouse_centered
2246
;* mouse centered - start code- Mario79
2352
;* mouse centered - start code- Mario79
2247
;mouse_centered:
2353
;mouse_centered:
2248
;        push  eax
2354
;        push  eax
2249
        mov     eax, [_display.width]
2355
        mov     eax, [Screen_Max_X]
2250
        shr     eax, 1
2356
        shr     eax, 1
2251
        mov     [MOUSE_X], ax
2357
        mov     [MOUSE_X], ax
2252
        mov     eax, [_display.height]
2358
        mov     eax, [Screen_Max_Y]
2253
        shr     eax, 1
2359
        shr     eax, 1
2254
        mov     [MOUSE_Y], ax
2360
        mov     [MOUSE_Y], ax
2255
        call    wakeup_osloop
2361
        call    wakeup_osloop
2256
;        ret
2362
;        ret
2257
;* mouse centered - end code- Mario79
2363
;* mouse centered - end code- Mario79
Line 2289... Line 2395...
2289
        ret
2395
        ret
2290
 .set_pointer_position:
2396
 .set_pointer_position:
2291
;     cmp  ecx,4  ; set mouse pointer position
2397
;     cmp  ecx,4  ; set mouse pointer position
2292
        dec     ecx
2398
        dec     ecx
2293
        jnz     .set_mouse_button
2399
        jnz     .set_mouse_button
2294
        cmp     dx, word[_display.height]
2400
        cmp     dx, word[Screen_Max_Y]
2295
        jae     .end
2401
        ja      .end
2296
        rol     edx, 16
2402
        rol     edx, 16
2297
        cmp     dx, word[_display.width]
2403
        cmp     dx, word[Screen_Max_X]
2298
        jae      .end
2404
        ja      .end
2299
        mov     [MOUSE_X], edx
2405
        mov     [MOUSE_X], edx
2300
        mov     [mouse_active], 1
2406
        mov     [mouse_active], 1
2301
        call    wakeup_osloop
2407
        call    wakeup_osloop
2302
        ret
2408
        ret
2303
 .set_mouse_button:
2409
 .set_mouse_button:
Line 2720... Line 2826...
2720
nosb8:
2826
nosb8:
2721
        cmp     ebx, 9
2827
        cmp     ebx, 9
2722
        jnz     nosb9
2828
        jnz     nosb9
2723
; ecx = [left]*65536 + [right]
2829
; ecx = [left]*65536 + [right]
2724
; edx = [top]*65536 + [bottom]
2830
; edx = [top]*65536 + [bottom]
2725
        mov     eax, [_display.width]
2831
        mov     eax, [Screen_Max_X]
2726
        mov     ebx, [_display.height]
2832
        mov     ebx, [Screen_Max_Y]
2727
; check [right]
2833
; check [right]
2728
        cmp     cx, ax
2834
        cmp     cx, ax
2729
        jae     .exit
2835
        ja      .exit
2730
; check [left]
2836
; check [left]
2731
        ror     ecx, 16
2837
        ror     ecx, 16
2732
        cmp     cx, ax
2838
        cmp     cx, ax
2733
        jae     .exit
2839
        ja      .exit
2734
; check [bottom]
2840
; check [bottom]
2735
        cmp     dx, bx
2841
        cmp     dx, bx
2736
        jae     .exit
2842
        ja      .exit
2737
; check [top]
2843
; check [top]
2738
        ror     edx, 16
2844
        ror     edx, 16
2739
        cmp     dx, bx
2845
        cmp     dx, bx
2740
        jae     .exit
2846
        ja      .exit
Line 2741... Line 2847...
2741
 
2847
 
2742
        movzx   eax, cx  ; [left]
2848
        movzx   eax, cx  ; [left]
Line 2743... Line 2849...
2743
        movzx   ebx, dx  ; [top]
2849
        movzx   ebx, dx  ; [top]
Line 4461... Line 4567...
4461
;        call    vesa20_drawbar
4567
;        call    vesa20_drawbar
4462
;        call    [draw_pointer]
4568
;        call    [draw_pointer]
4463
;        ret
4569
;        ret
4464
;-----------------------------------------------------------------------------
4570
;-----------------------------------------------------------------------------
4465
align 4
4571
align 4
4466
kb_read:
-
 
4467
 
-
 
4468
        push    ecx edx
-
 
4469
 
-
 
4470
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
-
 
4471
      kr_loop:
-
 
4472
        in      al, 0x64
-
 
4473
        test    al, 1
-
 
4474
        jnz     kr_ready
-
 
4475
        loop    kr_loop
-
 
4476
        mov     ah, 1
-
 
4477
        jmp     kr_exit
-
 
4478
      kr_ready:
-
 
4479
        push    ecx
-
 
4480
        mov     ecx, 32
-
 
4481
      kr_delay:
-
 
4482
        loop    kr_delay
-
 
4483
        pop     ecx
-
 
4484
        in      al, 0x60
-
 
4485
        xor     ah, ah
-
 
4486
      kr_exit:
-
 
4487
 
-
 
4488
        pop     edx ecx
-
 
4489
 
-
 
4490
        ret
-
 
4491
;-----------------------------------------------------------------------------
-
 
4492
align 4
-
 
4493
kb_write:
4572
kb_write_wait_ack:
Line 4494... Line 4573...
4494
 
4573
 
Line 4495... Line 4574...
4495
        push    ecx edx
4574
        push    ecx edx
4496
 
-
 
4497
        mov     dl, al
-
 
4498
;        mov     ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's
-
 
4499
;      kw_loop1:
-
 
4500
;        in      al,0x64
-
 
4501
;        test    al,0x20
-
 
4502
;        jz      kw_ok1
-
 
4503
;        loop    kw_loop1
-
 
4504
;        mov     ah,1
-
 
4505
;        jmp     kw_exit
-
 
4506
;      kw_ok1:
4575
 
4507
        in      al, 0x60
4576
        mov     dl, al
4508
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
4577
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
4509
      kw_loop:
4578
.wait_output_ready:
4510
        in      al, 0x64
4579
        in      al, 0x64
4511
        test    al, 2
4580
        test    al, 2
4512
        jz      kw_ok
4581
        jz      @f
4513
        loop    kw_loop
4582
        loop    .wait_output_ready
4514
        mov     ah, 1
4583
        mov     ah, 1
4515
        jmp     kw_exit
4584
        jmp     .nothing
4516
      kw_ok:
4585
@@:
4517
        mov     al, dl
4586
        mov     al, dl
4518
        out     0x60, al
-
 
4519
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
-
 
4520
      kw_loop3:
-
 
4521
        in      al, 0x64
-
 
4522
        test    al, 2
-
 
4523
        jz      kw_ok3
-
 
4524
        loop    kw_loop3
-
 
4525
        mov     ah, 1
4587
        out     0x60, al
4526
        jmp     kw_exit
-
 
4527
      kw_ok3:
-
 
4528
        mov     ah, 8
-
 
4529
      kw_loop4:
-
 
4530
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
4588
        mov     ecx, 0xfffff; last 0xffff, new value in view of fast CPU's
4531
      kw_loop5:
4589
.wait_ack:
4532
        in      al, 0x64
4590
        in      al, 0x64
4533
        test    al, 1
4591
        test    al, 1
4534
        jnz     kw_ok4
4592
        jnz     @f
4535
        loop    kw_loop5
4593
        loop    .wait_ack
-
 
4594
        mov     ah, 1
4536
        dec     ah
4595
        jmp     .nothing
4537
        jnz     kw_loop4
4596
@@:
4538
      kw_ok4:
-
 
Line -... Line 4597...
-
 
4597
        in      al, 0x60
4539
        xor     ah, ah
4598
        xor     ah, ah
Line 4540... Line 4599...
4540
      kw_exit:
4599
 
4541
 
4600
.nothing:
4542
        pop     edx ecx
-
 
4543
 
-
 
4544
        ret
-
 
4545
;-----------------------------------------------------------------------------
-
 
4546
align 4
-
 
4547
kb_cmd:
-
 
4548
 
-
 
4549
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
-
 
4550
      c_wait:
-
 
4551
        in      al, 0x64
-
 
4552
        test    al, 2
-
 
4553
        jz      c_send
-
 
4554
        loop    c_wait
-
 
4555
        jmp     c_error
-
 
4556
      c_send:
-
 
4557
        mov     al, bl
-
 
4558
        out     0x64, al
-
 
4559
        mov     ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
-
 
4560
      c_accept:
-
 
4561
        in      al, 0x64
-
 
4562
        test    al, 2
-
 
4563
        jz      c_ok
-
 
4564
        loop    c_accept
-
 
4565
      c_error:
-
 
4566
        mov     ah, 1
-
 
4567
        jmp     c_exit
-
 
4568
      c_ok:
-
 
Line 4569... Line 4601...
4569
        xor     ah, ah
4601
        pop     edx ecx
4570
      c_exit:
4602
 
Line 4571... Line 4603...
4571
        ret
4603
        ret
Line 4705... Line 4737...
4705
        add     word [msg_board_pos+2], 6
4737
        add     word [msg_board_pos+2], 6
4706
        cmp     bl, 10
4738
        cmp     bl, 10
4707
        jnz     @f
4739
        jnz     @f
4708
        mov     word [msg_board_pos+2], (42*6)
4740
        mov     word [msg_board_pos+2], (42*6)
4709
        add     word [msg_board_pos], 10
4741
        add     word [msg_board_pos], 10
4710
        mov     ax, word [_display.height]
4742
        mov     ax, word [Screen_Max_Y]
4711
        cmp     word [msg_board_pos], ax
4743
        cmp     word [msg_board_pos], ax
4712
        jb      @f
4744
        jbe     @f
4713
        mov     word [msg_board_pos], 10
4745
        mov     word [msg_board_pos], 10
4714
@@:
4746
@@:
4715
; // end if
4747
; // end if
Line 4716... Line 4748...
4716
 
4748
 
Line 5090... Line 5122...
5090
        and     [cd_status], 0
5122
        and     [cd_status], 0
5091
        ret
5123
        ret
5092
;-----------------------------------------------------------------------------
5124
;-----------------------------------------------------------------------------
5093
align 4
5125
align 4
5094
syscall_getpixel_WinMap:                       ; GetPixel WinMap
5126
syscall_getpixel_WinMap:                       ; GetPixel WinMap
5095
        cmp     ebx, [_display.width]
5127
        cmp     ebx, [Screen_Max_X]
5096
        jb      @f
5128
        jbe     @f
5097
        cmp     ecx, [_display.height]
5129
        cmp     ecx, [Screen_Max_Y]
5098
        jb      @f
5130
        jbe     @f
5099
        xor     eax, eax
5131
        xor     eax, eax
5100
        jmp     .store
5132
        jmp     .store
5101
;--------------------------------------
5133
;--------------------------------------
5102
align 4
5134
align 4
5103
@@:
5135
@@:
Line 5110... Line 5142...
5110
        mov     [esp + 32], eax
5142
        mov     [esp + 32], eax
5111
        ret
5143
        ret
5112
;-----------------------------------------------------------------------------
5144
;-----------------------------------------------------------------------------
5113
align 4
5145
align 4
5114
syscall_getpixel:                       ; GetPixel
5146
syscall_getpixel:                       ; GetPixel
5115
        mov     ecx, [_display.width]
5147
        mov     ecx, [Screen_Max_X]
-
 
5148
        inc     ecx
5116
        xor     edx, edx
5149
        xor     edx, edx
5117
        mov     eax, ebx
5150
        mov     eax, ebx
5118
        div     ecx
5151
        div     ecx
5119
        mov     ebx, edx
5152
        mov     ebx, edx
5120
        xchg    eax, ebx
5153
        xchg    eax, ebx
Line 5485... Line 5518...
5485
        ret
5518
        ret
5486
@@:
5519
@@:
5487
        call    stop_all_services
5520
        call    stop_all_services
Line 5488... Line 5521...
5488
 
5521
 
-
 
5522
yes_shutdown_param:
-
 
5523
; Shutdown other CPUs, if initialized
-
 
5524
        cmp     [ap_initialized], 0
-
 
5525
        jz      .no_shutdown_cpus
-
 
5526
        mov     edi, [LAPIC_BASE]
-
 
5527
        add     edi, 300h
-
 
5528
        mov     esi, smpt+4
-
 
5529
        mov     ebx, [cpu_count]
-
 
5530
        dec     ebx
-
 
5531
.shutdown_cpus_loop:
-
 
5532
        lodsd
-
 
5533
        push    esi
-
 
5534
        xor     esi, esi
-
 
5535
        inc     esi
-
 
5536
        shl     eax, 24
-
 
5537
        mov     [edi+10h], eax
-
 
5538
; assert INIT IPI
-
 
5539
        mov     dword [edi], 0C500h
-
 
5540
        call    delay_ms
-
 
5541
@@:
-
 
5542
        test    dword [edi], 1000h
-
 
5543
        jnz     @b
-
 
5544
; deassert INIT IPI
-
 
5545
        mov     dword [edi], 8500h
-
 
5546
        call    delay_ms
-
 
5547
@@:
-
 
5548
        test    dword [edi], 1000h
-
 
5549
        jnz     @b
-
 
5550
; don't send STARTUP IPI: let other CPUs be in wait-for-startup state
-
 
5551
        pop     esi
-
 
5552
        dec     ebx
-
 
5553
        jnz     .shutdown_cpus_loop
-
 
5554
.no_shutdown_cpus:
5489
yes_shutdown_param:
5555
 
Line 5490... Line 5556...
5490
        cli
5556
        cli
5491
 
5557
 
5492
if ~ defined extended_primary_loader
5558
if ~ defined extended_primary_loader
Line 5508... Line 5574...
5508
;        cld
5574
;        cld
5509
;        rep movsd
5575
;        rep movsd
Line 5510... Line 5576...
5510
 
5576
 
Line 5511... Line -...
5511
        call    IRQ_mask_all
-
 
5512
 
-
 
5513
if 0
-
 
5514
        mov     word [OS_BASE+0x467+0], pr_mode_exit
-
 
5515
        mov     word [OS_BASE+0x467+2], 0x1000
-
 
5516
 
-
 
5517
        mov     al, 0x0F
-
 
5518
        out     0x70, al
-
 
5519
        mov     al, 0x05
-
 
5520
        out     0x71, al
-
 
5521
 
-
 
5522
        mov     al, 0xFE
-
 
5523
        out     0x64, al
-
 
5524
 
-
 
5525
        hlt
-
 
5526
        jmp     $-1
-
 
5527
 
5577
        call    IRQ_mask_all
5528
else
5578
 
Line 5529... Line 5579...
5529
        cmp     byte [OS_BASE + 0x9030], 2
5579
        cmp     byte [OS_BASE + 0x9030], 2
5530
        jnz     no_acpi_power_off
5580
        jnz     no_acpi_power_off
Line 5669... Line 5719...
5669
        out     dx, ax
5719
        out     dx, ax
5670
@@:
5720
@@:
5671
        jmp     $
5721
        jmp     $
Line 5672... Line -...
5672
 
-
 
5673
 
-
 
5674
no_acpi_power_off:
-
 
5675
        mov     word [OS_BASE+0x467+0], pr_mode_exit
-
 
5676
        mov     word [OS_BASE+0x467+2], 0x1000
-
 
5677
 
-
 
5678
        mov     al, 0x0F
-
 
5679
        out     0x70, al
-
 
5680
        mov     al, 0x05
-
 
5681
        out     0x71, al
-
 
5682
 
-
 
5683
        mov     al, 0xFE
-
 
5684
        out     0x64, al
-
 
5685
 
-
 
5686
        hlt
-
 
5687
        jmp     $-1
5722
 
5688
 
5723
 
5689
scan_rsdp:
5724
scan_rsdp:
5690
        add     eax, OS_BASE
5725
        add     eax, OS_BASE
5691
.s:
5726
.s:
Line 5706... Line 5741...
5706
        add     eax, 10h
5741
        add     eax, 10h
5707
        loop    .s
5742
        loop    .s
5708
        stc
5743
        stc
5709
.ok:
5744
.ok:
5710
        ret
5745
        ret
-
 
5746
 
-
 
5747
no_acpi_power_off:
-
 
5748
        call    create_trampoline_pgmap
-
 
5749
        mov     cr3, eax
-
 
5750
        jmp     become_real+0x10000
-
 
5751
iglobal
-
 
5752
align 4
-
 
5753
realmode_gdt:
-
 
5754
; selector 0 - not used
-
 
5755
        dw      23
-
 
5756
        dd      realmode_gdt-OS_BASE
-
 
5757
        dw      0
-
 
5758
; selector 8 - code from 1000:0000 to 1000:FFFF
-
 
5759
        dw      0FFFFh
-
 
5760
        dw      0
-
 
5761
        db      1
-
 
5762
        db      10011011b
-
 
5763
        db      00000000b
-
 
5764
        db      0
-
 
5765
; selector 10h - data from 1000:0000 to 1000:FFFF
-
 
5766
        dw      0FFFFh
-
 
5767
        dw      0
-
 
5768
        db      1
-
 
5769
        db      10010011b
-
 
5770
        db      00000000b
-
 
5771
        db      0
5711
end if
5772
endg
Line 5712... Line 5773...
5712
 
5773
 
5713
if ~ lang eq sp
5774
if ~ lang eq sp
5714
diff16 "end of .text segment",0,$
5775
diff16 "end of .text segment",0,$