Subversion Repositories Kolibri OS

Rev

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

Rev 8867 Rev 8869
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: 8867 $
80
$Revision: 8869 $
Line 623... Line 623...
623
        call    setup_os_slot
623
        call    setup_os_slot
624
        mov     dword [edx], 'OS'
624
        mov     dword [edx], 'OS'
625
        xor     ecx, ecx
625
        xor     ecx, ecx
626
        call    scheduler_add_thread
626
        call    scheduler_add_thread
Line 627... Line 627...
627
 
627
 
628
        mov     dword [CURRENT_TASK], 2
628
        mov     dword [current_slot_idx], 2
629
        mov     [thread_count], 2
629
        mov     [thread_count], 2
630
        mov     dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
630
        mov     dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
Line 631... Line 631...
631
        mov     dword [TASK_BASE], CURRENT_TASK + sizeof.TASKDATA*2
631
        mov     dword [TASK_BASE], TASK_TABLE + sizeof.TASKDATA*2
632
 
632
 
633
; Move other CPUs to deep sleep, if it is useful
633
; Move other CPUs to deep sleep, if it is useful
634
uglobal
634
uglobal
Line 1175... Line 1175...
1175
        lea     ecx, [sys_proc+PROC.thr_list]
1175
        lea     ecx, [sys_proc+PROC.thr_list]
1176
        list_add_tail ebx, ecx
1176
        list_add_tail ebx, ecx
Line 1177... Line 1177...
1177
 
1177
 
1178
        mov     eax, edx
1178
        mov     eax, edx
1179
        shr     eax, 3
1179
        shr     eax, 3
1180
        add     eax, CURRENT_TASK - (SLOT_BASE shr 3)
1180
        add     eax, TASK_TABLE - (SLOT_BASE shr 3)
1181
        mov     [eax+TASKDATA.wnd_number], dh
1181
        mov     [eax+TASKDATA.wnd_number], dh
Line 1182... Line 1182...
1182
        mov     byte [eax+TASKDATA.pid], dh
1182
        mov     byte [eax+TASKDATA.pid], dh
1183
 
1183
 
Line 1598... Line 1598...
1598
        add     edx, esp
1598
        add     edx, esp
1599
        mov     ebx, [esp+64+32-8+4]
1599
        mov     ebx, [esp+64+32-8+4]
1600
; add window start x & y
1600
; add window start x & y
1601
        mov     ecx, [TASK_BASE]
1601
        mov     ecx, [TASK_BASE]
Line 1602... Line 1602...
1602
 
1602
 
1603
        mov     edi, [CURRENT_TASK]
1603
        mov     edi, [current_slot_idx]
Line 1604... Line 1604...
1604
        shl     edi, 8
1604
        shl     edi, 8
1605
 
1605
 
1606
        mov     eax, [ecx-twdw+WDATA.box.left]
1606
        mov     eax, [ecx-twdw+WDATA.box.left]
Line 1908... Line 1908...
1908
        mov     esi, [TASK_BASE]
1908
        mov     esi, [TASK_BASE]
1909
        mov     bx, word [esi-twdw+WDATA.box.left]
1909
        mov     bx, word [esi-twdw+WDATA.box.left]
1910
        shl     ebx, 16
1910
        shl     ebx, 16
1911
        mov     bx, word [esi-twdw+WDATA.box.top]
1911
        mov     bx, word [esi-twdw+WDATA.box.top]
1912
        sub     eax, ebx
1912
        sub     eax, ebx
1913
        mov     edi, [CURRENT_TASK]
1913
        mov     edi, [current_slot_idx]
1914
        shl     edi, 8
1914
        shl     edi, 8
1915
        sub     ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
1915
        sub     ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
1916
        rol     eax, 16
1916
        rol     eax, 16
1917
        sub     ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
1917
        sub     ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
1918
        rol     eax, 16
1918
        rol     eax, 16
Line 1966... Line 1966...
1966
        ret
1966
        ret
Line 1967... Line 1967...
1967
 
1967
 
1968
.msz:
1968
.msz:
1969
        mov     edi, [thread_count]
1969
        mov     edi, [thread_count]
1970
        movzx   edi, word [WIN_POS + edi*2]
1970
        movzx   edi, word [WIN_POS + edi*2]
1971
        cmp     edi, [CURRENT_TASK]
1971
        cmp     edi, [current_slot_idx]
1972
        jne     @f
1972
        jne     @f
1973
        mov     ax, [MOUSE_SCROLL_H]
1973
        mov     ax, [MOUSE_SCROLL_H]
1974
        shl     eax, 16
1974
        shl     eax, 16
1975
        mov     ax, [MOUSE_SCROLL_V]
1975
        mov     ax, [MOUSE_SCROLL_V]
Line 2215... Line 2215...
2215
        mov     edx, [thread_count]
2215
        mov     edx, [thread_count]
2216
        cmp     ecx, edx
2216
        cmp     ecx, edx
2217
        ja      noprocessterminate
2217
        ja      noprocessterminate
2218
        mov     eax, [thread_count]
2218
        mov     eax, [thread_count]
2219
        shl     ecx, BSF sizeof.TASKDATA
2219
        shl     ecx, BSF sizeof.TASKDATA
2220
        mov     edx, [ecx+CURRENT_TASK+TASKDATA.pid]
2220
        mov     edx, [ecx+TASK_TABLE+TASKDATA.pid]
2221
        add     ecx, CURRENT_TASK+TASKDATA.state
2221
        add     ecx, TASK_TABLE+TASKDATA.state
2222
        cmp     byte [ecx], TSTATE_FREE
2222
        cmp     byte [ecx], TSTATE_FREE
2223
        jz      noprocessterminate
2223
        jz      noprocessterminate
2224
        push    eax
2224
        push    eax
2225
        lea     eax, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
2225
        lea     eax, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
2226
        call    is_kernel_thread
2226
        call    is_kernel_thread
2227
        pop     eax
2227
        pop     eax
2228
        jz      noprocessterminate
2228
        jz      noprocessterminate
2229
        push    ecx edx
2229
        push    ecx edx
2230
        lea     edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
2230
        lea     edx, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
2231
        call    request_terminate
2231
        call    request_terminate
2232
        pop     edx ecx
2232
        pop     edx ecx
2233
        test    eax, eax
2233
        test    eax, eax
2234
        jz      noprocessterminate
2234
        jz      noprocessterminate
2235
;--------------------------------------
2235
;--------------------------------------
Line 2351... Line 2351...
2351
;1:   eax = z_modif
2351
;1:   eax = z_modif
2352
;2: eax=0(fail),1(success) for set z_modif
2352
;2: eax=0(fail),1(success) for set z_modif
Line 2353... Line 2353...
2353
 
2353
 
2354
        cmp     edx, -1
2354
        cmp     edx, -1
2355
        jne     @f
2355
        jne     @f
2356
        mov     edx, [CURRENT_TASK]
2356
        mov     edx, [current_slot_idx]
2357
     @@:
2357
     @@:
2358
        cmp     edx, [thread_count]
2358
        cmp     edx, [thread_count]
2359
        ja      .fail
2359
        ja      .fail
2360
        cmp     edx, 1
2360
        cmp     edx, 1
Line 2361... Line 2361...
2361
        je      .fail
2361
        je      .fail
2362
 
2362
 
Line 2363... Line 2363...
2363
        mov     eax, edx
2363
        mov     eax, edx
2364
        shl     edx, 5
2364
        shl     edx, 5
Line 2365... Line 2365...
2365
 
2365
 
2366
        cmp     [edx + CURRENT_TASK + TASKDATA.state], 9
2366
        cmp     [edx + TASK_TABLE + TASKDATA.state], 9
Line 2406... Line 2406...
2406
        mov     [esp+32], eax
2406
        mov     [esp+32], eax
2407
        ret
2407
        ret
Line 2408... Line 2408...
2408
 
2408
 
2409
;------------------------------------------------------------------------------
2409
;------------------------------------------------------------------------------
2410
sysfn_getidletime:              ; 18.4 = GET IDLETIME
2410
sysfn_getidletime:              ; 18.4 = GET IDLETIME
2411
        mov     eax, [CURRENT_TASK+32+TASKDATA.cpu_usage]
2411
        mov     eax, [TASK_TABLE+32+TASKDATA.cpu_usage]
2412
        mov     [esp+32], eax
2412
        mov     [esp+32], eax
2413
        ret
2413
        ret
2414
;------------------------------------------------------------------------------
2414
;------------------------------------------------------------------------------
2415
sysfn_getcpuclock:              ; 18.5 = GET TSC/SEC
2415
sysfn_getcpuclock:              ; 18.5 = GET TSC/SEC
Line 2873... Line 2873...
2873
        call    change_task
2873
        call    change_task
2874
        jmp     @b
2874
        jmp     @b
2875
;--------------------------------------
2875
;--------------------------------------
2876
align 4
2876
align 4
2877
@@:
2877
@@:
2878
        mov     eax, [CURRENT_TASK]
2878
        mov     eax, [current_slot_idx]
2879
        mov     [bgrlockpid], eax
2879
        mov     [bgrlockpid], eax
2880
        cmp     [img_background], static_background_data
2880
        cmp     [img_background], static_background_data
2881
        jz      .nomem
2881
        jz      .nomem
2882
        stdcall user_alloc, [mem_BACKGROUND]
2882
        stdcall user_alloc, [mem_BACKGROUND]
2883
        mov     [esp+32], eax
2883
        mov     [esp+32], eax
Line 2921... Line 2921...
2921
nosb6:
2921
nosb6:
2922
        cmp     ebx, 7
2922
        cmp     ebx, 7
2923
        jnz     nosb7
2923
        jnz     nosb7
2924
        cmp     [bgrlock], 0
2924
        cmp     [bgrlock], 0
2925
        jz      .err
2925
        jz      .err
2926
        mov     eax, [CURRENT_TASK]
2926
        mov     eax, [current_slot_idx]
2927
        cmp     [bgrlockpid], eax
2927
        cmp     [bgrlockpid], eax
2928
        jnz     .err
2928
        jnz     .err
2929
        mov     eax, ecx
2929
        mov     eax, ecx
2930
        mov     ebx, ecx
2930
        mov     ebx, ecx
2931
        shr     eax, 12
2931
        shr     eax, 12
Line 3101... Line 3101...
3101
;------------------------------------------------------------------------------
3101
;------------------------------------------------------------------------------
3102
align 4
3102
align 4
3103
sys_getkey:
3103
sys_getkey:
3104
        mov     [esp + 32], dword 1
3104
        mov     [esp + 32], dword 1
3105
        ; test main buffer
3105
        ; test main buffer
3106
        mov     ebx, [CURRENT_TASK]                          ; TOP OF WINDOW STACK
3106
        mov     ebx, [current_slot_idx]                          ; TOP OF WINDOW STACK
3107
        movzx   ecx, word [WIN_STACK + ebx * 2]
3107
        movzx   ecx, word [WIN_STACK + ebx * 2]
3108
        mov     edx, [thread_count]
3108
        mov     edx, [thread_count]
3109
        cmp     ecx, edx
3109
        cmp     ecx, edx
3110
        jne     .finish
3110
        jne     .finish
3111
        cmp     [KEY_COUNT], byte 0
3111
        cmp     [KEY_COUNT], byte 0
Line 3156... Line 3156...
3156
        and     dword [ecx], 0
3156
        and     dword [ecx], 0
3157
        jmp     .ret_eax
3157
        jmp     .ret_eax
3158
;------------------------------------------------------------------------------
3158
;------------------------------------------------------------------------------
3159
align 4
3159
align 4
3160
sys_getbutton:
3160
sys_getbutton:
3161
        mov     ebx, [CURRENT_TASK]                         ; TOP OF WINDOW STACK
3161
        mov     ebx, [current_slot_idx]                         ; TOP OF WINDOW STACK
3162
        mov     [esp + 32], dword 1
3162
        mov     [esp + 32], dword 1
3163
        movzx   ecx, word [WIN_STACK + ebx * 2]
3163
        movzx   ecx, word [WIN_STACK + ebx * 2]
3164
        mov     edx, [thread_count] ; less than 256 processes
3164
        mov     edx, [thread_count] ; less than 256 processes
3165
        cmp     ecx, edx
3165
        cmp     ecx, edx
3166
        jne     .exit
3166
        jne     .exit
Line 3193... Line 3193...
3193
        stdcall is_region_userspace, ebx, 0x4C
3193
        stdcall is_region_userspace, ebx, 0x4C
3194
        jz      .addr_error
3194
        jz      .addr_error
Line 3195... Line 3195...
3195
 
3195
 
3196
        cmp     ecx, -1 ; who am I ?
3196
        cmp     ecx, -1 ; who am I ?
3197
        jne     .no_who_am_i
3197
        jne     .no_who_am_i
3198
        mov     ecx, [CURRENT_TASK]
3198
        mov     ecx, [current_slot_idx]
3199
  .no_who_am_i:
3199
  .no_who_am_i:
3200
        cmp     ecx, max_processes
3200
        cmp     ecx, max_processes
Line 3201... Line 3201...
3201
        ja      .nofillbuf
3201
        ja      .nofillbuf
Line 3209... Line 3209...
3209
        mov     [ebx+6], ax
3209
        mov     [ebx+6], ax
Line 3210... Line 3210...
3210
 
3210
 
Line 3211... Line 3211...
3211
        shl     ecx, 5
3211
        shl     ecx, 5
3212
 
3212
 
3213
; +0: dword: memory usage
3213
; +0: dword: memory usage
3214
        mov     eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage]
3214
        mov     eax, [ecx+TASK_TABLE+TASKDATA.cpu_usage]
3215
        mov     [ebx], eax
3215
        mov     [ebx], eax
3216
; +10: 11 bytes: name of the process
3216
; +10: 11 bytes: name of the process
3217
        push    ecx
3217
        push    ecx
Line 3236... Line 3236...
3236
        stosd
3236
        stosd
3237
        lea     eax, [edx-1]
3237
        lea     eax, [edx-1]
3238
        stosd
3238
        stosd
Line 3239... Line 3239...
3239
 
3239
 
3240
; +30: PID/TID
3240
; +30: PID/TID
3241
        mov     eax, [ecx+CURRENT_TASK+TASKDATA.pid]
3241
        mov     eax, [ecx+TASK_TABLE+TASKDATA.pid]
Line 3242... Line 3242...
3242
        stosd
3242
        stosd
3243
 
3243
 
3244
    ; window position and size
3244
    ; window position and size
Line 3248... Line 3248...
3248
        movsd
3248
        movsd
3249
        movsd
3249
        movsd
3250
        movsd
3250
        movsd
Line 3251... Line 3251...
3251
 
3251
 
3252
    ; Process state (+50)
3252
    ; Process state (+50)
3253
        mov     eax, dword [ecx+CURRENT_TASK+TASKDATA.state]
3253
        movzx   eax, byte [ecx+TASK_TABLE+TASKDATA.state]
Line 3254... Line 3254...
3254
        stosd
3254
        stosd
3255
 
3255
 
3256
    ; Window client area box
3256
    ; Window client area box
Line 3263... Line 3263...
3263
    ; Window state
3263
    ; Window state
3264
        mov     al, [ecx+window_data+WDATA.fl_wstate]
3264
        mov     al, [ecx+window_data+WDATA.fl_wstate]
3265
        stosb
3265
        stosb
Line 3266... Line 3266...
3266
 
3266
 
3267
    ; Event mask (+71)
3267
    ; Event mask (+71)
3268
        mov     EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask]
3268
        mov     EAX, dword [ECX+TASK_TABLE+TASKDATA.event_mask]
Line 3269... Line 3269...
3269
        stosd
3269
        stosd
3270
 
3270
 
3271
    ; Keyboard mode (+75)
3271
    ; Keyboard mode (+75)
Line 3362... Line 3362...
3362
 
3362
 
3363
sys_redrawstat:
3363
sys_redrawstat:
3364
        cmp     ebx, 1
3364
        cmp     ebx, 1
3365
        jne     no_widgets_away
3365
        jne     no_widgets_away
3366
        ; buttons away
3366
        ; buttons away
3367
        mov     ecx, [CURRENT_TASK]
3367
        mov     ecx, [current_slot_idx]
3368
  sys_newba2:
3368
  sys_newba2:
3369
        mov     edi, [BTN_ADDR]
3369
        mov     edi, [BTN_ADDR]
3370
        cmp     [edi], dword 0  ; empty button list ?
3370
        cmp     [edi], dword 0  ; empty button list ?
3371
        je      end_of_buttons_away
3371
        je      end_of_buttons_away
Line 3400... Line 3400...
3400
 
3400
 
3401
        cmp     ebx, 2
3401
        cmp     ebx, 2
Line 3402... Line 3402...
3402
        jnz     srl1
3402
        jnz     srl1
3403
 
3403
 
3404
        mov     edx, [TASK_BASE]      ; return whole screen draw area for this app
3404
        mov     edx, [TASK_BASE]      ; return whole screen draw area for this app
3405
        add     edx, draw_data - CURRENT_TASK
3405
        add     edx, draw_data - TASK_TABLE
3406
        mov     [edx + RECT.left], 0
3406
        mov     [edx + RECT.left], 0
3407
        mov     [edx + RECT.top], 0
3407
        mov     [edx + RECT.top], 0
3408
        mov     eax, [_display.width]
3408
        mov     eax, [_display.width]
Line 3563... Line 3563...
3563
        cmp     [mouse_active], 1
3563
        cmp     [mouse_active], 1
3564
        jne     mouse_not_active
3564
        jne     mouse_not_active
3565
        mov     [mouse_active], 0
3565
        mov     [mouse_active], 0
Line 3566... Line 3566...
3566
 
3566
 
3567
        xor     edi, edi
3567
        xor     edi, edi
Line 3568... Line 3568...
3568
        mov     ebx, CURRENT_TASK
3568
        mov     ebx, TASK_TABLE
3569
 
3569
 
3570
        mov     ecx, [thread_count]
3570
        mov     ecx, [thread_count]
3571
        movzx   eax, word [WIN_POS + ecx*2]     ; active window
3571
        movzx   eax, word [WIN_POS + ecx*2]     ; active window
Line 3705... Line 3705...
3705
align 4
3705
align 4
3706
markz:
3706
markz:
3707
        push    ecx edx
3707
        push    ecx edx
3708
        cmp     [edx+TASKDATA.state], TSTATE_FREE
3708
        cmp     [edx+TASKDATA.state], TSTATE_FREE
3709
        jz      .nokill
3709
        jz      .nokill
3710
        lea     edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE]
3710
        lea     edx, [(edx-(TASK_TABLE and 1FFFFFFFh))*8+SLOT_BASE]
3711
        cmp     [edx+APPDATA.process], sys_proc
3711
        cmp     [edx+APPDATA.process], sys_proc
3712
        jz      .nokill
3712
        jz      .nokill
3713
        call    request_terminate
3713
        call    request_terminate
3714
        jmp     .common
3714
        jmp     .common
3715
.nokill:
3715
.nokill:
Line 4451... Line 4451...
4451
        imul    eax, ecx
4451
        imul    eax, ecx
4452
        stdcall is_region_userspace, ebx, eax
4452
        stdcall is_region_userspace, ebx, eax
4453
        pop     ecx
4453
        pop     ecx
4454
        jz      sys_putimage.exit
4454
        jz      sys_putimage.exit
Line 4455... Line 4455...
4455
 
4455
 
4456
        mov     eax, [CURRENT_TASK]
4456
        mov     eax, [current_slot_idx]
4457
        shl     eax, 8
4457
        shl     eax, 8
4458
        add     dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top]
4458
        add     dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top]
4459
        rol     edx, 16
4459
        rol     edx, 16
4460
        add     dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left]
4460
        add     dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left]
Line 5013... Line 5013...
5013
sys_process_def:
5013
sys_process_def:
5014
        dec     ebx
5014
        dec     ebx
5015
        cmp     ebx, 7
5015
        cmp     ebx, 7
5016
        jae     .not_support    ;if >=8 then or eax,-1
5016
        jae     .not_support    ;if >=8 then or eax,-1
Line 5017... Line 5017...
5017
 
5017
 
5018
        mov     edi, [CURRENT_TASK]
5018
        mov     edi, [current_slot_idx]
Line 5019... Line 5019...
5019
        jmp     dword [f66call+ebx*4]
5019
        jmp     dword [f66call+ebx*4]
5020
 
5020
 
5021
.not_support:
5021
.not_support:
Line 5110... Line 5110...
5110
        cli
5110
        cli
5111
        mov     eax, [PID_lock_input]
5111
        mov     eax, [PID_lock_input]
5112
        test    eax, eax
5112
        test    eax, eax
5113
        jnz     @f
5113
        jnz     @f
5114
; get current PID
5114
; get current PID
5115
        mov     eax, [CURRENT_TASK]
5115
        mov     eax, [current_slot_idx]
5116
        shl     eax, 5
5116
        shl     eax, 5
5117
        mov     eax, [eax+CURRENT_TASK+TASKDATA.pid]
5117
        mov     eax, [eax+TASK_TABLE+TASKDATA.pid]
5118
; set current PID for lock input
5118
; set current PID for lock input
5119
        mov     [PID_lock_input], eax
5119
        mov     [PID_lock_input], eax
5120
@@:
5120
@@:
5121
        popfd
5121
        popfd
5122
        ret
5122
        ret
Line 5125... Line 5125...
5125
.7:
5125
.7:
5126
        mov     eax, [PID_lock_input]
5126
        mov     eax, [PID_lock_input]
5127
        test    eax, eax
5127
        test    eax, eax
5128
        jz      @f
5128
        jz      @f
5129
; get current PID
5129
; get current PID
5130
        mov     ebx, [CURRENT_TASK]
5130
        mov     ebx, [current_slot_idx]
5131
        shl     ebx, 5
5131
        shl     ebx, 5
5132
        mov     ebx, [ebx+CURRENT_TASK+TASKDATA.pid]
5132
        mov     ebx, [ebx+TASK_TABLE+TASKDATA.pid]
5133
; compare current lock input with current PID
5133
; compare current lock input with current PID
5134
        cmp     ebx, eax
5134
        cmp     ebx, eax
5135
        jne     @f
5135
        jne     @f
Line 5136... Line 5136...
5136
 
5136