diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 4778afc991..32f4d38b2e 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -225,11 +225,10 @@ resendQ equ OS_BASE+0x0770000 ;skin_data equ OS_BASE+0x0778000 -draw_data equ OS_BASE+0x0800000 +tss_data equ 0x780000 +draw_data equ 0x988000 -tss_data equ 0x0803000 ;OS_BASE+0x0920000 - -HEAP_BASE equ 0xA0B000 ;x00C00000 +HEAP_BASE equ 0x98B000 pages_tab equ 0x60000000 master_tab equ 0x60180000 @@ -435,7 +434,6 @@ struc PG_DATA .kernel_tables dd ? .sys_page_dir dd ? .pg_mutex dd ? - .tmp_task_mutex dd ? } ;struc LIB diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 4b77d87022..5dafe18f52 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -461,6 +461,20 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\ ret endp +; description +; allocate kernel memory and loads the specified file +; +; param +; file_name= full path to file +; +; retval +; eax= file image in kernel memory +; ebx= size of file +; +; warging +; You mast call kernel_free() to delete each file +; loaded by the load_file() function + align 4 proc load_file stdcall, file_name:dword locals diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 2470fa293c..0c0461ccba 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -1363,7 +1363,6 @@ align 16 tmp_task_pdir rd 1 tmp_task_ptab rd 1 - tmp_task_data rd 1 fdd_buff rd 1 LFBSize rd 1 diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index bd16f38a19..385aa8bbbe 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -543,14 +543,14 @@ get_app_params: ret uglobal - new_process_place dd 0x0 - app_start dd 0x0 - app_i_end dd 0x0 - app_mem dd 0x0 - app_esp dd 0x0 - app_i_param dd 0x0 - app_i_icon dd 0x0 - app_mem_pos dd 0x0 +; new_process_place dd 0x0 +; app_start dd 0x0 +; app_i_end dd 0x0 +; app_mem dd 0x0 +; app_esp dd 0x0 +; app_i_param dd 0x0 +; app_i_icon dd 0x0 +; app_mem_pos dd 0x0 endg end if diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index 74b556a4b7..008ccd2c4f 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -71,24 +71,54 @@ macro _clear_ op rep stosd } + align 4 -proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword +proc fs_execute + +;fn_read:dword, file_size:dword, cluster:dword + +; ebx - cmdline +; edx - flags +; ebp - full filename +; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it + locals + cmdline rd 64 ;256/4 + filename rd 256 ;1024/4 + flags dd ? + save_cr3 dd ? slot dd ? slot_base dd ? file_base dd ? file_size dd ? - - app_cmdline dd ? ;0x00 - app_path dd ? ;0x04 - app_eip dd ? ;0x08 - app_esp dd ? ;0x0C - app_mem dd ? ;0x10 - app_i_end dd ? ;0x14 + ;app header data + hdr_cmdline dd ? ;0x00 + hdr_path dd ? ;0x04 + hdr_eip dd ? ;0x08 + hdr_esp dd ? ;0x0C + hdr_mem dd ? ;0x10 + hdr_i_end dd ? ;0x14 endl - stdcall load_file,[file_name] + pushad + + mov [cmdline], ebx + mov [flags], edx + +; [ebp] pointer to filename + + lea eax, [filename] + mov dword [eax+1020],0 ;force terminate + ;string + stdcall k_strncpy, eax, [ebp], 1023 + + lea eax, [cmdline] + mov dword [eax+252], 0 + stdcall k_strncpy, eax, [cmdline], 255 + + lea eax, [filename] + stdcall load_file, eax mov ecx, -ERROR_FILE_NOT_FOUND test eax, eax jz .err_file @@ -96,7 +126,7 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword mov [file_base], eax mov [file_size], ebx - lea ebx, [app_cmdline] + lea ebx, [hdr_cmdline] call test_app_header mov ecx, -0x1F test eax, eax @@ -117,8 +147,8 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword cmp eax, 0 jne .wait_lock - pushfd - cli +; pushfd +; cli call set_application_table_status @@ -135,14 +165,14 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword _clear_ 256 ;clean extended information about process ; write application name - mov edi, [file_name] + lea edi, [filename] mov al, '/' call k_strrchr ; now eax points to name without path lea esi, [eax+1] test eax, eax jnz @F - mov esi, [file_name] + lea esi, [filename] @@: mov ecx, 8 ; 8 chars for name mov edi, [slot_base] @@ -159,18 +189,18 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword mov ebx, cr3 mov [save_cr3], ebx - stdcall create_app_space,[app_mem],[file_base],[file_size] + stdcall create_app_space,[hdr_mem],[file_base],[file_size] test eax, eax jz .failed mov ebx,[slot_base] mov [ebx+APPDATA.dir_table],eax - mov eax,[app_mem] + mov eax,[hdr_mem] mov [ebx+APPDATA.mem_size],eax if GREEDY_KERNEL else - mov ecx, [app_mem] + mov ecx, [hdr_mem] mov edi, [file_size] add edi, 4095 and edi, not 4095 @@ -187,14 +217,15 @@ end if ; release only virtual space, not phisical memory stdcall free_kernel_space, [file_base] - lea eax, [app_cmdline] - stdcall set_app_params ,[slot],eax,[cmd_line],\ - [file_name], [flags] + lea eax, [hdr_cmdline] + lea ebx, [cmdline] + lea ecx, [filename] + stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] mov eax, [save_cr3] call set_cr3 - popfd + ; popfd xor ebx, ebx mov [application_table_status],ebx ;unlock application_table_status mutex mov eax,[process_number] ;set result @@ -203,7 +234,7 @@ end if mov eax, [save_cr3] call set_cr3 .err: - popfd + ; popfd .err_hdr: stdcall kernel_free,[file_base] .err_file: @@ -548,63 +579,6 @@ proc destroy_app_space stdcall, pg_dir:dword ret endp -align 4 -proc fs_execute - -;fn_read:dword, file_size:dword, cluster:dword - -; ebx - cmdline -; edx - flags -; ebp - full filename -; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it - - locals - cmdline dd ? - flags dd ? - filename dd ? - retval dd ? - endl - - pushad - - mov [cmdline], ebx - mov [flags], edx - mov eax, [ebp] - mov [filename], eax - - mov ebx, pg_data.tmp_task_mutex - call wait_mutex ;ebx - - mov edi, [tmp_task_data] - mov ecx, (1024+256)/4 - xor eax, eax - rep stosd - - mov esi, [filename] - mov edi, [tmp_task_data] - mov ecx, 1024 - rep movsb - - mov esi, [cmdline] - test esi, esi - jz @f - mov ecx, 256 - rep movsb -@@: - mov eax, [tmp_task_data] - lea ebx, [eax+1024] ;cmd line - - stdcall fs_exec, eax, ebx, [flags] - - mov [retval], eax - popad - mov [pg_data.tmp_task_mutex], 0 - mov eax, [retval] - ret - -endp - - pid_to_slot: ;Input: ; eax - pid of process diff --git a/kernel/trunk/gui/event.inc b/kernel/trunk/gui/event.inc index e1ea82d5b1..1ada2ab36e 100644 --- a/kernel/trunk/gui/event.inc +++ b/kernel/trunk/gui/event.inc @@ -96,7 +96,7 @@ create_event: jz .fail mov [eax+APPOBJ.magic], 'EVNT' - mov [eax+APPOBJ.destroy], destroy_event + mov [eax+APPOBJ.destroy], destroy_event.internal mov [eax+EVENT.id], ebx mov ebx, [CURRENT_TASK] @@ -144,12 +144,12 @@ destroy_event: jne .fail cmp [eax+EVENT.id], ebx jne .fail - +.internal: mov ebx, [eax+APPOBJ.fd] mov ecx, [eax+APPOBJ.bk] mov [ebx+APPOBJ.bk], ecx mov [ecx+APPOBJ.fd], ebx -.internal: +.force: xor edx, edx ;clear common header mov [eax], edx mov [eax+4], edx @@ -268,7 +268,7 @@ proc get_event_ex stdcall, p_ev:dword, timeout:dword ret .destroy: - call destroy_event.internal + call destroy_event.force ret .switch: mov eax, [0x3010] @@ -331,7 +331,7 @@ wait_event: add esp, 4 ret .destroy: - call destroy_event.internal + call destroy_event.force add esp, 4 ret .switch: diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index e5badd9c32..b822d95128 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -418,9 +418,6 @@ B32: add eax, ebx mov [ipc_ptab], eax - stdcall kernel_alloc, 0x1000 - mov [tmp_task_data], eax - call init_events mov eax, srv.fd-SRV_FD_OFFSET @@ -682,12 +679,18 @@ include 'vmodeld.inc' cmp byte [0x2f0000+0x9030],1 jne no_load_vrr_m - stdcall fs_exec, vrr_m, 0, 0 + mov ebp, vrr_m + xor ebx, ebx + xor edx, edx + call fs_execute cmp eax,2 ; if vrr_m app found (PID=2) je first_app_found no_load_vrr_m: - stdcall fs_exec, firstapp, 0, 0 + mov ebp, firstapp + xor ebx, ebx + xor edx, edx + call fs_execute cmp eax,2 ; continue if a process has been loaded je first_app_found mov eax, 0xDEADBEEF ; otherwise halt diff --git a/kernel/trunk/memmap.inc b/kernel/trunk/memmap.inc index d403e18fed..b983ac898f 100644 --- a/kernel/trunk/memmap.inc +++ b/kernel/trunk/memmap.inc @@ -199,10 +199,10 @@ ; 760000 -> 76ffff !vrr driver ; 770000 -> 777fff tcp memory ( 32 kb) ; -; 778000 -> 77ffff window skinning ( 32 kb) -; 780000 -> 7fffff reserved to physical memory manager +; 780000 -> 987FFF TSS and IO map for (8192*8)=65536 ports +; (128+8192)*256 = 2129920 = 0x208000 ; -; 800000 -> 801FFF draw_data - 256 entries +; 988000 -> 98AFFF draw_data - 256 entries ; ; 00 dword draw limit - x start ; 04 dword draw limit - y start @@ -210,10 +210,7 @@ ; 0C dword draw limit - y end ; ; -; 803000 -> 0xA0AFFF TSS and IO map for (8192*8)=65536 ports -; (128+8192)*256 = 2129920 = 0x208000 -; -; 0xA0B000 -> kernel heap +; 0x0098B000 -> kernel heap