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

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

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]
@ -211,7 +220,7 @@ else
jna @F
xor eax, eax
cld
cld
rep stosb
@@:
end if
@ -262,26 +271,28 @@ test_app_header:
jne .check_01_header
mov ecx,[APP_HEADER_00.start]
mov [ebx+0x08], ecx ;app_eip
mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_00.mem_size]
mov [ebx+0x10], edx ;app_mem
mov [ebx+0x10], edx ;app_mem
shr edx,1
sub edx,0x10
mov [ebx+0x0C], edx ;app_esp
mov [ebx+0x0C], edx ;app_esp
mov ecx,[APP_HEADER_00.i_param]
mov [ebx], ecx ;app_cmdline
mov [ebx+4], dword 0 ;app_path
mov [ebx], ecx ;app_cmdline
mov [ebx+4], dword 0 ;app_path
mov edx, [APP_HEADER_00.i_end]
mov [ebx+0x14], edx
ret
.check_01_header:
cmp [eax+6],word '01'
jne .fail
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 [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_01.mem_size]
; \begin{diamond}[20.08.2006]
@ -291,13 +302,13 @@ test_app_header:
jb .fail
; \end{diamond}[20.08.2006]
mov [ebx+0x10], edx ;app_mem
mov [ebx+0x10], edx ;app_mem
mov ecx,[APP_HEADER_01.stack_top]
mov [ebx+0x0C], ecx ;app_esp
mov [ebx+0x0C], ecx ;app_esp
mov edx,[APP_HEADER_01.i_param]
mov [ebx], edx ;app_cmdline
mov [ebx], edx ;app_cmdline
mov ecx,[APP_HEADER_01.i_icon]
mov [ebx+4], ecx ;app_path
mov [ebx+4], ecx ;app_path
mov edx, [APP_HEADER_01.i_end]
mov [ebx+0x14], edx
ret
@ -451,7 +462,7 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
if GREEDY_KERNEL
mov eax, 0x02
rep stosd
rep stosd
else
.alloc:
@ -572,7 +583,7 @@ endp
align 4
get_pid:
mov eax, [TASK_BASE]
mov eax, [eax+TASKDATA.pid]
mov eax, [eax+TASKDATA.pid]
ret
pid_to_slot:
@ -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],\
@ -895,17 +906,29 @@ proc new_sys_threads
mov [edx+APPDATA.mem_size], eax
mov ecx,[ebx+APPDATA.dir_table]
mov [edx+APPDATA.dir_table],ecx ;copy page directory
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
;mov esi,new_process_running
;call sys_msg_board_str ;output information about succefull startup
;call sys_msg_board_str ;output information about succefull startup
mov [application_table_status],0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result
mov [application_table_status],0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result
ret
.failed:
mov [application_table_status],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)
@ -281,15 +282,16 @@ org OS_BASE+$
align 4
high_code:
mov ax,os_stack
mov bx,app_data
mov ss,ax
add esp, OS_BASE
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

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