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
|
;scratched: eax,ecx,esi
|
||||||
mov esi,ebx
|
mov esi,ebx
|
||||||
xchg esi,[current_slot]
|
xchg esi,[current_slot]
|
||||||
; set new stack after saving old
|
; set new stack after saving old
|
||||||
mov [esi+APPDATA.saved_esp], esp
|
mov [esi+APPDATA.saved_esp], esp
|
||||||
mov esp, [ebx+APPDATA.saved_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_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]
|
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 ecx, APPDATA.dir_table
|
||||||
mov eax, [ebx+ecx] ;offset>0x7F
|
mov eax, [ebx+ecx] ;offset>0x7F
|
||||||
cmp eax, [esi+ecx] ;offset>0x7F
|
cmp eax, [esi+ecx] ;offset>0x7F
|
||||||
je @f
|
je @f
|
||||||
mov cr3, eax
|
mov cr3, eax
|
||||||
@@: ; set tss.esp0
|
@@:
|
||||||
|
; set tss.esp0
|
||||||
|
|
||||||
Mov [tss._esp0],eax,[ebx+APPDATA.saved_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
|
Mov gs,ax,graph_data
|
||||||
; set CR0.TS
|
; set CR0.TS
|
||||||
cmp bh, byte[fpu_owner] ;bh == incoming task (new)
|
cmp bh, byte[fpu_owner] ;bh == incoming task (new)
|
||||||
|
@ -113,6 +113,7 @@ proc fs_execute
|
|||||||
popad
|
popad
|
||||||
mov eax, -ERROR_FILE_NOT_FOUND
|
mov eax, -ERROR_FILE_NOT_FOUND
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.namecopied:
|
.namecopied:
|
||||||
|
|
||||||
mov [cmdline], ebx
|
mov [cmdline], ebx
|
||||||
@ -201,6 +202,14 @@ proc fs_execute
|
|||||||
mov eax,[hdr_mem]
|
mov eax,[hdr_mem]
|
||||||
mov [ebx+APPDATA.mem_size],eax
|
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
|
if GREEDY_KERNEL
|
||||||
else
|
else
|
||||||
mov ecx, [hdr_mem]
|
mov ecx, [hdr_mem]
|
||||||
@ -211,7 +220,7 @@ else
|
|||||||
jna @F
|
jna @F
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
cld
|
cld
|
||||||
rep stosb
|
rep stosb
|
||||||
@@:
|
@@:
|
||||||
end if
|
end if
|
||||||
@ -262,26 +271,28 @@ test_app_header:
|
|||||||
jne .check_01_header
|
jne .check_01_header
|
||||||
|
|
||||||
mov ecx,[APP_HEADER_00.start]
|
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 edx,[APP_HEADER_00.mem_size]
|
||||||
mov [ebx+0x10], edx ;app_mem
|
mov [ebx+0x10], edx ;app_mem
|
||||||
shr edx,1
|
shr edx,1
|
||||||
sub edx,0x10
|
sub edx,0x10
|
||||||
mov [ebx+0x0C], edx ;app_esp
|
mov [ebx+0x0C], edx ;app_esp
|
||||||
mov ecx,[APP_HEADER_00.i_param]
|
mov ecx,[APP_HEADER_00.i_param]
|
||||||
mov [ebx], ecx ;app_cmdline
|
mov [ebx], ecx ;app_cmdline
|
||||||
mov [ebx+4], dword 0 ;app_path
|
mov [ebx+4], dword 0 ;app_path
|
||||||
mov edx, [APP_HEADER_00.i_end]
|
mov edx, [APP_HEADER_00.i_end]
|
||||||
mov [ebx+0x14], edx
|
mov [ebx+0x14], edx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.check_01_header:
|
.check_01_header:
|
||||||
|
|
||||||
cmp [eax+6],word '01'
|
cmp [eax+6], word '01'
|
||||||
jne .fail
|
je @f
|
||||||
|
cmp [eax+6], word '02'
|
||||||
|
jne .fail
|
||||||
|
@@:
|
||||||
mov ecx,[APP_HEADER_01.start]
|
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]
|
mov edx,[APP_HEADER_01.mem_size]
|
||||||
|
|
||||||
; \begin{diamond}[20.08.2006]
|
; \begin{diamond}[20.08.2006]
|
||||||
@ -291,13 +302,13 @@ test_app_header:
|
|||||||
jb .fail
|
jb .fail
|
||||||
; \end{diamond}[20.08.2006]
|
; \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 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 edx,[APP_HEADER_01.i_param]
|
||||||
mov [ebx], edx ;app_cmdline
|
mov [ebx], edx ;app_cmdline
|
||||||
mov ecx,[APP_HEADER_01.i_icon]
|
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 edx, [APP_HEADER_01.i_end]
|
||||||
mov [ebx+0x14], edx
|
mov [ebx+0x14], edx
|
||||||
ret
|
ret
|
||||||
@ -451,7 +462,7 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
|
|||||||
|
|
||||||
if GREEDY_KERNEL
|
if GREEDY_KERNEL
|
||||||
mov eax, 0x02
|
mov eax, 0x02
|
||||||
rep stosd
|
rep stosd
|
||||||
else
|
else
|
||||||
|
|
||||||
.alloc:
|
.alloc:
|
||||||
@ -572,7 +583,7 @@ endp
|
|||||||
align 4
|
align 4
|
||||||
get_pid:
|
get_pid:
|
||||||
mov eax, [TASK_BASE]
|
mov eax, [TASK_BASE]
|
||||||
mov eax, [eax+TASKDATA.pid]
|
mov eax, [eax+TASKDATA.pid]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
pid_to_slot:
|
pid_to_slot:
|
||||||
@ -736,7 +747,7 @@ proc read_process_memory
|
|||||||
mov eax, [slot]
|
mov eax, [slot]
|
||||||
shl eax,8
|
shl eax,8
|
||||||
mov ebx, [offset]
|
mov ebx, [offset]
|
||||||
; add ebx, new_app_base
|
|
||||||
push ecx
|
push ecx
|
||||||
stdcall map_memEx, [proc_mem_map],\
|
stdcall map_memEx, [proc_mem_map],\
|
||||||
[SLOT_BASE+eax+0xB8],\
|
[SLOT_BASE+eax+0xB8],\
|
||||||
@ -895,17 +906,29 @@ proc new_sys_threads
|
|||||||
mov [edx+APPDATA.mem_size], eax
|
mov [edx+APPDATA.mem_size], eax
|
||||||
|
|
||||||
mov ecx,[ebx+APPDATA.dir_table]
|
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]
|
lea eax, [app_cmdline]
|
||||||
stdcall set_app_params ,[slot],eax,dword 0,\
|
stdcall set_app_params ,[slot],eax,dword 0,\
|
||||||
dword 0,dword 0
|
dword 0,dword 0
|
||||||
|
|
||||||
;mov esi,new_process_running
|
;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 [application_table_status],0 ;unlock application_table_status mutex
|
||||||
mov eax,[process_number] ;set result
|
mov eax,[process_number] ;set result
|
||||||
ret
|
ret
|
||||||
.failed:
|
.failed:
|
||||||
mov [application_table_status],0
|
mov [application_table_status],0
|
||||||
@ -931,6 +954,24 @@ wait_mutex:
|
|||||||
pop eax
|
pop eax
|
||||||
ret
|
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_IF equ 0x0200
|
||||||
EFL_IOPL1 equ 0x1000
|
EFL_IOPL1 equ 0x1000
|
||||||
EFL_IOPL2 equ 0x2000
|
EFL_IOPL2 equ 0x2000
|
||||||
@ -1037,6 +1078,11 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
|||||||
shl ebx,5
|
shl ebx,5
|
||||||
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data
|
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
|
; 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_wstate], WSTATE_NORMAL
|
||||||
mov [ebx+window_data+WDATA.fl_redraw], 1
|
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]
|
lea ecx, [ebx+REG_EIP]
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
|
||||||
mov [ebx+REG_RET], dword irq0.return
|
mov [ebx+REG_RET], edx
|
||||||
mov [ebx+REG_EDI], eax
|
mov [ebx+REG_EDI], eax
|
||||||
mov [ebx+REG_ESI], eax
|
mov [ebx+REG_ESI], eax
|
||||||
mov [ebx+REG_EBP], eax
|
mov [ebx+REG_EBP], eax
|
||||||
|
@ -202,14 +202,14 @@ app_code_l:
|
|||||||
dw 0
|
dw 0
|
||||||
db 0
|
db 0
|
||||||
db cpl3
|
db cpl3
|
||||||
dw G32+D32+(new_app_base shr 16)+0xF;
|
dw G32+D32+0xF;
|
||||||
|
|
||||||
app_data_l:
|
app_data_l:
|
||||||
dw 0xFFFF
|
dw 0xFFFF
|
||||||
dw 0
|
dw 0
|
||||||
db 0
|
db 0
|
||||||
db drw3
|
db drw3
|
||||||
dw G32+D32+(new_app_base shr 16)+0xF;
|
dw G32+D32+0xF;
|
||||||
|
|
||||||
; ------------- PCI BIOS ------------------
|
; ------------- PCI BIOS ------------------
|
||||||
|
|
||||||
@ -260,6 +260,14 @@ tss0_l:
|
|||||||
db (tss shr 16) and 0xFF
|
db (tss shr 16) and 0xFF
|
||||||
db 10001001b
|
db 10001001b
|
||||||
dw (tss shr 16) and 0xFF00
|
dw (tss shr 16) and 0xFF00
|
||||||
|
|
||||||
|
tls_data_l:
|
||||||
|
dw 0x0FFF
|
||||||
|
dw 0
|
||||||
|
db 0
|
||||||
|
db drw3
|
||||||
|
dw D32
|
||||||
|
|
||||||
endofcode:
|
endofcode:
|
||||||
gdte:
|
gdte:
|
||||||
|
|
||||||
|
@ -3776,6 +3776,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
|
|||||||
* E_NOMEM = 30
|
* E_NOMEM = 30
|
||||||
* E_PARAM = 33
|
* E_PARAM = 33
|
||||||
‡ ¬¥ç ¨ï:
|
‡ ¬¥ç ¨ï:
|
||||||
|
* <20>।¢ à¨â¥«ì® á«¥¤ã¥â ¨¨æ¨ «¨§¨à®¢ âì ªãçã ¯à®æ¥áá ¢ë§®¢®¬
|
||||||
|
¯®¤äãªæ¨¨ 11.
|
||||||
* …᫨ ᮧ¤ ñâáï ®¢ ï ®¡« áâì, â® ä« £¨ ¤®áâ㯠ãáâ ¢«¨¢ îâ
|
* …᫨ ᮧ¤ ñâáï ®¢ ï ®¡« áâì, â® ä« £¨ ¤®áâ㯠ãáâ ¢«¨¢ îâ
|
||||||
¬ ªá¨¬ «ìë¥ ¯à ¢ ¤®áâ㯠¤«ï ®áâ «ìëå ¯à®æ¥áᮢ. <20>®¯ëâª
|
¬ ªá¨¬ «ìë¥ ¯à ¢ ¤®áâ㯠¤«ï ®áâ «ìëå ¯à®æ¥áᮢ. <20>®¯ëâª
|
||||||
®âªàëâ¨ï ¤à㣨¬ ¯®â®ª®¬ á ¥à §à¥èñ묨 ¯à ¢ ¬¨ ¯à®¢ «¨âáï
|
®âªàëâ¨ï ¤à㣨¬ ¯®â®ª®¬ á ¥à §à¥èñ묨 ¯à ¢ ¬¨ ¯à®¢ «¨âáï
|
||||||
|
@ -79,6 +79,7 @@ graph_data equ (3+graph_data_l-gdts)
|
|||||||
tss0 equ (tss0_l-gdts)
|
tss0 equ (tss0_l-gdts)
|
||||||
app_code equ (3+app_code_l-gdts)
|
app_code equ (3+app_code_l-gdts)
|
||||||
app_data equ (3+app_data_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_code_sel equ (pci_code_32-gdts)
|
||||||
pci_data_sel equ (pci_data_32-gdts)
|
pci_data_sel equ (pci_data_32-gdts)
|
||||||
|
|
||||||
@ -281,15 +282,16 @@ org OS_BASE+$
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
high_code:
|
high_code:
|
||||||
mov ax,os_stack
|
mov ax, os_stack
|
||||||
mov bx,app_data
|
mov bx, app_data
|
||||||
mov ss,ax
|
mov cx, app_tls
|
||||||
add esp, OS_BASE
|
mov ss, ax
|
||||||
|
add esp, OS_BASE
|
||||||
|
|
||||||
mov ds,bx
|
mov ds, bx
|
||||||
mov es,bx
|
mov es, bx
|
||||||
mov fs,bx
|
mov fs, cx
|
||||||
mov gs,bx
|
mov gs, bx
|
||||||
|
|
||||||
bt [cpu_caps], CAPS_PGE
|
bt [cpu_caps], CAPS_PGE
|
||||||
jnc @F
|
jnc @F
|
||||||
@ -711,6 +713,7 @@ no_lib_load:
|
|||||||
mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx
|
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.cur_dir], sysdir_path
|
||||||
|
mov dword [SLOT_BASE+256+APPDATA.tls_base], eax
|
||||||
|
|
||||||
; task list
|
; task list
|
||||||
mov [CURRENT_TASK],dword 1
|
mov [CURRENT_TASK],dword 1
|
||||||
@ -1907,6 +1910,14 @@ detect_devices:
|
|||||||
|
|
||||||
sys_end:
|
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,[TASK_BASE]
|
||||||
mov [eax+TASKDATA.state], 3 ; terminate this program
|
mov [eax+TASKDATA.state], 3 ; terminate this program
|
||||||
|
|
||||||
|
@ -141,7 +141,8 @@ struc APPDATA
|
|||||||
.wait_begin dd ? ;+92 +++
|
.wait_begin dd ? ;+92 +++
|
||||||
.wait_test dd ? ;+96 +++
|
.wait_test dd ? ;+96 +++
|
||||||
.wait_param dd ? ;+100 +++
|
.wait_param dd ? ;+100 +++
|
||||||
db 24 dup(?) ;+104
|
.tls_base dd ? ;+104
|
||||||
|
db 20 dup(?) ;+108
|
||||||
|
|
||||||
.wnd_shape dd ? ;+128
|
.wnd_shape dd ? ;+128
|
||||||
.wnd_shape_scale dd ? ;+132
|
.wnd_shape_scale dd ? ;+132
|
||||||
|
Loading…
Reference in New Issue
Block a user