move kernel vars into .bss

git-svn-id: svn://kolibrios.org@928 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-11-22 12:57:25 +00:00
parent d43e578cc8
commit 072729a7f2
40 changed files with 1370 additions and 1208 deletions

View File

@ -525,7 +525,7 @@ hdd_irq14:
; mov [dma_slot_ptr], eax
; mov [CURRENT_TASK], ebx
; mov [TASK_BASE], edi
; mov byte [DONT_SWITCH], 1
; mov [dont_switch], 1
; call do_change_task
.noswitch:
popad
@ -556,7 +556,7 @@ hdd_irq15:
; mov [dma_slot_ptr], eax
; mov [CURRENT_TASK], ebx
; mov [TASK_BASE], edi
; mov byte [DONT_SWITCH], 1
; mov [dont_switch], 1
; call do_change_task
.noswitch:
popad

View File

@ -24,7 +24,7 @@ public _poweroff
public _bx_from_load
extrn __setvars
extrn core_init
section '.boot' code readable align 16
@ -64,24 +64,13 @@ include "bootcode.inc" ; 16 bit system boot code
include "../bus/pci/pci16.inc"
include "../detect/biosdisk.inc"
cli
mov eax, cr0
or eax, CR0_PG+CR0_WP+CR0_PE
mov cr0, eax
jmp pword 0x08:__setvars
;align 4
;_leave_16bit:
;
; cli
; mov eax, cr0
; or eax, CR0_PG+CR0_WP+CR0_PE
; mov cr0, eax
; hlt
jmp pword 0x10:core_init
align 4
rmode_idt:

View File

@ -9,7 +9,7 @@ include "../const.inc"
public __start
extrn _high_code
extrn high_code
extrn __os_stack
extrn _boot_mbi
extrn _sys_pdbr
@ -70,8 +70,9 @@ __start:
; ENABLE PAGING
mov ecx, 64
mov edi, _sys_pdbr+(OS_BASE shr 20)+(0x100000000-OS_BASE)
mov eax, PG_LARGE+PG_SW
mov edi, _sys_pdbr+(OS_BASE shr 20)+(0x100000000-OS_BASE)
mov [edi-4], dword (PG_LARGE+PG_USER)
@@:
stosd
add eax, 4*1024*1024
@ -110,8 +111,8 @@ __start:
add ecx, 4095
and ecx, not 4095
lgdt [_gdts+(0x100000000-OS_BASE)]
jmp pword 0x08:_high_code
lgdt [_gdts] ;+(0x100000000-OS_BASE)]
jmp pword 0x10:high_code
.fault:

View File

@ -385,7 +385,7 @@ sys_pcibios:
jz .emulate_bios
push ds
mov ax, pci_data_sel
mov ax, sel_pci_data
mov ds, ax
mov eax, ebp
mov ah, 0B1h

View File

@ -8,10 +8,13 @@
$Revision$
dpl0 equ 10010000b ; data read dpl0
dpl0 equ 10010000b ; data read dpl0
drw0 equ 10010010b ; data read/write dpl0
drw1 equ 10110010b ; data read/write dpl1
drw3 equ 11110010b ; data read/write dpl3
cpl0 equ 10011010b ; code read dpl0
cpl1 equ 10111010b ; code read dpl1
cpl3 equ 11111010b ; code read dpl3
D32 equ 01000000b ; 32bit segment
@ -20,11 +23,11 @@ G32 equ 10000000b ; page gran
;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;;
CPU_386 equ 3
CPU_486 equ 4
CPU_PENTIUM equ 5
CPU_P6 equ 6
CPU_PENTIUM4 equ 0x0F
CPU_386 equ 3
CPU_486 equ 4
CPU_PENTIUM equ 5
CPU_P6 equ 6
CPU_PENTIUM4 equ 0x0F
CAPS_FPU equ 00 ;on-chip x87 floating point unit
CAPS_VME equ 01 ;virtual-mode enhancements
@ -188,16 +191,17 @@ HEAP_BASE equ 0x80000000
HEAP_MIN_SIZE equ 0x01000000
LFB_BASE equ 0xDF000000
page_tabs equ 0xDF800000
app_page_tabs equ 0xDF800000
OS_TEMP equ 0xDFC00000
page_tabs equ 0xDDC00000
app_page_tabs equ 0xDDC00000
heap_tabs equ (page_tabs+ (HEAP_BASE shr 10))
kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) ;0xFDE00000
master_tab equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000
kernel_tabs equ (page_tabs+ (OS_BASE shr 10))
master_tab equ (page_tabs+ (page_tabs shr 10))
LFB_BASE equ 0xDE000000
SHADOWFB equ 0 ;0xDE800000
TEXT_BASE equ 0xDFC00000
_16BIT_BASE equ 0x00010000
LOAD_BASE equ 0x00100000
@ -221,81 +225,10 @@ WIN_STACK equ (OS_BASE+0x000C000)
WIN_POS equ (OS_BASE+0x000C400)
FDD_BUFF equ (OS_BASE+0x000D000)
;unused ? only one reference
ENABLE_TASKSWITCH equ (OS_BASE+0x000E000)
PUTPIXEL equ (OS_BASE+0x000E020)
GETPIXEL equ (OS_BASE+0x000E024)
;unused ? only one reference
BANK_SWITCH equ (OS_BASE+0x000E030)
;unused ? store mousepointer
MOUSE_PICTURE equ (OS_BASE+0x000F200)
MOUSE_VISIBLE equ (OS_BASE+0x000F204)
WIN_TEMP_XY equ (OS_BASE+0x000F300)
KEY_COUNT equ (OS_BASE+0x000F400)
KEY_BUFF equ (OS_BASE+0x000F401)
BTN_COUNT equ (OS_BASE+0x000F500)
BTN_BUFF equ (OS_BASE+0x000F501)
CPU_FREQ equ (OS_BASE+0x000F600)
;unused ? no active references
MOUSE_PORT equ (OS_BASE+0x000F604)
;unused
PS2_CHUNK equ (OS_BASE+0x000FB00)
MOUSE_SCROLL_H equ (OS_BASE+0x000FB08)
MOUSE_X equ (OS_BASE+0x000FB0A)
MOUSE_Y equ (OS_BASE+0x000FB0C)
MOUSE_SCROLL_V equ (OS_BASE+0x000FB0E)
MOUSE_COLOR_MEM equ (OS_BASE+0x000FB10)
COLOR_TEMP equ (OS_BASE+0x000FB30)
BTN_DOWN equ (OS_BASE+0x000FB40)
MOUSE_DOWN equ (OS_BASE+0x000FB44)
X_UNDER equ (OS_BASE+0x000FB4A)
Y_UNDER equ (OS_BASE+0x000FB4C)
ScreenBPP equ (OS_BASE+0x000FBF1)
;unused ? only one reference
MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
LFBAddress equ (OS_BASE+0x000FE80)
Screen_Max_X equ (OS_BASE+0x000FE00)
Screen_Max_Y equ (OS_BASE+0x000FE04)
BytesPerScanLine equ (OS_BASE+0x000FE08)
SCR_MODE equ (OS_BASE+0x000FE0C)
BTN_ADDR equ (OS_BASE+0x000FE88)
SYS_SHUTDOWN equ (OS_BASE+0x000FF00)
TASK_ACTIVATE equ (OS_BASE+0x000FF01)
REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0)
BANK_RW equ (OS_BASE+0x000FFF2)
MOUSE_BACKGROUND equ (OS_BASE+0x000FFF4)
DONT_DRAW_MOUSE equ (OS_BASE+0x000FFF5)
DONT_SWITCH equ (OS_BASE+0x000FFFF)
;TMP_STACK_TOP equ 0x006CC00
FONT_II equ (OS_BASE+0x006DC00)
FONT_I equ (OS_BASE+0x006E600)
;sys_pgdir equ (OS_BASE+0x006F000)
DRIVE_DATA equ (OS_BASE+0x0070000)
SLOT_BASE equ (OS_BASE+0x0080000)
;unused
TMP_BUFF equ (OS_BASE+0x0090000)
VGABasePtr equ (OS_BASE+0x00A0000)
RAMDISK_FAT equ (OS_BASE+0x0180000)
@ -377,7 +310,6 @@ BOOT_SCANLINE equ 0x9001 ;word scanline length
BOOT_VESA_MODE equ 0x9008 ;word vesa video mode
;;BOOT_X_RES equ 0x900A ;word X res
;;BOOT_Y_RES equ 0x900C ;word Y res
;;BOOT_MOUSE_PORT equ 0x9010 ;byte mouse port - not used
BOOT_BANK_SW equ 0x9014 ;dword Vesa 1.2 pm bank switch
BOOT_LFB equ 0x9018 ;dword Vesa 2.0 LFB address
BOOT_MTRR equ 0x901C ;byte 0 or 1 : enable MTRR graphics acceleration
@ -658,3 +590,37 @@ virtual at 0
CSYM COFF_SYM
end virtual
struc THR
{
.edi rd 1 ; 0x00
.esi rd 1 ; 0x04
.ebp rd 1 ; 0x08
rd 1 ; 0x0C ;esp
.ebx rd 1 ; 0x10
.edx rd 1 ; 0x14
.ecx rd 1 ; 0x18
.eax rd 1 ; 0x1C
.retaddr rd 1 ; 0x20 ;èëè êîä îøèáêè
.eip rd 1 ; 0x24
.cs rd 1 ; 0x28
.eflags rd 1 ; 0x2C
.esp rd 1 ; 0x30
.ss rd 1 ; 0x34
.pl0_stack:
.tid rd 1 ; ; number of this process (for fast access)
.slot rd 1 ; ; number of this process (for fast access)
.pdir rd 1 ; ;
.thr_flags rd 1 ; ; process is runnable only if zero
.ticks_left rd 1 ; ; number of scheduling ticks left
.quantum_size rd 1 ; ; quantum size in ticks
.user_time rd 1 ; ; user time in ticks
.sys_time rd 1 ; ; sys time in ticks
}
virtual at 0
THR THR
end virtual

View File

@ -421,7 +421,7 @@ debug_exc:
; int 1 = #DB
save_ring3_context
cld
mov ax, app_data ;os_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
mov eax, dr6

View File

@ -366,7 +366,6 @@ int sys_exec(char *path, char *cmdline, u32_t flags)
return pe_app_param(path, raw, ex_pg_dir, ex_stack);
};
#define master_tab (page_tabs+ (page_tabs>>10))
typedef struct
{
@ -385,11 +384,6 @@ typedef struct
u32_t pe_ss;
}thr_stack_t;
#define EFL_IF 0x0200
#define EFL_IOPL1 0x1000
#define EFL_IOPL2 0x2000
#define EFL_IOPL3 0x3000
void sys_app_entry(addr_t raw, thr_stack_t *thr_stack, exec_stack_t *ex_stack)
{
PIMAGE_DOS_HEADER dos;

View File

@ -159,7 +159,7 @@ align 16
.main:
save_ring3_context
mov eax, [esp + 32]
mov bx, app_data ;os_data
mov bx, sel_app_data
mov ds, bx
mov es, bx
@ -514,7 +514,7 @@ proc get_fileinfo stdcall, file_name:dword, info:dword
mov eax, 70
lea ebx, [cmd]
int 0x40
int 0x41
ret
endp

View File

@ -67,8 +67,7 @@ iglobal
szSysMsgBoardStr db 'SysMsgBoardStr', 0
szSysMsgBoardChar db 'SysMsgBoardChar', 0
szGetCurrentTask db 'GetCurrentTask',0
szLFBAddress db 'LFBAddress',0
szLoadFile db 'LoadFile',0
szLoadFile db 'LoadFile',0
szSendEvent db 'SendEvent',0
szSetMouseData db 'SetMouseData',0
szSleep db 'Sleep',0
@ -150,9 +149,7 @@ kernel_export:
dd szStrchr , strchr
dd szStrrchr , strrchr
exp_lfb:
dd szLFBAddress , 0
dd 0 ;terminator, must be zero
dd 0 ;terminator, must be zero
endg

View File

@ -145,7 +145,7 @@ align 4
e7: ;#NM exception handler
save_ring3_context
clts
mov ax, app_data ;
mov ax, sel_app_data
mov ds, ax
mov es, ax

View File

@ -6,8 +6,6 @@
#include <mm.h>
#include <slab.h>
#define page_tabs 0xDF800000
#define MD_FREE 1
#define MD_USED 2

View File

@ -0,0 +1,478 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include "../macros.inc"
include "../proc32.inc"
include "../const.inc"
$Revision: 847 $
sel_tss equ 0x08
sel_os_code equ 0x10
sel_os_stack equ 0x18
sel_app_code equ 0x23
sel_app_data equ 0x2B
sel_srv_code equ 0x31
sel_srv_stack equ 0x39
sel_code_16 equ 0x70
format MS COFF
use32
public __os_stack
public _pg_balloc
public high_code
public core_init
public test_cpu
public cpu_vendor
public cpu_sign
public cpu_info
public cpu_caps
extrn _parse_mbi
extrn _16bit_start
extrn _16bit_end
extrn _enter_bootscreen
extrn init_fpu
extrn init_idt
extrn _init_mm
extrn _slab_cache_init
extrn @init_heap@8
extrn init_malloc
extrn _init_core_dll
extrn _init_threads
extrn init_mtrr
extrn system_init
extrn sysenter_entry
extrn syscall_entry
extrn @create_systhread@4
extrn _sys_pdbr
extrn _current_thread
extrn _k_reenter:dword
extrn scr_mode:dword
extrn LFBAddress:dword
extrn LFBSize:dword
section '.text' code readable align 16
high_code:
mov ax, sel_os_stack
mov dx, sel_app_data
mov ss, ax
mov esp, __os_stack
mov ds, dx
mov es, dx
mov fs, dx
mov gs, dx
; bt [cpu_caps], CAPS_PGE
; jnc @F
; or dword [sys_pgdir-OS_BASE+(OS_BASE shr 20)], PG_GLOBAL
; mov ebx, cr4
; or ebx, CR4_PGE
; mov cr4, ebx
@@:
; mov eax, cr3
; mov cr3, eax ; flush TLB
mov edx, 0x3fB
mov eax, 3
out dx, al
call test_cpu
call _parse_mbi
; mov eax, [_pg_balloc]
; mov [_copy_pg_balloc], eax
__core_restart:
mov esi, _16bit_start
mov ecx, _16bit_end
shr ecx, 2
mov edi, _16BIT_BASE
cld
rep movsd
jmp far sel_code_16:_enter_bootscreen;
align 16
core_init:
cld
mov ax, sel_os_stack
mov dx, sel_app_data
mov ss, ax
mov esp, __os_stack
mov ds, dx
mov es, dx
mov fs, dx
mov gs, dx
mov [tss._ss0], sel_os_stack
mov [tss._esp0], __os_stack
mov [tss._esp], __os_stack
mov [tss._cs], sel_os_code
mov [tss._ss], sel_os_stack
mov [tss._ds], sel_app_data
mov [tss._es], sel_app_data
mov [tss._fs], sel_app_data
mov [tss._gs], sel_app_data
mov [tss._io], 128
;Add IO access table - bit array of permitted ports
mov edi, tss._io_map_0
xor eax, eax
; not eax
mov ecx, 8192/4
rep stosd ; access to 4096*8=65536 ports
mov ax, sel_tss
ltr ax
; -------- 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, sel_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
; Bits of EDX :
; Bit 3116 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 150 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, ((sel_os_code + 16) shl 16) + sel_os_code
mov eax, syscall_entry
mov ecx, MSR_AMD_STAR
wrmsr
.noSYSCALL:
call init_fpu
call init_idt
call _init_mm
call init_malloc
call _slab_cache_init
mov ecx, 0x80000000
mov edx, 0x40000000
call @init_heap@8
call _init_core_dll
call _init_threads
; SAVE & CLEAR 0-0xffff
cld
xor esi, esi
mov edi,BOOT_VAR
mov ecx,0x10000 / 4
rep movsd
xor edi, edi
xor eax, eax
mov ecx,0x10000 / 4
rep stosd
mov edi, 0x40000
mov ecx, (0x90000-0x40000)/4
rep stosd
mov dword [_sys_pdbr], eax
mov dword [_sys_pdbr+4], eax
xchg bx, bx
movzx eax,word [BOOT_VAR+0x9008] ; screen mode
mov [scr_mode],eax
mov eax,[BOOT_VAR+0x9018]
call map_LFB
mov eax, cr3
mov cr3, eax
jmp system_init
if 0
mov ecx, system_init
call @create_systhread@4
mov [_current_thread], eax
xchg bx, bx
mov ebx, [eax+THR.pdir]
mov ecx, cr3
cmp ebx, ecx
je .skip
mov cr3, ebx
.skip:
mov esp, [_current_thread]
; lea eax, [esp+THR.pl0_stack]
; mov [tss._esp0], eax
restart1:
dec [_k_reenter]
popad
add esp, 4 ; skip return adr
iretd ; continue process
end if
align 4
map_LFB:
cmp eax, -1
jne @f
ret
@@:
test [scr_mode], 0100000000000000b
jnz @f
mov [BOOT_VAR+0x901c],byte 2
ret
@@:
mov [LFBAddress], eax
mov [LFBSize], 0x800000
call init_mtrr
mov eax, [LFBAddress]
or eax, PG_LARGE+PG_UW
mov [_sys_pdbr+(LFB_BASE shr 20)], eax
add eax, 0x00400000
mov [_sys_pdbr+4+(LFB_BASE shr 20)], eax
if SHADOWFB
mov ecx, 11
call @core_alloc@4
or eax, PG_LARGE+PG_UW
mov [_sys_pdbr+(SHADOWFB shr 20)], eax
add eax, 0x00400000
mov [_sys_pdbr+4+(SHADOWFB shr 20)], eax
end if
bt [cpu_caps], CAPS_PGE
jnc @F
or dword [_sys_pdbr+(LFB_BASE shr 20)], PG_GLOBAL
@@:
mov dword [LFBAddress], LFB_BASE
ret
align 4
proc test_cpu
locals
cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl
mov [cpu_type], 0
xor eax, eax
mov [cpu_caps], eax
mov [cpu_caps+4], eax
xor eax, eax
cpuid
mov [cpu_vendor], ebx
mov [cpu_vendor+4], edx
mov [cpu_vendor+8], ecx
cmp ebx, dword [intel_str]
jne .check_AMD
cmp edx, dword [intel_str+4]
jne .check_AMD
cmp ecx, dword [intel_str+8]
jne .check_AMD
mov [cpu_Intel], 1
cmp eax, 1
jl .end_cpuid
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.end_cpuid:
mov eax, [cpu_type]
ret
.check_AMD:
cmp ebx, dword [AMD_str]
jne .unknown
cmp edx, dword [AMD_str+4]
jne .unknown
cmp ecx, dword [AMD_str+8]
jne .unknown
mov [cpu_AMD], 1
cmp eax, 1
jl .unknown
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
.unknown:
mov eax, 1
cpuid
mov [cpu_sign], eax
mov [cpu_info], ebx
mov [cpu_caps], edx
mov [cpu_caps+4],ecx
shr eax, 8
and eax, 0x0f
ret
endp
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
if 0
align 4
init_BIOS32:
mov edi, 0xE0000
.pcibios_nxt:
cmp dword[edi], '_32_' ; "magic" word
je .BIOS32_found
.pcibios_nxt2:
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
@@: lodsb
add ah, al
loop @b
jnz .pcibios_nxt2 ; control summ must be zero
; BIOS32 service found !
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
; çäåñü ñîçäàþòñÿ äèñêðèïòîðû äëÿ 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
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 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
.PCI_BIOS32_not_found:
; çäåñü äîëæíà çàïîëíÿòñÿ pci_emu_dat
.BIOS32_not_found:
.end:
ret
end if
section '.data' data writeable align 16
_pg_balloc dd LAST_PAGE
section '.bss' data writeable align 16
rb 8192-512
__os_stack rb 512
;CPUID information
cpu_vendor rd 3
cpu_sign rd 1
cpu_info rd 1
cpu_caps rd 4

View File

@ -19,7 +19,7 @@ extern multiboot_info_t *boot_mbi;
/* Check if the bit BIT in FLAGS is set. */
#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit)))
void init()
void parse_mbi()
{
u32_t last_page = 0;

View File

@ -178,46 +178,6 @@ proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
ret
endp
align 4
proc init_LFB
locals
pg_count dd ?
endl
cmp dword [LFBAddress], -1
jne @f
mov [BOOT_VAR+0x901c],byte 2
mov ecx, 0x280000
mov edx, PG_SW
call @mem_alloc@8
mov [LFBAddress], eax
ret
@@:
test [SCR_MODE],word 0100000000000000b
jnz @f
mov [BOOT_VAR+0x901c],byte 2
ret
@@:
call init_mtrr
mov eax, [LFBAddress]
or eax, PG_LARGE+PG_UW
mov [_sys_pdbr+(LFB_BASE shr 20)], eax
add eax, 0x00400000
mov [_sys_pdbr+4+(LFB_BASE shr 20)], eax
mov dword [exp_lfb+4], LFB_BASE
bt [cpu_caps], CAPS_PGE
jnc @F
or dword [_sys_pdbr+(LFB_BASE shr 20)], PG_GLOBAL
@@:
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB
mov cr3, eax
ret
endp
align 4
proc new_mem_resize stdcall, new_size:dword
@ -395,7 +355,7 @@ proc page_fault_handler
mov eax, cr2
push eax
mov ax, app_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
@ -407,25 +367,22 @@ proc page_fault_handler
cmp ebx, HEAP_BASE
jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ;
cmp ebx, LFB_BASE
jb .kernel_heap
cmp ebx, page_tabs
jb .lfb
jb .kernel_heap
cmp ebx, heap_tabs
jb .user_tabs
cmp ebx, OS_BASE
cmp ebx, LFB_BASE
jb .heap_tab
cmp ebx, OS_BASE
jb .lfb
; cmp ebx, kernel_tabs
; jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ;
;ïðîñòî ñîçäàäèì îäíó
.lfb:
shr ebx, 22
mov edx, [_sys_pdbr + ebx*4]
@ -996,7 +953,7 @@ new_services:
ret
@@:
cmp eax, 21 ;for test purposes only
ja @f ;will be removed soon
ja .fail ;will be removed soon
cmp ebx, OS_BASE
jae .fail
@ -1178,7 +1135,6 @@ align 4
_balloc: ; gcc fastcall
@balloc@4:
mov eax, [_pg_balloc]
add ecx, 4095
and ecx, -4096

View File

@ -1,51 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
include 'export.inc'
align 4
align 16
_kernel_exports:
export 'KERNEL', \
commit_pages, 'CommitPages', \ ; eax, ebx, ecx
create_kernel_object, 'CreateObject', \
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
malloc, 'Kmalloc', \
free, 'Kfree', \
map_io_mem, 'MapIoMem', \ ; stdcall
get_pg_addr, 'GetPgAddr', \ ; eax
@mem_alloc@8, 'mem_alloc', \ ; fastcall
@mem_free@4, 'mem_free', \ ; fastcall
\
select_hw_cursor, 'SelectHwCursor', \ ; stdcall
set_hw_cursor, 'SetHwCursor', \ ; stdcall
hw_restore, 'HwCursorRestore', \ ;
create_cursor, 'HwCursorCreate', \ ;
\
set_screen, 'SetScreen', \
pci_api, 'PciApi', \
pci_read8, 'PciRead8', \ ; stdcall
pci_read16, 'PciRead16', \ ; stdcall
pci_read32, 'PciRead32', \ ; stdcall
pci_write8, 'PciWrite8', \ ; stdcall
pci_write16, 'PciWrite16', \ ; stdcall
pci_write32, 'PciWrite32', \ ; stdcall
\
reg_service, 'RegService', \ ; stdcall
user_alloc, 'UserAlloc', \ ; stdcall
user_free, 'UserFree', \ ; stdcall
unmap_pages, 'UnmapPages', \ ; eax, ecx
sys_msg_board_str, 'SysMsgBoardStr'

View File

@ -16,7 +16,7 @@ $Revision$
align 32
irq0:
pushad
mov ax, app_data ;
mov ax, sel_app_data
mov ds, ax
mov es, ax
@ -31,14 +31,14 @@ irq0:
mov [next_usage_update],eax
call updatecputimes
.nocounter:
cmp [DONT_SWITCH], byte 1
cmp [dont_switch], 1
jne .change_task
mov al,0x20 ; send End Of Interrupt signal
mov dx,0x20
out dx,al
mov [DONT_SWITCH], byte 0
mov [dont_switch], 0
popad
iretd
@ -95,7 +95,7 @@ end if
test eax, eax ; the same task -> skip switch
jnz .return
@@:
mov [DONT_SWITCH],byte 1
mov [dont_switch], 1
call do_change_task
.return:
@ -225,7 +225,7 @@ do_change_task:
@@:
mov eax, [ebx+APPDATA.saved_esp0]
mov [tss._esp0], eax
mov ax, graph_data
mov ax, sel_graph_data
mov gs, ax
mov eax, [CURRENT_TASK]

View File

@ -14,7 +14,7 @@
$Revision$
align 4
_init_idt:
init_idt:
push edi
push esi
mov edi, idts
@ -25,28 +25,35 @@ _init_idt:
@@:
lodsd
mov [edi], ax ; lower part of offset
mov [edi+2], word os_code ; segment selector
mov [edi+2], word sel_os_code ; segment selector
mov ax, word 10001110b shl 8 ; type: interrupt gate
mov [edi+4], eax
add edi, 8
loop @b
mov eax, i40
mov ecx, i40
mov eax, _i40
mov ecx, _i40
and eax, 0x0000FFFF
and ecx, 0xFFFF0000
or eax, os_code shl 16
or eax, sel_app_code shl 16
or ecx, (11101111b shl 8)
mov [edi], eax
mov [edi+4], ecx
mov eax, i41
mov ecx, i41
and eax, 0x0000FFFF
and ecx, 0xFFFF0000
or eax, sel_os_code shl 16
or ecx, (11101111b shl 8)
mov [edi+8], eax
mov [edi+12], ecx
lidt [idtreg]
pop esi
pop edi
ret
iglobal
msg_sel_ker db "kernel", 0
@ -75,10 +82,10 @@ end if
times 16 dd unknown_interrupt
dd i40
dd i41
idtreg:
dw 8*0x41-1
dw 8*0x42-1
dd idts
endg
@ -118,10 +125,11 @@ macro exc_w_code [num]
exc_wo_code 0, 2, 3, 4, 5, 6, 9, 15, 18
exc_w_code 8, 10, 11, 12, 13, 14, 17
align 4
exc_c:
mov ax, app_data ;èñêëþ÷åíèå
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
mov es, ax ;â ðåãèñòðû
mov ax, sel_app_data ;èñêëþ÷åíèå
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ'
mov es, ax ;â ðåãèñòðû
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
test byte [esp+20h+8+2], 2
@ -215,7 +223,7 @@ defined_error:
mov eax, [esp + 8 + 0x20]
mov edi, msg_sel_app
mov ebx, [esp + 16 + 0x20]
cmp eax, app_code
cmp eax, sel_app_code
je @f
mov edi, msg_sel_ker
mov ebx, [esp - 16 + 0x20]
@ -239,7 +247,7 @@ irqh 2,3,4,5,7,8,9,10,11
p_irq6:
save_ring3_context
mov ax, app_data ;os_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
call fdc_irq
@ -250,7 +258,7 @@ p_irq6:
p_irq14:
save_ring3_context
mov ax, app_data ;os_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
mov byte [BOOT_VAR + 0x48E], 0xFF
@ -260,7 +268,7 @@ p_irq14:
iret
p_irq15:
save_ring3_context
mov ax, app_data ;os_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
mov byte [BOOT_VAR + 0x48E], 0xFF
@ -284,7 +292,7 @@ ready_for_next_irq_1:
irqD:
save_ring3_context
mov ax, app_data ;os_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
@ -518,8 +526,8 @@ term9:
frstor [eax]
@@:
mov [KEY_COUNT],byte 0 ; empty keyboard buffer
mov [BTN_COUNT],byte 0 ; empty button buffer
mov [KEY_COUNT], 0 ; empty keyboard buffer
mov [BTN_COUNT], 0 ; empty button buffer
; remove defined hotkeys
@ -558,7 +566,7 @@ term9:
mov ecx,esi ; remove buttons
bnewba2:
mov edi,[BTN_ADDR]
mov edi,[btn_addr]
mov eax,edi
cld
movzx ebx,word [edi]
@ -804,8 +812,8 @@ term9:
xor esi, esi
call redrawscreen
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
mov [mouse_background], 0 ; no mouse background
mov [dont_draw_mouse], 0 ; draw mouse
mov [application_table_status],0
;mov esi,process_terminated

View File

@ -0,0 +1,16 @@
format MS COFF
public _i40
section '.text' code readable align 16
align 16
_i40:
; xchg bx, bx
int 0x41
iretd

View File

@ -30,7 +30,7 @@ cross_order:
align 16
i40:
i41:
pushad
cld
movzx eax, al

View File

@ -1281,12 +1281,12 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax ;app_entry
mov [ebx+REG_CS], dword app_code
mov [ebx+REG_CS], dword sel_app_code
mov [ebx+REG_EFLAGS], dword EFL_IOPL3+EFL_IF
mov eax, [esi+0x0C] ;app_esp
mov [ebx+REG_APP_ESP], eax ;app_stack
mov [ebx+REG_SS], dword app_data
mov [ebx+REG_SS], dword sel_app_data
lea ecx, [ebx+REG_RET]
mov ebx, [slot]

View File

@ -0,0 +1,68 @@
#include <types.h>
#include <core.h>
#include <spinlock.h>
#include <link.h>
#include <mm.h>
#include <slab.h>
addr_t thr_ptr;
slab_cache_t *thr_slab;
extern addr_t sys_pdbr;
void init_threads()
{
thr_slab = slab_cache_create(sizeof(thr_t), 16,
NULL,NULL,SLAB_CACHE_MAGDEFERRED);
};
thr_t* __fastcall create_systhread(addr_t entry_ptr)
{
static count_t thr_cnt = 0;
static count_t slot = 1;
thr_t *thr;
addr_t thr_stack;
thr = (thr_t*)slab_alloc(thr_slab,0);
thr_stack = PA2KA(core_alloc(1));
thr_cnt++;
thr->eax = (thr_cnt<<8)|slot;
thr->tid = (thr_cnt<<8)|slot;
thr->slot = slot;
slot++;
thr->pdir = KA2PA(&sys_pdbr);
thr->ebx = 0;
thr->edi = 0;
thr->esi = 0;
thr->ebp = 0;
thr->edx = 0;
thr->ecx = 0;
thr->cs = sel_srv_code;
thr->eflags = EFL_IOPL1;
thr->esp = thr_stack + 8192;
thr->ss = sel_srv_stack;
thr->thr_flags = 0;
thr->ticks_left = 8;
thr->quantum_size = 8;
thr->eip = entry_ptr;
//lock_enqueue(thr_ptr); /* add to scheduling queues */
return thr;
};

View File

@ -392,7 +392,7 @@ v86_irqerr db 'V86 : IRQ already hooked',13,10,0
endg
v86_exc_c:
mov ax, app_data
mov ax, sel_app_data
mov ds, ax
mov es, ax
; Did we all that we have wanted to do?

View File

@ -81,8 +81,6 @@ msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0
msg_CR db 13,10,0
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
;szSound db 'SOUND',0
;szInfinity db 'INFINITY',0
@ -108,9 +106,6 @@ vmode db '/sys/drivers/VMODE.MDR',0
vrr_m db 'VRR_M',0
kernel_file db 'KERNEL MNT'
align 4
_pg_balloc dd LAST_PAGE
;supported videomodes
mode_1280_1024_32:
@ -162,7 +157,7 @@ syslang dd 1
boot_y dd 10
pci_bios_entry dd 0
dw pci_code_sel
dw sel_pci_code
if __DEBUG__ eq 1
include_debug_strings
@ -173,42 +168,61 @@ IncludeIGlobals
align 16
_gdts:
dw 0x67; gdte-$-1
dd _gdts
dw (gdte - _gdts -1)
dd _gdts
dw 0
tss_l:
dw TSS_SIZE-1
dw tss and 0xFFFF
db (tss shr 16) and 0xFF
db 10001001b
dw (tss shr 16) and 0xFF00
; Attention! Do not change the order of the first four selectors. They are used in Fast System Call
; must be : os_code, os_data, app_code, app_data, ....
int_code_l:
os_code_l:
os_code_l: ;0x10
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10011010b
db 0x00
int_data_l:
os_data_l:
os_stacK_l: ;0x18
dw 0xffff
dw 0x0000
db 0x00
dw 11011111b *256 +10010010b
db 0x00
app_code_l:
dw 0xFFFF
dw 0
db 0
db cpl3
dw G32+D32+0xF;
app_code_l: ;0x20
dw 0xFFFF
dw 0
db 0
db cpl3
dw G32+D32+0xF;
app_data_l:
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+0xF;
app_data_l: ;0x28
dw 0xFFFF
dw 0
db 0
db drw3
dw G32+D32+0xF;
srv_code_l: ;0x30
dw 0xFFFF
dw 0
db 0
db cpl1
dw G32+D32+0xF;
srv_stack_l: ;0x38
dw 0xFFFF
dw 0
db 0
db drw1
dw G32+D32+0xF;
; ------------- PCI BIOS ------------------
@ -253,19 +267,13 @@ graph_data_l:
db 0x00
dw 11010000b *256 +11110010b
db 0x00
tss0_l:
dw TSS_SIZE-1
dw tss and 0xFFFF
db (tss shr 16) and 0xFF
db 10001001b
dw (tss shr 16) and 0xFF00
code_16:
dw 0xFFFF
dw 0
db 1
db cpl0
dw 0
code_16_l:
dw 0xFFFF
dw 0
db 1
db cpl0
dw 0
endofcode:
gdte:
@ -274,17 +282,14 @@ section '.bss' data writeable align 4096
align 4096
_sys_pdbr rd 1024
rb 8192-512
__os_stack rb 512
cur_saved_data rb 4096
fpu_data: rb 512
_sys_pdbr rd 1024
idts rq 0x41
cur_saved_data rb 4096
fpu_data: rb 512
idts rq 0x42
; device irq owners
irq_owner rd 16 ; process id
@ -310,11 +315,14 @@ irq15read rd 16
irq_tab rd 16
FONT_I rb 2304 ;16*144
FONT_II rb 2560 ;16*160
_z_core rd 52
mem_block_map rb 512
event_map rb 64
event_map rb 64
mem_block_list rd 64
large_block_list rd 31
mem_block_mask rd 2
@ -330,18 +338,11 @@ _rd_fat_end rd 1 ;RAMDISK + 512 + 4278
_rd_root rd 1 ;RAMDISK + 512*18 + 512
_rd_root_end rd 1 ;RAMDISK + 512*33
mem_used.fd rd 1
mem_used.bk rd 1
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
mst MEM_STATE
@ -393,51 +394,98 @@ tmp_task_ptab rd 1
default_io_map rd 1
LFBSize rd 1 ;8Mb hardcoded
stall_mcs rd 1
stall_mcs rd 1
_current_slot:
current_slot rd 1
_display_data rd 1
_current_thread rd 1
_k_reenter rd 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
scr_mode rd 1
LFBAddress rd 1
LFBSize rd 1 ;8Mb hardcoded
ScreenBPP rd 1
BytesPerScanLine rd 1
put_pixel rd 1
get_pixel rd 1
Screen_Max_X rd 1
Screen_Max_Y rd 1
btn_addr rd 1
redraw_background rd 1
mouse_background rd 1
dont_draw_mouse rd 1
MOUSE_VISIBLE rd 1
WIN_TEMP_XY rd 1
MOUSE_X rw 1
MOUSE_Y rw 1
mouse_scroll_v rd 1
mouse_scroll_h rd 1
BTN_COUNT rd 1
BTN_BUFF rd 1
KEY_COUNT rd 1
KEY_BUFF rb 128
mouse_color_mem rd 1
color_temp rd 1
btn_down rd 1
x_under rd 1
y_under rd 1
dont_switch rd 1
sys_shutdown rd 1
bank_rw rd 1
CPU_FREQ rd 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; status
hd1_status rd 1 ; 0 - free : other - pid
application_table_status rd 1 ; 0 - free : other - pid
; device addresses
mididp rd 1
midisp rd 1
mididp rd 1
midisp rd 1
cdbase rd 1
cdid rd 1
cdbase rd 1
cdid rd 1
hdbase rd 1 ; for boot 0x1f0
hdid rd 1
hdpos rd 1 ; for boot 0x1
fat32part rd 1 ; for boot 0x1
cdpos rd 1
;CPUID information
cpu_vendor rd 3
cpu_sign rd 1
cpu_info rd 1
cpu_caps rd 4
hdbase rd 1 ; for boot 0x1f0
hdid rd 1
hdpos rd 1 ; for boot 0x1
fat32part rd 1 ; for boot 0x1
cdpos rd 1
pg_data PG_DATA
heap_test rd 1
buttontype rd 1
pg_data PG_DATA
heap_test rd 1
buttontype rd 1
windowtypechanged rd 1
hd_entries rd 1 ;unused ? 0xfe10
hd_entries rd 1 ;unused ? 0xfe10
;* start code - Mario79
mouse_active rd 1
mouse_pause rd 1
mouse_pause rd 1
MouseTickCounter rd 1
;* end code - Mario79
@ -447,8 +495,8 @@ mem_BACKGROUND rd 1
wraw_bacground_select rb 1
cache_ide0:
cache_ide0_pointer rd 1
cache_ide0_size rd 1 ; not use
cache_ide0_pointer rd 1
cache_ide0_size rd 1 ; not use
cache_ide0_data_pointer rd 1
cache_ide0_system_data_size rd 1 ; not use
cache_ide0_appl_data_size rd 1 ; not use
@ -460,8 +508,8 @@ cache_ide0_search_start rd 1
cache_ide0_appl_search_start rd 1
cache_ide1:
cache_ide1_pointer rd 1
cache_ide1_size rd 1 ; not use
cache_ide1_pointer rd 1
cache_ide1_size rd 1 ; not use
cache_ide1_data_pointer rd 1
cache_ide1_system_data_size rd 1 ; not use
cache_ide1_appl_data_size rd 1 ; not use
@ -473,8 +521,8 @@ cache_ide1_search_start rd 1
cache_ide1_appl_search_start rd 1
cache_ide2:
cache_ide2_pointer rd 1
cache_ide2_size rd 1 ; not use
cache_ide2_pointer rd 1
cache_ide2_size rd 1 ; not use
cache_ide2_data_pointer rd 1
cache_ide2_system_data_size rd 1 ; not use
cache_ide2_appl_data_size rd 1 ; not use
@ -486,8 +534,8 @@ cache_ide2_search_start rd 1
cache_ide2_appl_search_start rd 1
cache_ide3:
cache_ide3_pointer rd 1
cache_ide3_size rd 1 ; not use
cache_ide3_pointer rd 1
cache_ide3_size rd 1 ; not use
cache_ide3_data_pointer rd 1
cache_ide3_system_data_size rd 1 ; not use
cache_ide3_appl_data_size rd 1 ; not use
@ -498,18 +546,21 @@ cache_ide3_appl_sad_size rd 1
cache_ide3_search_start rd 1
cache_ide3_appl_search_start rd 1
debug_step_pointer rd 1
hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache
cd_appl_data rb 1 ; 0 = system cache, 1 - application cache
debug_step_pointer rd 1
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
timer_ticks_enable rb 1 ; for cd driver
hdd_appl_data rb 1 ; 0 = system cache, 1 - application cache
cd_appl_data rb 1 ; 0 = system cache, 1 - application cache
NumBiosDisks rd 1
BiosDisksData rb 200h
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
BiosDiskPartitions rd 80h
align 4
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
timer_ticks_enable rb 1 ; for cd driver
align 4
NumBiosDisks rd 1
BiosDisksData rb 200h
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
BiosDiskPartitions rd 80h
IncludeUGlobals

View File

@ -571,7 +571,7 @@ proc r200_SetCursor stdcall, hcursor:dword, x:dword, y:dword
shl edx, 8
add edx, [esi+CURSOR.base]
sub edx, LFBAddress
sub edx, LFB_BASE
wrr CUR_OFFSET, edx
popfd
ret
@ -602,7 +602,7 @@ proc video_alloc
lea eax,[eax+ebx*8]
shl eax,14
add eax, LFBAddress+CURSOR_IMAGE_OFFSET
add eax, LFB_BASE+CURSOR_IMAGE_OFFSET
ret
endp
@ -610,7 +610,7 @@ align 4
video_free:
pushfd
cli
sub eax, LFBAddress+CURSOR_IMAGE_OFFSET
sub eax, LFB_BASE+CURSOR_IMAGE_OFFSET
shr eax, 14
mov ebx, cursor_map
bts [ebx], eax

View File

@ -82,6 +82,6 @@ kernel_export \
strncmp,\
strnlen,\
strchr,\
strrchr,\
\
LFBAddress
strrchr

View File

@ -227,7 +227,7 @@ sys_button:
button_no_draw:
push edi
mov edi, [BTN_ADDR]
mov edi, [btn_addr]
movzx eax, word [edi]
cmp eax, max_buttons
jge noaddbutt
@ -264,7 +264,7 @@ remove_button:
rnewba2:
mov edi, [BTN_ADDR]
mov edi, [btn_addr]
mov eax, edi
movzx ebx, word [edi]
inc ebx
@ -429,7 +429,7 @@ negativebutton:
checkbuttons:
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed
cmp byte [btn_down], 0 ; mouse buttons pressed
jnz @f
;..................................... start 1/5 : modified by vhanla .............................
mov [bPressedMouseXY_B],0
@ -439,7 +439,7 @@ checkbuttons:
pushad
xor esi, esi
mov edi, [BTN_ADDR]
mov edi, [btn_addr]
movzx edx, word [edi]
test edx, edx
jne @f
@ -449,7 +449,7 @@ checkbuttons:
@@:
;..................................... start 2/5 : modified by vhanla .............................
;here i catch the coordinates when the mouse's button is clicked
push ax
push eax
cmp [bPressedMouseXY_B],0;FALSE
jnz @f
mov [bPressedMouseXY_B],1;TRUE - it was already clicked
@ -458,7 +458,7 @@ checkbuttons:
mov ax,[MOUSE_Y]
mov [my],ax
@@:
pop ax
pop eax
;and it is only refreshed after the mouse's button release
;..................................... end 2/5 : modified by vhanla .............................
@ -520,7 +520,7 @@ checkbuttons:
movzx edx,word [eax+4] ; button x start
add edx,ecx
;..................................... start 3/5 : modified by vhanla .............................
mov cx,[mx] ;mov cx,[MOUSE_X]
mov cx,[mx] ;mov cx,[mouse_x]
;..................................... end 3/5 : modified by vhanla .............................
cmp edx,ecx
jg buttonnewcheck
@ -555,17 +555,16 @@ checkbuttons:
mov bx,[eax+0xc] ; button id : bits 16-31
shl ebx,16
mov bx,[eax+2] ; button id : bits 00-16
mov bx,[eax+2] ; button id : bits 00-16
push ebx
mov [MOUSE_DOWN],byte 1 ; no mouse down checks
call find_pressed_button_frames
call negativebutton
pushad
; // Alver 22.06.2008 // {
push eax
mov al, byte [BTN_DOWN]
mov al, byte [btn_down]
mov byte [btn_down_determ], al
pop eax
; } \\ Alver \\
@ -580,13 +579,13 @@ checkbuttons:
call stack_handler
popad
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed ?
cmp byte [btn_down], 0 ; mouse buttons pressed ?
jnz cbwaitmouseup
popad
call negativebutton
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
mov [mouse_background], 0 ; no mouse background
mov [dont_draw_mouse], 0 ; draw mouse
;..................................... start 5/5 : modified by vhanla .............................
; check coordinates
iglobal
@ -629,16 +628,15 @@ endg
cmp ecx,edx
jg no_on_button
popa
mov [BTN_COUNT],byte 1 ; no of buttons in buffer
mov [BTN_COUNT], 1 ; no of buttons in buffer
pop ebx
mov [BTN_BUFF],ebx ; lets put the button id in buffer
push ebx
pusha
jmp yes_on_button
no_on_button:
mov [BTN_COUNT],byte 0 ; no of buttons in buffer
mov [BTN_COUNT], 0 ; no of buttons in buffer
yes_on_button:
mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
popa
pop ebx
popa

View File

@ -507,13 +507,13 @@ sys_sendwindowmsg:
.sendkey:
pushf
cli
movzx eax, byte [KEY_COUNT]
cmp al, 120
jae .overflow
inc eax
mov [KEY_COUNT], al
mov [KEY_COUNT+eax], cl
jmp .ok
mov eax, [KEY_COUNT]
cmp eax, 120
jae .overflow
inc eax
mov [KEY_COUNT], eax
mov [KEY_BUFF+eax-1], cl
jmp .ok
.overflow:
popf
mov dword [esp+36], 1
@ -521,9 +521,9 @@ sys_sendwindowmsg:
.sendbtn:
pushf
cli
cmp byte [BTN_COUNT], 0
cmp [BTN_COUNT], 0
jnz .overflow
mov byte [BTN_COUNT], 1
mov [BTN_COUNT], 1
mov [BTN_BUFF], ecx
.ok:
popf
@ -554,7 +554,7 @@ get_event_for_app:
mov eax, [TASK_COUNT]
cmp eax,edx
jne no_eventoccur2x
cmp [KEY_COUNT],byte 0
cmp [KEY_COUNT], 0
je no_eventoccur2x
eventoccur2:
popad
@ -573,7 +573,7 @@ get_event_for_app:
;mov edi,[TASK_BASE] ; BUTTON IN BUFFER
test [edi+TASKDATA.event_mask],dword 4
jz no_eventoccur3
cmp [BTN_COUNT],byte 0
cmp [BTN_COUNT], 0
je no_eventoccur3
mov ecx, [CURRENT_TASK]
movzx edx, word [WIN_STACK+ecx*2]
@ -589,7 +589,7 @@ get_event_for_app:
no_event_1:
mov [window_minimize],1
mov [BTN_COUNT],byte 0
mov [BTN_COUNT], 0
xor eax, eax
ret
@ -613,7 +613,7 @@ no_mouse_event:
;mov edi,[TASK_BASE] ; DESKTOP BACKGROUND REDRAW
test [edi+TASKDATA.event_mask], 16
jz no_eventoccur5
; cmp [REDRAW_BACKGROUND],byte 2
; cmp [redraw_background], 2
; jnz no_eventoccur5
test [eax+APPDATA.event_mask], 16
jz no_eventoccur5

View File

@ -379,7 +379,7 @@ drawwindow_IV:
jne no_skin_add_button
;* close button
mov edi,[BTN_ADDR]
mov edi,[btn_addr]
movzx eax,word [edi]
cmp eax,1000
jge no_skin_add_button
@ -418,7 +418,7 @@ drawwindow_IV:
mov [eax],bx
;* minimize button
mov edi,[BTN_ADDR]
mov edi,[btn_addr]
movzx eax,word [edi]
cmp eax,1000
jge no_skin_add_button

View File

@ -629,8 +629,8 @@ sys_window_mouse:
cmp [new_window_starting],eax
jb swml1
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
mov [mouse_background], 0 ; no mouse background
mov [dont_draw_mouse], 0 ; draw mouse
mov [new_window_starting],eax
@ -926,7 +926,7 @@ windowactivate:
movzx eax, word [WIN_STACK+eax*2] ; ax <- position in window stack
xor esi, esi ; drop others
waloop:
waloop:
cmp esi, dword [TASK_COUNT]
jae wacont
inc esi
@ -938,17 +938,17 @@ windowactivate:
mov [edi], bx
@@:
jmp waloop
wacont:
wacont:
; set to no 1
pop esi ; esi = pointer at 0xC400
movzx eax, word [esi]
movzx eax, word [esi]
mov bx, [TASK_COUNT] ; number of processes
mov [WIN_STACK+eax*2], bx ; this is the last (and the upper)
; update on screen -window stack
xor esi, esi
waloop2:
waloop2:
mov edi, [TASK_COUNT]
cmp esi, edi
jae wacont2
@ -956,11 +956,11 @@ windowactivate:
movzx ebx, word [esi*2 + WIN_STACK]
mov [ebx*2 + WIN_POS], si
jmp waloop2
wacont2:
mov [KEY_COUNT], byte 0 ; empty keyboard buffer
mov [BTN_COUNT], byte 0 ; empty button buffer
mov [MOUSE_SCROLL_H], word 0 ; zero mouse z-index
mov [MOUSE_SCROLL_V], word 0 ; zero mouse z-index
wacont2:
mov [KEY_COUNT], 0 ; empty keyboard buffer
mov [BTN_COUNT], 0 ; empty button buffer
mov [mouse_scroll_h], 0 ; zero mouse z-index
mov [mouse_scroll_v], 0 ; zero mouse z-index
popad
ret
@ -1056,7 +1056,6 @@ waredraw: ; if redraw necessary at activate
jz .do_not_draw
popad
mov [MOUSE_DOWN], byte 1 ; do draw mouse
call windowactivate
; update screen info
@ -1081,7 +1080,6 @@ waredraw: ; if redraw necessary at activate
popad
mov [edi + WDATA.fl_redraw], 1 ; redraw flag for app
mov [MOUSE_DOWN],byte 0 ; mouse down checks
ret
@ -1090,9 +1088,8 @@ waredraw: ; if redraw necessary at activate
popad
call windowactivate
mov [MOUSE_DOWN],byte 0 ; mouse down checks
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
mov [mouse_background], 0 ; no mouse background
mov [dont_draw_mouse], 0 ; draw mouse
ret
@ -1159,7 +1156,7 @@ restore_minimized_window:
add edx, [edi+WDATA.box.height]
call calculatescreen
.done:
mov [MOUSE_BACKGROUND],byte 0 ; no mouse under
mov [mouse_background], 0 ; no mouse under
.skip_redrawings:
popfd
ret
@ -1189,7 +1186,7 @@ checkwindows:
.continue:
.no_minimizing:
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed ?
cmp byte [btn_down], 0 ; mouse buttons pressed ?
jne .mouse_buttons_pressed
;..................................... start 1/4 : modified by vhanla .................
mov [bPressedMouseXY_W],0
@ -1206,7 +1203,7 @@ checkwindows:
inc esi
;..................................... start 3/4 : modified by vhanla .................
push ax
push eax
cmp [bPressedMouseXY_W],0
jnz @f
mov [bPressedMouseXY_W],1
@ -1215,7 +1212,7 @@ checkwindows:
mov ax,[MOUSE_Y]
mov [my],ax
@@:
pop ax
pop eax
;..................................... end 3/4 : modified by vhanla ...................
cwloop:
@ -1236,7 +1233,7 @@ checkwindows:
jnz cwloop
;..................................... start 4/4 : modified by vhanla .................
movzx eax, word [mx]; movzx eax,word[MOUSE_X]
movzx eax, word [mx]; movzx eax,word[mouse_x]
movzx ebx, word [my]; movzx ebx,word[MOUSE_Y]
;..................................... endt 4/4 : modified by vhanla ..................
cmp ecx, eax
@ -1321,7 +1318,7 @@ checkwindows:
mov [latest_window_touch], ecx
mov [latest_window_touch_delta], edx
mov cl, [BTN_DOWN] ; save for shade check
mov cl, byte [btn_down] ; save for shade check
mov [do_resize], cl
no_emulation_righ_button:
mov ecx, [edi + WDATA.box.left]
@ -1341,7 +1338,7 @@ checkwindows:
sub eax, ecx
sub ebx, edx
mov esi, [MOUSE_X]
mov esi, dword [MOUSE_X]
mov [WIN_TEMP_XY], esi
pushad ; wait for putimages to finish
@ -1369,19 +1366,18 @@ checkwindows:
call drawwindowframes
mov [reposition],0
mov [MOUSE_DOWN],byte 1 ; no reaction to mouse up/down
; move window
newchm:
mov [DONT_DRAW_MOUSE],byte 1
mov [dont_draw_mouse], 1
call checkidle
call checkVga_N13
mov [MOUSE_BACKGROUND],byte 0
mov [mouse_background], 0
call [draw_pointer]
@ -1390,7 +1386,7 @@ checkwindows:
popad
mov esi,[WIN_TEMP_XY]
cmp esi,[MOUSE_X]
cmp esi, dword [MOUSE_X]
je cwb
mov cx,[MOUSE_X]
@ -1403,8 +1399,8 @@ checkwindows:
call drawwindowframes
mov ax,[Screen_Max_X]
mov bx,[Screen_Max_Y]
mov ax, word [Screen_Max_X]
mov bx, word [Screen_Max_Y]
cmp [do_resize_from_corner],1
je no_new_position
@ -1477,14 +1473,14 @@ checkwindows:
pop ax
call drawwindowframes
mov esi,[MOUSE_X]
mov esi, dword [MOUSE_X]
mov [WIN_TEMP_XY],esi
cwb:
cmp [BTN_DOWN],byte 0
cmp byte [btn_down], 0
jne newchm
; new position done
mov [DONT_DRAW_MOUSE],byte 1
mov [dont_draw_mouse], 1
mov cl,0
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jnz @f
@ -1637,7 +1633,7 @@ checkwindows:
cmp [reposition],0
je retwm
mov [DONT_DRAW_MOUSE],byte 1 ; no mouse
mov [dont_draw_mouse], 1 ; no mouse
push eax ebx ecx edx
@ -1666,7 +1662,7 @@ checkwindows:
mov ecx,100 ; wait to avoid mouse residuals
waitre2:
mov [DONT_DRAW_MOUSE],byte 1
mov [dont_draw_mouse], 1
call checkidle
cmp [edi+WDATA.fl_redraw],0
jz retwm
@ -1674,9 +1670,8 @@ checkwindows:
retwm:
mov [DONT_DRAW_MOUSE],byte 0 ; mouse pointer
mov [MOUSE_BACKGROUND],byte 0 ; no mouse under
mov [MOUSE_DOWN],byte 0 ; react to mouse up/down
mov [dont_draw_mouse], 0 ; mouse pointer
mov [mouse_background], 0 ; no mouse under
mov esi,window_moved
call sys_msg_board_str

View File

@ -300,12 +300,12 @@ irq1:
.scancode:
mov bl, ch
.dowrite:
movzx eax,byte[KEY_COUNT]
mov eax, [KEY_COUNT]
cmp al,120
jae .exit.irq1
inc eax
mov [KEY_COUNT],al
mov [KEY_COUNT+eax],bl
mov [KEY_COUNT], eax
mov [KEY_BUFF+eax-1],bl
.exit.irq1:
mov [check_idle_semaphore],5

View File

@ -17,9 +17,6 @@ $Revision$
; FB22 y move
; FB30 color temp
; FB28 high bits temp
; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under
; FC00 -> FCFE com1/ps2 buffer
; FCFF com1/ps2 buffer count starting from FC00
uglobal
mousecount dd 0x0
@ -27,35 +24,20 @@ uglobal
endg
iglobal
mouse_delay dd 10
mouse_delay dd 10
mouse_speed_factor: dd 3
mouse_timer_ticks dd 0
mouse_timer_ticks dd 0
endg
;include 'm_com.inc'
;test_mario79:
; push esi
; push eax
; mov [write_error_to],process_test_m79+43
; movzx eax,al ;[DevErrorCode]
; call writehex
; mov esi,process_test_m79
; call sys_msg_board_str
; pop eax
; pop esi
; ret
;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0
align 4
draw_mouse_under:
; return old picture
cmp [set_hw_cursor], 0
jz @F
pushad
movzx eax,word [X_UNDER]
movzx ebx,word [Y_UNDER]
mov eax, [x_under]
mov ebx, [y_under]
stdcall [hw_restore], eax, ebx
popad
ret
@ -65,8 +47,8 @@ draw_mouse_under:
xor edx,edx
align 4
mres:
movzx eax,word [X_UNDER]
movzx ebx,word [Y_UNDER]
mov eax, [x_under]
mov ebx, [y_under]
add eax,ecx
add ebx,edx
push ecx
@ -101,8 +83,8 @@ save_draw_mouse:
je .no_hw_cursor
pushad
mov [X_UNDER],ax
mov [Y_UNDER],bx
mov [x_under], eax
mov [y_under], ebx
movzx eax,word [MOUSE_Y]
movzx ebx,word [MOUSE_X]
push eax
@ -139,8 +121,8 @@ save_draw_mouse:
.no_hw_cursor:
pushad
; save & draw
mov [X_UNDER],ax
mov [Y_UNDER],bx
mov [x_under], eax
mov [y_under], ebx
push eax
push ebx
mov ecx,0
@ -157,29 +139,26 @@ drm:
add ebx,edx
push ecx
call getpixel
mov [COLOR_TEMP],ecx
mov [color_temp],ecx
pop ecx
mov eax,edx
shl eax,6
shl ecx,2
add eax,ecx
add eax,mouseunder
mov ebx,[COLOR_TEMP]
mov ebx,[color_temp]
mov [eax],ebx
pop ecx
mov edi,edx ; y cycle
shl edi,4 ; *16 bytes per row
add edi,ecx ; x cycle
mov esi, edi
add edi, esi
add edi, esi ; *3
add edi,[MOUSE_PICTURE] ; we have our str address
mov edi,edx ; y cycle
shl edi,4 ; *16 bytes per row
add edi,ecx ; x cycle
lea edi, [mousepointer+edi+edi*2] ; we have our str address
mov esi, edi
add esi, 16*24*3
push ecx
mov ecx, [COLOR_TEMP]
mov ecx, [color_temp]
call combine_colors
mov [MOUSE_COLOR_MEM], ecx
mov [mouse_color_mem], ecx
pop ecx
pop edx
pop ecx
@ -188,13 +167,13 @@ drm:
add eax,ecx ; we have x coord+cycle
add ebx,edx ; and y coord+cycle
push ecx
mov ecx, [MOUSE_COLOR_MEM]
mov ecx, [mouse_color_mem]
mov edi, 1
call [putpixel]
pop ecx
mov ebx,[esp+0] ; pure y coord again
mov eax,[esp+4] ; and x
inc ecx ; +1 cycle
inc ecx ; +1 cycle
cmp ecx,16 ; if more than 16
jnz drm
xor ecx, ecx
@ -276,7 +255,7 @@ combine_colors:
__sys_disable_mouse:
cmp dword [MOUSE_VISIBLE],dword 0
cmp [MOUSE_VISIBLE], 0
je @f
ret
@@:
@ -334,13 +313,13 @@ yes_mouse_disable:
cmp ebx,ecx
jg no_mouse_disable
disable_m:
cmp dword [MOUSE_VISIBLE],dword 0
cmp [MOUSE_VISIBLE], 0
jne no_mouse_disable
pushf
cli
call draw_mouse_under
popf
mov [MOUSE_VISIBLE],dword 1
mov [MOUSE_VISIBLE], 1
no_mouse_disable:
popad
ret
@ -362,9 +341,9 @@ __sys_draw_pointer:
mov [MouseTickCounter],eax
pop eax
pushad
cmp dword [MOUSE_VISIBLE],dword 0 ; mouse visible ?
cmp [MOUSE_VISIBLE], 0 ; mouse visible ?
je chms00
mov [MOUSE_VISIBLE], dword 0
mov [MOUSE_VISIBLE], 0
movzx ebx,word [MOUSE_Y]
movzx eax,word [MOUSE_X]
pushfd
@ -375,8 +354,8 @@ nodmu2:
popad
ret
chms00:
movzx ecx,word [X_UNDER]
movzx edx,word [Y_UNDER]
mov ecx, [x_under]
mov edx, [y_under]
movzx ebx,word [MOUSE_Y]
movzx eax,word [MOUSE_X]
cmp eax,ecx
@ -397,7 +376,7 @@ nodmp:
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
mov eax,[BtnState]
mov [BTN_DOWN],eax
mov [btn_down],eax
mov eax,[XMoving]
call mouse_acceleration
@ -407,9 +386,9 @@ proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScro
mov eax,0
jmp @@M2
@@M1:
cmp ax,[Screen_Max_X] ;ScreenLength
cmp ax, word [Screen_Max_X] ;ScreenLength
jl @@M2
mov ax,[Screen_Max_X] ;ScreenLength-1
mov ax, word [Screen_Max_X] ;ScreenLength-1
@@M2:
mov [MOUSE_X],ax ;[XCoordinate]
@ -424,18 +403,18 @@ proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScro
mov ax,0
jmp @@M4
@@M3:
cmp ax,[Screen_Max_Y] ;ScreenHeigth
cmp ax, word [Screen_Max_Y] ;ScreenHeigth
jl @@M4
mov ax,[Screen_Max_Y] ;ScreenHeigth-1
mov ax, word [Screen_Max_Y] ;ScreenHeigth-1
@@M4:
mov [MOUSE_Y],ax ;[YCoordinate]
mov eax,[VScroll]
add [MOUSE_SCROLL_V],ax
add [mouse_scroll_v], eax
mov eax,[HScroll]
add [MOUSE_SCROLL_H],ax
add [mouse_scroll_h], eax
mov [mouse_active],1
mov eax,[timer_ticks]

View File

@ -4,8 +4,20 @@
#define LOAD_BASE 0x00100000
#define page_tabs 0xDF800000
#define page_tabs 0xDDC00000
#define master_tab (page_tabs+(page_tabs>>10))
#define sel_tss 0x08
#define sel_os_stack 0x10
#define sel_os_code 0x18
#define sel_app_code 0x23
#define sel_app_data 0x2B
#define sel_srv_code 0x31
#define sel_srv_stack 0x39
void printf (const char *format, ...);
@ -53,8 +65,7 @@ static inline eflags_t safe_cli(void)
"pushfl\n\t"
"popl %0\n\t"
"cli\n"
: "=r" (tmp)
);
: "=r" (tmp));
return tmp;
}
@ -70,41 +81,35 @@ static inline void safe_sti(eflags_t efl)
static inline count_t fnzb(u32_t arg)
{
count_t n;
asm volatile ("xorl %0, %0 \n\t"
asm volatile (
"xorl %0, %0 \n\t"
"bsr %1, %0"
:"=&r" (n)
:"r"(arg)
);
:"=&r"(n) :"r"(arg) );
return n;
}
static inline count_t _bsf(u32_t arg)
{
count_t n;
asm volatile ("xorl %0, %0 \n\t"
asm volatile (
"xorl %0, %0 \n\t"
"bsf %1, %0"
:"=&r" (n)
:"r"(arg)
);
:"=&r" (n) :"r"(arg));
return n;
}
static inline void _bts(u32_t *data, count_t val)
{
asm volatile ("bts %0, %1 \n\t"
:
:"g"(data), "r"(val)
:"cc"
);
asm volatile (
"bts %0, %1 \n\t"
::"g"(data), "r"(val):"cc");
}
extern inline void _btr(u32_t *data, count_t val)
{
asm volatile ("btr %0, %1 \n\t"
:
:"g"(data), "r"(val)
:"cc"
);
asm volatile (
"btr %0, %1 \n\t"
::"g"(data), "r"(val):"cc");
}
extern inline void* load_file(const char *path, size_t *size)
@ -124,4 +129,63 @@ extern inline void* load_file(const char *path, size_t *size)
};
/* reemain part
saved_box BOX
ipc_start dd ?
ipc_size dd ?
event_mask dd ?
debugger_slot dd ?
dd ?
keyboard_mode db ?
db 3 dup(?)
dir_table dd ?
dbg_event_mem dd ?
dbg_regs:
dbg_regs.dr0 dd ?
dbg_regs.dr1 dd ?
dbg_regs.dr2 dd ?
dbg_regs.dr3 dd ?
dbg_regs.dr7 dd ?
wnd_caption dd ?
wnd_clientbox BOX
*/
//extern __fastcall void* load_file(const char *path, size_t *size);
typedef struct
{
u32_t edi;
u32_t esi;
u32_t ebp;
u32_t tmp; // esp
u32_t ebx;
u32_t edx;
u32_t ecx;
u32_t eax;
addr_t retaddr;
addr_t eip;
u32_t cs;
u32_t eflags;
addr_t esp;
u32_t ss; // 14*4
u32_t tid; // thread id
u32_t slot; // thread slot
addr_t pdir; //
u32_t thr_flags; // process is runnable only if zero
int ticks_left; // number of scheduling ticks left */
int quantum_size; // quantum size in ticks */
u32_t user_time; // user time in ticks
u32_t sys_time; // sys time in ticks
}thr_t;
#define EFL_IF 0x0200
#define EFL_IOPL1 0x1000
#define EFL_IOPL2 0x2000
#define EFL_IOPL3 0x3000

View File

@ -1,76 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
align 4
init_BIOS32:
mov edi, 0xE0000
.pcibios_nxt:
cmp dword[edi], '_32_' ; "magic" word
je .BIOS32_found
.pcibios_nxt2:
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
@@: lodsb
add ah, al
loop @b
jnz .pcibios_nxt2 ; control summ must be zero
; BIOS32 service found !
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
; çäåñü ñîçäàþòñÿ äèñêðèïòîðû äëÿ 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
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 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
.PCI_BIOS32_not_found:
; çäåñü äîëæíà çàïîëíÿòñÿ pci_emu_dat
.BIOS32_not_found:
.end:
ret

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,15 @@ SECTIONS
. = ALIGN(4096);
}
.flat . + 0xE0000000:
.text . + 0xDFC00000:
{
*(.flat) *(.text) *(.rdata) *(.data)
*(.text) *(.rdata)
. = ALIGN(4096);
}
.flat . + 0x00400000:
{
*(.flat) *(.data)
}
.edata ALIGN(32):

View File

@ -28,13 +28,16 @@ KERNEL_SRC:= \
PE_SRC:= \
init.c \
init.asm \
mbi.c \
mm.c \
slab.c \
heap.c \
pe.c \
dll.c \
spinlock.c \
thread.c \
syscall.asm \
boot/boot.asm \
boot/start.asm
@ -64,6 +67,9 @@ kernel.mnt: kernel.obj bin/export.obj $(PE_OBJS) Makefile ld.x
bin/%.obj : core/%.c $(H_SRC) Makefile
$(CC) $(CFLAGS) -o $@ $<
bin/%.obj: core/%.asm Makefile
$(FASM) $< $@
bin/%.obj: %.asm
$(FASM) $< $@

View File

@ -453,13 +453,13 @@ select_cursor:
align 4
proc init_cursors
cmp [SCR_MODE],word 0x13
cmp [scr_mode], 0x13
jbe .fail
test word [SCR_MODE], 0x4000
test [scr_mode], 0x4000
jz .fail
movzx eax, byte [ScreenBPP]
mov eax, [ScreenBPP]
mov ebx, [BytesPerScanLine]
cmp eax, 32
jne @F
@ -493,7 +493,7 @@ proc init_cursors
mov [scr_width], ecx
mov [scr_height], edx
movzx ebx, byte [ScreenBPP]
mov ebx, [ScreenBPP]
cmp ebx, 32
jne @F
@ -598,8 +598,7 @@ proc cursor_24 stdcall, hcursor:dword, x:dword, y:dword
mov [_dy], edi
mul ebx
lea esi, [ecx+ecx*2]
add esi, [LFBAddress]
lea esi, [LFB_BASE+ecx+ecx*2]
add esi, eax
mov [cur_saved_base],esi
@ -710,8 +709,7 @@ proc cursor_32 stdcall, hcursor:dword, x:dword, y:dword
mov [_dy], edi
mul ebx
lea esi, [eax+ecx*4]
add esi, [LFBAddress]
lea esi, [LFB_BASE+eax+ecx*4]
mov [cur_saved_base],esi
mov edi, [scr_width]

View File

@ -63,10 +63,10 @@ if TRIDENT
set_bank:
pushfd
cli
cmp al,[BANK_RW]
cmp al, byte [bank_rw]
je .retsb
mov [BANK_RW],al
mov byte [bank_rw],al
push dx
mov dx,3D8h
out dx,al
@ -84,10 +84,10 @@ if S3_VIDEO
set_bank:
pushfd
cli
cmp al,[BANK_RW]
cmp al, byte [bank_rw]
je .retsb
mov [BANK_RW],al
mov byte [bank_rw],al
push ax
push dx
push cx
@ -172,10 +172,10 @@ set_bank:
pushfd
cli
cmp al,[BANK_RW]
cmp al, byte [bank_rw]
je .retsb
mov [BANK_RW],al
mov byte [bank_rw],al
push ax
push dx
mov dx,3CEh
@ -206,10 +206,10 @@ set_bank:
pushfd
cli
cmp al,[BANK_RW]
cmp al, byte [bank_rw]
je .retsb
mov [BANK_RW],al
mov byte [bank_rw],al
push ax
push dx
mov ah,al
@ -336,7 +336,7 @@ vesa12_drawbackground:
mul ebx
add eax, esi
lea eax, [VGABasePtr+eax+esi*2]
cmp [ScreenBPP],byte 24
cmp byte [ScreenBPP], 24
jz v12bgl3
add eax,esi
@ -410,7 +410,7 @@ vesa12_drawbar:
add eax,ecx ; x
add eax,ecx
add eax,ecx
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x start
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ? - x start
jz dbpi2412
add eax,ecx
@ -425,7 +425,7 @@ vesa12_drawbar:
mov ecx,eax
add ecx,eax
add ecx,eax
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ? - x size
jz dbpi24312
add ecx,eax
@ -463,7 +463,7 @@ vesa12_drawbar:
dbcblimitlno12:
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ?
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ?
jz dbpi24bit12
jmp dbpi32bit12
@ -776,7 +776,7 @@ vesa12_putimage:
add eax,ecx ; x
add eax,ecx
add eax,ecx
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x start
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ? - x start
jz pi2412
add eax,ecx
@ -817,7 +817,7 @@ vesa12_putimage:
dbcblimitlno212:
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ?
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ?
jnz pi32bit12
pi24bit12:
@ -974,7 +974,7 @@ vesa12_putimage:
vesa12_read_screen_pixel:
and eax,0x3FFFFF
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ?
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ?
jz v12rsp24
mov edi,eax
shl edi,2

View File

@ -23,12 +23,6 @@ $Revision$
; If you're planning to write your own video driver I suggest
; you replace the VESA12.INC file and see those instructions.
;Screen_Max_X equ 0xfe00
;Screen_Max_Y equ 0xfe04
;BytesPerScanLine equ 0xfe08
;LFBAddress equ 0xfe80
;ScreenBPP equ 0xfbf1
;*************************************************
; getpixel
@ -42,7 +36,7 @@ $Revision$
getpixel:
push eax ebx edx edi
call dword [GETPIXEL]
call [get_pixel]
pop edi edx ebx eax
ret
@ -52,16 +46,22 @@ Vesa20_getpixel24:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
add edi, ebx ; edi = x*3+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
if SHADOWFB
mov ecx, [SHADOWFB+edi]
else
mov ecx, [LFB_BASE+edi]
end if
and ecx, 0xffffff
ret
Vesa20_getpixel32:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
add edi, [LFBAddress] ; ebx = where pixel is in memory
mov ecx, [edi]
if SHADOWFB
mov ecx, [SHADOWFB+edi]
else
mov ecx, [LFB_BASE+edi]
end if
and ecx, 0xffffff
ret
@ -177,7 +177,7 @@ vesa20_putimage:
mov [putimg.winmap_newline], eax
; screen new line increment
mov eax, [BytesPerScanLine]
movzx ebx, byte [ScreenBPP]
mov ebx, [ScreenBPP]
shr ebx, 3
imul ecx, ebx
sub eax, ecx
@ -188,11 +188,10 @@ vesa20_putimage:
mov edx, [putimg.abs_cy]
imul edx, [BytesPerScanLine]
mov eax, [putimg.abs_cx]
movzx ebx, byte [ScreenBPP]
mov ebx, [ScreenBPP]
shr ebx, 3
imul eax, ebx
add edx, eax
add edx, [LFBAddress]
; pointer to pixel map
mov eax, [putimg.abs_cy]
imul eax, [Screen_Max_X]
@ -218,9 +217,15 @@ align 4
cmp [ebp], bl
jne .skip
; mov eax, [esi] ; eax = RRBBGGRR
mov [edx], ax
if SHADOWFB
mov [SHADOWFB+edx], ax
end if
mov [LFB_BASE+edx], ax
shr eax, 16
mov [edx+2], al
if SHADOWFB
mov [SHADOWFB+edx+2], al
end if
mov [LFB_BASE+edx+2], al
.skip:
; add esi, 3 ;[putimg.source_bpp]
add edx, 3
@ -261,7 +266,10 @@ align 4
cmp [ebp], bl
jne .skip
; mov eax, [esi] ; ecx = RRBBGGRR
mov [edx], eax
if SHADOWFB
mov [SHADOWFB+edx], eax
end if
mov [LFB_BASE+edx], eax
.skip:
; add esi, [putimg.source_bpp]
add edx, 4
@ -324,7 +332,7 @@ __sys_putpixel:
mov [esp+32-8],ecx
.noneg:
; OK to set pixel
call dword [PUTPIXEL] ; call the real put_pixel function
call [put_pixel] ; call the real put_pixel function
.exit:
popad
ret
@ -336,11 +344,15 @@ Vesa20_putpixel24:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3
mov eax, [esp+32-8+4]
add edi, [LFBAddress]
add edi, ebx ; ebx = where to put pixel in memory
mov [edi], ax
if SHADOWFB
mov [SHADOWFB+ebx+edi], ax
end if
mov [LFB_BASE+ebx+edi], ax
shr eax, 16
mov [edi+2], al
if SHADOWFB
mov [SHADOWFB+ebx+edi+2], al
end if
mov [LFB_BASE+ebx+edi+2], al
ret
@ -351,8 +363,10 @@ Vesa20_putpixel32:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier)
mov eax, [esp+32-8+4] ; eax = color
add edi, [LFBAddress] ; ebx = where to put pixel in memory
mov [edi], eax
if SHADOWFB
mov [SHADOWFB+edi], eax
end if
mov [LFB_BASE+edi], eax
ret
;*************************************************
@ -623,7 +637,7 @@ vesa20_drawbar:
mov [drbar.line_inc_map], eax
; line_inc_scr
mov eax, [drbar.real_sx]
movzx ebx, byte [ScreenBPP]
mov ebx, [ScreenBPP]
shr ebx, 3
imul eax, ebx
neg eax
@ -633,11 +647,10 @@ vesa20_drawbar:
mov edx, [drbar.abs_cy]
imul edx, [BytesPerScanLine]
mov eax, [drbar.abs_cx]
; movzx ebx, byte [ScreenBPP]
; mov ebx, [ScreenBPP]
; shr ebx, 3
imul eax, ebx
add edx, eax
add edx, [LFBAddress]
; pointer to pixel map
mov eax, [drbar.abs_cy]
imul eax, [Screen_Max_X]
@ -668,8 +681,12 @@ align 4
.new_x:
cmp byte [ebp], bl
jne .skip
mov [edx], bh
mov [edx + 1], ax
if SHADOWFB
mov [SHADOWFB+edx], bh
mov [SHADOWFB+edx + 1], ax
end if
mov [LFB_BASE+edx], bh
mov [LFB_BASE+edx + 1], ax
.skip:
; add pixel
add edx, 3
@ -704,7 +721,10 @@ align 4
.new_x:
cmp byte [ebp], bl
jne .skip
mov [edx], eax
if SHADOWFB
mov [SHADOWFB+edx], eax
end if
mov [LFB_BASE+edx], eax
.skip:
; add pixel
add edx, 4
@ -731,59 +751,6 @@ align 4
mov [EGA_counter],1
ret
;voodoodbcplimit:
; ebp:=(y+Ywin)*(ScreenXSize+1)+(x+Xwin)+AddrBuffer
; pusha
; xor edx,edx
; mov eax,ebp
; mov ebx,[Screen_Max_X] ; Screen_X_size
; inc ebx ; +1
; sub eax,display_data ; -AddrBuffer
; div ebx ;
; mov ebx,eax ; ebx:=Y
; mov eax,edx ; eax:=X
; call cplimit
; test ecx,ecx
; jne dbcpl12
; popa
; clc
; ret
; dbcpl12:
; popa
; stc
; ret
;dbcplimit:
; pusha
; xor edx,edx
; mov ebx,[Screen_Max_X]
; inc ebx
; sub eax,display_data
; div ebx
; mov ebx,eax
; mov eax,edx
; call cplimit
; test ecx,ecx
; jne dbcpl1
; popa
; clc
; ret
; dbcpl1:
; popa
; stc
; ret
vesa20_drawbackground_tiled:
call [disable_mouse]
@ -800,11 +767,11 @@ dp2:
add ebp, eax
add ebp, eax
add ebp, eax
cmp [ScreenBPP], byte 24 ; 24 or 32 bpp ? - x size
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ? - x size
jz @f
add ebp, eax
@@:
add ebp, [LFBAddress]
; add ebp, LFB_BASE
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
call calculate_edi
xchg edi, ebp
@ -849,7 +816,7 @@ nbgp:
add esi, 3
add edi, 3
@@:
cmp [ScreenBPP], byte 25 ; 24 or 32 bpp?
cmp byte [ScreenBPP], 25 ; 24 or 32 bpp?
sbb edi, -1 ; +1 for 32 bpp
; I do not use 'inc eax' because this is slightly slower then 'add eax,1'
add ebp, edx
@ -910,11 +877,10 @@ vesa20_drawbackground_stretch:
add ebp, eax
add ebp, eax
add ebp, eax
cmp [ScreenBPP], byte 24 ; 24 or 32 bpp ? - x size
cmp byte [ScreenBPP], 24 ; 24 or 32 bpp ? - x size
jz @f
add ebp, eax
@@:
add ebp, [LFBAddress]
; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB
call calculate_edi
xchg edi, ebp
@ -991,11 +957,17 @@ sdp3a:
mov ebx, [bgr_next_line+esi]
call [overlapping_of_points_ptr]
.novert:
mov [edi], ax
if SHADOWFB
mov [SHADOWFB+edi], ax
end if
mov [LFB_BASE+edi], ax
shr eax, 16
mov [edi+2], al
if SHADOWFB
mov [SHADOWFB+edi+2], al
end if
mov [LFB_BASE+edi+2], al
snbgp:
cmp [ScreenBPP], byte 25
cmp byte [ScreenBPP], 25
sbb edi, -4
add ebp, 1
mov eax, [esp+20]
@ -1019,7 +991,7 @@ sdp4:
sub edi, eax
sub edi, eax
sub edi, eax
cmp [ScreenBPP], byte 24
cmp byte [ScreenBPP], 24
jz @f
sub edi, eax
@@:

View File

@ -126,14 +126,14 @@ endg
checkVga_N13:
cmp [SCR_MODE],dword 0x13
cmp [scr_mode], 0x13
jne @f
; cnvl:
pushad
cmp [EGA_counter],1
je novesal
mov ecx,[MOUSE_X]
mov ecx, dword [MOUSE_X]
cmp ecx,[novesachecksum]
jne novesal
popad
@ -201,7 +201,7 @@ checkVga_N13:
VGA_drawbackground:
; draw all
cmp [SCR_MODE],dword 0x12
cmp [scr_mode], 0x12
jne .end
pushad
mov esi,[LFBAddress]
@ -377,7 +377,7 @@ VGA_putpixel:
VGA__putimage:
; ecx = size [x|y]
; edx = coordinates [x|y]
cmp [SCR_MODE],dword 0x12
cmp [scr_mode], 0x12
jne @f
pushad
rol edx,16
@ -397,7 +397,7 @@ VGA_draw_bar:
; ebx cy
; ecx xe
; edx ye
cmp [SCR_MODE],dword 0x12
cmp [scr_mode], 0x12
jne @f
pushad
sub ecx,eax