From 0e38558cb0b30745aa2da1dd01a44a071bf430b1 Mon Sep 17 00:00:00 2001 From: Doczom Date: Sat, 19 Mar 2022 16:20:29 +0000 Subject: [PATCH] fix bug in free group of port(46 sysf) in deleting thread git-svn-id: svn://kolibrios.org@9743 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/sys32.inc | 32 +++++++++++++++----------------- kernel/trunk/kernel.asm | 28 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index e323ea4da2..c4ea2e19d7 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -617,14 +617,6 @@ destroy_thread: lea ebx, [edi + APPDATA.list] list_del ebx ;destroys edx, ecx - mov eax, 0x20202020 - stosd - stosd - stosd - mov ecx, 244/4 - xor eax, eax - rep stosd - ; activate window movzx eax, word [WIN_STACK + esi*2] cmp eax, [thread_count] @@ -672,7 +664,6 @@ destroy_thread: mov edx, [SLOT_BASE + edx + APPDATA.tid] rmpr0: - mov esi, [RESERVED_PORTS] test esi, esi @@ -693,13 +684,6 @@ destroy_thread: jmp rmpr9 rmpr4: - push eax edx ebp ;TODO: check using register ebp in next code - mov eax, [edi + 4] - mov edx, [edi + 8] - xor ebp, ebp - inc ebp - call new_port_access_disable - pop ebp edx eax mov ecx, 256 sub ecx, esi @@ -715,8 +699,22 @@ destroy_thread: jmp rmpr0 rmpr9: - popa + +; clearing APPDATA structure this thread + pushad + mov edi, esi + shl edi, BSF sizeof.APPDATA + add edi, SLOT_BASE + mov eax, 0x20202020 + stosd + stosd + stosd + mov ecx, 244/4 + xor eax, eax + rep stosd + popad + mov edi, esi ; do not run this process slot shl edi, BSF sizeof.APPDATA mov [SLOT_BASE + edi + APPDATA.state], TSTATE_FREE diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index cac29e763e..bce6dbbe7a 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -3489,16 +3489,10 @@ align 4 set_io_access_rights: push edi eax mov edi, tss._io_map_0 -; mov ecx,eax -; and ecx,7 ; offset in byte -; shr eax,3 ; number of byte -; add edi,eax -; mov ebx,1 -; shl ebx,cl + test ebp, ebp ; enable access - ebp = 0 jnz .siar1 -; not ebx -; and [edi],byte bl + btr [edi], eax pop eax edi ret @@ -3508,7 +3502,13 @@ set_io_access_rights: ret align 4 -syscall_reserveportarea: ; ReservePortArea and FreePortArea +; @brief ReservePortArea and FreePortArea +; @param edx number end arrea of ports (include last number of port) +; @param ecx number start arrea of ports +; @param ebx sub function 0 - reserve, 1 - free +; @param eax 46 - number function +; @returns eax = 0 - succesful eax = 1 - error +syscall_reserveportarea: ; ReservePortArea and FreePortArea call r_f_port_area mov [esp+32], eax @@ -3532,7 +3532,7 @@ r_f_port_area: cmp ecx, edx ; beginning > end ? ja rpal1 - cmp edx, 65536 + cmp edx, 65536 ;test ebx, not 0xffff jae rpal1 mov eax, [RESERVED_PORTS] test eax, eax ; no reserved areas ? @@ -3541,7 +3541,7 @@ r_f_port_area: jae rpal1 rpal3: mov ebx, eax - shl ebx, 4 + shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table add ebx, RESERVED_PORTS cmp ecx, [ebx+8] ja rpal4 @@ -3578,9 +3578,9 @@ no_unmask_io: add eax, RESERVED_PORTS mov ebx, [current_slot] mov ebx, [ebx + APPDATA.tid] - mov [eax], ebx - mov [eax+4], ecx - mov [eax+8], edx + mov [eax], ebx ; tid + mov [eax+4], ecx ;start port + mov [eax+8], edx ;finish port xor eax, eax ret