forked from KolibriOS/kolibrios
reduce kernel memory
git-svn-id: svn://kolibrios.org@363 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8df9a500b6
commit
0f0c0aabfa
@ -225,11 +225,10 @@ resendQ equ OS_BASE+0x0770000
|
|||||||
|
|
||||||
;skin_data equ OS_BASE+0x0778000
|
;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 0x98B000
|
||||||
|
|
||||||
HEAP_BASE equ 0xA0B000 ;x00C00000
|
|
||||||
|
|
||||||
pages_tab equ 0x60000000
|
pages_tab equ 0x60000000
|
||||||
master_tab equ 0x60180000
|
master_tab equ 0x60180000
|
||||||
@ -435,7 +434,6 @@ struc PG_DATA
|
|||||||
.kernel_tables dd ?
|
.kernel_tables dd ?
|
||||||
.sys_page_dir dd ?
|
.sys_page_dir dd ?
|
||||||
.pg_mutex dd ?
|
.pg_mutex dd ?
|
||||||
.tmp_task_mutex dd ?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
;struc LIB
|
;struc LIB
|
||||||
|
@ -461,6 +461,20 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
|
|||||||
ret
|
ret
|
||||||
endp
|
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
|
align 4
|
||||||
proc load_file stdcall, file_name:dword
|
proc load_file stdcall, file_name:dword
|
||||||
locals
|
locals
|
||||||
|
@ -1363,7 +1363,6 @@ align 16
|
|||||||
|
|
||||||
tmp_task_pdir rd 1
|
tmp_task_pdir rd 1
|
||||||
tmp_task_ptab rd 1
|
tmp_task_ptab rd 1
|
||||||
tmp_task_data rd 1
|
|
||||||
|
|
||||||
fdd_buff rd 1
|
fdd_buff rd 1
|
||||||
LFBSize rd 1
|
LFBSize rd 1
|
||||||
|
@ -543,14 +543,14 @@ get_app_params:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
uglobal
|
uglobal
|
||||||
new_process_place dd 0x0
|
; new_process_place dd 0x0
|
||||||
app_start dd 0x0
|
; app_start dd 0x0
|
||||||
app_i_end dd 0x0
|
; app_i_end dd 0x0
|
||||||
app_mem dd 0x0
|
; app_mem dd 0x0
|
||||||
app_esp dd 0x0
|
; app_esp dd 0x0
|
||||||
app_i_param dd 0x0
|
; app_i_param dd 0x0
|
||||||
app_i_icon dd 0x0
|
; app_i_icon dd 0x0
|
||||||
app_mem_pos dd 0x0
|
; app_mem_pos dd 0x0
|
||||||
endg
|
endg
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
@ -71,24 +71,54 @@ macro _clear_ op
|
|||||||
rep stosd
|
rep stosd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
align 4
|
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
|
locals
|
||||||
|
cmdline rd 64 ;256/4
|
||||||
|
filename rd 256 ;1024/4
|
||||||
|
flags dd ?
|
||||||
|
|
||||||
save_cr3 dd ?
|
save_cr3 dd ?
|
||||||
slot dd ?
|
slot dd ?
|
||||||
slot_base dd ?
|
slot_base dd ?
|
||||||
file_base dd ?
|
file_base dd ?
|
||||||
file_size dd ?
|
file_size dd ?
|
||||||
|
;app header data
|
||||||
app_cmdline dd ? ;0x00
|
hdr_cmdline dd ? ;0x00
|
||||||
app_path dd ? ;0x04
|
hdr_path dd ? ;0x04
|
||||||
app_eip dd ? ;0x08
|
hdr_eip dd ? ;0x08
|
||||||
app_esp dd ? ;0x0C
|
hdr_esp dd ? ;0x0C
|
||||||
app_mem dd ? ;0x10
|
hdr_mem dd ? ;0x10
|
||||||
app_i_end dd ? ;0x14
|
hdr_i_end dd ? ;0x14
|
||||||
endl
|
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
|
mov ecx, -ERROR_FILE_NOT_FOUND
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err_file
|
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_base], eax
|
||||||
mov [file_size], ebx
|
mov [file_size], ebx
|
||||||
|
|
||||||
lea ebx, [app_cmdline]
|
lea ebx, [hdr_cmdline]
|
||||||
call test_app_header
|
call test_app_header
|
||||||
mov ecx, -0x1F
|
mov ecx, -0x1F
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -117,8 +147,8 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword
|
|||||||
cmp eax, 0
|
cmp eax, 0
|
||||||
jne .wait_lock
|
jne .wait_lock
|
||||||
|
|
||||||
pushfd
|
; pushfd
|
||||||
cli
|
; cli
|
||||||
|
|
||||||
call set_application_table_status
|
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
|
_clear_ 256 ;clean extended information about process
|
||||||
|
|
||||||
; write application name
|
; write application name
|
||||||
mov edi, [file_name]
|
lea edi, [filename]
|
||||||
mov al, '/'
|
mov al, '/'
|
||||||
call k_strrchr ; now eax points to name without path
|
call k_strrchr ; now eax points to name without path
|
||||||
|
|
||||||
lea esi, [eax+1]
|
lea esi, [eax+1]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @F
|
jnz @F
|
||||||
mov esi, [file_name]
|
lea esi, [filename]
|
||||||
@@:
|
@@:
|
||||||
mov ecx, 8 ; 8 chars for name
|
mov ecx, 8 ; 8 chars for name
|
||||||
mov edi, [slot_base]
|
mov edi, [slot_base]
|
||||||
@ -159,18 +189,18 @@ proc fs_exec stdcall file_name:dword, cmd_line:dword, flags:dword
|
|||||||
mov ebx, cr3
|
mov ebx, cr3
|
||||||
mov [save_cr3], ebx
|
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
|
test eax, eax
|
||||||
jz .failed
|
jz .failed
|
||||||
|
|
||||||
mov ebx,[slot_base]
|
mov ebx,[slot_base]
|
||||||
mov [ebx+APPDATA.dir_table],eax
|
mov [ebx+APPDATA.dir_table],eax
|
||||||
mov eax,[app_mem]
|
mov eax,[hdr_mem]
|
||||||
mov [ebx+APPDATA.mem_size],eax
|
mov [ebx+APPDATA.mem_size],eax
|
||||||
|
|
||||||
if GREEDY_KERNEL
|
if GREEDY_KERNEL
|
||||||
else
|
else
|
||||||
mov ecx, [app_mem]
|
mov ecx, [hdr_mem]
|
||||||
mov edi, [file_size]
|
mov edi, [file_size]
|
||||||
add edi, 4095
|
add edi, 4095
|
||||||
and edi, not 4095
|
and edi, not 4095
|
||||||
@ -187,14 +217,15 @@ end if
|
|||||||
; release only virtual space, not phisical memory
|
; release only virtual space, not phisical memory
|
||||||
|
|
||||||
stdcall free_kernel_space, [file_base]
|
stdcall free_kernel_space, [file_base]
|
||||||
lea eax, [app_cmdline]
|
lea eax, [hdr_cmdline]
|
||||||
stdcall set_app_params ,[slot],eax,[cmd_line],\
|
lea ebx, [cmdline]
|
||||||
[file_name], [flags]
|
lea ecx, [filename]
|
||||||
|
stdcall set_app_params ,[slot],eax,ebx,ecx,[flags]
|
||||||
|
|
||||||
mov eax, [save_cr3]
|
mov eax, [save_cr3]
|
||||||
call set_cr3
|
call set_cr3
|
||||||
|
|
||||||
popfd
|
; popfd
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov [application_table_status],ebx ;unlock application_table_status mutex
|
mov [application_table_status],ebx ;unlock application_table_status mutex
|
||||||
mov eax,[process_number] ;set result
|
mov eax,[process_number] ;set result
|
||||||
@ -203,7 +234,7 @@ end if
|
|||||||
mov eax, [save_cr3]
|
mov eax, [save_cr3]
|
||||||
call set_cr3
|
call set_cr3
|
||||||
.err:
|
.err:
|
||||||
popfd
|
; popfd
|
||||||
.err_hdr:
|
.err_hdr:
|
||||||
stdcall kernel_free,[file_base]
|
stdcall kernel_free,[file_base]
|
||||||
.err_file:
|
.err_file:
|
||||||
@ -548,63 +579,6 @@ proc destroy_app_space stdcall, pg_dir:dword
|
|||||||
ret
|
ret
|
||||||
endp
|
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:
|
pid_to_slot:
|
||||||
;Input:
|
;Input:
|
||||||
; eax - pid of process
|
; eax - pid of process
|
||||||
|
@ -96,7 +96,7 @@ create_event:
|
|||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
mov [eax+APPOBJ.magic], 'EVNT'
|
mov [eax+APPOBJ.magic], 'EVNT'
|
||||||
mov [eax+APPOBJ.destroy], destroy_event
|
mov [eax+APPOBJ.destroy], destroy_event.internal
|
||||||
mov [eax+EVENT.id], ebx
|
mov [eax+EVENT.id], ebx
|
||||||
|
|
||||||
mov ebx, [CURRENT_TASK]
|
mov ebx, [CURRENT_TASK]
|
||||||
@ -144,12 +144,12 @@ destroy_event:
|
|||||||
jne .fail
|
jne .fail
|
||||||
cmp [eax+EVENT.id], ebx
|
cmp [eax+EVENT.id], ebx
|
||||||
jne .fail
|
jne .fail
|
||||||
|
.internal:
|
||||||
mov ebx, [eax+APPOBJ.fd]
|
mov ebx, [eax+APPOBJ.fd]
|
||||||
mov ecx, [eax+APPOBJ.bk]
|
mov ecx, [eax+APPOBJ.bk]
|
||||||
mov [ebx+APPOBJ.bk], ecx
|
mov [ebx+APPOBJ.bk], ecx
|
||||||
mov [ecx+APPOBJ.fd], ebx
|
mov [ecx+APPOBJ.fd], ebx
|
||||||
.internal:
|
.force:
|
||||||
xor edx, edx ;clear common header
|
xor edx, edx ;clear common header
|
||||||
mov [eax], edx
|
mov [eax], edx
|
||||||
mov [eax+4], edx
|
mov [eax+4], edx
|
||||||
@ -268,7 +268,7 @@ proc get_event_ex stdcall, p_ev:dword, timeout:dword
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.destroy:
|
.destroy:
|
||||||
call destroy_event.internal
|
call destroy_event.force
|
||||||
ret
|
ret
|
||||||
.switch:
|
.switch:
|
||||||
mov eax, [0x3010]
|
mov eax, [0x3010]
|
||||||
@ -331,7 +331,7 @@ wait_event:
|
|||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
.destroy:
|
.destroy:
|
||||||
call destroy_event.internal
|
call destroy_event.force
|
||||||
add esp, 4
|
add esp, 4
|
||||||
ret
|
ret
|
||||||
.switch:
|
.switch:
|
||||||
|
@ -418,9 +418,6 @@ B32:
|
|||||||
add eax, ebx
|
add eax, ebx
|
||||||
mov [ipc_ptab], eax
|
mov [ipc_ptab], eax
|
||||||
|
|
||||||
stdcall kernel_alloc, 0x1000
|
|
||||||
mov [tmp_task_data], eax
|
|
||||||
|
|
||||||
call init_events
|
call init_events
|
||||||
|
|
||||||
mov eax, srv.fd-SRV_FD_OFFSET
|
mov eax, srv.fd-SRV_FD_OFFSET
|
||||||
@ -682,12 +679,18 @@ include 'vmodeld.inc'
|
|||||||
cmp byte [0x2f0000+0x9030],1
|
cmp byte [0x2f0000+0x9030],1
|
||||||
jne no_load_vrr_m
|
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)
|
cmp eax,2 ; if vrr_m app found (PID=2)
|
||||||
je first_app_found
|
je first_app_found
|
||||||
|
|
||||||
no_load_vrr_m:
|
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
|
cmp eax,2 ; continue if a process has been loaded
|
||||||
je first_app_found
|
je first_app_found
|
||||||
mov eax, 0xDEADBEEF ; otherwise halt
|
mov eax, 0xDEADBEEF ; otherwise halt
|
||||||
|
@ -199,10 +199,10 @@
|
|||||||
; 760000 -> 76ffff !vrr driver
|
; 760000 -> 76ffff !vrr driver
|
||||||
; 770000 -> 777fff tcp memory ( 32 kb)
|
; 770000 -> 777fff tcp memory ( 32 kb)
|
||||||
;
|
;
|
||||||
; 778000 -> 77ffff window skinning ( 32 kb)
|
; 780000 -> 987FFF TSS and IO map for (8192*8)=65536 ports
|
||||||
; 780000 -> 7fffff reserved to physical memory manager
|
; (128+8192)*256 = 2129920 = 0x208000
|
||||||
;
|
;
|
||||||
; 800000 -> 801FFF draw_data - 256 entries
|
; 988000 -> 98AFFF draw_data - 256 entries
|
||||||
;
|
;
|
||||||
; 00 dword draw limit - x start
|
; 00 dword draw limit - x start
|
||||||
; 04 dword draw limit - y start
|
; 04 dword draw limit - y start
|
||||||
@ -210,10 +210,7 @@
|
|||||||
; 0C dword draw limit - y end
|
; 0C dword draw limit - y end
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
; 803000 -> 0xA0AFFF TSS and IO map for (8192*8)=65536 ports
|
; 0x0098B000 -> kernel heap
|
||||||
; (128+8192)*256 = 2129920 = 0x208000
|
|
||||||
;
|
|
||||||
; 0xA0B000 -> kernel heap
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user