From 74c5e79c925ea65cac64925cc9d126d1f7096664 Mon Sep 17 00:00:00 2001 From: "Artem Jerdev (art_zh)" Date: Mon, 1 Nov 2010 11:30:29 +0000 Subject: [PATCH] init.inc optimized for AMD chipsets git-svn-id: svn://kolibrios.org@1683 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../Kolibri-A/trunk/boot/bootcode.inc | 1677 ++++--- kernel/branches/Kolibri-A/trunk/bus/HT.inc | 182 +- .../branches/Kolibri-A/trunk/bus/pci/PCIe.inc | 7 +- kernel/branches/Kolibri-A/trunk/const.inc | 9 +- kernel/branches/Kolibri-A/trunk/data32.inc | 12 +- kernel/branches/Kolibri-A/trunk/init.inc | 556 +-- kernel/branches/Kolibri-A/trunk/kernel.asm | 4236 ++++++++--------- kernel/branches/Kolibri-A/trunk/kernel32.inc | 2 +- kernel/branches/Kolibri-A/trunk/memmap.inc | 27 +- 9 files changed, 3262 insertions(+), 3446 deletions(-) diff --git a/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc b/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc index e1f9c2b3a3..e6e0491cb8 100644 --- a/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc +++ b/kernel/branches/Kolibri-A/trunk/boot/bootcode.inc @@ -23,81 +23,81 @@ $Revision$ putchar: ; in: al=character - mov ah, 0Eh - mov bh, 0 - int 10h - ret + mov ah, 0Eh + mov bh, 0 + int 10h + ret print: ; in: si->string - mov al, 186 - call putchar - mov al, ' ' - call putchar + mov al, 186 + call putchar + mov al, ' ' + call putchar printplain: ; in: si->string - pusha - lodsb + pusha + lodsb @@: - call putchar - lodsb - test al,al - jnz @b - popa - ret + call putchar + lodsb + test al,al + jnz @b + popa + ret getkey: ; get number in range [bl,bh] (bl,bh in ['0'..'9']) ; in: bx=range ; out: ax=digit (1..9, 10 for 0) - mov ah, 0 - int 16h - cmp al, bl - jb getkey - cmp al, bh - ja getkey - push ax - call putchar - pop ax - and ax, 0Fh - jnz @f - mov al, 10 + mov ah, 0 + int 16h + cmp al, bl + jb getkey + cmp al, bh + ja getkey + push ax + call putchar + pop ax + and ax, 0Fh + jnz @f + mov al, 10 @@: - ret + ret setcursor: ; in: dl=column, dh=row - mov ah, 2 - mov bh, 0 - int 10h - ret + mov ah, 2 + mov bh, 0 + int 10h + ret macro _setcursor row,column { - mov dx, row*256 + column - call setcursor + mov dx, row*256 + column + call setcursor } boot_read_floppy: - push si - xor si, si - mov ah, 2 ; read + push si + xor si, si + mov ah, 2 ; read @@: - push ax - int 0x13 - pop ax - jnc @f - inc si - cmp si, 10 - jb @b - mov si, badsect + push ax + int 0x13 + pop ax + jnc @f + inc si + cmp si, 10 + jb @b + mov si, badsect sayerr_plain: - call printplain - jmp $ + call printplain + jmp $ @@: - pop si - ret + pop si + ret ; convert abs. sector number (AX) to BIOS T:H:S ; sector number = (abs.sector%BPB_SecPerTrk)+1 @@ -109,34 +109,34 @@ sayerr_plain: ; dl - drive number (0 = a:) ; dh - head number conv_abs_to_THS: - push bx - mov bx,word [BPB_SecPerTrk] - xor dx,dx - div bx - inc dx - mov cl, dl ; cl = sector number - mov bx,word [BPB_NumHeads] - xor dx,dx - div bx - ; !!!!!!! ax = track number, dx = head number - mov ch,al ; ch=track number - xchg dh,dl ; dh=head number - mov dl,0 ; dl=0 (drive 0 (a:)) - pop bx - retn + push bx + mov bx,word [BPB_SecPerTrk] + xor dx,dx + div bx + inc dx + mov cl, dl ; cl = sector number + mov bx,word [BPB_NumHeads] + xor dx,dx + div bx + ; !!!!!!! ax = track number, dx = head number + mov ch,al ; ch=track number + xchg dh,dl ; dh=head number + mov dl,0 ; dl=0 (drive 0 (a:)) + pop bx + retn ; needed variables -BPB_SecPerTrk dw 0 ; sectors per track -BPB_NumHeads dw 0 ; number of heads -BPB_FATSz16 dw 0 ; size of FAT -BPB_RootEntCnt dw 0 ; count of root dir. entries -BPB_BytsPerSec dw 0 ; bytes per sector -BPB_RsvdSecCnt dw 0 ; number of reserved sectors -BPB_TotSec16 dw 0 ; count of the sectors on the volume -BPB_SecPerClus db 0 ; number of sectors per cluster -BPB_NumFATs db 0 ; number of FAT tables -abs_sector_adj dw 0 ; adjustment to make abs. sector number -end_of_FAT dw 0 ; end of FAT table -FirstDataSector dw 0 ; begin of data +BPB_SecPerTrk dw 0 ; sectors per track +BPB_NumHeads dw 0 ; number of heads +BPB_FATSz16 dw 0 ; size of FAT +BPB_RootEntCnt dw 0 ; count of root dir. entries +BPB_BytsPerSec dw 0 ; bytes per sector +BPB_RsvdSecCnt dw 0 ; number of reserved sectors +BPB_TotSec16 dw 0 ; count of the sectors on the volume +BPB_SecPerClus db 0 ; number of sectors per cluster +BPB_NumFATs db 0 ; number of FAT tables +abs_sector_adj dw 0 ; adjustment to make abs. sector number +end_of_FAT dw 0 ; end of FAT table +FirstDataSector dw 0 ; begin of data ;========================================================================= ; @@ -144,97 +144,79 @@ FirstDataSector dw 0 ; begin of data ; ;========================================================================= -include 'bootvesa.inc' ;Include source for boot vesa +include 'bootvesa.inc' ;Include source for boot vesa start_of_code: - cld + cld ; \begin{diamond}[02.12.2005] ; if bootloader sets ax = 'KL', then ds:si points to loader block - cmp ax, 'KL' - jnz @f - mov word [cs:cfgmanager.loader_block], si - mov word [cs:cfgmanager.loader_block+2], ds + cmp ax, 'KL' + jnz @f + mov word [cs:cfgmanager.loader_block], si + mov word [cs:cfgmanager.loader_block+2], ds @@: ; \end{diamond}[02.12.2005] ; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk ; (see comment to bx_from_load) - cmp cx, 'HA' - jnz no_hd_load - cmp dx,'RD' - jnz no_hd_load - mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] + cmp cx, 'HA' + jnz no_hd_load + cmp dx,'RD' + jnz no_hd_load + mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] no_hd_load: ; set up stack - mov ax, 3000h - mov ss, ax - mov sp, 0EC00h + mov ax, 3000h + mov ss, ax + mov sp, 0EC00h ; set up segment registers - push cs - pop ds - push cs - pop es + push cs + pop ds + push cs + pop es ; set videomode - mov ax, 3 - int 0x10 - -if lang eq ru - ; Load & set russian VGA font (RU.INC) - mov bp, RU_FNT1 ; RU_FNT1 - First part - mov bx, 1000h ; 768 bytes - mov cx, 30h ; 48 symbols - mov dx, 80h ; 128 - position of first symbol - mov ax, 1100h - int 10h - - mov bp, RU_FNT2 ; RU_FNT2 -Second part - mov bx, 1000h ; 512 bytes - mov cx, 20h ; 32 symbols - mov dx, 0E0h ; 224 - position of first symbol - mov ax, 1100h - int 10h - ; End set VGA russian font -end if + mov ax, 3 + int 0x10 ; draw frames - push 0xb800 - pop es - xor di, di - mov ah, 1*16+15 + push 0xb800 + pop es + xor di, di + mov ah, 1*16+15 ; draw top - mov si, d80x25_top - mov cx, d80x25_top_num * 80 + mov si, d80x25_top + mov cx, d80x25_top_num * 80 @@: - lodsb - stosw - loop @b + lodsb + stosw + loop @b ; draw spaces - mov si, space_msg - mov dx, 25 - d80x25_top_num - d80x25_bottom_num + mov si, space_msg + mov dx, 25 - d80x25_top_num - d80x25_bottom_num dfl1: - push si - mov cx, 80 + push si + mov cx, 80 @@: - lodsb - stosw - loop @b - pop si - dec dx - jnz dfl1 + lodsb + stosw + loop @b + pop si + dec dx + jnz dfl1 ; draw bottom - mov si, d80x25_bottom - mov cx, d80x25_bottom_num * 80 + mov si, d80x25_bottom + mov cx, d80x25_bottom_num * 80 @@: - lodsb - stosw - loop @b + lodsb + stosw + loop @b - mov byte [space_msg+80], 0 ; now space_msg is null terminated + mov byte [space_msg+80], 0 ; now space_msg is null terminated - _setcursor d80x25_top_num,0 + _setcursor d80x25_top_num,0 ; TEST FOR 386+ @@ -254,138 +236,111 @@ dfl1: ; jnz cpugood ; mov si, not386 sayerr: - call print - jmp $ + call print + jmp $ cpugood: - push 0 - popf - sti + push 0 + popf + sti ; set up esp - movzx esp, sp + movzx esp, sp - push 0 - pop es - and word [es:0x9031], 0 + push 0 + pop es + and word [es:0x9031], 0 ; \begin{Mario79} ; find HDD IDE DMA PCI device ; check for PCI BIOS - mov ax, 0xB101 - int 0x1A - jc .nopci - cmp edx, 'PCI ' - jnz .nopci + mov ax, 0xB101 + int 0x1A + jc .nopci + cmp edx, 'PCI ' + jnz .nopci ; find PCI class code ; class 1 = mass storage ; subclass 1 = IDE controller ; a) class 1, subclass 1, programming interface 0x80 - mov ax, 0xB103 - mov ecx, 1*10000h + 1*100h + 0x80 - xor si, si ; device index = 0 - int 0x1A - jnc .found + mov ax, 0xB103 + mov ecx, 1*10000h + 1*100h + 0x80 + xor si, si ; device index = 0 + int 0x1A + jnc .found ; b) class 1, subclass 1, programming interface 0x8A - mov ax, 0xB103 - mov ecx, 1*10000h + 1*100h + 0x8A - xor si, si ; device index = 0 - int 0x1A - jnc .found + mov ax, 0xB103 + mov ecx, 1*10000h + 1*100h + 0x8A + xor si, si ; device index = 0 + int 0x1A + jnc .found ; c) class 1, subclass 1, programming interface 0x85 - mov ax, 0xB103 - mov ecx, 1*10000h + 1*100h + 0x85 - xor si, si - int 0x1A - jc .nopci + mov ax, 0xB103 + mov ecx, 1*10000h + 1*100h + 0x85 + xor si, si + int 0x1A + jc .nopci .found: ; get memory base - mov ax, 0xB10A - mov di, 0x20 ; memory base is config register at 0x20 - int 0x1A - jc .nopci - and cx, 0xFFF0 ; clear address decode type - mov [es:0x9031], cx + mov ax, 0xB10A + mov di, 0x20 ; memory base is config register at 0x20 + int 0x1A + jc .nopci + and cx, 0xFFF0 ; clear address decode type + mov [es:0x9031], cx .nopci: ; \end{Mario79} -; mov al, 0xf6 ; ╤сЁюё ъыртшрЄєЁ√, ЁрчЁх°шЄ№ ёърэшЁютрэшх -; out 0x60, al -; xor cx, cx -;wait_loop: ; variant 2 -; reading state of port of 8042 controller -; in al, 64h -; and al, 00000010b ; ready flag -; wait until 8042 controller is ready -; loopnz wait_loop - -;;;/diamond 5.02.2008 -; set keyboard typematic rate & delay -; mov al, 0xf3 -; out 0x60, al -; xor cx, cx -;@@: -; in al, 64h -; test al, 2 -; loopnz @b -; mov al, 0 -; out 0x60, al -; xor cx, cx -;@@: -; in al, 64h -; test al, 2 -; loopnz @b -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; --------------- APM --------------------- - and word [es:0x9044], 0 ; ver = 0.0 (APM not found) - mov ax, 0x5300 - xor bx, bx - int 0x15 - jc apm_end ; APM not found - test cx, 2 - jz apm_end ; APM 32-bit protected-mode interface not supported - mov [es:0x9044], ax ; Save APM Version - mov [es:0x9046], cx ; Save APM flags + and word [es:0x9044], 0 ; ver = 0.0 (APM not found) + mov ax, 0x5300 + xor bx, bx + int 0x15 + jc apm_end ; APM not found + test cx, 2 + jz apm_end ; APM 32-bit protected-mode interface not supported + mov [es:0x9044], ax ; Save APM Version + mov [es:0x9046], cx ; Save APM flags - ; Write APM ver ---- - and ax, 0xf0f - add ax, '00' - mov si, msg_apm - mov [si + 5], ah - mov [si + 7], al - _setcursor 0, 3 - call printplain - ; ------------------ + ; Write APM ver ---- + and ax, 0xf0f + add ax, '00' + mov si, msg_apm + mov [si + 5], ah + mov [si + 7], al + _setcursor 0, 3 + call printplain + ; ------------------ - mov ax, 0x5304 ; Disconnect interface - xor bx, bx - int 0x15 - mov ax, 0x5303 ; Connect 32 bit mode interface - xor bx, bx - int 0x15 + mov ax, 0x5304 ; Disconnect interface + xor bx, bx + int 0x15 + mov ax, 0x5303 ; Connect 32 bit mode interface + xor bx, bx + int 0x15 - mov [es:0x9040], ebx - mov [es:0x9050], ax - mov [es:0x9052], cx - mov [es:0x9054], dx + mov [es:0x9040], ebx + mov [es:0x9050], ax + mov [es:0x9052], cx + mov [es:0x9054], dx apm_end: - _setcursor d80x25_top_num, 0 + _setcursor d80x25_top_num, 0 ;CHECK current of code - cmp [cfgmanager.loader_block], -1 - jz noloaderblock - les bx, [cfgmanager.loader_block] - cmp byte [es:bx], 1 - mov si, loader_block_error - jnz sayerr - push 0 - pop es + cmp [cfgmanager.loader_block], -1 + jz noloaderblock + les bx, [cfgmanager.loader_block] + cmp byte [es:bx], 1 + mov si, loader_block_error + jnz sayerr + push 0 + pop es noloaderblock: ; DISPLAY VESA INFORMATION - call print_vesa_info - call calc_vmodes_table - call check_first_parm ;check and enable cursor_pos + call print_vesa_info + call calc_vmodes_table + call check_first_parm ;check and enable cursor_pos ; \begin{diamond}[30.11.2005] cfgmanager: @@ -397,270 +352,258 @@ cfgmanager: ; d) preboot_device = from what boot? ; determine default settings - mov [.bSettingsChanged], 0 + mov [.bSettingsChanged], 0 ;.preboot_gr_end: - mov di, preboot_device + mov di, preboot_device ; if image in memory is present and [preboot_device] is uninitialized, ; set it to use this preloaded image - cmp byte [di], 0 - jnz .preboot_device_inited - cmp [.loader_block], -1 - jz @f - les bx, [.loader_block] - test byte [es:bx+1], 1 - jz @f - mov byte [di], 3 - jmp .preboot_device_inited + cmp byte [di], 0 + jnz .preboot_device_inited + cmp [.loader_block], -1 + jz @f + les bx, [.loader_block] + test byte [es:bx+1], 1 + jz @f + mov byte [di], 3 + jmp .preboot_device_inited @@: ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) - mov byte [di], 1 + mov byte [di], 1 .preboot_device_inited: ; following 4 lines set variables to 1 if its current value is 0 - cmp byte [di+preboot_dma-preboot_device], 1 - adc byte [di+preboot_dma-preboot_device], 0 - cmp byte [di+preboot_biosdisk-preboot_device], 1 - adc byte [di+preboot_biosdisk-preboot_device], 0 + cmp byte [di+preboot_dma-preboot_device], 1 + adc byte [di+preboot_dma-preboot_device], 0 + cmp byte [di+preboot_biosdisk-preboot_device], 1 + adc byte [di+preboot_biosdisk-preboot_device], 0 ; default value for VRR is OFF - cmp byte [di+preboot_vrrm-preboot_device], 0 - jnz @f - mov byte [di+preboot_vrrm-preboot_device], 2 + cmp byte [di+preboot_vrrm-preboot_device], 0 + jnz @f + mov byte [di+preboot_vrrm-preboot_device], 2 @@: ; notify user - _setcursor 5,2 + _setcursor 5,2 - mov si, linef - call printplain - mov si, start_msg - call print - mov si, time_msg - call print + mov si, linef + call printplain + mov si, start_msg + call print + mov si, time_msg + call print ; get start time - call .gettime - mov [.starttime], eax - mov word [.timer], .newtimer - mov word [.timer+2], cs + call .gettime + mov [.starttime], eax + mov word [.timer], .newtimer + mov word [.timer+2], cs .printcfg: - _setcursor 9,0 - mov si, current_cfg_msg - call print - mov si, curvideo_msg - call print + _setcursor 9,0 + mov si, current_cfg_msg + call print + mov si, curvideo_msg + call print - call draw_current_vmode + call draw_current_vmode - mov si, usebd_msg - cmp [preboot_biosdisk], 1 - call .say_on_off - mov si, vrrm_msg - cmp [preboot_vrrm], 1 - call .say_on_off - mov si, preboot_device_msg - call print - mov al, [preboot_device] - and eax, 7 - mov si, [preboot_device_msgs+eax*2] - call printplain + mov si, usebd_msg + cmp [preboot_biosdisk], 1 + call .say_on_off + mov si, vrrm_msg + cmp [preboot_vrrm], 1 + call .say_on_off + mov si, preboot_device_msg + call print + mov al, [preboot_device] + and eax, 7 + mov si, [preboot_device_msgs+eax*2] + call printplain .show_remarks: ; show remarks in gray color - mov di, ((21-num_remarks)*80 + 2)*2 - push 0xB800 - pop es - mov cx, num_remarks - mov si, remarks + mov di, ((21-num_remarks)*80 + 2)*2 + push 0xB800 + pop es + mov cx, num_remarks + mov si, remarks .write_remarks: - lodsw - push si - xchg ax, si - mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) - push di + lodsw + push si + xchg ax, si + mov ah, 1*16+7 ; background: blue (1), foreground: gray (7) + push di .write_remark: - lodsb - test al, al - jz @f - stosw - jmp .write_remark + lodsb + test al, al + jz @f + stosw + jmp .write_remark @@: - pop di - pop si - add di, 80*2 - loop .write_remarks + pop di + pop si + add di, 80*2 + loop .write_remarks .wait: - _setcursor 25,0 ; out of screen + _setcursor 25,0 ; out of screen ; set timer interrupt handler - cli - push 0 - pop es - push dword [es:8*4] - pop dword [.oldtimer] - push dword [.timer] - pop dword [es:8*4] -; mov eax, [es:8*4] -; mov [.oldtimer], eax -; mov eax, [.timer] -; mov [es:8*4], eax - sti + cli + push 0 + pop es + push dword [es:8*4] + pop dword [.oldtimer] + push dword [.timer] + pop dword [es:8*4] + sti ; wait for keypressed - xor ax,ax - int 16h - push ax + xor ax,ax + int 16h + push ax ; restore timer interrupt -; push 0 -; pop es - mov eax, [.oldtimer] - mov [es:8*4], eax - mov [.timer], eax + mov eax, [.oldtimer] + mov [es:8*4], eax + mov [.timer], eax - _setcursor 7,0 - mov si, space_msg - call printplain + _setcursor 7,0 + mov si, space_msg + call printplain ; clear remarks and restore normal attributes - push es - mov di, ((21-num_remarks)*80 + 2)*2 - push 0xB800 - pop es - mov cx, num_remarks - mov ax, ' ' + (1*16 + 15)*100h + push es + mov di, ((21-num_remarks)*80 + 2)*2 + push 0xB800 + pop es + mov cx, num_remarks + mov ax, ' ' + (1*16 + 15)*100h @@: - push cx - mov cx, 76 - rep stosw - pop cx - add di, 4*2 - loop @b - pop es - pop ax + push cx + mov cx, 76 + rep stosw + pop cx + add di, 4*2 + loop @b + pop es + pop ax ; switch on key - cmp al, 13 - jz .continue - or al, 20h - cmp al, 'a' - jz .change_a - cmp al, 'b' - jz .change_b - cmp al, 'c' - jz .change_c - cmp al, 'd' - jnz .show_remarks - _setcursor 15,0 - mov si, bdev - call print - mov bx, '14' - call getkey - mov [preboot_device], al - _setcursor 13,0 + cmp al, 13 + jz .continue + or al, 20h + cmp al, 'a' + jz .change_a + cmp al, 'b' + jz .change_b + cmp al, 'c' + jz .change_c + cmp al, 'd' + jnz .show_remarks + _setcursor 15,0 + mov si, bdev + call print + mov bx, '14' + call getkey + mov [preboot_device], al + _setcursor 13,0 .d: - mov [.bSettingsChanged], 1 - call clear_vmodes_table ;clear vmodes_table - jmp .printcfg + mov [.bSettingsChanged], 1 + call clear_vmodes_table ;clear vmodes_table + jmp .printcfg .change_a: .loops: - call draw_vmodes_table - _setcursor 25,0 ; out of screen - xor ax,ax - int 0x16 -; call clear_table_cursor ;clear current position of cursor + call draw_vmodes_table + _setcursor 25,0 ; out of screen + xor ax,ax + int 0x16 - mov si,word [cursor_pos] + mov si,word [cursor_pos] - cmp ah,0x48;x,0x48E0 ; up - jne .down - cmp si,modes_table - jbe .loops - sub word [cursor_pos],size_of_step - jmp .loops + cmp ah,0x48;x,0x48E0 ; up + jne .down + cmp si,modes_table + jbe .loops + sub word [cursor_pos],size_of_step + jmp .loops -.down: cmp ah,0x50;x,0x50E0 ; down - jne .pgup - cmp word[es:si+10],-1 - je .loops - add word [cursor_pos],size_of_step - jmp .loops +.down: cmp ah,0x50;x,0x50E0 ; down + jne .pgup + cmp word[es:si+10],-1 + je .loops + add word [cursor_pos],size_of_step + jmp .loops -.pgup: cmp ah,0x49 ; page up - jne .pgdn - sub si, size_of_step*long_v_table - cmp si, modes_table - jae @f - mov si, modes_table +.pgup: cmp ah,0x49 ; page up + jne .pgdn + sub si, size_of_step*long_v_table + cmp si, modes_table + jae @f + mov si, modes_table @@: - mov word [cursor_pos], si - mov si, word [home_cursor] - sub si, size_of_step*long_v_table - cmp si, modes_table - jae @f - mov si, modes_table + mov word [cursor_pos], si + mov si, word [home_cursor] + sub si, size_of_step*long_v_table + cmp si, modes_table + jae @f + mov si, modes_table @@: - mov word [home_cursor], si - jmp .loops + mov word [home_cursor], si + jmp .loops -.pgdn: cmp ah,0x51 ; page down - jne .enter - mov ax, [end_cursor] - add si, size_of_step*long_v_table - cmp si, ax - jb @f - mov si, ax - sub si, size_of_step +.pgdn: cmp ah,0x51 ; page down + jne .enter + mov ax, [end_cursor] + add si, size_of_step*long_v_table + cmp si, ax + jb @f + mov si, ax + sub si, size_of_step @@: - mov word [cursor_pos], si - mov si, word [home_cursor] - sub ax, size_of_step*long_v_table - add si, size_of_step*long_v_table - cmp si, ax - jb @f - mov si, ax + mov word [cursor_pos], si + mov si, word [home_cursor] + sub ax, size_of_step*long_v_table + add si, size_of_step*long_v_table + cmp si, ax + jb @f + mov si, ax @@: - mov word [home_cursor], si - jmp .loops + mov word [home_cursor], si + jmp .loops -.enter: cmp al,0x0D;x,0x1C0D ; enter - jne .loops - push word [cursor_pos] - pop bp - push word [es:bp] - pop word [x_save] - push word [es:bp+2] - pop word [y_save] - push word [es:bp+6] - pop word [number_vm] - mov word [preboot_graph],bp ;save choose - - jmp .d +.enter: cmp al,0x0D;x,0x1C0D ; enter + jne .loops + push word [cursor_pos] + pop bp + push word [es:bp] + pop word [x_save] + push word [es:bp+2] + pop word [y_save] + push word [es:bp+6] + pop word [number_vm] + mov word [preboot_graph],bp ;save choose + + jmp .d .change_b: - _setcursor 15,0 -; mov si, ask_dma -; call print -; mov bx, '13' -; call getkey -; mov [preboot_dma], al - mov si, ask_bd - call print - mov bx, '12' - call getkey - mov [preboot_biosdisk], al - _setcursor 11,0 - jmp .d + _setcursor 15,0 + mov si, ask_bd + call print + mov bx, '12' + call getkey + mov [preboot_biosdisk], al + _setcursor 11,0 + jmp .d .change_c: - _setcursor 15,0 - mov si, vrrmprint - call print - mov bx, '12' - call getkey - mov [preboot_vrrm], al - _setcursor 12,0 - jmp .d + _setcursor 15,0 + mov si, vrrmprint + call print + mov bx, '12' + call getkey + mov [preboot_vrrm], al + _setcursor 12,0 + jmp .d ;;;;;;;;;;;;;;;;;;;;;;;;;;;; .say_on_off: - pushf - call print - mov si, on_msg - popf - jz @f - mov si, off_msg -@@: jmp printplain + pushf + call print + mov si, on_msg + popf + jz @f + mov si, off_msg +@@: jmp printplain ; novesa and vervesa strings are not used at the moment of executing this code virtual at novesa .oldtimer dd ? @@ -670,515 +613,495 @@ virtual at novesa end virtual .loader_block dd -1 .gettime: - mov ah, 0 - int 1Ah - xchg ax, cx - shl eax, 10h - xchg ax, dx - ret + mov ah, 0 + int 1Ah + xchg ax, cx + shl eax, 10h + xchg ax, dx + ret .newtimer: - push ds - push cs - pop ds - pushf - call [.oldtimer] - pushad - call .gettime - sub eax, [.starttime] - sub ax, 18*5 - jae .timergo - neg ax - add ax, 18-1 - mov bx, 18 - xor dx, dx - div bx -if lang eq ru -; подождите 5 секунд, 4/3/2 секунды, 1 секунду - cmp al, 5 - mov cl, ' ' - jae @f - cmp al, 1 - mov cl, 'у' - jz @f - mov cl, 'ы' -@@: mov [time_str+9], cl -else if lang eq et - cmp al, 1 - ja @f - mov [time_str+9], ' ' - mov [time_str+10],' ' -@@: -else -; wait 5/4/3/2 seconds, 1 second - cmp al, 1 - mov cl, 's' - ja @f - mov cl, ' ' -@@: mov [time_str+9], cl -end if - add al, '0' - mov [time_str+1], al - mov si, time_msg - _setcursor 7,0 - call print - _setcursor 25,0 - popad - pop ds - iret -.timergo: - push 0 - pop es - mov eax, [.oldtimer] - mov [es:8*4], eax - mov sp, 0EC00h -.continue: - sti - _setcursor 6,0 - mov si, space_msg - call printplain - call printplain - _setcursor 6,0 - mov si, loading_msg - call print - _setcursor 15,0 - cmp [.bSettingsChanged], 0 - jz .load - cmp [.loader_block], -1 - jz .load - les bx, [.loader_block] - mov eax, [es:bx+3] - push ds - pop es - test eax, eax - jz .load - push eax - mov si, save_quest - call print -.waityn: - mov ah, 0 - int 16h - or al, 20h - cmp al, 'n' - jz .loadc - cmp al, 'y' - jnz .waityn - call putchar - mov byte [space_msg+80], 186 + push ds + push cs + pop ds + pushf + call [.oldtimer] + pushad + call .gettime + sub eax, [.starttime] + sub ax, 18*5 + jae .timergo + neg ax + add ax, 18-1 + mov bx, 18 + xor dx, dx + div bx - pop eax - push cs - push .cont - push eax - retf ;call back +; wait 5/4/3/2 seconds, 1 second + cmp al, 1 + mov cl, 's' + ja @f + mov cl, ' ' +@@: mov [time_str+9], cl + add al, '0' + mov [time_str+1], al + mov si, time_msg + _setcursor 7,0 + call print + _setcursor 25,0 + popad + pop ds + iret +.timergo: + push 0 + pop es + mov eax, [.oldtimer] + mov [es:8*4], eax + mov sp, 0EC00h +.continue: + sti + _setcursor 6,0 + mov si, space_msg + call printplain + call printplain + _setcursor 6,0 + mov si, loading_msg + call print + _setcursor 15,0 + cmp [.bSettingsChanged], 0 + jz .load + cmp [.loader_block], -1 + jz .load + les bx, [.loader_block] + mov eax, [es:bx+3] + push ds + pop es + test eax, eax + jz .load + push eax + mov si, save_quest + call print +.waityn: + mov ah, 0 + int 16h + or al, 20h + cmp al, 'n' + jz .loadc + cmp al, 'y' + jnz .waityn + call putchar + mov byte [space_msg+80], 186 + + pop eax + push cs + push .cont + push eax + retf ;call back .loadc: - pop eax + pop eax .cont: - push cs - pop ds - mov si, space_msg - mov byte [si+80], 0 - _setcursor 15,0 - call printplain - _setcursor 15,0 + push cs + pop ds + mov si, space_msg + mov byte [si+80], 0 + _setcursor 15,0 + call printplain + _setcursor 15,0 .load: ; \end{diamond}[02.12.2005] ; ASK GRAPHICS MODE - call set_vmode + call set_vmode ; GRAPHICS ACCELERATION ; force yes - mov [es:0x901C], byte 1 + mov [es:0x901C], byte 1 ; DMA ACCESS TO HD - mov al, [preboot_dma] - mov [es:0x901F], al + mov al, [preboot_dma] + mov [es:0x901F], al ; VRR_M USE - mov al,[preboot_vrrm] - mov [es:0x9030], al - mov [es:0x901E], byte 1 + mov al,[preboot_vrrm] + mov [es:0x9030], al + mov [es:0x901E], byte 1 ; BOOT DEVICE - mov al, [preboot_device] - dec al - mov [boot_dev], al + mov al, [preboot_device] + dec al + mov [boot_dev], al ; GET MEMORY MAP include 'detect/biosmem.inc' ; READ DISKETTE TO MEMORY - cmp [boot_dev],0 - jne no_sys_on_floppy - mov si,diskload - call print - xor ax, ax ; reset drive - xor dx, dx - int 0x13 + cmp [boot_dev],0 + jne no_sys_on_floppy + mov si,diskload + call print + 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 + 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 + + 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 - pusha - mov al, ch - shr ch, 2 - add al, ch - aam - xchg al, ah - add ax, '00' - mov si, pros - mov [si], ax - call printplain - popa - jmp .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 + pusha + mov al, ch + shr ch, 2 + add al, ch + aam + xchg al, ah + add ax, '00' + mov si, pros + mov [si], ax + call printplain + popa + 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 + 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 + 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 + 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 + 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 + 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 + 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 sayerr_plain + mov dx, 0x3f2 + mov al, 0 + out dx, al + mov si, memmovefailed + jmp sayerr_plain @@: - 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 + 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 + 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 - 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 + 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 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 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 - 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 + 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 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 + 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 byte [si+8*2+3], bh + push bx - mov di, 2 ; First data cluster + 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 + 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 !!! + test word [es:bx+di+0xB200], 0xFFF ; TODO: may not be 0xB200 !!! @@: - jz .skip + 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 + ;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 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 + 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 [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 + 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' - mov si, pros - cmp [si], ax - jz @f - mov [si], ax - call printplain + xchg ax, di + mov cx, 100 + mul cx + div di + aam + xchg al, ah + add ax, '00' + mov si, pros + cmp [si], ax + jz @f + mov [si], ax + call printplain @@: - popa - inc di - cmp di, word [end_of_FAT] ; max number of cluster - jnz .read_loop - pop bx ; clear stack + popa + inc di + cmp di, word [end_of_FAT] ; max number of cluster + jnz .read_loop + pop bx ; clear stack ok_sys_on_floppy: - mov si, backspace2 - call printplain - mov si, okt - call printplain + mov si, backspace2 + call printplain + mov si, okt + call printplain 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 + xor ax, ax ; reset drive + xor dx, dx + int 0x13 + mov dx, 0x3f2 ; floppy motor off + mov al, 0 + out dx, al ; SET GRAPHICS - xor ax, ax - mov es, ax + xor ax, ax + mov es, ax - mov ax, [es:0x9008] ; vga & 320x200 - mov bx, ax - cmp ax, 0x13 - je setgr - cmp ax, 0x12 - je setgr - mov ax, 0x4f02 ; Vesa + mov bx, [es:0x9008] ; vga & 320x200 +; mov bx, ax +; cmp ax, 0x13 +; je setgr +; cmp ax, 0x12 +; je setgr + mov ax, 0x4f02 ; Vesa setgr: - int 0x10 - test ah, ah - mov si, fatalsel - jnz v_mode_error + int 0x10 + test ah, ah + mov si, fatalsel + jnz v_mode_error ; set mode 0x12 graphics registers: - cmp bx, 0x12 - jne gmok2 - - mov al, 0x05 - mov dx, 0x03ce - push dx - out dx, al ; select GDC mode register - mov al, 0x02 - inc dx - out dx, al ; set write mode 2 - - mov al, 0x02 - mov dx, 0x03c4 - out dx, al ; select VGA sequencer map mask register - mov al, 0x0f - inc dx - out dx, al ; set mask for all planes 0-3 - - mov al, 0x08 - pop dx - out dx, al ; select GDC bit mask register - ; for writes to 0x03cf +; cmp bx, 0x12 +; jne gmok2 +; mov al, 0x05 +; mov dx, 0x03ce +; push dx +; out dx, al ; select GDC mode register +; mov al, 0x02 +; inc dx +; out dx, al ; set write mode 2 +; mov al, 0x02 +; mov dx, 0x03c4 +; out dx, al ; select VGA sequencer map mask register +; mov al, 0x0f +; inc dx +; out dx, al ; set mask for all planes 0-3 +; mov al, 0x08 +; pop dx +; out dx, al ; select GDC bit mask register + ; for writes to 0x03cf gmok2: - push ds - pop es + push ds + pop es diff --git a/kernel/branches/Kolibri-A/trunk/bus/HT.inc b/kernel/branches/Kolibri-A/trunk/bus/HT.inc index 2bbdc13ffb..e9592fb156 100644 --- a/kernel/branches/Kolibri-A/trunk/bus/HT.inc +++ b/kernel/branches/Kolibri-A/trunk/bus/HT.inc @@ -3,6 +3,7 @@ ;; Copyright (C) 2010 KolibriOS team. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; +;; HT.inc ;; ;; ;; ;; ;; AMD HyperTransport bus control ;; ;; ;; @@ -22,6 +23,9 @@ HTIU_NB_INDEX equ 0xF0000094 ; HyperTransport indirect config space access ; This code is a part of Kolibri-A and will only work with AMD RS760+ chipsets ; ;============================================================================= + +org $-OS_BASE ; physical addresses needed at initial stage + align 4 ;------------------------------------------ @@ -71,7 +75,7 @@ rs7xx_nbconfig_write_pci: align 4 rs7xx_unlock_bar3: mov eax, NB_MISC_INDEX - mov ebx, 0x080 ; reg#0; write-enable + mov ebx, 0x080 ; NBMISCIND:0x0; write-enable call rs7xx_nbconfig_write_pci ; set index mov eax, NB_MISC_DATA call rs7xx_nbconfig_read_pci ; read data @@ -84,6 +88,90 @@ rs7xx_unlock_bar3: call rs7xx_nbconfig_write_pci ; set index ret + + +;*************************************************************************** +; Function +; rs7xx_pcie_init: +; +; Description +; PCIe extended (memory-mapped) config space detection +; +;*************************************************************************** + +align 4 + +rs7xx_pcie_init: + call rs7xx_unlock_bar3 + mov al, 0x7C ; NB_IOC_CFG_CNTL + call rs7xx_nbconfig_read_pci + mov ebx, eax +; call rs7xx_nbconfig_flush_pci + test ebx, 0x20000000 ; BAR3 locked? + jz $ + mov al, 0x84 ; NB_PCI_ARB + call rs7xx_nbconfig_read_pci + shr eax,16 + and ax, 7 ; the Bus range lays here: + jnz @f + mov ax, 8 ; 1=2Mb, 2=4MB, 3=8MB, 4=16MB +@@: + mov word[PCIe_bus_range-OS_BASE], ax ; 5=32Mb, 6=64MB, 7=128Mb, 8=256Mb + mov cl, al + call rs7xx_nbconfig_flush_pci + dec cl ; <4M ? + jz @f + dec cl ; one PDE needed anyway +@@: + mov ebx, 1 + shl ebx, cl + mov word[mmio_pcie_cfg_pdes-OS_BASE], bx ; 1..64 PDE(s) needed, + shl ebx, 22 + mov dword[mmio_pcie_cfg_lim-OS_BASE], ebx ; or 4..256Mb space to map + dec dword[mmio_pcie_cfg_lim-OS_BASE] + + mov al, 0x1C ; NB_BAR3_PCIEXP_MMCFG + call rs7xx_nbconfig_read_pci + mov ebx, eax + call rs7xx_nbconfig_flush_pci + mov eax, ebx + and eax, 0xFFE00000 ; valid bits [31..21] + jz $ ; NB BAR3 may be invisible! +.addr_found: + mov dword[mmio_pcie_cfg_addr-OS_BASE], eax ; physical address (lower 32 bits) + add dword[mmio_pcie_cfg_lim-OS_BASE], eax + + or eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW) ; by the way, UW is unsafe! + mov ecx, PCIe_CONFIG_SPACE ; linear address + mov ebx, ecx + shr ebx, 20 + add ebx, (sys_pgdir - OS_BASE) ; PgDir entry @ + mov dl, byte[mmio_pcie_cfg_pdes-OS_BASE] ; 1 page = 4M in address space + cmp dl, 0x34 ; =(USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4M + jb @f + mov dl, 0x33 + mov byte[mmio_pcie_cfg_pdes-OS_BASE], dl +@@: + xor dx, dx ; PDEs counter +.write_pde: + mov dword[ebx], eax ; map 4 buses + add bx, 4 ; new PDE + add eax, 0x400000 ; +4M phys. + add ecx, 0x400000 ; +4M lin. + cmp dl, byte[mmio_pcie_cfg_pdes-OS_BASE] + jae .pcie_cfg_mapped + inc dl + jmp .write_pde +; mov eax, cr3 +; mov cr3, eax ; flush TLB +.pcie_cfg_mapped: + ret ; <<< OK >>> + + +; ================================================================================ + +org OS_BASE+$ ; back to the linear address space + ;-------------------------------------------------------------- align 4 rs780_read_misc: @@ -192,96 +280,4 @@ rs780_write_htiu: -;*************************************************************************** -; Function -; rs7xx_pcie_init: -; -; Description -; PCIe extended (memory-mapped) config space detection -; -;*************************************************************************** - -align 4 - -rs7xx_pcie_init: - call rs7xx_unlock_bar3 - mov al, 0x7C ; NB_IOC_CFG_CNTL - call rs7xx_nbconfig_read_pci - mov ebx, eax - call rs7xx_nbconfig_flush_pci - test ebx, 0x20000000 ; BAR3 locked? - jz .rs7xx_pcie_blocked - mov al, 0x84 ; NB_PCI_ARB - call rs7xx_nbconfig_read_pci - shr eax,16 - and ax, 7 ; the Bus range lays here: - jnz @f - mov ax, 8 ; 1=2Mb, 2=4MB, 3=8MB, 4=16MB -@@: - mov [PCIe_bus_range], ax ; 5=32Mb, 6=64MB, 7=128Mb, 8=256Mb - mov cl, al - call rs7xx_nbconfig_flush_pci - dec cl ; <4M ? - jnz @f - inc cl ; one PDE needed anyway -@@: - dec cl - mov ebx, 1 - shl ebx, cl - mov [mmio_pcie_cfg_pdes], bx ; 1..64 PDE(s) needed, - shl ebx, 22 - mov [mmio_pcie_cfg_lim], ebx ; or 4..256Mb space to map - dec [mmio_pcie_cfg_lim] - - mov al, 0x1C ; NB_BAR3_PCIEXP_MMCFG - call rs7xx_nbconfig_read_pci - mov ebx, eax - call rs7xx_nbconfig_flush_pci - mov eax, ebx - and eax, 0xFFE00000 ; valid bits [31..21] - jz .rs7xx_pcie_blocked ; NB BAR3 may be invisible! - ; try to get pcie ecfg address indirectly -.addr_found: - mov [mmio_pcie_cfg_addr], eax ; physical address (lower 32 bits) - add [mmio_pcie_cfg_lim], eax - - or eax, (PG_SHARED + PG_LARGE + PG_UW) ; by the way, UW is unsafe! - mov ecx, PCIe_CONFIG_SPACE ; linear address - mov ebx, ecx - shr ebx, 20 - add ebx, sys_pgdir ; PgDir entry @ - mov dl, byte[mmio_pcie_cfg_pdes] ; 1 page = 4M in address space - cmp dl, (USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4194304 - jb @f - mov dl, ((USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4194304) - 1 - mov byte[mmio_pcie_cfg_pdes], dl -@@: - xor dx, dx ; PDEs counter -@@: - mov dword[ebx], eax ; map 4 buses - add bx, 4 ; new PDE - add eax, 0x400000 ; +4M phys. - add ecx, 0x400000 ; +4M lin. - cmp dl, byte[mmio_pcie_cfg_pdes] - jnc .pcie_cfg_mapped - inc dl - jmp @b - mov eax, cr3 - mov cr3, eax ; flush TLB -.pcie_cfg_mapped: - mov esi, boot_pcie_ok - call boot_log - ret ; <<< OK >>> -.rs7xx_pcie_fail: - mov esi, boot_rs7xx_fail - call boot_log - jmp $ -.rs7xx_pcie_blocked: - mov esi, boot_rs7xx_blkd - call boot_log - jmp $ - - - - diff --git a/kernel/branches/Kolibri-A/trunk/bus/pci/PCIe.inc b/kernel/branches/Kolibri-A/trunk/bus/pci/PCIe.inc index 72d2ed33c4..9c160d4686 100644 --- a/kernel/branches/Kolibri-A/trunk/bus/pci/PCIe.inc +++ b/kernel/branches/Kolibri-A/trunk/bus/pci/PCIe.inc @@ -87,10 +87,9 @@ pci_ext_config: jb .check_HT_mmio .pcie_failed: - mov esi, boot_pcie_fail - call boot_log - xor eax, eax - ret ; <<<<<<<<< FAILURE >>>>>>>>> + jmp $ +; xor eax, eax +; ret ; <<<<<<<<< FAILURE >>>>>>>>> ;-------------------------------------------------------------------------- diff --git a/kernel/branches/Kolibri-A/trunk/const.inc b/kernel/branches/Kolibri-A/trunk/const.inc index 783927d070..c0039d0202 100644 --- a/kernel/branches/Kolibri-A/trunk/const.inc +++ b/kernel/branches/Kolibri-A/trunk/const.inc @@ -252,8 +252,13 @@ Screen_Max_Y equ (OS_BASE+0x000FE04) BytesPerScanLine equ (OS_BASE+0x000FE08) SCR_MODE equ (OS_BASE+0x000FE0C) -LFBAddress equ (OS_BASE+0x000FE80) -UserDMAaddr equ (OS_BASE+0x000FE84) +mmio_pcie_cfg_addr equ (OS_BASE+0x000FE74) +mmio_pcie_cfg_lim equ (OS_BASE+0x000FE78) +mmio_pcie_cfg_pdes equ (OS_BASE+0x000FE7C) +PCIe_bus_range equ (OS_BASE+0x000FE7E) + +UserDMAaddr equ (OS_BASE+0x000FE80) +LFBAddress equ (OS_BASE+0x000FE84) BTN_ADDR equ (OS_BASE+0x000FE88) MEM_AMOUNT equ (OS_BASE+0x000FE8C) diff --git a/kernel/branches/Kolibri-A/trunk/data32.inc b/kernel/branches/Kolibri-A/trunk/data32.inc index 971e1e8609..3da4721830 100644 --- a/kernel/branches/Kolibri-A/trunk/data32.inc +++ b/kernel/branches/Kolibri-A/trunk/data32.inc @@ -57,21 +57,15 @@ keymap_alt: 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_resirqports db 'Reserving IRQs & ports',0 ; boot_setrports db 'Setting addresses for IRQs',0 boot_setostask db 'Setting OS task',0 boot_allirqs db 'Unmasking all IRQs',0 boot_tsc db 'Reading TSC',0 boot_cpufreq db 'CPU frequency is ',' ',' MHz',0 -; boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0 -; boot_pal_vga db 'Setting VGA 640x480 palette',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 - boot_pcie_ok db 'PCIe config set OK',0 - boot_pcie_fail db 'PCIe config XXX failed XXX',0 - boot_rs7xx_fail db 'RS7xx config XXX failed XXX',0 - boot_rs7xx_blkd db 'RS7xx config ---------- FAILED -----------',0 if preboot_blogesc boot_tasking db 'All set - press ESC to start',0 end if @@ -87,7 +81,7 @@ msg_www db 'please visit www.kolibrios.org',13,10,0 msg_CR db 13,10,0 aSis db 'SIS',0 -intel_str db "GenuineIntel",0 +;intel_str db "GenuineIntel",0 AMD_str db "AuthenticAMD",0 ;szSound db 'SOUND',0 @@ -469,4 +463,6 @@ BiosDisksData rb 200h BiosDiskCaches rb 80h*(cache_ide1-cache_ide0) BiosDiskPartitions rd 80h +diff16 "UGlobals start ",0,$ + IncludeUGlobals diff --git a/kernel/branches/Kolibri-A/trunk/init.inc b/kernel/branches/Kolibri-A/trunk/init.inc index f340571625..678c751ecb 100644 --- a/kernel/branches/Kolibri-A/trunk/init.inc +++ b/kernel/branches/Kolibri-A/trunk/init.inc @@ -8,380 +8,316 @@ $Revision$ -MEM_WB equ 6 ;write-back memory -MEM_WC equ 1 ;write combined memory -MEM_UC equ 0 ;uncached memory +MEM_WB equ 6 ;write-back memory +MEM_WC equ 1 ;write combined memory +MEM_UC equ 0 ;uncached memory +; ====================================================================== +align 4 +preinit_mem: +; clear [0x280000..HEAP_BASE] + xor eax,eax + mov edi,0x280000 ; 0x280000 = ramdisk FAT ? + mov ecx,(HEAP_BASE-OS_BASE-0x280000) / 4 + cld + rep stosd + +; clear [0x40000..0x90000] + mov edi,0x50000 ; 0x50000 is somewhere inside kernel code? + mov ecx,(0x90000-0x50000)/4 + rep stosd + +; clear undefined kernel globals + mov edi, endofcode-OS_BASE + mov ecx, (uglobals_size/4)+4 + rep stosd + +; save [0..0xffff] + xor esi, esi + mov edi,0x2F0000 ; low mem storage area + mov ecx, 0x10000 / 4 + rep movsd +; clear [0x1000..0x0ffff] + mov edi,0x1000 + mov ecx,0xf000 / 4 + rep stosd + +; clear table + mov edi, sys_pgdir-OS_BASE + mov ecx, 4096/4 + rep stosd + ret + +; ====================================================================== align 4 proc init_mem -; calculate maximum allocatable address and number of allocatable pages - mov edi, BOOT_VAR-OS_BASE + 0x9104 - mov ecx, [edi-4] - xor esi, esi ; esi will hold total amount of memory - xor edx, edx ; edx will hold maximum allocatable address -.calcmax: -; round all to pages - mov eax, [edi] - test eax, 0xFFF - jz @f - neg eax - and eax, 0xFFF - add [edi], eax - adc dword [edi+4], 0 - sub [edi+8], eax - sbb dword [edi+12], 0 - jc .unusable -@@: - and dword [edi+8], not 0xFFF - jz .unusable -; ignore memory after 4 Gb - cmp dword [edi+4], 0 - jnz .unusable - mov eax, [edi] - cmp dword [edi+12], 0 - jnz .overflow - add eax, [edi+8] - jnc @f -.overflow: - mov eax, 0xFFFFF000 -@@: - cmp edx, eax - jae @f - mov edx, eax -@@: - sub eax, [edi] - mov [edi+8], eax - add esi, eax - jmp .usable -.unusable: - and dword [edi+8], 0 -.usable: - add edi, 20 - loop .calcmax -.calculated: - mov [MEM_AMOUNT-OS_BASE], esi - mov [pg_data.mem_amount-OS_BASE], esi - shr esi, 12 - mov [pg_data.pages_count-OS_BASE], esi - shr edx, 12 - add edx, 31 - and edx, not 31 - shr edx, 3 - mov [pg_data.pagemap_size-OS_BASE], edx + mov esi, (PCIe_CONFIG_SPACE-OS_BASE) ; esi will hold total amount of memory + mov edx, esi ; edx will hold maximum allocatable address - add edx, (sys_pgmap-OS_BASE)+4095 - and edx, not 4095 - mov [tmp_page_tabs], edx + mov [MEM_AMOUNT-OS_BASE], esi + mov [pg_data.mem_amount-OS_BASE], esi + shr esi, 12 + mov [pg_data.pages_count-OS_BASE], esi ; max number of PTEs ? - mov edx, esi - and edx, -1024 - cmp edx, (OS_BASE/4096) - jbe @F - mov edx, (OS_BASE/4096) - jmp .set -@@: - cmp edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096 - jae .set - mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096 -.set: - mov [pg_data.kernel_pages-OS_BASE], edx - shr edx, 10 - mov [pg_data.kernel_tables-OS_BASE], edx + shr edx, 12 + add edx, 31 + and edx, not 31 + shr edx, 3 + mov [pg_data.pagemap_size-OS_BASE], edx ; size of sys_pgmap structure - xor eax, eax - mov edi, sys_pgdir-OS_BASE - mov ecx, 4096/4 - cld - rep stosd + add edx, (sys_pgmap-OS_BASE)+4095 + and edx, not 4095 + mov [tmp_page_tabs], edx ; free zone to build PTEs - mov edx, (sys_pgdir-OS_BASE)+ 0x800; (OS_BASE shr 20) + mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096 + mov [pg_data.kernel_pages -OS_BASE], edx + shr edx, 10 + mov [pg_data.kernel_tables-OS_BASE], edx - mov ebx, cr4 - or ebx, CR4_PSE - mov eax, PG_LARGE+PG_SW - mov cr4, ebx - dec [pg_data.kernel_tables-OS_BASE] + mov edx, (sys_pgdir-OS_BASE)+ 0x800 ; (0x800 = OS_BASE shr 20) - mov [edx], eax - add edx, 4 + mov ebx, cr4 + or ebx, CR4_PSE + mov eax, PG_LARGE+PG_SW + mov cr4, ebx + dec [pg_data.kernel_tables-OS_BASE] - mov edi, [tmp_page_tabs] - mov ecx, [pg_data.kernel_tables-OS_BASE] - shl ecx, 10 - xor eax, eax - rep stosd + mov [edx], eax ; map first (physical) 4M bytes + add edx, 4 + + mov edi, [tmp_page_tabs] + mov ecx, [pg_data.kernel_pages -OS_BASE] ; safety cleaning of already-zeroed space + xor eax, eax + rep stosd + + mov ecx, [pg_data.kernel_tables-OS_BASE] ; build some PDEs to hold empty PTEs + mov eax, [tmp_page_tabs] + or eax, PG_SW + mov edi, edx ; edi = sys_pgdir+0x804 - mov ecx, [pg_data.kernel_tables-OS_BASE] - mov eax, [tmp_page_tabs] - or eax, PG_SW - mov edi, edx - .map_kernel_tabs: - stosd - add eax, 0x1000 - dec ecx - jnz .map_kernel_tabs + stosd + add eax, 0x1000 + dec ecx + jnz .map_kernel_tabs - mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE +; map pagetables to linear space + mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE - mov edi, (sys_pgdir-OS_BASE) - lea esi, [edi+(OS_BASE shr 20)] - movsd - movsd - ret + mov edi, (sys_pgdir-OS_BASE) + lea esi, [edi+(OS_BASE shr 20)] + movsd + movsd + ret endp align 4 proc init_page_map ; mark all memory as unavailable - mov edi, sys_pgmap-OS_BASE - mov ecx, [pg_data.pagemap_size-OS_BASE] - shr ecx, 2 - xor eax, eax - cld - rep stosd + mov edi, sys_pgmap-OS_BASE + mov ecx, [pg_data.pagemap_size-OS_BASE] + shr ecx, 2 + xor eax, eax + cld + rep stosd ; scan through memory map and mark free areas as available - mov ebx, BOOT_VAR-OS_BASE + 0x9104 - mov edx, [ebx-4] + mov ebx, BOOT_VAR-OS_BASE + 0x9104 + mov edx, [ebx-4] .scanmap: - mov ecx, [ebx+8] - shr ecx, 12 ; ecx = number of pages - jz .next - mov edi, [ebx] - shr edi, 12 ; edi = first page - mov eax, edi - shr edi, 5 - shl edi, 2 - add edi, sys_pgmap-OS_BASE - and eax, 31 - jz .startok - add ecx, eax - sub ecx, 32 - jbe .onedword - push ecx - mov ecx, eax - or eax, -1 - shl eax, cl - or [edi], eax - add edi, 4 - pop ecx + mov ecx, [ebx+8] + shr ecx, 12 ; ecx = number of pages + jz .next + mov edi, [ebx] + shr edi, 12 ; edi = first page + mov eax, edi + shr edi, 5 + shl edi, 2 + add edi, sys_pgmap-OS_BASE + and eax, 31 + jz .startok + add ecx, eax + sub ecx, 32 + jbe .onedword + push ecx + mov ecx, eax + or eax, -1 + shl eax, cl + or [edi], eax + add edi, 4 + pop ecx .startok: - push ecx - shr ecx, 5 - or eax, -1 - rep stosd - pop ecx - and ecx, 31 - neg eax - shl eax, cl - dec eax - or [edi], eax - jmp .next + push ecx + shr ecx, 5 + or eax, -1 + rep stosd + pop ecx + and ecx, 31 + neg eax + shl eax, cl + dec eax + or [edi], eax + jmp .next .onedword: - add ecx, 32 - sub ecx, eax + add ecx, 32 + sub ecx, eax @@: - bts [edi], eax - inc eax - loop @b + bts [edi], eax + inc eax + loop @b .next: - add ebx, 20 - dec edx - jnz .scanmap + add ebx, 20 + dec edx + jnz .scanmap ; mark kernel memory as allocated (unavailable) - mov ecx, [tmp_page_tabs] - mov edx, [pg_data.pages_count-OS_BASE] - shr ecx, 12 - add ecx, [pg_data.kernel_tables-OS_BASE] - sub edx, ecx - mov [pg_data.pages_free-OS_BASE], edx + mov ecx, [tmp_page_tabs] + mov edx, [pg_data.pages_count-OS_BASE] + shr ecx, 12 + add ecx, [pg_data.kernel_tables-OS_BASE] + sub edx, ecx + mov [pg_data.pages_free-OS_BASE], edx - mov edi, sys_pgmap-OS_BASE - mov ebx, ecx - shr ecx, 5 - xor eax, eax - rep stosd + mov edi, sys_pgmap-OS_BASE + mov ebx, ecx + shr ecx, 5 + xor eax, eax + rep stosd - not eax - mov ecx, ebx - and ecx, 31 - shl eax, cl - and [edi], eax - add edi, OS_BASE - mov [page_start-OS_BASE], edi; + not eax + mov ecx, ebx + and ecx, 31 + shl eax, cl + and [edi], eax + add edi, OS_BASE + mov [page_start-OS_BASE], edi; - mov ebx, sys_pgmap - add ebx, [pg_data.pagemap_size-OS_BASE] - mov [page_end-OS_BASE], ebx + mov ebx, sys_pgmap + add ebx, [pg_data.pagemap_size-OS_BASE] + mov [page_end-OS_BASE], ebx - mov [pg_data.pg_mutex-OS_BASE], 0 - ret + mov [pg_data.pg_mutex-OS_BASE], 0 + ret endp align 4 init_BIOS32: - mov edi, 0xE0000 + mov edi, 0xE0000 .pcibios_nxt: - cmp dword[edi], '_32_' ; "magic" word - je .BIOS32_found + cmp dword[edi], '_32_' ; "magic" word + je .BIOS32_found .pcibios_nxt2: - add edi, 0x10 - cmp edi, 0xFFFF0 - je .BIOS32_not_found - jmp .pcibios_nxt + add edi, 0x10 + cmp edi, 0xFFFF0 + je .BIOS32_not_found + jmp .pcibios_nxt .BIOS32_found: ; magic word found, check control summ - movzx ecx, byte[edi + 9] - shl ecx, 4 - mov esi, edi - xor eax, eax - cld ; paranoia + movzx ecx, byte[edi + 9] + shl ecx, 4 + mov esi, edi + xor eax, eax + cld ; paranoia @@: lodsb - add ah, al - loop @b - jnz .pcibios_nxt2 ; control summ must be zero + add ah, al + loop @b + jnz .pcibios_nxt2 ; control summ must be zero ; BIOS32 service found ! - mov ebp, [edi + 4] - mov [bios32_entry], ebp + mov ebp, [edi + 4] + mov [bios32_entry], ebp ; check PCI BIOS present - mov eax, '$PCI' - xor ebx, ebx - push cs ; special for 'ret far' from BIOS - call ebp - test al, al - jnz .PCI_BIOS32_not_found + mov eax, '$PCI' + xor ebx, ebx + push cs ; special for 'ret far' from BIOS + call ebp + test al, al + jnz .PCI_BIOS32_not_found ; чфхё№ ёючфр■Єё  фшёъЁшяЄюЁ√ фы  PCI BIOS - add ebx, OS_BASE - dec ecx - mov [(pci_code_32-OS_BASE)], cx ;limit 0-15 - mov [(pci_data_32-OS_BASE)], cx ;limit 0-15 + add ebx, OS_BASE + dec ecx + mov [(pci_code_32-OS_BASE)], cx ;limit 0-15 + mov [(pci_data_32-OS_BASE)], cx ;limit 0-15 - mov [(pci_code_32-OS_BASE)+2], bx ;base 0-15 - mov [(pci_data_32-OS_BASE)+2], bx ;base 0-15 + mov [(pci_code_32-OS_BASE)+2], bx ;base 0-15 + mov [(pci_data_32-OS_BASE)+2], bx ;base 0-15 - shr ebx, 16 - mov [(pci_code_32-OS_BASE)+4], bl ;base 16-23 - mov [(pci_data_32-OS_BASE)+4], bl ;base 16-23 + shr ebx, 16 + mov [(pci_code_32-OS_BASE)+4], bl ;base 16-23 + mov [(pci_data_32-OS_BASE)+4], bl ;base 16-23 - shr ecx, 16 - and cl, 0x0F - mov ch, bh - add cx, D32 - mov [(pci_code_32-OS_BASE)+6], cx ;lim 16-19 & - mov [(pci_data_32-OS_BASE)+6], cx ;base 24-31 + shr ecx, 16 + and cl, 0x0F + mov ch, bh + add cx, D32 + mov [(pci_code_32-OS_BASE)+6], cx ;lim 16-19 & + mov [(pci_data_32-OS_BASE)+6], cx ;base 24-31 - mov [(pci_bios_entry-OS_BASE)], edx - ; jmp .end + mov [(pci_bios_entry-OS_BASE)], edx + ; jmp .end .PCI_BIOS32_not_found: ; чфхё№ фюыцэр чряюыэ Єё  pci_emu_dat .BIOS32_not_found: .end: - ret + ret align 4 -proc test_cpu - locals - cpu_type dd ? - cpu_id dd ? - cpu_Intel dd ? - cpu_AMD dd ? - endl +test_cpu: ; only AMD machines supported - xor eax, eax - mov [cpu_type], eax - mov [cpu_caps-OS_BASE], eax - mov [cpu_caps+4-OS_BASE], eax + xor eax, eax + mov [cpu_caps-OS_BASE], eax + mov [cpu_caps+4-OS_BASE], eax - pushfd - pop eax - mov ecx, eax - xor eax, 0x40000 - push eax - popfd - pushfd - pop eax - xor eax, ecx - mov [cpu_type], CPU_386 - jz .end_cpuid - push ecx - popfd + pushfd + pop eax + mov ecx, eax + xor eax, 0x40000 + push eax + popfd + pushfd + pop eax + xor eax, ecx + jz $ ; 386 + push ecx + popfd - mov [cpu_type], CPU_486 - mov eax, ecx - xor eax, 0x200000 - push eax - popfd - pushfd - pop eax - xor eax, ecx - je .end_cpuid - mov [cpu_id], 1 + mov eax, ecx + xor eax, 0x200000 + push eax + popfd + pushfd + pop eax + xor eax, ecx + je $ ; 486 - xor eax, eax - cpuid + xor eax, eax + cpuid - mov [cpu_vendor-OS_BASE], ebx - mov [cpu_vendor+4-OS_BASE], edx - mov [cpu_vendor+8-OS_BASE], ecx - cmp ebx, dword [intel_str-OS_BASE] - jne .check_AMD - cmp edx, dword [intel_str+4-OS_BASE] - jne .check_AMD - cmp ecx, dword [intel_str+8-OS_BASE] - jne .check_AMD - mov [cpu_Intel], 1 - cmp eax, 1 - jl .end_cpuid - mov eax, 1 - cpuid - mov [cpu_sign-OS_BASE], eax - mov [cpu_info-OS_BASE], ebx - mov [cpu_caps-OS_BASE], edx - mov [cpu_caps+4-OS_BASE],ecx + mov [cpu_vendor-OS_BASE], ebx + mov [cpu_vendor+4-OS_BASE], edx + mov [cpu_vendor+8-OS_BASE], ecx + + cmp ebx, dword [AMD_str-OS_BASE] + jne $ + cmp edx, dword [AMD_str+4-OS_BASE] + jne $ + cmp ecx, dword [AMD_str+8-OS_BASE] + jne $ + cmp eax, 1 + jl $ + mov eax, 1 + cpuid + mov [cpu_sign-OS_BASE], eax + mov [cpu_info-OS_BASE], ebx + mov [cpu_caps-OS_BASE], edx + mov [cpu_caps+4-OS_BASE],ecx + shr eax, 8 + and eax, 0x0f + ret - shr eax, 8 - and eax, 0x0f - ret -.end_cpuid: - mov eax, [cpu_type] - ret - -.check_AMD: - cmp ebx, dword [AMD_str-OS_BASE] - jne .unknown - cmp edx, dword [AMD_str+4-OS_BASE] - jne .unknown - cmp ecx, dword [AMD_str+8-OS_BASE] - jne .unknown - mov [cpu_AMD], 1 - cmp eax, 1 - jl .unknown - mov eax, 1 - cpuid - mov [cpu_sign-OS_BASE], eax - mov [cpu_info-OS_BASE], ebx - mov [cpu_caps-OS_BASE], edx - mov [cpu_caps+4-OS_BASE],ecx - shr eax, 8 - and eax, 0x0f - ret -.unknown: - mov eax, 1 - cpuid - mov [cpu_sign-OS_BASE], eax - mov [cpu_info-OS_BASE], ebx - mov [cpu_caps-OS_BASE], edx - mov [cpu_caps+4-OS_BASE],ecx - shr eax, 8 - and eax, 0x0f - ret -endp diff --git a/kernel/branches/Kolibri-A/trunk/kernel.asm b/kernel/branches/Kolibri-A/trunk/kernel.asm index 67423fc2d0..b1cf9a93d7 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel.asm +++ b/kernel/branches/Kolibri-A/trunk/kernel.asm @@ -61,7 +61,7 @@ include 'macros.inc' $Revision$ -USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices +USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices ; Enabling the next line will enable serial output console ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used @@ -70,14 +70,14 @@ include "proc32.inc" include "kglobals.inc" include "const.inc" -max_processes equ 255 -tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 +max_processes equ 255 +tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 -os_stack equ (os_data_l-gdts) ; GDTs +os_stack equ (os_data_l-gdts) ; GDTs os_code equ (os_code_l-gdts) graph_data equ (3+graph_data_l-gdts) -tss0 equ (tss0_l-gdts) +tss0 equ (tss0_l-gdts) app_code equ (3+app_code_l-gdts) app_data equ (3+app_data_l-gdts) app_tls equ (3+tls_data_l-gdts) @@ -116,8 +116,8 @@ pci_data_sel equ (pci_data_32-gdts) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; use16 - org 0x0 - jmp start_of_code + org 0x0 + jmp start_of_code version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 @@ -130,6 +130,8 @@ include "boot/bootcode.inc" ; 16 bit system boot code include "bus/pci/pci16.inc" include "detect/biosdisk.inc" +diff16 "end of code16 ",0,$ + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; SWITCH TO 32 BIT PROTECTED MODE ;; @@ -139,124 +141,109 @@ include "detect/biosdisk.inc" ; CR0 Flags - Protected mode and Paging - mov ecx, CR0_PE + mov ecx, CR0_PE ; Enabling 32 bit protected mode - sidt [cs:old_ints_h] + sidt [cs:old_ints_h] - cli ; disable all irqs - cld - mov al,255 ; mask all irqs - out 0xa1,al - out 0x21,al - l.5: in al, 0x64 ; Enable A20 - test al, 2 - jnz l.5 - mov al, 0xD1 - out 0x64, al - l.6: in al, 0x64 - test al, 2 - jnz l.6 - mov al, 0xDF - out 0x60, al - l.7: in al, 0x64 - test al, 2 - jnz l.7 - mov al, 0xFF - out 0x64, al + cli ; disable all irqs + cld + mov al,255 ; mask all irqs + out 0xa1,al + out 0x21,al + l.5: in al, 0x64 ; Enable A20 + test al, 2 + jnz l.5 + mov al, 0xD1 + out 0x64, al + l.6: in al, 0x64 + test al, 2 + jnz l.6 + mov al, 0xDF + out 0x60, al + l.7: in al, 0x64 + test al, 2 + jnz l.7 + mov al, 0xFF + out 0x64, al - lgdt [cs:tmp_gdt] ; Load GDT - mov eax, cr0 ; protected mode - or eax, ecx - and eax, 10011111b *65536*256 + 0xffffff ; caching enabled - mov cr0, eax - jmp pword os_code:B32 ; jmp to enable 32 bit mode + lgdt [cs:tmp_gdt] ; Load GDT + mov eax, cr0 ; protected mode + or eax, ecx + and eax, 10011111b *65536*256 + 0xffffff ; caching enabled + mov cr0, eax + jmp pword os_code:B32 ; jmp to enable 32 bit mode align 8 tmp_gdt: - dw 23 - dd tmp_gdt+0x10000 - dw 0 + dw 23 + dd tmp_gdt+0x10000 + dw 0 - dw 0xffff - dw 0x0000 - db 0x00 - dw 11011111b *256 +10011010b - db 0x00 + dw 0xffff + dw 0x0000 + db 0x00 + dw 11011111b *256 +10011010b + db 0x00 - dw 0xffff - dw 0x0000 - db 0x00 - dw 11011111b *256 +10010010b - db 0x00 + dw 0xffff + dw 0x0000 + db 0x00 + dw 11011111b *256 +10010010b + db 0x00 + +diff16 "end of tmp_gdt ",0,$ include "data16.inc" +diff16 "end of data16 ",0,$ + use32 org $+0x10000 align 4 B32: - mov ax,os_stack ; Selector for os - mov ds,ax - mov es,ax - mov fs,ax - mov gs,ax - mov ss,ax - mov esp,0x3ec00 ; Set stack +diff16 "32-bit code start ",0,$ + mov ax,os_stack ; Selector for os + mov ds,ax + mov es,ax + mov fs,ax + mov gs,ax + mov ss,ax + mov esp,0x4ec00 ; Set stack -; CLEAR 0x280000 - HEAP_BASE +;------------------------------------------------------------------------------- + call preinit_mem ; (init.inc) - xor eax,eax - mov edi,0x280000 - mov ecx,(HEAP_BASE-OS_BASE-0x280000) / 4 - cld - rep stosd + call test_cpu ; (init.inc - to be moved to bus/CPU.inc) + bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc - mov edi,0x40000 - mov ecx,(0x90000-0x40000)/4 - rep stosd + call init_BIOS32 ; (init.inc - to be removed later) -; CLEAR KERNEL UNDEFINED GLOBALS - mov edi, endofcode-OS_BASE - mov ecx, (uglobals_size/4)+4 - rep stosd +; PCIe extended config space access + call rs7xx_pcie_init ; (bus/HT.inc) -; SAVE & CLEAR 0-0xffff - - xor esi, esi - mov edi,0x2F0000 - mov ecx,0x10000 / 4 - rep movsd - mov edi,0x1000 - mov ecx,0xf000 / 4 - rep stosd - - call test_cpu - bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc - - call init_BIOS32 ; MEMORY MODEL - call init_mem - call init_page_map + call init_mem ; (init.inc) + call init_page_map ; (init.inc) ; ENABLE PAGING - mov eax, sys_pgdir-OS_BASE - mov cr3, eax + mov eax, sys_pgdir-OS_BASE + mov cr3, eax - mov eax,cr0 - or eax,CR0_PG+CR0_WP - mov cr0,eax + mov eax,cr0 + or eax,CR0_PG+CR0_WP + mov cr0,eax - lgdt [gdts] - jmp pword os_code:high_code + lgdt [gdts] + jmp pword os_code:high_code align 4 -bios32_entry dd ? -tmp_page_tabs dd ? +bios32_entry dd ? +tmp_page_tabs dd ? use16 org $-0x10000 @@ -272,45 +259,45 @@ org OS_BASE+$ align 4 high_code: - mov ax, os_stack - mov bx, app_data - mov cx, app_tls - mov ss, ax - add esp, OS_BASE + mov ax, os_stack + mov bx, app_data + mov cx, app_tls + mov ss, ax + add esp, OS_BASE - mov ds, bx - mov es, bx - mov fs, cx - mov gs, bx + mov ds, bx + mov es, bx + mov fs, cx + mov gs, bx - bt [cpu_caps], CAPS_PGE - jnc @F + bt [cpu_caps], CAPS_PGE + jnc @F - or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL + or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL - mov ebx, cr4 - or ebx, CR4_PGE - mov cr4, ebx + mov ebx, cr4 + or ebx, CR4_PGE + mov cr4, ebx @@: - xor eax, eax - mov dword [sys_pgdir], eax - mov dword [sys_pgdir+4], eax + xor eax, eax + mov dword [sys_pgdir], eax + mov dword [sys_pgdir+4], eax - mov eax, cr3 - mov cr3, eax ; flush TLB + mov eax, cr3 + mov cr3, eax ; flush TLB ; SAVE REAL MODE VARIABLES - mov ax, [BOOT_VAR + 0x9031] - mov [IDEContrRegsBaseAddr], ax + mov ax, [BOOT_VAR + 0x9031] + mov [IDEContrRegsBaseAddr], ax ; --------------- APM --------------------- ; init selectors mov ebx,[BOOT_VAR+0x9040] ; offset of APM entry point - movzx eax,word [BOOT_VAR+0x9050] ; real-mode segment base address of + movzx eax,word [BOOT_VAR+0x9050] ; real-mode segment base address of ; protected-mode 32-bit code segment - movzx ecx,word [BOOT_VAR+0x9052] ; real-mode segment base address of + movzx ecx,word [BOOT_VAR+0x9052] ; real-mode segment base address of ; protected-mode 16-bit code segment - movzx edx,word [BOOT_VAR+0x9054] ; real-mode segment base address of + movzx edx,word [BOOT_VAR+0x9054] ; real-mode segment base address of ; protected-mode 16-bit data segment shl eax, 4 @@ -334,261 +321,237 @@ high_code: mov eax, [BOOT_VAR + 0x9044] ; version & flags mov [apm_vf], eax ; ----------------------------------------- -; movzx eax,byte [BOOT_VAR+0x9010] ; mouse port +; movzx eax,byte [BOOT_VAR+0x9010] ; mouse port ; mov [0xF604],byte 1 ;al - mov al, [BOOT_VAR+0x901F] ; DMA access - mov [allow_dma_access], al - movzx eax, byte [BOOT_VAR+0x9000] ; bpp - mov [ScreenBPP],al + mov al, [BOOT_VAR+0x901F] ; DMA access + mov [allow_dma_access], al + movzx eax, byte [BOOT_VAR+0x9000] ; bpp + mov [ScreenBPP],al - mov [_display.bpp], eax - mov [_display.vrefresh], 60 - mov [_display.disable_mouse], __sys_disable_mouse + mov [_display.bpp], eax + mov [_display.vrefresh], 60 + mov [_display.disable_mouse], __sys_disable_mouse - movzx eax,word [BOOT_VAR+0x900A] ; X max - mov [_display.width], eax - dec eax - mov [Screen_Max_X],eax - mov [screen_workarea.right],eax - movzx eax,word [BOOT_VAR+0x900C] ; Y max - mov [_display.height], eax - dec eax - mov [Screen_Max_Y],eax - mov [screen_workarea.bottom],eax - movzx eax,word [BOOT_VAR+0x9008] ; screen mode - mov [SCR_MODE],eax - mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add - mov [BANK_SWITCH],eax - mov [BytesPerScanLine],word 640*4 ; Bytes PerScanLine - cmp [SCR_MODE],word 0x13 ; 320x200 - je @f - cmp [SCR_MODE],word 0x12 ; VGA 640x480 - je @f - movzx eax, word[BOOT_VAR+0x9001] ; for other modes - mov [BytesPerScanLine],ax - mov [_display.pitch], eax + movzx eax,word [BOOT_VAR+0x900A] ; X max + mov [_display.width], eax + dec eax + mov [Screen_Max_X],eax + mov [screen_workarea.right],eax + movzx eax,word [BOOT_VAR+0x900C] ; Y max + mov [_display.height], eax + dec eax + mov [Screen_Max_Y],eax + mov [screen_workarea.bottom],eax + movzx eax,word [BOOT_VAR+0x9008] ; screen mode + mov [SCR_MODE],eax + mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add + mov [BANK_SWITCH],eax + mov [BytesPerScanLine],word 640*4 ; Bytes PerScanLine + cmp [SCR_MODE],word 0x13 ; 320x200 + je @f + cmp [SCR_MODE],word 0x12 ; VGA 640x480 + je @f + movzx eax, word[BOOT_VAR+0x9001] ; for other modes + mov [BytesPerScanLine],ax + mov [_display.pitch], eax @@: - mov eax, [_display.width] - mul [_display.height] - mov [_WinMapSize], eax + mov eax, [_display.width] + mul [_display.height] + mov [_WinMapSize], eax + + mov esi, BOOT_VAR+0x9080 + movzx ecx, byte [esi-1] + mov [NumBiosDisks], ecx + mov edi, BiosDisksData + rep movsd - mov esi, BOOT_VAR+0x9080 - movzx ecx, byte [esi-1] - mov [NumBiosDisks], ecx - mov edi, BiosDisksData - rep movsd ; GRAPHICS ADDRESSES - and byte [BOOT_VAR+0x901e],0x0 - mov eax,[BOOT_VAR+0x9018] - mov [LFBAddress],eax + and byte [BOOT_VAR+0x901e],0x0 + mov eax,[BOOT_VAR+0x9018] + mov [LFBAddress],eax -;== - cmp [SCR_MODE],word 0100000000000000b - jge setvesa20 + cmp [SCR_MODE],word 0100000000000000b + jge setvesa20 mov eax, 0xDEADBEEF hlt ; === EGA, VGA & Vesa 1.2 modes not supported === - setvesa20: -; mov [PUTPIXEL],dword Vesa20_putpixel24 ; Vesa 2.0 24bpp modes -; mov [GETPIXEL],dword Vesa20_getpixel24 -; cmp [ScreenBPP],byte 24 -; jz v20ga24 - v20ga32: - mov [PUTPIXEL],dword Vesa20_putpixel32 - mov [GETPIXEL],dword Vesa20_getpixel32 +setvesa20: +v20ga32: + mov [PUTPIXEL],dword Vesa20_putpixel32 + mov [GETPIXEL],dword Vesa20_getpixel32 ; -------- Fast System Call init ---------- -; Intel SYSENTER/SYSEXIT (AMD CPU support it too) -; bt [cpu_caps], CAPS_SEP -; jnc .SEnP ; SysEnter not Present -; xor edx, edx -; mov ecx, MSR_SYSENTER_CS -; mov eax, os_code -; wrmsr -; mov ecx, MSR_SYSENTER_ESP -;; mov eax, sysenter_stack ; Check it -; xor eax, eax -; wrmsr -; mov ecx, MSR_SYSENTER_EIP -; mov eax, sysenter_entry -; wrmsr .SEnP: ; AMD SYSCALL/SYSRET -; cmp byte[cpu_vendor], 'A' -; jne .noSYSCALL -; mov eax, 0x80000001 -; cpuid -; test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support -; jz .noSYSCALL - mov ecx, MSR_AMD_EFER - rdmsr - or eax, 1 ; bit_0 - System Call Extension (SCE) - wrmsr + mov ecx, MSR_AMD_EFER + rdmsr + or eax, 1 ; bit_0 - System Call Extension (SCE) + wrmsr - ; Bits of EDX : - ; Bit 31Ц16 During the SYSRET instruction, this field is copied into the CS register - ; and the contents of this field, plus 8, are copied into the SS register. - ; Bit 15Ц0 During the SYSCALL instruction, this field is copied into the CS register - ; and the contents of this field, plus 8, are copied into the SS register. + ; Bits of EDX : + ; Bit 31..16 During the SYSRET instruction, this field is copied into the CS register + ; and the contents of this field, plus 8, are copied into the SS register. + ; Bit 15..0 During the SYSCALL instruction, this field is copied into the CS register + ; and the contents of this field, plus 8, are copied into the SS register. - mov edx, 0x1B000B ; RING3 task stack will be used for fast syscalls! + mov edx, 0x1B000B ; RING3 task stack will be used for fast syscalls! - mov eax, syscall_entry - mov ecx, MSR_AMD_STAR - wrmsr + mov eax, syscall_entry + mov ecx, MSR_AMD_STAR + wrmsr .noSYSCALL: ; ----------------------------------------- - stdcall alloc_page - stdcall map_page, tss-0xF80, eax, PG_SW ; lower 0xF80 bytes might be used for something - stdcall alloc_page - inc eax - mov [SLOT_BASE+256+APPDATA.io_map], eax - stdcall map_page, tss+0x80, eax, PG_SW - stdcall alloc_page - inc eax - mov dword [SLOT_BASE+256+APPDATA.io_map+4], eax - stdcall map_page, tss+0x1080, eax, PG_SW + stdcall alloc_page + stdcall map_page, tss-0xF80, eax, PG_SW ; lower 0xF80 bytes might be used for something + stdcall alloc_page + inc eax + mov [SLOT_BASE+256+APPDATA.io_map], eax + stdcall map_page, tss+0x80, eax, PG_SW + stdcall alloc_page + inc eax + mov dword [SLOT_BASE+256+APPDATA.io_map+4], eax + stdcall map_page, tss+0x1080, eax, PG_SW ; LOAD IDT - call build_interrupt_table ;lidt is executed - ;lidt [idtreg] + call build_interrupt_table ;lidt is executed + ;lidt [idtreg] - call init_kernel_heap - stdcall kernel_alloc, RING0_STACK_SIZE+512 - mov [os_stack_seg], eax + call init_kernel_heap + stdcall kernel_alloc, RING0_STACK_SIZE+512 + mov [os_stack_seg], eax - lea esp, [eax+RING0_STACK_SIZE] + lea esp, [eax+RING0_STACK_SIZE] - mov [tss._ss0], os_stack - mov [tss._esp0], esp - mov [tss._esp], esp - mov [tss._cs],os_code - mov [tss._ss],os_stack - mov [tss._ds],app_data - mov [tss._es],app_data - mov [tss._fs],app_data - mov [tss._gs],app_data - mov [tss._io],128 + mov [tss._ss0], os_stack + mov [tss._esp0], esp + mov [tss._esp], esp + mov [tss._cs],os_code + mov [tss._ss],os_stack + mov [tss._ds],app_data + mov [tss._es],app_data + mov [tss._fs],app_data + mov [tss._gs],app_data + mov [tss._io],128 ;Add IO access table - bit array of permitted ports - mov edi, tss._io_map_0 - xor eax, eax + mov edi, tss._io_map_0 + xor eax, eax mov ecx, 2047 rep stosd ; access to 65504 ports granted not eax ; the last 32 ports blocked stosd - mov ax,tss0 - ltr ax + mov ax,tss0 + ltr ax - mov [LFBSize], 0x800000 - call init_LFB - call init_fpu - call init_malloc + mov [LFBSize], 0x800000 + call init_LFB + call init_fpu + call init_malloc +;- + stdcall alloc_kernel_space, 0x51000 + mov [default_io_map], eax - stdcall alloc_kernel_space, 0x51000 - mov [default_io_map], eax + add eax, 0x2000 + mov [ipc_tmp], eax + mov ebx, 0x1000 - add eax, 0x2000 - mov [ipc_tmp], eax - mov ebx, 0x1000 + add eax, 0x40000 + mov [proc_mem_map], eax - add eax, 0x40000 - mov [proc_mem_map], eax + add eax, 0x8000 + mov [proc_mem_pdir], eax - add eax, 0x8000 - mov [proc_mem_pdir], eax + add eax, ebx + mov [proc_mem_tab], eax - add eax, ebx - mov [proc_mem_tab], eax + add eax, ebx + mov [tmp_task_pdir], eax - add eax, ebx - mov [tmp_task_pdir], eax + add eax, ebx + mov [tmp_task_ptab], eax - add eax, ebx - mov [tmp_task_ptab], eax + add eax, ebx + mov [ipc_pdir], eax - add eax, ebx - mov [ipc_pdir], eax + add eax, ebx + mov [ipc_ptab], eax - add eax, ebx - mov [ipc_ptab], eax + stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ + (unpack.lc+unpack.lp)))*4 - stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ - (unpack.lc+unpack.lp)))*4 + mov [unpack.p], eax - mov [unpack.p], eax + call init_events + mov eax, srv.fd-SRV_FD_OFFSET + mov [srv.fd], eax + mov [srv.bk], eax - call init_events - mov eax, srv.fd-SRV_FD_OFFSET - mov [srv.fd], eax - mov [srv.bk], eax - - mov edi, irq_tab - xor eax, eax - mov ecx, 16 - rep stosd + mov edi, irq_tab + xor eax, eax + mov ecx, 16 + rep stosd ;Set base of graphic segment to linear address of LFB - mov eax,[LFBAddress] ; set for gs - mov [graph_data_l+2],ax - shr eax,16 - mov [graph_data_l+4],al - mov [graph_data_l+7],ah + mov eax,[LFBAddress] ; set for gs + mov [graph_data_l+2],ax + shr eax,16 + mov [graph_data_l+4],al + mov [graph_data_l+7],ah - stdcall kernel_alloc, [_WinMapSize] - mov [_WinMapAddress], eax + stdcall kernel_alloc, [_WinMapSize] + mov [_WinMapAddress], eax - xor eax,eax - inc eax - mov [CURRENT_TASK],eax ;dword 1 - mov [TASK_COUNT],eax ;dword 1 - mov [TASK_BASE],dword TASK_DATA - mov [current_slot], SLOT_BASE+256 + xor eax,eax + inc eax + mov [CURRENT_TASK],eax ;dword 1 + mov [TASK_COUNT],eax ;dword 1 + mov [TASK_BASE],dword TASK_DATA + mov [current_slot], SLOT_BASE+256 ; set background - mov [BgrDrawMode],eax - mov [BgrDataWidth],eax - mov [BgrDataHeight],eax - mov [mem_BACKGROUND], 4 - mov [img_background], static_background_data + mov [BgrDrawMode],eax + mov [BgrDataWidth],eax + mov [BgrDataHeight],eax + mov [mem_BACKGROUND], 4 + mov [img_background], static_background_data - mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE + mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE - stdcall kernel_alloc, 0x10000/8 - mov edi, eax - mov [network_free_ports], eax - or eax, -1 - mov ecx, 0x10000/32 - rep stosd + stdcall kernel_alloc, 0x10000/8 + mov edi, eax + mov [network_free_ports], eax + or eax, -1 + mov ecx, 0x10000/32 + rep stosd ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f - call rerouteirqs + call rerouteirqs ; Initialize system V86 machine - call init_sys_v86 + call init_sys_v86 ; TIMER SET TO 1/100 S - mov al,0x34 ; set to 100Hz - out 0x43,al - mov al,0x9b ; lsb 1193180 / 1193 - out 0x40,al - mov al,0x2e ; msb - out 0x40,al + mov al,0x34 ; set to 100Hz + out 0x43,al + mov al,0x9b ; lsb 1193180 / 1193 + out 0x40,al + mov al,0x2e ; msb + out 0x40,al ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) ; they are used: when partitions are scanned, hd_read relies on timer ; Also enable IRQ2, because in some configurations ; IRQs from slave controller are not delivered until IRQ2 on master is enabled - mov al, 0xFA - out 0x21, al - mov al, 0x3F - out 0xA1, al + mov al, 0xFA + out 0x21, al + mov al, 0x3F + out 0xA1, al ;!!!!!!!!!!!!!!!!!!!!!!!!!! include 'detect/disks.inc' @@ -604,7 +567,7 @@ include 'boot/rdload.inc' ; mov [dma_hdd],1 ; CALCULATE FAT CHAIN FOR RAMDISK - call calculatefatchain + call calculatefatchain ; LOAD VMODE DRIVER @@ -614,60 +577,60 @@ 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} + 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 + 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 + 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" - sub ecx, 10 - mov edx, 0xFFFFFF - mov ebx, [MEM_AMOUNT] - shr ebx, 20 - xor edi,edi - mov eax, 0x00040000 + movzx ecx, word [boot_y] + or ecx, (10+29*6) shl 16 ; "Determining amount of memory" + sub ecx, 10 + mov edx, 0xFFFFFF + mov ebx, [MEM_AMOUNT] + shr ebx, 20 + xor edi,edi + mov eax, 0x00040000 inc edi - call display_number_force + call display_number_force ; BUILD SCHEDULER - call build_scheduler ; sys32.inc + call build_scheduler ; sys32.inc - mov esi,boot_devices - call boot_log + mov esi,boot_devices + call boot_log - mov [pci_access_enabled],1 + mov [pci_access_enabled],1 ; SET PRELIMINARY WINDOW STACK AND POSITIONS - mov esi,boot_windefs - call boot_log - call set_window_defaults + mov esi,boot_windefs + call boot_log + call set_window_defaults ; SET BACKGROUND DEFAULTS - mov esi,boot_bgr - call boot_log - call init_background - call calculatebackground + mov esi,boot_bgr + call boot_log + call init_background + call calculatebackground ; RESERVE SYSTEM IRQ'S JA PORT'S @@ -678,202 +641,182 @@ end if ; 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 - mov dword [SLOT_BASE+APPDATA.exc_handler], eax - mov dword [SLOT_BASE+APPDATA.except_mask], eax + xor eax, eax + mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data + mov dword [SLOT_BASE+APPDATA.exc_handler], eax + mov dword [SLOT_BASE+APPDATA.except_mask], eax - ; name for OS/IDLE process + ; name for OS/IDLE process - mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' - mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' - mov edi, [os_stack_seg] - mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi - add edi, 0x2000-512 - mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi - mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case + mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' + mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' + mov edi, [os_stack_seg] + mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi + add edi, 0x2000-512 + mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi + mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case ; [SLOT_BASE+256+APPDATA.io_map] was set earlier - mov esi, fpu_data - mov ecx, 512/4 - cld - rep movsd + mov esi, fpu_data + mov ecx, 512/4 + cld + rep movsd - mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax - mov dword [SLOT_BASE+256+APPDATA.except_mask], eax + mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax + mov dword [SLOT_BASE+256+APPDATA.except_mask], eax - mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET - mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx - mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx + mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET + mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx + mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx - mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path - mov dword [SLOT_BASE+256+APPDATA.tls_base], eax + mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path + mov dword [SLOT_BASE+256+APPDATA.tls_base], eax - ; task list - mov dword [TASK_DATA+TASKDATA.mem_start],eax ; process base address + ; task list + mov dword [TASK_DATA+TASKDATA.mem_start],eax ; process base address inc eax - mov dword [CURRENT_TASK],eax - mov dword [TASK_COUNT],eax - mov [current_slot], SLOT_BASE+256 - mov [TASK_BASE],dword TASK_DATA - mov byte[TASK_DATA+TASKDATA.wnd_number],al ; on screen number - mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number + mov dword [CURRENT_TASK],eax + mov dword [TASK_COUNT],eax + mov [current_slot], SLOT_BASE+256 + mov [TASK_BASE],dword TASK_DATA + mov byte[TASK_DATA+TASKDATA.wnd_number],al ; on screen number + mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number - call init_display - mov eax, [def_cursor] - mov [SLOT_BASE+APPDATA.cursor],eax - mov [SLOT_BASE+APPDATA.cursor+256],eax + call init_display + mov eax, [def_cursor] + mov [SLOT_BASE+APPDATA.cursor],eax + mov [SLOT_BASE+APPDATA.cursor+256],eax ; READ TSC / SECOND - mov esi,boot_tsc - call boot_log - cli - rdtsc ;call _rdtsc - mov ecx,eax - mov esi,250 ; wait 1/4 a second - call delay_ms - rdtsc ;call _rdtsc - sti - sub eax,ecx - shl eax,2 - mov [CPU_FREQ],eax ; save tsc / sec + mov esi,boot_tsc + call boot_log + cli + rdtsc ;call _rdtsc + mov ecx,eax + mov esi,250 ; wait 1/4 a second + call delay_ms + rdtsc ;call _rdtsc + sti + sub eax,ecx + shl eax,2 + mov [CPU_FREQ],eax ; save tsc / sec ; mov ebx, 1000000 ; div ebx -; вообще-то производительность в данном конкретном месте -; совершенно некритична, но чтобы заткнуть любителей -; оптимизирующих компиляторов ЯВУ... - mov edx, 2251799814 - mul edx - shr edx, 19 - mov [stall_mcs], edx +; faster division possible: + mov edx, 2251799814 + mul edx + shr edx, 19 + mov [stall_mcs], edx ; PRINT CPU FREQUENCY - mov esi, boot_cpufreq - call boot_log + mov esi, boot_cpufreq + call boot_log - mov ebx, edx - movzx ecx, word [boot_y] - add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is ' - mov edx, 0xFFFFFF - xor edi,edi - mov eax, 0x00040000 + mov ebx, edx + movzx ecx, word [boot_y] + add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is ' + mov edx, 0xFFFFFF + xor edi,edi + mov eax, 0x00040000 inc edi - call display_number_force + call display_number_force ; SET VARIABLES - call set_variables + call set_variables ; SET MOUSE - ;call detect_devices - stdcall load_driver, szPS2MDriver + ;call detect_devices + stdcall load_driver, szPS2MDriver ; stdcall load_driver, szCOM_MDriver - mov esi,boot_setmouse - call boot_log - call setmouse + mov esi,boot_setmouse + call boot_log + call setmouse ; STACK AND FDC - call stack_init - call fdc_init + call stack_init + call fdc_init -; PALETTE FOR 320x200 and 640x480 16 col - -; cmp [SCR_MODE],word 0x12 -; jne no_pal_vga -; mov esi,boot_pal_vga -; call boot_log -; call paletteVGA -; no_pal_vga: - -; cmp [SCR_MODE],word 0x13 -; jne no_pal_ega -; mov esi,boot_pal_ega -; call boot_log -; call palette320x200 -; no_pal_ega: ; LOAD DEFAULT SKIN - call load_default_skin + call load_default_skin ;protect io permission map - mov esi, [default_io_map] - stdcall map_page,esi,[SLOT_BASE+256+APPDATA.io_map], PG_MAP - add esi, 0x1000 - stdcall map_page,esi,[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP + mov esi, [default_io_map] + stdcall map_page,esi,[SLOT_BASE+256+APPDATA.io_map], PG_MAP + add esi, 0x1000 + stdcall map_page,esi,[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP - stdcall map_page,tss._io_map_0,\ - [SLOT_BASE+256+APPDATA.io_map], PG_MAP - stdcall map_page,tss._io_map_1,\ - [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP + stdcall map_page,tss._io_map_0,\ + [SLOT_BASE+256+APPDATA.io_map], PG_MAP + stdcall map_page,tss._io_map_1,\ + [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP mov ax,[OS_BASE+0x10000+bx_from_load] - cmp ax,'r1' ; if not rused ram disk - load network configuration from files {SPraid.simba} + cmp ax,'r1' ; if not rused ram disk - load network configuration from files {SPraid.simba} je no_st_network - call set_network_conf + call set_network_conf no_st_network: - call init_userDMA ; <<<<<<<<< ============== core/memory.inc ================= - mov esi, boot_uDMA_ok - call boot_log -; call pci_ext_config ; <<<<<<<<< bus/pci/pcie.inc -;------------------------------------------------------------------------------- - call rs7xx_pcie_init ; <<<<<<<<< bus/ht.inc + call init_userDMA ; <<<<<<<<< ============== core/memory.inc ================= + mov esi, boot_uDMA_ok + call boot_log ; LOAD FIRST APPLICATION - cli + cli - cmp byte [BOOT_VAR+0x9030],1 - jne no_load_vrr_m + cmp byte [BOOT_VAR+0x9030],1 + jne no_load_vrr_m - mov ebp, vrr_m - call fs_execute_from_sysdir + mov ebp, vrr_m + call fs_execute_from_sysdir ; cmp eax,2 ; if vrr_m app found (PID=2) sub eax,2 - jz first_app_found + jz first_app_found no_load_vrr_m: - mov ebp, firstapp - call fs_execute_from_sysdir + mov ebp, firstapp + call fs_execute_from_sysdir ; cmp eax,2 ; continue if a process has been loaded sub eax,2 - jz first_app_found + jz first_app_found - mov esi, boot_failed - call boot_log + mov esi, boot_failed + call boot_log - mov eax, 0xDEADBEEF ; otherwise halt - hlt + mov eax, 0xDEADBEEF ; otherwise halt + hlt first_app_found: - cli + cli - ;mov [TASK_COUNT],dword 2 + ;mov [TASK_COUNT],dword 2 push 1 - pop dword [CURRENT_TASK] ; set OS task fisrt + pop dword [CURRENT_TASK] ; set OS task fisrt ; SET KEYBOARD PARAMETERS - mov al, 0xf6 ; reset keyboard, scan enabled - call kb_write + mov al, 0xf6 ; reset keyboard, scan enabled + call kb_write - ; wait until 8042 is ready - xor ecx,ecx + ; wait until 8042 is ready + xor ecx,ecx @@: - in al,64h - and al,00000010b - loopnz @b + in al,64h + and al,00000010b + loopnz @b ; mov al, 0xED ; svetodiody - only for testing! ; call kb_write @@ -882,14 +825,14 @@ first_app_found: ; call kb_write ; call kb_read - mov al, 0xF3 ; set repeat rate & delay - call kb_write + mov al, 0xF3 ; set repeat rate & delay + call kb_write ; call kb_read - mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 - call kb_write + mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 + call kb_write ; call kb_read ;// mike.dld [ - call set_lights + call set_lights ;// mike.dld ] @@ -897,39 +840,39 @@ first_app_found: if defined debug_com_base - ; enable Divisor latch + ; enable Divisor latch - mov dx, debug_com_base+3 - mov al, 1 shl 7 - out dx, al + mov dx, debug_com_base+3 + mov al, 1 shl 7 + out dx, al - ; Set speed to 115200 baud (max speed) + ; Set speed to 115200 baud (max speed) - mov dx, debug_com_base - mov al, 0x01 - out dx, al + mov dx, debug_com_base + mov al, 0x01 + out dx, al - mov dx, debug_com_base+1 - mov al, 0x00 - out dx, al + mov dx, debug_com_base+1 + mov al, 0x00 + out dx, al - ; No parity, 8bits words, one stop bit, dlab bit back to 0 + ; No parity, 8bits words, one stop bit, dlab bit back to 0 - mov dx, debug_com_base+3 - mov al, 3 - out dx, al + mov dx, debug_com_base+3 + mov al, 3 + out dx, al - ; disable interrupts + ; disable interrupts - mov dx, debug_com_base+1 - mov al, 0 - out dx, al + mov dx, debug_com_base+1 + mov al, 0 + out dx, al - ; clear + enable fifo (64 bits) + ; clear + enable fifo (64 bits) - mov dx, debug_com_base+2 - mov al, 0x7 + 1 shl 5 - out dx, al + mov dx, debug_com_base+2 + mov al, 0x7 + 1 shl 5 + out dx, al end if @@ -937,11 +880,11 @@ end if ; 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 + mov esi, boot_tasking + call boot_log +.bll1: in al, 0x60 ; wait for ESC key press + cmp al, 129 + jne .bll1 end if ; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled @@ -966,44 +909,44 @@ end if ; ; loop ready_for_irqs ; flush the queue - stdcall attach_int_handler, 1, irq1, 0 + stdcall attach_int_handler, 1, irq1, 0 ; mov [dma_hdd],1 - cmp [IDEContrRegsBaseAddr], 0 - setnz [dma_hdd] - mov [timer_ticks_enable],1 ; for cd driver + cmp [IDEContrRegsBaseAddr], 0 + setnz [dma_hdd] + mov [timer_ticks_enable],1 ; for cd driver - sti - call change_task + sti + call change_task - jmp osloop + jmp osloop ; jmp $ ; wait here for timer to take control - ; Fly :) + ; Fly :) include 'unpacker.inc' include 'fdo.inc' align 4 boot_log: - pushad + pushad - mov ebx,10*65536 - mov bx,word [boot_y] - add [boot_y],dword 10 - mov ecx,0x80ffffff ; ASCIIZ string with white color + mov ebx,10*65536 + mov bx,word [boot_y] + add [boot_y],dword 10 + mov ecx,0x80ffffff ; ASCIIZ string with white color xor edi,edi - mov edx,esi + mov edx,esi inc edi - call dtext + call dtext ; mov [novesachecksum],1000 ; call checkVga_N13 - popad + popad - ret + ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; @@ -1012,16 +955,16 @@ boot_log: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 32 osloop: - call [draw_pointer] - call window_check_events - call mouse_check_events - call checkmisc + call [draw_pointer] + call window_check_events + call mouse_check_events + call checkmisc ; call checkVga_N13 - call stack_handler - call checkidle - call check_fdd_motor_status + call stack_handler + call checkidle + call check_fdd_motor_status ; call check_ATAPI_device_event - jmp osloop + jmp osloop ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; MAIN OS LOOP END ; @@ -1029,33 +972,33 @@ osloop: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 4 checkidle: - pushad - call change_task - jmp idle_loop_entry + pushad + call change_task + jmp idle_loop_entry idle_loop: - cmp eax,[idlemem] ; eax == [timer_ticks] - jne idle_exit - rdtsc ;call _rdtsc - mov ecx,eax - hlt - rdtsc ;call _rdtsc - sub eax,ecx - add [idleuse],eax + cmp eax,[idlemem] ; eax == [timer_ticks] + jne idle_exit + rdtsc ;call _rdtsc + mov ecx,eax + hlt + rdtsc ;call _rdtsc + sub eax,ecx + add [idleuse],eax idle_loop_entry: - mov eax,[timer_ticks] ; eax = [timer_ticks] - cmp [check_idle_semaphore],0 - je idle_loop - dec [check_idle_semaphore] + mov eax,[timer_ticks] ; eax = [timer_ticks] + cmp [check_idle_semaphore],0 + je idle_loop + dec [check_idle_semaphore] idle_exit: - mov [idlemem],eax ; eax == [timer_ticks] - popad - ret + mov [idlemem],eax ; eax == [timer_ticks] + popad + ret uglobal - idlemem dd 0x0 - idleuse dd 0x0 - idleusesec dd 0x0 - check_idle_semaphore dd 0x0 + idlemem dd 0x0 + idleuse dd 0x0 + idleusesec dd 0x0 + check_idle_semaphore dd 0x0 endg @@ -1077,8 +1020,8 @@ include "kernel32.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; reserve_irqs_ports: - ; removed - ret + ; removed + ret setirqreadports: ; removed @@ -1090,30 +1033,30 @@ endg set_variables: - mov ecx,0x100 ; flush port 0x60 -.fl60: in al,0x60 - loop .fl60 - push eax + mov ecx,0x100 ; flush port 0x60 +.fl60: in al,0x60 + loop .fl60 + push eax - mov ax,[BOOT_VAR+0x900c] - shr ax,1 - shl eax,16 - mov ax,[BOOT_VAR+0x900A] - shr ax,1 - mov [MOUSE_X],eax + mov ax,[BOOT_VAR+0x900c] + shr ax,1 + shl eax,16 + mov ax,[BOOT_VAR+0x900A] + shr ax,1 + mov [MOUSE_X],eax - xor eax,eax - mov [BTN_ADDR],dword BUTTON_INFO ; address of button list + xor eax,eax + mov [BTN_ADDR],dword BUTTON_INFO ; address of button list - mov byte [MOUSE_BUFF_COUNT],al ; mouse buffer - mov byte [KEY_COUNT],al ; keyboard buffer - mov byte [BTN_COUNT],al ; button buffer + mov byte [MOUSE_BUFF_COUNT],al ; mouse buffer + mov byte [KEY_COUNT],al ; keyboard buffer + mov byte [BTN_COUNT],al ; button buffer ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y ;!! IP 04.02.2005: - mov byte [DONT_SWITCH],al ; change task if possible - pop eax - ret + mov byte [DONT_SWITCH],al ; change task if possible + pop eax + ret align 4 ;input eax=43,bl-byte of output, ecx - number of port @@ -1123,11 +1066,11 @@ sys_outport: display_number: ;It is not optimization - mov eax, ebx - mov ebx, ecx - mov ecx, edx - mov edx, esi - mov esi, edi + mov eax, ebx + mov ebx, ecx + mov ecx, edx + mov edx, esi + mov esi, edi ; eax = print type, al=0 -> ebx is number ; al=1 -> ebx is pointer ; ah=0 -> display decimal @@ -1143,14 +1086,14 @@ display_number: display_number_force: push eax and eax,0x3fffffff - cmp eax,0xffff ; length > 0 ? + cmp eax,0xffff ; length > 0 ? pop eax jge cont_displ ret cont_displ: push eax and eax,0x3fffffff - cmp eax,61*0x10000 ; length <= 60 ? + cmp eax,61*0x10000 ; length <= 60 ? pop eax jb cont_displ2 ret @@ -1158,7 +1101,7 @@ display_number_force: pushad - cmp al,1 ; ecx is a pointer ? + cmp al,1 ; ecx is a pointer ? jne displnl1 mov ebp,ebx add ebp,4 @@ -1167,7 +1110,7 @@ display_number_force: displnl1: sub esp,64 - test ah,ah ; DECIMAL + test ah,ah ; DECIMAL jnz no_display_desnum shr eax,16 and eax,0xC03f @@ -1195,7 +1138,7 @@ display_number_force: ret no_display_desnum: - cmp ah,0x01 ; HEXADECIMAL + cmp ah,0x01 ; HEXADECIMAL jne no_display_hexnum shr eax,16 and eax,0xC03f @@ -1225,7 +1168,7 @@ display_number_force: ret no_display_hexnum: - cmp ah,0x02 ; BINARY + cmp ah,0x02 ; BINARY jne no_display_binnum shr eax,16 and eax,0xC03f @@ -1304,9 +1247,9 @@ draw_num_text: add eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] add ebx,eax mov ecx,[esp+64+32-12+4] - and ecx, not 0x80000000 ; force counted string - mov eax, [esp+64+8] ; background color (if given) - mov edi, [esp+64+4] + and ecx, not 0x80000000 ; force counted string + mov eax, [esp+64+8] ; background color (if given) + mov edi, [esp+64+4] jmp dtext align 4 @@ -1325,7 +1268,7 @@ sys_setup: ; 12 = enable pci access - and [esp+32],dword 0 + and [esp+32],dword 0 dec ebx ; MIDI jnz nsyse1 cmp ecx,0x100 @@ -1337,7 +1280,7 @@ sys_setup: jb nsyse1 mov [midi_base],cx ;bx mov word [mididp],cx ;bx - inc cx ;bx + inc cx ;bx mov word [midisp],cx ;bx ret @@ -1404,76 +1347,76 @@ endg mov [cdid],0xb0 noprsl: dec ecx - jnz nosema - mov [cdbase],0x170 - mov [cdid],0xa0 + jnz nosema + mov [cdbase],0x170 + mov [cdid],0xa0 nosema: dec ecx - jnz nosesl - mov [cdbase],0x170 - mov [cdid],0xb0 + jnz nosesl + mov [cdbase],0x170 + mov [cdid],0xb0 nosesl: - ret + ret iglobal cd_base db 0 endg nsyse4: - - sub ebx,2 ; SYSTEM LANGUAGE - jnz nsyse5 - mov [syslang],ecx - ret + + sub ebx,2 ; SYSTEM LANGUAGE + jnz nsyse5 + mov [syslang],ecx + ret nsyse5: - - sub ebx,2 ; HD BASE - jnz nsyse7 - test ecx,ecx - jz nosethd + sub ebx,2 ; HD BASE + jnz nsyse7 - cmp ecx,4 - ja nosethd - mov [hd_base],cl + test ecx,ecx + jz nosethd - cmp ecx,1 - jnz noprmahd - mov [hdbase],0x1f0 - and dword [hdid],0x0 - mov dword [hdpos],ecx + cmp ecx,4 + ja nosethd + mov [hd_base],cl + + cmp ecx,1 + jnz noprmahd + mov [hdbase],0x1f0 + and dword [hdid],0x0 + mov dword [hdpos],ecx ; call set_FAT32_variables noprmahd: - cmp ecx,2 - jnz noprslhd - mov [hdbase],0x1f0 - mov [hdid],0x10 - mov dword [hdpos],ecx + cmp ecx,2 + jnz noprslhd + mov [hdbase],0x1f0 + mov [hdid],0x10 + mov dword [hdpos],ecx ; call set_FAT32_variables noprslhd: - cmp ecx,3 - jnz nosemahd - mov [hdbase],0x170 - and dword [hdid],0x0 - mov dword [hdpos],ecx + cmp ecx,3 + jnz nosemahd + mov [hdbase],0x170 + and dword [hdid],0x0 + mov dword [hdpos],ecx ; call set_FAT32_variables nosemahd: - cmp ecx,4 - jnz noseslhd - mov [hdbase],0x170 - mov [hdid],0x10 - mov dword [hdpos],ecx + cmp ecx,4 + jnz noseslhd + mov [hdbase],0x170 + mov [hdid],0x10 + mov dword [hdpos],ecx ; call set_FAT32_variables noseslhd: - call reserve_hd1 - call reserve_hd_channel - call free_hd_channel - and dword [hd1_status],0 ; free + call reserve_hd1 + call reserve_hd_channel + call free_hd_channel + and dword [hd1_status],0 ; free nosethd: - ret + ret iglobal hd_base db 0 @@ -1482,33 +1425,33 @@ endg nsyse7: ; cmp eax,8 ; HD PARTITION - dec ebx - jnz nsyse8 - mov [fat32part],ecx + dec ebx + jnz nsyse8 + mov [fat32part],ecx ; call set_FAT32_variables - call reserve_hd1 - call reserve_hd_channel - call free_hd_channel -; pusha - call choice_necessity_partition_1 -; popa - and dword [hd1_status],0 ; free - ret + call reserve_hd1 + call reserve_hd_channel + call free_hd_channel +; pusha + call choice_necessity_partition_1 +; popa + and dword [hd1_status],0 ; free + ret nsyse8: ; cmp eax,11 ; ENABLE LBA READ - and ecx,1 + and ecx,1 sub ebx,3 - jnz no_set_lba_read - mov [lba_read_enabled],ecx - ret + jnz no_set_lba_read + mov [lba_read_enabled],ecx + ret no_set_lba_read: ; cmp eax,12 ; ENABLE PCI ACCESS - dec ebx - jnz no_set_pci_access - mov [pci_access_enabled],ecx - ret + dec ebx + jnz no_set_pci_access + mov [pci_access_enabled],ecx + ret no_set_pci_access: ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1516,8 +1459,8 @@ include 'vmodeint.inc' ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sys_setup_err: - or [esp+32],dword -1 - ret + or [esp+32],dword -1 + ret align 4 @@ -1533,118 +1476,118 @@ sys_getsetup: ; cmp eax,1 dec ebx - jnz ngsyse1 - movzx eax,[midi_base] - mov [esp+32],eax - ret + jnz ngsyse1 + movzx eax,[midi_base] + mov [esp+32],eax + ret ngsyse1: ; cmp eax,2 dec ebx - jnz ngsyse2 + jnz ngsyse2 - mov edi,[TASK_BASE] - mov ebx,[edi+TASKDATA.mem_start] - add ebx,edx + mov edi,[TASK_BASE] + mov ebx,[edi+TASKDATA.mem_start] + add ebx,edx ; cmp ebx,1 dec ecx - jnz kbnobaseret - mov eax,keymap - mov ecx,128 - call memmove - ret + jnz kbnobaseret + mov eax,keymap + mov ecx,128 + call memmove + ret kbnobaseret: ; cmp ebx,2 dec ecx - jnz kbnoshiftret + jnz kbnoshiftret - mov eax,keymap_shift - mov ecx,128 - call memmove - ret + mov eax,keymap_shift + mov ecx,128 + call memmove + ret kbnoshiftret: ; cmp ebx,3 dec ecx - jne kbnoaltret + jne kbnoaltret - mov eax,keymap_alt - mov ecx,128 - call memmove - ret + mov eax,keymap_alt + mov ecx,128 + call memmove + ret kbnoaltret: ; cmp ebx,9 sub ecx,6 - jnz ngsyse2 - movzx eax,word [keyboard] - mov [esp+32],eax - ret + jnz ngsyse2 + movzx eax,word [keyboard] + mov [esp+32],eax + ret ngsyse2: ; cmp eax,3 dec ebx - jnz ngsyse3 - movzx eax,[cd_base] - mov [esp+32],eax - ret + jnz ngsyse3 + movzx eax,[cd_base] + mov [esp+32],eax + ret ngsyse3: ; cmp eax,5 sub ebx,2 - jnz ngsyse5 - mov eax,[syslang] - mov [esp+32],eax - ret + jnz ngsyse5 + mov eax,[syslang] + mov [esp+32],eax + ret ngsyse5: ; cmp eax,7 sub ebx,2 - jnz ngsyse7 - movzx eax,[hd_base] - mov [esp+32],eax - ret + jnz ngsyse7 + movzx eax,[hd_base] + mov [esp+32],eax + ret ngsyse7: ; cmp eax,8 dec ebx - jnz ngsyse8 - mov eax,[fat32part] - mov [esp+32],eax - ret + jnz ngsyse8 + mov eax,[fat32part] + mov [esp+32],eax + ret ngsyse8: ; cmp eax,9 dec ebx - jnz ngsyse9 - mov eax,[timer_ticks] ;[0xfdf0] - mov [esp+32],eax - ret + jnz ngsyse9 + mov eax,[timer_ticks] ;[0xfdf0] + mov [esp+32],eax + ret ngsyse9: ; cmp eax,11 sub ebx,2 - jnz ngsyse11 - mov eax,[lba_read_enabled] - mov [esp+32],eax - ret + jnz ngsyse11 + mov eax,[lba_read_enabled] + mov [esp+32],eax + ret ngsyse11: ; cmp eax,12 dec ebx - jnz ngsyse12 - mov eax,[pci_access_enabled] - mov [esp+32],eax - ret + jnz ngsyse12 + mov eax,[pci_access_enabled] + mov [esp+32],eax + ret ngsyse12: - mov [esp+32],dword 1 - ret + mov [esp+32],dword 1 + ret + - get_timer_ticks: - mov eax,[timer_ticks] - ret + mov eax,[timer_ticks] + ret iglobal align 4 mousefn dd msscreen, mswin, msbutton, msset - dd app_load_cursor - dd app_set_cursor - dd app_delete_cursor - dd msz + dd app_load_cursor + dd app_set_cursor + dd app_delete_cursor + dd msz endg readmousepos: @@ -1658,106 +1601,106 @@ readmousepos: ; eax=6 delete cursor ; reserved ; eax=7 get mouse_z - cmp ebx, 7 - ja msset - jmp [mousefn+ebx*4] + cmp ebx, 7 + ja msset + jmp [mousefn+ebx*4] msscreen: - mov eax,[MOUSE_X] - shl eax,16 - mov ax,[MOUSE_Y] - mov [esp+36-4],eax - ret + mov eax,[MOUSE_X] + shl eax,16 + mov ax,[MOUSE_Y] + mov [esp+36-4],eax + ret mswin: - mov eax,[MOUSE_X] - shl eax,16 - mov ax,[MOUSE_Y] - mov esi,[TASK_BASE] - mov bx, word [esi-twdw+WDATA.box.left] - shl ebx,16 - mov bx, word [esi-twdw+WDATA.box.top] - sub eax,ebx + mov eax,[MOUSE_X] + shl eax,16 + mov ax,[MOUSE_Y] + mov esi,[TASK_BASE] + mov bx, word [esi-twdw+WDATA.box.left] + shl ebx,16 + mov bx, word [esi-twdw+WDATA.box.top] + sub eax,ebx - mov edi,[CURRENT_TASK] - shl edi,8 - sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] - rol eax,16 - sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] - rol eax,16 - mov [esp+36-4],eax - ret + mov edi,[CURRENT_TASK] + shl edi,8 + sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] + rol eax,16 + sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] + rol eax,16 + mov [esp+36-4],eax + ret msbutton: - movzx eax,byte [BTN_DOWN] - mov [esp+36-4],eax - ret + movzx eax,byte [BTN_DOWN] + mov [esp+36-4],eax + ret msz: - mov edi, [TASK_COUNT] - movzx edi, word [WIN_POS + edi*2] - cmp edi, [CURRENT_TASK] - jne @f - mov ax,[MOUSE_SCROLL_H] - shl eax,16 - mov ax,[MOUSE_SCROLL_V] - mov [esp+36-4],eax - and [MOUSE_SCROLL_H],word 0 - and [MOUSE_SCROLL_V],word 0 - ret + mov edi, [TASK_COUNT] + movzx edi, word [WIN_POS + edi*2] + cmp edi, [CURRENT_TASK] + jne @f + mov ax,[MOUSE_SCROLL_H] + shl eax,16 + mov ax,[MOUSE_SCROLL_V] + mov [esp+36-4],eax + and [MOUSE_SCROLL_H],word 0 + and [MOUSE_SCROLL_V],word 0 + ret @@: - and [esp+36-4],dword 0 + and [esp+36-4],dword 0 ; ret msset: - ret + ret app_load_cursor: - cmp ecx, OS_BASE - jae msset - stdcall load_cursor, ecx, edx - mov [esp+36-4], eax - ret + cmp ecx, OS_BASE + jae msset + stdcall load_cursor, ecx, edx + mov [esp+36-4], eax + ret app_set_cursor: - stdcall set_cursor, ecx - mov [esp+36-4], eax - ret + stdcall set_cursor, ecx + mov [esp+36-4], eax + ret app_delete_cursor: - stdcall delete_cursor, ecx - mov [esp+36-4], eax - ret + stdcall delete_cursor, ecx + mov [esp+36-4], eax + ret is_input: push edx - mov dx,word [midisp] - in al,dx - and al,0x80 - pop edx + mov dx,word [midisp] + in al,dx + and al,0x80 + pop edx ret is_output: push edx - mov dx,word [midisp] - in al,dx - and al,0x40 - pop edx + mov dx,word [midisp] + in al,dx + and al,0x40 + pop edx ret get_mpu_in: push edx - mov dx,word [mididp] - in al,dx - pop edx + mov dx,word [mididp] + in al,dx + pop edx ret put_mpu_out: push edx - mov dx,word [mididp] - out dx,al - pop edx + mov dx,word [mididp] + out dx,al + pop edx ret @@ -1835,7 +1778,7 @@ sys_end: mov eax,[TASK_BASE] mov [eax+TASKDATA.state], 3 ; terminate this program - waitterm: ; wait here for termination + waitterm: ; wait here for termination mov ebx,100 call delay_hs jmp waitterm @@ -1843,42 +1786,42 @@ sys_end: iglobal align 4 sys_system_table: - dd exit_for_anyone ; 1 = obsolete - dd sysfn_terminate ; 2 = terminate thread - dd sysfn_activate ; 3 = activate window - dd sysfn_getidletime ; 4 = get idle time - dd sysfn_getcpuclock ; 5 = get cpu clock - dd sysfn_saveramdisk ; 6 = save ramdisk - dd sysfn_getactive ; 7 = get active window - dd sysfn_sound_flag ; 8 = get/set sound_flag - dd sysfn_shutdown ; 9 = shutdown with parameter - dd sysfn_minimize ; 10 = minimize window - dd sysfn_getdiskinfo ; 11 = get disk subsystem info - dd sysfn_lastkey ; 12 = get last pressed key - dd sysfn_getversion ; 13 = get kernel version - dd sysfn_waitretrace ; 14 = wait retrace - dd sysfn_centermouse ; 15 = center mouse cursor - dd sysfn_getfreemem ; 16 = get free memory size - dd sysfn_getallmem ; 17 = get total memory size - dd sysfn_terminate2 ; 18 = terminate thread using PID - ; instead of slot - dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration - dd sysfn_meminfo ; 20 = get extended memory info - dd sysfn_pid_to_slot ; 21 = get slot number for pid - dd sysfn_min_rest_window ; 22 = minimize and restore any window + dd exit_for_anyone ; 1 = obsolete + dd sysfn_terminate ; 2 = terminate thread + dd sysfn_activate ; 3 = activate window + dd sysfn_getidletime ; 4 = get idle time + dd sysfn_getcpuclock ; 5 = get cpu clock + dd sysfn_saveramdisk ; 6 = save ramdisk + dd sysfn_getactive ; 7 = get active window + dd sysfn_sound_flag ; 8 = get/set sound_flag + dd sysfn_shutdown ; 9 = shutdown with parameter + dd sysfn_minimize ; 10 = minimize window + dd sysfn_getdiskinfo ; 11 = get disk subsystem info + dd sysfn_lastkey ; 12 = get last pressed key + dd sysfn_getversion ; 13 = get kernel version + dd sysfn_waitretrace ; 14 = wait retrace + dd sysfn_centermouse ; 15 = center mouse cursor + dd sysfn_getfreemem ; 16 = get free memory size + dd sysfn_getallmem ; 17 = get total memory size + dd sysfn_terminate2 ; 18 = terminate thread using PID + ; instead of slot + dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration + dd sysfn_meminfo ; 20 = get extended memory info + dd sysfn_pid_to_slot ; 21 = get slot number for pid + dd sysfn_min_rest_window ; 22 = minimize and restore any window sysfn_num = ($ - sys_system_table)/4 endg sys_system: - dec ebx - cmp ebx, sysfn_num - jae @f - jmp dword [sys_system_table + ebx*4] + dec ebx + cmp ebx, sysfn_num + jae @f + jmp dword [sys_system_table + ebx*4] @@: - ret + ret -sysfn_shutdown: ; 18.9 = system shutdown +sysfn_shutdown: ; 18.9 = system shutdown cmp ecx,1 jl exit_for_anyone cmp ecx,4 @@ -1895,7 +1838,7 @@ sysfn_shutdown: ; 18.9 = system shutdown shutdown_processes: dd 0x0 endg -sysfn_terminate: ; 18.2 = TERMINATE +sysfn_terminate: ; 18.2 = TERMINATE cmp ecx,2 jb noprocessterminate mov edx,[TASK_COUNT] @@ -1909,7 +1852,7 @@ sysfn_terminate: ; 18.2 = TERMINATE jz noprocessterminate ;call MEM_Heap_Lock ;guarantee that process isn't working with heap - mov [ecx],byte 3 ; clear possible i40's + mov [ecx],byte 3 ; clear possible i40's ;call MEM_Heap_UnLock cmp edx,[application_table_status] ; clear app table stat @@ -1925,7 +1868,7 @@ sysfn_terminate2: .table_status: cli cmp [application_table_status],0 - je .stf + je .stf sti call change_task jmp .table_status @@ -1934,7 +1877,7 @@ sysfn_terminate2: mov eax,ecx call pid_to_slot test eax,eax - jz .not_found + jz .not_found mov ecx,eax cli call sysfn_terminate @@ -1944,10 +1887,10 @@ sysfn_terminate2: ret .not_found: mov [application_table_status],0 - or dword [esp+32],-1 + or dword [esp+32],-1 ret -sysfn_activate: ; 18.3 = ACTIVATE WINDOW +sysfn_activate: ; 18.3 = ACTIVATE WINDOW cmp ecx,2 jb .nowindowactivate cmp ecx,[TASK_COUNT] @@ -1968,12 +1911,12 @@ sysfn_activate: ; 18.3 = ACTIVATE WINDOW .nowindowactivate: ret -sysfn_getidletime: ; 18.4 = GET IDLETIME +sysfn_getidletime: ; 18.4 = GET IDLETIME mov eax,[idleusesec] mov [esp+32], eax ret -sysfn_getcpuclock: ; 18.5 = GET TSC/SEC +sysfn_getcpuclock: ; 18.5 = GET TSC/SEC mov eax,[CPU_FREQ] mov [esp+32], eax ret @@ -1983,13 +1926,13 @@ sysfn_getcpuclock: ; 18.5 = GET TSC/SEC include 'blkdev/rdsave.inc' ;!!!!!!!!!!!!!!!!!!!!!!!! align 4 -sysfn_getactive: ; 18.7 = get active window +sysfn_getactive: ; 18.7 = get active window mov eax, [TASK_COUNT] movzx eax, word [WIN_POS + eax*2] mov [esp+32],eax ret -sysfn_sound_flag: ; 18.8 = get/set sound_flag +sysfn_sound_flag: ; 18.8 = get/set sound_flag ; cmp ecx,1 dec ecx jnz nogetsoundflag @@ -2004,11 +1947,11 @@ sysfn_sound_flag: ; 18.8 = get/set sound_flag nosoundflag: ret -sysfn_minimize: ; 18.10 = minimize window +sysfn_minimize: ; 18.10 = minimize window mov [window_minimize],1 ret align 4 -sysfn_getdiskinfo: ; 18.11 = get disk info table +sysfn_getdiskinfo: ; 18.11 = get disk info table ; cmp ecx,1 dec ecx jnz full_table @@ -2032,11 +1975,11 @@ sysfn_getdiskinfo: ; 18.11 = get disk info table rep movsd ret -sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) - and dword [esp+32], 0 - ret +sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) + and dword [esp+32], 0 + ret -sysfn_getversion: ; 18.13 = get kernel ID and version +sysfn_getversion: ; 18.13 = get kernel ID and version mov edi,ecx mov esi,version_inf mov ecx,version_end-version_inf @@ -2055,22 +1998,22 @@ sysfn_waitretrace: ; 18.14 = sys wait retrace ret align 4 -sysfn_centermouse: ; 18.15 = mouse centered +sysfn_centermouse: ; 18.15 = mouse centered ; removed here by ; call mouse_centered ;* mouse centered - start code- Mario79 ;mouse_centered: ; push eax - mov eax,[Screen_Max_X] - shr eax,1 - mov [MOUSE_X],ax - mov eax,[Screen_Max_Y] - shr eax,1 - mov [MOUSE_Y],ax + mov eax,[Screen_Max_X] + shr eax,1 + mov [MOUSE_X],ax + mov eax,[Screen_Max_Y] + shr eax,1 + mov [MOUSE_Y],ax ; ret ;* mouse centered - end code- Mario79 xor eax,eax - and [esp+32],eax + and [esp+32],eax ; pop eax ret @@ -2140,14 +2083,14 @@ sysfn_pid_to_slot: sysfn_min_rest_window: pushad - mov eax, edx ; ebx - operating + mov eax, edx ; ebx - operating shr ecx, 1 jnc @f call pid_to_slot @@: - or eax, eax ; eax - number of slot + or eax, eax ; eax - number of slot jz .error - cmp eax, 255 ; varify maximal slot number + cmp eax, 255 ; varify maximal slot number ja .error movzx eax, word [WIN_STACK + eax*2] shr ecx, 1 @@ -2175,7 +2118,7 @@ uglobal screen_workarea RECT ;// mike.dld, 2006-29-01 ] window_minimize db 0 -sound_flag db 0 +sound_flag db 0 endg iglobal @@ -2187,27 +2130,27 @@ version_end: endg UID_NONE=0 -UID_MENUETOS=1 ;official -UID_KOLIBRI=2 ;russian +UID_MENUETOS=1 ;official +UID_KOLIBRI=2 ;russian sys_cachetodiskette: - cmp ebx, 1 - jne .no_floppy_a_save - mov [flp_number], 1 - jmp .save_image_on_floppy + cmp ebx, 1 + jne .no_floppy_a_save + mov [flp_number], 1 + jmp .save_image_on_floppy .no_floppy_a_save: - cmp ebx, 2 - jne .no_floppy_b_save - mov [flp_number], 2 + cmp ebx, 2 + jne .no_floppy_b_save + mov [flp_number], 2 .save_image_on_floppy: - call save_image - mov [esp + 32], dword 0 - cmp [FDC_Status], 0 - je .yes_floppy_save + call save_image + mov [esp + 32], dword 0 + cmp [FDC_Status], 0 + je .yes_floppy_save .no_floppy_b_save: - mov [esp + 32], dword 1 + mov [esp + 32], dword 1 .yes_floppy_save: - ret + ret uglobal ; bgrchanged dd 0x0 @@ -2218,20 +2161,20 @@ endg sys_background: - cmp ebx,1 ; BACKGROUND SIZE + cmp ebx,1 ; BACKGROUND SIZE jnz nosb1 test ecx,ecx ; cmp ecx,0 - jz sbgrr + jz sbgrr test edx,edx ; cmp edx,0 - jz sbgrr + jz sbgrr @@: ;;Maxis use atomic bts for mutexes 4.4.2009 - bts dword [bgrlock], 0 - jnc @f - call change_task - jmp @b + bts dword [bgrlock], 0 + jnc @f + call change_task + jmp @b @@: mov [BgrDataWidth],ecx mov [BgrDataHeight],edx @@ -2239,10 +2182,10 @@ sys_background: pushad ; return memory for old background - mov eax, [img_background] - cmp eax, static_background_data - jz @f - stdcall kernel_free, eax + mov eax, [img_background] + cmp eax, static_background_data + jz @f + stdcall kernel_free, eax @@: ; calculate RAW size xor eax,eax @@ -2267,36 +2210,36 @@ sys_background: jmp .exit .memfailed: ; revert to static monotone data - mov [img_background], static_background_data - xor eax, eax - inc eax - mov [BgrDataWidth], eax - mov [BgrDataHeight], eax - mov [mem_BACKGROUND], 4 + mov [img_background], static_background_data + xor eax, eax + inc eax + mov [BgrDataWidth], eax + mov [BgrDataHeight], eax + mov [mem_BACKGROUND], 4 .exit: popad - mov [bgrlock], 0 + mov [bgrlock], 0 sbgrr: ret nosb1: - cmp ebx,2 ; SET PIXEL + cmp ebx,2 ; SET PIXEL jnz nosb2 mov eax, [img_background] test ecx, ecx - jz @f + jz @f cmp eax, static_background_data - jz .ret + jz .ret @@: mov ebx, [mem_BACKGROUND] add ebx, 4095 and ebx, -4096 sub ebx, 4 cmp ecx, ebx - ja .ret + ja .ret mov ebx,[eax+ecx] and ebx,0xFF000000 ;255*256*256*256 @@ -2307,7 +2250,7 @@ nosb1: ret nosb2: - cmp ebx,3 ; DRAW BACKGROUND + cmp ebx,3 ; DRAW BACKGROUND jnz nosb3 draw_background_temp: ; cmp [bgrchanged],1 ;0 @@ -2321,24 +2264,24 @@ draw_background_temp: ret nosb3: - cmp ebx,4 ; TILED / STRETCHED + cmp ebx,4 ; TILED / STRETCHED jnz nosb4 cmp ecx,[BgrDrawMode] - je nosb41 + je nosb41 mov [BgrDrawMode],ecx ; mov [bgrchanged],1 nosb41: ret nosb4: - cmp ebx,5 ; BLOCK MOVE TO BGR + cmp ebx,5 ; BLOCK MOVE TO BGR jnz nosb5 cmp [img_background], static_background_data jnz @f test edx, edx jnz .fin cmp esi, 4 - ja .fin + ja .fin @@: ; bughere mov eax, ecx @@ -2350,87 +2293,87 @@ draw_background_temp: ret nosb5: - cmp ebx, 6 - jnz nosb6 + cmp ebx, 6 + jnz nosb6 ;;Maxis use atomic bts for mutex 4.4.2009 @@: - bts dword [bgrlock], 0 - jnc @f - call change_task - jmp @b + bts dword [bgrlock], 0 + jnc @f + call change_task + jmp @b @@: - mov eax, [CURRENT_TASK] - mov [bgrlockpid], eax - cmp [img_background], static_background_data - jz .nomem - stdcall user_alloc, [mem_BACKGROUND] - mov [esp+32], eax - test eax, eax - jz .nomem - mov ebx, eax - shr ebx, 12 - or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK - mov esi, [img_background] - shr esi, 12 - mov ecx, [mem_BACKGROUND] - add ecx, 0xFFF - shr ecx, 12 + mov eax, [CURRENT_TASK] + mov [bgrlockpid], eax + cmp [img_background], static_background_data + jz .nomem + stdcall user_alloc, [mem_BACKGROUND] + mov [esp+32], eax + test eax, eax + jz .nomem + mov ebx, eax + shr ebx, 12 + or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK + mov esi, [img_background] + shr esi, 12 + mov ecx, [mem_BACKGROUND] + add ecx, 0xFFF + shr ecx, 12 .z: - mov eax, [page_tabs+ebx*4] - test al, 1 - jz @f - call free_page + mov eax, [page_tabs+ebx*4] + test al, 1 + jz @f + call free_page @@: - mov eax, [page_tabs+esi*4] - or al, PG_UW - mov [page_tabs+ebx*4], eax - mov eax, ebx - shl eax, 12 - invlpg [eax] - inc ebx - inc esi - loop .z - ret + mov eax, [page_tabs+esi*4] + or al, PG_UW + mov [page_tabs+ebx*4], eax + mov eax, ebx + shl eax, 12 + invlpg [eax] + inc ebx + inc esi + loop .z + ret .nomem: - and [bgrlockpid], 0 - mov [bgrlock], 0 + and [bgrlockpid], 0 + mov [bgrlock], 0 nosb6: - cmp ebx, 7 - jnz nosb7 - cmp [bgrlock], 0 - jz .err - mov eax, [CURRENT_TASK] - cmp [bgrlockpid], eax - jnz .err - mov eax, ecx - mov ebx, ecx - shr eax, 12 - mov ecx, [page_tabs+(eax-1)*4] - test cl, USED_BLOCK+DONT_FREE_BLOCK - jz .err - jnp .err - push eax - shr ecx, 12 - dec ecx + cmp ebx, 7 + jnz nosb7 + cmp [bgrlock], 0 + jz .err + mov eax, [CURRENT_TASK] + cmp [bgrlockpid], eax + jnz .err + mov eax, ecx + mov ebx, ecx + shr eax, 12 + mov ecx, [page_tabs+(eax-1)*4] + test cl, USED_BLOCK+DONT_FREE_BLOCK + jz .err + jnp .err + push eax + shr ecx, 12 + dec ecx @@: - and dword [page_tabs+eax*4], 0 - mov edx, eax - shl edx, 12 - push eax - invlpg [edx] - pop eax - inc eax - loop @b - pop eax - and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK - stdcall user_free, ebx - mov [esp+32], eax - and [bgrlockpid], 0 - mov [bgrlock], 0 - ret + and dword [page_tabs+eax*4], 0 + mov edx, eax + shl edx, 12 + push eax + invlpg [edx] + pop eax + inc eax + loop @b + pop eax + and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK + stdcall user_free, ebx + mov [esp+32], eax + and [bgrlockpid], 0 + mov [bgrlock], 0 + ret .err: - and dword [esp+32], 0 - ret + and dword [esp+32], 0 + ret nosb7: ret @@ -2451,7 +2394,7 @@ align 4 sys_getbackground: ; cmp eax,1 ; SIZE - dec ebx + dec ebx jnz nogb1 mov eax,[BgrDataWidth] shl eax,16 @@ -2461,21 +2404,21 @@ sys_getbackground: nogb1: ; cmp eax,2 ; PIXEL - dec ebx + dec ebx jnz nogb2 - mov eax, [img_background] - test ecx, ecx - jz @f - cmp eax, static_background_data - jz .ret + mov eax, [img_background] + test ecx, ecx + jz @f + cmp eax, static_background_data + jz .ret @@: mov ebx, [mem_BACKGROUND] add ebx, 4095 and ebx, -4096 sub ebx, 4 cmp ecx, ebx - ja .ret + ja .ret mov eax,[ecx+eax] @@ -2497,67 +2440,67 @@ nogb1: align 4 sys_getkey: - mov [esp + 32],dword 1 - ; test main buffer - mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK - movzx ecx, word [WIN_STACK + ebx * 2] - mov edx, [TASK_COUNT] - cmp ecx, edx - jne .finish - cmp [KEY_COUNT], byte 0 - je .finish - movzx eax, byte [KEY_BUFF] - shl eax, 8 - push eax - dec byte [KEY_COUNT] - and byte [KEY_COUNT], 127 - movzx ecx, byte [KEY_COUNT] - add ecx, 2 - mov eax, KEY_BUFF + 1 - mov ebx, KEY_BUFF - call memmove - pop eax + mov [esp + 32],dword 1 + ; test main buffer + mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK + movzx ecx, word [WIN_STACK + ebx * 2] + mov edx, [TASK_COUNT] + cmp ecx, edx + jne .finish + cmp [KEY_COUNT], byte 0 + je .finish + movzx eax, byte [KEY_BUFF] + shl eax, 8 + push eax + dec byte [KEY_COUNT] + and byte [KEY_COUNT], 127 + movzx ecx, byte [KEY_COUNT] + add ecx, 2 + mov eax, KEY_BUFF + 1 + mov ebx, KEY_BUFF + call memmove + pop eax .ret_eax: - mov [esp + 32], eax - ret + mov [esp + 32], eax + ret .finish: ; test hotkeys buffer - mov ecx, hotkey_buffer + mov ecx, hotkey_buffer @@: - cmp [ecx], ebx - jz .found - add ecx, 8 - cmp ecx, hotkey_buffer + 120 * 8 - jb @b - ret + cmp [ecx], ebx + jz .found + add ecx, 8 + cmp ecx, hotkey_buffer + 120 * 8 + jb @b + ret .found: - mov ax, [ecx + 6] - shl eax, 16 - mov ah, [ecx + 4] - mov al, 2 - and dword [ecx + 4], 0 - and dword [ecx], 0 - jmp .ret_eax + mov ax, [ecx + 6] + shl eax, 16 + mov ah, [ecx + 4] + mov al, 2 + and dword [ecx + 4], 0 + and dword [ecx], 0 + jmp .ret_eax align 4 sys_getbutton: - mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK - mov [esp + 32], dword 1 - movzx ecx, word [WIN_STACK + ebx * 2] - mov edx, [TASK_COUNT] ; less than 256 processes - cmp ecx, edx - jne .exit - movzx eax, byte [BTN_COUNT] - test eax, eax - jz .exit - mov eax, [BTN_BUFF] - and al, 0xFE ; delete left button bit - mov [BTN_COUNT], byte 0 - mov [esp + 32], eax + mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK + mov [esp + 32], dword 1 + movzx ecx, word [WIN_STACK + ebx * 2] + mov edx, [TASK_COUNT] ; less than 256 processes + cmp ecx, edx + jne .exit + movzx eax, byte [BTN_COUNT] + test eax, eax + jz .exit + mov eax, [BTN_BUFF] + and al, 0xFE ; delete left button bit + mov [BTN_COUNT], byte 0 + mov [esp + 32], eax .exit: - ret + ret align 4 @@ -2575,78 +2518,78 @@ sys_cpuusage: ; +30 dword PID , process idenfification number ; - cmp ecx,-1 ; who am I ? + cmp ecx,-1 ; who am I ? jne .no_who_am_i mov ecx,[CURRENT_TASK] .no_who_am_i: - cmp ecx, max_processes - ja .nofillbuf + cmp ecx, max_processes + ja .nofillbuf ; +4: word: position of the window of thread in the window stack - mov ax, [WIN_STACK + ecx * 2] - mov [ebx+4], ax + mov ax, [WIN_STACK + ecx * 2] + mov [ebx+4], ax ; +6: word: number of the thread slot, which window has in the window stack ; position ecx (has no relation to the specific thread) - mov ax, [WIN_POS + ecx * 2] - mov [ebx+6], ax + mov ax, [WIN_POS + ecx * 2] + mov [ebx+6], ax - shl ecx, 5 + shl ecx, 5 ; +0: dword: memory usage - mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] - mov [ebx], eax + mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] + mov [ebx], eax ; +10: 11 bytes: name of the process - push ecx - lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] - add ebx, 10 - mov ecx, 11 - call memmove - pop ecx + push ecx + lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] + add ebx, 10 + mov ecx, 11 + call memmove + pop ecx ; +22: address of the process in memory ; +26: size of used memory - 1 - push edi - lea edi, [ebx+12] - xor eax, eax - mov edx, 0x100000*16 - cmp ecx, 1 shl 5 - je .os_mem - mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] - mov eax, std_application_base_address + push edi + lea edi, [ebx+12] + xor eax, eax + mov edx, 0x100000*16 + cmp ecx, 1 shl 5 + je .os_mem + mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] + mov eax, std_application_base_address .os_mem: - stosd - lea eax, [edx-1] - stosd + stosd + lea eax, [edx-1] + stosd ; +30: PID/TID - mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] - stosd + mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] + stosd ; window position and size - push esi - lea esi, [ecx + window_data + WDATA.box] - movsd - movsd - movsd - movsd + push esi + lea esi, [ecx + window_data + WDATA.box] + movsd + movsd + movsd + movsd ; Process state (+50) - mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] - stosd + mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] + stosd ; Window client area box - lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] - movsd - movsd - movsd - movsd + lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] + movsd + movsd + movsd + movsd ; Window state - mov al, [ecx+window_data+WDATA.fl_wstate] - stosb + mov al, [ecx+window_data+WDATA.fl_wstate] + stosb - pop esi - pop edi + pop esi + pop edi .nofillbuf: ; return number of processes @@ -2657,133 +2600,133 @@ sys_cpuusage: align 4 sys_clock: - cli + cli ; Mikhail Lisovin xx Jan 2005 - @@: mov al, 10 - out 0x70, al - in al, 0x71 - test al, al - jns @f - mov esi, 1 - call delay_ms - jmp @b + @@: mov al, 10 + out 0x70, al + in al, 0x71 + test al, al + jns @f + mov esi, 1 + call delay_ms + jmp @b @@: ; end Lisovin's fix - xor al,al ; seconds - out 0x70,al - in al,0x71 - movzx ecx,al - mov al,02 ; minutes - shl ecx,16 - out 0x70,al - in al,0x71 - movzx edx,al - mov al,04 ; hours - shl edx,8 - out 0x70,al - in al,0x71 - add ecx,edx - movzx edx,al - add ecx,edx - sti - mov [esp + 32], ecx - ret + xor al,al ; seconds + out 0x70,al + in al,0x71 + movzx ecx,al + mov al,02 ; minutes + shl ecx,16 + out 0x70,al + in al,0x71 + movzx edx,al + mov al,04 ; hours + shl edx,8 + out 0x70,al + in al,0x71 + add ecx,edx + movzx edx,al + add ecx,edx + sti + mov [esp + 32], ecx + ret align 4 sys_date: - cli - @@: mov al, 10 - out 0x70, al - in al, 0x71 - test al, al - jns @f - mov esi, 1 - call delay_ms - jmp @b + cli + @@: mov al, 10 + out 0x70, al + in al, 0x71 + test al, al + jns @f + mov esi, 1 + call delay_ms + jmp @b @@: - mov ch,0 - mov al,7 ; date - out 0x70,al - in al,0x71 - mov cl,al - mov al,8 ; month - shl ecx,16 - out 0x70,al - in al,0x71 - mov ch,al - mov al,9 ; year - out 0x70,al - in al,0x71 - mov cl,al - sti - mov [esp+32], ecx - ret + mov ch,0 + mov al,7 ; date + out 0x70,al + in al,0x71 + mov cl,al + mov al,8 ; month + shl ecx,16 + out 0x70,al + in al,0x71 + mov ch,al + mov al,9 ; year + out 0x70,al + in al,0x71 + mov cl,al + sti + mov [esp+32], ecx + ret ; redraw status sys_redrawstat: - cmp ebx, 1 - jne no_widgets_away - ; buttons away - mov ecx,[CURRENT_TASK] + cmp ebx, 1 + jne no_widgets_away + ; buttons away + mov ecx,[CURRENT_TASK] sys_newba2: - mov edi,[BTN_ADDR] - cmp [edi], dword 0 ; empty button list ? - je end_of_buttons_away - movzx ebx, word [edi] - inc ebx - mov eax,edi + mov edi,[BTN_ADDR] + cmp [edi], dword 0 ; empty button list ? + je end_of_buttons_away + movzx ebx, word [edi] + inc ebx + mov eax,edi sys_newba: - dec ebx - jz end_of_buttons_away + dec ebx + jz end_of_buttons_away - add eax, 0x10 - cmp cx, [eax] - jnz sys_newba + add eax, 0x10 + cmp cx, [eax] + jnz sys_newba - push eax ebx ecx - mov ecx,ebx - inc ecx - shl ecx, 4 - mov ebx, eax - add eax, 0x10 - call memmove - dec dword [edi] - pop ecx ebx eax + push eax ebx ecx + mov ecx,ebx + inc ecx + shl ecx, 4 + mov ebx, eax + add eax, 0x10 + call memmove + dec dword [edi] + pop ecx ebx eax - jmp sys_newba2 + jmp sys_newba2 end_of_buttons_away: - ret + ret no_widgets_away: - cmp ebx, 2 - jnz srl1 + cmp ebx, 2 + jnz srl1 - mov edx, [TASK_BASE] ; return whole screen draw area for this app - add edx, draw_data - CURRENT_TASK - mov [edx + RECT.left], 0 - mov [edx + RECT.top], 0 - mov eax, [Screen_Max_X] - mov [edx + RECT.right], eax - mov eax, [Screen_Max_Y] - mov [edx + RECT.bottom], eax + mov edx, [TASK_BASE] ; return whole screen draw area for this app + add edx, draw_data - CURRENT_TASK + mov [edx + RECT.left], 0 + mov [edx + RECT.top], 0 + mov eax, [Screen_Max_X] + mov [edx + RECT.right], eax + mov eax, [Screen_Max_Y] + mov [edx + RECT.bottom], eax - mov edi, [TASK_BASE] - or [edi - twdw + WDATA.fl_wdrawn], 1 ; no new position & buttons from app - call sys_window_mouse - ret + mov edi, [TASK_BASE] + or [edi - twdw + WDATA.fl_wdrawn], 1 ; no new position & buttons from app + call sys_window_mouse + ret srl1: - ret + ret ;ok - 100% work ;nt - not tested @@ -2811,7 +2754,7 @@ sheduler: dd sys_sheduler.03 dd sys_sheduler.04 endg -sys_sheduler: +sys_sheduler: ;rewritten by 29.12.2009 jmp dword [sheduler+ebx*4] ;.shed_counter: @@ -2823,55 +2766,55 @@ sys_sheduler: .02: ;.perf_control: inc ebx ;before ebx=2, ebx=3 - cmp ebx,ecx ;if ecx=3, ebx=3 - jz cache_disable + cmp ebx,ecx ;if ecx=3, ebx=3 + jz cache_disable - dec ebx ;ebx=2 - cmp ebx,ecx ; + dec ebx ;ebx=2 + cmp ebx,ecx ; jz cache_enable ;if ecx=2 and ebx=2 - dec ebx ;ebx=1 + dec ebx ;ebx=1 cmp ebx,ecx - jz is_cache_enabled ;if ecx=1 and ebx=1 + jz is_cache_enabled ;if ecx=1 and ebx=1 dec ebx - test ebx,ecx ;ebx=0 and ecx=0 - jz modify_pce ;if ecx=0 + test ebx,ecx ;ebx=0 and ecx=0 + jz modify_pce ;if ecx=0 ret -.03: +.03: ;.rdmsr_instr: ;now counter in ecx ;(edx:eax) esi:edi => edx:esi - mov eax,esi + mov eax,esi mov ecx,edx rdmsr - mov [esp+32],eax - mov [esp+20],edx ;ret in ebx? + mov [esp+32],eax + mov [esp+20],edx ;ret in ebx? ret .04: ;.wrmsr_instr: ;now counter in ecx ;(edx:eax) esi:edi => edx:esi - ; Fast Call MSR can't be destroy - ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш - ; включаются/выключаются расширенные возможности - cmp edx,MSR_SYSENTER_CS - je @f - cmp edx,MSR_SYSENTER_ESP - je @f - cmp edx,MSR_SYSENTER_EIP - je @f - cmp edx,MSR_AMD_STAR - je @f + ; Fast Call MSR can't be destroy + ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш + ; включаются/выключаются расширенные возможности + cmp edx,MSR_SYSENTER_CS + je @f + cmp edx,MSR_SYSENTER_ESP + je @f + cmp edx,MSR_SYSENTER_EIP + je @f + cmp edx,MSR_AMD_STAR + je @f - mov eax,esi + mov eax,esi mov ecx,edx - wrmsr - ; mov [esp + 32], eax - ; mov [esp + 20], edx ;ret in ebx? + wrmsr + ; mov [esp + 32], eax + ; mov [esp + 20], edx ;ret in ebx? @@: ret @@ -2913,28 +2856,28 @@ ret ; check if pixel is allowed to be drawn checkpixel: - push eax edx + push eax edx - mov edx,[Screen_Max_X] ; screen x size - inc edx - imul edx, ebx - add eax, [_WinMapAddress] - mov dl, [eax+edx] ; lea eax, [...] + mov edx,[Screen_Max_X] ; screen x size + inc edx + imul edx, ebx + add eax, [_WinMapAddress] + mov dl, [eax+edx] ; lea eax, [...] - xor ecx, ecx - mov eax, [CURRENT_TASK] - cmp al, dl - setne cl + xor ecx, ecx + mov eax, [CURRENT_TASK] + cmp al, dl + setne cl - pop edx eax - ret + pop edx eax + ret iglobal cpustring db 'CPU',0 endg uglobal -background_defined db 0 ; diamond, 11.04.2006 +background_defined db 0 ; diamond, 11.04.2006 endg align 4 @@ -2945,8 +2888,8 @@ checkmisc: cmp [ctrl_alt_del], 1 jne nocpustart - mov ebp, cpustring - call fs_execute_from_sysdir + mov ebp, cpustring + call fs_execute_from_sysdir mov [ctrl_alt_del], 0 @@ -2955,27 +2898,27 @@ nocpustart: jne mouse_not_active mov [mouse_active], 0 xor edi, edi - mov ecx, [TASK_COUNT] + mov ecx, [TASK_COUNT] set_mouse_event: add edi, 256 - or [edi+SLOT_BASE+APPDATA.event_mask], dword 100000b + or [edi+SLOT_BASE+APPDATA.event_mask], dword 100000b loop set_mouse_event mouse_not_active: cmp byte[BACKGROUND_CHANGED], 0 - jz no_set_bgr_event + jz no_set_bgr_event xor edi, edi mov ecx, [TASK_COUNT] set_bgr_event: add edi, 256 - or [edi+SLOT_BASE+APPDATA.event_mask], 16 + or [edi+SLOT_BASE+APPDATA.event_mask], 16 loop set_bgr_event mov byte[BACKGROUND_CHANGED], 0 no_set_bgr_event: - cmp byte[REDRAW_BACKGROUND], 0 ; background update ? - jz nobackgr + cmp byte[REDRAW_BACKGROUND], 0 ; background update ? + jz nobackgr cmp [background_defined], 0 - jz nobackgr + jz nobackgr ; mov [draw_data+32 + RECT.left],dword 0 ; mov [draw_data+32 + RECT.top],dword 0 ; mov eax,[Screen_Max_X] @@ -2986,7 +2929,7 @@ no_set_bgr_event: call drawbackground xor eax, eax xchg al, [REDRAW_BACKGROUND] - test al, al ; got new update request? + test al, al ; got new update request? jnz @b mov [draw_data+32 + RECT.left], eax mov [draw_data+32 + RECT.top], eax @@ -2999,7 +2942,7 @@ nobackgr: ; system shutdown request cmp [SYS_SHUTDOWN],byte 0 - je noshutdown + je noshutdown mov edx,[shutdown_processes] @@ -3020,21 +2963,21 @@ markz: call [_display.disable_mouse] dec byte [SYS_SHUTDOWN] - je system_shutdown + je system_shutdown noshutdown: - mov eax,[TASK_COUNT] ; termination + mov eax,[TASK_COUNT] ; termination mov ebx,TASK_DATA+TASKDATA.state mov esi,1 newct: mov cl,[ebx] cmp cl,byte 3 - jz terminate + jz terminate cmp cl,byte 4 - jz terminate + jz terminate add ebx,0x20 inc esi @@ -3048,151 +2991,151 @@ redrawscreen: ; eax , if process window_data base is eax, do not set flag/limits - pushad - push eax + pushad + push eax ;;; mov ebx,2 ;;; call delay_hs - ;mov ecx,0 ; redraw flags for apps - xor ecx,ecx + ;mov ecx,0 ; redraw flags for apps + xor ecx,ecx newdw2: - inc ecx - push ecx + inc ecx + push ecx - mov eax,ecx - shl eax,5 - add eax,window_data + mov eax,ecx + shl eax,5 + add eax,window_data - cmp eax,[esp+4] - je not_this_task - ; check if window in redraw area - mov edi,eax + cmp eax,[esp+4] + je not_this_task + ; check if window in redraw area + mov edi,eax - cmp ecx,1 ; limit for background - jz bgli + cmp ecx,1 ; limit for background + jz bgli - mov eax, [edi + WDATA.box.left] - mov ebx, [edi + WDATA.box.top] - mov ecx, [edi + WDATA.box.width] - mov edx, [edi + WDATA.box.height] - add ecx,eax - add edx,ebx + mov eax, [edi + WDATA.box.left] + mov ebx, [edi + WDATA.box.top] + mov ecx, [edi + WDATA.box.width] + mov edx, [edi + WDATA.box.height] + add ecx,eax + add edx,ebx - mov ecx,[draw_limits.bottom] ; ecx = area y end ebx = window y start - cmp ecx,ebx - jb ricino + mov ecx,[draw_limits.bottom] ; ecx = area y end ebx = window y start + cmp ecx,ebx + jb ricino - mov ecx,[draw_limits.right] ; ecx = area x end eax = window x start - cmp ecx,eax - jb ricino + mov ecx,[draw_limits.right] ; ecx = area x end eax = window x start + cmp ecx,eax + jb ricino - mov eax, [edi + WDATA.box.left] - mov ebx, [edi + WDATA.box.top] - mov ecx, [edi + WDATA.box.width] - mov edx, [edi + WDATA.box.height] - add ecx, eax - add edx, ebx + mov eax, [edi + WDATA.box.left] + mov ebx, [edi + WDATA.box.top] + mov ecx, [edi + WDATA.box.width] + mov edx, [edi + WDATA.box.height] + add ecx, eax + add edx, ebx - mov eax,[draw_limits.top] ; eax = area y start edx = window y end - cmp edx,eax - jb ricino + mov eax,[draw_limits.top] ; eax = area y start edx = window y end + cmp edx,eax + jb ricino - mov eax,[draw_limits.left] ; eax = area x start ecx = window x end - cmp ecx,eax - jb ricino + mov eax,[draw_limits.left] ; eax = area x start ecx = window x end + cmp ecx,eax + jb ricino - bgli: + bgli: - cmp dword[esp], 1 - jnz .az + cmp dword[esp], 1 + jnz .az ; cmp byte[BACKGROUND_CHANGED], 0 ; jnz newdw8 - cmp byte[REDRAW_BACKGROUND], 0 - jz .az - mov dl, 0 - lea eax,[edi+draw_data-window_data] - mov ebx,[draw_limits.left] - cmp ebx,[eax+RECT.left] - jae @f - mov [eax+RECT.left],ebx - mov dl, 1 - @@: - mov ebx,[draw_limits.top] - cmp ebx,[eax+RECT.top] - jae @f - mov [eax+RECT.top],ebx - mov dl, 1 - @@: - mov ebx,[draw_limits.right] - cmp ebx,[eax+RECT.right] - jbe @f - mov [eax+RECT.right],ebx - mov dl, 1 - @@: - mov ebx,[draw_limits.bottom] - cmp ebx,[eax+RECT.bottom] - jbe @f - mov [eax+RECT.bottom],ebx - mov dl, 1 - @@: - add byte[REDRAW_BACKGROUND], dl - jmp newdw8 - .az: + cmp byte[REDRAW_BACKGROUND], 0 + jz .az + mov dl, 0 + lea eax,[edi+draw_data-window_data] + mov ebx,[draw_limits.left] + cmp ebx,[eax+RECT.left] + jae @f + mov [eax+RECT.left],ebx + mov dl, 1 + @@: + mov ebx,[draw_limits.top] + cmp ebx,[eax+RECT.top] + jae @f + mov [eax+RECT.top],ebx + mov dl, 1 + @@: + mov ebx,[draw_limits.right] + cmp ebx,[eax+RECT.right] + jbe @f + mov [eax+RECT.right],ebx + mov dl, 1 + @@: + mov ebx,[draw_limits.bottom] + cmp ebx,[eax+RECT.bottom] + jbe @f + mov [eax+RECT.bottom],ebx + mov dl, 1 + @@: + add byte[REDRAW_BACKGROUND], dl + jmp newdw8 + .az: - mov eax,edi - add eax,draw_data-window_data + mov eax,edi + add eax,draw_data-window_data - mov ebx,[draw_limits.left] ; set limits - mov [eax + RECT.left], ebx - mov ebx,[draw_limits.top] - mov [eax + RECT.top], ebx - mov ebx,[draw_limits.right] - mov [eax + RECT.right], ebx - mov ebx,[draw_limits.bottom] - mov [eax + RECT.bottom], ebx + mov ebx,[draw_limits.left] ; set limits + mov [eax + RECT.left], ebx + mov ebx,[draw_limits.top] + mov [eax + RECT.top], ebx + mov ebx,[draw_limits.right] + mov [eax + RECT.right], ebx + mov ebx,[draw_limits.bottom] + mov [eax + RECT.bottom], ebx - sub eax,draw_data-window_data + sub eax,draw_data-window_data - cmp dword [esp],1 - jne nobgrd - inc byte[REDRAW_BACKGROUND] + cmp dword [esp],1 + jne nobgrd + inc byte[REDRAW_BACKGROUND] newdw8: nobgrd: - mov [eax + WDATA.fl_redraw],byte 1 ; mark as redraw + mov [eax + WDATA.fl_redraw],byte 1 ; mark as redraw ricino: not_this_task: - pop ecx + pop ecx - cmp ecx,[TASK_COUNT] - jle newdw2 + cmp ecx,[TASK_COUNT] + jle newdw2 - pop eax - popad + pop eax + popad - ret + ret calculatebackground: ; background - mov edi, [_WinMapAddress] ; set os to use all pixels - mov eax,0x01010101 - mov ecx, [_WinMapSize] - shr ecx, 2 - rep stosd + mov edi, [_WinMapAddress] ; set os to use all pixels + mov eax,0x01010101 + mov ecx, [_WinMapSize] + shr ecx, 2 + rep stosd - mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! - mov byte[BACKGROUND_CHANGED], 0 + mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! + mov byte[BACKGROUND_CHANGED], 0 - ret + ret uglobal - imax dd 0x0 + imax dd 0x0 endg @@ -3200,65 +3143,65 @@ endg delay_ms: ; delay in 1/1000 sec - push eax - push ecx + push eax + push ecx - mov ecx,esi - ; - imul ecx, 33941 - shr ecx, 9 - ; + mov ecx,esi + ; + imul ecx, 33941 + shr ecx, 9 + ; - in al,0x61 - and al,0x10 - mov ah,al - cld + in al,0x61 + and al,0x10 + mov ah,al + cld - cnt1: in al,0x61 - and al,0x10 - cmp al,ah - jz cnt1 + cnt1: in al,0x61 + and al,0x10 + cmp al,ah + jz cnt1 - mov ah,al - loop cnt1 + mov ah,al + loop cnt1 - pop ecx - pop eax + pop ecx + pop eax - ret + ret set_app_param: - mov edi, [TASK_BASE] - mov eax, [edi + TASKDATA.event_mask] - mov [edi + TASKDATA.event_mask], ebx - mov [esp+32], eax - ret + mov edi, [TASK_BASE] + mov eax, [edi + TASKDATA.event_mask] + mov [edi + TASKDATA.event_mask], ebx + mov [esp+32], eax + ret delay_hs: ; delay in 1/100 secs ; ebx = delay time - push ecx - push edx + push ecx + push edx - mov edx,[timer_ticks] + mov edx,[timer_ticks] newtic: - mov ecx,[timer_ticks] - sub ecx,edx - cmp ecx,ebx - jae zerodelay + mov ecx,[timer_ticks] + sub ecx,edx + cmp ecx,ebx + jae zerodelay - call change_task + call change_task - jmp newtic + jmp newtic zerodelay: - pop edx - pop ecx + pop edx + pop ecx - ret + ret align 16 ;very often call this subrutine memmove: ; memory move in bytes @@ -3275,14 +3218,14 @@ memmove: ; memory move in bytes mov esi, eax test ecx, not 11b - jz @f + jz @f push ecx shr ecx, 2 rep movsd pop ecx and ecx, 11b - jz .finish + jz .finish @@: rep movsb @@ -3343,7 +3286,7 @@ memmove: ; memory move in bytes align 4 sys_programirq: - ; removed + ; removed mov dword [esp+32], 1 ; operation failed ret @@ -3352,7 +3295,7 @@ align 4 get_irq_data: ; removed - mov dword [esp+32], -1 + mov dword [esp+32], -1 ret @@ -3454,7 +3397,7 @@ drawbackground: align 4 -syscall_putimage: ; PutImage +syscall_putimage: ; PutImage sys_putimage: test ecx,0x80008000 jnz .exit @@ -3465,15 +3408,15 @@ sys_putimage: .exit: ret @@: - mov edi,[current_slot] - add dx,word[edi+APPDATA.wnd_clientbox.top] - rol edx,16 - add dx,word[edi+APPDATA.wnd_clientbox.left] - rol edx,16 + mov edi,[current_slot] + add dx,word[edi+APPDATA.wnd_clientbox.top] + rol edx,16 + add dx,word[edi+APPDATA.wnd_clientbox.left] + rol edx,16 .forced: - push ebp esi 0 - mov ebp, putimage_get24bpp - mov esi, putimage_init24bpp + push ebp esi 0 + mov ebp, putimage_get24bpp + mov esi, putimage_init24bpp sys_putimage_bpp: ; cmp [SCR_MODE], word 0x12 ; jz @f ;.doit @@ -3483,13 +3426,13 @@ sys_putimage_bpp: ; cmp [SCR_MODE], word 0x13 ; jnz .doit ;@@: - mov eax, vesa20_putimage + mov eax, vesa20_putimage .doit: - inc [mouse_pause] - call eax - dec [mouse_pause] - pop ebp esi ebp - jmp [draw_pointer] + inc [mouse_pause] + call eax + dec [mouse_pause] + pop ebp esi ebp + jmp [draw_pointer] align 4 sys_putimage_palette: ; ebx = pointer to image @@ -3498,277 +3441,277 @@ sys_putimage_palette: ; esi = number of bits per pixel, must be 8, 24 or 32 ; edi = pointer to palette ; ebp = row delta - mov eax, [CURRENT_TASK] - shl eax, 8 - add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] - rol edx, 16 - add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] - rol edx, 16 + mov eax, [CURRENT_TASK] + shl eax, 8 + add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] + rol edx, 16 + add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] + rol edx, 16 .forced: - cmp esi, 1 - jnz @f - push edi - mov eax, [edi+4] - sub eax, [edi] - push eax - push dword [edi] - push 0ffffff80h - mov edi, esp - call put_mono_image - add esp, 12 - pop edi - ret + cmp esi, 1 + jnz @f + push edi + mov eax, [edi+4] + sub eax, [edi] + push eax + push dword [edi] + push 0ffffff80h + mov edi, esp + call put_mono_image + add esp, 12 + pop edi + ret @@: - cmp esi, 2 - jnz @f - push edi - push 0ffffff80h - mov edi, esp - call put_2bit_image - pop eax - pop edi - ret + cmp esi, 2 + jnz @f + push edi + push 0ffffff80h + mov edi, esp + call put_2bit_image + pop eax + pop edi + ret @@: - cmp esi, 4 - jnz @f - push edi - push 0ffffff80h - mov edi, esp - call put_4bit_image - pop eax - pop edi - ret + cmp esi, 4 + jnz @f + push edi + push 0ffffff80h + mov edi, esp + call put_4bit_image + pop eax + pop edi + ret @@: - push ebp esi ebp - cmp esi, 8 - jnz @f - mov ebp, putimage_get8bpp - mov esi, putimage_init8bpp - jmp sys_putimage_bpp + push ebp esi ebp + cmp esi, 8 + jnz @f + mov ebp, putimage_get8bpp + mov esi, putimage_init8bpp + jmp sys_putimage_bpp @@: - cmp esi, 15 - jnz @f - mov ebp, putimage_get15bpp - mov esi, putimage_init15bpp - jmp sys_putimage_bpp + cmp esi, 15 + jnz @f + mov ebp, putimage_get15bpp + mov esi, putimage_init15bpp + jmp sys_putimage_bpp @@: - cmp esi, 16 - jnz @f - mov ebp, putimage_get16bpp - mov esi, putimage_init16bpp - jmp sys_putimage_bpp + cmp esi, 16 + jnz @f + mov ebp, putimage_get16bpp + mov esi, putimage_init16bpp + jmp sys_putimage_bpp @@: - cmp esi, 24 - jnz @f - mov ebp, putimage_get24bpp - mov esi, putimage_init24bpp - jmp sys_putimage_bpp + cmp esi, 24 + jnz @f + mov ebp, putimage_get24bpp + mov esi, putimage_init24bpp + jmp sys_putimage_bpp @@: - cmp esi, 32 - jnz @f - mov ebp, putimage_get32bpp - mov esi, putimage_init32bpp - jmp sys_putimage_bpp + cmp esi, 32 + jnz @f + mov ebp, putimage_get32bpp + mov esi, putimage_init32bpp + jmp sys_putimage_bpp @@: - pop ebp esi ebp - ret + pop ebp esi ebp + ret put_mono_image: - push ebp esi ebp - mov ebp, putimage_get1bpp - mov esi, putimage_init1bpp - jmp sys_putimage_bpp + push ebp esi ebp + mov ebp, putimage_get1bpp + mov esi, putimage_init1bpp + jmp sys_putimage_bpp put_2bit_image: - push ebp esi ebp - mov ebp, putimage_get2bpp - mov esi, putimage_init2bpp - jmp sys_putimage_bpp + push ebp esi ebp + mov ebp, putimage_get2bpp + mov esi, putimage_init2bpp + jmp sys_putimage_bpp put_4bit_image: - push ebp esi ebp - mov ebp, putimage_get4bpp - mov esi, putimage_init4bpp - jmp sys_putimage_bpp + push ebp esi ebp + mov ebp, putimage_get4bpp + mov esi, putimage_init4bpp + jmp sys_putimage_bpp putimage_init24bpp: - lea eax, [eax*3] + lea eax, [eax*3] putimage_init8bpp: - ret + ret align 16 putimage_get24bpp: - movzx eax, byte [esi+2] - shl eax, 16 - mov ax, [esi] - add esi, 3 - ret 4 + movzx eax, byte [esi+2] + shl eax, 16 + mov ax, [esi] + add esi, 3 + ret 4 align 16 putimage_get8bpp: - movzx eax, byte [esi] - push edx - mov edx, [esp+8] - mov eax, [edx+eax*4] - pop edx - inc esi - ret 4 + movzx eax, byte [esi] + push edx + mov edx, [esp+8] + mov eax, [edx+eax*4] + pop edx + inc esi + ret 4 putimage_init1bpp: - add eax, ecx - push ecx - add eax, 7 - add ecx, 7 - shr eax, 3 - shr ecx, 3 - sub eax, ecx - pop ecx - ret + add eax, ecx + push ecx + add eax, 7 + add ecx, 7 + shr eax, 3 + shr ecx, 3 + sub eax, ecx + pop ecx + ret align 16 putimage_get1bpp: - push edx - mov edx, [esp+8] - mov al, [edx] - add al, al - jnz @f - lodsb - adc al, al + push edx + mov edx, [esp+8] + mov al, [edx] + add al, al + jnz @f + lodsb + adc al, al @@: - mov [edx], al - sbb eax, eax - and eax, [edx+8] - add eax, [edx+4] - pop edx - ret 4 + mov [edx], al + sbb eax, eax + and eax, [edx+8] + add eax, [edx+4] + pop edx + ret 4 putimage_init2bpp: - add eax, ecx - push ecx - add ecx, 3 - add eax, 3 - shr ecx, 2 - shr eax, 2 - sub eax, ecx - pop ecx - ret + add eax, ecx + push ecx + add ecx, 3 + add eax, 3 + shr ecx, 2 + shr eax, 2 + sub eax, ecx + pop ecx + ret align 16 putimage_get2bpp: - push edx - mov edx, [esp+8] - mov al, [edx] - mov ah, al - shr al, 6 - shl ah, 2 - jnz .nonewbyte - lodsb - mov ah, al - shr al, 6 - shl ah, 2 - add ah, 1 + push edx + mov edx, [esp+8] + mov al, [edx] + mov ah, al + shr al, 6 + shl ah, 2 + jnz .nonewbyte + lodsb + mov ah, al + shr al, 6 + shl ah, 2 + add ah, 1 .nonewbyte: - mov [edx], ah - mov edx, [edx+4] - movzx eax, al - mov eax, [edx+eax*4] - pop edx - ret 4 + mov [edx], ah + mov edx, [edx+4] + movzx eax, al + mov eax, [edx+eax*4] + pop edx + ret 4 putimage_init4bpp: - add eax, ecx - push ecx - add ecx, 1 - add eax, 1 - shr ecx, 1 - shr eax, 1 - sub eax, ecx - pop ecx - ret + add eax, ecx + push ecx + add ecx, 1 + add eax, 1 + shr ecx, 1 + shr eax, 1 + sub eax, ecx + pop ecx + ret align 16 putimage_get4bpp: - push edx - mov edx, [esp+8] - add byte [edx], 80h - jc @f - movzx eax, byte [edx+1] - mov edx, [edx+4] - and eax, 0x0F - mov eax, [edx+eax*4] - pop edx - ret 4 + push edx + mov edx, [esp+8] + add byte [edx], 80h + jc @f + movzx eax, byte [edx+1] + mov edx, [edx+4] + and eax, 0x0F + mov eax, [edx+eax*4] + pop edx + ret 4 @@: - movzx eax, byte [esi] - add esi, 1 - mov [edx+1], al - shr eax, 4 - mov edx, [edx+4] - mov eax, [edx+eax*4] - pop edx - ret 4 + movzx eax, byte [esi] + add esi, 1 + mov [edx+1], al + shr eax, 4 + mov edx, [edx+4] + mov eax, [edx+eax*4] + pop edx + ret 4 putimage_init32bpp: - shl eax, 2 - ret + shl eax, 2 + ret align 16 putimage_get32bpp: - lodsd - ret 4 + lodsd + ret 4 putimage_init15bpp: putimage_init16bpp: - add eax, eax - ret + add eax, eax + ret align 16 putimage_get15bpp: ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 - push ecx edx - movzx eax, word [esi] - add esi, 2 - mov ecx, eax - mov edx, eax - and eax, 0x1F - and ecx, 0x1F shl 5 - and edx, 0x1F shl 10 - shl eax, 3 - shl ecx, 6 - shl edx, 9 - or eax, ecx - or eax, edx - pop edx ecx - ret 4 + push ecx edx + movzx eax, word [esi] + add esi, 2 + mov ecx, eax + mov edx, eax + and eax, 0x1F + and ecx, 0x1F shl 5 + and edx, 0x1F shl 10 + shl eax, 3 + shl ecx, 6 + shl edx, 9 + or eax, ecx + or eax, edx + pop edx ecx + ret 4 align 16 putimage_get16bpp: ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 - push ecx edx - movzx eax, word [esi] - add esi, 2 - mov ecx, eax - mov edx, eax - and eax, 0x1F - and ecx, 0x3F shl 5 - and edx, 0x1F shl 11 - shl eax, 3 - shl ecx, 5 - shl edx, 8 - or eax, ecx - or eax, edx - pop edx ecx - ret 4 + push ecx edx + movzx eax, word [esi] + add esi, 2 + mov ecx, eax + mov edx, eax + and eax, 0x1F + and ecx, 0x3F shl 5 + and edx, 0x1F shl 11 + shl eax, 3 + shl ecx, 5 + shl edx, 8 + or eax, ecx + or eax, edx + pop edx ecx + ret 4 ; eax x beginning ; ebx y beginning ; ecx x end - ; edx y end + ; edx y end ; edi color __sys_drawbar: - mov esi,[current_slot] - add eax,[esi+APPDATA.wnd_clientbox.left] - add ecx,[esi+APPDATA.wnd_clientbox.left] - add ebx,[esi+APPDATA.wnd_clientbox.top] - add edx,[esi+APPDATA.wnd_clientbox.top] + mov esi,[current_slot] + add eax,[esi+APPDATA.wnd_clientbox.left] + add ecx,[esi+APPDATA.wnd_clientbox.left] + add ebx,[esi+APPDATA.wnd_clientbox.top] + add edx,[esi+APPDATA.wnd_clientbox.top] .forced: inc [mouse_pause] ; call [disable_mouse] cmp [SCR_MODE],word 0x12 - je dbv20 + je dbv20 sdbv20: ; cmp [SCR_MODE],word 0100000000000000b ; jge dbv20 @@ -3788,36 +3731,36 @@ __sys_drawbar: kb_read: - push ecx edx + push ecx edx - mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's + mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's kr_loop: - in al,0x64 - test al,1 - jnz kr_ready - loop kr_loop - mov ah,1 - jmp kr_exit + in al,0x64 + test al,1 + jnz kr_ready + loop kr_loop + mov ah,1 + jmp kr_exit kr_ready: - push ecx - mov ecx,32 + push ecx + mov ecx,32 kr_delay: - loop kr_delay - pop ecx - in al,0x60 - xor ah,ah + loop kr_delay + pop ecx + in al,0x60 + xor ah,ah kr_exit: - pop edx ecx + pop edx ecx - ret + ret kb_write: - push ecx edx + push ecx edx - mov dl,al + mov dl,al ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's ; kw_loop1: ; in al,0x64 @@ -3827,75 +3770,75 @@ kb_write: ; mov ah,1 ; jmp kw_exit ; kw_ok1: - in al,0x60 - mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's + in al,0x60 + mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's kw_loop: - in al,0x64 - test al,2 - jz kw_ok - loop kw_loop - mov ah,1 - jmp kw_exit + in al,0x64 + test al,2 + jz kw_ok + loop kw_loop + mov ah,1 + jmp kw_exit kw_ok: - mov al,dl - out 0x60,al - mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's + mov al,dl + out 0x60,al + mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's kw_loop3: - in al,0x64 - test al,2 - jz kw_ok3 - loop kw_loop3 - mov ah,1 - jmp kw_exit + in al,0x64 + test al,2 + jz kw_ok3 + loop kw_loop3 + mov ah,1 + jmp kw_exit kw_ok3: - mov ah,8 + mov ah,8 kw_loop4: - mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's + mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's kw_loop5: - in al,0x64 - test al,1 - jnz kw_ok4 - loop kw_loop5 - dec ah - jnz kw_loop4 + in al,0x64 + test al,1 + jnz kw_ok4 + loop kw_loop5 + dec ah + jnz kw_loop4 kw_ok4: - xor ah,ah + xor ah,ah kw_exit: - pop edx ecx + pop edx ecx - ret + ret kb_cmd: - mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's + mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's c_wait: - in al,0x64 - test al,2 - jz c_send - loop c_wait - jmp c_error + in al,0x64 + test al,2 + jz c_send + loop c_wait + jmp c_error c_send: - mov al,bl - out 0x64,al - mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's + mov al,bl + out 0x64,al + mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's c_accept: - in al,0x64 - test al,2 - jz c_ok - loop c_accept + in al,0x64 + test al,2 + jz c_ok + loop c_accept c_error: - mov ah,1 - jmp c_exit + mov ah,1 + jmp c_exit c_ok: - xor ah,ah + xor ah,ah c_exit: - ret + ret setmouse: ; set mousepicture -pointer - ; ps2 mouse enable + ; ps2 mouse enable mov [MOUSE_PICTURE],dword mousepointer @@ -3917,60 +3860,60 @@ end if rerouteirqs: - cli + cli - mov al,0x11 ; icw4, edge triggered - out 0x20,al - call pic_delay - out 0xA0,al - call pic_delay + mov al,0x11 ; icw4, edge triggered + out 0x20,al + call pic_delay + out 0xA0,al + call pic_delay - mov al,0x20 ; generate 0x20 + - out 0x21,al - call pic_delay - mov al,0x28 ; generate 0x28 + - out 0xA1,al - call pic_delay + mov al,0x20 ; generate 0x20 + + out 0x21,al + call pic_delay + mov al,0x28 ; generate 0x28 + + out 0xA1,al + call pic_delay - mov al,0x04 ; slave at irq2 - out 0x21,al - call pic_delay - mov al,0x02 ; at irq9 - out 0xA1,al - call pic_delay + mov al,0x04 ; slave at irq2 + out 0x21,al + call pic_delay + mov al,0x02 ; at irq9 + out 0xA1,al + call pic_delay - mov al,0x01 ; 8086 mode - out 0x21,al - call pic_delay - out 0xA1,al - call pic_delay + mov al,0x01 ; 8086 mode + out 0x21,al + call pic_delay + out 0xA1,al + call pic_delay - mov al,255 ; mask all irq's - out 0xA1,al - call pic_delay - out 0x21,al - call pic_delay + mov al,255 ; mask all irq's + out 0xA1,al + call pic_delay + out 0x21,al + call pic_delay - mov ecx,0x1000 - cld -picl1: call pic_delay - loop picl1 + mov ecx,0x1000 + cld +picl1: call pic_delay + loop picl1 - mov al,255 ; mask all irq's - out 0xA1,al - call pic_delay - out 0x21,al - call pic_delay + mov al,255 ; mask all irq's + out 0xA1,al + call pic_delay + out 0x21,al + call pic_delay - cli + cli - ret + ret pic_delay: - jmp pdl1 -pdl1: ret + jmp pdl1 +pdl1: ret sys_msg_board_str: @@ -3992,43 +3935,43 @@ sys_msg_board_byte: ; in: al = byte to display ; out: nothing ; destroys: nothing - pushad - mov ecx, 2 - shl eax, 24 - jmp @f + pushad + mov ecx, 2 + shl eax, 24 + jmp @f sys_msg_board_word: ; in: ax = word to display ; out: nothing ; destroys: nothing - pushad - mov ecx, 4 - shl eax, 16 - jmp @f + pushad + mov ecx, 4 + shl eax, 16 + jmp @f sys_msg_board_dword: ; in: eax = dword to display ; out: nothing ; destroys: nothing - pushad - mov ecx, 8 + pushad + mov ecx, 8 @@: - push ecx - rol eax, 4 - push eax - and al, 0xF - cmp al, 10 - sbb al, 69h - das - mov bl, al - xor eax, eax - inc eax - call sys_msg_board - pop eax - pop ecx - loop @b - popad - ret + push ecx + rol eax, 4 + push eax + and al, 0xF + cmp al, 10 + sbb al, 69h + das + mov bl, al + xor eax, eax + inc eax + call sys_msg_board + pop eax + pop ecx + loop @b + popad + ret uglobal msg_board_data: times 4096 db 0 @@ -4040,52 +3983,52 @@ sys_msg_board: ; eax=1 : write : bl byte to write ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al - mov ecx, [msg_board_count] - cmp eax, 1 - jne .smbl1 + mov ecx, [msg_board_count] + cmp eax, 1 + jne .smbl1 if defined debug_com_base - push dx ax + push dx ax - @@: ; Wait for empty transmit register (yes, this slows down system..) - mov dx, debug_com_base+5 - in al, dx - test al, 1 shl 5 - jz @r + @@: ; Wait for empty transmit register (yes, this slows down system..) + mov dx, debug_com_base+5 + in al, dx + test al, 1 shl 5 + jz @r - mov dx, debug_com_base ; Output the byte - mov al, bl - out dx, al + mov dx, debug_com_base ; Output the byte + mov al, bl + out dx, al - pop ax dx + pop ax dx end if - mov [msg_board_data+ecx],bl - inc ecx - and ecx, 4095 - mov [msg_board_count], ecx - mov [check_idle_semaphore], 5 - ret + mov [msg_board_data+ecx],bl + inc ecx + and ecx, 4095 + mov [msg_board_count], ecx + mov [check_idle_semaphore], 5 + ret .smbl1: - cmp eax, 2 - jne .smbl2 - test ecx, ecx - jz .smbl21 - mov eax, msg_board_data+1 - mov ebx, msg_board_data - movzx edx, byte [ebx] - call memmove - dec [msg_board_count] - mov [esp + 36], edx ;eax - mov [esp + 24], dword 1 - ret + cmp eax, 2 + jne .smbl2 + test ecx, ecx + jz .smbl21 + mov eax, msg_board_data+1 + mov ebx, msg_board_data + movzx edx, byte [ebx] + call memmove + dec [msg_board_count] + mov [esp + 36], edx ;eax + mov [esp + 24], dword 1 + ret .smbl21: - mov [esp+36], ecx - mov [esp+24], ecx + mov [esp+36], ecx + mov [esp+24], ecx .smbl2: - ret + ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 66 sys function. ;; @@ -4095,11 +4038,11 @@ end if iglobal align 4 f66call: - dd sys_process_def.1 ; 1 = set keyboard mode - dd sys_process_def.2 ; 2 = get keyboard mode - dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift - dd sys_process_def.4 - dd sys_process_def.5 + dd sys_process_def.1 ; 1 = set keyboard mode + dd sys_process_def.2 ; 2 = get keyboard mode + dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift + dd sys_process_def.4 + dd sys_process_def.5 endg @@ -4110,7 +4053,7 @@ sys_process_def: cmp ebx,5 jae .not_support ;if >=6 then or eax,-1 - mov edi, [CURRENT_TASK] + mov edi, [CURRENT_TASK] jmp dword [f66call+ebx*4] .not_support: @@ -4144,63 +4087,63 @@ sys_process_def: ret .4: - mov eax, hotkey_list + mov eax, hotkey_list @@: - cmp dword [eax+8], 0 - jz .found_free - add eax, 16 - cmp eax, hotkey_list+16*256 - jb @b - mov dword [esp+32], 1 - ret + cmp dword [eax+8], 0 + jz .found_free + add eax, 16 + cmp eax, hotkey_list+16*256 + jb @b + mov dword [esp+32], 1 + ret .found_free: - mov [eax+8], edi - mov [eax+4], edx - movzx ecx, cl - lea ecx, [hotkey_scancodes+ecx*4] - mov edx, [ecx] - mov [eax], edx - mov [ecx], eax - mov [eax+12], ecx - jecxz @f - mov [edx+12], eax + mov [eax+8], edi + mov [eax+4], edx + movzx ecx, cl + lea ecx, [hotkey_scancodes+ecx*4] + mov edx, [ecx] + mov [eax], edx + mov [ecx], eax + mov [eax+12], ecx + jecxz @f + mov [edx+12], eax @@: - and dword [esp+32], 0 - ret + and dword [esp+32], 0 + ret .5: - movzx ebx, cl - lea ebx, [hotkey_scancodes+ebx*4] - mov eax, [ebx] + movzx ebx, cl + lea ebx, [hotkey_scancodes+ebx*4] + mov eax, [ebx] .scan: - test eax, eax - jz .notfound - cmp [eax+8], edi - jnz .next - cmp [eax+4], edx - jz .found + test eax, eax + jz .notfound + cmp [eax+8], edi + jnz .next + cmp [eax+4], edx + jz .found .next: - mov eax, [eax] - jmp .scan + mov eax, [eax] + jmp .scan .notfound: - mov dword [esp+32], 1 - ret + mov dword [esp+32], 1 + ret .found: - mov ecx, [eax] - jecxz @f - mov edx, [eax+12] - mov [ecx+12], edx + mov ecx, [eax] + jecxz @f + mov edx, [eax+12] + mov [ecx+12], edx @@: - mov ecx, [eax+12] - mov edx, [eax] - mov [ecx], edx - xor edx, edx - mov [eax+4], edx - mov [eax+8], edx - mov [eax+12], edx - mov [eax], edx - mov [esp+32], edx - ret + mov ecx, [eax+12] + mov edx, [eax] + mov [ecx], edx + xor edx, edx + mov [eax+4], edx + mov [eax+8], edx + mov [eax+12], edx + mov [eax], edx + mov [esp+32], edx + ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -4211,25 +4154,25 @@ sys_process_def: iglobal align 4 f61call: - dd sys_gs.1 ; resolution - dd sys_gs.2 ; bits per pixel - dd sys_gs.3 ; bytes per scanline + dd sys_gs.1 ; resolution + dd sys_gs.2 ; bits per pixel + dd sys_gs.3 ; bytes per scanline endg align 4 -sys_gs: ; direct screen access +sys_gs: ; direct screen access dec ebx cmp ebx,2 ja .not_support jmp dword [f61call+ebx*4] .not_support: or [esp+32],dword -1 - ret + ret -.1: ; resolution +.1: ; resolution mov eax,[Screen_Max_X] shl eax,16 mov ax,[Screen_Max_Y] @@ -4240,7 +4183,7 @@ sys_gs: ; direct screen access movzx eax,byte [ScreenBPP] mov [esp+32],eax ret -.3: ; bytes per scanline +.3: ; bytes per scanline mov eax,[BytesPerScanLine] mov [esp+32],eax ret @@ -4257,95 +4200,95 @@ sys_pci: align 4 ; system functions -syscall_setpixel: ; SetPixel +syscall_setpixel: ; SetPixel - mov eax, ebx - mov ebx, ecx - mov ecx, edx - mov edx, [TASK_BASE] - add eax, [edx-twdw+WDATA.box.left] - add ebx, [edx-twdw+WDATA.box.top] - mov edi, [current_slot] - add eax, [edi+APPDATA.wnd_clientbox.left] - add ebx, [edi+APPDATA.wnd_clientbox.top] - xor edi, edi ; no force + mov eax, ebx + mov ebx, ecx + mov ecx, edx + mov edx, [TASK_BASE] + add eax, [edx-twdw+WDATA.box.left] + add ebx, [edx-twdw+WDATA.box.top] + mov edi, [current_slot] + add eax, [edi+APPDATA.wnd_clientbox.left] + add ebx, [edi+APPDATA.wnd_clientbox.top] + xor edi, edi ; no force ; mov edi, 1 - call [_display.disable_mouse] - jmp [putpixel] + call [_display.disable_mouse] + jmp [putpixel] align 4 -syscall_writetext: ; WriteText +syscall_writetext: ; WriteText - mov eax,[TASK_BASE] - mov ebp,[eax-twdw+WDATA.box.left] - push esi - mov esi,[current_slot] - add ebp,[esi+APPDATA.wnd_clientbox.left] - shl ebp,16 - add ebp,[eax-twdw+WDATA.box.top] - add bp,word[esi+APPDATA.wnd_clientbox.top] - pop esi - add ebx,ebp - mov eax,edi - xor edi,edi - jmp dtext + mov eax,[TASK_BASE] + mov ebp,[eax-twdw+WDATA.box.left] + push esi + mov esi,[current_slot] + add ebp,[esi+APPDATA.wnd_clientbox.left] + shl ebp,16 + add ebp,[eax-twdw+WDATA.box.top] + add bp,word[esi+APPDATA.wnd_clientbox.top] + pop esi + add ebx,ebp + mov eax,edi + xor edi,edi + jmp dtext align 4 -syscall_openramdiskfile: ; OpenRamdiskFile +syscall_openramdiskfile: ; OpenRamdiskFile - mov eax, ebx - mov ebx, ecx - mov ecx, edx - mov edx, esi - mov esi, 12 - call fileread - mov [esp+32], eax - ret + mov eax, ebx + mov ebx, ecx + mov ecx, edx + mov edx, esi + mov esi, 12 + call fileread + mov [esp+32], eax + ret align 4 -syscall_drawrect: ; DrawRect +syscall_drawrect: ; DrawRect - mov edi, edx ; color + gradient - and edi, 0x80FFFFFF - test bx, bx ; x.size - je .drectr - test cx, cx ; y.size - je .drectr + mov edi, edx ; color + gradient + and edi, 0x80FFFFFF + test bx, bx ; x.size + je .drectr + test cx, cx ; y.size + je .drectr - mov eax, ebx ; bad idea - mov ebx, ecx + mov eax, ebx ; bad idea + mov ebx, ecx - movzx ecx, ax ; ecx - x.size - shr eax, 16 ; eax - x.coord - movzx edx, bx ; edx - y.size - shr ebx, 16 ; ebx - y.coord - mov esi, [current_slot] + movzx ecx, ax ; ecx - x.size + shr eax, 16 ; eax - x.coord + movzx edx, bx ; edx - y.size + shr ebx, 16 ; ebx - y.coord + mov esi, [current_slot] - add eax, [esi + APPDATA.wnd_clientbox.left] - add ebx, [esi + APPDATA.wnd_clientbox.top] - add ecx, eax - add edx, ebx - jmp [drawbar] + add eax, [esi + APPDATA.wnd_clientbox.left] + add ebx, [esi + APPDATA.wnd_clientbox.top] + add ecx, eax + add edx, ebx + jmp [drawbar] .drectr: - ret + ret align 4 -syscall_getscreensize: ; GetScreenSize - mov ax, [Screen_Max_X] - shl eax, 16 - mov ax, [Screen_Max_Y] - mov [esp + 32], eax - ret +syscall_getscreensize: ; GetScreenSize + mov ax, [Screen_Max_X] + shl eax, 16 + mov ax, [Screen_Max_Y] + mov [esp + 32], eax + ret align 4 align 4 -syscall_getpixel: ; GetPixel +syscall_getpixel: ; GetPixel mov ecx, [Screen_Max_X] inc ecx xor edx, edx @@ -4365,10 +4308,10 @@ syscall_getarea: ;ecx = [size x]*65536 + [size y] ;edx = [start x]*65536 + [start y] pushad - inc [mouse_pause] + inc [mouse_pause] ; Check of use of the hardware cursor. cmp [_display.disable_mouse],__sys_disable_mouse - jne @f + jne @f ; Since the test for the coordinates of the mouse should not be used, ; then use the call [disable_mouse] is not possible! cmp dword [MOUSE_VISIBLE],dword 0 @@ -4385,30 +4328,30 @@ syscall_getarea: mov ebx,edx and ebx,0xffff dec eax - dec ebx + dec ebx ; eax - x, ebx - y mov edx,ecx - + shr ecx,16 and edx,0xffff mov esi,ecx ; ecx - size x, edx - size y - - mov ebp,edx - dec ebp + + mov ebp,edx + dec ebp lea ebp,[ebp*3] - - imul ebp,esi - - mov esi,ecx - dec esi - lea esi,[esi*3] - + + imul ebp,esi + + mov esi,ecx + dec esi + lea esi,[esi*3] + add ebp,esi add ebp,edi add ebx,edx - + .start_y: push ecx edx .start_x: @@ -4416,7 +4359,7 @@ syscall_getarea: add eax,ecx call dword [GETPIXEL] ; eax - x, ebx - y - + mov [ebp],cx shr ecx,16 mov [ebp+2],cl @@ -4425,46 +4368,46 @@ syscall_getarea: sub ebp,3 dec ecx jnz .start_x - pop edx ecx - dec ebx + pop edx ecx + dec ebx dec edx jnz .start_y - dec [mouse_pause] + dec [mouse_pause] ; Check of use of the hardware cursor. cmp [_display.disable_mouse],__sys_disable_mouse - jne @f - call [draw_pointer] + jne @f + call [draw_pointer] @@: popad ret align 4 -syscall_drawline: ; DrawLine +syscall_drawline: ; DrawLine - mov edi, [TASK_BASE] - movzx eax, word[edi-twdw+WDATA.box.left] - mov ebp, eax - mov esi, [current_slot] - add ebp, [esi+APPDATA.wnd_clientbox.left] - add ax, word[esi+APPDATA.wnd_clientbox.left] - add ebp,ebx - shl eax, 16 - movzx ebx, word[edi-twdw+WDATA.box.top] - add eax, ebp - mov ebp, ebx - add ebp, [esi+APPDATA.wnd_clientbox.top] - add bx, word[esi+APPDATA.wnd_clientbox.top] - add ebp, ecx - shl ebx, 16 - xor edi, edi - add ebx, ebp - mov ecx, edx - jmp [draw_line] + mov edi, [TASK_BASE] + movzx eax, word[edi-twdw+WDATA.box.left] + mov ebp, eax + mov esi, [current_slot] + add ebp, [esi+APPDATA.wnd_clientbox.left] + add ax, word[esi+APPDATA.wnd_clientbox.left] + add ebp,ebx + shl eax, 16 + movzx ebx, word[edi-twdw+WDATA.box.top] + add eax, ebp + mov ebp, ebx + add ebp, [esi+APPDATA.wnd_clientbox.top] + add bx, word[esi+APPDATA.wnd_clientbox.top] + add ebp, ecx + shl ebx, 16 + xor edi, edi + add ebx, ebp + mov ecx, edx + jmp [draw_line] align 4 -syscall_getirqowner: ; GetIrqOwner +syscall_getirqowner: ; GetIrqOwner cmp ebx,16 jae .err @@ -4482,7 +4425,7 @@ syscall_getirqowner: ; GetIrqOwner align 4 -syscall_reserveportarea: ; ReservePortArea and FreePortArea +syscall_reserveportarea: ; ReservePortArea and FreePortArea call r_f_port_area mov [esp+32],eax @@ -4490,7 +4433,7 @@ syscall_reserveportarea: ; ReservePortArea and FreePortArea align 4 -syscall_threads: ; CreateThreads +syscall_threads: ; CreateThreads ; eax=1 create thread ; ; ebx=thread start @@ -4507,7 +4450,7 @@ align 4 stack_driver_stat: - call app_stack_handler ; Stack status + call app_stack_handler ; Stack status ; mov [check_idle_semaphore],5 ; enable these for zero delay ; call change_task ; between sent packet @@ -4517,7 +4460,7 @@ stack_driver_stat: align 4 -socket: ; Socket interface +socket: ; Socket interface call app_socket_handler ; mov [check_idle_semaphore],5 ; enable these for zero delay @@ -4529,7 +4472,7 @@ socket: ; Socket interface align 4 -read_from_hd: ; Read from hd - fn not in use +read_from_hd: ; Read from hd - fn not in use mov edi,[TASK_BASE] add edi,TASKDATA.mem_start @@ -4544,61 +4487,61 @@ read_from_hd: ; Read from hd - fn not in use ret paleholder: - ret + ret align 4 set_screen: - cmp eax, [Screen_Max_X] - jne .set + cmp eax, [Screen_Max_X] + jne .set - cmp edx, [Screen_Max_Y] - jne .set - ret + cmp edx, [Screen_Max_Y] + jne .set + ret .set: - pushfd - cli + pushfd + cli - mov [Screen_Max_X], eax - mov [Screen_Max_Y], edx - mov [BytesPerScanLine], ecx + mov [Screen_Max_X], eax + mov [Screen_Max_Y], edx + mov [BytesPerScanLine], ecx - mov [screen_workarea.right],eax - mov [screen_workarea.bottom], edx + mov [screen_workarea.right],eax + mov [screen_workarea.bottom], edx - push ebx - push esi - push edi + push ebx + push esi + push edi - pushad + pushad - stdcall kernel_free, [_WinMapAddress] + stdcall kernel_free, [_WinMapAddress] - mov eax, [_display.width] - mul [_display.height] - mov [_WinMapSize], eax + mov eax, [_display.width] + mul [_display.height] + mov [_WinMapSize], eax - stdcall kernel_alloc, eax - mov [_WinMapAddress], eax - test eax, eax - jz .epic_fail + stdcall kernel_alloc, eax + mov [_WinMapAddress], eax + test eax, eax + jz .epic_fail - popad + popad - call repos_windows - xor eax, eax - xor ebx, ebx - mov ecx, [Screen_Max_X] - mov edx, [Screen_Max_Y] - call calculatescreen - pop edi - pop esi - pop ebx + call repos_windows + xor eax, eax + xor ebx, ebx + mov ecx, [Screen_Max_X] + mov edx, [Screen_Max_Y] + call calculatescreen + pop edi + pop esi + pop ebx - popfd - ret + popfd + ret .epic_fail: - hlt ; Houston, we've had a problem + hlt ; Houston, we've had a problem ; --------------- APM --------------------- uglobal @@ -4614,16 +4557,16 @@ sys_apm: inc eax or dword [esp + 44], eax ; error add eax,7 - mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported + mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported ret @@: -; xchg eax, ecx -; xchg ebx, ecx +; xchg eax, ecx +; xchg ebx, ecx cmp dx, 3 ja @f - and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 + and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 mov eax,[apm_vf] mov [esp + 32], eax shr eax, 16 @@ -4635,15 +4578,15 @@ sys_apm: mov esi,[master_tab+(OS_BASE shr 20)] xchg [master_tab], esi push esi - mov edi, cr3 - mov cr3, edi ;flush TLB + mov edi, cr3 + mov cr3, edi ;flush TLB - call pword [apm_entry] ;call APM BIOS + call pword [apm_entry] ;call APM BIOS - xchg eax, [esp] - mov [master_tab], eax - mov eax, cr3 - mov cr3, eax + xchg eax, [esp] + mov [master_tab], eax + mov eax, cr3 + mov cr3, eax pop eax mov [esp + 4 ], edi @@ -4660,250 +4603,253 @@ sys_apm: align 4 -undefined_syscall: ; Undefined system call +undefined_syscall: ; Undefined system call mov [esp + 32], dword -1 ret align 4 -system_shutdown: ; shut down the system +system_shutdown: ; shut down the system - cmp byte [BOOT_VAR+0x9030], 1 - jne @F - ret + cmp byte [BOOT_VAR+0x9030], 1 + jne @F + ret @@: - call stop_all_services + call stop_all_services yes_shutdown_param: - cli + 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 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, 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 + mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff + mov edi, OS_BASE + mov ecx,0x10000/4 + cld + rep movsd - call restorefatchain + call restorefatchain - mov al, 0xFF - out 0x21, al - out 0xA1, al + mov al, 0xFF + out 0x21, al + out 0xA1, al if 0 - mov word [OS_BASE+0x467+0],pr_mode_exit - mov word [OS_BASE+0x467+2],0x1000 + 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,0x0F + out 0x70,al + mov al,0x05 + out 0x71,al - mov al,0xFE - out 0x64,al + mov al,0xFE + out 0x64,al - hlt - jmp $-1 + hlt + jmp $-1 else - cmp byte [OS_BASE + 0x9030], 2 - jnz no_acpi_power_off + 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 + 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 + 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 + 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 + 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 + 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] + 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] + 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 + 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 + 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 + 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] - out dx, al - mov edx, [ebx+64] + mov edx, [ebx+48] + test edx, edx + jz .nosmi + mov al, [ebx+52] + out dx, al + mov edx, [ebx+64] @@: - in ax, dx - test al, 1 - jz @b + 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 - out dx, ax - mov edx, [ebx+68] - test edx, edx - jz @f - in ax, dx - and ax, 203h - or ah, ch - out dx, ax + and cx, 0x0707 + shl cx, 2 + or cx, 0x2020 + mov edx, [ebx+64] + in ax, dx + and ax, 203h + or ah, cl + 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 $ + jmp $ no_acpi_power_off: - mov word [OS_BASE+0x467+0],pr_mode_exit - mov word [OS_BASE+0x467+2],0x1000 + 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,0x0F + out 0x70,al + mov al,0x05 + out 0x71,al - mov al,0xFE - out 0x64,al + mov al,0xFE + out 0x64,al - hlt - jmp $-1 + hlt + jmp $-1 scan_rsdp: - add eax, OS_BASE + add eax, OS_BASE .s: - cmp dword [eax], 'RSD ' - jnz .n - cmp dword [eax+4], 'PTR ' - jnz .n - xor edx, edx - xor esi, esi + 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 + add dl, [eax+esi] + inc esi + cmp esi, 20 + jnz @b + test dl, dl + jz .ok .n: - add eax, 10h - loop .s - stc + add eax, 10h + loop .s + stc .ok: - ret + ret end if +diff16 "End of 32-code ",0,$ + include "data32.inc" __REV__ = __REV uglobals_size = $ - endofcode -diff16 "end of kernel code",0,$ +diff16 "Zero-filled blk",0,endofcode +diff16 "End of kernel ",0,$ diff --git a/kernel/branches/Kolibri-A/trunk/kernel32.inc b/kernel/branches/Kolibri-A/trunk/kernel32.inc index ee7fdbed35..5d38c531d1 100644 --- a/kernel/branches/Kolibri-A/trunk/kernel32.inc +++ b/kernel/branches/Kolibri-A/trunk/kernel32.inc @@ -246,7 +246,7 @@ include "gui/skincode.inc" ; Pci functions include "bus/pci/pci32.inc" -include "bus/pci/PCIe.inc" +;include "bus/pci/PCIe.inc" include "bus/HT.inc" ; AMD HyperTransport bus control ; Floppy drive controller diff --git a/kernel/branches/Kolibri-A/trunk/memmap.inc b/kernel/branches/Kolibri-A/trunk/memmap.inc index 89f65f9bac..ecc205945a 100644 --- a/kernel/branches/Kolibri-A/trunk/memmap.inc +++ b/kernel/branches/Kolibri-A/trunk/memmap.inc @@ -122,9 +122,13 @@ ; FE04 dword screen y size ; FE08 dword screen y multiplier ; FE0C dword screen mode -; FE10 -> FE7F free (112) -; FE80 dword physical address of LFB -; FE84 dword physical address of user-accessible static system buffer +; FE10 -> FE73 free (100) +; FE74 dword PCIe extended (memory-mappable) config space - physical address +; FE78 dword PCIe extended config space limit +; FE7C word number of 4M-pages needed to map PCIe config space +; FE7E word PCIe bus range (power-ow-two Mbytes) +; FE80 dword physical address of user-accessible static system buffer +; FE84 dword physical address of LFB ; FE88 dword address of button list ; FE8C dword memory to use ; FE90 -> FEFF free (112) @@ -138,7 +142,16 @@ ; FFFF byte do not change task for 1/100 sec. ; ; 0x80010000 -> 6CBFF kernel, 32-bit run-time code (up to 371 Kb) - +; in the current version: +; -> 01726 16-bit code end +; -> 01828 16-bit data end +; -> 11828 32-bit code start +; -> 2E19E 32-bit code end +; -> 314F8..end_of_kernel zero-filled zone after preinit_mem +; -> 34DFB uninitialized globals start +; -> 3CFEA end_of_kernel +; -> 3D000 not used (190k) +; 0x80050000 -> 090000 zero-filled zone after preinit_mem ; 0x8006CC00 -> 6DBFF stack at boot time (4Kb) ; ; 0x8006DC00 -> 6E5FF basic text font II @@ -192,6 +205,8 @@ ; 0x800A0000 -> AFFFF screen access area ; 0x800B0000 -> FFFFF bios rest in peace -area (320k) ? ; 0x80100000 -> 27FFFF diskette image (1m5) + +; 0x80280000 -> HEAP_BASE zero-filled zone after preinit_mem ; 0x80280000 -> 281FFF ramdisk fat (8k) ; 0x80282000 -> 283FFF floppy fat (8k) ; @@ -225,8 +240,8 @@ ; dword end port ; dword 0 ; -; 0x802E0000 -> 2EFFFF irq data area (64k) -; 0x802F0000 -> 2FFFFF low memory save (64k) +; 0x802E0000 -> 2EFFFF irq data area (64k) +; 0x802F0000 -> 2FFFFF low memory save (64k) ; ; 0x80300000 -> 31FFFF tcp memory (128k) ; 0x80320000 -> 327FFF tcp memory (32k)