menuet02 tls

git-svn-id: svn://kolibrios.org@1220 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2009-10-19 19:45:30 +00:00
parent c2b5a1b2a8
commit b7c98dff1b
6 changed files with 121 additions and 38 deletions

View File

@ -174,8 +174,23 @@ do_change_task:
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]
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

View File

@ -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]
@ -278,8 +287,10 @@ test_app_header:
.check_01_header:
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

View File

@ -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:

View File

@ -3776,6 +3776,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
* E_NOMEM = 30
* E_PARAM = 33
‡ ¬¥ç ­¨ï:
* <20>।¢ à¨â¥«ì­® á«¥¤ã¥â ¨­¨æ¨ «¨§¨à®¢ âì ªãçã ¯à®æ¥áá  ¢ë§®¢®¬
¯®¤ä㭪樨 11.
* …᫨ ᮧ¤ ñâáï ­®¢ ï ®¡« áâì, â® ä« £¨ ¤®áâ㯠 ãáâ ­ ¢«¨¢ îâ
¬ ªá¨¬ «ì­ë¥ ¯à ¢  ¤®áâ㯠 ¤«ï ®áâ «ì­ëå ¯à®æ¥áᮢ. <20>®¯ë⪠
®âªàëâ¨ï ¤à㣨¬ ¯®â®ª®¬ á ­¥à §à¥èñ­­ë¬¨ ¯à ¢ ¬¨ ¯à®¢ «¨âáï

View File

@ -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)
@ -283,12 +284,13 @@ align 4
high_code:
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 fs, cx
mov gs, bx
bt [cpu_caps], CAPS_PGE
@ -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

View File

@ -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