From e338e5353fb835f363ae5daff2fdc659ce191347 Mon Sep 17 00:00:00 2001 From: "Artem Jerdev (art_zh)" Date: Sat, 23 Jul 2011 15:27:18 +0000 Subject: [PATCH] getting smaller and closer to real hardware... git-svn-id: svn://kolibrios.org@2014 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/Kolibri-A/trunk/bld.bat | 50 +- .../Kolibri-A/trunk/boot/bootcode.inc | 355 +-- .../branches/Kolibri-A/trunk/boot/booteng.inc | 51 +- .../Kolibri-A/trunk/boot/bootvesa.inc | 2 +- .../branches/Kolibri-A/trunk/boot/rdload.inc | 7 +- .../Kolibri-A/trunk/boot/shutdown.inc | 209 -- kernel/branches/Kolibri-A/trunk/bus/HT.inc | 51 +- .../Kolibri-A/trunk/bus/SB/HUDSON.INC | 3 + .../trunk/bus/SB/{SB710.ASM => SB.INC} | 55 +- .../branches/Kolibri-A/trunk/bus/SB/SB710.INC | 3 + kernel/branches/Kolibri-A/trunk/const.inc | 5 + kernel/branches/Kolibri-A/trunk/core/heap.inc | 2238 ++++++++--------- .../branches/Kolibri-A/trunk/core/memory.inc | 4 +- kernel/branches/Kolibri-A/trunk/data32.inc | 62 +- kernel/branches/Kolibri-A/trunk/gui/font.inc | 188 +- kernel/branches/Kolibri-A/trunk/gui/mouse.inc | 14 +- .../branches/Kolibri-A/trunk/gui/skincode.inc | 642 ++--- .../branches/Kolibri-A/trunk/gui/window.inc | 18 +- .../branches/Kolibri-A/trunk/hid/mousedrv.inc | 18 +- kernel/branches/Kolibri-A/trunk/kernel.asm | 318 +-- kernel/branches/Kolibri-A/trunk/kernel32.inc | 11 +- kernel/branches/Kolibri-A/trunk/memmap.inc | 10 +- .../branches/Kolibri-A/trunk/video/vesa20.inc | 62 +- 23 files changed, 1795 insertions(+), 2581 deletions(-) delete mode 100644 kernel/branches/Kolibri-A/trunk/boot/shutdown.inc create mode 100644 kernel/branches/Kolibri-A/trunk/bus/SB/HUDSON.INC rename kernel/branches/Kolibri-A/trunk/bus/SB/{SB710.ASM => SB.INC} (73%) create mode 100644 kernel/branches/Kolibri-A/trunk/bus/SB/SB710.INC diff --git a/kernel/branches/Kolibri-A/trunk/bld.bat b/kernel/branches/Kolibri-A/trunk/bld.bat index 029c15791c..f4ee5fa404 100644 --- a/kernel/branches/Kolibri-A/trunk/bld.bat +++ b/kernel/branches/Kolibri-A/trunk/bld.bat @@ -1,53 +1,7 @@ @echo off -set languages=en ru - -call :Check_Lang en -call :Target_kernel - -if ERRORLEVEL 0 goto Exit_OK - -echo There was an error executing script. -echo For any help, please send a report. -pause -goto :eof - - - - -:Check_Lang - set res=%1 - :Check_Lang_loop - for %%a in (%languages%) do if %%a==%res% set lang=%res% - if defined lang goto :eof - - echo Language '%res%' is incorrect - echo Enter valid language [ %languages% ]: - - set /P res="> - goto Check_Lang_loop -goto :eof - - -:Target_kernel - echo *** building kernel with language '%lang%' ... - if not exist bin mkdir bin - echo lang fix %lang% > lang.inc - c:\fasm\fasm -m 65536 kernel.asm bin\kernel.mnt - if not %errorlevel%==0 goto :Error_FasmFailed - erase lang.inc -goto :eof + fasm -m 65536 kernel.asm bin\kernel.mnt - - -:Error_FasmFailed -echo error: fasm execution failed -erase lang.inc pause -exit 1 - -:Exit_OK -echo all operations has been done -pause -exit 0 +exit 0 \ No newline at end of file diff --git a/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc b/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc index 1d4ca5bc9a..a4e12beb28 100644 --- a/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc +++ b/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc @@ -20,48 +20,6 @@ $Revision$ ; ;========================================================================== -if 0 -putchar: -; in: al=character - mov ah, 0Eh - mov bh, 0 - int 10h - ret - -print: -; in: si->string - mov al, 186 - call putchar - mov al, ' ' - call putchar - -printplain: -; in: si->string - pusha - lodsb -@@: - call putchar - lodsb - test al,al - jnz @b - popa - ret - - -setcursor: -; in: dl=column, dh=row - mov ah, 2 - mov bh, 0 - int 10h - ret - -macro _setcursor row,column -{ - mov dx, row*256 + column - call setcursor -} - -end if boot_read_floppy: push si @@ -80,8 +38,6 @@ boot_read_floppy: ret sayerr_plain: - jmp $ - sayerr: jmp $ @@ -163,6 +119,7 @@ no_hd_load: push cs pop es +if 0 ; set videomode mov ax, 3 int 0x10 @@ -172,6 +129,7 @@ no_hd_load: pop es xor di, di mov ah, 1*16+15 +end if cpugood: @@ -302,6 +260,7 @@ cfgmanager: ; pop ax ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ?? jmp .continue + .loader_block dd -1 .continue: sti @@ -344,314 +303,6 @@ include 'detect/biosmem.inc' ; READ DISKETTE TO MEMORY -if 0 ----- - cmp [boot_dev],0 - jne no_sys_on_floppy - xor ax, ax ; reset drive - xor dx, dx - int 0x13 -; do we boot from CD-ROM? - mov ah, 41h - mov bx, 55AAh - xor dx, dx - int 0x13 - jc .nocd - cmp bx, 0AA55h - jnz .nocd - mov ah, 48h - push ds - push es - pop ds - mov si, 0xa000 - mov word [si], 30 - int 0x13 - pop ds - jc .nocd - push ds - lds si, [es:si+26] - test byte [ds:si+10], 40h - pop ds - jz .nocd -; yes - read all floppy by 18 sectors - -; TODO: !!!! read only first sector and set variables !!!!! -; ... -; TODO: !!! then read flippy image track by track - - mov cx, 0x0001 ; startcyl,startsector -.a1: - push cx dx - mov al, 18 - mov bx, 0xa000 - call boot_read_floppy - mov si, movedesc - push es - push ds - pop es - mov cx, 256*18 - mov ah, 0x87 - int 0x15 - pop es - pop dx cx - test ah, ah - jnz sayerr_floppy - add dword [si+8*3+2], 512*18 - inc dh - cmp dh, 2 - jnz .a1 - mov dh, 0 - inc ch - cmp ch, 80 - jae ok_sys_on_floppy - mov al, ch - shr ch, 2 - jmp .a1 -.nocd: -; no - read only used sectors from floppy -; now load floppy image to memory -; at first load boot sector and first FAT table - -; read only first sector and fill variables - mov cx, 0x0001 ; first logical sector - xor dx, dx ; head = 0, drive = 0 (a:) - mov al, 1 ; read one sector - mov bx, 0xB000 ; es:bx -> data area - call boot_read_floppy -; fill the necessary parameters to work with a floppy - mov ax, word [es:bx+24] - mov word [BPB_SecPerTrk], ax - mov ax, word [es:bx+26] - mov word [BPB_NumHeads], ax - mov ax, word [es:bx+17] - mov word [BPB_RootEntCnt], ax - mov ax, word [es:bx+14] - mov word [BPB_RsvdSecCnt], ax - mov ax, word [es:bx+19] - mov word [BPB_TotSec16], ax - mov al, byte [es:bx+13] - mov byte [BPB_SecPerClus], al - mov al, byte [es:bx+16] - mov byte [BPB_NumFATs], al -; 18.11.2008 - mov ax, word [es:bx+22] - mov word [BPB_FATSz16], ax - mov cx, word [es:bx+11] - mov word [BPB_BytsPerSec], cx - -; count of clusters in FAT12 ((size_of_FAT*2)/3) -; mov ax, word [BPB_FATSz16] -; mov cx, word [BPB_BytsPerSec] -;end 18.11.2008 - xor dx, dx - mul cx - shl ax, 1 - mov cx, 3 - div cx ; now ax - number of clusters in FAT12 - mov word [end_of_FAT], ax - -; load first FAT table - mov cx, 0x0002 ; startcyl,startsector ; TODO!!!!! - xor dx, dx ; starthead,drive - mov al, byte [BPB_FATSz16] ; no of sectors to read - add bx, word [BPB_BytsPerSec] ; es:bx -> data area - call boot_read_floppy - mov bx, 0xB000 - -; and copy them to extended memory - mov si, movedesc - mov [si+8*2+3], bh ; from - - mov ax, word [BPB_BytsPerSec] - shr ax, 1 ; words per sector - mov cx, word [BPB_RsvdSecCnt] - add cx, word [BPB_FATSz16] - mul cx - push ax ; save to stack count of words in boot+FAT - xchg ax, cx - - push es - push ds - pop es - mov ah, 0x87 - int 0x15 - pop es - test ah, ah - jz @f -sayerr_floppy: - mov dx, 0x3f2 - mov al, 0 - out dx, al -; mov si, memmovefailed - jmp $ -@@: - pop ax ; restore from stack count of words in boot+FAT - shl ax, 1 ; make bytes count from count of words - and eax, 0ffffh - add dword [si+8*3+2], eax - -; copy first FAT to second copy -; TODO: BPB_NumFATs !!!!! - add bx, word [BPB_BytsPerSec] ; !!! TODO: may be need multiply by BPB_RsvdSecCnt !!! - mov byte [si+8*2+3], bh ; bx - begin of FAT - - mov ax, word [BPB_BytsPerSec] - shr ax, 1 ; words per sector - mov cx, word [BPB_FATSz16] - mul cx - mov cx, ax ; cx - count of words in FAT - - push es - push ds - pop es - mov ah, 0x87 - int 0x15 - pop es - test ah, ah - jnz sayerr_floppy - - mov ax, cx - shl ax, 1 - and eax, 0ffffh ; ax - count of bytes in FAT - add dword [si+8*3+2], eax - -; reading RootDir -; TODO: BPB_NumFATs - add bx, ax - add bx, 100h - and bx, 0ff00h ; bx - place in buffer to write RootDir - push bx - - mov bx, word [BPB_BytsPerSec] - shr bx, 5 ; divide bx by 32 - mov ax, word [BPB_RootEntCnt] - xor dx, dx - div bx - push ax ; ax - count of RootDir sectors - - mov ax, word [BPB_FATSz16] - xor cx, cx - mov cl, byte [BPB_NumFATs] - mul cx - add ax, word [BPB_RsvdSecCnt] ; ax - first sector of RootDir - - mov word [FirstDataSector], ax - pop bx - push bx - add word [FirstDataSector], bx ; Begin of data region of floppy - -; read RootDir - call conv_abs_to_THS - pop ax - pop bx ; place in buffer to write - push ax - call boot_read_floppy ; read RootDir into buffer -; copy RootDir - mov byte [si+8*2+3], bh ; from buffer - pop ax ; ax = count of RootDir sectors - mov cx, word [BPB_BytsPerSec] - mul cx - shr ax, 1 - mov cx, ax ; count of words to copy - push es - push ds - pop es - mov ah, 0x87 - int 0x15 - pop es - - mov ax, cx - shl ax, 1 - and eax, 0ffffh ; ax - count of bytes in RootDir - add dword [si+8*3+2], eax ; add count of bytes copied - -; Reading data clusters from floppy - mov byte [si+8*2+3], bh - push bx - - mov di, 2 ; First data cluster -.read_loop: - mov bx, di - shr bx, 1 ; bx+di = di*1.5 - jnc .even - test word [es:bx+di+0xB200], 0xFFF0 ; TODO: may not be 0xB200 !!! - jmp @f -.even: - test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! - -@@: - jz .skip -; read cluster di -;.read: - ;conv cluster di to abs. sector ax - ; ax = (N-2) * BPB_SecPerClus + FirstDataSector - mov ax, di - sub ax, 2 - xor bx, bx - mov bl, byte [BPB_SecPerClus] - mul bx - add ax, word [FirstDataSector] - call conv_abs_to_THS - pop bx - push bx - mov al, byte [BPB_SecPerClus] ; number of sectors in cluster - call boot_read_floppy - push es - push ds - pop es - pusha -; - mov ax, word [BPB_BytsPerSec] - xor cx, cx - mov cl, byte [BPB_SecPerClus] - mul cx - shr ax, 1 ; ax = (BPB_BytsPerSec * BPB_SecPerClus)/2 - mov cx, ax ; number of words to copy (count words in cluster) -; - mov ah, 0x87 - int 0x15 ; copy data - test ah, ah - popa - pop es - jnz sayerr_floppy -; skip cluster di -.skip: - mov ax, word [BPB_BytsPerSec] - xor cx, cx - mov cl, byte [BPB_SecPerClus] - mul cx - and eax, 0ffffh ; ax - count of bytes in cluster - add dword [si+8*3+2], eax - - mov ax, word [end_of_FAT] ; max cluster number - pusha -; draw percentage -; total clusters: ax -; read clusters: di - xchg ax, di - mov cx, 100 - mul cx - div di - aam - xchg al, ah - add ax, '00' -@@: - popa - inc di - cmp di, word [end_of_FAT] ; max number of cluster - jnz .read_loop - pop bx ; clear stack - -ok_sys_on_floppy: -no_sys_on_floppy: - xor ax, ax ; reset drive - xor dx, dx - int 0x13 - mov dx, 0x3f2 ; floppy motor off - mov al, 0 - out dx, al ---- -end if ; SET GRAPHICS diff --git a/kernel/branches/Kolibri-A/trunk/boot/booteng.inc b/kernel/branches/Kolibri-A/trunk/boot/booteng.inc index d695558558..536d4d4804 100644 --- a/kernel/branches/Kolibri-A/trunk/boot/booteng.inc +++ b/kernel/branches/Kolibri-A/trunk/boot/booteng.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -14,53 +14,4 @@ $Revision$ -;d80x25_bottom: -; db 186,' KolibriOS is based on MenuetOS and comes with ABSOLUTELY ' -; db 'NO WARRANTY ',186 -; db 186,' See file COPYING for details ' -; db ' ',186 -; line_full_bottom -;d80x25_bottom_num = 3 - -;msg_apm db " APM x.x ", 0 -;vervesa db "Version of Vesa: Vesa x.x",13,10,0 -;novesa db "Display: EGA/CGA",13,10,0 -;s_vesa db "Version of VESA: " -; .ver db "?.?",13,10,0 - -;gr_mode db "Select a videomode: ",13,10,0 - -;vrrmprint db "Apply VRR? (picture frequency greater than 60Hz" -; db " only for transfers:",13,10 -; db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0 - - -;ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0 - -;bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);" -; db 13,10,186," " -; db "3-use preloaded ram-image from kernel restart;" -; db 13,10,186," " -; db "4-create blank image]: ",0 -;probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, " -; db "2-probe bios (Vesa 3.0)]: ",0 -;prnotfnd db "Fatal - Videomode not found.",0 -;btns db "Fatal - Can't determine color depth.",0 -;badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0 -;memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0 -;okt db " ... OK" -;linef db 13,10,0 -;diskload db "Loading diskette: 00 %",8,8,8,8,0 -;pros db "00" -;backspace2 db 8,8,0 boot_dev db 0 ; 0=floppy, 1=hd -;start_msg db "Press [abcd] to change settings, press [Enter] to continue booting",13,10,0 -;time_msg db " or wait " -;time_str db " 5 seconds" -; db " before automatical continuation",13,10,0 -;current_cfg_msg db "cfgmanager.printcfg reached",13,10,0 -;curvideo_msg db " [a] Videomode: ",0 - -;loading_msg db "Loading KolibriOS...",0 -;save_quest db "Remember current settings? [y/n]: ",0 -;loader_block_error db "Invalid boot data",0 diff --git a/kernel/branches/Kolibri-A/trunk/boot/bootvesa.inc b/kernel/branches/Kolibri-A/trunk/boot/bootvesa.inc index 7664766439..b59fca8445 100644 --- a/kernel/branches/Kolibri-A/trunk/boot/bootvesa.inc +++ b/kernel/branches/Kolibri-A/trunk/boot/bootvesa.inc @@ -78,7 +78,7 @@ virtual at $A000 mi VBE_ModeInfo modes_table: end virtual -cursor_pos dw 0 ;временное хранение курсора. +cursor_pos dw 0 ;temporary cursor storage. home_cursor dw 0 ;current shows rows a table end_cursor dw 0 ;end of position current shows rows a table scroll_start dw 0 ;start position of scroll bar diff --git a/kernel/branches/Kolibri-A/trunk/boot/rdload.inc b/kernel/branches/Kolibri-A/trunk/boot/rdload.inc index 568aa004ee..9548bc6fd8 100644 --- a/kernel/branches/Kolibri-A/trunk/boot/rdload.inc +++ b/kernel/branches/Kolibri-A/trunk/boot/rdload.inc @@ -10,9 +10,9 @@ $Revision$ ; READ RAMDISK IMAGE FROM HD - cmp [boot_dev+OS_BASE+0x10000],1 -; jne no_sys_on_hd - +; cmp [boot_dev+OS_BASE+0x10000],1 + jmp no_sys_on_hd +if 0 test [DRIVE_DATA+1],byte 0x40 jz position_2 mov [hdbase],0x1f0 @@ -97,6 +97,7 @@ read_image: mov edi, 12 call file_read ret +end if image_retrieved db 0 counter_of_partitions db 0 diff --git a/kernel/branches/Kolibri-A/trunk/boot/shutdown.inc b/kernel/branches/Kolibri-A/trunk/boot/shutdown.inc deleted file mode 100644 index 3e3679cafd..0000000000 --- a/kernel/branches/Kolibri-A/trunk/boot/shutdown.inc +++ /dev/null @@ -1,209 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; Shutdown for Menuet ;; -;; ;; -;; Distributed under General Public License ;; -;; See file COPYING for details. ;; -;; Copyright 2003 Ville Turjanmaa ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -$Revision$ - - -align 4 -pr_mode_exit: - -; setup stack - mov ax, 0x3000 - mov ss, ax - mov esp, 0x0EC00 -; setup ds - push cs - pop ds - - lidt [old_ints_h] -;remap IRQs - mov al,0x11 - out 0x20,al - call rdelay - out 0xA0,al - call rdelay - - mov al,0x08 - out 0x21,al - call rdelay - mov al,0x70 - out 0xA1,al - call rdelay - - mov al,0x04 - out 0x21,al - call rdelay - mov al,0x02 - out 0xA1,al - call rdelay - - mov al,0x01 - out 0x21,al - call rdelay - out 0xA1,al - call rdelay - - mov al,0xB8 - out 0x21,al - call rdelay - mov al,0xBD - out 0xA1,al - sti - -temp_3456: - xor ax,ax - mov es,ax - mov al,byte [es:0x9030] - cmp al,1 - jl nbw - cmp al,4 - jle nbw32 - -nbw: - in al,0x60 - cmp al,6 - jae nbw - mov bl,al -nbw2: - in al,0x60 - cmp al,bl - je nbw2 - cmp al,240 ;ax,240 - jne nbw31 - mov al,bl - dec ax - jmp nbw32 -nbw31: - add bl,128 - cmp al,bl - jne nbw - sub al,129 - -nbw32: - - dec ax - dec ax ; 2 = power off - jnz no_apm_off - call APM_PowerOff - jmp $ -no_apm_off: - - dec ax ; 3 = reboot - jnz restart_kernel ; 4 = restart kernel - push 0x40 - pop ds - mov word[0x0072],0x1234 - jmp 0xF000:0xFFF0 - - -rdelay: - ret - -APM_PowerOff: - mov ax, 5304h - xor bx, bx - int 15h -;!!!!!!!!!!!!!!!!!!!!!!!! - mov ax,0x5300 - xor bx,bx - int 0x15 - push ax - - mov ax,0x5301 - xor bx,bx - int 0x15 - - mov ax,0x5308 - mov bx,1 - mov cx,bx - int 0x15 - - mov ax,0x530E - xor bx,bx - pop cx - int 0x15 - - mov ax,0x530D - mov bx,1 - mov cx,bx - int 0x15 - - mov ax,0x530F - mov bx,1 - mov cx,bx - int 0x15 - - mov ax,0x5307 - mov bx,1 - mov cx,3 - int 0x15 -;!!!!!!!!!!!!!!!!!!!!!!!! - ret - -restart_kernel: - - mov ax,0x0003 ; set text mode for screen - int 0x10 - jmp 0x4000:0000 - -restart_kernel_4000: - cli - - push ds - pop es - mov cx, 0x8000 - push cx - push 0x7000 - pop ds - xor si, si - xor di, di - rep movsw - pop cx - mov ds, cx - push 0x2000 - pop es - rep movsw - push 0x9000 - pop ds - push 0x3000 - pop es - mov cx, 0xE000/2 - rep movsw - - wbinvd ; write and invalidate cache - - mov al, 00110100b - out 43h, al - jcxz $+2 - mov al, 0xFF - out 40h, al - jcxz $+2 - out 40h, al - jcxz $+2 - sti - -; (hint by Black_mirror) -; We must read data from keyboard port, -; because there may be situation when previous keyboard interrupt is lost -; (due to return to real mode and IRQ reprogramming) -; and next interrupt will not be generated (as keyboard waits for handling) - in al, 0x60 - -; bootloader interface - push 0x1000 - pop ds - mov si, kernel_restart_bootblock - mov ax, 'KL' - jmp 0x1000:0000 - - diff --git a/kernel/branches/Kolibri-A/trunk/bus/HT.inc b/kernel/branches/Kolibri-A/trunk/bus/HT.inc index 58734c446a..f7a1194a8d 100644 --- a/kernel/branches/Kolibri-A/trunk/bus/HT.inc +++ b/kernel/branches/Kolibri-A/trunk/bus/HT.inc @@ -174,29 +174,29 @@ map_pcie_pages: ; ---- stepping 10h CPUs and Fusion APUs: the configspace is stored in MSR_C001_0058 ---- align 4 fusion_pcie_init: - mov ecx, 0xC0010058 - rdmsr - or edx, edx - jnz $ ; PCIe is in the upper memory. Stop. - xchg dl, al + mov ecx, 0xC0010058 + rdmsr + or edx, edx + jnz $ ; PCIe is in the upper memory. Stop. + xchg dl, al mov dword[mmio_pcie_cfg_addr-OS_BASE], eax ; store the physical address - mov ecx, edx - and dl, 1 - jz $ ; bit[0] = 1 means no PCIe mapping allowed. Stop. - shr cl, 2 ; ecx = log2(number of buses) - mov word[PCIe_bus_range-OS_BASE], cx - sub cl, 2 - jae @f - xor cl, cl + mov ecx, edx + and dl, 1 + jz $ ; bit[0] = 1 means no PCIe mapping allowed. Stop. + shr cl, 2 ; ecx = log2(number of buses) + mov word[PCIe_bus_range-OS_BASE], cx + sub cl, 2 + jae @f + xor cl, cl @@: - shl edx, cl ; edx = number of 4M pages to map - mov word[mmio_pcie_cfg_pdes-OS_BASE], dx - shl edx, 22 - dec edx - add edx, eax ; the upper configspace limit + shl edx, cl ; edx = number of 4M pages to map + mov word[mmio_pcie_cfg_pdes-OS_BASE], dx + shl edx, 22 + dec edx + add edx, eax ; the upper configspace limit mov dword[mmio_pcie_cfg_lim-OS_BASE], edx - jmp map_pcie_pages + jmp map_pcie_pages ; ================================================================================ @@ -315,12 +315,11 @@ sys_rdmsr: ; out: [esp+8] = MSR[63:32] ; [eax] = MSR[31: 0] ;------------------------------------------------ - push ecx edx - mov ecx, [esp+16] - rdmsr - mov [esp+16], edx - pop edx ecx - ret - + push ecx edx + mov ecx, [esp+16] + rdmsr + mov [esp+16], edx + pop edx ecx + ret diff --git a/kernel/branches/Kolibri-A/trunk/bus/SB/HUDSON.INC b/kernel/branches/Kolibri-A/trunk/bus/SB/HUDSON.INC new file mode 100644 index 0000000000..2da38b496d --- /dev/null +++ b/kernel/branches/Kolibri-A/trunk/bus/SB/HUDSON.INC @@ -0,0 +1,3 @@ + +SB_PM_CTRL_BLK equ 0x62 + diff --git a/kernel/branches/Kolibri-A/trunk/bus/SB/SB710.ASM b/kernel/branches/Kolibri-A/trunk/bus/SB/SB.INC similarity index 73% rename from kernel/branches/Kolibri-A/trunk/bus/SB/SB710.ASM rename to kernel/branches/Kolibri-A/trunk/bus/SB/SB.INC index 9588568b7f..b9d209fbc9 100644 --- a/kernel/branches/Kolibri-A/trunk/bus/SB/SB710.ASM +++ b/kernel/branches/Kolibri-A/trunk/bus/SB/SB.INC @@ -1,9 +1,16 @@ $Revision: 1598 $ -SMBUS_PCIE_ADDR equ 0xF00A0000 ; bdf0:20.0 = SB7xx SMBus PCI Config Registers -LPC_PCIE_ADDR equ 0xF00A3000 ; bdf0:20.3 = SB7xx LPC ISA bridge Config Registers +SMBUS_PCIE_ADDR equ 0xF00A0000 ; bdf0:20.0 = SB7xx SMBus PCI Config Registers +LPC_PCIE_ADDR equ 0xF00A3000 ; bdf0:20.3 = SB7xx LPC ISA bridge Config Registers -SB_SIO_INDEX equ 0x2e +SB_SIO_INDEX equ 0x2E +SB_PM_INDEX equ 0xCD6 + +if PLATFORM>PLATFORM_RS780 +include "bus/sb/hudson.inc" +else +include "bus/sb/sb710.inc" +end if ;--------------------------------------------------------------------- align 4 @@ -43,10 +50,38 @@ lpc_write_pciconfig: align 4 read_sio_cfg: ; in: al = reg# | out: al = data + push edx mov dx, SB_SIO_INDEX out dx, al inc dl in al, dx + pop edx + ret + +;------------------------------------------------ +align 4 +write_pm_cfg: +; in: al = reg#; ah = data +;------------------------------------------------ + push edx + mov dx, SB_PM_INDEX + out dx, al + inc dl + xchg al, ah + out dx, al + xchg al, ah + pop edx + ret +;-------------------------------------------------------------------- +align 4 +read_pm_cfg: +; in: al = reg# | out: al = data + push edx + mov dx, SB_PM_INDEX + out dx, al + inc dl + in al, dx + pop edx ret ;------------------------------------------------ @@ -54,12 +89,14 @@ align 4 write_sio_cfg: ; in: al = reg#; ah = data ;------------------------------------------------ + push edx mov dx, SB_SIO_INDEX out dx, al inc dl xchg al, ah out dx, al xchg al, ah + pop edx ret ;------------------------------------------------ align 4 @@ -78,12 +115,12 @@ enter_sio_cfg_mode: ret ;----------------------------------------------------------------------- -; ATTENTION: the functions assume that RESET# signals use pins 84 and 34 -; of IT8712F SuperIO chip. These signals may be (and will be!) different +; ATTENTION: the functions assume that RESET# signals use pins 84 and 34 +; of IT8712F SuperIO chip. These signals may be (and will be!) different ; for every particular motherboard and SIO. Please refer to your m/board -; documentation to define the correct pins and GPIO lines! +; documentation to define the correct pins and GPIO lines! ; -; Note this example DOES NOT PRETEND to be 100% correct implementation +; Note this example DOES NOT PRETEND to be 100% correct implementation ; of PCIe hotplug techniques !! ;----------------------------------------------------------------------- align 4 @@ -111,7 +148,7 @@ init_pcie_slot_control: mov ax, 0x0202 ; Lock SIO config ports call write_sio_cfg ret - + align 4 reset_pcie_slot: ;------------------------------------------------ @@ -122,7 +159,7 @@ reset_pcie_slot: call read_sio_cfg ; ah = regB0h (Pin polarity) and ah, 0xFC ; invert bits 0, 1 call write_sio_cfg - or ah, 3 ; restore bits 0, 1 + or ah, 3 ; restore bits 0, 1 call write_sio_cfg mov ax, 0x0202 ; Lock SIO config ports call write_sio_cfg diff --git a/kernel/branches/Kolibri-A/trunk/bus/SB/SB710.INC b/kernel/branches/Kolibri-A/trunk/bus/SB/SB710.INC new file mode 100644 index 0000000000..225bcfef42 --- /dev/null +++ b/kernel/branches/Kolibri-A/trunk/bus/SB/SB710.INC @@ -0,0 +1,3 @@ + +SB_PM_CTRL_BLK equ 0x22 + diff --git a/kernel/branches/Kolibri-A/trunk/const.inc b/kernel/branches/Kolibri-A/trunk/const.inc index e82ff1c337..c55e78210c 100644 --- a/kernel/branches/Kolibri-A/trunk/const.inc +++ b/kernel/branches/Kolibri-A/trunk/const.inc @@ -26,6 +26,11 @@ CPU_PENTIUM equ 5 CPU_P6 equ 6 CPU_PENTIUM4 equ 0x0F +PLATFORM equ 0x14 +PLATFORM_RS780 equ 0x0F +PLATFORM_RS880 equ 0x10 +PLATFORM_FUSION equ 0x14 + CAPS_FPU equ 00 ;on-chip x87 floating point unit CAPS_VME equ 01 ;virtual-mode enhancements CAPS_DE equ 02 ;debugging extensions diff --git a/kernel/branches/Kolibri-A/trunk/core/heap.inc b/kernel/branches/Kolibri-A/trunk/core/heap.inc index ef2694f612..3b81488613 100644 --- a/kernel/branches/Kolibri-A/trunk/core/heap.inc +++ b/kernel/branches/Kolibri-A/trunk/core/heap.inc @@ -9,19 +9,19 @@ $Revision$ struc MEM_BLOCK -{ .next_block dd ? - .prev_block dd ? ;+4 - .list_fd dd ? ;+8 - .list_bk dd ? ;+12 - .base dd ? ;+16 - .size dd ? ;+20 - .flags dd ? ;+24 - .handle dd ? ;+28 +{ .next_block dd ? + .prev_block dd ? ;+4 + .list_fd dd ? ;+8 + .list_bk dd ? ;+12 + .base dd ? ;+16 + .size dd ? ;+20 + .flags dd ? ;+24 + .handle dd ? ;+28 } MEM_LIST_OFFSET equ 8 -FREE_BLOCK equ 4 -USED_BLOCK equ 8 +FREE_BLOCK equ 4 +USED_BLOCK equ 8 DONT_FREE_BLOCK equ 10h virtual at 0 @@ -39,123 +39,123 @@ block_size equ MEM_BLOCK.size block_flags equ MEM_BLOCK.flags macro calc_index op -{ shr op, 12 - dec op - cmp op, 63 - jna @f - mov op, 63 +{ shr op, 12 + dec op + cmp op, 63 + jna @f + mov op, 63 @@: } macro remove_from_list op -{ mov edx, [op+list_fd] - mov ecx, [op+list_bk] - test edx, edx - jz @f - mov [edx+list_bk], ecx +{ mov edx, [op+list_fd] + mov ecx, [op+list_bk] + test edx, edx + jz @f + mov [edx+list_bk], ecx @@: - test ecx, ecx - jz @f - mov [ecx+list_fd], edx + test ecx, ecx + jz @f + mov [ecx+list_fd], edx @@: - mov [op+list_fd],0 - mov [op+list_bk],0 + mov [op+list_fd],0 + mov [op+list_bk],0 } macro remove_from_free op { - remove_from_list op + remove_from_list op - mov eax, [op+block_size] - calc_index eax - cmp [mem_block_list+eax*4], op - jne @f - mov [mem_block_list+eax*4], edx + mov eax, [op+block_size] + calc_index eax + cmp [mem_block_list+eax*4], op + jne @f + mov [mem_block_list+eax*4], edx @@: - cmp [mem_block_list+eax*4], 0 - jne @f - btr [mem_block_mask], eax + cmp [mem_block_list+eax*4], 0 + jne @f + btr [mem_block_mask], eax @@: } macro remove_from_used op { - mov edx, [op+list_fd] - mov ecx, [op+list_bk] - mov [edx+list_bk], ecx - mov [ecx+list_fd], edx - mov [op+list_fd], 0 - mov [op+list_bk], 0 + mov edx, [op+list_fd] + mov ecx, [op+list_bk] + mov [edx+list_bk], ecx + mov [ecx+list_fd], edx + mov [op+list_fd], 0 + mov [op+list_bk], 0 } align 4 proc init_kernel_heap - mov ecx, 64 - mov edi, mem_block_list - xor eax, eax - cld - rep stosd + mov ecx, 64 + mov edi, mem_block_list + xor eax, eax + cld + rep stosd - mov ecx, 512/4 - mov edi, mem_block_map - not eax - rep stosd + mov ecx, 512/4 + mov edi, mem_block_map + not eax + rep stosd - mov [mem_block_start], mem_block_map - mov [mem_block_end], mem_block_map+512 - mov [mem_block_arr], HEAP_BASE + mov [mem_block_start], mem_block_map + mov [mem_block_end], mem_block_map+512 + mov [mem_block_arr], HEAP_BASE - mov eax, mem_used.fd-MEM_LIST_OFFSET - mov [mem_used.fd], eax - mov [mem_used.bk], eax + mov eax, mem_used.fd-MEM_LIST_OFFSET + mov [mem_used.fd], eax + mov [mem_used.bk], eax mov [KERNEL_ALLOC_FLAG], dword PG_SW - stdcall alloc_pages, dword 32 - mov ecx, 32 - mov edx, eax - mov edi, HEAP_BASE + stdcall alloc_pages, dword 32 + mov ecx, 32 + mov edx, eax + mov edi, HEAP_BASE .l1: - stdcall map_page,edi,edx,PG_SW - add edi, 0x1000 - add edx, 0x1000 - dec ecx - jnz .l1 + stdcall map_page,edi,edx,PG_SW + add edi, 0x1000 + add edx, 0x1000 + dec ecx + jnz .l1 - mov edi, HEAP_BASE - mov ebx, HEAP_BASE+MEM_BLOCK_SIZE - xor eax, eax - mov [edi+block_next], ebx - mov [edi+block_prev], eax - mov [edi+list_fd], eax - mov [edi+list_bk], eax - mov [edi+block_base], HEAP_BASE - mov [edi+block_size], 4096*MEM_BLOCK_SIZE - mov [edi+block_flags], USED_BLOCK + mov edi, HEAP_BASE + mov ebx, HEAP_BASE+MEM_BLOCK_SIZE + xor eax, eax + mov [edi+block_next], ebx + mov [edi+block_prev], eax + mov [edi+list_fd], eax + mov [edi+list_bk], eax + mov [edi+block_base], HEAP_BASE + mov [edi+block_size], 4096*MEM_BLOCK_SIZE + mov [edi+block_flags], USED_BLOCK - mov [ebx+block_next], eax - mov [ebx+block_prev], eax - mov [ebx+list_fd], eax - mov [ebx+list_bk], eax - mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE + mov [ebx+block_next], eax + mov [ebx+block_prev], eax + mov [ebx+list_fd], eax + mov [ebx+list_bk], eax + mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE - mov ecx, [pg_data.kernel_pages] - shl ecx, 12 - sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK_SIZE - mov [heap_size], ecx - mov [heap_free], ecx - mov [ebx+block_size], ecx - mov [ebx+block_flags], FREE_BLOCK + mov ecx, [pg_data.kernel_pages] + shl ecx, 12 + sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK_SIZE + mov [heap_size], ecx + mov [heap_free], ecx + mov [ebx+block_size], ecx + mov [ebx+block_flags], FREE_BLOCK - mov [mem_block_mask], eax - mov [mem_block_mask+4],0x80000000 + mov [mem_block_mask], eax + mov [mem_block_mask+4],0x80000000 - mov [mem_block_list+63*4], ebx - mov byte [mem_block_map], 0xFC - and [heap_mutex], 0 - mov [heap_blocks], 4095 - mov [free_blocks], 4094 - ret + mov [mem_block_list+63*4], ebx + mov byte [mem_block_map], 0xFC + and [heap_mutex], 0 + mov [heap_blocks], 4095 + mov [free_blocks], 4094 + ret endp ; param @@ -167,479 +167,479 @@ endp align 4 get_small_block: - mov ecx, eax - shr ecx, 12 - dec ecx - cmp ecx, 63 - jle .get_index - mov ecx, 63 + mov ecx, eax + shr ecx, 12 + dec ecx + cmp ecx, 63 + jle .get_index + mov ecx, 63 .get_index: - lea esi, [mem_block_mask] - xor ebx, ebx - or edx, -1 + lea esi, [mem_block_mask] + xor ebx, ebx + or edx, -1 - cmp ecx, 32 - jb .bit_test + cmp ecx, 32 + jb .bit_test - sub ecx, 32 - add ebx, 32 - add esi, 4 + sub ecx, 32 + add ebx, 32 + add esi, 4 .bit_test: - shl edx, cl - and edx, [esi] + shl edx, cl + and edx, [esi] .find: - bsf edi, edx - jz .high_mask - add ebx, edi - mov edi, [mem_block_list+ebx*4] + bsf edi, edx + jz .high_mask + add ebx, edi + mov edi, [mem_block_list+ebx*4] .check_size: - cmp eax, [edi+block_size] - ja .next - ret + cmp eax, [edi+block_size] + ja .next + ret .high_mask: - add esi, 4 - cmp esi, mem_block_mask+8 - jae .err - add ebx, 32 - mov edx, [esi] - jmp .find + add esi, 4 + cmp esi, mem_block_mask+8 + jae .err + add ebx, 32 + mov edx, [esi] + jmp .find .next: - mov edi, [edi+list_fd] - test edi, edi - jnz .check_size + mov edi, [edi+list_fd] + test edi, edi + jnz .check_size .err: - xor edi, edi - ret + xor edi, edi + ret align 4 alloc_mem_block: - mov ebx, [mem_block_start] - mov ecx, [mem_block_end] + mov ebx, [mem_block_start] + mov ecx, [mem_block_end] .l1: - bsf eax,[ebx]; - jnz found - add ebx,4 - cmp ebx, ecx - jb .l1 - xor eax,eax - ret + bsf eax,[ebx]; + jnz found + add ebx,4 + cmp ebx, ecx + jb .l1 + xor eax,eax + ret found: - btr [ebx], eax - mov [mem_block_start],ebx - sub ebx, mem_block_map - lea eax,[eax+ebx*8] - shl eax, 5 - add eax, [mem_block_arr] - dec [free_blocks] - ret + btr [ebx], eax + mov [mem_block_start],ebx + sub ebx, mem_block_map + lea eax,[eax+ebx*8] + shl eax, 5 + add eax, [mem_block_arr] + dec [free_blocks] + ret align 4 free_mem_block: - mov dword [eax], 0 - mov dword [eax+4], 0 - mov dword [eax+8], 0 - mov dword [eax+12], 0 - mov dword [eax+16], 0 + mov dword [eax], 0 + mov dword [eax+4], 0 + mov dword [eax+8], 0 + mov dword [eax+12], 0 + mov dword [eax+16], 0 ; mov dword [eax+20], 0 - mov dword [eax+24], 0 - mov dword [eax+28], 0 + mov dword [eax+24], 0 + mov dword [eax+28], 0 - sub eax, [mem_block_arr] - shr eax, 5 + sub eax, [mem_block_arr] + shr eax, 5 - mov ebx, mem_block_map - bts [ebx], eax - inc [free_blocks] - shr eax, 3 - and eax, not 3 - add eax, ebx - cmp [mem_block_start], eax - ja @f - ret + mov ebx, mem_block_map + bts [ebx], eax + inc [free_blocks] + shr eax, 3 + and eax, not 3 + add eax, ebx + cmp [mem_block_start], eax + ja @f + ret @@: - mov [mem_block_start], eax + mov [mem_block_start], eax ret .err: - xor eax, eax + xor eax, eax ret align 4 proc alloc_kernel_space stdcall, size:dword - local block_ind:DWORD + local block_ind:DWORD - push ebx - push esi - push edi + push ebx + push esi + push edi - mov eax, [size] - add eax, 4095 - and eax, not 4095 - mov [size], eax + mov eax, [size] + add eax, 4095 + and eax, not 4095 + mov [size], eax - mov ebx, heap_mutex - call wait_mutex ;ebx + mov ebx, heap_mutex + call wait_mutex ;ebx - cmp eax, [heap_free] - ja .error + cmp eax, [heap_free] + ja .error - call get_small_block ; eax - test edi, edi - jz .error + call get_small_block ; eax + test edi, edi + jz .error - cmp [edi+block_flags], FREE_BLOCK - jne .error + cmp [edi+block_flags], FREE_BLOCK + jne .error - mov [block_ind], ebx ;index of allocated block + mov [block_ind], ebx ;index of allocated block - mov eax, [edi+block_size] - cmp eax, [size] - je .m_eq_size + mov eax, [edi+block_size] + cmp eax, [size] + je .m_eq_size - call alloc_mem_block - and eax, eax - jz .error + call alloc_mem_block + and eax, eax + jz .error - mov esi, eax ;esi - splitted block + mov esi, eax ;esi - splitted block - mov [esi+block_next], edi - mov eax, [edi+block_prev] - mov [esi+block_prev], eax - mov [edi+block_prev], esi - mov [esi+list_fd], 0 - mov [esi+list_bk], 0 - and eax, eax - jz @f - mov [eax+block_next], esi + mov [esi+block_next], edi + mov eax, [edi+block_prev] + mov [esi+block_prev], eax + mov [edi+block_prev], esi + mov [esi+list_fd], 0 + mov [esi+list_bk], 0 + and eax, eax + jz @f + mov [eax+block_next], esi @@: - mov ebx, [edi+block_base] - mov [esi+block_base], ebx - mov edx, [size] - mov [esi+block_size], edx - add [edi+block_base], edx - sub [edi+block_size], edx + mov ebx, [edi+block_base] + mov [esi+block_base], ebx + mov edx, [size] + mov [esi+block_size], edx + add [edi+block_base], edx + sub [edi+block_size], edx - mov eax, [edi+block_size] - shr eax, 12 - sub eax, 1 - cmp eax, 63 - jna @f - mov eax, 63 + mov eax, [edi+block_size] + shr eax, 12 + sub eax, 1 + cmp eax, 63 + jna @f + mov eax, 63 @@: - cmp eax, [block_ind] - je .m_eq_ind + cmp eax, [block_ind] + je .m_eq_ind - remove_from_list edi + remove_from_list edi - mov ecx, [block_ind] - mov [mem_block_list+ecx*4], edx + mov ecx, [block_ind] + mov [mem_block_list+ecx*4], edx - test edx, edx - jnz @f - btr [mem_block_mask], ecx + test edx, edx + jnz @f + btr [mem_block_mask], ecx @@: - mov edx, [mem_block_list+eax*4] - mov [edi+list_fd], edx - test edx, edx - jz @f - mov [edx+list_bk], edi + mov edx, [mem_block_list+eax*4] + mov [edi+list_fd], edx + test edx, edx + jz @f + mov [edx+list_bk], edi @@: - mov [mem_block_list+eax*4], edi - bts [mem_block_mask], eax + mov [mem_block_list+eax*4], edi + bts [mem_block_mask], eax .m_eq_ind: - mov ecx, mem_used.fd-MEM_LIST_OFFSET - mov edx, [ecx+list_fd] - mov [esi+list_fd], edx - mov [esi+list_bk], ecx - mov [ecx+list_fd], esi - mov [edx+list_bk], esi + mov ecx, mem_used.fd-MEM_LIST_OFFSET + mov edx, [ecx+list_fd] + mov [esi+list_fd], edx + mov [esi+list_bk], ecx + mov [ecx+list_fd], esi + mov [edx+list_bk], esi - mov [esi+block_flags], USED_BLOCK - mov eax, [esi+block_base] - mov ebx, [size] - sub [heap_free], ebx - and [heap_mutex], 0 - pop edi - pop esi - pop ebx - ret + mov [esi+block_flags], USED_BLOCK + mov eax, [esi+block_base] + mov ebx, [size] + sub [heap_free], ebx + and [heap_mutex], 0 + pop edi + pop esi + pop ebx + ret .m_eq_size: - remove_from_list edi - mov [mem_block_list+ebx*4], edx - and edx, edx - jnz @f - btr [mem_block_mask], ebx + remove_from_list edi + mov [mem_block_list+ebx*4], edx + and edx, edx + jnz @f + btr [mem_block_mask], ebx @@: - mov ecx, mem_used.fd-MEM_LIST_OFFSET - mov edx, [ecx+list_fd] - mov [edi+list_fd], edx - mov [edi+list_bk], ecx - mov [ecx+list_fd], edi - mov [edx+list_bk], edi + mov ecx, mem_used.fd-MEM_LIST_OFFSET + mov edx, [ecx+list_fd] + mov [edi+list_fd], edx + mov [edi+list_bk], ecx + mov [ecx+list_fd], edi + mov [edx+list_bk], edi - mov [edi+block_flags], USED_BLOCK - mov eax, [edi+block_base] - mov ebx, [size] - sub [heap_free], ebx - and [heap_mutex], 0 - pop edi - pop esi - pop ebx - ret + mov [edi+block_flags], USED_BLOCK + mov eax, [edi+block_base] + mov ebx, [size] + sub [heap_free], ebx + and [heap_mutex], 0 + pop edi + pop esi + pop ebx + ret .error: - xor eax, eax - mov [heap_mutex], eax - pop edi - pop esi - pop ebx - ret + xor eax, eax + mov [heap_mutex], eax + pop edi + pop esi + pop ebx + ret endp align 4 proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword - push ebx - push esi - push edi - mov ebx, heap_mutex - call wait_mutex ;ebx + push ebx + push esi + push edi + mov ebx, heap_mutex + call wait_mutex ;ebx - mov eax, [base] - mov esi, [mem_used.fd] + mov eax, [base] + mov esi, [mem_used.fd] @@: - cmp esi, mem_used.fd-MEM_LIST_OFFSET - je .fail + cmp esi, mem_used.fd-MEM_LIST_OFFSET + je .fail - cmp [esi+block_base], eax - je .found - mov esi, [esi+list_fd] - jmp @b + cmp [esi+block_base], eax + je .found + mov esi, [esi+list_fd] + jmp @b .found: - cmp [esi+block_flags], USED_BLOCK - jne .fail + cmp [esi+block_flags], USED_BLOCK + jne .fail - mov eax, [esi+block_size] - add [heap_free], eax + mov eax, [esi+block_size] + add [heap_free], eax - mov edi, [esi+block_next] - test edi, edi - jz .prev + mov edi, [esi+block_next] + test edi, edi + jz .prev - cmp [edi+block_flags], FREE_BLOCK - jne .prev + cmp [edi+block_flags], FREE_BLOCK + jne .prev - remove_from_free edi + remove_from_free edi - mov edx, [edi+block_next] - mov [esi+block_next], edx - test edx, edx - jz @f + mov edx, [edi+block_next] + mov [esi+block_next], edx + test edx, edx + jz @f - mov [edx+block_prev], esi + mov [edx+block_prev], esi @@: - mov ecx, [edi+block_size] - add [esi+block_size], ecx + mov ecx, [edi+block_size] + add [esi+block_size], ecx - mov eax, edi - call free_mem_block + mov eax, edi + call free_mem_block .prev: - mov edi, [esi+block_prev] - test edi, edi - jz .insert + mov edi, [esi+block_prev] + test edi, edi + jz .insert - cmp [edi+block_flags], FREE_BLOCK - jne .insert + cmp [edi+block_flags], FREE_BLOCK + jne .insert - remove_from_used esi + remove_from_used esi - mov edx, [esi+block_next] - mov [edi+block_next], edx - test edx, edx - jz @f - mov [edx+block_prev], edi + mov edx, [esi+block_next] + mov [edi+block_next], edx + test edx, edx + jz @f + mov [edx+block_prev], edi @@: - mov eax, esi - call free_mem_block + mov eax, esi + call free_mem_block - mov ecx, [edi+block_size] - mov eax, [esi+block_size] - add eax, ecx - mov [edi+block_size], eax + mov ecx, [edi+block_size] + mov eax, [esi+block_size] + add eax, ecx + mov [edi+block_size], eax - calc_index eax - calc_index ecx - cmp eax, ecx - je .m_eq + calc_index eax + calc_index ecx + cmp eax, ecx + je .m_eq - push ecx - remove_from_list edi - pop ecx + push ecx + remove_from_list edi + pop ecx - cmp [mem_block_list+ecx*4], edi - jne @f - mov [mem_block_list+ecx*4], edx + cmp [mem_block_list+ecx*4], edi + jne @f + mov [mem_block_list+ecx*4], edx @@: - cmp [mem_block_list+ecx*4], 0 - jne @f - btr [mem_block_mask], ecx + cmp [mem_block_list+ecx*4], 0 + jne @f + btr [mem_block_mask], ecx @@: - mov esi, [mem_block_list+eax*4] - mov [mem_block_list+eax*4], edi - mov [edi+list_fd], esi - test esi, esi - jz @f - mov [esi+list_bk], edi + mov esi, [mem_block_list+eax*4] + mov [mem_block_list+eax*4], edi + mov [edi+list_fd], esi + test esi, esi + jz @f + mov [esi+list_bk], edi @@: - bts [mem_block_mask], eax + bts [mem_block_mask], eax .m_eq: - xor eax, eax - mov [heap_mutex], eax - dec eax - pop edi - pop esi - pop ebx - ret + xor eax, eax + mov [heap_mutex], eax + dec eax + pop edi + pop esi + pop ebx + ret .insert: - remove_from_used esi + remove_from_used esi - mov eax, [esi+block_size] - calc_index eax + mov eax, [esi+block_size] + calc_index eax - mov edi, [mem_block_list+eax*4] - mov [mem_block_list+eax*4], esi - mov [esi+list_fd], edi - test edi, edi - jz @f - mov [edi+list_bk], esi + mov edi, [mem_block_list+eax*4] + mov [mem_block_list+eax*4], esi + mov [esi+list_fd], edi + test edi, edi + jz @f + mov [edi+list_bk], esi @@: - bts [mem_block_mask], eax - mov [esi+block_flags],FREE_BLOCK - xor eax, eax - mov [heap_mutex], eax - dec eax - pop edi - pop esi - pop ebx - ret + bts [mem_block_mask], eax + mov [esi+block_flags],FREE_BLOCK + xor eax, eax + mov [heap_mutex], eax + dec eax + pop edi + pop esi + pop ebx + ret .fail: - xor eax, eax - mov [heap_mutex], eax - pop edi - pop esi - pop ebx - ret + xor eax, eax + mov [heap_mutex], eax + pop edi + pop esi + pop ebx + ret endp align 4 proc kernel_alloc stdcall, size:dword - locals - lin_addr dd ? - pages_count dd ? - endl + locals + lin_addr dd ? + pages_count dd ? + endl - push ebx - push edi + push ebx + push edi - mov eax, [size] - add eax, 4095 - and eax, not 4095; - mov [size], eax - and eax, eax - jz .err - mov ebx, eax - shr ebx, 12 - mov [pages_count], ebx + mov eax, [size] + add eax, 4095 + and eax, not 4095; + mov [size], eax + and eax, eax + jz .err + mov ebx, eax + shr ebx, 12 + mov [pages_count], ebx - stdcall alloc_kernel_space, eax - test eax, eax - jz .err - mov [lin_addr], eax + stdcall alloc_kernel_space, eax + test eax, eax + jz .err + mov [lin_addr], eax - mov ecx, [pages_count] - mov edx, eax - mov ebx, ecx + mov ecx, [pages_count] + mov edx, eax + mov ebx, ecx - shr ecx, 3 - jz .next + shr ecx, 3 + jz .next - and ebx, not 7 - push ebx - stdcall alloc_pages, ebx - pop ecx ; yes ecx!!! - and eax, eax - jz .err + and ebx, not 7 + push ebx + stdcall alloc_pages, ebx + pop ecx ; yes ecx!!! + and eax, eax + jz .err - mov edi, eax - mov edx, [lin_addr] + mov edi, eax + mov edx, [lin_addr] @@: - stdcall map_page,edx,edi,dword [KERNEL_ALLOC_FLAG] - add edx, 0x1000 - add edi, 0x1000 - dec ecx - jnz @B + stdcall map_page,edx,edi,dword [KERNEL_ALLOC_FLAG] + add edx, 0x1000 + add edi, 0x1000 + dec ecx + jnz @B .next: - mov ecx, [pages_count] - and ecx, 7 - jz .end + mov ecx, [pages_count] + and ecx, 7 + jz .end @@: - push ecx - call alloc_page - pop ecx - test eax, eax - jz .err + push ecx + call alloc_page + pop ecx + test eax, eax + jz .err - stdcall map_page,edx,eax,dword PG_SW - add edx, 0x1000 - dec ecx - jnz @B + stdcall map_page,edx,eax,dword PG_SW + add edx, 0x1000 + dec ecx + jnz @B .end: - mov eax, [lin_addr] - pop edi - pop ebx - ret + mov eax, [lin_addr] + pop edi + pop ebx + ret .err: - xor eax, eax - pop edi - pop ebx - ret + xor eax, eax + pop edi + pop ebx + ret endp align 4 proc kernel_free stdcall, base:dword - push ebx esi + push ebx esi - mov ebx, heap_mutex - call wait_mutex ;ebx + mov ebx, heap_mutex + call wait_mutex ;ebx - mov eax, [base] - mov esi, [mem_used.fd] + mov eax, [base] + mov esi, [mem_used.fd] @@: - cmp esi, mem_used.fd-MEM_LIST_OFFSET - je .fail + cmp esi, mem_used.fd-MEM_LIST_OFFSET + je .fail - cmp [esi+block_base], eax - je .found - mov esi, [esi+list_fd] - jmp @b + cmp [esi+block_base], eax + je .found + mov esi, [esi+list_fd] + jmp @b .found: - cmp [esi+block_flags], USED_BLOCK - jne .fail + cmp [esi+block_flags], USED_BLOCK + jne .fail - and [heap_mutex], 0 + and [heap_mutex], 0 - push ecx - mov ecx, [esi+block_size]; - shr ecx, 12 - call release_pages ;eax, ecx - pop ecx - stdcall free_kernel_space, [base] - pop esi ebx - ret + push ecx + mov ecx, [esi+block_size]; + shr ecx, 12 + call release_pages ;eax, ecx + pop ecx + stdcall free_kernel_space, [base] + pop esi ebx + ret .fail: - xor eax, eax - mov [heap_mutex], eax - pop esi ebx - ret + xor eax, eax + mov [heap_mutex], eax + pop esi ebx + ret endp restore block_next @@ -656,151 +656,151 @@ HEAP_TOP equ 0x5FC00000 align 4 proc init_heap - mov ebx,[current_slot] - mov eax, [ebx+APPDATA.heap_top] - test eax, eax - jz @F - sub eax,[ebx+APPDATA.heap_base] - sub eax, 4096 - ret + mov ebx,[current_slot] + mov eax, [ebx+APPDATA.heap_top] + test eax, eax + jz @F + sub eax,[ebx+APPDATA.heap_base] + sub eax, 4096 + ret @@: - mov esi, [ebx+APPDATA.mem_size] - add esi, 4095 - and esi, not 4095 - mov [ebx+APPDATA.mem_size], esi - mov eax, HEAP_TOP - mov [ebx+APPDATA.heap_base], esi - mov [ebx+APPDATA.heap_top], eax + mov esi, [ebx+APPDATA.mem_size] + add esi, 4095 + and esi, not 4095 + mov [ebx+APPDATA.mem_size], esi + mov eax, HEAP_TOP + mov [ebx+APPDATA.heap_base], esi + mov [ebx+APPDATA.heap_top], eax - sub eax, esi - shr esi, 10 - mov ecx, eax - sub eax, 4096 - or ecx, FREE_BLOCK - mov [page_tabs+esi], ecx - ret + sub eax, esi + shr esi, 10 + mov ecx, eax + sub eax, 4096 + or ecx, FREE_BLOCK + mov [page_tabs+esi], ecx + ret endp align 4 proc user_alloc stdcall, alloc_size:dword - push ebx - push esi - push edi + push ebx + push esi + push edi - mov ecx, [alloc_size] - add ecx, (4095+4096) - and ecx, not 4095 + mov ecx, [alloc_size] + add ecx, (4095+4096) + and ecx, not 4095 - mov ebx, [current_slot] - mov esi, dword [ebx+APPDATA.heap_base] ; heap_base - mov edi, dword [ebx+APPDATA.heap_top] ; heap_top + mov ebx, [current_slot] + mov esi, dword [ebx+APPDATA.heap_base] ; heap_base + mov edi, dword [ebx+APPDATA.heap_top] ; heap_top l_0: - cmp esi, edi - jae m_exit + cmp esi, edi + jae m_exit - mov ebx, esi - shr ebx, 12 - mov eax, [page_tabs+ebx*4] - test al, FREE_BLOCK - jz test_used - and eax, 0xFFFFF000 - cmp eax, ecx ;alloc_size - jb m_next - jz @f + mov ebx, esi + shr ebx, 12 + mov eax, [page_tabs+ebx*4] + test al, FREE_BLOCK + jz test_used + and eax, 0xFFFFF000 + cmp eax, ecx ;alloc_size + jb m_next + jz @f - lea edx, [esi+ecx] - sub eax, ecx - or al, FREE_BLOCK - shr edx, 12 - mov [page_tabs+edx*4], eax + lea edx, [esi+ecx] + sub eax, ecx + or al, FREE_BLOCK + shr edx, 12 + mov [page_tabs+edx*4], eax @@: - or ecx, USED_BLOCK - mov [page_tabs+ebx*4], ecx - shr ecx, 12 - inc ebx - dec ecx - jz .no + or ecx, USED_BLOCK + mov [page_tabs+ebx*4], ecx + shr ecx, 12 + inc ebx + dec ecx + jz .no @@: - mov dword [page_tabs+ebx*4], 2 - inc ebx - dec ecx - jnz @B + mov dword [page_tabs+ebx*4], 2 + inc ebx + dec ecx + jnz @B .no: - mov edx, [current_slot] - mov ebx, [alloc_size] - add ebx, 0xFFF - and ebx, not 0xFFF - add ebx, [edx+APPDATA.mem_size] - call update_mem_size + mov edx, [current_slot] + mov ebx, [alloc_size] + add ebx, 0xFFF + and ebx, not 0xFFF + add ebx, [edx+APPDATA.mem_size] + call update_mem_size - lea eax, [esi+4096] + lea eax, [esi+4096] - pop edi - pop esi - pop ebx - ret + pop edi + pop esi + pop ebx + ret test_used: - test al, USED_BLOCK - jz m_exit + test al, USED_BLOCK + jz m_exit - and eax, 0xFFFFF000 + and eax, 0xFFFFF000 m_next: - add esi, eax - jmp l_0 + add esi, eax + jmp l_0 m_exit: - xor eax, eax - pop edi - pop esi - pop ebx - ret + xor eax, eax + pop edi + pop esi + pop ebx + ret endp align 4 proc user_alloc_at stdcall, address:dword, alloc_size:dword - push ebx - push esi - push edi + push ebx + push esi + push edi - mov ebx, [current_slot] - mov edx, [address] - and edx, not 0xFFF - mov [address], edx - sub edx, 0x1000 - jb .error - mov esi, [ebx+APPDATA.heap_base] - mov edi, [ebx+APPDATA.heap_top] - cmp edx, esi - jb .error + mov ebx, [current_slot] + mov edx, [address] + and edx, not 0xFFF + mov [address], edx + sub edx, 0x1000 + jb .error + mov esi, [ebx+APPDATA.heap_base] + mov edi, [ebx+APPDATA.heap_top] + cmp edx, esi + jb .error .scan: - cmp esi, edi - jae .error - mov ebx, esi - shr ebx, 12 - mov eax, [page_tabs+ebx*4] - mov ecx, eax - and ecx, 0xFFFFF000 - add ecx, esi - cmp edx, ecx - jb .found - mov esi, ecx - jmp .scan + cmp esi, edi + jae .error + mov ebx, esi + shr ebx, 12 + mov eax, [page_tabs+ebx*4] + mov ecx, eax + and ecx, 0xFFFFF000 + add ecx, esi + cmp edx, ecx + jb .found + mov esi, ecx + jmp .scan .error: - xor eax, eax - pop edi - pop esi - pop ebx - ret + xor eax, eax + pop edi + pop esi + pop ebx + ret .found: - test al, FREE_BLOCK - jz .error - mov eax, ecx - sub eax, edx - sub eax, 0x1000 - cmp eax, [alloc_size] - jb .error + test al, FREE_BLOCK + jz .error + mov eax, ecx + sub eax, edx + sub eax, 0x1000 + cmp eax, [alloc_size] + jb .error ; Here we have 1 big free block which includes requested area. ; In general, 3 other blocks must be created instead: @@ -808,429 +808,429 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword ; busy at [edx, edx+0x1000+ALIGN_UP(alloc_size,0x1000)); ; free at [edx+0x1000+ALIGN_UP(alloc_size,0x1000), ecx) ; First or third block (or both) may be absent. - mov eax, edx - sub eax, esi - jz .nofirst - or al, FREE_BLOCK - mov [page_tabs+ebx*4], eax + mov eax, edx + sub eax, esi + jz .nofirst + or al, FREE_BLOCK + mov [page_tabs+ebx*4], eax .nofirst: - mov eax, [alloc_size] - add eax, 0x1FFF - and eax, not 0xFFF - mov ebx, edx - add edx, eax - shr ebx, 12 - or al, USED_BLOCK - mov [page_tabs+ebx*4], eax - shr eax, 12 - dec eax - jz .second_nofill - inc ebx + mov eax, [alloc_size] + add eax, 0x1FFF + and eax, not 0xFFF + mov ebx, edx + add edx, eax + shr ebx, 12 + or al, USED_BLOCK + mov [page_tabs+ebx*4], eax + shr eax, 12 + dec eax + jz .second_nofill + inc ebx .fill: - mov dword [page_tabs+ebx*4], 2 - inc ebx - dec eax - jnz .fill + mov dword [page_tabs+ebx*4], 2 + inc ebx + dec eax + jnz .fill .second_nofill: - sub ecx, edx - jz .nothird - or cl, FREE_BLOCK - mov [page_tabs+ebx*4], ecx + sub ecx, edx + jz .nothird + or cl, FREE_BLOCK + mov [page_tabs+ebx*4], ecx .nothird: - mov edx, [current_slot] - mov ebx, [alloc_size] - add ebx, 0xFFF - and ebx, not 0xFFF - add ebx, [edx+APPDATA.mem_size] - call update_mem_size + mov edx, [current_slot] + mov ebx, [alloc_size] + add ebx, 0xFFF + and ebx, not 0xFFF + add ebx, [edx+APPDATA.mem_size] + call update_mem_size - mov eax, [address] + mov eax, [address] - pop edi - pop esi - pop ebx - ret + pop edi + pop esi + pop ebx + ret endp align 4 proc user_free stdcall, base:dword - push esi + push esi - mov esi, [base] - test esi, esi - jz .exit + mov esi, [base] + test esi, esi + jz .exit - push ebx + push ebx - xor ebx, ebx - shr esi, 12 - mov eax, [page_tabs+(esi-1)*4] - test al, USED_BLOCK - jz .cantfree - test al, DONT_FREE_BLOCK - jnz .cantfree + xor ebx, ebx + shr esi, 12 + mov eax, [page_tabs+(esi-1)*4] + test al, USED_BLOCK + jz .cantfree + test al, DONT_FREE_BLOCK + jnz .cantfree - and eax, not 4095 - mov ecx, eax - or al, FREE_BLOCK - mov [page_tabs+(esi-1)*4], eax - sub ecx, 4096 - mov ebx, ecx - shr ecx, 12 - jz .released + and eax, not 4095 + mov ecx, eax + or al, FREE_BLOCK + mov [page_tabs+(esi-1)*4], eax + sub ecx, 4096 + mov ebx, ecx + shr ecx, 12 + jz .released .release: - xor eax, eax - xchg eax, [page_tabs+esi*4] - test al, 1 - jz @F - test eax, PG_SHARED - jnz @F - call free_page - mov eax, esi - shl eax, 12 - invlpg [eax] + xor eax, eax + xchg eax, [page_tabs+esi*4] + test al, 1 + jz @F + test eax, PG_SHARED + jnz @F + call free_page + mov eax, esi + shl eax, 12 + invlpg [eax] @@: - inc esi - dec ecx - jnz .release + inc esi + dec ecx + jnz .release .released: - push edi + push edi - mov edx, [current_slot] - mov esi, dword [edx+APPDATA.heap_base] - mov edi, dword [edx+APPDATA.heap_top] - sub ebx, [edx+APPDATA.mem_size] - neg ebx - call update_mem_size - call user_normalize - pop edi - pop ebx - pop esi - ret + mov edx, [current_slot] + mov esi, dword [edx+APPDATA.heap_base] + mov edi, dword [edx+APPDATA.heap_top] + sub ebx, [edx+APPDATA.mem_size] + neg ebx + call update_mem_size + call user_normalize + pop edi + pop ebx + pop esi + ret .exit: - xor eax, eax - inc eax - pop esi - ret + xor eax, eax + inc eax + pop esi + ret .cantfree: - xor eax, eax - pop ebx - pop esi - ret + xor eax, eax + pop ebx + pop esi + ret endp user_normalize: ; in: esi=heap_base, edi=heap_top ; out: eax=0 <=> OK ; destroys: ebx,edx,esi,edi - shr esi, 12 - shr edi, 12 + shr esi, 12 + shr edi, 12 @@: - mov eax, [page_tabs+esi*4] - test al, USED_BLOCK - jz .test_free - shr eax, 12 - add esi, eax - jmp @B + mov eax, [page_tabs+esi*4] + test al, USED_BLOCK + jz .test_free + shr eax, 12 + add esi, eax + jmp @B .test_free: - test al, FREE_BLOCK - jz .err - mov edx, eax - shr edx, 12 - add edx, esi - cmp edx, edi - jae .exit + test al, FREE_BLOCK + jz .err + mov edx, eax + shr edx, 12 + add edx, esi + cmp edx, edi + jae .exit - mov ebx, [page_tabs+edx*4] - test bl, USED_BLOCK - jz .next_free + mov ebx, [page_tabs+edx*4] + test bl, USED_BLOCK + jz .next_free - shr ebx, 12 - add edx, ebx - mov esi, edx - jmp @B + shr ebx, 12 + add edx, ebx + mov esi, edx + jmp @B .next_free: - test bl, FREE_BLOCK - jz .err - and dword [page_tabs+edx*4], 0 - add eax, ebx - and eax, not 4095 - or eax, FREE_BLOCK - mov [page_tabs+esi*4], eax - jmp @B + test bl, FREE_BLOCK + jz .err + and dword [page_tabs+edx*4], 0 + add eax, ebx + and eax, not 4095 + or eax, FREE_BLOCK + mov [page_tabs+esi*4], eax + jmp @B .exit: - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret .err: - xor eax, eax - ret + xor eax, eax + ret user_realloc: ; in: eax = pointer, ebx = new size ; out: eax = new pointer or NULL - test eax, eax - jnz @f + test eax, eax + jnz @f ; realloc(NULL,sz) - same as malloc(sz) - push ebx - call user_alloc - ret + push ebx + call user_alloc + ret @@: - push ecx edx - lea ecx, [eax - 0x1000] - shr ecx, 12 - mov edx, [page_tabs+ecx*4] - test dl, USED_BLOCK - jnz @f + push ecx edx + lea ecx, [eax - 0x1000] + shr ecx, 12 + mov edx, [page_tabs+ecx*4] + test dl, USED_BLOCK + jnz @f ; attempt to realloc invalid pointer .ret0: - pop edx ecx - xor eax, eax - ret + pop edx ecx + xor eax, eax + ret @@: - test dl, DONT_FREE_BLOCK - jnz .ret0 - add ebx, 0x1FFF - shr edx, 12 - shr ebx, 12 + test dl, DONT_FREE_BLOCK + jnz .ret0 + add ebx, 0x1FFF + shr edx, 12 + shr ebx, 12 ; edx = allocated size, ebx = new size - add edx, ecx - add ebx, ecx - cmp edx, ebx - jb .realloc_add + add edx, ecx + add ebx, ecx + cmp edx, ebx + jb .realloc_add ; release part of allocated memory .loop: - cmp edx, ebx - jz .release_done - dec edx - xor eax, eax - xchg eax, [page_tabs+edx*4] - test al, 1 - jz .loop - call free_page - mov eax, edx - shl eax, 12 - invlpg [eax] - jmp .loop + cmp edx, ebx + jz .release_done + dec edx + xor eax, eax + xchg eax, [page_tabs+edx*4] + test al, 1 + jz .loop + call free_page + mov eax, edx + shl eax, 12 + invlpg [eax] + jmp .loop .release_done: - sub ebx, ecx - cmp ebx, 1 - jnz .nofreeall - mov eax, [page_tabs+ecx*4] - and eax, not 0xFFF - mov edx, [current_slot] - mov ebx, [APPDATA.mem_size+edx] - sub ebx, eax - add ebx, 0x1000 - or al, FREE_BLOCK - mov [page_tabs+ecx*4], eax - push esi edi - mov esi, [APPDATA.heap_base+edx] - mov edi, [APPDATA.heap_top+edx] - call update_mem_size - call user_normalize - pop edi esi - jmp .ret0 ; all freed + sub ebx, ecx + cmp ebx, 1 + jnz .nofreeall + mov eax, [page_tabs+ecx*4] + and eax, not 0xFFF + mov edx, [current_slot] + mov ebx, [APPDATA.mem_size+edx] + sub ebx, eax + add ebx, 0x1000 + or al, FREE_BLOCK + mov [page_tabs+ecx*4], eax + push esi edi + mov esi, [APPDATA.heap_base+edx] + mov edi, [APPDATA.heap_top+edx] + call update_mem_size + call user_normalize + pop edi esi + jmp .ret0 ; all freed .nofreeall: - sub edx, ecx - shl ebx, 12 - or ebx, USED_BLOCK - xchg [page_tabs+ecx*4], ebx - shr ebx, 12 - sub ebx, edx - push ebx ecx edx - mov edx, [current_slot] - shl ebx, 12 - sub ebx, [APPDATA.mem_size+edx] - neg ebx - call update_mem_size - pop edx ecx ebx - lea eax, [ecx+1] - shl eax, 12 - push eax - add ecx, edx - lea edx, [ecx+ebx] - shl ebx, 12 - jz .ret - push esi - mov esi, [current_slot] - mov esi, [APPDATA.heap_top+esi] - shr esi, 12 + sub edx, ecx + shl ebx, 12 + or ebx, USED_BLOCK + xchg [page_tabs+ecx*4], ebx + shr ebx, 12 + sub ebx, edx + push ebx ecx edx + mov edx, [current_slot] + shl ebx, 12 + sub ebx, [APPDATA.mem_size+edx] + neg ebx + call update_mem_size + pop edx ecx ebx + lea eax, [ecx+1] + shl eax, 12 + push eax + add ecx, edx + lea edx, [ecx+ebx] + shl ebx, 12 + jz .ret + push esi + mov esi, [current_slot] + mov esi, [APPDATA.heap_top+esi] + shr esi, 12 @@: - cmp edx, esi - jae .merge_done - mov eax, [page_tabs+edx*4] - test al, USED_BLOCK - jnz .merge_done - and dword [page_tabs+edx*4], 0 - shr eax, 12 - add edx, eax - shl eax, 12 - add ebx, eax - jmp @b + cmp edx, esi + jae .merge_done + mov eax, [page_tabs+edx*4] + test al, USED_BLOCK + jnz .merge_done + and dword [page_tabs+edx*4], 0 + shr eax, 12 + add edx, eax + shl eax, 12 + add ebx, eax + jmp @b .merge_done: - pop esi - or ebx, FREE_BLOCK - mov [page_tabs+ecx*4], ebx + pop esi + or ebx, FREE_BLOCK + mov [page_tabs+ecx*4], ebx .ret: - pop eax edx ecx - ret + pop eax edx ecx + ret .realloc_add: ; get some additional memory - mov eax, [current_slot] - mov eax, [APPDATA.heap_top+eax] - shr eax, 12 - cmp edx, eax - jae .cant_inplace - mov eax, [page_tabs+edx*4] - test al, FREE_BLOCK - jz .cant_inplace - shr eax, 12 - add eax, edx - sub eax, ebx - jb .cant_inplace - jz @f - shl eax, 12 - or al, FREE_BLOCK - mov [page_tabs+ebx*4], eax + mov eax, [current_slot] + mov eax, [APPDATA.heap_top+eax] + shr eax, 12 + cmp edx, eax + jae .cant_inplace + mov eax, [page_tabs+edx*4] + test al, FREE_BLOCK + jz .cant_inplace + shr eax, 12 + add eax, edx + sub eax, ebx + jb .cant_inplace + jz @f + shl eax, 12 + or al, FREE_BLOCK + mov [page_tabs+ebx*4], eax @@: - mov eax, ebx - sub eax, ecx - shl eax, 12 - or al, USED_BLOCK - mov [page_tabs+ecx*4], eax - lea eax, [ecx+1] - shl eax, 12 - push eax - push edi - lea edi, [page_tabs+edx*4] - mov eax, 2 - sub ebx, edx - mov ecx, ebx - cld - rep stosd - pop edi - mov edx, [current_slot] - shl ebx, 12 - add ebx, [APPDATA.mem_size+edx] - call update_mem_size - pop eax edx ecx - ret + mov eax, ebx + sub eax, ecx + shl eax, 12 + or al, USED_BLOCK + mov [page_tabs+ecx*4], eax + lea eax, [ecx+1] + shl eax, 12 + push eax + push edi + lea edi, [page_tabs+edx*4] + mov eax, 2 + sub ebx, edx + mov ecx, ebx + cld + rep stosd + pop edi + mov edx, [current_slot] + shl ebx, 12 + add ebx, [APPDATA.mem_size+edx] + call update_mem_size + pop eax edx ecx + ret .cant_inplace: - push esi edi - mov eax, [current_slot] - mov esi, [APPDATA.heap_base+eax] - mov edi, [APPDATA.heap_top+eax] - shr esi, 12 - shr edi, 12 - sub ebx, ecx + push esi edi + mov eax, [current_slot] + mov esi, [APPDATA.heap_base+eax] + mov edi, [APPDATA.heap_top+eax] + shr esi, 12 + shr edi, 12 + sub ebx, ecx .find_place: - cmp esi, edi - jae .place_not_found - mov eax, [page_tabs+esi*4] - test al, FREE_BLOCK - jz .next_place - shr eax, 12 - cmp eax, ebx - jae .place_found - add esi, eax - jmp .find_place + cmp esi, edi + jae .place_not_found + mov eax, [page_tabs+esi*4] + test al, FREE_BLOCK + jz .next_place + shr eax, 12 + cmp eax, ebx + jae .place_found + add esi, eax + jmp .find_place .next_place: - shr eax, 12 - add esi, eax - jmp .find_place + shr eax, 12 + add esi, eax + jmp .find_place .place_not_found: - pop edi esi - jmp .ret0 + pop edi esi + jmp .ret0 .place_found: - sub eax, ebx - jz @f - push esi - add esi, ebx - shl eax, 12 - or al, FREE_BLOCK - mov [page_tabs+esi*4], eax - pop esi + sub eax, ebx + jz @f + push esi + add esi, ebx + shl eax, 12 + or al, FREE_BLOCK + mov [page_tabs+esi*4], eax + pop esi @@: - mov eax, ebx - shl eax, 12 - or al, USED_BLOCK - mov [page_tabs+esi*4], eax - inc esi - mov eax, esi - shl eax, 12 - push eax - mov eax, [page_tabs+ecx*4] - and eax, not 0xFFF - or al, FREE_BLOCK - sub edx, ecx - mov [page_tabs+ecx*4], eax - inc ecx - dec ebx - dec edx - jz .no + mov eax, ebx + shl eax, 12 + or al, USED_BLOCK + mov [page_tabs+esi*4], eax + inc esi + mov eax, esi + shl eax, 12 + push eax + mov eax, [page_tabs+ecx*4] + and eax, not 0xFFF + or al, FREE_BLOCK + sub edx, ecx + mov [page_tabs+ecx*4], eax + inc ecx + dec ebx + dec edx + jz .no @@: - xor eax, eax - xchg eax, [page_tabs+ecx*4] - mov [page_tabs+esi*4], eax - mov eax, ecx - shl eax, 12 - invlpg [eax] - inc esi - inc ecx - dec ebx - dec edx - jnz @b + xor eax, eax + xchg eax, [page_tabs+ecx*4] + mov [page_tabs+esi*4], eax + mov eax, ecx + shl eax, 12 + invlpg [eax] + inc esi + inc ecx + dec ebx + dec edx + jnz @b .no: - push ebx - mov edx, [current_slot] - shl ebx, 12 - add ebx, [APPDATA.mem_size+edx] - call update_mem_size - pop ebx + push ebx + mov edx, [current_slot] + shl ebx, 12 + add ebx, [APPDATA.mem_size+edx] + call update_mem_size + pop ebx @@: - mov dword [page_tabs+esi*4], 2 - inc esi - dec ebx - jnz @b - pop eax edi esi edx ecx - ret + mov dword [page_tabs+esi*4], 2 + inc esi + dec ebx + jnz @b + pop eax edi esi edx ecx + ret if 0 align 4 proc alloc_dll - pushf - cli - bsf eax, [dll_map] - jnz .find - popf - xor eax, eax - ret + pushf + cli + bsf eax, [dll_map] + jnz .find + popf + xor eax, eax + ret .find: - btr [dll_map], eax - popf - shl eax, 5 - add eax, dll_tab - ret + btr [dll_map], eax + popf + shl eax, 5 + add eax, dll_tab + ret endp align 4 proc alloc_service - pushf - cli - bsf eax, [srv_map] - jnz .find - popf - xor eax, eax - ret + pushf + cli + bsf eax, [srv_map] + jnz .find + popf + xor eax, eax + ret .find: - btr [srv_map], eax - popf - shl eax,0x02 - lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36 - ret + btr [srv_map], eax + popf + shl eax,0x02 + lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36 + ret endp end if @@ -1245,299 +1245,299 @@ end if align 4 destroy_smap: - pushfd - cli + pushfd + cli - push esi - push edi + push esi + push edi - mov edi, eax - mov esi, [eax+SMAP.parent] - test esi, esi - jz .done + mov edi, eax + mov esi, [eax+SMAP.parent] + test esi, esi + jz .done - lock dec [esi+SMEM.refcount] - jnz .done + lock dec [esi+SMEM.refcount] + jnz .done - mov ecx, [esi+SMEM.bk] - mov edx, [esi+SMEM.fd] + mov ecx, [esi+SMEM.bk] + mov edx, [esi+SMEM.fd] - mov [ecx+SMEM.fd], edx - mov [edx+SMEM.bk], ecx + mov [ecx+SMEM.fd], edx + mov [edx+SMEM.bk], ecx - stdcall kernel_free, [esi+SMEM.base] - mov eax, esi - call free + stdcall kernel_free, [esi+SMEM.base] + mov eax, esi + call free .done: - mov eax, edi - call destroy_kernel_object + mov eax, edi + call destroy_kernel_object - pop edi - pop esi - popfd + pop edi + pop esi + popfd - ret + ret -E_NOTFOUND equ 5 -E_ACCESS equ 10 -E_NOMEM equ 30 -E_PARAM equ 33 +E_NOTFOUND equ 5 +E_ACCESS equ 10 +E_NOMEM equ 30 +E_PARAM equ 33 -SHM_READ equ 0 -SHM_WRITE equ 1 +SHM_READ equ 0 +SHM_WRITE equ 1 SHM_ACCESS_MASK equ 3 -SHM_OPEN equ (0 shl 2) +SHM_OPEN equ (0 shl 2) SHM_OPEN_ALWAYS equ (1 shl 2) -SHM_CREATE equ (2 shl 2) +SHM_CREATE equ (2 shl 2) -SHM_OPEN_MASK equ (3 shl 2) +SHM_OPEN_MASK equ (3 shl 2) align 4 proc shmem_open stdcall name:dword, size:dword, access:dword - locals - action dd ? - owner_access dd ? - mapped dd ? - endl + locals + action dd ? + owner_access dd ? + mapped dd ? + endl - push ebx - push esi - push edi + push ebx + push esi + push edi - mov [mapped], 0 - mov [owner_access], 0 + mov [mapped], 0 + mov [owner_access], 0 - pushfd ;mutex required - cli + pushfd ;mutex required + cli - mov eax, [access] - and eax, SHM_OPEN_MASK - mov [action], eax + mov eax, [access] + and eax, SHM_OPEN_MASK + mov [action], eax - mov ebx, [name] - test ebx, ebx - mov edx, E_PARAM - jz .fail + mov ebx, [name] + test ebx, ebx + mov edx, E_PARAM + jz .fail - mov esi, [shmem_list.fd] + mov esi, [shmem_list.fd] align 4 @@: - cmp esi, shmem_list - je .not_found + cmp esi, shmem_list + je .not_found - lea edx, [esi+SMEM.name] ; link , base, size - stdcall strncmp, edx, ebx, 32 - test eax, eax - je .found + lea edx, [esi+SMEM.name] ; link , base, size + stdcall strncmp, edx, ebx, 32 + test eax, eax + je .found - mov esi, [esi+SMEM.fd] - jmp @B + mov esi, [esi+SMEM.fd] + jmp @B .not_found: - mov eax, [action] + mov eax, [action] - cmp eax, SHM_OPEN - mov edx, E_NOTFOUND - je .fail + cmp eax, SHM_OPEN + mov edx, E_NOTFOUND + je .fail - cmp eax, SHM_CREATE - mov edx, E_PARAM - je .create_shm + cmp eax, SHM_CREATE + mov edx, E_PARAM + je .create_shm - cmp eax, SHM_OPEN_ALWAYS - jne .fail + cmp eax, SHM_OPEN_ALWAYS + jne .fail .create_shm: - mov ecx, [size] - test ecx, ecx - jz .fail + mov ecx, [size] + test ecx, ecx + jz .fail - add ecx, 4095 - and ecx, -4096 - mov [size], ecx + add ecx, 4095 + and ecx, -4096 + mov [size], ecx - mov eax, SMEM.sizeof - call malloc - test eax, eax - mov esi, eax - mov edx, E_NOMEM - jz .fail + mov eax, SMEM.sizeof + call malloc + test eax, eax + mov esi, eax + mov edx, E_NOMEM + jz .fail - stdcall kernel_alloc, [size] - test eax, eax - mov [mapped], eax - mov edx, E_NOMEM - jz .cleanup + stdcall kernel_alloc, [size] + test eax, eax + mov [mapped], eax + mov edx, E_NOMEM + jz .cleanup - mov ecx, [size] - mov edx, [access] - and edx, SHM_ACCESS_MASK + mov ecx, [size] + mov edx, [access] + and edx, SHM_ACCESS_MASK - mov [esi+SMEM.base], eax - mov [esi+SMEM.size], ecx - mov [esi+SMEM.access], edx - mov [esi+SMEM.refcount], 0 - mov [esi+SMEM.name+28], 0 + mov [esi+SMEM.base], eax + mov [esi+SMEM.size], ecx + mov [esi+SMEM.access], edx + mov [esi+SMEM.refcount], 0 + mov [esi+SMEM.name+28], 0 - lea eax, [esi+SMEM.name] - stdcall strncpy, eax, [name], 31 + lea eax, [esi+SMEM.name] + stdcall strncpy, eax, [name], 31 - mov eax, [shmem_list.fd] - mov [esi+SMEM.bk], shmem_list - mov [esi+SMEM.fd], eax + mov eax, [shmem_list.fd] + mov [esi+SMEM.bk], shmem_list + mov [esi+SMEM.fd], eax - mov [eax+SMEM.bk], esi - mov [shmem_list.fd], esi + mov [eax+SMEM.bk], esi + mov [shmem_list.fd], esi - mov [action], SHM_OPEN - mov [owner_access], SHM_WRITE + mov [action], SHM_OPEN + mov [owner_access], SHM_WRITE .found: - mov eax, [action] + mov eax, [action] - cmp eax, SHM_CREATE - mov edx, E_ACCESS - je .exit + cmp eax, SHM_CREATE + mov edx, E_ACCESS + je .exit - cmp eax, SHM_OPEN - mov edx, E_PARAM - je .create_map + cmp eax, SHM_OPEN + mov edx, E_PARAM + je .create_map - cmp eax, SHM_OPEN_ALWAYS - jne .fail + cmp eax, SHM_OPEN_ALWAYS + jne .fail .create_map: - mov eax, [access] - and eax, SHM_ACCESS_MASK - cmp eax, [esi+SMEM.access] - mov [access], eax - mov edx, E_ACCESS - ja .fail + mov eax, [access] + and eax, SHM_ACCESS_MASK + cmp eax, [esi+SMEM.access] + mov [access], eax + mov edx, E_ACCESS + ja .fail - mov ebx, [CURRENT_TASK] - shl ebx, 5 - mov ebx, [CURRENT_TASK+ebx+4] - mov eax, SMAP.sizeof + mov ebx, [CURRENT_TASK] + shl ebx, 5 + mov ebx, [CURRENT_TASK+ebx+4] + mov eax, SMAP.sizeof - call create_kernel_object - test eax, eax - mov edi, eax - mov edx, E_NOMEM - jz .fail + call create_kernel_object + test eax, eax + mov edi, eax + mov edx, E_NOMEM + jz .fail - inc [esi+SMEM.refcount] + inc [esi+SMEM.refcount] - mov [edi+SMAP.magic], 'SMAP' - mov [edi+SMAP.destroy], destroy_smap - mov [edi+SMAP.parent], esi - mov [edi+SMAP.base], 0 + mov [edi+SMAP.magic], 'SMAP' + mov [edi+SMAP.destroy], destroy_smap + mov [edi+SMAP.parent], esi + mov [edi+SMAP.base], 0 - stdcall user_alloc, [esi+SMEM.size] - test eax, eax - mov [mapped], eax - mov edx, E_NOMEM - jz .cleanup2 + stdcall user_alloc, [esi+SMEM.size] + test eax, eax + mov [mapped], eax + mov edx, E_NOMEM + jz .cleanup2 - mov [edi+SMAP.base], eax + mov [edi+SMAP.base], eax - mov ecx, [esi+SMEM.size] - mov [size], ecx + mov ecx, [esi+SMEM.size] + mov [size], ecx - shr ecx, 12 - shr eax, 10 + shr ecx, 12 + shr eax, 10 - mov esi, [esi+SMEM.base] - shr esi, 10 - lea edi, [page_tabs+eax] - add esi, page_tabs + mov esi, [esi+SMEM.base] + shr esi, 10 + lea edi, [page_tabs+eax] + add esi, page_tabs - mov edx, [access] - or edx, [owner_access] - shl edx, 1 - or edx, PG_USER+PG_SHARED + mov edx, [access] + or edx, [owner_access] + shl edx, 1 + or edx, PG_USER+PG_SHARED @@: - lodsd - and eax, 0xFFFFF000 - or eax, edx - stosd - loop @B + lodsd + and eax, 0xFFFFF000 + or eax, edx + stosd + loop @B - xor edx, edx + xor edx, edx - cmp [owner_access], 0 - jne .fail + cmp [owner_access], 0 + jne .fail .exit: - mov edx, [size] + mov edx, [size] .fail: - mov eax, [mapped] + mov eax, [mapped] - popfd - pop edi - pop esi - pop ebx - ret + popfd + pop edi + pop esi + pop ebx + ret .cleanup: - mov [size], edx - mov eax, esi - call free - jmp .exit + mov [size], edx + mov eax, esi + call free + jmp .exit .cleanup2: - mov [size], edx - mov eax, edi - call destroy_smap - jmp .exit + mov [size], edx + mov eax, edi + call destroy_smap + jmp .exit endp align 4 proc shmem_close stdcall, name:dword - mov eax, [name] - test eax, eax - jz .fail + mov eax, [name] + test eax, eax + jz .fail - push esi - push edi - pushfd - cli + push esi + push edi + pushfd + cli - mov esi, [current_slot] - add esi, APP_OBJ_OFFSET + mov esi, [current_slot] + add esi, APP_OBJ_OFFSET .next: - mov eax, [esi+APPOBJ.fd] - test eax, eax - jz @F + mov eax, [esi+APPOBJ.fd] + test eax, eax + jz @F - cmp eax, esi - mov esi, eax - je @F + cmp eax, esi + mov esi, eax + je @F - cmp [eax+SMAP.magic], 'SMAP' - jne .next + cmp [eax+SMAP.magic], 'SMAP' + jne .next - mov edi, [eax+SMAP.parent] - test edi, edi - jz .next + mov edi, [eax+SMAP.parent] + test edi, edi + jz .next - lea edi, [edi+SMEM.name] - stdcall strncmp, [name], edi, 32 - test eax, eax - jne .next + lea edi, [edi+SMEM.name] + stdcall strncmp, [name], edi, 32 + test eax, eax + jne .next - stdcall user_free, [esi+SMAP.base] + stdcall user_free, [esi+SMAP.base] - mov eax,esi - call [esi+APPOBJ.destroy] + mov eax,esi + call [esi+APPOBJ.destroy] @@: - popfd - pop edi - pop esi + popfd + pop edi + pop esi .fail: - ret + ret endp -diff16 "heap code end ",0,$ -diff16 "heap code size",init_kernel_heap,$ +;diff16 "heap code end ",0,$ +diff10 "heap code size",init_kernel_heap,$ diff --git a/kernel/branches/Kolibri-A/trunk/core/memory.inc b/kernel/branches/Kolibri-A/trunk/core/memory.inc index dcff0a179b..4ad52e7f97 100644 --- a/kernel/branches/Kolibri-A/trunk/core/memory.inc +++ b/kernel/branches/Kolibri-A/trunk/core/memory.inc @@ -1441,5 +1441,5 @@ proc create_ring_buffer stdcall, size:dword, flags:dword .fail: ret endp -diff16 "memman code end",0,$ -diff16 "memman code sze",alloc_page,$ +;diff16 "memman code end",0,$ +diff10 "memman code sze",alloc_page,$ diff --git a/kernel/branches/Kolibri-A/trunk/data32.inc b/kernel/branches/Kolibri-A/trunk/data32.inc index 2a1f038c19..dca29a54fc 100644 --- a/kernel/branches/Kolibri-A/trunk/data32.inc +++ b/kernel/branches/Kolibri-A/trunk/data32.inc @@ -7,7 +7,7 @@ $Revision$ - + keymap: db '6',27 @@ -47,28 +47,26 @@ keymap_alt: db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - boot_memdetect db 'Determining amount of memory',0 - boot_fonts db 'Fonts loaded',0 - boot_tss db 'Setting TSSs',0 - boot_cpuid db 'Reading CPUIDs',0 - boot_devices db 'Detecting devices',0 +; boot_memdetect db 'Determining amount of memory',0 +; boot_fonts db 'Fonts loaded',0 +; boot_tss db 'Setting TSSs',0 +; boot_cpuid db 'Reading CPUIDs',0 +; boot_devices db 'Detecting devices',0 boot_timer db 'Setting timer',0 boot_irqs db 'Reprogramming IRQs',0 - boot_setmouse db 'Setting mouse',0 +; boot_setmouse db 'Setting mouse',0 boot_windefs db 'Setting window defaults',0 - boot_bgr db 'Calculating background',0 -; boot_resirqports db 'Reserving IRQs & ports',0 -; boot_setrports db 'Setting addresses for IRQs',0 - boot_setostask db 'Setting OS task',0 +; boot_bgr db 'Calculating background',0 +; boot_setostask db 'Setting OS task',0 boot_allirqs db 'Unmasking all IRQs',0 - boot_tsc db 'Reading TSC',0 +; boot_tsc db 'Reading TSC',0 boot_cpufreq db 'CPU frequency is ',' ',' MHz',0 - boot_failed db 'Failed to start first app',0 - boot_mtrr db 'Setting MTRR',0 - boot_uDMA_ok db 'Set user DMA OK',0 -if preboot_blogesc - boot_tasking db 'All set - press ESC to start',0 -end if +; boot_failed db 'Failed to start first app',0 +; boot_mtrr db 'Setting MTRR',0 +; boot_uDMA_ok db 'Set user DMA OK',0 +;if preboot_blogesc +; boot_tasking db 'All set - press ESC to start',0 +;end if ;new_process_loading db 'K : New Process - loading',13,10,0 ;new_process_running db 'K : New Process - done',13,10,0 @@ -90,7 +88,7 @@ szHwMouse db 'ATI2D',0 szPS2MDriver db 'PS2MOUSE',0 ;szCOM_MDriver db 'COM_MOUSE',0 szUSB db 'USB',0 -szAtiHW db '/rd/1/drivers/ati2d.drv',0 +;szAtiHW db '/rd/1/drivers/ati2d.drv',0 szSTART db 'START',0 szEXPORTS db 'EXPORTS',0 @@ -318,23 +316,23 @@ srv.bk rd 1 ;align 64 ;img_draw_core_fn rd 1 ; putimage variables & helpers ;img_draw_edge_fn rd 1 -;img_lfb_origin rd 1 -;img_buf_origin rd 1 +;img_lfb_origin rd 1 +;img_buf_origin rd 1 ;img_buf_line_size rd 1 -;img_palette rd 1 -;img_bitoffset rd 1 -;img_edgeoffset rd 1 +;img_palette rd 1 +;img_bitoffset rd 1 +;img_edgeoffset rd 1 ;img_bytes_per_pix rd 1 -;img_map_right rd 1 -;img_map_x rd 1 -;img_pix_x rd 1 ; real Xsize -;img_pix_y rd 1 ; real Ysize -;img_screen_x rd 1 -;img_screen_y rd 1 +;img_map_right rd 1 +;img_map_x rd 1 +;img_pix_x rd 1 ; real Xsize +;img_pix_y rd 1 ; real Ysize +;img_screen_x rd 1 +;img_screen_y rd 1 align 64 -;_WinMapWidth rd 1 -;_WinMapHeight rd 1 +;_WinMapWidth rd 1 +;_WinMapHeight rd 1 _WinMapAddress rd 1 _WinMapSize rd 1 diff --git a/kernel/branches/Kolibri-A/trunk/gui/font.inc b/kernel/branches/Kolibri-A/trunk/gui/font.inc index b6b6133cfc..79e9250525 100644 --- a/kernel/branches/Kolibri-A/trunk/gui/font.inc +++ b/kernel/branches/Kolibri-A/trunk/gui/font.inc @@ -9,7 +9,7 @@ $Revision$ ; // Alver 22.06.2008 // { align 4 -dtext_asciiz_esi: ; for skins title out +dtext_asciiz_esi: ; for skins title out push eax xor eax, eax inc eax @@ -17,118 +17,118 @@ dtext_asciiz_esi: ; for skins title out ; } \\ Alver \\ align 4 -dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) - ; ebx x & y - ; ecx style ( 0xX0000000 ) & color ( 0x00RRGGBB ) - ; X = ABnnb: - ; nn = font - ; A = 0 <=> output esi characters; otherwise output ASCIIZ string - ; B = 1 <=> fill background with color eax - ; edx start of text - ; edi 1 force +dtext: ; Text String Output (rw by Johnny_B[john@kolibrios.org]) + ; ebx x & y + ; ecx style ( 0xX0000000 ) & color ( 0x00RRGGBB ) + ; X = ABnnb: + ; nn = font + ; A = 0 <=> output esi characters; otherwise output ASCIIZ string + ; B = 1 <=> fill background with color eax + ; edx start of text + ; edi 1 force ; // Alver 22.06.2008 // { push eax - xor eax, eax + xor eax, eax .1: ; } \\ Alver \\ - pushad - call [_display.disable_mouse] + pushad + call [_display.disable_mouse] - movsx eax, bx ; eax=y - sar ebx, 16 ; ebx=x - xchg eax, ebx ; eax=x, ebx=y - cmp esi, 255 - jb .loop - mov esi, 255 + movsx eax, bx ; eax=y + sar ebx, 16 ; ebx=x + xchg eax, ebx ; eax=x, ebx=y + cmp esi, 255 + jb .loop + mov esi, 255 .loop: - test ecx, ecx - js .test_asciiz - dec esi - js .end - jmp @f + test ecx, ecx + js .test_asciiz + dec esi + js .end + jmp @f .test_asciiz: - cmp byte [edx], 0 - jz .end + cmp byte [edx], 0 + jz .end ; // Alver 22.06.2008 // { - cmp byte [esp+28], 1 ; was the entry point = dtext.1 ? - jne @f - dec esi - js .end + cmp byte [esp+28], 1 ; was the entry point = dtext.1 ? + jne @f + dec esi + js .end ; } \\ Alver \\ @@: - inc edx - pushad ; esp -= 64 ! - movzx edx, byte [edx-1] - test ecx, 0x10000000 - jnz .font2 - mov esi, 9 - lea ebp, [FONT_I+8*edx+edx] + inc edx + pushad ; esp -= 64 ! + movzx edx, byte [edx-1] + test ecx, 0x10000000 + jnz .font2 + mov esi, 9 + lea ebp, [FONT_I+8*edx+edx] .symloop1: - mov dl, byte [ebp] - or dl, 1 shl 6 + mov dl, byte [ebp] + or dl, 1 shl 6 .pixloop1: - shr dl, 1 - jz .pixloop1end - jnc .nopix - call [putpixel] - jmp .pixloop1cont + shr dl, 1 + jz .pixloop1end + jnc .nopix + call [putpixel] + jmp .pixloop1cont .nopix: - test ecx, 0x40000000 - jz .pixloop1cont - push ecx - mov ecx, [esp+4+20h+20h] ; original eax? - call [putpixel] - pop ecx + test ecx, 0x40000000 + jz .pixloop1cont + push ecx + mov ecx, [esp+4+20h+20h] ; original eax? + call [putpixel] + pop ecx .pixloop1cont: - inc eax - jmp .pixloop1 + inc eax + jmp .pixloop1 .pixloop1end: - sub eax, 6 - inc ebx - inc ebp - dec esi - jnz .symloop1 - popad - add eax, 6 - jmp .loop + sub eax, 6 + inc ebx + inc ebp + dec esi + jnz .symloop1 + popad + add eax, 6 + jmp .loop .font2: - add edx, edx - lea ebp, [FONT_II+4*edx+edx+1] - push 9 - movzx esi, byte [ebp-1] + add edx, edx + lea ebp, [FONT_II+4*edx+edx+1] + push 9 + movzx esi, byte [ebp-1] .symloop2: - mov dl, byte [ebp] - push esi + mov dl, byte [ebp] + push esi .pixloop2: - shr dl, 1 - jnc .nopix2 - call [putpixel] - jmp .pixloop2cont + shr dl, 1 + jnc .nopix2 + call [putpixel] + jmp .pixloop2cont .nopix2: - test ecx, 0x40000000 - jz .pixloop2cont - push ecx - mov ecx, [esp+12+20h+20h] - call [putpixel] - pop ecx + test ecx, 0x40000000 + jz .pixloop2cont + push ecx + mov ecx, [esp+12+20h+20h] + call [putpixel] + pop ecx .pixloop2cont: - inc eax - dec esi - jnz .pixloop2 - pop esi - sub eax, esi - inc ebx - inc ebp - dec dword [esp] - jnz .symloop2 - pop eax - add dword [esp+28], esi - popad - jmp .loop + inc eax + dec esi + jnz .pixloop2 + pop esi + sub eax, esi + inc ebx + inc ebp + dec dword [esp] + jnz .symloop2 + pop eax + add dword [esp+28], esi + popad + jmp .loop .end: - popad - pop eax ; << // Alver 22.06.2008 // << - ret -diff16 "font code end ",0,$ -diff16 "font code size",dtext,$ + popad + pop eax ; << // Alver 22.06.2008 // << + ret +;diff16 "font code end ",0,$ +diff10 "font code size",dtext,$ diff --git a/kernel/branches/Kolibri-A/trunk/gui/mouse.inc b/kernel/branches/Kolibri-A/trunk/gui/mouse.inc index c6aaa88fae..8da86d7080 100644 --- a/kernel/branches/Kolibri-A/trunk/gui/mouse.inc +++ b/kernel/branches/Kolibri-A/trunk/gui/mouse.inc @@ -381,7 +381,7 @@ mouse._.move_handler: ;//////////////////////////////////////////////////////// mov [mouse.active_sys_window.new_box.left], eax mov eax, [mouse.state.pos.y] sub eax, [mouse.active_sys_window.delta.y] - mov [mouse.active_sys_window.new_box.top], eax + mov [mouse.active_sys_window.new_box.top], eax mov eax, [mouse.active_sys_window.new_box.left] or eax, eax @@ -513,11 +513,11 @@ mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// ;< esi = process slot ;< edi = pointer to WDATA struct ;------------------------------------------------------------------------------ - mov esi, [Screen_Max_X] - inc esi - imul esi, [mouse.state.pos.y] - add esi, [_WinMapAddress] - add esi, [mouse.state.pos.x] + mov esi, [Screen_Max_X] + inc esi + imul esi, [mouse.state.pos.y] + add esi, [_WinMapAddress] + add esi, [mouse.state.pos.x] movzx esi, byte[esi] mov edi, esi shl edi, 5 @@ -700,5 +700,5 @@ mouse._.check_sys_window_actions: ;//////////////////////////////////////////// .exit: ret -diff16 "mouse code end ",0,$ +;diff16 "mouse code end ",0,$ diff10 "mouse code size",mouse_check_events,$ diff --git a/kernel/branches/Kolibri-A/trunk/gui/skincode.inc b/kernel/branches/Kolibri-A/trunk/gui/skincode.inc index 135ee57c26..26ed2e9c25 100644 --- a/kernel/branches/Kolibri-A/trunk/gui/skincode.inc +++ b/kernel/branches/Kolibri-A/trunk/gui/skincode.inc @@ -13,34 +13,34 @@ include "skindata.inc" ;skin_data = 0x00778000 read_skin_file: - stdcall load_file, ebx - test eax, eax - jz .notfound - cmp dword [eax], 'SKIN' - jnz .noskin - cmp ebx, 32*1024 - jb @f - mov ebx, 32*1024 + stdcall load_file, ebx + test eax, eax + jz .notfound + cmp dword [eax], 'SKIN' + jnz .noskin + cmp ebx, 32*1024 + jb @f + mov ebx, 32*1024 @@: - lea ecx, [ebx+3] - shr ecx, 2 - mov esi, eax - mov edi, skin_data - rep movsd - stdcall kernel_free, eax + lea ecx, [ebx+3] + shr ecx, 2 + mov esi, eax + mov edi, skin_data + rep movsd + stdcall kernel_free, eax - call parse_skin_data - xor eax, eax - ret + call parse_skin_data + xor eax, eax + ret .notfound: - xor eax, eax - inc eax - ret + xor eax, eax + inc eax + ret .noskin: - stdcall kernel_free, eax - push 2 - pop eax - ret + stdcall kernel_free, eax + push 2 + pop eax + ret struct SKIN_HEADER .ident dd ? @@ -51,19 +51,19 @@ struct SKIN_HEADER ends struct SKIN_PARAMS - .skin_height dd ? + .skin_height dd ? .margin.right dw ? - .margin.left dw ? + .margin.left dw ? .margin.bottom dw ? - .margin.top dw ? + .margin.top dw ? .colors.inner dd ? .colors.outer dd ? .colors.frame dd ? .colors_1.inner dd ? .colors_1.outer dd ? .colors_1.frame dd ? - .dtp.size dd ? - .dtp.data db 40 dup (?) + .dtp.size dd ? + .dtp.data db 40 dup (?) ends struct SKIN_BUTTONS @@ -83,203 +83,203 @@ struct SKIN_BITMAPS ends load_default_skin: - mov [_skinh],22 - mov ebx,_skin_file_default - call read_skin_file - ret + mov [_skinh],22 + mov ebx,_skin_file_default + call read_skin_file + ret parse_skin_data: - mov ebp,skin_data - cmp [ebp+SKIN_HEADER.ident],'SKIN' - jne .exit + mov ebp,skin_data + cmp [ebp+SKIN_HEADER.ident],'SKIN' + jne .exit - mov edi,skin_udata - mov ecx,(skin_udata.end-skin_udata)/4 - xor eax,eax - cld - rep stosd + mov edi,skin_udata + mov ecx,(skin_udata.end-skin_udata)/4 + xor eax,eax + cld + rep stosd - mov ebx,[ebp+SKIN_HEADER.params] - add ebx,skin_data - mov eax,[ebx+SKIN_PARAMS.skin_height] - mov [_skinh],eax - mov eax,[ebx+SKIN_PARAMS.colors.inner] - mov [skin_active.colors.inner],eax - mov eax,[ebx+SKIN_PARAMS.colors.outer] - mov [skin_active.colors.outer],eax - mov eax,[ebx+SKIN_PARAMS.colors.frame] - mov [skin_active.colors.frame],eax - mov eax,[ebx+SKIN_PARAMS.colors_1.inner] - mov [skin_inactive.colors.inner],eax - mov eax,[ebx+SKIN_PARAMS.colors_1.outer] - mov [skin_inactive.colors.outer],eax - mov eax,[ebx+SKIN_PARAMS.colors_1.frame] - mov [skin_inactive.colors.frame],eax - lea esi,[ebx+SKIN_PARAMS.dtp.data] - mov edi,common_colours - mov ecx,[ebx+SKIN_PARAMS.dtp.size] - and ecx,127 - rep movsb - mov eax,dword[ebx+SKIN_PARAMS.margin.right] - mov dword[_skinmargins+0],eax - mov eax,dword[ebx+SKIN_PARAMS.margin.bottom] - mov dword[_skinmargins+4],eax + mov ebx,[ebp+SKIN_HEADER.params] + add ebx,skin_data + mov eax,[ebx+SKIN_PARAMS.skin_height] + mov [_skinh],eax + mov eax,[ebx+SKIN_PARAMS.colors.inner] + mov [skin_active.colors.inner],eax + mov eax,[ebx+SKIN_PARAMS.colors.outer] + mov [skin_active.colors.outer],eax + mov eax,[ebx+SKIN_PARAMS.colors.frame] + mov [skin_active.colors.frame],eax + mov eax,[ebx+SKIN_PARAMS.colors_1.inner] + mov [skin_inactive.colors.inner],eax + mov eax,[ebx+SKIN_PARAMS.colors_1.outer] + mov [skin_inactive.colors.outer],eax + mov eax,[ebx+SKIN_PARAMS.colors_1.frame] + mov [skin_inactive.colors.frame],eax + lea esi,[ebx+SKIN_PARAMS.dtp.data] + mov edi,common_colours + mov ecx,[ebx+SKIN_PARAMS.dtp.size] + and ecx,127 + rep movsb + mov eax,dword[ebx+SKIN_PARAMS.margin.right] + mov dword[_skinmargins+0],eax + mov eax,dword[ebx+SKIN_PARAMS.margin.bottom] + mov dword[_skinmargins+4],eax - mov ebx,[ebp+SKIN_HEADER.bitmaps] - add ebx,skin_data - .lp1: cmp dword[ebx],0 - je .end_bitmaps - movzx eax,[ebx+SKIN_BITMAPS.kind] - movzx ecx,[ebx+SKIN_BITMAPS.type] - dec eax - jnz .not_left - xor eax,eax - mov edx,skin_active.left.data - or ecx,ecx - jnz @f - mov edx,skin_inactive.left.data - @@: jmp .next_bitmap + mov ebx,[ebp+SKIN_HEADER.bitmaps] + add ebx,skin_data + .lp1: cmp dword[ebx],0 + je .end_bitmaps + movzx eax,[ebx+SKIN_BITMAPS.kind] + movzx ecx,[ebx+SKIN_BITMAPS.type] + dec eax + jnz .not_left + xor eax,eax + mov edx,skin_active.left.data + or ecx,ecx + jnz @f + mov edx,skin_inactive.left.data + @@: jmp .next_bitmap .not_left: - dec eax - jnz .not_oper - mov esi,[ebx+SKIN_BITMAPS.data] - add esi,skin_data - mov eax,[esi+0] - neg eax - mov edx,skin_active.oper.data - or ecx,ecx - jnz @f - mov edx,skin_inactive.oper.data - @@: jmp .next_bitmap + dec eax + jnz .not_oper + mov esi,[ebx+SKIN_BITMAPS.data] + add esi,skin_data + mov eax,[esi+0] + neg eax + mov edx,skin_active.oper.data + or ecx,ecx + jnz @f + mov edx,skin_inactive.oper.data + @@: jmp .next_bitmap .not_oper: - dec eax - jnz .not_base - mov eax,[skin_active.left.width] - mov edx,skin_active.base.data - or ecx,ecx - jnz @f - mov eax,[skin_inactive.left.width] - mov edx,skin_inactive.base.data - @@: jmp .next_bitmap + dec eax + jnz .not_base + mov eax,[skin_active.left.width] + mov edx,skin_active.base.data + or ecx,ecx + jnz @f + mov eax,[skin_inactive.left.width] + mov edx,skin_inactive.base.data + @@: jmp .next_bitmap .not_base: - add ebx,8 - jmp .lp1 + add ebx,8 + jmp .lp1 .next_bitmap: - mov ecx,[ebx+SKIN_BITMAPS.data] - add ecx,skin_data - mov [edx+4],eax - mov eax,[ecx+0] - mov [edx+8],eax - add ecx,8 - mov [edx+0],ecx - add ebx,8 - jmp .lp1 + mov ecx,[ebx+SKIN_BITMAPS.data] + add ecx,skin_data + mov [edx+4],eax + mov eax,[ecx+0] + mov [edx+8],eax + add ecx,8 + mov [edx+0],ecx + add ebx,8 + jmp .lp1 .end_bitmaps: - mov ebx,[ebp+SKIN_HEADER.buttons] - add ebx,skin_data - .lp2: cmp dword[ebx],0 - je .end_buttons - mov eax,[ebx+SKIN_BUTTONS.type] - dec eax - jnz .not_close - mov edx,skin_btn_close - jmp .next_button + mov ebx,[ebp+SKIN_HEADER.buttons] + add ebx,skin_data + .lp2: cmp dword[ebx],0 + je .end_buttons + mov eax,[ebx+SKIN_BUTTONS.type] + dec eax + jnz .not_close + mov edx,skin_btn_close + jmp .next_button .not_close: - dec eax - jnz .not_minimize - mov edx,skin_btn_minimize - jmp .next_button + dec eax + jnz .not_minimize + mov edx,skin_btn_minimize + jmp .next_button .not_minimize: - add ebx,12 - jmp .lp2 + add ebx,12 + jmp .lp2 .next_button: - movsx eax,[ebx+SKIN_BUTTONS.left] - mov [edx+SKIN_BUTTON.left],eax - movsx eax,[ebx+SKIN_BUTTONS.top] - mov [edx+SKIN_BUTTON.top],eax - movsx eax,[ebx+SKIN_BUTTONS.width] - mov [edx+SKIN_BUTTON.width],eax - movsx eax,[ebx+SKIN_BUTTONS.height] - mov [edx+SKIN_BUTTON.height],eax - add ebx,12 - jmp .lp2 + movsx eax,[ebx+SKIN_BUTTONS.left] + mov [edx+SKIN_BUTTON.left],eax + movsx eax,[ebx+SKIN_BUTTONS.top] + mov [edx+SKIN_BUTTON.top],eax + movsx eax,[ebx+SKIN_BUTTONS.width] + mov [edx+SKIN_BUTTON.width],eax + movsx eax,[ebx+SKIN_BUTTONS.height] + mov [edx+SKIN_BUTTON.height],eax + add ebx,12 + jmp .lp2 .end_buttons: .exit: - ret + ret sys_putimage_with_check: or ebx,ebx jz @f - call sys_putimage.forced + call sys_putimage.forced @@: ret drawwindow_IV_caption: - mov ebp,skin_active - or al,al - jnz @f - mov ebp,skin_inactive + mov ebp,skin_active + or al,al + jnz @f + mov ebp,skin_inactive @@: - mov esi,[esp+4] - mov eax,[esi+WDATA.box.width] ; window width - mov edx,[ebp+SKIN_DATA.left.left] - shl edx,16 - mov ecx,[ebp+SKIN_DATA.left.width] - shl ecx,16 - add ecx,[_skinh] + mov esi,[esp+4] + mov eax,[esi+WDATA.box.width] ; window width + mov edx,[ebp+SKIN_DATA.left.left] + shl edx,16 + mov ecx,[ebp+SKIN_DATA.left.width] + shl ecx,16 + add ecx,[_skinh] - mov ebx, [ebp+SKIN_DATA.left.data] - call sys_putimage_with_check + mov ebx, [ebp+SKIN_DATA.left.data] + call sys_putimage_with_check - mov esi,[esp+4] - mov eax,[esi+WDATA.box.width] - sub eax,[ebp+SKIN_DATA.left.width] - sub eax,[ebp+SKIN_DATA.oper.width] - cmp eax,[ebp+SKIN_DATA.base.left] - jng .non_base - xor edx,edx - mov ecx,[ebp+SKIN_DATA.base.width] - jecxz .non_base - div ecx + mov esi,[esp+4] + mov eax,[esi+WDATA.box.width] + sub eax,[ebp+SKIN_DATA.left.width] + sub eax,[ebp+SKIN_DATA.oper.width] + cmp eax,[ebp+SKIN_DATA.base.left] + jng .non_base + xor edx,edx + mov ecx,[ebp+SKIN_DATA.base.width] + jecxz .non_base + div ecx - inc eax + inc eax - mov ebx,[ebp+SKIN_DATA.base.data] - mov ecx,[ebp+SKIN_DATA.base.width] - shl ecx,16 - add ecx,[_skinh] - mov edx,[ebp+SKIN_DATA.base.left] - sub edx,[ebp+SKIN_DATA.base.width] - shl edx,16 + mov ebx,[ebp+SKIN_DATA.base.data] + mov ecx,[ebp+SKIN_DATA.base.width] + shl ecx,16 + add ecx,[_skinh] + mov edx,[ebp+SKIN_DATA.base.left] + sub edx,[ebp+SKIN_DATA.base.width] + shl edx,16 .baseskinloop: - shr edx,16 - add edx,[ebp+SKIN_DATA.base.width] - shl edx,16 + shr edx,16 + add edx,[ebp+SKIN_DATA.base.width] + shl edx,16 - push eax ebx ecx edx - call sys_putimage_with_check - pop edx ecx ebx eax + push eax ebx ecx edx + call sys_putimage_with_check + pop edx ecx ebx eax - dec eax - jnz .baseskinloop + dec eax + jnz .baseskinloop .non_base: - mov esi,[esp+4] - mov edx,[esi+WDATA.box.width] - sub edx,[ebp+SKIN_DATA.oper.width] - inc edx - shl edx,16 - mov ebx,[ebp+SKIN_DATA.oper.data] + mov esi,[esp+4] + mov edx,[esi+WDATA.box.width] + sub edx,[ebp+SKIN_DATA.oper.width] + inc edx + shl edx,16 + mov ebx,[ebp+SKIN_DATA.oper.data] - mov ecx,[ebp+SKIN_DATA.oper.width] - shl ecx,16 - add ecx,[_skinh] - call sys_putimage_with_check + mov ecx,[ebp+SKIN_DATA.oper.width] + shl ecx,16 + add ecx,[_skinh] + call sys_putimage_with_check - ret + ret ;//mike.dld, 2006-08-02 ] @@ -287,176 +287,176 @@ drawwindow_IV_caption: drawwindow_IV: ;param1 - aw_yes - pusha + pusha - push edx + push edx - mov edi,edx + mov edi,edx - mov ebp,skin_active - cmp byte [esp+32+4+4],0 - jne @f - mov ebp,skin_inactive + mov ebp,skin_active + cmp byte [esp+32+4+4],0 + jne @f + mov ebp,skin_inactive @@: - mov eax,[edi+WDATA.box.left] - shl eax,16 + mov eax,[edi+WDATA.box.left] + shl eax,16 mov ax,word [edi+WDATA.box.left] add ax,word [edi+WDATA.box.width] - mov ebx,[edi+WDATA.box.top] - shl ebx,16 + mov ebx,[edi+WDATA.box.top] + shl ebx,16 mov bx,word [edi+WDATA.box.top] add bx,word [edi+WDATA.box.height] ; mov esi,[edi+24] ; shr esi,1 ; and esi,0x007f7f7f - mov esi,[ebp+SKIN_DATA.colors.outer] - call draw_rectangle - mov ecx,3 + mov esi,[ebp+SKIN_DATA.colors.outer] + call draw_rectangle + mov ecx,3 _dw3l: - add eax,1*65536-1 - add ebx,1*65536-1 - test ax,ax - js no_skin_add_button - test bx,bx - js no_skin_add_button - mov esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24] - call draw_rectangle - dec ecx - jnz _dw3l - mov esi,[ebp+SKIN_DATA.colors.inner] - add eax,1*65536-1 - add ebx,1*65536-1 - test ax,ax - js no_skin_add_button - test bx,bx - js no_skin_add_button - call draw_rectangle + add eax,1*65536-1 + add ebx,1*65536-1 + test ax,ax + js no_skin_add_button + test bx,bx + js no_skin_add_button + mov esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24] + call draw_rectangle + dec ecx + jnz _dw3l + mov esi,[ebp+SKIN_DATA.colors.inner] + add eax,1*65536-1 + add ebx,1*65536-1 + test ax,ax + js no_skin_add_button + test bx,bx + js no_skin_add_button + call draw_rectangle - cmp dword[skin_data],'SKIN' - je @f - xor eax,eax - xor ebx,ebx - mov esi,[esp] - mov ecx,[esi+WDATA.box.width] - inc ecx - mov edx,[_skinh] - mov edi,[common_colours+4] ; standard grab color - call [drawbar] - jmp draw_clientbar + cmp dword[skin_data],'SKIN' + je @f + xor eax,eax + xor ebx,ebx + mov esi,[esp] + mov ecx,[esi+WDATA.box.width] + inc ecx + mov edx,[_skinh] + mov edi,[common_colours+4] ; standard grab color + call [drawbar] + jmp draw_clientbar @@: - mov al,[esp+32+4+4] - call drawwindow_IV_caption + mov al,[esp+32+4+4] + call drawwindow_IV_caption draw_clientbar: - mov esi,[esp] + mov esi,[esp] - mov edx,[esi+WDATA.box.top] ; WORK AREA - add edx,21+5 - mov ebx,[esi+WDATA.box.top] - add ebx,[esi+WDATA.box.height] - cmp edx,ebx - jg _noinside2 - mov eax,5 - mov ebx,[_skinh] - mov ecx,[esi+WDATA.box.width] - mov edx,[esi+WDATA.box.height] - sub ecx,4 - sub edx,4 - mov edi,[esi+WDATA.cl_workarea] + mov edx,[esi+WDATA.box.top] ; WORK AREA + add edx,21+5 + mov ebx,[esi+WDATA.box.top] + add ebx,[esi+WDATA.box.height] + cmp edx,ebx + jg _noinside2 + mov eax,5 + mov ebx,[_skinh] + mov ecx,[esi+WDATA.box.width] + mov edx,[esi+WDATA.box.height] + sub ecx,4 + sub edx,4 + mov edi,[esi+WDATA.cl_workarea] test edi,0x40000000 jnz _noinside2 - call [drawbar] + call [drawbar] _noinside2: - cmp dword[skin_data],'SKIN' - jne no_skin_add_button + cmp dword[skin_data],'SKIN' + jne no_skin_add_button ;* close button - mov edi,[BTN_ADDR] - movzx eax,word [edi] - cmp eax,1000 - jge no_skin_add_button - inc eax - mov [edi],ax + mov edi,[BTN_ADDR] + movzx eax,word [edi] + cmp eax,1000 + jge no_skin_add_button + inc eax + mov [edi],ax - shl eax,4 - add eax,edi + shl eax,4 + add eax,edi - mov bx,[CURRENT_TASK] - mov [eax],bx + mov bx,[CURRENT_TASK] + mov [eax],bx - add eax,2 ; save button id number - mov bx,1 - mov [eax],bx - add eax,2 ; x start - xor ebx,ebx - cmp [skin_btn_close.left],0 - jge _bCx_at_right - mov ebx,[esp] - mov ebx,[ebx+WDATA.box.width] - inc ebx + add eax,2 ; save button id number + mov bx,1 + mov [eax],bx + add eax,2 ; x start + xor ebx,ebx + cmp [skin_btn_close.left],0 + jge _bCx_at_right + mov ebx,[esp] + mov ebx,[ebx+WDATA.box.width] + inc ebx _bCx_at_right: - add ebx,[skin_btn_close.left] - mov [eax],bx - add eax,2 ; x size - mov ebx,[skin_btn_close.width] - dec ebx - mov [eax],bx - add eax,2 ; y start - mov ebx,[skin_btn_close.top] - mov [eax],bx - add eax,2 ; y size - mov ebx,[skin_btn_close.height] - dec ebx - mov [eax],bx + add ebx,[skin_btn_close.left] + mov [eax],bx + add eax,2 ; x size + mov ebx,[skin_btn_close.width] + dec ebx + mov [eax],bx + add eax,2 ; y start + mov ebx,[skin_btn_close.top] + mov [eax],bx + add eax,2 ; y size + mov ebx,[skin_btn_close.height] + dec ebx + mov [eax],bx ;* minimize button - mov edi,[BTN_ADDR] - movzx eax,word [edi] - cmp eax,1000 - jge no_skin_add_button - inc eax - mov [edi],ax + mov edi,[BTN_ADDR] + movzx eax,word [edi] + cmp eax,1000 + jge no_skin_add_button + inc eax + mov [edi],ax - shl eax,4 - add eax,edi + shl eax,4 + add eax,edi - mov bx,[CURRENT_TASK] - mov [eax],bx + mov bx,[CURRENT_TASK] + mov [eax],bx - add eax,2 ; save button id number - mov bx,65535 ;999 - mov [eax],bx - add eax,2 ; x start - xor ebx,ebx - cmp [skin_btn_minimize.left],0 - jge _bMx_at_right - mov ebx,[esp] - mov ebx,[ebx+WDATA.box.width] - inc ebx + add eax,2 ; save button id number + mov bx,65535 ;999 + mov [eax],bx + add eax,2 ; x start + xor ebx,ebx + cmp [skin_btn_minimize.left],0 + jge _bMx_at_right + mov ebx,[esp] + mov ebx,[ebx+WDATA.box.width] + inc ebx _bMx_at_right: - add ebx,[skin_btn_minimize.left] - mov [eax],bx - add eax,2 ; x size - mov ebx,[skin_btn_minimize.width] - dec ebx - mov [eax],bx - add eax,2 ; y start - mov ebx,[skin_btn_minimize.top] - mov [eax],bx - add eax,2 ; y size - mov ebx,[skin_btn_minimize.height] - dec ebx - mov [eax],bx + add ebx,[skin_btn_minimize.left] + mov [eax],bx + add eax,2 ; x size + mov ebx,[skin_btn_minimize.width] + dec ebx + mov [eax],bx + add eax,2 ; y start + mov ebx,[skin_btn_minimize.top] + mov [eax],bx + add eax,2 ; y size + mov ebx,[skin_btn_minimize.height] + dec ebx + mov [eax],bx no_skin_add_button: - pop edi - popa + pop edi + popa - ret 4 + ret 4 -diff16 "skin code end ",0,$ -diff16 "skin code size",read_skin_file,$ +;diff16 "skin code end ",0,$ +diff10 "skin code size",read_skin_file,$ diff --git a/kernel/branches/Kolibri-A/trunk/gui/window.inc b/kernel/branches/Kolibri-A/trunk/gui/window.inc index a1262eb424..f0216c4d90 100644 --- a/kernel/branches/Kolibri-A/trunk/gui/window.inc +++ b/kernel/branches/Kolibri-A/trunk/gui/window.inc @@ -1637,25 +1637,25 @@ window._.set_screen: ;///////////////////////////////////////////////////////// imul edi, ebx add edi, eax add edi, [_WinMapAddress] - pop eax ; al = process# + pop eax ; al = process# mov ah, al push ax shl eax, 16 - pop ax ; eax = 4 dup PROCESS_NUM + pop ax ; eax = 4 dup PROCESS_NUM .next_line: push ecx - shr ecx, 2 - rep stosd ; filling the screen map + shr ecx, 2 + rep stosd ; filling the screen map mov ecx,[esp] - and ecx, 3 + and ecx, 3 rep stosb pop ecx - add edi, esi + add edi, esi sub edi, ecx dec edx - jnz .next_line -; jmp .exit + jnz .next_line +; jmp .exit .shaped_window: ; (not supported any more) @@ -1947,5 +1947,5 @@ window._.draw_negative_box: ;////////////////////////////////////////////////// pop esi ebx eax ret -diff16 "window code end",0,$ +;diff16 "window code end",0,$ diff10 "window.inc size",syscall_draw_window,$ diff --git a/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc b/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc index b67bde0ac9..78620a52ae 100644 --- a/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc +++ b/kernel/branches/Kolibri-A/trunk/hid/mousedrv.inc @@ -7,7 +7,7 @@ $Revision$ - + ; check mouse ; ; @@ -93,21 +93,21 @@ save_draw_mouse: movzx ebx,word [MOUSE_X] push eax push ebx - + mov ecx, [Screen_Max_X] inc ecx mul ecx add eax, [_WinMapAddress] movzx edx, byte [ebx+eax] shl edx, 8 - mov esi, [edx+SLOT_BASE+APPDATA.cursor] + mov esi, [edx+SLOT_BASE+APPDATA.cursor] - cmp esi, [current_cursor] + cmp esi, [current_cursor] je .draw - push esi + push esi call [_display.select_cursor] - mov [current_cursor], esi + mov [current_cursor], esi .draw: stdcall [_display.move_cursor], esi popad @@ -115,7 +115,7 @@ save_draw_mouse: .fail: mov ecx, [def_cursor] mov [edx+SLOT_BASE+APPDATA.cursor], ecx - stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax + stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax popad ret @@ -156,7 +156,7 @@ drm: mov esi, edi add edi, esi add edi, esi ; *3 - add edi, mousepointer ;[MOUSE_PICTURE] ; we have our str address + add edi, mousepointer ;[MOUSE_PICTURE] ; we have our str address mov esi, edi add esi, 16*24*3 push ecx @@ -439,5 +439,5 @@ mouse_acceleration: @@: ret -diff16 "window code end",0,$ +;diff16 "window code end",0,$ diff10 "mousedrv size ",draw_mouse_under,$ diff --git a/kernel/branches/Kolibri-A/trunk/kernel.asm b/kernel/branches/Kolibri-A/trunk/kernel.asm index 9b8fc62ba4..f71da97371 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel.asm +++ b/kernel/branches/Kolibri-A/trunk/kernel.asm @@ -219,8 +219,17 @@ diff16 "32-bit code start ",0,$ call init_BIOS32 ; (init.inc - to be removed later) ; PCIe extended config space access -; call rs7xx_pcie_init ; (bus/HT.inc) - call fusion_pcie_init ; (bus/HT.inc) + + display '** Platform chosen (const.inc): ' +if PLATFORM>PLATFORM_RS780 + call fusion_pcie_init ; (bus/HT.inc) + display 'RS880/Fusion ' +else + call rs7xx_pcie_init ; (bus/HT.inc) + display 'RS780 ' +end if + display 10,13 + ; MEMORY MODEL call init_mem ; (init.inc) @@ -242,10 +251,11 @@ align 4 bios32_entry dd ? tmp_page_tabs dd ? -use16 -org $-0x10000 -include "boot/shutdown.inc" ; shutdown or restart -org $+0x10000 +;use16 +;org $-0x10000 +;include "boot/shutdown.inc" ; shutdown or restart +;org $+0x10000 + use32 __DEBUG__ fix 1 @@ -572,28 +582,18 @@ include 'detect/disks.inc' include 'vmodeld.inc' ;!!!!!!!!!!!!!!!!!!!!!!! -if 0 - mov ax,[OS_BASE+0x10000+bx_from_load] - cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba} - je no_lib_load -; LOADING LIBRARES - stdcall dll.Load,@IMPORT ; loading librares for kernel (.obj files) - call load_file_parse_table ; prepare file parse table - call set_kernel_conf ; configure devices and gui -no_lib_load: -end if ; LOAD FONTS I and II stdcall read_file, char, FONT_I, 0, 2304 stdcall read_file, char2, FONT_II, 0, 2560 - mov esi,boot_fonts - call boot_log +; mov esi,boot_fonts +; call boot_log ; PRINT AMOUNT OF MEMORY - mov esi, boot_memdetect - call boot_log +; mov esi, boot_memdetect +; call boot_log movzx ecx, word [boot_y] or ecx, (10+29*6) shl 16 ; "Determining amount of memory" @@ -610,8 +610,8 @@ end if call build_scheduler ; sys32.inc - mov esi,boot_devices - call boot_log +; mov esi,boot_devices +; call boot_log mov [pci_access_enabled],1 @@ -624,15 +624,15 @@ end if ; SET BACKGROUND DEFAULTS - mov esi,boot_bgr - call boot_log +; mov esi,boot_bgr +; call boot_log call init_background ; call calculatebackground ; SET UP OS TASK - mov esi,boot_setostask - call boot_log +; mov esi,boot_setostask +; call boot_log xor eax, eax mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data @@ -683,8 +683,8 @@ end if ; READ TSC / SECOND - mov esi,boot_tsc - call boot_log +; mov esi,boot_tsc +; call boot_log cli rdtsc ;call _rdtsc mov ecx,eax @@ -724,8 +724,8 @@ end if ;call detect_devices stdcall load_driver, szPS2MDriver - mov esi,boot_setmouse - call boot_log +; mov esi,boot_setmouse +; call boot_log ; call setmouse ; mov [MOUSE_PICTURE],dword mousepointer cli @@ -754,8 +754,8 @@ end if call init_userDMA ; <<<<<<<<< ============== core/memory.inc ================= - mov esi, boot_uDMA_ok - call boot_log +; mov esi, boot_uDMA_ok +; call boot_log ; LOAD FIRST APPLICATION cli @@ -779,8 +779,8 @@ no_load_vrr_m: sub eax,2 jz first_app_found - mov esi, boot_failed - call boot_log +; mov esi, boot_failed +; call boot_log mov eax, 0xDEADBEEF ; otherwise halt hlt @@ -825,13 +825,13 @@ first_app_found: ; START MULTITASKING -if preboot_blogesc - mov esi, boot_tasking - call boot_log -.bll1: in al, 0x60 ; wait for ESC key press - cmp al, 129 - jne .bll1 -end if +;if preboot_blogesc +; mov esi, boot_tasking +; call boot_log +;.bll1: in al, 0x60 ; wait for ESC key press +; cmp al, 129 +; jne .bll1 +;end if stdcall attach_int_handler, 1, irq1, 0 @@ -4468,230 +4468,50 @@ system_shutdown: ; shut down the system yes_shutdown_param: cli - mov eax, kernel_file ; load kernel.mnt to 0x7000:0 - push 12 - pop esi - xor ebx,ebx - or ecx,-1 - mov edx, OS_BASE+0x70000 - call fileread - - mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 - mov edi,OS_BASE+0x40000 - mov ecx,1000 - rep movsb - - mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff - mov edi, OS_BASE - mov ecx,0x10000/4 - cld - rep movsd - - call restorefatchain mov al, 0xFF - out 0x21, al - out 0xA1, al + out 0x21, al ;IntrCntrl1Reg2 + out 0xA1, al ;IntrCntrl2Reg2 + cmp byte [BOOT_VAR + 0x9030], 2 + jnz pm_restart if 0 - mov word [OS_BASE+0x467+0],pr_mode_exit - mov word [OS_BASE+0x467+2],0x1000 - - mov al,0x0F - out 0x70,al - mov al,0x05 - out 0x71,al - - mov al,0xFE - out 0x64,al - - hlt - jmp $-1 - -else - cmp byte [OS_BASE + 0x9030], 2 - jnz no_acpi_power_off - -; scan for RSDP -; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). - movzx eax, word [OS_BASE + 0x40E] - shl eax, 4 - jz @f - mov ecx, 1024/16 - call scan_rsdp - jnc .rsdp_found -@@: -; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. - mov eax, 0xE0000 - mov ecx, 0x2000 - call scan_rsdp - jc no_acpi_power_off -.rsdp_found: - mov esi, [eax+16] ; esi contains physical address of the RSDT - mov ebp, [ipc_tmp] - stdcall map_page, ebp, esi, PG_MAP - lea eax, [esi+1000h] - lea edx, [ebp+1000h] - stdcall map_page, edx, eax, PG_MAP - and esi, 0xFFF - add esi, ebp - cmp dword [esi], 'RSDT' - jnz no_acpi_power_off - mov ecx, [esi+4] - sub ecx, 24h - jbe no_acpi_power_off - shr ecx, 2 - add esi, 24h -.scan_fadt: - lodsd - mov ebx, eax - lea eax, [ebp+2000h] - stdcall map_page, eax, ebx, PG_MAP - lea eax, [ebp+3000h] - add ebx, 0x1000 - stdcall map_page, eax, ebx, PG_MAP - and ebx, 0xFFF - lea ebx, [ebx+ebp+2000h] - cmp dword [ebx], 'FACP' - jz .fadt_found - loop .scan_fadt - jmp no_acpi_power_off -.fadt_found: -; ebx is linear address of FADT - mov edi, [ebx+40] ; physical address of the DSDT - lea eax, [ebp+4000h] - stdcall map_page, eax, edi, PG_MAP - lea eax, [ebp+5000h] - lea esi, [edi+0x1000] - stdcall map_page, eax, esi, PG_MAP - and esi, 0xFFF - sub edi, esi - cmp dword [esi+ebp+4000h], 'DSDT' - jnz no_acpi_power_off - mov eax, [esi+ebp+4004h] ; DSDT length - sub eax, 36+4 - jbe no_acpi_power_off - add esi, 36 -.scan_dsdt: - cmp dword [esi+ebp+4000h], '_S5_' - jnz .scan_dsdt_cont - cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode - jnz .scan_dsdt_cont - mov dl, [esi+ebp+4000h+6] - cmp dl, 4 ; _S5_ package must contain 4 bytes - ; ...in theory; in practice, VirtualBox has 2 bytes - ja .scan_dsdt_cont - cmp dl, 1 - jb .scan_dsdt_cont - lea esi, [esi+ebp+4000h+7] - xor ecx, ecx - cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx - jz @f - cmp byte [esi], 0xA - jnz no_acpi_power_off - inc esi - mov cl, [esi] -@@: - inc esi - cmp dl, 2 - jb @f - cmp byte [esi], 0 - jz @f - cmp byte [esi], 0xA - jnz no_acpi_power_off - inc esi - mov ch, [esi] -@@: - jmp do_acpi_power_off -.scan_dsdt_cont: - inc esi - cmp esi, 0x1000 - jb @f - sub esi, 0x1000 - add edi, 0x1000 - push eax - lea eax, [ebp+4000h] - stdcall map_page, eax, edi, PG_MAP - push PG_MAP - lea eax, [edi+1000h] - push eax - lea eax, [ebp+5000h] - push eax - stdcall map_page - pop eax -@@: - dec eax - jnz .scan_dsdt - jmp no_acpi_power_off -do_acpi_power_off: - mov edx, [ebx+48] - test edx, edx - jz .nosmi - mov al, [ebx+52] + mov al, SB_PM_CTRL_BLK + mov ah, al + inc ah + mov dx, 0x0CD6 out dx, al - mov edx, [ebx+64] -@@: - in ax, dx - test al, 1 - jz @b -.nosmi: - and cx, 0x0707 - shl cx, 2 - or cx, 0x2020 - mov edx, [ebx+64] - in ax, dx - and ax, 203h - or ah, cl + inc dl + in al, dx + mov cl, al + dec dl + mov al, ah + out dx, al + inc dl + in al, dx + mov ch, al +end if + mov dx, 0x0804 ;cx + mov ax, 0x03400 out dx, ax - mov edx, [ebx+68] - test edx, edx - jz @f - in ax, dx - and ax, 203h - or ah, ch - out dx, ax -@@: - jmp $ +; THE END... + jmp $ ; just to be absolutely sure -no_acpi_power_off: - mov word [OS_BASE+0x467+0],pr_mode_exit - mov word [OS_BASE+0x467+2],0x1000 +pm_restart: mov al,0x0F - out 0x70,al + out 0x70,al ; NmiEnable mov al,0x05 - out 0x71,al + out 0x71,al ; RtcData - mov al,0xFE - out 0x64,al + mov ax, 6 + mov dx, 0xCF9 ; reset reg + out dx, ax hlt jmp $-1 -scan_rsdp: - add eax, OS_BASE -.s: - cmp dword [eax], 'RSD ' - jnz .n - cmp dword [eax+4], 'PTR ' - jnz .n - xor edx, edx - xor esi, esi -@@: - add dl, [eax+esi] - inc esi - cmp esi, 20 - jnz @b - test dl, dl - jz .ok -.n: - add eax, 10h - loop .s - stc -.ok: - ret -end if diff16 "End of 32-code ",0,$ diff --git a/kernel/branches/Kolibri-A/trunk/kernel32.inc b/kernel/branches/Kolibri-A/trunk/kernel32.inc index a32b0c6828..aefbef25c9 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel32.inc +++ b/kernel/branches/Kolibri-A/trunk/kernel32.inc @@ -15,7 +15,7 @@ $Revision$ - + struc POINT { .x dd ? @@ -220,13 +220,13 @@ include "fs/ext2.inc" ; read / write for ext2 filesystem ; sound include "sound/playnote.inc" ; player Note for Speaker PC -;include "sound/FHT.inc" ; fast Fourier transform routines +;include "sound/FHT.inc" ; fast Fourier transform routines ; display -;include "video/graph32.inc" ; 32bpp graphics -include "video/vesa20.inc" ; older graphics engine -include "video/cursors.inc" ; cursors functions +;include "video/graph32.inc" ; 32bpp graphics +include "video/vesa20.inc" ; older graphics engine +include "video/cursors.inc" ; cursors functions ; Network Interface & TCPIP Stack @@ -247,6 +247,7 @@ include "gui/skincode.inc" include "bus/pci/pci32.inc" ;include "bus/pci/PCIe.inc" include "bus/HT.inc" ; AMD HyperTransport bus control +include "bus/SB/SB.inc" ; Floppy drive controller diff --git a/kernel/branches/Kolibri-A/trunk/memmap.inc b/kernel/branches/Kolibri-A/trunk/memmap.inc index 48886347d5..bd11380dc4 100644 --- a/kernel/branches/Kolibri-A/trunk/memmap.inc +++ b/kernel/branches/Kolibri-A/trunk/memmap.inc @@ -149,11 +149,11 @@ ; in the current version: ; -> 00B3C 16-bit code end ; -> 00C40 16-bit data end -; -> 10C40 32-bit code start -; -> 2D07E 32-bit code end -; -> 30418..end_of_kernel zero-filled zone after preinit_mem -; -> 33D63 uninitialized globals start -; -> 3BF52 end_of_kernel +; -> 105F0 32-bit code start +; -> 2C889 32-bit code end +; -> 2FC28..end_of_kernel zero-filled zone after preinit_mem +; -> 33563 uninitialized globals start +; -> 3B752 end_of_kernel ; -> 3C000 not used (>200k) ; 0x80050000 -> 090000 zero-filled zone after preinit_mem ; 0x8006CC00 -> 6DBFF stack at boot time (4Kb) diff --git a/kernel/branches/Kolibri-A/trunk/video/vesa20.inc b/kernel/branches/Kolibri-A/trunk/video/vesa20.inc index 20638c3e77..8a0e3a22f9 100644 --- a/kernel/branches/Kolibri-A/trunk/video/vesa20.inc +++ b/kernel/branches/Kolibri-A/trunk/video/vesa20.inc @@ -463,7 +463,7 @@ align 4 ret align 4 .drawtable: -dd .check_overlap ; general case +dd .check_overlap ; general case dd .invert_color dd .putpixel ; force to draw it dd .invert_force @@ -497,18 +497,18 @@ vline: shl eax, 1 add eax, ebx add eax, LFB_BASE - pop ebx ; restore ebx = y1 + pop ebx ; restore ebx = y1 cmp edx, [Screen_Max_Y] ; the last check jb .draw mov edx, [Screen_Max_Y] ; to prevent off-screen drawing -.draw: - jmp dword [vline.drawtable + edi*4] +.draw: + jmp dword [vline.drawtable + edi*4] align 4 .invert_color: mov ecx, [eax] xor ecx, 0x00FFFFFF - or ecx, 0x01000000 + or ecx, 0x01000000 align 4 .check_overlap: movzx esi, byte [ebp] @@ -520,7 +520,7 @@ align 4 .invert_force: mov ecx, [eax] xor ecx, 0x00FFFFFF - or ecx, 0x01000000 + or ecx, 0x01000000 align 4 .putpixel: mov [eax], ecx @@ -531,7 +531,7 @@ align 4 inc ebx cmp ebx, edx ja .exit - jmp dword [vline.drawtable + edi*4] + jmp dword [vline.drawtable + edi*4] .exit: shr edi, 1 pop edx ebx esi ebp eax @@ -539,7 +539,7 @@ align 4 ret align 4 .drawtable: -dd .check_overlap ; general case +dd .check_overlap ; general case dd .invert_color dd .putpixel ; force to draw it dd .invert_force @@ -576,9 +576,9 @@ vesa20_drawbar: sub esp, drbar.stack_data mov [drbar.color], edi sub edx, ebx - jle .exit + jle .exit sub ecx, eax - jle .exit + jle .exit mov [drbar.bar_sy], edx mov [drbar.bar_sx], ecx mov [drbar.bar_cx], eax @@ -594,7 +594,7 @@ vesa20_drawbar: inc ebx sub ebx, [drbar.bar_cx] ja @f -.exit: +.exit: add esp, drbar.stack_data popad xor eax, eax @@ -755,7 +755,7 @@ nbgp: add esi, 3 add edi, 3 @@: - inc edi ; +1 for 32 bpp + inc edi ; +1 for 32 bpp add ebp, edx add eax, edx cmp eax, [draw_data+32+RECT.right] @@ -1042,23 +1042,23 @@ init_background: align 16 overlapping_of_points_mmx: - movd mm0, eax - movd mm4, eax - movd mm1, ebx - pxor mm2, mm2 - punpcklbw mm0, mm2 - punpcklbw mm1, mm2 - psubw mm1, mm0 - movd mm3, ecx - psrld mm3, 24 - packuswb mm3, mm3 - packuswb mm3, mm3 - pmullw mm1, mm3 - psrlw mm1, 8 - packuswb mm1, mm2 - paddb mm4, mm1 - movd eax, mm4 - ret -diff16 "VESA2 code end ",0,$ -diff16 "VESA2 code size",get_pixel,$ + movd mm0, eax + movd mm4, eax + movd mm1, ebx + pxor mm2, mm2 + punpcklbw mm0, mm2 + punpcklbw mm1, mm2 + psubw mm1, mm0 + movd mm3, ecx + psrld mm3, 24 + packuswb mm3, mm3 + packuswb mm3, mm3 + pmullw mm1, mm3 + psrlw mm1, 8 + packuswb mm1, mm2 + paddb mm4, mm1 + movd eax, mm4 + ret +;diff16 "VESA2 code end ",0,$ +diff10 "VESA2 code size",get_pixel,$