Subversion Repositories Kolibri OS

Rev

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

Rev 9692 Rev 9709
Line 75... Line 75...
75
format binary as "mnt"
75
format binary as "mnt"
Line 76... Line 76...
76
 
76
 
77
include 'macros.inc'
77
include 'macros.inc'
Line 78... Line 78...
78
include 'struct.inc'
78
include 'struct.inc'
Line 79... Line 79...
79
 
79
 
80
$Revision: 9692 $
80
$Revision: 9709 $
Line 628... Line 628...
628
        call    scheduler_add_thread
628
        call    scheduler_add_thread
Line 629... Line 629...
629
 
629
 
630
        mov     dword [current_slot_idx], 2
630
        mov     dword [current_slot_idx], 2
631
        mov     [thread_count], 2
631
        mov     [thread_count], 2
632
        mov     dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
-
 
Line 633... Line 632...
633
        mov     dword [TASK_BASE], TASK_TABLE + sizeof.TASKDATA*2
632
        mov     dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
634
 
633
 
635
; Move other CPUs to deep sleep, if it is useful
634
; Move other CPUs to deep sleep, if it is useful
636
uglobal
635
uglobal
Line 1930... Line 1929...
1930
        stdcall user_free, eax
1929
        stdcall user_free, eax
1931
@@:
1930
@@:
Line 1932... Line 1931...
1932
 
1931
 
1933
        mov     eax, [current_slot]
1932
        mov     eax, [current_slot]
1934
        mov     [eax+APPDATA.state], TSTATE_ZOMBIE
-
 
1935
        mov     eax, [TASK_BASE]                       ;
-
 
1936
        mov     [eax+TASKDATA.state], TSTATE_ZOMBIE    ; delete
1933
        mov     [eax+APPDATA.state], TSTATE_ZOMBIE
Line 1937... Line 1934...
1937
        call    wakeup_osloop
1934
        call    wakeup_osloop
1938
 
1935
 
1939
.waitterm:            ; wait here for termination
1936
.waitterm:            ; wait here for termination
Line 1951... Line 1948...
1951
        movzx   ebx, word [MOUSE_X]
1948
        movzx   ebx, word [MOUSE_X]
1952
        mov     eax, [d_width_calc_area + eax*4]
1949
        mov     eax, [d_width_calc_area + eax*4]
Line 1953... Line 1950...
1953
 
1950
 
1954
        add     eax, [_display.win_map]
1951
        add     eax, [_display.win_map]
1955
        movzx   edx, byte [ebx+eax]
1952
        movzx   edx, byte [ebx+eax]
1956
        shl     edx, 8
1953
        shl     edx, BSF sizeof.APPDATA
Line 1957... Line 1954...
1957
        mov     esi, [edx+SLOT_BASE+APPDATA.cursor]
1954
        mov     esi, [edx+SLOT_BASE+APPDATA.cursor]
1958
 
1955
 
Line 2041... Line 2038...
2041
        jb      noprocessterminate
2038
        jb      noprocessterminate
2042
        mov     edx, [thread_count]
2039
        mov     edx, [thread_count]
2043
        cmp     ecx, edx
2040
        cmp     ecx, edx
2044
        ja      noprocessterminate
2041
        ja      noprocessterminate
2045
        mov     eax, [thread_count]
2042
        mov     eax, [thread_count]
2046
        shl     ecx, BSF sizeof.TASKDATA
2043
        shl     ecx, BSF sizeof.APPDATA
2047
        mov     edx, [ecx*8 + SLOT_BASE + APPDATA.tid]
2044
        add     ecx, SLOT_BASE
2048
        add     ecx, TASK_TABLE+TASKDATA.state
2045
        mov     edx, [ecx + APPDATA.tid]
2049
        cmp     byte [ecx], TSTATE_FREE
2046
        cmp     byte [ecx + APPDATA.state], TSTATE_FREE
2050
        jz      noprocessterminate
2047
        jz      noprocessterminate
2051
        push    eax
2048
        push    eax
2052
        lea     eax, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
2049
        mov     eax, ecx
2053
        call    is_kernel_thread
2050
        call    is_kernel_thread
2054
        pop     eax
2051
        pop     eax
2055
        jz      noprocessterminate
2052
        jz      noprocessterminate
2056
        push    ecx edx
2053
        push    ecx edx
2057
        lea     edx, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
2054
        mov     edx, ecx
2058
        call    request_terminate
2055
        call    request_terminate
2059
        pop     edx ecx
2056
        pop     edx ecx
2060
        test    eax, eax
2057
        test    eax, eax
2061
        jz      noprocessterminate
2058
        jz      noprocessterminate
2062
;--------------------------------------
2059
;--------------------------------------
2063
; terminate all network sockets it used
2060
; terminate all network sockets it used
2064
        pusha
2061
        pusha
2065
        mov     eax, edx
2062
        mov     eax, edx     ;TODO: check function
2066
        call    socket_process_end
2063
        call    socket_process_end
2067
        popa
2064
        popa
2068
;--------------------------------------
2065
;--------------------------------------
2069
        cmp     [_display.select_cursor], 0
2066
        cmp     [_display.select_cursor], 0
2070
        je      .restore_end
2067
        je      .restore_end
Line 2080... Line 2077...
2080
@@:
2077
@@:
2081
        popa
2078
        popa
2082
.restore_end:
2079
.restore_end:
2083
;--------------------------------------
2080
;--------------------------------------
2084
     ;call MEM_Heap_Lock      ;guarantee that process isn't working with heap
2081
     ;call MEM_Heap_Lock      ;guarantee that process isn't working with heap
2085
        mov     [ecx], byte 3; clear possible i40's
2082
        mov     [ecx + APPDATA.state], TSTATE_ZOMBIE; clear possible i40's
2086
        call    wakeup_osloop
2083
        call    wakeup_osloop
2087
     ;call MEM_Heap_UnLock
2084
     ;call MEM_Heap_UnLock
Line 2088... Line 2085...
2088
 
2085
 
2089
        cmp     edx, [application_table_owner]; clear app table stat
2086
        cmp     edx, [application_table_owner]; clear app table stat
Line 2187... Line 2184...
2187
        cmp     edx, 1
2184
        cmp     edx, 1
2188
        je      .fail
2185
        je      .fail
Line 2189... Line 2186...
2189
 
2186
 
2190
        mov     eax, edx
2187
        mov     eax, edx
2191
        shl     edx, 5
-
 
Line 2192... Line 2188...
2192
        ;shl     edx, 8
2188
        shl     edx, 5
2193
 
-
 
2194
        ;cmp     [edx + SLOT_BASE + APPDATA.state], TSTATE_FREE
2189
 
Line 2195... Line -...
2195
        cmp     [edx + TASK_TABLE + TASKDATA.state], TSTATE_FREE
-
 
2196
        je      .fail
2190
        cmp     [edx*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE
2197
 
2191
        je      .fail
Line 2198... Line 2192...
2198
        ;shr     edx, 3
2192
 
2199
        cmp     ecx, 1
2193
        cmp     ecx, 1
Line 2663... Line 2657...
2663
        movsd
2657
        movsd
2664
        movsd
2658
        movsd
Line 2665... Line 2659...
2665
 
2659
 
2666
    ; Process state (+50)
2660
    ; Process state (+50)
2667
        movzx   eax, byte [ecx*8 + SLOT_BASE + APPDATA.state]
-
 
2668
        movzx   eax, byte [ecx+TASK_TABLE+TASKDATA.state]
2661
        movzx   eax, byte [ecx*8 + SLOT_BASE + APPDATA.state]
Line 2669... Line 2662...
2669
        stosd
2662
        stosd
2670
 
2663
 
2671
    ; Window client area box
2664
    ; Window client area box
Line 2743... Line 2736...
2743
  no_widgets_away:
2736
  no_widgets_away:
Line 2744... Line 2737...
2744
 
2737
 
2745
        cmp     ebx, 2
2738
        cmp     ebx, 2
Line 2746... Line 2739...
2746
        jnz     srl1
2739
        jnz     srl1
-
 
2740
 
2747
 
2741
        mov     edx, [current_slot_idx]      ; return whole screen draw area for this app
2748
        mov     edx, [TASK_BASE]      ; return whole screen draw area for this app
2742
        shl     edx, 5
2749
        add     edx, draw_data - TASK_TABLE
2743
        add     edx, draw_data
2750
        mov     [edx + RECT.left], 0
2744
        mov     [edx + RECT.left], 0
2751
        mov     [edx + RECT.top], 0
2745
        mov     [edx + RECT.top], 0
2752
        mov     eax, [_display.width]
2746
        mov     eax, [_display.width]
Line 2907... Line 2901...
2907
        cmp     [mouse_active], 1
2901
        cmp     [mouse_active], 1
2908
        jne     mouse_not_active
2902
        jne     mouse_not_active
2909
        mov     [mouse_active], 0
2903
        mov     [mouse_active], 0
Line 2910... Line 2904...
2910
 
2904
 
2911
        xor     edi, edi
2905
        xor     edi, edi
Line 2912... Line 2906...
2912
        mov     ebx, TASK_TABLE
2906
        mov     ebx, window_data
2913
 
2907
 
2914
        mov     ecx, [thread_count]
2908
        mov     ecx, [thread_count]
2915
        movzx   eax, word [WIN_POS + ecx*2]     ; active window
2909
        movzx   eax, word [WIN_POS + ecx*2]     ; active window
Line 2920... Line 2914...
2920
        movzx   edx, word [MOUSE_Y]
2914
        movzx   edx, word [MOUSE_Y]
2921
;--------------------------------------
2915
;--------------------------------------
2922
align 4
2916
align 4
2923
.set_mouse_event:
2917
.set_mouse_event:
2924
        add     edi, sizeof.APPDATA
2918
        add     edi, sizeof.APPDATA
2925
        add     ebx, sizeof.TASKDATA
2919
        add     ebx, sizeof.WDATA
2926
        test    [edi + SLOT_BASE + APPDATA.event_mask], 0x80000000
2920
        test    [edi + SLOT_BASE + APPDATA.event_mask], 0x80000000
2927
        jz      .pos_filter
2921
        jz      .pos_filter
Line 2928... Line 2922...
2928
 
2922
 
2929
        cmp     edi, [esp]                      ; skip if filtration active
2923
        cmp     edi, [esp]                      ; skip if filtration active
Line 2932... Line 2926...
2932
align 4
2926
align 4
2933
.pos_filter:
2927
.pos_filter:
2934
        test    [edi + SLOT_BASE + APPDATA.event_mask], 0x40000000
2928
        test    [edi + SLOT_BASE + APPDATA.event_mask], 0x40000000
2935
        jz      .set
2929
        jz      .set
Line 2936... Line 2930...
2936
 
2930
 
2937
        mov     esi, [ebx-twdw+WDATA.box.left]
2931
        mov     esi, [ebx + WDATA.box.left]
2938
        cmp     eax, esi
2932
        cmp     eax, esi
2939
        jb      .skip
2933
        jb      .skip
2940
        add     esi, [ebx-twdw+WDATA.box.width]
2934
        add     esi, [ebx + WDATA.box.width]
2941
        cmp     eax, esi
2935
        cmp     eax, esi
Line 2942... Line 2936...
2942
        ja      .skip
2936
        ja      .skip
2943
 
2937
 
2944
        mov     esi, [ebx-twdw+WDATA.box.top]
2938
        mov     esi, [ebx + WDATA.box.top]
2945
        cmp     edx, esi
2939
        cmp     edx, esi
2946
        jb      .skip
2940
        jb      .skip
2947
        add     esi, [ebx-twdw+WDATA.box.height]
2941
        add     esi, [ebx + WDATA.box.height]
2948
        cmp     edx, esi
2942
        cmp     edx, esi
2949
        ja      .skip
2943
        ja      .skip
2950
;--------------------------------------
2944
;--------------------------------------
Line 3041... Line 3035...
3041
 
3035
 
3042
        cmp     [SYS_SHUTDOWN], dl
3036
        cmp     [SYS_SHUTDOWN], dl
Line 3043... Line 3037...
3043
        jne     noshutdown
3037
        jne     noshutdown
3044
 
3038
 
3045
        lea     ecx, [edx-1]
3039
        lea     ecx, [edx-1]
3046
        mov     edx, OS_BASE+0x3040
3040
        mov     edx, SLOT_BASE + sizeof.APPDATA ;OS_BASE+0x3040
3047
        jecxz   no_mark_system_shutdown
3041
        jecxz   no_mark_system_shutdown
3048
;--------------------------------------
3042
;--------------------------------------
3049
align 4
3043
align 4
3050
markz:
3044
markz:
3051
        push    ecx edx
3045
        push    ecx edx
3052
        cmp     [edx+TASKDATA.state], TSTATE_FREE
-
 
3053
        jz      .nokill
3046
        cmp     [edx + APPDATA.state], TSTATE_FREE
3054
        lea     edx, [(edx-(TASK_TABLE and 1FFFFFFFh))*8+SLOT_BASE]
3047
        jz      .nokill
3055
        cmp     [edx+APPDATA.process], sys_proc
3048
        cmp     [edx+APPDATA.process], sys_proc
3056
        jz      .nokill
3049
        jz      .nokill
3057
        call    request_terminate
3050
        call    request_terminate
Line 3061... Line 3054...
3061
        xor     eax, eax
3054
        xor     eax, eax
3062
.common:
3055
.common:
3063
        pop     edx ecx
3056
        pop     edx ecx
3064
        test    eax, eax
3057
        test    eax, eax
3065
        jz      @f
3058
        jz      @f
3066
        mov     [edx+TASKDATA.state], TSTATE_ZOMBIE
-
 
3067
        ;mov     [edx+APPDATA.state], TSTATE_ZOMBIE
3059
        mov     [edx + APPDATA.state], TSTATE_ZOMBIE
3068
@@:
3060
@@:
3069
        add     edx, 0x20
3061
        add     edx, sizeof.APPDATA
3070
        loop    markz
3062
        loop    markz
3071
        call    wakeup_osloop
3063
        call    wakeup_osloop
3072
;--------------------------------------
3064
;--------------------------------------
3073
align 4
3065
align 4
3074
@@:
3066
@@:
Line 3077... Line 3069...
3077
        je      system_shutdown
3069
        je      system_shutdown
3078
;--------------------------------------
3070
;--------------------------------------
3079
align 4
3071
align 4
3080
noshutdown:
3072
noshutdown:
3081
        mov     eax, [thread_count]           ; termination
3073
        mov     eax, [thread_count]           ; termination
3082
        mov     ebx, TASK_DATA+TASKDATA.state
3074
        mov     ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state
3083
        mov     esi, 1
3075
        mov     esi, 1
3084
;--------------------------------------
3076
;--------------------------------------
3085
align 4
3077
align 4
3086
newct:
3078
newct:
3087
        mov     cl, [ebx]
3079
        mov     cl, [ebx]
Line 3105... Line 3097...
3105
        jz      .noterminate
3097
        jz      .noterminate
3106
        dec     byte [SYS_SHUTDOWN]
3098
        dec     byte [SYS_SHUTDOWN]
3107
        je      system_shutdown
3099
        je      system_shutdown
Line 3108... Line 3100...
3108
 
3100
 
3109
.noterminate:
3101
.noterminate:
3110
        add     ebx, 0x20
3102
        add     ebx, sizeof.APPDATA
3111
        inc     esi
3103
        inc     esi
3112
        dec     eax
3104
        dec     eax
3113
        jnz     newct
3105
        jnz     newct
3114
        ret
3106
        ret