forked from KolibriOS/kolibrios
menuet02 tls
git-svn-id: svn://kolibrios.org@1220 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c2b5a1b2a8
commit
b7c98dff1b
@ -162,21 +162,36 @@ do_change_task:
|
||||
;scratched: eax,ecx,esi
|
||||
mov esi,ebx
|
||||
xchg esi,[current_slot]
|
||||
; set new stack after saving old
|
||||
; set new stack after saving old
|
||||
mov [esi+APPDATA.saved_esp], esp
|
||||
mov esp, [ebx+APPDATA.saved_esp]
|
||||
; set new thread io-map
|
||||
; set new thread io-map
|
||||
Mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)],eax,[ebx+APPDATA.io_map]
|
||||
Mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)],eax,[ebx+APPDATA.io_map+4]
|
||||
; set new thread memory-map
|
||||
; set new thread memory-map
|
||||
mov ecx, APPDATA.dir_table
|
||||
mov eax, [ebx+ecx] ;offset>0x7F
|
||||
cmp eax, [esi+ecx] ;offset>0x7F
|
||||
je @f
|
||||
mov cr3, eax
|
||||
@@: ; set tss.esp0
|
||||
@@:
|
||||
; set tss.esp0
|
||||
|
||||
Mov [tss._esp0],eax,[ebx+APPDATA.saved_esp0]
|
||||
; set gs selector unconditionally
|
||||
|
||||
mov edx, [ebx+APPDATA.tls_base]
|
||||
cmp edx, [esi+APPDATA.tls_base]
|
||||
je @f
|
||||
|
||||
mov [tls_data_l+2],dx
|
||||
shr edx,16
|
||||
mov [tls_data_l+4],dl
|
||||
mov [tls_data_l+7],dh
|
||||
|
||||
mov dx, app_tls
|
||||
mov fs, dx
|
||||
@:
|
||||
; set gs selector unconditionally
|
||||
Mov gs,ax,graph_data
|
||||
; set CR0.TS
|
||||
cmp bh, byte[fpu_owner] ;bh == incoming task (new)
|
||||
|
@ -113,6 +113,7 @@ proc fs_execute
|
||||
popad
|
||||
mov eax, -ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
|
||||
.namecopied:
|
||||
|
||||
mov [cmdline], ebx
|
||||
@ -201,6 +202,14 @@ proc fs_execute
|
||||
mov eax,[hdr_mem]
|
||||
mov [ebx+APPDATA.mem_size],eax
|
||||
|
||||
xor edx, edx
|
||||
cmp word [6], '02'
|
||||
jne @f
|
||||
|
||||
not edx
|
||||
@@:
|
||||
mov [ebx+APPDATA.tls_base],edx
|
||||
|
||||
if GREEDY_KERNEL
|
||||
else
|
||||
mov ecx, [hdr_mem]
|
||||
@ -277,9 +286,11 @@ test_app_header:
|
||||
|
||||
.check_01_header:
|
||||
|
||||
cmp [eax+6],word '01'
|
||||
cmp [eax+6], word '01'
|
||||
je @f
|
||||
cmp [eax+6], word '02'
|
||||
jne .fail
|
||||
|
||||
@@:
|
||||
mov ecx,[APP_HEADER_01.start]
|
||||
mov [ebx+0x08], ecx ;app_eip
|
||||
mov edx,[APP_HEADER_01.mem_size]
|
||||
@ -736,7 +747,7 @@ proc read_process_memory
|
||||
mov eax, [slot]
|
||||
shl eax,8
|
||||
mov ebx, [offset]
|
||||
; add ebx, new_app_base
|
||||
|
||||
push ecx
|
||||
stdcall map_memEx, [proc_mem_map],\
|
||||
[SLOT_BASE+eax+0xB8],\
|
||||
@ -897,6 +908,18 @@ proc new_sys_threads
|
||||
mov ecx,[ebx+APPDATA.dir_table]
|
||||
mov [edx+APPDATA.dir_table],ecx ;copy page directory
|
||||
|
||||
mov eax, [ebx+APPDATA.tls_base]
|
||||
test eax, eax
|
||||
jz @F
|
||||
|
||||
push edx
|
||||
stdcall user_alloc, 4096
|
||||
pop edx
|
||||
test eax, eax
|
||||
jz .failed
|
||||
@@:
|
||||
mov [edx+APPDATA.tls_base], eax
|
||||
|
||||
lea eax, [app_cmdline]
|
||||
stdcall set_app_params ,[slot],eax,dword 0,\
|
||||
dword 0,dword 0
|
||||
@ -931,6 +954,24 @@ wait_mutex:
|
||||
pop eax
|
||||
ret
|
||||
|
||||
align 4
|
||||
tls_app_entry:
|
||||
|
||||
call init_heap
|
||||
stdcall user_alloc, 4096
|
||||
|
||||
mov edx, [current_slot]
|
||||
mov [edx+APPDATA.tls_base], eax
|
||||
mov [tls_data_l+2],ax
|
||||
shr eax,16
|
||||
mov [tls_data_l+4],al
|
||||
mov [tls_data_l+7],ah
|
||||
mov dx, app_tls
|
||||
mov fs, dx
|
||||
popad
|
||||
iretd
|
||||
|
||||
|
||||
EFL_IF equ 0x0200
|
||||
EFL_IOPL1 equ 0x1000
|
||||
EFL_IOPL2 equ 0x2000
|
||||
@ -1037,6 +1078,11 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
shl ebx,5
|
||||
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data
|
||||
|
||||
mov edx, irq0.return
|
||||
cmp [ebx*8+SLOT_BASE+APPDATA.tls_base], -1
|
||||
jne @F
|
||||
mov edx, tls_app_entry
|
||||
@@:
|
||||
; set window state to 'normal' (non-minimized/maximized/rolled-up) state
|
||||
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
|
||||
mov [ebx+window_data+WDATA.fl_redraw], 1
|
||||
@ -1063,7 +1109,7 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
lea ecx, [ebx+REG_EIP]
|
||||
xor eax, eax
|
||||
|
||||
mov [ebx+REG_RET], dword irq0.return
|
||||
mov [ebx+REG_RET], edx
|
||||
mov [ebx+REG_EDI], eax
|
||||
mov [ebx+REG_ESI], eax
|
||||
mov [ebx+REG_EBP], eax
|
||||
|
@ -202,14 +202,14 @@ app_code_l:
|
||||
dw 0
|
||||
db 0
|
||||
db cpl3
|
||||
dw G32+D32+(new_app_base shr 16)+0xF;
|
||||
dw G32+D32+0xF;
|
||||
|
||||
app_data_l:
|
||||
dw 0xFFFF
|
||||
dw 0
|
||||
db 0
|
||||
db drw3
|
||||
dw G32+D32+(new_app_base shr 16)+0xF;
|
||||
dw G32+D32+0xF;
|
||||
|
||||
; ------------- PCI BIOS ------------------
|
||||
|
||||
@ -260,6 +260,14 @@ tss0_l:
|
||||
db (tss shr 16) and 0xFF
|
||||
db 10001001b
|
||||
dw (tss shr 16) and 0xFF00
|
||||
|
||||
tls_data_l:
|
||||
dw 0x0FFF
|
||||
dw 0
|
||||
db 0
|
||||
db drw3
|
||||
dw D32
|
||||
|
||||
endofcode:
|
||||
gdte:
|
||||
|
||||
|
@ -3776,6 +3776,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
||||
* E_NOMEM = 30
|
||||
* E_PARAM = 33
|
||||
‡ ¬¥ç ¨ï:
|
||||
* <20>।¢ à¨â¥«ì® á«¥¤ã¥â ¨¨æ¨ «¨§¨à®¢ âì ªãçã ¯à®æ¥áá ¢ë§®¢®¬
|
||||
¯®¤äãªæ¨¨ 11.
|
||||
* …᫨ ᮧ¤ ñâáï ®¢ ï ®¡« áâì, â® ä« £¨ ¤®áâ㯠ãáâ ¢«¨¢ îâ
|
||||
¬ ªá¨¬ «ìë¥ ¯à ¢ ¤®áâ㯠¤«ï ®áâ «ìëå ¯à®æ¥áᮢ. <20>®¯ëâª
|
||||
®âªàëâ¨ï ¤à㣨¬ ¯®â®ª®¬ á ¥à §à¥èñ묨 ¯à ¢ ¬¨ ¯à®¢ «¨âáï
|
||||
|
@ -79,6 +79,7 @@ graph_data equ (3+graph_data_l-gdts)
|
||||
tss0 equ (tss0_l-gdts)
|
||||
app_code equ (3+app_code_l-gdts)
|
||||
app_data equ (3+app_data_l-gdts)
|
||||
app_tls equ (3+tls_data_l-gdts)
|
||||
pci_code_sel equ (pci_code_32-gdts)
|
||||
pci_data_sel equ (pci_data_32-gdts)
|
||||
|
||||
@ -281,15 +282,16 @@ org OS_BASE+$
|
||||
|
||||
align 4
|
||||
high_code:
|
||||
mov ax,os_stack
|
||||
mov bx,app_data
|
||||
mov ss,ax
|
||||
mov ax, os_stack
|
||||
mov bx, app_data
|
||||
mov cx, app_tls
|
||||
mov ss, ax
|
||||
add esp, OS_BASE
|
||||
|
||||
mov ds,bx
|
||||
mov es,bx
|
||||
mov fs,bx
|
||||
mov gs,bx
|
||||
mov ds, bx
|
||||
mov es, bx
|
||||
mov fs, cx
|
||||
mov gs, bx
|
||||
|
||||
bt [cpu_caps], CAPS_PGE
|
||||
jnc @F
|
||||
@ -711,6 +713,7 @@ no_lib_load:
|
||||
mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx
|
||||
|
||||
mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path
|
||||
mov dword [SLOT_BASE+256+APPDATA.tls_base], eax
|
||||
|
||||
; task list
|
||||
mov [CURRENT_TASK],dword 1
|
||||
@ -1907,6 +1910,14 @@ detect_devices:
|
||||
|
||||
sys_end:
|
||||
|
||||
mov ecx, [current_slot]
|
||||
mov eax, [ecx+APPDATA.tls_base]
|
||||
test eax, eax
|
||||
jz @F
|
||||
|
||||
stdcall user_free, eax
|
||||
@@:
|
||||
|
||||
mov eax,[TASK_BASE]
|
||||
mov [eax+TASKDATA.state], 3 ; terminate this program
|
||||
|
||||
|
@ -141,7 +141,8 @@ struc APPDATA
|
||||
.wait_begin dd ? ;+92 +++
|
||||
.wait_test dd ? ;+96 +++
|
||||
.wait_param dd ? ;+100 +++
|
||||
db 24 dup(?) ;+104
|
||||
.tls_base dd ? ;+104
|
||||
db 20 dup(?) ;+108
|
||||
|
||||
.wnd_shape dd ? ;+128
|
||||
.wnd_shape_scale dd ? ;+132
|
||||
|
Loading…
Reference in New Issue
Block a user