From cf0e9867b0c1aa861466936de118af5840f9ac2d Mon Sep 17 00:00:00 2001 From: Doczom Date: Sat, 8 Apr 2023 21:24:05 +0000 Subject: [PATCH] [KERNEL] updated local labels in functions and other small changes git-svn-id: svn://kolibrios.org@9910 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/bus/pci/pci32.inc | 124 +++++++++++++------------- kernel/trunk/core/memory.inc | 22 ++--- kernel/trunk/core/sched.inc | 1 + kernel/trunk/core/sys32.inc | 30 +++---- kernel/trunk/gui/background.inc | 54 ++++++------ kernel/trunk/gui/event.inc | 4 +- kernel/trunk/gui/window.inc | 25 +++--- kernel/trunk/hid/mousedrv.inc | 16 ++-- kernel/trunk/hid/set_dtc.inc | 105 +++++++++++----------- kernel/trunk/kernel.asm | 151 ++++++++++++++++---------------- kernel/trunk/sound/playnote.inc | 55 ++++++------ 11 files changed, 289 insertions(+), 298 deletions(-) diff --git a/kernel/trunk/bus/pci/pci32.inc b/kernel/trunk/bus/pci/pci32.inc index 9bd6ce076e..71c7a88b2c 100644 --- a/kernel/trunk/bus/pci/pci32.inc +++ b/kernel/trunk/bus/pci/pci32.inc @@ -57,7 +57,6 @@ endg align 4 pci_api: - ;cross mov eax, ebx mov ebx, ecx @@ -76,8 +75,8 @@ else ja pci_service_not_supported end if - call dword [f62call+edx*4] - mov dword [esp+32], eax + call dword [f62call + edx*4] + mov dword [esp + SYSCALL_STACK.eax], eax ret @@ -90,7 +89,7 @@ pci_api_drv: cmp eax, 2 ja .fail - jmp dword [f62call+eax*4] + jmp dword [f62call + eax*4] .fail: or eax, -1 @@ -116,7 +115,7 @@ pci_fn_2: pci_service_not_supported: or eax, -1 - mov dword [esp+32], eax + mov dword [esp + SYSCALL_STACK.eax], eax ret ;*************************************************************************** @@ -157,7 +156,7 @@ align 4 pci_read_reg: push ebx esi cmp [BOOT.pci_data.access_mechanism], 2; what mechanism will we use? - je pci_read_reg_2 + je .pci_read_reg_2 ; mechanism 1 mov esi, eax ; save register size into ESI @@ -176,28 +175,29 @@ pci_read_reg: or dl, bl ; add to port address first 2 bits of register address or esi, esi - jz pci_read_byte1 + jz .byte1 cmp esi, 1 - jz pci_read_word1 + jz .word1 cmp esi, 2 - jz pci_read_dword1 - jmp pci_fin_read1 + jz .dword1 + jmp .fin_read1 -pci_read_byte1: +.byte1: in al, dx - jmp pci_fin_read1 -pci_read_word1: + jmp .fin_read1 +.word1: in ax, dx - jmp pci_fin_read1 -pci_read_dword1: + jmp .fin_read1 +.dword1: in eax, dx -pci_fin_read1: +.fin_read1: pop esi ebx ret -pci_read_reg_2: + +.pci_read_reg_2: test bh, 128 ;mech#2 only supports 16 devices per bus - jnz pci_read_reg_err + jnz .pci_read_reg_err mov esi, eax ; save register size into ESI and esi, 3 @@ -217,27 +217,27 @@ pci_read_reg_2: mov dx, bx or esi, esi - jz pci_read_byte2 + jz .byte2 cmp esi, 1 - jz pci_read_word2 + jz .word2 cmp esi, 2 - jz pci_read_dword2 - jmp pci_fin_read2 + jz .dword2 + jmp .fin_read2 -pci_read_byte2: +.byte2: in al, dx - jmp pci_fin_read2 -pci_read_word2: + jmp .fin_read2 +.word2: in ax, dx - jmp pci_fin_read2 -pci_read_dword2: + jmp .fin_read2 +.dword2: in eax, dx -pci_fin_read2: +.fin_read2: pop esi ebx ret -pci_read_reg_err: +.pci_read_reg_err: xor eax, eax dec eax pop esi ebx @@ -281,22 +281,22 @@ pci_write_reg: mov eax, ecx or esi, esi - jz pci_write_byte1 + jz .byte1 cmp esi, 1 - jz pci_write_word1 + jz .word1 cmp esi, 2 - jz pci_write_dword1 - jmp pci_fin_write1 + jz .dword1 + jmp .fin_write1 -pci_write_byte1: +.byte1: out dx, al - jmp pci_fin_write1 -pci_write_word1: + jmp .fin_write1 +.word1: out dx, ax - jmp pci_fin_write1 -pci_write_dword1: + jmp .fin_write1 +.dword1: out dx, eax -pci_fin_write1: +.fin_write1: xor eax, eax pop ebx esi @@ -305,7 +305,7 @@ pci_fin_write1: pci_write_reg_2: test bh, 128 ;mech#2 only supports 16 devices per bus - jnz pci_write_reg_err + jnz .pci_write_reg_err mov esi, eax ; save register size into ESI @@ -327,28 +327,28 @@ pci_write_reg_2: mov eax, ecx or esi, esi - jz pci_write_byte2 + jz .byte2 cmp esi, 1 - jz pci_write_word2 + jz .word2 cmp esi, 2 - jz pci_write_dword2 - jmp pci_fin_write2 + jz .dword2 + jmp .fin_write2 -pci_write_byte2: +.byte2: out dx, al - jmp pci_fin_write2 -pci_write_word2: + jmp .fin_write2 +.word2: out dx, ax - jmp pci_fin_write2 -pci_write_dword2: + jmp .fin_write2 +.dword2: out dx, eax -pci_fin_write2: +.fin_write2: xor eax, eax pop ebx esi ret -pci_write_reg_err: +.pci_write_reg_err: xor eax, eax dec eax pop ebx esi @@ -432,12 +432,12 @@ pci_mmio_map: or eax, eax jnz @f mov eax, -3 ; empty I/O space - jmp mmio_ret_fail + jmp .mmio_ret_fail @@: test eax, 1 jz @f mov eax, -4 ; damned ports (not MMIO space) - jmp mmio_ret_fail + jmp .mmio_ret_fail @@: pop ecx ; ecx = block size, bytes (expanded to whole page) mov ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx @@ -445,15 +445,15 @@ pci_mmio_map: push eax ; store MMIO physical address + keep 2DWords in the stack stdcall user_alloc, ecx or eax, eax - jnz mmio_map_over + jnz .mmio_map_over mov eax, -5 ; problem with page allocation -mmio_ret_fail: +.mmio_ret_fail: pop ecx pop edx ret -mmio_map_over: +.mmio_map_over: mov ecx, ebx; ecx = size (bytes, expanded to whole page) shr ecx, 12 ; ecx = number of pages mov ebx, eax; ebx = linear address @@ -596,16 +596,16 @@ sys_pcibios: .unsupported_func: mov ah, 0x81 ; FUNC_NOT_SUPPORTED .return: - mov dword[esp + 4 ], edi - mov dword[esp + 8], esi + mov dword[esp + SYSCALL_STACK.edi], edi + mov dword[esp + SYSCALL_STACK.esi], esi .return_abcd: - mov dword[esp + 24], edx + mov dword[esp + SYSCALL_STACK.edx], edx .return_abc: - mov dword[esp + 28], ecx + mov dword[esp + SYSCALL_STACK.ecx], ecx .return_ab: - mov dword[esp + 20], ebx + mov dword[esp + SYSCALL_STACK.ebx], ebx .return_a: - mov dword[esp + 32], eax + mov dword[esp + SYSCALL_STACK.eax], eax ret proc pci_enum diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 8dc0e4d5fd..da2b521361 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -936,7 +936,7 @@ sys_IPC: jb .touch popf - mov [esp+32], ebx ;ebx=0 + mov [esp + SYSCALL_STACK.eax], ebx ;ebx=0 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -946,11 +946,11 @@ sys_IPC: jnz @f stdcall sys_ipc_send, ecx, edx, esi - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax ret @@: or eax, -1 - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax ret proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword @@ -1079,22 +1079,22 @@ sysfn_meminfo: mov eax, [pg_data.pages_count] mov [ecx], eax shl eax, 12 - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax mov eax, [pg_data.pages_free] - mov [ecx+4], eax + mov [ecx + 4], eax mov eax, [pg_data.pages_faults] - mov [ecx+8], eax + mov [ecx + 8], eax mov eax, [heap_size] - mov [ecx+12], eax + mov [ecx + 12], eax mov eax, [heap_free] - mov [ecx+16], eax + mov [ecx + 16], eax mov eax, [heap_blocks] - mov [ecx+20], eax + mov [ecx + 20], eax mov eax, [free_blocks] - mov [ecx+24], eax + mov [ecx + 24], eax ret .fail: - or dword [esp+32], -1 + or dword [esp + SYSCALL_STACK.eax], -1 ret align 4 diff --git a/kernel/trunk/core/sched.inc b/kernel/trunk/core/sched.inc index 7ed32c4f32..75244bfa29 100644 --- a/kernel/trunk/core/sched.inc +++ b/kernel/trunk/core/sched.inc @@ -76,6 +76,7 @@ update_counters: sub eax, [esi - sizeof.APPDATA + APPDATA.counter_add] ; time stamp counter add add [esi - sizeof.APPDATA + APPDATA.counter_sum], eax ; counter sum ret + align 4 updatecputimes: mov ecx, [thread_count] diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index ba70cec362..6556f3c950 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -525,18 +525,18 @@ destroy_thread: jb .loop2 mov ecx, esi ; remove buttons - bnewba2: + .bnewba2: mov edi, [BTN_ADDR] mov eax, edi cld movzx ebx, word [edi] inc bx - bnewba: + .bnewba: dec bx - jz bnmba + jz .bnmba add eax, 0x10 cmp cx, [eax] - jnz bnewba + jnz .bnewba pusha mov ecx, ebx inc ecx @@ -546,8 +546,8 @@ destroy_thread: call memmove dec dword [edi] popa - jmp bnewba2 - bnmba: + jmp .bnewba2 + .bnmba: pusha ; save window coordinates for window restoring cld @@ -662,27 +662,27 @@ destroy_thread: shl edx, BSF sizeof.APPDATA mov edx, [SLOT_BASE + edx + APPDATA.tid] - rmpr0: + .rmpr0: mov esi, [RESERVED_PORTS] test esi, esi - jz rmpr9 + jz .rmpr9 - rmpr3: + .rmpr3: mov edi, esi shl edi, 4 add edi, RESERVED_PORTS cmp edx, [edi] - je rmpr4 + je .rmpr4 dec esi - jnz rmpr3 + jnz .rmpr3 - jmp rmpr9 + jmp .rmpr9 - rmpr4: + .rmpr4: mov ecx, 256 sub ecx, esi @@ -695,9 +695,9 @@ destroy_thread: dec dword [RESERVED_PORTS] - jmp rmpr0 + jmp .rmpr0 - rmpr9: + .rmpr9: popa ; clearing APPDATA structure this thread diff --git a/kernel/trunk/gui/background.inc b/kernel/trunk/gui/background.inc index 52f68a6721..1a96156d8c 100644 --- a/kernel/trunk/gui/background.inc +++ b/kernel/trunk/gui/background.inc @@ -20,12 +20,12 @@ endg align 4 sys_background: cmp ebx, 1 ; BACKGROUND SIZE - jnz nosb1 + jnz .nosb1 test ecx, ecx - jz sbgrr + jz .sbgrr test edx, edx - jz sbgrr + jz .sbgrr ;-------------------------------------- align 4 @@: @@ -98,13 +98,13 @@ align 4 mov [bgrlock], 0 ;-------------------------------------- align 4 -sbgrr: +.sbgrr: ret ;-------------------------------------- align 4 -nosb1: +.nosb1: cmp ebx, 2 ; SET PIXEL - jnz nosb2 + jnz .nosb2 mov eax, [img_background] test ecx, ecx @@ -115,8 +115,8 @@ nosb1: align 4 @@: mov ebx, [mem_BACKGROUND] - add ebx, 4095 - and ebx, -4096 + add ebx, PAGE_SIZE-1 + and ebx, -PAGE_SIZE sub ebx, 4 cmp ecx, ebx ja .ret @@ -132,7 +132,7 @@ align 4 ret ;-------------------------------------- align 4 -nosb2: +.nosb2: cmp ebx, 3 ; DRAW BACKGROUND jnz nosb3 ;-------------------------------------- @@ -206,7 +206,7 @@ align 4 cmp [img_background], static_background_data jz .nomem stdcall user_alloc, [mem_BACKGROUND] - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax test eax, eax jz .nomem mov ebx, eax @@ -276,14 +276,14 @@ align 4 pop eax and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE stdcall user_free, ebx - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax and [bgrlockpid], 0 mov [bgrlock], 0 ret ;-------------------------------------- align 4 .err: - and dword [esp+32], 0 + and dword [esp + SYSCALL_STACK.eax], 0 ret ;------------------------------------- align 4 @@ -293,17 +293,17 @@ nosb7: mov ecx, [current_slot] xor eax, eax - xchg eax, [ecx+APPDATA.draw_bgr_x] - mov [esp + 32], eax ; eax = [left]*65536 + [right] + xchg eax, [ecx + APPDATA.draw_bgr_x] + mov [esp + SYSCALL_STACK.eax], eax ; eax = [left]*65536 + [right] xor eax, eax - xchg eax, [ecx+APPDATA.draw_bgr_y] - mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] + xchg eax, [ecx + APPDATA.draw_bgr_y] + mov [esp + SYSCALL_STACK.ebx], eax ; ebx = [top]*65536 + [bottom] ret ;--------------------------------------- align 4 nosb8: cmp ebx, 9 - jnz nosb9 + jnz .exit ; ecx = [left]*65536 + [right] ; edx = [top]*65536 + [bottom] mov eax, [_display.width] @@ -343,10 +343,6 @@ nosb8: align 4 .exit: ret -;-------------------------------------- -align 4 -nosb9: - ret ;------------------------------------------------------------------------------ @@ -384,7 +380,7 @@ sys_getbackground: ; sysfn 39 mov eax, [BgrDataWidth] shl eax, 16 mov ax, word [BgrDataHeight] - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax ret ;--------------------------------------- align 4 @@ -400,8 +396,8 @@ align 4 align 4 @@: mov ebx, [mem_BACKGROUND] - add ebx, 4095 - and ebx, -4096 + add ebx, PAGE_SIZE-1 + and ebx, -PAGE_SIZE sub ebx, 4 cmp ecx, ebx ja .ret @@ -409,7 +405,7 @@ align 4 mov eax, [ecx+eax] and eax, 0xFFFFFF - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax align 4 .ret: ret @@ -456,8 +452,8 @@ align 4 ; check bounds mov ebx, [mem_BACKGROUND] - add ebx, 4095 - and ebx, -4096 + add ebx, PAGE_SIZE-1 + and ebx, -PAGE_SIZE sub ebx, 4 add eax, [.subrect_startptr] cmp eax, ebx @@ -495,7 +491,7 @@ align 4 jmp .copy_rect .end_copy_rect: xor eax, eax - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax ;-------------------------------------- align 4 .fail_39_3: @@ -513,7 +509,7 @@ align 4 ;-------------------------------------- align 4 .nogb4: - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax ret ;----------------------------------------------------------------------------- diff --git a/kernel/trunk/gui/event.inc b/kernel/trunk/gui/event.inc index 510a7db7bc..8694828e20 100644 --- a/kernel/trunk/gui/event.inc +++ b/kernel/trunk/gui/event.inc @@ -480,7 +480,7 @@ sys_getevent: ;; f11 cli ; the right to hope to disable interrupts, as when called from shed call get_event_for_app popfd - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax ret ;----------------------------------------------------------------------------- align 4 @@ -492,7 +492,7 @@ sys_wait_event_timeout: ;; f23 call unprotect_from_terminate mov edx, get_event_for_app; wait_test call Wait_events_ex ; ebx - timeout - mov [esp+32], eax + mov [esp + SYSCALL_STACK.eax], eax call protect_from_terminate ret ;----------------------------------------------------------------------------- diff --git a/kernel/trunk/gui/window.inc b/kernel/trunk/gui/window.inc index 1d0939ceb9..94833636c7 100644 --- a/kernel/trunk/gui/window.inc +++ b/kernel/trunk/gui/window.inc @@ -284,10 +284,10 @@ dd .setSkinUnicode ; out: eax = pack[left, right], ebx = pack[top, bottom] mov eax, [screen_workarea.left - 2] mov ax, word[screen_workarea.right] - mov [esp + 32], eax + mov [esp + SYSCALL_STACK.eax], eax mov eax, [screen_workarea.top - 2] mov ax, word[screen_workarea.bottom] - mov [esp + 20], eax + mov [esp + SYSCALL_STACK.ebx], eax ret .setScreenWorkingArea: @@ -346,16 +346,16 @@ dd .setSkinUnicode .getSkinMargins: ; out: eax = pack[left, right], ebx = pack[top, bottom] mov eax, [_skinmargins + 0] - mov [esp + 32], eax + mov [esp + SYSCALL_STACK.eax], eax mov eax, [_skinmargins + 4] - mov [esp + 20], eax + mov [esp + SYSCALL_STACK.ebx], eax ret .setSkin: ; in: ecx -> file path string mov ebx, ecx call read_skin_file - mov [esp + 32], eax + mov [esp + SYSCALL_STACK.eax], eax test eax, eax jnz .ret call .calculateScreen @@ -364,7 +364,7 @@ dd .setSkinUnicode .getFontSmoothing: xor eax, eax mov al, [fontSmoothing] - mov [esp + 32], eax + mov [esp + SYSCALL_STACK.eax], eax ret .setFontSmoothing: @@ -374,7 +374,7 @@ dd .setSkinUnicode .getFontSize: xor eax, eax mov al, [fontSize] - mov [esp + 32], eax + mov [esp + SYSCALL_STACK.eax], eax ret .setFontSize: @@ -393,7 +393,7 @@ dd .setSkinUnicode jz @f mov ebx, [esp] call read_skin_file - mov [esp + 32 + 4], eax + mov [esp + SYSCALL_STACK.eax + 4], eax @@: call kernel_free call .calculateScreen @@ -505,7 +505,7 @@ syscall_window_settings: align 4 set_window_defaults: - mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable + mov byte [window_data + sizeof.WDATA + WDATA.cl_titlebar + 3], 1 ; desktop is not movable push eax ecx xor eax, eax mov ecx, WIN_STACK @@ -1090,10 +1090,10 @@ align 4 movzx edi, word[WIN_POS + eax * 2] shl edi, BSF sizeof.WDATA ; it is a unused slot? - cmp byte [edi*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE + cmp byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE je @f ; it is a hidden thread? - lea esi, [edi*8+SLOT_BASE+APPDATA.app_name] + lea esi, [SLOT_BASE + edi*8 + APPDATA.app_name] cmp [esi], byte '@' je @f ; is it already minimized? @@ -2548,6 +2548,3 @@ align 4 add esp, 4 ;dword for 0/1 - set_screen/fl_redraw ret - - - diff --git a/kernel/trunk/hid/mousedrv.inc b/kernel/trunk/hid/mousedrv.inc index a59627fd89..e9cf8b5fa7 100644 --- a/kernel/trunk/hid/mousedrv.inc +++ b/kernel/trunk/hid/mousedrv.inc @@ -61,7 +61,7 @@ draw_mouse_under: xor ecx, ecx xor edx, edx - mres: + .mres: movzx eax, word [X_UNDER] movzx ebx, word [Y_UNDER] add eax, ecx @@ -86,11 +86,13 @@ draw_mouse_under: pop ecx inc ecx cmp ecx, 16 - jnz mres + jnz .mres + xor ecx, ecx inc edx cmp edx, 24 - jnz mres + jnz .mres + popad ret @@ -186,7 +188,7 @@ align 4 mov edx, 0 ;-------------------------------------- align 4 -drm: +.drm: push eax push ebx push ecx @@ -243,11 +245,13 @@ drm: mov eax, [esp+4] ; and x inc ecx ; +1 cycle cmp ecx, 16 ; if more than 16 - jnz drm + jnz .drm + xor ecx, ecx inc edx cmp edx, 24 - jnz drm + jnz .drm + add esp, 8 popad ret diff --git a/kernel/trunk/hid/set_dtc.inc b/kernel/trunk/hid/set_dtc.inc index 6e29e327f3..f2d914413e 100644 --- a/kernel/trunk/hid/set_dtc.inc +++ b/kernel/trunk/hid/set_dtc.inc @@ -17,19 +17,18 @@ $Revision$ ; ebx =3 - set alarm-clock ecx - 00SSMMHH ; out: 0 -Ok 1 -wrong format 2 -battery low sys_settime: - cli mov al, 0x0d out 0x70, al in al, 0x71 bt ax, 7 - jnc bat_low - cmp ebx, 2;day of week - jne nosetweek + jnc .bat_low + cmp ebx, 2 ;day of week + jne .nosetweek test ecx, ecx ;test day of week - je wrongtime + je .wrongtime cmp ecx, 7 - ja wrongtime + ja .wrongtime mov edx, 0x70 call startstopclk dec edx @@ -38,52 +37,52 @@ sys_settime: inc edx mov al, cl out dx, al - jmp endsettime - nosetweek: ;set date + jmp .endsettime + .nosetweek: ;set date cmp ebx, 1 - jne nosetdate + jne .nosetdate cmp cl, 0x99;test year - ja wrongtime + ja .wrongtime shl ecx, 4 cmp cl, 0x90 - ja wrongtime + ja .wrongtime cmp ch, 0x99;test month - ja wrongtime + ja .wrongtime shr ecx, 4 test ch, ch - je wrongtime + je .wrongtime cmp ch, 0x12 - ja wrongtime + ja .wrongtime shl ecx, 8 bswap ecx ;ebx=00YYMMDD test cl, cl ;test day - je wrongtime + je .wrongtime shl ecx, 4 cmp cl, 0x90 - ja wrongtime + ja .wrongtime shr ecx, 4 cmp ch, 2 ;February - jne testday + jne .testday cmp cl, 0x29 - ja wrongtime - jmp setdate - testday: + ja .wrongtime + jmp .setdate + .testday: cmp ch, 8 - jb testday1;Aug-Dec + jb .testday1 ;Aug-Dec bt cx, 8 - jnc days31 - jmp days30 - testday1: + jnc .days31 + jmp .days30 + .testday1: bt cx, 8 ;Jan-Jul ex.Feb - jnc days30 - days31: + jnc .days30 + .days31: cmp cl, 0x31 - ja wrongtime - jmp setdate - days30: + ja .wrongtime + jmp .setdate + .days30: cmp cl, 0x30 - ja wrongtime - setdate: + ja .wrongtime + .setdate: mov edx, 0x70 call startstopclk dec edx @@ -105,26 +104,26 @@ sys_settime: shr ecx, 8 mov al, ch out dx, al - jmp endsettime - nosetdate: ;set time or alarm-clock + jmp .endsettime + .nosetdate: ;set time or alarm-clock cmp ebx, 3 - ja wrongtime + ja .wrongtime cmp cl, 0x23 - ja wrongtime + ja .wrongtime cmp ch, 0x59 - ja wrongtime + ja .wrongtime shl ecx, 4 cmp cl, 0x90 - ja wrongtime + ja .wrongtime cmp ch, 0x92 - ja wrongtime + ja .wrongtime shl ecx, 4 bswap ecx ;00HHMMSS cmp cl, 0x59 - ja wrongtime + ja .wrongtime shl ecx, 4 cmp cl, 0x90 - ja wrongtime + ja .wrongtime shr ecx, 4 mov edx, 0x70 @@ -132,7 +131,7 @@ sys_settime: dec edx cmp ebx, 3 - je setalarm + je .setalarm xor eax, eax;al=0-set seconds out dx, al inc edx @@ -151,8 +150,8 @@ sys_settime: shr ecx, 8 mov al, ch out dx, al - jmp endsettime - setalarm: + jmp .endsettime + .setalarm: mov al, 1;set seconds for al. out dx, al inc edx @@ -178,19 +177,19 @@ sys_settime: in al, dx bts ax, 5;set bit 5 out dx, al - endsettime: + .endsettime: dec edx call startstopclk sti - and [esp+36-4], dword 0 + and [esp + SYSCALL_STACK.eax], dword 0 ret - bat_low: + .bat_low: sti - mov [esp+36-4], dword 2 + mov [esp + SYSCALL_STACK.eax], dword 2 ret - wrongtime: + .wrongtime: sti - mov [esp+36-4], dword 1 + mov [esp + SYSCALL_STACK.eax], dword 1 ret startstopclk: @@ -235,14 +234,11 @@ sys_clock: movzx edx, al add ecx, edx sti - mov [esp + 32], ecx + mov [esp + SYSCALL_STACK.eax], ecx ret - align 4 - sys_date: - cli @@: mov al, 10 @@ -254,7 +250,6 @@ sys_date: call delay_ms jmp @b @@: - mov ch, 0 mov al, 7 ; date out 0x70, al @@ -270,5 +265,5 @@ sys_date: in al, 0x71 mov cl, al sti - mov [esp+32], ecx + mov [esp + SYSCALL_STACK.eax], ecx ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 81d3bdcbbb..4b9d13fd68 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -1363,7 +1363,14 @@ display_number: ; add check pointers test bl, bl jz @f - stdcall is_region_userspace, ecx, 1 + bt ebx, 30 ; check 30 bit + jb @f + stdcall is_region_userspace, ecx, 4 + jz @f + ret +@@: + jz @f + stdcall is_region_userspace, ecx, 8 jz @f ret @@: @@ -1882,16 +1889,6 @@ sm10: smn2: ret -detect_devices: -;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -;include 'detect/commouse.inc' -;include 'detect/ps2mouse.inc' -;include 'detect/dev_fd.inc' -;include 'detect/dev_hdcd.inc' -;include 'detect/sear_par.inc' -;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ret - sys_end: ;-------------------------------------- cmp [_display.select_cursor], 0 @@ -2024,27 +2021,27 @@ is_kernel_thread: sysfn_terminate: ; 18.2 = TERMINATE push ecx cmp ecx, 2 - jb noprocessterminate + jb .noprocessterminate mov edx, [thread_count] cmp ecx, edx - ja noprocessterminate + ja .noprocessterminate mov eax, [thread_count] shl ecx, BSF sizeof.APPDATA add ecx, SLOT_BASE mov edx, [ecx + APPDATA.tid] cmp byte [ecx + APPDATA.state], TSTATE_FREE - jz noprocessterminate + jz .noprocessterminate push eax mov eax, ecx call is_kernel_thread pop eax - jz noprocessterminate + jz .noprocessterminate push ecx edx mov edx, ecx call request_terminate pop edx ecx test eax, eax - jz noprocessterminate + jz .noprocessterminate ;-------------------------------------- ; terminate all network sockets it used pusha @@ -2073,10 +2070,10 @@ sysfn_terminate: ; 18.2 = TERMINATE ;call MEM_Heap_UnLock cmp edx, [application_table_owner]; clear app table stat - jne noatsc + jne .noatsc call unlock_application_table -noatsc: -noprocessterminate: +.noatsc: +.noprocessterminate: add esp, 4 ret ;------------------------------------------------------------------------------ @@ -2496,7 +2493,7 @@ sys_cachetodiskette: align 4 sys_getkey: - mov [esp + 32], dword 1 + mov [esp + SYSCALL_STACK.eax], dword 1 ; test main buffer mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK movzx ecx, word [WIN_STACK + ebx * 2] @@ -2688,23 +2685,23 @@ sys_cpuusage: align 4 sys_redrawstat: cmp ebx, 1 - jne no_widgets_away + jne .no_widgets_away ; buttons away mov ecx, [current_slot_idx] - sys_newba2: +.sys_newba2: mov edi, [BTN_ADDR] cmp [edi], dword 0 ; empty button list ? - je end_of_buttons_away + je .end_of_buttons_away movzx ebx, word [edi] inc ebx mov eax, edi - sys_newba: +.sys_newba: dec ebx - jz end_of_buttons_away + jz .end_of_buttons_away add eax, 0x10 cmp cx, [eax] - jnz sys_newba + jnz .sys_newba push eax ebx ecx mov ecx, ebx @@ -2716,16 +2713,15 @@ sys_redrawstat: dec dword [edi] pop ecx ebx eax - jmp sys_newba2 - - end_of_buttons_away: + jmp .sys_newba2 +.end_of_buttons_away: ret - no_widgets_away: +.no_widgets_away: cmp ebx, 2 - jnz srl1 + jnz .srl1 mov edx, [current_slot_idx] ; return whole screen draw area for this app shl edx, 5 ;? @@ -2739,7 +2735,7 @@ sys_redrawstat: dec eax mov [edx + RECT.bottom], eax - srl1: +.srl1: ret ;ok - 100% work @@ -2878,7 +2874,7 @@ endg align 4 checkmisc: cmp [ctrl_alt_del], 1 - jne nocpustart + jne .nocpustart mov ebp, cpustring call fs_execute_from_sysdir @@ -2886,9 +2882,9 @@ checkmisc: mov [ctrl_alt_del], 0 ;-------------------------------------- align 4 -nocpustart: +.nocpustart: cmp [mouse_active], 1 - jne mouse_not_active + jne .mouse_not_active mov [mouse_active], 0 xor edi, edi @@ -2942,7 +2938,7 @@ align 4 pop eax ;-------------------------------------- align 4 -mouse_not_active: +.mouse_not_active: cmp [REDRAW_BACKGROUND], 0 ; background update ? jz nobackgr @@ -3425,18 +3421,18 @@ delay_hs: ; delay in 1/100 secs mov edx, [timer_ticks] ;-------------------------------------- align 4 -newtic: +.newtic: mov ecx, [timer_ticks] sub ecx, edx cmp ecx, ebx - jae zerodelay + jae .zerodelay call change_task - jmp newtic + jmp .newtic ;-------------------------------------- align 4 -zerodelay: +.zerodelay: pop edx pop ecx ret @@ -3527,46 +3523,46 @@ syscall_reserveportarea: ; ReservePortArea and FreePortArea r_f_port_area: test ebx, ebx - jnz free_port_area + jnz .free_port_area cmp ecx, edx ; beginning > end ? - ja rpal1 + ja .rpal1 cmp edx, 65536 ;test ebx, not 0xffff - jae rpal1 + jae .rpal1 mov eax, [RESERVED_PORTS] test eax, eax ; no reserved areas ? - je rpal2 + je .rpal2 cmp eax, 255 ; max reserved - jae rpal1 - rpal3: + jae .rpal1 + .rpal3: mov ebx, eax shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table add ebx, RESERVED_PORTS cmp ecx, [ebx+8] - ja rpal4 + ja .rpal4 cmp edx, [ebx+4] - jae rpal1 - rpal4: + jae .rpal1 + .rpal4: dec eax - jnz rpal3 - jmp rpal2 - rpal1: + jnz .rpal3 + jmp .rpal2 + .rpal1: xor eax, eax inc eax ret - rpal2: + .rpal2: ; enable port access at port IO map pushad ; start enable io map mov eax, ecx xor ebp, ebp ; enable - eax = port cli -new_port_access: +.new_port_access: call set_io_access_rights inc eax cmp eax, edx - jbe new_port_access -no_unmask_io: + jbe .new_port_access +;no_unmask_io: sti popad ; end enable io map @@ -3584,31 +3580,31 @@ no_unmask_io: xor eax, eax ret -free_port_area: +.free_port_area: mov eax, [RESERVED_PORTS]; no reserved areas ? test eax, eax - jz frpal2 + jz .frpal2 mov ebx, [current_slot] mov ebx, [ebx + APPDATA.tid] - frpal3: + .frpal3: mov edi, eax shl edi, 4 add edi, RESERVED_PORTS cmp ebx, [edi] - jne frpal4 + jne .frpal4 cmp ecx, [edi+4] - jne frpal4 + jne .frpal4 cmp edx, [edi+8] - jne frpal4 - jmp frpal1 - frpal4: + jne .frpal4 + jmp .frpal1 + .frpal4: dec eax - jnz frpal3 - frpal2: + jnz .frpal3 + .frpal2: inc eax ret - frpal1: + .frpal1: push ecx mov ecx, 256 sub ecx, eax @@ -3627,28 +3623,27 @@ free_port_area: xor ebp, ebp inc ebp -new_port_access_disable: ; disable - eax = port +.new_port_access_disable: ; disable - eax = port call set_io_access_rights inc eax cmp eax, edx - jbe new_port_access_disable -no_mask_io: ; end disable io map + jbe .new_port_access_disable +;no_mask_io: ; end disable io map xor eax, eax ret ;----------------------------------------------------------------------------- align 4 drawbackground: -dbrv20: cmp [BgrDrawMode], dword 1 - jne bgrstr + jne .bgrstr call vesa20_drawbackground_tiled ; call [draw_pointer] call __sys_draw_pointer ret ;-------------------------------------- align 4 -bgrstr: +.bgrstr: call vesa20_drawbackground_stretch ; call [draw_pointer] call __sys_draw_pointer @@ -3708,12 +3703,14 @@ sys_putimage_palette: ; edi = pointer to palette ; ebp = row delta ; check pointer - push ecx + push ecx esi mov ax, cx shr ecx, 16 imul eax, ecx +; imul eax, esi ; eax*count bit in 1 pixel +; shr eax, 3 stdcall is_region_userspace, ebx, eax - pop ecx + pop esi ecx jnz sys_putimage.exit mov eax, [current_slot] @@ -4078,10 +4075,10 @@ kb_write_wait_ack: if used _rdtsc _rdtsc: bt [cpu_caps], CAPS_TSC - jnc ret_rdtsc + jnc .ret_rdtsc rdtsc ret - ret_rdtsc: + .ret_rdtsc: mov edx, 0xffffffff mov eax, 0xffffffff ret diff --git a/kernel/trunk/sound/playnote.inc b/kernel/trunk/sound/playnote.inc index 1a09c7da78..b884766d51 100644 --- a/kernel/trunk/sound/playnote.inc +++ b/kernel/trunk/sound/playnote.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2022. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2023. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; PLAYNOTE.INC version 1.1 22 November 2003 ;; @@ -22,21 +22,21 @@ align 4 sound_interface: cmp eax, ebx ; this is subfunction #55 ? - jne retFunc55 ; if no then return. + jne .ret ; if no then return. cmp byte [sound_flag], 0 - jne retFunc55 + jne .ret movzx eax, byte [countDelayNote] or al, al ; player is busy ? - jnz retFunc55 ; return counter delay Note + jnz .ret ; return counter delay Note mov [memAdrNote], esi;edx call get_pid mov [pidProcessNote], eax - xor eax, eax ; Ok! EAX = 0 - retFunc55: - mov [esp+32], eax ; return value EAX for application + xor eax, eax ; Ok! EAX = 0 +.ret: + mov [esp + SYSCALL_STACK.eax], eax ; return value EAX for application ret iglobal @@ -55,41 +55,41 @@ playNote: ; jmp NotPlayNotes mov esi, [memAdrNote] or esi, esi ; ESI = 0 ? - OFF Notes Play ? - jz NotPlayNotes ; if ESI = 0 -> ignore play pocedure + jz .NotPlayNotes ; if ESI = 0 -> ignore play pocedure cmp eax, [count_timer_Note] - jb NotPlayNotes + jb .NotPlayNotes push eax inc eax mov [count_timer_Note], eax mov al, [countDelayNote] dec al ; decrement counter Delay for Playing Note - jz NewLoadNote@Delay + jz .NewLoadNote@Delay cmp al, 0xFF ; this is first Note Play ? - jne NextDelayNote - ;This is FIRST Note, save counter channel 2 chip 8253 + jne .NextDelayNote + ;This is FIRST Note, save counter channel 2 chip 8253 mov al, 0xB6 ; control byte to timer chip 8253 out 0x43, al ; Send it to the control port chip 8253 in al, 0x42 ; Read Lower byte counter channel 2 chip 8253 mov ah, al ; AH = Lower byte counter channel 2 in al, 0x42 ; Read Upper byte counter channel 2 chip 8253 mov [mem8253r42], ax ; Save counter channel 2 timer chip 8253 - NewLoadNote@Delay: + .NewLoadNote@Delay: cld ; lodsb ; load AL - counter Delay call ReadNoteByte or al, al ; THE END ? - jz EndPlayNote + jz .EndPlayNote cmp al, 0x81 - jnc NoteforOctave + jnc .NoteforOctave mov [countDelayNote], al ; lodsw ; load AX - counter for Note! call ReadNoteByte mov ah, al call ReadNoteByte xchg al, ah - jmp pokeNote + jmp .pokeNote - EndPlayNote: ; THE END Play Notes! + .EndPlayNote: ; THE END Play Notes! in al, 0x61 ; Get contents of system port B chip 8255 and al, 0xFC ; Turn OFF timer and speaker out 0x61, al ; Send out new values to port B chip 8255 @@ -100,25 +100,25 @@ playNote: out 0x42, al ; restore Upper byte channel 2 xor eax, eax ; EAX = 0 mov [memAdrNote], eax; clear header control Delay-Note string - NextDelayNote: + .NextDelayNote: mov [countDelayNote], al; save new counter delay Note pop eax - NotPlayNotes: - RET + .NotPlayNotes: + ret - NoteforOctave: + .NoteforOctave: sub al, 0x81 ; correction value for delay Note mov [countDelayNote], al; save counter delay this new Note ; lodsb ; load pack control code call ReadNoteByte cmp al, 0xFF ; this is PAUSE ? - jne packCode ; no, this is PACK CODE + jne .packCode ; no, this is PACK CODE in al, 0x61 ; Get contents of system port B chip 8255 and al, 0xFC ; Turn OFF timer and speaker out 0x61, al ; Send out new values to port B chip 8255 - jmp saveESI + jmp .saveESI - packCode: + .packCode: mov cl, al ; save code and al, 0xF ; clear upper bits dec al ; correction @@ -128,17 +128,18 @@ playNote: mov ax, [eax] ; read constant shr cl, 4 ; transform for number Octave shr ax, cl ; calculate from Note this Octave! - pokeNote: + .pokeNote: out 0x42, al ; Lower byte Out to channel 2 timer chip 8253 mov al, ah out 0x42, al ; Upper byte Out to channel 2 timer chip 8253 in al, 0x61 ; Get contents of system port B chip 8255 or al, 3 ; Turn ON timer and speaker out 0x61, al ; Send out new values to port B chip 8255 - saveESI: + .saveESI: ; mov [memAdrNote], esi ; save new header control Delay-Note string pop eax - RET + ret + ReadNoteByte: ;result: ; al - note