Subversion Repositories Kolibri OS

Rev

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

Rev 3500 Rev 3555
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
 
Line 74... Line 74...
74
$Revision: 3500 $
74
$Revision: 3555 $
75
 
75
 
-
 
76
 
-
 
77
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
Line 76... Line 78...
76
 
78
 
77
USE_COM_IRQ     equ 1      ; make irq 3 and irq 4 available for PCI devices
79
; Enabling the next line will enable serial output console
78
 
80
debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
-
 
81
; The following constant, if nonzero, duplicates debug output to the screen.
Line 79... Line 82...
79
; Enabling the next line will enable serial output console
82
debug_direct_print equ 0
80
;debug_com_base  equ 0x3f8  ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
83
 
81
 
84
include "proc32.inc"
Line 158... Line 161...
158
 
161
 
159
include "boot/bootcode.inc"    ; 16 bit system boot code
162
include "boot/bootcode.inc"    ; 16 bit system boot code
160
include "bus/pci/pci16.inc"
163
include "bus/pci/pci16.inc"
Line -... Line 164...
-
 
164
include "detect/biosdisk.inc"
-
 
165
 
-
 
166
FDD_BUFF            equ (OS_BASE+0x000D000)
-
 
167
 
-
 
168
sys_pgdir           equ (OS_BASE+0x006F000)
-
 
169
 
-
 
170
VGABasePtr          equ (OS_BASE+0x00A0000)
-
 
171
 
-
 
172
RAMDISK             equ (OS_BASE+0x0100000)
-
 
173
 
-
 
174
CLEAN_ZONE          equ 0x284000
-
 
175
IDE_DMA             equ 0x284000
-
 
176
 
-
 
177
BOOT_VAR            equ (OS_BASE+0x02E0000)
-
 
178
 
-
 
179
TASK_COUNT          equ (CURRENT_TASK+0x04)
-
 
180
TASK_BASE           equ (CURRENT_TASK+0x10)
-
 
181
TASK_DATA           equ (CURRENT_TASK+0x20)
-
 
182
TASK_EVENT          equ (CURRENT_TASK+0x20)
-
 
183
 
-
 
184
BPSLine_calc_area   equ (OS_BASE+0x02C4000)
-
 
185
 
-
 
186
d_width_calc_area   equ (OS_BASE+0x02CA000)
-
 
187
 
-
 
188
stack_data_start    equ (OS_BASE+0x02F0000)
-
 
189
eth_data_start      equ (OS_BASE+0x02F0000)
-
 
190
stack_data          equ (OS_BASE+0x02F4000)
-
 
191
stack_data_end      equ (OS_BASE+0x030ffff)
-
 
192
resendQ             equ (OS_BASE+0x0310000)
161
include "detect/biosdisk.inc"
193
 
162
 
194
 
163
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
195
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
164
;;                                                                      ;;
196
;;                                                                      ;;
165
;;                  SWITCH TO 32 BIT PROTECTED MODE                     ;;
197
;;                  SWITCH TO 32 BIT PROTECTED MODE                     ;;
Line 344... Line 376...
344
        call    mutex_init
376
        call    mutex_init
Line 345... Line 377...
345
 
377
 
346
        mov     ecx, unpack_mutex
378
        mov     ecx, unpack_mutex
Line -... Line 379...
-
 
379
        call    mutex_init
-
 
380
 
-
 
381
        mov     ecx, application_table_mutex
347
        call    mutex_init
382
        call    mutex_init
348
 
383
 
349
; SAVE REAL MODE VARIABLES
384
; SAVE REAL MODE VARIABLES
350
        mov     ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR]
385
        mov     ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR]
Line 382... Line 417...
382
        mov     [apm_vf], eax
417
        mov     [apm_vf], eax
383
; -----------------------------------------
418
; -----------------------------------------
384
        mov     al, [BOOT_VAR+BOOT_DMA]            ; DMA access
419
        mov     al, [BOOT_VAR+BOOT_DMA]            ; DMA access
385
        mov     [allow_dma_access], al
420
        mov     [allow_dma_access], al
386
        movzx   eax, byte [BOOT_VAR+BOOT_BPP]      ; bpp
421
        movzx   eax, byte [BOOT_VAR+BOOT_BPP]      ; bpp
387
        mov     [ScreenBPP], al
-
 
388
 
-
 
389
        mov     [_display.bpp], eax
422
        mov     [_display.bpp], eax
390
        mov     [_display.vrefresh], 60
423
        mov     [_display.vrefresh], 60
Line 391... Line 424...
391
 
424
 
392
        movzx   eax, word [BOOT_VAR+BOOT_X_RES]; X max
425
        movzx   eax, word [BOOT_VAR+BOOT_X_RES]; X max
Line 399... Line 432...
399
        mov     [_display.height], eax
432
        mov     [_display.height], eax
400
        mov     [display_height_standard], eax
433
        mov     [display_height_standard], eax
401
        dec     eax
434
        dec     eax
402
        mov     [Screen_Max_Y], eax
435
        mov     [Screen_Max_Y], eax
403
        mov     [screen_workarea.bottom], eax
436
        mov     [screen_workarea.bottom], eax
404
        movzx   eax, word [BOOT_VAR+BOOT_VESA_MODE]; screen mode
437
        mov     ax, word [BOOT_VAR+BOOT_VESA_MODE]  ; screen mode
405
        mov     [SCR_MODE], eax
438
        mov     [SCR_MODE], ax
406
;        mov     eax, [BOOT_VAR+0x9014]    ; Vesa 1.2 bnk sw add
-
 
407
;        mov     [BANK_SWITCH], eax
-
 
408
        mov     [BytesPerScanLine], word 640*4      ; Bytes PerScanLine
439
        mov     [BytesPerScanLine], 640*4           ; Bytes PerScanLine
409
        cmp     [SCR_MODE], word 0x13       ; 320x200
440
        cmp     [SCR_MODE], 0x13                    ; 320x200
410
        je      @f
441
        je      @f
411
        cmp     [SCR_MODE], word 0x12       ; VGA 640x480
442
        cmp     [SCR_MODE], 0x12                    ; VGA 640x480
412
        je      @f
443
        je      @f
413
        movzx   eax, word[BOOT_VAR+BOOT_PITCH]   ; for other modes
444
        movzx   eax, word[BOOT_VAR+BOOT_PITCH]      ; for other modes
414
        mov     [BytesPerScanLine], ax
445
        mov     [BytesPerScanLine], eax
415
        mov     [_display.pitch], eax
446
        mov     [_display.pitch], eax
416
@@:
447
@@:
417
        mov     eax, [_display.width]
448
        mov     eax, [_display.width]
418
        mul     [_display.height]
449
        mul     [_display.height]
419
        mov     [_WinMapSize], eax
450
        mov     [_WinMapSize], eax
Line 442... Line 473...
442
        jmp     v20ga24
473
        jmp     v20ga24
Line 443... Line 474...
443
 
474
 
444
setvesa20:
475
setvesa20:
445
        mov     [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0
476
        mov     [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0
446
        mov     [GETPIXEL], dword Vesa20_getpixel24
477
        mov     [GETPIXEL], dword Vesa20_getpixel24
447
        cmp     [ScreenBPP], byte 24
478
        cmp     byte [_display.bpp], 24
448
        jz      v20ga24
479
        jz      v20ga24
449
v20ga32:
480
v20ga32:
450
        mov     [PUTPIXEL], dword Vesa20_putpixel32
481
        mov     [PUTPIXEL], dword Vesa20_putpixel32
451
        mov     [GETPIXEL], dword Vesa20_getpixel32
482
        mov     [GETPIXEL], dword Vesa20_getpixel32
Line 489... Line 520...
489
        or      eax, 1 ; bit_0 - System Call Extension (SCE)
520
        or      eax, 1 ; bit_0 - System Call Extension (SCE)
490
        wrmsr
521
        wrmsr
Line 491... Line 522...
491
 
522
 
492
        ; !!!! It`s dirty hack, fix it !!!
523
        ; !!!! It`s dirty hack, fix it !!!
493
        ; Bits of EDX :
524
        ; Bits of EDX :
494
        ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register
525
        ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register
495
        ;  and the contents of this field, plus 8, are copied into the SS register.
526
        ;  and the contents of this field, plus 8, are copied into the SS register.
496
        ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register
527
        ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register
Line 497... Line 528...
497
        ;  and the contents of this field, plus 8, are copied into the SS register.
528
        ;  and the contents of this field, plus 8, are copied into the SS register.
498
 
529
 
Line 505... Line 536...
505
.noSYSCALL:
536
.noSYSCALL:
506
; -----------------------------------------
537
; -----------------------------------------
507
        stdcall alloc_page
538
        stdcall alloc_page
508
        stdcall map_page, tss-0xF80, eax, PG_SW
539
        stdcall map_page, tss-0xF80, eax, PG_SW
509
        stdcall alloc_page
540
        stdcall alloc_page
510
        inc     eax
-
 
511
        mov     [SLOT_BASE+256+APPDATA.io_map], eax
-
 
512
        stdcall map_page, tss+0x80, eax, PG_SW
541
        stdcall map_page, tss+0x80, eax, PG_SW
513
        stdcall alloc_page
542
        stdcall alloc_page
514
        inc     eax
-
 
515
        mov     dword [SLOT_BASE+256+APPDATA.io_map+4], eax
-
 
516
        stdcall map_page, tss+0x1080, eax, PG_SW
543
        stdcall map_page, tss+0x1080, eax, PG_SW
Line 517... Line 544...
517
 
544
 
Line 518... Line 545...
518
; LOAD IDT
545
; LOAD IDT
519
 
546
 
Line 520... Line 547...
520
        call    build_interrupt_table ;lidt is executed
547
        call    build_interrupt_table ;lidt is executed
521
          ;lidt [idtreg]
548
          ;lidt [idtreg]
522
 
549
 
Line 523... Line 550...
523
        call    init_kernel_heap
550
        call    init_kernel_heap
Line 524... Line 551...
524
        stdcall kernel_alloc, RING0_STACK_SIZE+512
551
        stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2
Line 599... Line 626...
599
        stdcall kernel_alloc, [_WinMapSize]
626
        stdcall kernel_alloc, [_WinMapSize]
600
        mov     [_WinMapAddress], eax
627
        mov     [_WinMapAddress], eax
Line 601... Line 628...
601
 
628
 
602
        xor     eax, eax
629
        xor     eax, eax
603
        inc     eax
-
 
604
        mov     [CURRENT_TASK], eax     ;dword 1
-
 
605
        mov     [TASK_COUNT], eax       ;dword 1
-
 
606
        mov     [TASK_BASE], dword TASK_DATA
-
 
Line 607... Line 630...
607
        mov     [current_slot], SLOT_BASE+256
630
        inc     eax
Line 608... Line 631...
608
 
631
 
609
; set background
632
; set background
Line 617... Line 640...
617
; SET UP OS TASK
640
; SET UP OS TASK
Line 618... Line 641...
618
 
641
 
619
        mov     esi, boot_setostask
642
        mov     esi, boot_setostask
Line 620... Line 643...
620
        call    boot_log
643
        call    boot_log
621
 
-
 
622
        xor     eax, eax
-
 
623
        mov     dword [SLOT_BASE+APPDATA.fpu_state], fpu_data
-
 
624
        mov     dword [SLOT_BASE+APPDATA.exc_handler], eax
-
 
625
        mov     dword [SLOT_BASE+APPDATA.except_mask], eax
-
 
626
 
-
 
627
        ; name for OS/IDLE process
-
 
628
 
-
 
629
        mov     dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I'
644
 
630
        mov     dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE '
645
        mov     edx, SLOT_BASE+256
631
        mov     edi, [os_stack_seg]
646
        mov     ebx, [os_stack_seg]
632
        mov     dword [SLOT_BASE+256+APPDATA.pl0_stack], edi
647
        add     ebx, 0x2000
633
        add     edi, 0x2000-512
648
        call    setup_os_slot
634
        mov     dword [SLOT_BASE+256+APPDATA.fpu_state], edi
649
        mov     dword [edx], 'IDLE'
635
        mov     dword [SLOT_BASE+256+APPDATA.saved_esp0], edi; just for case
-
 
636
        mov     dword [SLOT_BASE+256+APPDATA.terminate_protection], 80000001h
650
        sub     [edx+APPDATA.saved_esp], 4
637
 
651
        mov     eax, [edx+APPDATA.saved_esp]
638
        mov     esi, fpu_data
-
 
639
        mov     ecx, 512/4
652
        mov     dword [eax], idle_thread
640
        cld
653
        mov     ecx, IDLE_PRIORITY
641
        rep movsd
654
        call    scheduler_add_thread
642
 
655
 
643
        mov     dword [SLOT_BASE+256+APPDATA.exc_handler], eax
-
 
644
        mov     dword [SLOT_BASE+256+APPDATA.except_mask], eax
656
        mov     edx, SLOT_BASE+256*2
645
 
657
        mov     ebx, [os_stack_seg]
646
        mov     ebx, SLOT_BASE+256+APP_OBJ_OFFSET
658
        call    setup_os_slot
647
        mov     dword [SLOT_BASE+256+APPDATA.fd_obj], ebx
-
 
648
        mov     dword [SLOT_BASE+256+APPDATA.bk_obj], ebx
-
 
649
 
659
        mov     dword [edx], 'OS'
Line 650... Line -...
650
        mov     dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path
-
 
651
        mov     dword [SLOT_BASE+256+APPDATA.tls_base], eax
-
 
652
 
-
 
653
        ; task list
660
        xor     ecx, ecx
654
        mov     dword [TASK_DATA+TASKDATA.mem_start], eax; process base address
661
        call    scheduler_add_thread
655
        inc     eax
662
 
656
        mov     dword [CURRENT_TASK], eax
663
        mov     dword [CURRENT_TASK], 2
657
        mov     dword [TASK_COUNT], eax
-
 
658
        mov     [current_slot], SLOT_BASE+256
-
 
Line 659... Line -...
659
        mov     [TASK_BASE], dword TASK_DATA
-
 
660
        mov     byte[TASK_DATA+TASKDATA.wnd_number], al ; on screen number
-
 
661
        mov     dword [TASK_DATA+TASKDATA.pid], eax     ; process id number
-
 
662
 
-
 
663
        mov     [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE
-
 
664
 
-
 
665
        stdcall kernel_alloc, 0x10000/8
-
 
666
        mov     edi, eax
-
 
Line 667... Line 664...
667
        mov     [network_free_ports], eax
664
        mov     dword [TASK_COUNT], 2
668
        or      eax, -1
665
        mov     dword [current_slot], SLOT_BASE + 256*2
669
        mov     ecx, 0x10000/32
666
        mov     dword [TASK_BASE], CURRENT_TASK + 32*2
670
        rep stosd
667
 
Line 799... Line 796...
799
;        call    boot_log
796
;        call    boot_log
Line 800... Line 797...
800
 
797
 
801
        mov     [pci_access_enabled], 1
798
        mov     [pci_access_enabled], 1
Line -... Line 799...
-
 
799
        call    pci_enum
-
 
800
 
-
 
801
        stdcall load_driver, szVidintel
-
 
802
 
802
        call    pci_enum
803
        call    usb_init
Line 803... Line 804...
803
 
804
 
804
; SET PRELIMINARY WINDOW STACK AND POSITIONS
805
; SET PRELIMINARY WINDOW STACK AND POSITIONS
805
 
806
 
Line 820... Line 821...
820
        call    boot_log
821
        call    boot_log
821
        call    reserve_irqs_ports
822
        call    reserve_irqs_ports
Line 822... Line 823...
822
 
823
 
823
        call    init_display
824
        call    init_display
824
        mov     eax, [def_cursor]
-
 
825
        mov     [SLOT_BASE+APPDATA.cursor], eax
825
        mov     eax, [def_cursor]
-
 
826
        mov     [SLOT_BASE+APPDATA.cursor+256], eax
Line 826... Line 827...
826
        mov     [SLOT_BASE+APPDATA.cursor+256], eax
827
        mov     [SLOT_BASE+APPDATA.cursor+256*2], eax
Line 827... Line 828...
827
 
828
 
828
  ; READ TSC / SECOND
829
; PRINT CPU FREQUENCY
-
 
830
 
829
 
831
        mov     esi, boot_cpufreq
830
        mov     esi, boot_tsc
832
        call    boot_log
831
        call    boot_log
833
 
832
        cli
834
        cli                         ;FIXME check IF
833
        rdtsc   ;call  _rdtsc
835
        rdtsc
834
        mov     ecx, eax
-
 
835
        mov     esi, 250            ; wait 1/4 a second
836
        mov     ecx, eax
-
 
837
        mov     esi, 250            ; wait 1/4 a second
836
        call    delay_ms
838
        call    delay_ms
837
        rdtsc   ;call  _rdtsc
839
        rdtsc
838
        sti
840
 
839
        sub     eax, ecx
841
        sub     eax, ecx
840
        xor     edx, edx
842
        xor     edx, edx
841
        shld    edx, eax, 2
843
        shld    edx, eax, 2
842
        shl     eax, 2
844
        shl     eax, 2
843
        mov     dword [cpu_freq], eax
845
        mov     dword [cpu_freq], eax
844
        mov     dword [cpu_freq+4], edx
846
        mov     dword [cpu_freq+4], edx
Line 845... Line -...
845
; PRINT CPU FREQUENCY
-
 
846
        mov     esi, boot_cpufreq
847
        mov     ebx, 1000000
847
        call    boot_log
848
        div     ebx
848
 
849
        mov     ebx, eax
849
        mov     ebx, edx
850
 
850
        movzx   ecx, word [boot_y]
851
        movzx   ecx, word [boot_y]
851
        if lang eq ru
852
        if lang eq ru
852
        add     ecx, (10+19*6) shl 16 - 10         ; 'Determining amount of memory'
853
        add     ecx, (10+19*6) shl 16 - 10
853
        else if lang eq sp
854
        else if lang eq sp
-
 
855
        add     ecx, (10+25*6) shl 16 - 10
854
        add     ecx, (10+25*6) shl 16 - 10         ; 'Determining amount of memory'
856
                else
855
                else
857
        add     ecx, (10+17*6) shl 16 - 10
856
        add     ecx, (10+17*6) shl 16 - 10         ; 'Determining amount of memory'
858
                end if
857
                end if
859
 
858
        mov     edx, 0xFFFFFF
860
        mov     edx, 0xFFFFFF
Line 900... Line 902...
900
        stdcall map_page, tss._io_map_0, \
902
        stdcall map_page, tss._io_map_0, \
901
                [SLOT_BASE+256+APPDATA.io_map], PG_MAP
903
                [SLOT_BASE+256+APPDATA.io_map], PG_MAP
902
        stdcall map_page, tss._io_map_1, \
904
        stdcall map_page, tss._io_map_1, \
903
                [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
905
                [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
Line 904... Line -...
904
 
-
 
905
        mov     ax, [OS_BASE+0x10000+bx_from_load]
-
 
906
        cmp     ax, 'r1'; if not rused ram disk - load network configuration from files {SPraid.simba}
-
 
907
        je      no_st_network
-
 
908
        call    set_network_conf
-
 
909
  no_st_network:
-
 
910
 
906
 
911
; LOAD FIRST APPLICATION
907
; LOAD FIRST APPLICATION
Line 912... Line 908...
912
        cli
908
        cli
913
 
909
 
Line 938... Line 934...
938
 
934
 
Line 939... Line 935...
939
first_app_found:
935
first_app_found:
Line 940... Line -...
940
 
-
 
941
        cli
-
 
942
 
-
 
943
        ;mov   [TASK_COUNT],dword 2
-
 
944
        push    1
936
 
945
        pop     dword [CURRENT_TASK]    ; set OS task fisrt
937
        cli
946
 
938
 
947
; SET KEYBOARD PARAMETERS
939
; SET KEYBOARD PARAMETERS
948
        mov     al, 0xf6       ; reset keyboard, scan enabled
940
        mov     al, 0xf6       ; reset keyboard, scan enabled
Line 1042... Line 1034...
1042
        jnz     @F
1034
        jnz     @F
1043
        mov     al, 1                             ; at least one CPU
1035
        mov     al, 1                             ; at least one CPU
1044
@@:
1036
@@:
1045
        DEBUGF  1, "K : %d CPU detected\n", eax
1037
        DEBUGF  1, "K : %d CPU detected\n", eax
Line 1046... Line -...
1046
 
-
 
1047
;        call    print_mem
-
 
1048
 
1038
 
Line 1049... Line 1039...
1049
; START MULTITASKING
1039
; START MULTITASKING
1050
 
1040
 
1051
; A 'All set - press ESC to start' messages if need
1041
; A 'All set - press ESC to start' messages if need
Line 1061... Line 1051...
1061
        cmp     [IDEContrRegsBaseAddr], 0
1051
        cmp     [IDEContrRegsBaseAddr], 0
1062
        setnz   [dma_hdd]
1052
        setnz   [dma_hdd]
1063
        mov     [timer_ticks_enable], 1         ; for cd driver
1053
        mov     [timer_ticks_enable], 1         ; for cd driver
Line 1064... Line 1054...
1064
 
1054
 
1065
        sti
1055
        sti
Line 1066... Line 1056...
1066
        call    change_task
1056
;        call    change_task
Line 1067... Line 1057...
1067
 
1057
 
Line 1090... Line 1080...
1090
 
1080
 
Line 1091... Line 1081...
1091
        popad
1081
        popad
Line -... Line 1082...
-
 
1082
 
-
 
1083
        ret
-
 
1084
 
-
 
1085
; in: edx -> APPDATA for OS/IDLE slot
-
 
1086
; in: ebx = stack base
-
 
1087
proc setup_os_slot
-
 
1088
        xor     eax, eax
-
 
1089
        mov     ecx, 256/4
-
 
1090
        mov     edi, edx
-
 
1091
        rep stosd
-
 
1092
 
-
 
1093
        mov     eax, tss+0x80
-
 
1094
        call    get_pg_addr
-
 
1095
        inc     eax
-
 
1096
        mov     [edx+APPDATA.io_map], eax
-
 
1097
        mov     eax, tss+0x1080
-
 
1098
        call    get_pg_addr
-
 
1099
        inc     eax
-
 
1100
        mov     [edx+APPDATA.io_map+4], eax
-
 
1101
 
-
 
1102
        mov     dword [edx+APPDATA.pl0_stack], ebx
-
 
1103
        lea     edi, [ebx+0x2000-512]
-
 
1104
        mov     dword [edx+APPDATA.fpu_state], edi
-
 
1105
        mov     dword [edx+APPDATA.saved_esp0], edi
-
 
1106
        mov     dword [edx+APPDATA.saved_esp], edi
-
 
1107
        mov     dword [edx+APPDATA.terminate_protection], 1 ; make unkillable
-
 
1108
 
-
 
1109
        mov     esi, fpu_data
-
 
1110
        mov     ecx, 512/4
-
 
1111
        cld
-
 
1112
        rep movsd
-
 
1113
 
-
 
1114
        lea     eax, [edx+APP_OBJ_OFFSET]
-
 
1115
        mov     dword [edx+APPDATA.fd_obj], eax
-
 
1116
        mov     dword [edx+APPDATA.bk_obj], eax
-
 
1117
 
-
 
1118
        mov     dword [edx+APPDATA.cur_dir], sysdir_path
-
 
1119
 
-
 
1120
        mov     [edx + APPDATA.dir_table], sys_pgdir - OS_BASE
-
 
1121
 
-
 
1122
        mov     eax, edx
-
 
1123
        shr     eax, 3
-
 
1124
        add     eax, CURRENT_TASK - (SLOT_BASE shr 3)
-
 
1125
        mov     [eax+TASKDATA.wnd_number], dh
-
 
1126
        mov     byte [eax+TASKDATA.pid], dh
-
 
1127
 
1092
 
1128
        ret
1093
        ret
1129
endp
1094
 
1130
 
1095
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1096
;                                                                    ;
1132
;                                                                    ;
1097
;                    MAIN OS LOOP START                              ;
1133
;                    MAIN OS LOOP START                              ;
1098
;                                                                    ;
1134
;                                                                    ;
-
 
1135
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
1136
align 32
-
 
1137
osloop:
-
 
1138
        mov     edx, osloop_has_work?
-
 
1139
        xor     ecx, ecx
-
 
1140
        call    Wait_events
-
 
1141
        xor     eax, eax
1099
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1142
        xchg    eax, [osloop_nonperiodic_work]
1100
align 32
1143
        test    eax, eax
1101
osloop:
1144
        jz      .no_periodic
1102
;        call    [draw_pointer]
1145
;        call    [draw_pointer]
1103
        call    __sys_draw_pointer
1146
        call    __sys_draw_pointer
1104
        call    window_check_events
1147
        call    window_check_events
-
 
1148
        call    mouse_check_events
1105
        call    mouse_check_events
1149
        call    checkmisc
1106
        call    checkmisc
-
 
1107
        call    checkVga_N13
1150
        call    checkVga_N13
1108
        call    stack_handler
1151
.no_periodic:
1109
        call    checkidle
1152
        call    stack_handler
1110
        call    check_fdd_motor_status
1153
        call    check_fdd_motor_status
1111
        call    check_ATAPI_device_event
1154
        call    check_ATAPI_device_event
1112
        call    check_lights_state
1155
        call    check_lights_state
1113
        call    check_timers
1156
        call    check_timers
1114
        jmp     osloop
1157
        jmp     osloop
1115
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1158
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1116
;                                                                    ;
1159
;                                                                    ;
1117
;                      MAIN OS LOOP END                              ;
-
 
1118
;                                                                    ;
-
 
1119
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1160
;                      MAIN OS LOOP END                              ;
1120
align 4
1161
;                                                                    ;
1121
checkidle:
1162
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1122
        pushad
-
 
1123
        call    change_task
1163
proc osloop_has_work?
1124
        jmp     idle_loop_entry
1164
        cmp     [osloop_nonperiodic_work], 0
1125
  idle_loop:
1165
        jnz     .yes
1126
        cmp     eax, [idlemem]    ; eax == [timer_ticks]
1166
        call    stack_handler_has_work?
1127
        jne     idle_exit
-
 
1128
        rdtsc   ;call _rdtsc
1167
        jnz     .yes
1129
        mov     ecx, eax
1168
        call    check_fdd_motor_status_has_work?
1130
        hlt
1169
        jnz     .yes
1131
        rdtsc   ;call _rdtsc
1170
        call    check_ATAPI_device_event_has_work?
1132
        sub     eax, ecx
-
 
1133
        add     [idleuse], eax
1171
        jnz     .yes
1134
  idle_loop_entry:
1172
        call    check_lights_state_has_work?
-
 
1173
        jnz     .yes
1135
        mov     eax, [timer_ticks]; eax =  [timer_ticks]
1174
        call    check_timers_has_work?
1136
        cmp     [check_idle_semaphore], 0
1175
        jnz     .yes
-
 
1176
.no:
1137
        je      idle_loop
1177
        xor     eax, eax
1138
        dec     [check_idle_semaphore]
1178
        ret
1139
  idle_exit:
1179
.yes:
-
 
1180
        xor     eax, eax
-
 
1181
        inc     eax
-
 
1182
        ret
-
 
1183
endp
-
 
1184
 
-
 
1185
proc wakeup_osloop
Line 1140... Line 1186...
1140
        mov     [idlemem], eax    ; eax == [timer_ticks]
1186
        mov     [osloop_nonperiodic_work], 1
1141
        popad
-
 
1142
        ret
-
 
1143
 
1187
        ret
1144
uglobal
1188
endp
1145
  idlemem               dd   0x0
1189
 
Line -... Line 1190...
-
 
1190
uglobal
-
 
1191
align 4
-
 
1192
osloop_nonperiodic_work dd      ?
-
 
1193
endg
-
 
1194
 
-
 
1195
align 4
-
 
1196
idle_thread:
Line 1146... Line 1197...
1146
  idleuse               dd   0x0
1197
        sti
1147
  idleusesec            dd   0x0
1198
idle_loop:
1148
  check_idle_semaphore  dd   0x0
1199
        hlt
Line 1193... Line 1244...
1193
 
1244
 
Line 1194... Line 1245...
1194
        ret
1245
        ret
1195
 
1246
 
1196
 
1247
 
Line 1197... Line 1248...
1197
iglobal
1248
iglobal
Line 1198... Line 1249...
1198
  process_number dd 0x1
1249
  process_number dd 0x2
Line 1210... Line 1261...
1210
        shr     ax, 1
1261
        shr     ax, 1
1211
        shl     eax, 16
1262
        shl     eax, 16
1212
        mov     ax, [BOOT_VAR+BOOT_X_RES]
1263
        mov     ax, [BOOT_VAR+BOOT_X_RES]
1213
        shr     ax, 1
1264
        shr     ax, 1
1214
        mov     [MOUSE_X], eax
1265
        mov     [MOUSE_X], eax
-
 
1266
        call    wakeup_osloop
Line 1215... Line 1267...
1215
 
1267
 
1216
        xor     eax, eax
1268
        xor     eax, eax
Line 1217... Line -...
1217
        mov     [BTN_ADDR], dword BUTTON_INFO ; address of button list
-
 
1218
 
1269
        mov     [BTN_ADDR], dword BUTTON_INFO ; address of button list
1219
        mov     byte [MOUSE_BUFF_COUNT], al              ; mouse buffer
1270
 
1220
        mov     byte [KEY_COUNT], al              ; keyboard buffer
1271
        mov     byte [KEY_COUNT], al              ; keyboard buffer
Line 1221... Line 1272...
1221
        mov     byte [BTN_COUNT], al              ; button buffer
1272
        mov     byte [BTN_COUNT], al              ; button buffer
1222
;        mov   [MOUSE_X],dword 100*65536+100    ; mouse x/y
1273
;        mov   [MOUSE_X],dword 100*65536+100    ; mouse x/y
1223
 
1274
 
1224
     ;!! IP 04.02.2005:
1275
     ;!! IP 04.02.2005:
Line 1225... Line 1276...
1225
        mov     byte [DONT_SWITCH], al; change task if possible
1276
;        mov     byte [DONT_SWITCH], al; change task if possible
1226
        pop     eax
1277
        pop     eax
Line 1990... Line 2041...
1990
        mov     ecx, [current_slot]
2041
        mov     ecx, [current_slot]
1991
        call    restore_default_cursor_before_killing
2042
        call    restore_default_cursor_before_killing
1992
        popa
2043
        popa
1993
@@:
2044
@@:
1994
;--------------------------------------
2045
;--------------------------------------
-
 
2046
; kill all sockets this process owns
-
 
2047
        pusha
-
 
2048
        mov     edx, [TASK_BASE]
-
 
2049
        mov     edx, [edx+TASKDATA.pid]
-
 
2050
        call    SOCKET_process_end
-
 
2051
        popa
-
 
2052
;--------------------------------------
1995
        mov     ecx, [current_slot]
2053
        mov     ecx, [current_slot]
1996
        mov     eax, [ecx+APPDATA.tls_base]
2054
        mov     eax, [ecx+APPDATA.tls_base]
1997
        test    eax, eax
2055
        test    eax, eax
1998
        jz      @F
2056
        jz      @F
Line 1999... Line 2057...
1999
 
2057
 
2000
        stdcall user_free, eax
2058
        stdcall user_free, eax
Line 2001... Line 2059...
2001
@@:
2059
@@:
2002
 
2060
 
-
 
2061
        mov     eax, [TASK_BASE]
Line 2003... Line 2062...
2003
        mov     eax, [TASK_BASE]
2062
        mov     [eax+TASKDATA.state], 3; terminate this program
2004
        mov     [eax+TASKDATA.state], 3; terminate this program
2063
        call    wakeup_osloop
2005
 
2064
 
2006
    waitterm:            ; wait here for termination
2065
    waitterm:            ; wait here for termination
Line 2033... Line 2092...
2033
        push    esi
2092
        push    esi
2034
        call    [_display.select_cursor]
2093
        call    [_display.select_cursor]
2035
        mov     [current_cursor], esi
2094
        mov     [current_cursor], esi
2036
@@:
2095
@@:
2037
        mov     [redrawmouse_unconditional], 1
2096
        mov     [redrawmouse_unconditional], 1
-
 
2097
        call    wakeup_osloop
2038
        popfd
2098
        popfd
2039
        ret
2099
        ret
2040
;------------------------------------------------------------------------------
2100
;------------------------------------------------------------------------------
2041
iglobal
2101
iglobal
2042
align 4
2102
align 4
Line 2085... Line 2145...
2085
        mov     [BOOT_VAR+0x9030], cl
2145
        mov     [BOOT_VAR+0x9030], cl
Line 2086... Line 2146...
2086
 
2146
 
2087
        mov     eax, [TASK_COUNT]
2147
        mov     eax, [TASK_COUNT]
2088
        mov     [SYS_SHUTDOWN], al
2148
        mov     [SYS_SHUTDOWN], al
-
 
2149
        mov     [shutdown_processes], eax
2089
        mov     [shutdown_processes], eax
2150
        call    wakeup_osloop
2090
        and     dword [esp+32], 0
2151
        and     dword [esp+32], 0
2091
 exit_for_anyone:
2152
 exit_for_anyone:
2092
        ret
2153
        ret
2093
  uglobal
2154
  uglobal
Line 2113... Line 2174...
2113
        call    request_terminate
2174
        call    request_terminate
2114
        pop     edx ecx
2175
        pop     edx ecx
2115
        test    eax, eax
2176
        test    eax, eax
2116
        jz      noprocessterminate
2177
        jz      noprocessterminate
2117
;--------------------------------------
2178
;--------------------------------------
-
 
2179
; terminate all network sockets it used
-
 
2180
        pusha
-
 
2181
        mov     eax, edx
-
 
2182
        call    SOCKET_process_end
-
 
2183
        popa
-
 
2184
;--------------------------------------
2118
        cmp     [_display.select_cursor], 0
2185
        cmp     [_display.select_cursor], 0
2119
        je      .restore_end
2186
        je      .restore_end
2120
; restore default cursor before killing
2187
; restore default cursor before killing
2121
        pusha
2188
        pusha
2122
        mov     ecx, [esp+32]
2189
        mov     ecx, [esp+32]
Line 2130... Line 2197...
2130
        popa
2197
        popa
2131
.restore_end:
2198
.restore_end:
2132
;--------------------------------------
2199
;--------------------------------------
2133
     ;call MEM_Heap_Lock      ;guarantee that process isn't working with heap
2200
     ;call MEM_Heap_Lock      ;guarantee that process isn't working with heap
2134
        mov     [ecx], byte 3; clear possible i40's
2201
        mov     [ecx], byte 3; clear possible i40's
-
 
2202
        call    wakeup_osloop
2135
     ;call MEM_Heap_UnLock
2203
     ;call MEM_Heap_UnLock
Line 2136... Line 2204...
2136
 
2204
 
2137
        cmp     edx, [application_table_status]; clear app table stat
2205
        cmp     edx, [application_table_owner]; clear app table stat
2138
        jne     noatsc
2206
        jne     noatsc
2139
        and     [application_table_status], 0
2207
        call    unlock_application_table
2140
noatsc:
2208
noatsc:
2141
noprocessterminate:
2209
noprocessterminate:
2142
        add     esp, 4
2210
        add     esp, 4
2143
        ret
2211
        ret
2144
;------------------------------------------------------------------------------
2212
;------------------------------------------------------------------------------
2145
sysfn_terminate2:
2213
sysfn_terminate2:
2146
;lock application_table_status mutex
2214
;lock application_table_status mutex
2147
.table_status:
-
 
2148
        cli
-
 
2149
        cmp     [application_table_status], 0
-
 
2150
        je      .stf
-
 
2151
        sti
-
 
2152
        call    change_task
-
 
2153
        jmp     .table_status
-
 
2154
.stf:
2215
.table_status:
2155
        call    set_application_table_status
2216
        call    lock_application_table
2156
        mov     eax, ecx
2217
        mov     eax, ecx
2157
        call    pid_to_slot
2218
        call    pid_to_slot
2158
        test    eax, eax
2219
        test    eax, eax
2159
        jz      .not_found
2220
        jz      .not_found
2160
        mov     ecx, eax
2221
        mov     ecx, eax
2161
        cli
2222
        cli
2162
        call    sysfn_terminate
2223
        call    sysfn_terminate
2163
        and     [application_table_status], 0
2224
        call    unlock_application_table
2164
        sti
2225
        sti
2165
        and     dword [esp+32], 0
2226
        and     dword [esp+32], 0
2166
        ret
2227
        ret
2167
.not_found:
2228
.not_found:
2168
        mov     [application_table_status], 0
2229
        call    unlock_application_table
2169
        or      dword [esp+32], -1
2230
        or      dword [esp+32], -1
2170
        ret
2231
        ret
2171
;------------------------------------------------------------------------------
2232
;------------------------------------------------------------------------------
2172
sysfn_deactivate:         ; 18.1 = DEACTIVATE WINDOW
2233
sysfn_deactivate:         ; 18.1 = DEACTIVATE WINDOW
Line 2184... Line 2245...
2184
        add     edi, window_data
2245
        add     edi, window_data
2185
        movzx   esi, word [WIN_STACK + ecx * 2]
2246
        movzx   esi, word [WIN_STACK + ecx * 2]
2186
        lea     esi, [WIN_POS + esi * 2]
2247
        lea     esi, [WIN_POS + esi * 2]
2187
        call    window._.window_deactivate
2248
        call    window._.window_deactivate
Line 2188... Line -...
2188
 
-
 
2189
        xor     eax, eax
-
 
2190
        mov     byte[MOUSE_BACKGROUND], al
-
 
2191
        mov     byte[DONT_DRAW_MOUSE], al
-
 
2192
        mov     byte[MOUSE_DOWN], 0
-
 
2193
 
2249
 
2194
        call    syscall_display_settings._.calculate_whole_screen
2250
        call    syscall_display_settings._.calculate_whole_screen
2195
        call    syscall_display_settings._.redraw_whole_screen
2251
        call    syscall_display_settings._.redraw_whole_screen
2196
.nowindowdeactivate:
2252
.nowindowdeactivate:
2197
        ret
2253
        ret
Line 2212... Line 2268...
2212
        call    change_task
2268
        call    change_task
2213
        jmp     @b
2269
        jmp     @b
2214
@@:
2270
@@:
2215
;-------------------------------------
2271
;-------------------------------------
2216
        mov     [window_minimize], 2; restore window if minimized
2272
        mov     [window_minimize], 2; restore window if minimized
-
 
2273
        call    wakeup_osloop
Line 2217... Line 2274...
2217
 
2274
 
2218
        movzx   esi, word [WIN_STACK + ecx*2]
2275
        movzx   esi, word [WIN_STACK + ecx*2]
2219
        cmp     esi, [TASK_COUNT]
2276
        cmp     esi, [TASK_COUNT]
Line 2227... Line 2284...
2227
        call    waredraw
2284
        call    waredraw
2228
.nowindowactivate:
2285
.nowindowactivate:
2229
        ret
2286
        ret
2230
;------------------------------------------------------------------------------
2287
;------------------------------------------------------------------------------
2231
sysfn_getidletime:              ; 18.4 = GET IDLETIME
2288
sysfn_getidletime:              ; 18.4 = GET IDLETIME
2232
        mov     eax, [idleusesec]
2289
        mov     eax, [CURRENT_TASK+32+TASKDATA.cpu_usage]
2233
        mov     [esp+32], eax
2290
        mov     [esp+32], eax
2234
        ret
2291
        ret
2235
;------------------------------------------------------------------------------
2292
;------------------------------------------------------------------------------
2236
sysfn_getcpuclock:              ; 18.5 = GET TSC/SEC
2293
sysfn_getcpuclock:              ; 18.5 = GET TSC/SEC
2237
        mov     eax, dword [cpu_freq]
2294
        mov     eax, dword [cpu_freq]
Line 2269... Line 2326...
2269
 nosoundflag:
2326
 nosoundflag:
2270
        ret
2327
        ret
2271
;------------------------------------------------------------------------------
2328
;------------------------------------------------------------------------------
2272
sysfn_minimize:         ; 18.10 = minimize window
2329
sysfn_minimize:         ; 18.10 = minimize window
2273
        mov     [window_minimize], 1
2330
        mov     [window_minimize], 1
-
 
2331
        call    wakeup_osloop
2274
        ret
2332
        ret
2275
;------------------------------------------------------------------------------
2333
;------------------------------------------------------------------------------
2276
align 4
2334
align 4
2277
sysfn_getdiskinfo:      ; 18.11 = get disk info table
2335
sysfn_getdiskinfo:      ; 18.11 = get disk info table
2278
;     cmp  ecx,1
2336
;     cmp  ecx,1
Line 2331... Line 2389...
2331
        shr     eax, 1
2389
        shr     eax, 1
2332
        mov     [MOUSE_X], ax
2390
        mov     [MOUSE_X], ax
2333
        mov     eax, [Screen_Max_Y]
2391
        mov     eax, [Screen_Max_Y]
2334
        shr     eax, 1
2392
        shr     eax, 1
2335
        mov     [MOUSE_Y], ax
2393
        mov     [MOUSE_Y], ax
-
 
2394
        call    wakeup_osloop
2336
;        ret
2395
;        ret
2337
;* mouse centered - end code- Mario79
2396
;* mouse centered - end code- Mario79
2338
        xor     eax, eax
2397
        xor     eax, eax
2339
        and     [esp+32], eax
2398
        and     [esp+32], eax
2340
;        pop   eax
2399
;        pop   eax
Line 2375... Line 2434...
2375
        ja      .end
2434
        ja      .end
2376
        rol     edx, 16
2435
        rol     edx, 16
2377
        cmp     dx, word[Screen_Max_X]
2436
        cmp     dx, word[Screen_Max_X]
2378
        ja      .end
2437
        ja      .end
2379
        mov     [MOUSE_X], edx
2438
        mov     [MOUSE_X], edx
-
 
2439
        call    wakeup_osloop
2380
        ret
2440
        ret
2381
 .set_mouse_button:
2441
 .set_mouse_button:
2382
;     cmp   ecx,5  ; set mouse button features
2442
;     cmp   ecx,5  ; set mouse button features
2383
        dec     ecx
2443
        dec     ecx
2384
        jnz     .end
2444
        jnz     .end
2385
        mov     [BTN_DOWN], dl
2445
        mov     [BTN_DOWN], dl
2386
        mov     [mouse_active], 1
2446
        mov     [mouse_active], 1
-
 
2447
        call    wakeup_osloop
2387
 .end:
2448
 .end:
2388
        ret
2449
        ret
2389
;------------------------------------------------------------------------------
2450
;------------------------------------------------------------------------------
2390
sysfn_getfreemem:
2451
sysfn_getfreemem:
2391
        mov     eax, [pg_data.pages_free]
2452
        mov     eax, [pg_data.pages_free]
Line 2797... Line 2858...
2797
align 4
2858
align 4
2798
nosb7:
2859
nosb7:
2799
        cmp     ebx, 8
2860
        cmp     ebx, 8
2800
        jnz     nosb8
2861
        jnz     nosb8
Line 2801... Line 2862...
2801
 
2862
 
-
 
2863
        mov     ecx, [current_slot]
-
 
2864
        xor     eax, eax
2802
        mov     eax, [BG_Rect_X_left_right]
2865
        xchg    eax, [ecx+APPDATA.draw_bgr_x]
-
 
2866
        mov     [esp + 32], eax ; eax = [left]*65536 + [right]
2803
        mov     [esp + 32], eax ; eax = [left]*65536 + [right]
2867
        xor     eax, eax
2804
        mov     eax, [BG_Rect_Y_top_bottom]
2868
        xchg    eax, [ecx+APPDATA.draw_bgr_y]
2805
        mov     [esp + 20], eax ; ebx = [top]*65536 + [bottom]
2869
        mov     [esp + 20], eax ; ebx = [top]*65536 + [bottom]
2806
        ret
2870
        ret
2807
;------------------------------------------------------------------------------
2871
;------------------------------------------------------------------------------
2808
align 4
2872
align 4
Line 2841... Line 2905...
2841
 
2905
 
2842
        mov     [draw_data+32 + RECT.right], ecx
2906
        mov     [draw_data+32 + RECT.right], ecx
Line 2843... Line 2907...
2843
        mov     [draw_data+32 + RECT.bottom], edx
2907
        mov     [draw_data+32 + RECT.bottom], edx
-
 
2908
 
2844
 
2909
        inc     byte[REDRAW_BACKGROUND]
2845
        inc     byte[REDRAW_BACKGROUND]
2910
        call    wakeup_osloop
2846
;--------------------------------------
2911
;--------------------------------------
2847
align 4
2912
align 4
2848
.exit:
2913
.exit:
Line 2867... Line 2932...
2867
        mov     ebx, [Screen_Max_Y]
2932
        mov     ebx, [Screen_Max_Y]
2868
        mov     [draw_data+32 + RECT.right], eax
2933
        mov     [draw_data+32 + RECT.right], eax
2869
        mov     [draw_data+32 + RECT.bottom], ebx
2934
        mov     [draw_data+32 + RECT.bottom], ebx
2870
        pop     ebx eax
2935
        pop     ebx eax
2871
        inc     byte[REDRAW_BACKGROUND]
2936
        inc     byte[REDRAW_BACKGROUND]
-
 
2937
        call    wakeup_osloop
2872
        ret
2938
        ret
2873
;------------------------------------------------------------------------------
2939
;------------------------------------------------------------------------------
2874
align 4
2940
align 4
2875
sys_getbackground:
2941
sys_getbackground:
2876
;    cmp   eax,1                                  ; SIZE
2942
;    cmp   eax,1                                  ; SIZE
2877
        dec     ebx
2943
        dec     ebx
2878
        jnz     nogb1
2944
        jnz     nogb1
2879
        mov     eax, [BgrDataWidth]
2945
        mov     eax, [BgrDataWidth]
2880
        shl     eax, 16
2946
        shl     eax, 16
2881
        mov     ax, [BgrDataHeight]
2947
        mov     ax, word [BgrDataHeight]
2882
        mov     [esp+32], eax
2948
        mov     [esp+32], eax
2883
        ret
2949
        ret
2884
;------------------------------------------------------------------------------
2950
;------------------------------------------------------------------------------
2885
align 4
2951
align 4
2886
nogb1:
2952
nogb1:
Line 3292... Line 3358...
3292
.04:
3358
.04:
3293
;.wrmsr_instr:
3359
;.wrmsr_instr:
3294
;now counter in ecx
3360
;now counter in ecx
3295
;(edx:eax) esi:edi => edx:esi
3361
;(edx:eax) esi:edi => edx:esi
3296
        ; Fast Call MSR can't be destroy
3362
        ; Fast Call MSR can't be destroy
3297
        ; ® MSR_AMD_EFER ¬®¦­® ¨§¬¥­ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è
3363
        ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш
3298
        ; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥­­ë¥ ¢®§¬®¦­®áâ¨
3364
        ; включаются/выключаются расширенные возможности
3299
        cmp     edx, MSR_SYSENTER_CS
3365
        cmp     edx, MSR_SYSENTER_CS
3300
        je      @f
3366
        je      @f
3301
        cmp     edx, MSR_SYSENTER_ESP
3367
        cmp     edx, MSR_SYSENTER_ESP
3302
        je      @f
3368
        je      @f
3303
        cmp     edx, MSR_SYSENTER_EIP
3369
        cmp     edx, MSR_SYSENTER_EIP
Line 3449... Line 3515...
3449
 
3515
 
3450
        cmp     [background_defined], 0
3516
        cmp     [background_defined], 0
3451
        jz      nobackgr
3517
        jz      nobackgr
3452
;--------------------------------------
3518
;--------------------------------------
3453
align 4
3519
align 4
3454
@@:
-
 
3455
        push    eax
3520
backgr:
3456
        mov     eax, [draw_data+32 + RECT.left]
3521
        mov     eax, [draw_data+32 + RECT.left]
3457
        shl     eax, 16
3522
        shl     eax, 16
3458
        add     eax, [draw_data+32 + RECT.right]
3523
        add     eax, [draw_data+32 + RECT.right]
Line 3459... Line 3524...
3459
        mov     [BG_Rect_X_left_right], eax ; [left]*65536 + [right]
3524
        mov     [BG_Rect_X_left_right], eax ; [left]*65536 + [right]
3460
 
3525
 
3461
        mov     eax, [draw_data+32 + RECT.top]
3526
        mov     eax, [draw_data+32 + RECT.top]
3462
        shl     eax, 16
3527
        shl     eax, 16
3463
        add     eax, [draw_data+32 + RECT.bottom]
-
 
Line 3464... Line 3528...
3464
        mov     [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom]
3528
        add     eax, [draw_data+32 + RECT.bottom]
3465
        pop     eax
3529
        mov     [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom]
3466
 
3530
 
3467
        call    drawbackground
3531
        call    drawbackground
Line 3474... Line 3538...
3474
        mov     ecx, [TASK_COUNT]
3538
        mov     ecx, [TASK_COUNT]
3475
;--------------------------------------
3539
;--------------------------------------
3476
align 4
3540
align 4
3477
set_bgr_event:
3541
set_bgr_event:
3478
        add     edi, 256
3542
        add     edi, 256
-
 
3543
        mov     eax, [BG_Rect_X_left_right]
-
 
3544
        mov     edx, [BG_Rect_Y_top_bottom]
-
 
3545
        cmp     [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0
-
 
3546
        jz      .set
-
 
3547
.join:
-
 
3548
        cmp     word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax
-
 
3549
        jbe     @f
-
 
3550
        mov     word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax
-
 
3551
@@:
-
 
3552
        shr     eax, 16
-
 
3553
        cmp     word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax
-
 
3554
        jae     @f
-
 
3555
        mov     word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax
-
 
3556
@@:
-
 
3557
        cmp     word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx
-
 
3558
        jbe     @f
-
 
3559
        mov     word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx
-
 
3560
@@:
-
 
3561
        shr     edx, 16
-
 
3562
        cmp     word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx
-
 
3563
        jae     @f
-
 
3564
        mov     word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx
-
 
3565
@@:
-
 
3566
        jmp     .common
-
 
3567
.set:
-
 
3568
        mov     [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax
-
 
3569
        mov     [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx
-
 
3570
.common:
3479
        or      [edi+SLOT_BASE+APPDATA.event_mask], 10000b  ; set event 5
3571
        or      [edi+SLOT_BASE+APPDATA.event_mask], 10000b  ; set event 5
3480
        loop    set_bgr_event
3572
        loop    set_bgr_event
3481
        pop     edi ecx
3573
        pop     edi ecx
3482
; call change_task - because the application must have time to call f.15.8
-
 
3483
        call    change_task
-
 
3484
;--------- set event 5 stop -----------
3574
;--------- set event 5 stop -----------
3485
        dec     byte[REDRAW_BACKGROUND]    ; got new update request?
3575
        dec     byte[REDRAW_BACKGROUND]    ; got new update request?
3486
        jnz     @b
3576
        jnz     backgr
Line -... Line 3577...
-
 
3577
 
3487
 
3578
        xor     eax, eax
3488
        mov     [draw_data+32 + RECT.left], eax
3579
        mov     [draw_data+32 + RECT.left], eax
3489
        mov     [draw_data+32 + RECT.top], eax
3580
        mov     [draw_data+32 + RECT.top], eax
3490
        mov     [draw_data+32 + RECT.right], eax
3581
        mov     [draw_data+32 + RECT.right], eax
3491
        mov     [draw_data+32 + RECT.bottom], eax
-
 
3492
        mov     [MOUSE_BACKGROUND], byte 0
3582
        mov     [draw_data+32 + RECT.bottom], eax
3493
;--------------------------------------
3583
;--------------------------------------
3494
align 4
3584
align 4
3495
nobackgr:
3585
nobackgr:
3496
; system shutdown request
3586
; system shutdown request
Line 3525... Line 3615...
3525
        jz      @f
3615
        jz      @f
3526
        mov     [edx+TASKDATA.state], byte 3
3616
        mov     [edx+TASKDATA.state], byte 3
3527
@@:
3617
@@:
3528
        add     edx, 0x20
3618
        add     edx, 0x20
3529
        loop    markz
3619
        loop    markz
-
 
3620
        call    wakeup_osloop
3530
;--------------------------------------
3621
;--------------------------------------
3531
align 4
3622
align 4
3532
@@:
3623
@@:
3533
no_mark_system_shutdown:
3624
no_mark_system_shutdown:
3534
        dec     byte [SYS_SHUTDOWN]
3625
        dec     byte [SYS_SHUTDOWN]
Line 3676... Line 3767...
3676
        mov     dl, 1
3767
        mov     dl, 1
3677
;--------------------------------------
3768
;--------------------------------------
3678
align 4
3769
align 4
3679
@@:
3770
@@:
3680
        add     byte[REDRAW_BACKGROUND], dl
3771
        add     byte[REDRAW_BACKGROUND], dl
-
 
3772
        call    wakeup_osloop
3681
        jmp     newdw8
3773
        jmp     newdw8
3682
;--------------------------------------
3774
;--------------------------------------
3683
align 4
3775
align 4
3684
.az:
3776
.az:
3685
        mov     eax, edi
3777
        mov     eax, edi
Line 3697... Line 3789...
3697
        sub     eax, draw_data-window_data
3789
        sub     eax, draw_data-window_data
Line 3698... Line 3790...
3698
 
3790
 
3699
        cmp     dword [esp], 1
3791
        cmp     dword [esp], 1
3700
        jne     nobgrd
3792
        jne     nobgrd
-
 
3793
        inc     byte[REDRAW_BACKGROUND]
3701
        inc     byte[REDRAW_BACKGROUND]
3794
        call    wakeup_osloop
3702
;--------------------------------------
3795
;--------------------------------------
3703
align 4
3796
align 4
3704
newdw8:
3797
newdw8:
Line 4668... Line 4761...
4668
        pop     ax dx
4761
        pop     ax dx
Line 4669... Line 4762...
4669
 
4762
 
Line 4670... Line 4763...
4670
end if
4763
end if
-
 
4764
 
-
 
4765
        mov     [msg_board_data+ecx], bl
-
 
4766
if debug_direct_print
-
 
4767
        pusha
-
 
4768
iglobal
-
 
4769
msg_board_pos   dd      234*65536+10
-
 
4770
endg
-
 
4771
        lea     edx, [msg_board_data+ecx]
-
 
4772
        mov     ecx, 0x40FFFFFF
-
 
4773
        mov     ebx, [msg_board_pos]
-
 
4774
        mov     edi, 1
-
 
4775
        mov     esi, 1
-
 
4776
        call    dtext
-
 
4777
        popa
-
 
4778
        add     word [msg_board_pos+2], 6
-
 
4779
        cmp     bl, 10
-
 
4780
        jnz     @f
-
 
4781
        mov     word [msg_board_pos+2], 234
-
 
4782
        add     word [msg_board_pos], 10
-
 
4783
        mov     ax, [Screen_Max_Y]
-
 
4784
        cmp     word [msg_board_pos], ax
-
 
4785
        jbe     @f
-
 
4786
        mov     word [msg_board_pos], 10
-
 
4787
@@:
-
 
4788
end if
-
 
4789
if 0
-
 
4790
        pusha
-
 
4791
        mov     al, bl
-
 
4792
        mov     edx, 402h
-
 
4793
        out     dx, al
4671
 
4794
        popa
4672
        mov     [msg_board_data+ecx], bl
4795
end if
4673
        inc     ecx
4796
        inc     ecx
4674
        and     ecx, msg_board_data_size - 1
-
 
4675
        mov     [msg_board_count], ecx
4797
        and     ecx, msg_board_data_size - 1
4676
        mov     [check_idle_semaphore], 5
4798
        mov     [msg_board_count], ecx
4677
        ret
4799
        ret
4678
.smbl1:
4800
.smbl1:
4679
        cmp     eax, 2
4801
        cmp     eax, 2
Line 4871... Line 4993...
4871
 
4993
 
4872
 
4994
 
4873
.1:                             ; resolution
4995
.1:                             ; resolution
4874
        mov     eax, [Screen_Max_X]
4996
        mov     eax, [Screen_Max_X]
4875
        shl     eax, 16
4997
        shl     eax, 16
4876
        mov     ax, [Screen_Max_Y]
4998
        mov     ax, word [Screen_Max_Y]
4877
        add     eax, 0x00010001
4999
        add     eax, 0x00010001
4878
        mov     [esp+32], eax
5000
        mov     [esp+32], eax
4879
        ret
5001
        ret
4880
.2:                             ; bits per pixel
5002
.2:                             ; bits per pixel
4881
        movzx   eax, byte [ScreenBPP]
5003
        mov     eax, [_display.bpp]
4882
        mov     [esp+32], eax
5004
        mov     [esp+32], eax
4883
        ret
5005
        ret
4884
.3:                             ; bytes per scanline
5006
.3:                             ; bytes per scanline
Line 4970... Line 5092...
4970
.drectr:
5092
.drectr:
4971
        ret
5093
        ret
Line 4972... Line 5094...
4972
 
5094
 
4973
align 4
5095
align 4
4974
syscall_getscreensize:                  ; GetScreenSize
5096
syscall_getscreensize:                  ; GetScreenSize
4975
        mov     ax, [Screen_Max_X]
5097
        mov     eax, [Screen_Max_X]
4976
        shl     eax, 16
5098
        shl     eax, 16
4977
        mov     ax, [Screen_Max_Y]
5099
        mov     ax, word [Screen_Max_Y]
4978
        mov     [esp + 32], eax
5100
        mov     [esp + 32], eax
Line 4979... Line 5101...
4979
        ret
5101
        ret
Line 5263... Line 5385...
5263
        mov     [esp+32], eax
5385
        mov     [esp+32], eax
5264
        ret
5386
        ret
Line 5265... Line 5387...
5265
 
5387
 
Line 5266... Line -...
5266
align 4
-
 
5267
 
-
 
5268
stack_driver_stat:
-
 
5269
 
-
 
5270
        call    app_stack_handler       ; Stack status
-
 
5271
 
-
 
5272
;     mov   [check_idle_semaphore],5    ; enable these for zero delay
-
 
5273
;     call  change_task                 ; between sent packet
-
 
5274
 
-
 
5275
        mov     [esp+32], eax
-
 
5276
        ret
-
 
5277
 
-
 
5278
align 4
-
 
5279
 
-
 
5280
socket:                                 ; Socket interface
-
 
5281
        call    app_socket_handler
-
 
5282
 
-
 
5283
;     mov   [check_idle_semaphore],5    ; enable these for zero delay
-
 
5284
;     call  change_task                 ; between sent packet
-
 
5285
 
-
 
5286
        mov     [esp+36], eax
-
 
5287
        mov     [esp+24], ebx
-
 
5288
        ret
5388
align 4
5289
 
5389
 
5290
paleholder:
5390
paleholder:
5291
        ret
5391
        ret
5292
;------------------------------------------------------------------------------
5392
;------------------------------------------------------------------------------