From ad63ea7013204581a2053d04a1a1aab3f5581144 Mon Sep 17 00:00:00 2001 From: "Alexey Teplov (" Date: Wed, 2 Dec 2009 17:10:46 +0000 Subject: [PATCH] 30 and 43 sysfunc rewritten without cross registers call. git-svn-id: svn://kolibrios.org@1304 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/syscall.inc | 12 ++-- kernel/trunk/docs/sysfuncr.txt | 3 +- kernel/trunk/fs/fs_lfn.inc | 77 ++++++++++++++++--------- kernel/trunk/kernel.asm | 102 +++++++++++++++++---------------- 4 files changed, 109 insertions(+), 85 deletions(-) diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index f906795744..454059de5e 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -133,7 +133,7 @@ iglobal dd 0 dd 0 ; dd 0 - dd sys_current_directory ; 30-Get/SetCurrentDirectory + dd 0 ; 30-Get/SetCurrentDirectory dd 0 dd 0 dd 0 @@ -142,11 +142,11 @@ iglobal dd 0 dd 0 ; 37-GetMousePosition_ScreenRelative,. dd 0 ; 38-DrawLine - dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,. + dd 0 ; 39-GetBackgroundSize,ReadBgrData,. dd 0 dd 0 dd 0 - dd sys_outport ; 43-SendDeviceData + dd 0 ; 43-SendDeviceData dd 0 dd 0 dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea @@ -212,7 +212,7 @@ iglobal dd undefined_syscall ; 27-reserved dd undefined_syscall ; 28-reserved dd sys_date ; 29-GetDate - dd cross_order ; 30-Get/SetCurrentDirectory + dd sys_current_directory ; 30-Get/SetCurrentDirectory dd undefined_syscall ; 31-reserved dd undefined_syscall ; 32-reserved dd undefined_syscall ; 33-reserved @@ -221,11 +221,11 @@ iglobal dd syscall_getarea ; 36-GetArea dd readmousepos ; 37-GetMousePosition_ScreenRelative,. dd syscall_drawline ; 38-DrawLine - dd cross_order ; 39-GetBackgroundSize,ReadBgrData,. + dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,. dd set_app_param ; 40-WantEvents dd syscall_getirqowner ; 41-GetIrqOwner dd get_irq_data ; 42-ReadIrqData - dd cross_order ; 43-SendDeviceData + 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 diff --git a/kernel/trunk/docs/sysfuncr.txt b/kernel/trunk/docs/sysfuncr.txt index 3bd6c5d404..a07697c316 100644 --- a/kernel/trunk/docs/sysfuncr.txt +++ b/kernel/trunk/docs/sysfuncr.txt @@ -1,4 +1,4 @@ -СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.5.0 +СИСТЕМНЫЕ ФУНКЦИИ ОПЕРАЦИОННОЙ СИСТЕМЫ Kolibri 0.7.5.0+ Номер функции помещается в регистр eax. Вызов системной функции осуществляется командой "int 0x40". @@ -1677,6 +1677,7 @@ dd 638 * ecx = указатель на буфер * edx = размер буфера Возвращаемое значение: + * eax = - 1 ощибка, папка текущего потока имеет длинну более чем 4096 символов. * eax = длина имени текущей папки (включая завершающий 0) Замечания: * Если размера буфера недостаточно для копирования всего имени, diff --git a/kernel/trunk/fs/fs_lfn.inc b/kernel/trunk/fs/fs_lfn.inc index 3c1178f16f..789dbf5e47 100644 --- a/kernel/trunk/fs/fs_lfn.inc +++ b/kernel/trunk/fs/fs_lfn.inc @@ -967,46 +967,67 @@ process_replace_file_name: ret sys_current_directory: - mov esi, [current_slot] - mov esi, [esi+APPDATA.cur_dir] - mov edx, esi - dec eax +; mov esi, [current_slot] +; mov esi, [esi+APPDATA.cur_dir] +; mov edx, esi + +;get lenght string of appdata.cur_dir +; mov eax, [current_slot] +; mov edi, [eax+APPDATA.cur_dir] + + dec ebx jz .set - dec eax + dec ebx jz .get ret .get: ; sysfunction 30.2: [for app] eax=30,ebx=2,ecx->buffer,edx=len ; for our code: ebx->buffer,ecx=len -@@: - lodsb - test al, al - jnz @b - sub esi, edx - inc esi - mov [esp+36], esi - cmp ecx, esi - jbe @f - mov ecx, esi -@@: - cmp ecx, 1 - jbe .ret - mov esi, edx - mov edi, ebx - mov al, '/' +max_cur_dir equ 0x1000 +;get lenght string of appdata.cur_dir + mov eax, [current_slot] + mov edi, [eax+APPDATA.cur_dir] + + mov ebx,edi + + push ecx + push edi + + xor eax,eax + mov ecx,max_cur_dir + + repne scasb ;find zerro at and string + jcxz .error ;ecx=0 and destination buffer is too small. + + sub edi,ebx ;lenght for copy + inc edi + mov [esp+32+8],edi ;return in eax + + cmp edx,edi ;edi must have more than 2 (for / and 0x0) +;sourse string + pop esi +;destination string + pop edi + jb .ret + + mov al,'/' ;start string with '/' stosb - dec ecx - dec ecx - rep movsb - mov byte [edi], 0 -.ret: + mov ecx,edx + rep movsb ;copy string + xor eax,eax + mov byte [edi],al ;set zerro +.ret: ret + +.error: add esp,8 + or dword [esp+32],-1 ;error not found zerro at string ->[eax+APPDATA.cur_dir] ret .set: ; sysfunction 30.1: [for app] eax=30,ebx=1,ecx->string ; for our code: ebx->string to set ; use generic resolver with APPDATA.cur_dir as destination - push 0x1000 - push edx + push max_cur_dir ;0x1000 + push edi ;destination + mov ebx,ecx call get_full_file_name ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 393a787b02..f870d64a9a 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -1180,60 +1180,62 @@ set_variables: ret align 4 - +;input eax=43,bl-byte of output, ecx - number of port sys_outport: - mov edi,ebx ; separate flag for read / write - and ebx,65535 + mov edi,ecx ; separate flag for read / write + and ecx,65535 - mov ecx,[RESERVED_PORTS] - test ecx,ecx - jne sopl8 - mov [esp+36],dword 1 + mov eax,[RESERVED_PORTS] + test eax,eax + jnz .sopl8 + inc eax + mov [esp+32],eax ret - sopl8: + .sopl8: mov edx,[TASK_BASE] mov edx,[edx+0x4] - and ebx,65535 - cld - sopl1: + ;and ecx,65535 + ;cld - set on interrupt 0x40 + .sopl1: - mov esi,ecx + mov esi,eax shl esi,4 add esi,RESERVED_PORTS cmp edx,[esi+0] - jne sopl2 - cmp ebx,[esi+4] - jb sopl2 - cmp ebx,[esi+8] - jg sopl2 - jmp sopl3 - - sopl2: - - dec ecx - jnz sopl1 - mov [esp+36],dword 1 - ret - - sopl3: + jne .sopl2 + cmp ecx,[esi+4] + jb .sopl2 + cmp ecx,[esi+8] + jg .sopl2 +.sopl3: test edi,0x80000000 ; read ? - jnz sopl4 + jnz .sopl4 - mov dx,bx ; write + mov eax,ebx + mov dx,cx ; write out dx,al - and [esp+36],dword 0 + and [esp+32],dword 0 ret - sopl4: + .sopl2: - mov dx,bx ; read + dec eax + jnz .sopl1 + inc eax + mov [esp+32],eax + ret + + + .sopl4: + + mov dx,cx ; read in al,dx and eax,0xff - and [esp+36],dword 0 - mov [esp+24],eax + and [esp+32],dword 0 + mov [esp+20],eax ret display_number: @@ -2558,49 +2560,49 @@ force_redraw_background: align 4 sys_getbackground: - - cmp eax,1 ; SIZE +; cmp eax,1 ; SIZE + dec ebx jnz nogb1 mov eax,[BgrDataWidth] shl eax,16 mov ax,[BgrDataHeight] - mov [esp+36],eax + mov [esp+32],eax ret nogb1: - - cmp eax,2 ; PIXEL +; cmp eax,2 ; PIXEL + dec ebx jnz nogb2 mov eax, [img_background] - test ebx, ebx + test ecx, ecx jz @f cmp eax, static_background_data jz .ret @@: - mov ecx, [mem_BACKGROUND] - add ecx, 4095 - and ecx, -4096 - sub ecx, 4 - cmp ebx, ecx + mov ebx, [mem_BACKGROUND] + add ebx, 4095 + and ebx, -4096 + sub ebx, 4 + cmp ecx, ebx ja .ret - mov eax,[ebx+eax] + mov eax,[ecx+eax] and eax, 0xFFFFFF - mov [esp+36],eax + mov [esp+32],eax .ret: ret nogb2: - cmp eax,4 ; TILED / STRETCHED +; cmp eax,4 ; TILED / STRETCHED + dec ebx jnz nogb4 mov eax,[BgrDrawMode] nogb4: - mov [esp+36],eax + mov [esp+32],eax ret - align 4 sys_getkey: