diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index aa21fa71a5..6ab71e607e 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -388,23 +388,28 @@ struc PG_DATA .tmp_task_mutex dd ? } -struc LIB -{ .lib_name rb 16 - .lib_base dd ? - .lib_start dd ? - .export dd ? - .import dd ? -} +;struc LIB +;{ .lib_name rb 16 +; .lib_base dd ? +; .lib_start dd ? +; .export dd ? +; .import dd ? +;} struc SRV -{ .srv_name rb 16 - .magic dd ? - .size dd ? - .base dd ? - .entry dd ? - .srv_proc dd ? +{ .srv_name rb 16 ;ASCIIZ string + .magic dd ? ;+0x10 ;'SRV ' + .size dd ? ;+0x14 ;size of structure SRV + .fd dd ? ;+0x18 ;next SRV descriptor + .bk dd ? ;+0x1C ;prev SRV descriptor + .base dd ? ;+0x20 ;service base address + .entry dd ? ;+0x24 ;service START function + .srv_proc dd ? ;+0x28 ;main service handler } +SRV_FD_OFFSET equ 0x18 +SRV_SIZE equ 44 + struc COFF_HEADER { .machine dw ? .nSections dw ? @@ -459,12 +464,9 @@ virtual at 0 IOCTL IOCTL end virtual - -SRV_SIZE equ 36 - -virtual at 0 - LIB LIB -end virtual +;virtual at 0 +; LIB LIB +;end virtual virtual at 0 SRV SRV diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 7ef46d2984..5dc6f2937c 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -281,36 +281,31 @@ restore out_size align 4 proc get_service stdcall, sz_name:dword - locals - srv_ptr dd ? - counter dd ? - endl - mov eax, [sz_name] test eax, eax jnz @F ret @@: - mov [srv_ptr], srv_tab - mov [counter], 16 + mov edx, [srv.fd] @@: - stdcall strncmp, [srv_ptr], [sz_name], 16 + cmp edx, srv.fd-SRV_FD_OFFSET + je .not_load + + stdcall strncmp, edx, [sz_name], 16 test eax, eax je .ok - add [srv_ptr], SRV_SIZE - dec [counter] - jnz @B + mov edx, [edx+SRV.fd] + jmp @B .not_load: stdcall find_service, [sz_name] test eax, eax - jnz @F - ret -@@: + jz @F stdcall load_driver, eax +@@: ret .ok: - mov eax, [srv_ptr] + mov eax, edx ret endp @@ -343,40 +338,43 @@ proc find_service stdcall ,sz_name:dword endp align 4 -proc reg_service stdcall, sz_name:dword, handler:dword - locals - srv dd ? - endl - - mov eax, [sz_name] +reg_service: +.sz_name equ esp+4 +.handler equ esp+8 + mov eax, [.sz_name] test eax, eax jz .fail - mov ebx, [handler] + mov ebx, [.handler] test ebx, ebx jz .fail - call alloc_service + mov eax, SRV_SIZE + call malloc ;call alloc_service test eax, eax jz .fail - mov [srv], eax mov edi, eax - mov esi, [sz_name] - mov ecx, 16 - rep movsb + mov esi, [.sz_name] + mov ecx, 16/4 + rep movsd - mov edi, eax - mov [edi+SRV.magic], ' SRV' - mov [edi+SRV.size], SRV_SIZE - mov ebx, [handler] - mov [edi+SRV.srv_proc], ebx - mov eax, [srv] + mov [eax+SRV.magic], ' SRV' + mov [eax+SRV.size], SRV_SIZE + + mov ebx, srv.fd-SRV_FD_OFFSET + mov edx, [ebx+SRV.fd] + mov [eax+SRV.fd], edx + mov [eax+SRV.bk], ebx + mov [ebx+SRV.fd], eax + mov [edx+SRV.bk], eax + + mov ecx, [.handler] + mov [eax+SRV.srv_proc], ecx ret .fail: xor eax, eax ret -endp align 4 proc get_proc stdcall, exp:dword, sz_name:dword @@ -967,24 +965,26 @@ proc load_library stdcall, file_name:dword ret endp + align 4 proc stop_all_services - not [srv_map] + + mov edx, [srv.fd] .next: - bsf eax, [srv_map] - jnz .find - ret -.find: - btr [srv_map], eax - shl eax,0x02 - lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36 - cmp [eax+SRV.magic], ' SRV' + cmp edx, srv.fd-SRV_FD_OFFSET + je .done + cmp [edx+SRV.magic], ' SRV' jne .next - cmp [eax+SRV.size], SRV_SIZE + cmp [edx+SRV.size], SRV_SIZE jne .next - mov ebx, [eax+SRV.entry] + mov ebx, [edx+SRV.entry] + mov edx, [edx+SRV.fd] + push edx stdcall ebx, dword -1 + pop edx jmp .next +.done: + ret endp diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index 735f1dc47d..e7ec805486 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -800,6 +800,7 @@ proc user_free stdcall, base:dword ret endp +if 0 align 4 proc alloc_dll pushf @@ -833,3 +834,5 @@ proc alloc_service lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36 ret endp + +end if diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 27a42ed768..a32acaaeac 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -1300,15 +1300,18 @@ align 16 mst MEM_STATE - dll_tab rb 32*32 - srv_tab rb 36*32 +; dll_tab rb 32*32 +; srv_tab rb 36*32 mem_block_map rb 512 event_map rb 128 mem_block_list rd 64 mem_block_mask rd 2 - dll_map rd 1 - srv_map rd 1 +; dll_map rd 1 +; srv_map rd 1 + + srv.fd rd 1 + srv.bk rd 1 mem_used_list rd 1 mem_block_arr rd 1 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index b177eca4b3..c34a1d40f8 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -438,14 +438,18 @@ B32: call init_events - mov [dll_map], 0xFFFFFFFF - mov [srv_map], 0xFFFFFFFF +; mov [dll_map], 0xFFFFFFFF +; mov [srv_map], 0xFFFFFFFF - call alloc_dll - mov edi, eax - mov esi, szKernel - mov ecx, 16 - rep movsb +; call alloc_dll +; mov edi, eax +; mov esi, szKernel +; mov ecx, 16 +; rep movsb + + mov eax, srv.fd-SRV_FD_OFFSET + mov [srv.fd], eax + mov [srv.bk], eax mov edi, irq_tab xor eax, eax