From a7414ad7ff4a587cd72b84f6620ca92651cb980f Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 8 Jan 2014 21:12:36 +0000 Subject: [PATCH] kolibri-process:use [current_process] instead of [APPDATA.process] git-svn-id: svn://kolibrios.org@4432 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/kolibri-process/core/heap.inc | 41 ++++++------------- .../branches/kolibri-process/core/sched.inc | 6 +-- .../branches/kolibri-process/core/taskman.inc | 10 ++--- kernel/branches/kolibri-process/data32.inc | 4 +- kernel/branches/kolibri-process/kernel.asm | 2 + 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/kernel/branches/kolibri-process/core/heap.inc b/kernel/branches/kolibri-process/core/heap.inc index da4b353563..ab4dae1865 100644 --- a/kernel/branches/kolibri-process/core/heap.inc +++ b/kernel/branches/kolibri-process/core/heap.inc @@ -565,8 +565,7 @@ HEAP_TOP equ 0x80000000 align 4 proc init_heap - mov ebx, [current_slot] - mov ebx, [ebx+APPDATA.process] + mov ebx, [current_process] mov eax, [ebx+PROC.heap_top] test eax, eax jz @F @@ -602,8 +601,7 @@ proc user_alloc stdcall, alloc_size:dword add ecx, (4095+PAGE_SIZE) and ecx, not 4095 - mov ebx, [current_slot] - mov ebx, [ebx+APPDATA.process] + mov ebx, [current_process] mov esi, dword [ebx+PROC.heap_base] ; heap_base mov edi, dword [ebx+PROC.heap_top] ; heap_top .scan: @@ -639,9 +637,7 @@ proc user_alloc stdcall, alloc_size:dword jnz @B .no: - mov edx, [current_slot] - mov edx, [edx+APPDATA.process] - + mov edx, [current_process] mov ebx, [alloc_size] add ebx, 0xFFF and ebx, not 0xFFF @@ -676,8 +672,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword push esi push edi - mov ebx, [current_slot] - mov ebx, [ebx+APPDATA.process] + mov ebx, [current_process] mov edx, [address] and edx, not 0xFFF @@ -753,9 +748,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword mov [page_tabs+ebx*4], ecx .nothird: - mov edx, [current_slot] - mov edx, [edx+APPDATA.process] - + mov edx, [current_process] mov ebx, [alloc_size] add ebx, 0xFFF and ebx, not 0xFFF @@ -815,8 +808,7 @@ proc user_free stdcall, base:dword .released: push edi - mov edx, [current_slot] - mov edx, [edx+APPDATA.process] + mov edx, [current_process] mov esi, dword [edx+PROC.heap_base] mov edi, dword [edx+PROC.heap_top] sub ebx, [edx+PROC.mem_used] @@ -1004,8 +996,7 @@ user_realloc: jnz .nofreeall mov eax, [page_tabs+ecx*4] and eax, not 0xFFF - mov edx, [current_slot] - mov edx, [edx+APPDATA.process] + mov edx, [current_process] mov ebx, [edx+PROC.mem_used] sub ebx, eax add ebx, 0x1000 @@ -1026,8 +1017,7 @@ user_realloc: shr ebx, 12 sub ebx, edx push ebx ecx edx - mov edx, [current_slot] - mov edx, [edx+APPDATA.process] + mov edx, [current_process] shl ebx, 12 sub ebx, [edx+PROC.mem_used] neg ebx @@ -1041,8 +1031,7 @@ user_realloc: shl ebx, 12 jz .ret push esi - mov esi, [current_slot] - mov esi, [esi+APPDATA.process] + mov esi, [current_process] mov esi, [esi+PROC.heap_top] shr esi, 12 @@: @@ -1066,8 +1055,7 @@ user_realloc: ret .realloc_add: ; get some additional memory - mov eax, [current_slot] - mov eax, [eax+APPDATA.process] + mov eax, [current_process] mov eax, [eax+PROC.heap_top] shr eax, 12 cmp edx, eax @@ -1100,16 +1088,14 @@ user_realloc: cld rep stosd pop edi - mov edx, [current_slot] - mov edx, [edx+APPDATA.process] + mov edx, [current_process] shl ebx, 12 add [edx+PROC.mem_used], ebx pop eax edx ecx ret .cant_inplace: push esi edi - mov eax, [current_slot] - mov eax, [eax+APPDATA.process] + mov eax, [current_process] mov esi, [eax+PROC.heap_base] mov edi, [eax+PROC.heap_top] shr esi, 12 @@ -1174,8 +1160,7 @@ user_realloc: jnz @b .no: push ebx - mov edx, [current_slot] - mov edx, [eax+APPDATA.process] + mov edx, [current_process] shl ebx, 12 add [edx+PROC.mem_used], ebx pop ebx diff --git a/kernel/branches/kolibri-process/core/sched.inc b/kernel/branches/kolibri-process/core/sched.inc index 7558e345c7..82cc9d029b 100644 --- a/kernel/branches/kolibri-process/core/sched.inc +++ b/kernel/branches/kolibri-process/core/sched.inc @@ -121,10 +121,10 @@ do_change_task: 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 - mov ecx, APPDATA.process - mov eax, [ebx+ecx] ;offset>0x7F - cmp eax, [esi+ecx] ;offset>0x7F + mov eax, [ebx+APPDATA.process] + cmp eax, [current_process] je @f + mov [current_process], eax mov eax, [eax+PROC.pdt_0_phys] mov cr3, eax @@: diff --git a/kernel/branches/kolibri-process/core/taskman.inc b/kernel/branches/kolibri-process/core/taskman.inc index ab104dfb4d..13ed7169fc 100644 --- a/kernel/branches/kolibri-process/core/taskman.inc +++ b/kernel/branches/kolibri-process/core/taskman.inc @@ -248,8 +248,7 @@ proc fs_execute loop .copy_process_name_loop .copy_process_name_done: - mov ebx, [current_slot] - mov ebx, [ebx+APPDATA.process] + mov ebx, [current_process] mov [save_proc], ebx stdcall create_process, [hdr_mem], [file_base], [file_size] @@ -431,8 +430,6 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword mov ecx, pg_data.mutex call mutex_lock - xchg bx, bx - xor eax, eax mov [process], eax @@ -565,11 +562,14 @@ endp align 4 set_cr3: - + pushfd + cli mov ebx, [current_slot] + mov [current_process], eax mov [ebx+APPDATA.process], eax mov eax, [eax+PROC.pdt_0_phys] mov cr3, eax + popfd ret align 4 diff --git a/kernel/branches/kolibri-process/data32.inc b/kernel/branches/kolibri-process/data32.inc index 2a3fb4f85e..c9bf656103 100644 --- a/kernel/branches/kolibri-process/data32.inc +++ b/kernel/branches/kolibri-process/data32.inc @@ -446,7 +446,9 @@ default_io_map rd 1 LFBSize rd 1 -current_slot rd 1 +current_process rd 1 +current_slot rd 1 ; i.e. cureent thread + ; status hd1_status rd 1 ; 0 - free : other - pid diff --git a/kernel/branches/kolibri-process/kernel.asm b/kernel/branches/kolibri-process/kernel.asm index f08ec16ca7..391d609834 100644 --- a/kernel/branches/kolibri-process/kernel.asm +++ b/kernel/branches/kolibri-process/kernel.asm @@ -730,6 +730,8 @@ no_mode_0x12: stosd stosd + mov [current_process], sys_proc + mov edx, SLOT_BASE+256*1 mov ebx, [os_stack_seg] add ebx, 0x2000