From b1d15587ca8893842142ae18b38484ba47645459 Mon Sep 17 00:00:00 2001 From: "Alexey Teplov (" Date: Thu, 3 Dec 2009 18:48:41 +0000 Subject: [PATCH] optimization 46 and 64 sysfunc. git-svn-id: svn://kolibrios.org@1306 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/sys32.inc | 56 +++++--- kernel/trunk/core/syscall.inc | 8 +- kernel/trunk/drivers/com_mouse.asm | 28 ++-- kernel/trunk/drivers/sb16/sb16.asm | 10 +- kernel/trunk/kernel.asm | 212 +++++++++++++---------------- 5 files changed, 160 insertions(+), 154 deletions(-) diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 10722d93cb..256d992752 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -279,21 +279,27 @@ p_irq15: iret ready_for_next_irq: - mov [check_idle_semaphore],5 + mov eax,5 + mov [check_idle_semaphore],eax +; mov al, 0x20 + add eax,(0x20-0x5) + mov al, 0x20 out 0x20, al ret - +;destroy eax ready_for_next_irq_1: - mov [check_idle_semaphore],5 - mov al, 0x20 + mov eax,5 + mov [check_idle_semaphore],eax +; mov al, 0x20 + add eax,(0x20-0x5) out 0xa0,al out 0x20, al ret irqD: push eax - mov al,0 + xor eax,eax out 0xf0,al mov al,0x20 out 0xa0,al @@ -396,24 +402,32 @@ clear_application_table_status: cmp eax,[application_table_status] jne apptsl1 - mov [application_table_status],0 + xor eax,eax + mov [application_table_status],eax apptsl1: pop eax ret +; * eax = 64 - номер функции +; * ebx = 1 - единственная подфункция +; * ecx = новый размер памяти +;Возвращаемое значение: +; * eax = 0 - успешно +; * eax = 1 - недостаточно памяти + sys_resize_app_memory: - ; eax = 1 - resize - ; ebx = new amount of memory - - cmp eax,1 - jne .no_application_mem_resize + ; ebx = 1 - resize + ; ecx = new amount of memory +; cmp eax,1 + dec ebx + jnz .no_application_mem_resize +;fix it! + mov ebx,ecx stdcall new_mem_resize, ebx - mov [esp+36], eax - ret - + mov [esp+32], eax .no_application_mem_resize: ret @@ -689,22 +703,22 @@ term9: cmp [hd1_status], esi jnz @f call free_hd_channel - mov [hd1_status], 0 + and [hd1_status], 0 @@: cmp [cd_status], esi jnz @f call free_cd_channel - mov [cd_status], 0 + and [cd_status], 0 @@: cmp [flp_status], esi jnz @f - mov [flp_status], 0 + and [flp_status], 0 @@: pop esi cmp [bgrlockpid], esi jnz @f and [bgrlockpid], 0 - mov [bgrlock], 0 + and [bgrlock], 0 @@: pusha ; remove all irq reservations @@ -736,8 +750,8 @@ term9: mov esi,[RESERVED_PORTS] - cmp esi,0 - je rmpr9 + test esi,esi + jz rmpr9 rmpr3: @@ -808,7 +822,7 @@ term9: mov [MOUSE_BACKGROUND],byte 0 ; no mouse background mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse - mov [application_table_status],0 + and [application_table_status],0 ;mov esi,process_terminated ;call sys_msg_board_str add esp, 4 diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index 454059de5e..cd0cbbf45f 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -149,7 +149,7 @@ iglobal dd 0 ; 43-SendDeviceData dd 0 dd 0 - dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea + dd 0 ; 46-ReservePortArea and FreePortArea dd display_number ; 47-WriteNum dd display_settings ; 48-SetRedrawType and SetButtonType dd sys_apm ; 49-Advanced Power Management (APM) @@ -167,7 +167,7 @@ iglobal dd sys_gs ; 61-Direct graphics access dd sys_pci ; 62-PCI functions dd sys_msg_board ; 63-System message board - dd sys_resize_app_memory ; 64-Resize application memory usage + dd 0 ; 64-Resize application memory usage dd syscall_putimage_palette; 65-PutImagePalette dd sys_process_def ; 66-Process definitions - keyboard dd sys_window_move ; 67-Window move or resize @@ -228,7 +228,7 @@ iglobal dd sys_outport ; 43-SendDeviceData dd sys_programirq ; 44-ProgramIrqs dd reserve_free_irq ; 45-ReserveIrq and FreeIrq - dd cross_order ; 46-ReservePortArea and FreePortArea + dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea dd cross_order ; 47-WriteNum dd cross_order ; 48-SetRedrawType and SetButtonType dd cross_order ; 49-Advanced Power Management (APM) @@ -246,7 +246,7 @@ iglobal dd cross_order ; 61-Direct graphics access dd cross_order ; 62-PCI functions dd cross_order ; 63-System message board - dd cross_order ; 64-Resize application memory usage + dd sys_resize_app_memory ; 64-Resize application memory usage dd cross_order ; 65-PutImagePalette dd cross_order ; 66-Process definitions - keyboard dd cross_order ; 67-Window move or resize diff --git a/kernel/trunk/drivers/com_mouse.asm b/kernel/trunk/drivers/com_mouse.asm index 4d764fd243..4996aae182 100644 --- a/kernel/trunk/drivers/com_mouse.asm +++ b/kernel/trunk/drivers/com_mouse.asm @@ -5,6 +5,7 @@ ;; ;; ;; Includes source code by Kulakov Vladimir Gennadievich. ;; ;; Modified by Mario79 and Rus. ;; +;; 02.12.2009 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;driver sceletone @@ -67,16 +68,19 @@ end if stdcall AttachIntHandler, 4, irq4_handler, dword 0 if DEBUG - cmp eax, 0 + test eax, eax jne .label1 mov esi, msg_error_attach_int_handler call Boot_Log end if .label1: - mov eax, 0 - mov ebx, 0x3F8 - mov ecx, 0x3FF +; mov eax, 0 +; mov ebx, 0x3F8 +; mov ecx, 0x3FF + xor ebx,ebx + mov ecx, 0x3F8 + mov edx, 0x3FF call ReservePortArea if DEBUG @@ -100,9 +104,13 @@ end if stdcall AttachIntHandler, 3, irq3_handler, dword 0 - mov eax, 0 - mov ebx, 0x2F8 - mov ecx, 0x3F8 +; mov eax, 0 +; mov ebx, 0x2F8 +; mov ecx, 0x3F8 + xor ebx,ebx + mov ecx, 0x2F8 + mov edx, 0x3F8 + call ReservePortArea if DEBUG cmp eax, 1 @@ -119,7 +127,7 @@ end if stdcall RegService, my_service, service_proc if DEBUG - cmp eax, 0 + test eax, eax jne @f mov esi, msg_exit @@ -219,8 +227,8 @@ MouseSearch: WaitData: ; Ожидать еще 10 "тиков" dec ecx - cmp ecx,0 - je NoMouse +; cmp ecx,0 + jz NoMouse ; Проверить наличие идентификационного байта mov DX, bx add DX,5 diff --git a/kernel/trunk/drivers/sb16/sb16.asm b/kernel/trunk/drivers/sb16/sb16.asm index 91674bcdbf..33a62da5df 100644 --- a/kernel/trunk/drivers/sb16/sb16.asm +++ b/kernel/trunk/drivers/sb16/sb16.asm @@ -66,9 +66,13 @@ if DEBUG mov esi,msgDSPFound call SysMsgBoardStr end if - xor eax,eax - mov ebx,[sb_base_port] - lea ecx,[ebx+0xF] +; xor eax,eax +; mov ebx,[sb_base_port] +; lea ecx,[ebx+0xF] + xor ebx,ebx + mov ecx,[sb_base_port] + lea edx,[ebx+0xF] + call ReservePortArea ;these ports must be my! if DEBUG dec eax diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index f870d64a9a..54f3271a4c 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -4015,193 +4015,173 @@ get_irq_data: set_io_access_rights: - - pushad - - mov edi, tss._io_map_0 - + 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 ; cmp ebp,0 ; enable access - ebp = 0 jnz siar1 - ; not ebx ; and [edi],byte bl btr [edi], eax - - popad - + pop eax edi ret - siar1: - bts [edi], eax ; or [edi],byte bl ; disable access - ebp = 1 - - popad - + pop eax edi ret - +;reserve/free group of ports +; * eax = 46 - number function +; * ebx = 0 - reserve, 1 - free +; * ecx = number start arrea of ports +; * edx = number end arrea of ports (include last number of port) +;Return value: +; * eax = 0 - succesful +; * eax = 1 - error +; * The system has reserve this ports: +; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). +;destroys eax,ebx, ebp r_f_port_area: - test eax, eax + test ebx, ebx jnz free_port_area ; je r_port_area ; jmp free_port_area ; r_port_area: - pushad +; pushad - cmp ebx,ecx ; beginning > end ? + cmp ecx,edx ; beginning > end ? ja rpal1 - cmp ecx,65536 + cmp edx,65536 jae rpal1 - mov esi,[RESERVED_PORTS] - test esi,esi ; no reserved areas ? + mov eax,[RESERVED_PORTS] + test eax,eax ; no reserved areas ? je rpal2 - cmp esi,255 ; max reserved + cmp eax,255 ; max reserved jae rpal1 rpal3: - mov edi,esi - shl edi,4 - add edi,RESERVED_PORTS - cmp ebx,[edi+8] + mov ebx,eax + shl ebx,4 + add ebx,RESERVED_PORTS + cmp ecx,[ebx+8] ja rpal4 - cmp ecx,[edi+4] + cmp edx,[ebx+4] jae rpal1 ; jb rpal4 ; jmp rpal1 rpal4: - - dec esi + dec eax jnz rpal3 jmp rpal2 rpal1: - popad - mov eax,1 +; popad +; mov eax,1 + xor eax,eax + inc eax ret - rpal2: - popad - - +; popad ; enable port access at port IO map - cli - pushad ; start enable io map - - cmp ecx,65536 ;16384 - jae no_unmask_io ; jge - - mov eax,ebx - - new_port_access: - - pushad - - xor ebp,ebp ; enable - eax = port - call set_io_access_rights - - popad + cli + pushad ; start enable io map + cmp edx,65536 ;16384 + jae no_unmask_io ; jge + mov eax,ecx +; push ebp + xor ebp,ebp ; enable - eax = port +new_port_access: +; pushad + call set_io_access_rights +; popad inc eax - cmp eax,ecx + cmp eax,edx jbe new_port_access - - no_unmask_io: - - popad ; end enable io map +; pop ebp +no_unmask_io: + popad ; end enable io map sti - mov edi,[RESERVED_PORTS] - add edi,1 - mov [RESERVED_PORTS],edi - shl edi,4 - add edi,RESERVED_PORTS - mov esi,[TASK_BASE] - mov esi,[esi+TASKDATA.pid] - mov [edi],esi - mov [edi+4],ebx - mov [edi+8],ecx + mov eax,[RESERVED_PORTS] + add eax,1 + mov [RESERVED_PORTS],eax + shl eax,4 + add eax,RESERVED_PORTS + mov ebx,[TASK_BASE] + mov ebx,[ebx+TASKDATA.pid] + mov [eax],ebx + mov [eax+4],ecx + mov [eax+8],edx xor eax, eax ret free_port_area: - pushad - - mov esi,[RESERVED_PORTS] ; no reserved areas ? - test esi,esi - je frpal2 - mov edx,[TASK_BASE] - mov edx,[edx+TASKDATA.pid] +; pushad + mov eax,[RESERVED_PORTS] ; no reserved areas ? + test eax,eax + jz frpal2 + mov ebx,[TASK_BASE] + mov ebx,[ebx+TASKDATA.pid] frpal3: - mov edi,esi + mov edi,eax shl edi,4 add edi,RESERVED_PORTS - cmp edx,[edi] + cmp ebx,[edi] jne frpal4 - cmp ebx,[edi+4] + cmp ecx,[edi+4] jne frpal4 - cmp ecx,[edi+8] + cmp edx,[edi+8] jne frpal4 jmp frpal1 frpal4: - dec esi + dec eax jnz frpal3 frpal2: - popad - mov eax,1 +; popad + inc eax ret frpal1: - mov ecx,256 - sub ecx,esi - shl ecx,4 - mov esi,edi - add esi,16 - cld - rep movsb + push ecx + mov ecx,256 + sub ecx,eax + shl ecx,4 + mov esi,edi + add esi,16 + cld + rep movsb - dec dword [RESERVED_PORTS] + dec dword [RESERVED_PORTS] +;popad +;disable port access at port IO map - popad - - - ; disable port access at port IO map - - pushad ; start disable io map - - cmp ecx,65536 ;16384 +; pushad ; start disable io map + pop eax ;start port + cmp edx,65536 ;16384 jge no_mask_io - mov eax,ebx - - new_port_access_disable: - - pushad - - mov ebp,1 ; disable - eax = port +; mov eax,ecx + xor ebp,ebp + inc ebp +new_port_access_disable: +; pushad +; mov ebp,1 ; disable - eax = port call set_io_access_rights - - popad - +; popad inc eax - cmp eax,ecx + cmp eax,edx jbe new_port_access_disable - - no_mask_io: - - popad ; end disable io map - +no_mask_io: +; popad ; end disable io map xor eax, eax ret @@ -5381,7 +5361,7 @@ align 4 syscall_reserveportarea: ; ReservePortArea and FreePortArea call r_f_port_area - mov [esp+36],eax + mov [esp+32],eax ret align 4