From 7b51a898527a0d563aece3133cc6e80cbf63adbd Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Mon, 15 Jan 2024 05:16:31 +0000 Subject: [PATCH] Use process_information structure in the kernel Copied from the userspace macros.inc git-svn-id: svn://kolibrios.org@9967 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/const.inc | 16 ++++++++++++++++ kernel/trunk/kernel.asm | 20 ++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 94a851fc66..f2fc065bb8 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -485,6 +485,22 @@ struct BOX height dd ? ends +struct process_information + cpu_usage dd ? ; +0 + window_stack_position dw ? ; +4 + window_stack_value dw ? ; +6 + dw ? ; +8 + process_name rb 12 ; +10 + memory_start dd ? ; +22 + used_memory dd ? ; +26 + PID dd ? ; +30 + box BOX ; +34 + slot_state dw ? ; +50 + dw ? ; +52 + client_box BOX ; +54 + wnd_state db ? ; +70 +ends + struct APPDATA app_name rb 11 rb 5 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 811717a149..001954165e 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -2412,18 +2412,10 @@ sys_cachetodiskette: align 4 sys_cpuusage: -; RETURN: -; -; +00 dword process cpu usage -; +04 word position in windowing stack -; +06 word windowing stack value at current position (cpu nro) -; +10 12 bytes name -; +22 dword start in mem -; +26 dword used mem -; +30 dword PID , process idenfification number +; RETURN: process_information structure ; ; if given memory address belongs to kernel then error - stdcall is_region_userspace, ebx, 0x4C + stdcall is_region_userspace, ebx, sizeof.process_information jnz .addr_error cmp ecx, -1 ; who am I ? @@ -2437,21 +2429,21 @@ sys_cpuusage: ; +4: word: position of the window of thread in the window stack mov ax, [WIN_STACK + ecx * 2] - mov [ebx+4], ax + mov [ebx+process_information.window_stack_position], ax ; +6: word: number of the thread slot, which window has in the window stack ; position ecx (has no relation to the specific thread) mov ax, [WIN_POS + ecx * 2] - mov [ebx+6], ax + mov [ebx+process_information.window_stack_value], ax shl ecx, BSF sizeof.APPDATA ; +0: dword: memory usage mov eax, [SLOT_BASE + ecx + APPDATA.cpu_usage] - mov [ebx], eax + mov [ebx+process_information.cpu_usage], eax ; +10: 11 bytes: name of the process push ecx lea eax, [SLOT_BASE + ecx + APPDATA.app_name] - add ebx, 10 + add ebx, process_information.process_name mov ecx, 11 call memmove pop ecx