From 072729a7f2976f5d71696148181c8a4d2a31566a Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sat, 22 Nov 2008 12:57:25 +0000 Subject: [PATCH] move kernel vars into .bss git-svn-id: svn://kolibrios.org@928 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/kolibri_pe/blkdev/hd_drv.inc | 4 +- kernel/branches/kolibri_pe/boot/boot.asm | 15 +- kernel/branches/kolibri_pe/boot/start.asm | 9 +- kernel/branches/kolibri_pe/bus/pci/pci32.inc | 2 +- kernel/branches/kolibri_pe/const.inc | 138 ++-- kernel/branches/kolibri_pe/core/debug.inc | 2 +- kernel/branches/kolibri_pe/core/dll.c | 6 - kernel/branches/kolibri_pe/core/dll.inc | 4 +- kernel/branches/kolibri_pe/core/exports.inc | 7 +- kernel/branches/kolibri_pe/core/fpu.inc | 2 +- kernel/branches/kolibri_pe/core/heap.c | 2 - kernel/branches/kolibri_pe/core/init.asm | 478 +++++++++++ .../kolibri_pe/core/{init.c => mbi.c} | 2 +- kernel/branches/kolibri_pe/core/memory.inc | 56 +- kernel/branches/kolibri_pe/core/peload.inc | 51 -- kernel/branches/kolibri_pe/core/sched.inc | 10 +- kernel/branches/kolibri_pe/core/sys32.inc | 52 +- kernel/branches/kolibri_pe/core/syscall.asm | 16 + kernel/branches/kolibri_pe/core/syscall.inc | 2 +- kernel/branches/kolibri_pe/core/taskman.inc | 4 +- kernel/branches/kolibri_pe/core/thread.c | 68 ++ kernel/branches/kolibri_pe/core/v86.inc | 2 +- kernel/branches/kolibri_pe/data32.inc | 247 +++--- kernel/branches/kolibri_pe/drivers/ati2d.asm | 6 +- .../branches/kolibri_pe/drivers/imports.inc | 6 +- kernel/branches/kolibri_pe/gui/button.inc | 30 +- kernel/branches/kolibri_pe/gui/event.inc | 26 +- kernel/branches/kolibri_pe/gui/skincode.inc | 4 +- kernel/branches/kolibri_pe/gui/window.inc | 69 +- kernel/branches/kolibri_pe/hid/keyboard.inc | 8 +- kernel/branches/kolibri_pe/hid/mousedrv.inc | 91 +-- kernel/branches/kolibri_pe/include/core.h | 106 ++- kernel/branches/kolibri_pe/init.inc | 76 -- kernel/branches/kolibri_pe/kernel.asm | 749 ++++++------------ kernel/branches/kolibri_pe/ld.x | 10 +- kernel/branches/kolibri_pe/makefile | 8 +- kernel/branches/kolibri_pe/video/cursors.inc | 14 +- kernel/branches/kolibri_pe/video/vesa12.inc | 30 +- kernel/branches/kolibri_pe/video/vesa20.inc | 156 ++-- kernel/branches/kolibri_pe/video/vga.inc | 10 +- 40 files changed, 1370 insertions(+), 1208 deletions(-) create mode 100644 kernel/branches/kolibri_pe/core/init.asm rename kernel/branches/kolibri_pe/core/{init.c => mbi.c} (95%) delete mode 100644 kernel/branches/kolibri_pe/core/peload.inc create mode 100644 kernel/branches/kolibri_pe/core/syscall.asm create mode 100644 kernel/branches/kolibri_pe/core/thread.c delete mode 100644 kernel/branches/kolibri_pe/init.inc diff --git a/kernel/branches/kolibri_pe/blkdev/hd_drv.inc b/kernel/branches/kolibri_pe/blkdev/hd_drv.inc index 016f4a2166..9ad6aa6030 100644 --- a/kernel/branches/kolibri_pe/blkdev/hd_drv.inc +++ b/kernel/branches/kolibri_pe/blkdev/hd_drv.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/boot/boot.asm b/kernel/branches/kolibri_pe/boot/boot.asm index 5b8663435c..4997c47667 100644 --- a/kernel/branches/kolibri_pe/boot/boot.asm +++ b/kernel/branches/kolibri_pe/boot/boot.asm @@ -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: diff --git a/kernel/branches/kolibri_pe/boot/start.asm b/kernel/branches/kolibri_pe/boot/start.asm index c5bb128dad..f675f8acf0 100644 --- a/kernel/branches/kolibri_pe/boot/start.asm +++ b/kernel/branches/kolibri_pe/boot/start.asm @@ -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: diff --git a/kernel/branches/kolibri_pe/bus/pci/pci32.inc b/kernel/branches/kolibri_pe/bus/pci/pci32.inc index 037cc5119e..0fa84f0f8b 100644 --- a/kernel/branches/kolibri_pe/bus/pci/pci32.inc +++ b/kernel/branches/kolibri_pe/bus/pci/pci32.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/const.inc b/kernel/branches/kolibri_pe/const.inc index 234690c474..99e329df0c 100644 --- a/kernel/branches/kolibri_pe/const.inc +++ b/kernel/branches/kolibri_pe/const.inc @@ -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 + + diff --git a/kernel/branches/kolibri_pe/core/debug.inc b/kernel/branches/kolibri_pe/core/debug.inc index f0aa56981e..0766a713d6 100644 --- a/kernel/branches/kolibri_pe/core/debug.inc +++ b/kernel/branches/kolibri_pe/core/debug.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/core/dll.c b/kernel/branches/kolibri_pe/core/dll.c index c4f507b115..3e123b7c71 100644 --- a/kernel/branches/kolibri_pe/core/dll.c +++ b/kernel/branches/kolibri_pe/core/dll.c @@ -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; diff --git a/kernel/branches/kolibri_pe/core/dll.inc b/kernel/branches/kolibri_pe/core/dll.inc index 530fbcb315..d5631f242f 100644 --- a/kernel/branches/kolibri_pe/core/dll.inc +++ b/kernel/branches/kolibri_pe/core/dll.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/core/exports.inc b/kernel/branches/kolibri_pe/core/exports.inc index e343becc35..24cdf4a6d3 100644 --- a/kernel/branches/kolibri_pe/core/exports.inc +++ b/kernel/branches/kolibri_pe/core/exports.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/core/fpu.inc b/kernel/branches/kolibri_pe/core/fpu.inc index 15d901a10c..9a3594f298 100644 --- a/kernel/branches/kolibri_pe/core/fpu.inc +++ b/kernel/branches/kolibri_pe/core/fpu.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/core/heap.c b/kernel/branches/kolibri_pe/core/heap.c index 44bc66dc45..80c391719f 100644 --- a/kernel/branches/kolibri_pe/core/heap.c +++ b/kernel/branches/kolibri_pe/core/heap.c @@ -6,8 +6,6 @@ #include #include -#define page_tabs 0xDF800000 - #define MD_FREE 1 #define MD_USED 2 diff --git a/kernel/branches/kolibri_pe/core/init.asm b/kernel/branches/kolibri_pe/core/init.asm new file mode 100644 index 0000000000..56f2038012 --- /dev/null +++ b/kernel/branches/kolibri_pe/core/init.asm @@ -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 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, ((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 + + + diff --git a/kernel/branches/kolibri_pe/core/init.c b/kernel/branches/kolibri_pe/core/mbi.c similarity index 95% rename from kernel/branches/kolibri_pe/core/init.c rename to kernel/branches/kolibri_pe/core/mbi.c index 7f75e25f35..1129be1165 100644 --- a/kernel/branches/kolibri_pe/core/init.c +++ b/kernel/branches/kolibri_pe/core/mbi.c @@ -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; diff --git a/kernel/branches/kolibri_pe/core/memory.inc b/kernel/branches/kolibri_pe/core/memory.inc index b01e470f12..f01e91a805 100644 --- a/kernel/branches/kolibri_pe/core/memory.inc +++ b/kernel/branches/kolibri_pe/core/memory.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/core/peload.inc b/kernel/branches/kolibri_pe/core/peload.inc deleted file mode 100644 index abf43186e5..0000000000 --- a/kernel/branches/kolibri_pe/core/peload.inc +++ /dev/null @@ -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' - - - diff --git a/kernel/branches/kolibri_pe/core/sched.inc b/kernel/branches/kolibri_pe/core/sched.inc index 6d54f24688..5449329f57 100644 --- a/kernel/branches/kolibri_pe/core/sched.inc +++ b/kernel/branches/kolibri_pe/core/sched.inc @@ -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] diff --git a/kernel/branches/kolibri_pe/core/sys32.inc b/kernel/branches/kolibri_pe/core/sys32.inc index dcb51d2676..95e25de363 100644 --- a/kernel/branches/kolibri_pe/core/sys32.inc +++ b/kernel/branches/kolibri_pe/core/sys32.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/core/syscall.asm b/kernel/branches/kolibri_pe/core/syscall.asm new file mode 100644 index 0000000000..0e7f01a3cb --- /dev/null +++ b/kernel/branches/kolibri_pe/core/syscall.asm @@ -0,0 +1,16 @@ + +format MS COFF + +public _i40 + + +section '.text' code readable align 16 + +align 16 + +_i40: + ; xchg bx, bx + + int 0x41 + iretd + diff --git a/kernel/branches/kolibri_pe/core/syscall.inc b/kernel/branches/kolibri_pe/core/syscall.inc index 7e09c0091a..5fd71cfc41 100644 --- a/kernel/branches/kolibri_pe/core/syscall.inc +++ b/kernel/branches/kolibri_pe/core/syscall.inc @@ -30,7 +30,7 @@ cross_order: align 16 -i40: +i41: pushad cld movzx eax, al diff --git a/kernel/branches/kolibri_pe/core/taskman.inc b/kernel/branches/kolibri_pe/core/taskman.inc index 1d310cacb8..1584786ff2 100644 --- a/kernel/branches/kolibri_pe/core/taskman.inc +++ b/kernel/branches/kolibri_pe/core/taskman.inc @@ -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] diff --git a/kernel/branches/kolibri_pe/core/thread.c b/kernel/branches/kolibri_pe/core/thread.c new file mode 100644 index 0000000000..e3f5751435 --- /dev/null +++ b/kernel/branches/kolibri_pe/core/thread.c @@ -0,0 +1,68 @@ + +#include +#include +#include +#include +#include +#include + +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; +}; + diff --git a/kernel/branches/kolibri_pe/core/v86.inc b/kernel/branches/kolibri_pe/core/v86.inc index d9a63a98da..fa0574b824 100644 --- a/kernel/branches/kolibri_pe/core/v86.inc +++ b/kernel/branches/kolibri_pe/core/v86.inc @@ -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? diff --git a/kernel/branches/kolibri_pe/data32.inc b/kernel/branches/kolibri_pe/data32.inc index 9d109f82c7..8a8881bd3a 100644 --- a/kernel/branches/kolibri_pe/data32.inc +++ b/kernel/branches/kolibri_pe/data32.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/drivers/ati2d.asm b/kernel/branches/kolibri_pe/drivers/ati2d.asm index b27a296a6d..30b0186af1 100644 --- a/kernel/branches/kolibri_pe/drivers/ati2d.asm +++ b/kernel/branches/kolibri_pe/drivers/ati2d.asm @@ -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 diff --git a/kernel/branches/kolibri_pe/drivers/imports.inc b/kernel/branches/kolibri_pe/drivers/imports.inc index 0ced3c794a..a0efa7787d 100644 --- a/kernel/branches/kolibri_pe/drivers/imports.inc +++ b/kernel/branches/kolibri_pe/drivers/imports.inc @@ -82,6 +82,6 @@ kernel_export \ strncmp,\ strnlen,\ strchr,\ - strrchr,\ -\ - LFBAddress + strrchr + + diff --git a/kernel/branches/kolibri_pe/gui/button.inc b/kernel/branches/kolibri_pe/gui/button.inc index d63774bbf3..d04584dd13 100644 --- a/kernel/branches/kolibri_pe/gui/button.inc +++ b/kernel/branches/kolibri_pe/gui/button.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/gui/event.inc b/kernel/branches/kolibri_pe/gui/event.inc index 5f9976ca52..e576128c0c 100644 --- a/kernel/branches/kolibri_pe/gui/event.inc +++ b/kernel/branches/kolibri_pe/gui/event.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/gui/skincode.inc b/kernel/branches/kolibri_pe/gui/skincode.inc index 8a7b6fab5d..6685d3c751 100644 --- a/kernel/branches/kolibri_pe/gui/skincode.inc +++ b/kernel/branches/kolibri_pe/gui/skincode.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/gui/window.inc b/kernel/branches/kolibri_pe/gui/window.inc index 49fcae1ba7..259c5e7d2c 100644 --- a/kernel/branches/kolibri_pe/gui/window.inc +++ b/kernel/branches/kolibri_pe/gui/window.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/hid/keyboard.inc b/kernel/branches/kolibri_pe/hid/keyboard.inc index 9d6d0b836e..086db79174 100644 --- a/kernel/branches/kolibri_pe/hid/keyboard.inc +++ b/kernel/branches/kolibri_pe/hid/keyboard.inc @@ -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 @@ -340,4 +340,4 @@ numlock_map: db 0x33 ;Num 3 db 0x30 ;Num 0 db 0x2E ;Num . -;..........................Part2 End................................................ \ No newline at end of file +;..........................Part2 End................................................ diff --git a/kernel/branches/kolibri_pe/hid/mousedrv.inc b/kernel/branches/kolibri_pe/hid/mousedrv.inc index 0e795183ee..2ed1d6f1fd 100644 --- a/kernel/branches/kolibri_pe/hid/mousedrv.inc +++ b/kernel/branches/kolibri_pe/hid/mousedrv.inc @@ -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] diff --git a/kernel/branches/kolibri_pe/include/core.h b/kernel/branches/kolibri_pe/include/core.h index 1bfb7a10ca..d3ca794c1e 100644 --- a/kernel/branches/kolibri_pe/include/core.h +++ b/kernel/branches/kolibri_pe/include/core.h @@ -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 diff --git a/kernel/branches/kolibri_pe/init.inc b/kernel/branches/kolibri_pe/init.inc deleted file mode 100644 index 13f631e77e..0000000000 --- a/kernel/branches/kolibri_pe/init.inc +++ /dev/null @@ -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 - - diff --git a/kernel/branches/kolibri_pe/kernel.asm b/kernel/branches/kolibri_pe/kernel.asm index 1f3e6ff1f3..210c860e06 100644 --- a/kernel/branches/kolibri_pe/kernel.asm +++ b/kernel/branches/kolibri_pe/kernel.asm @@ -73,16 +73,23 @@ include "const.inc" max_processes equ 255 tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 +sel_tss equ (tss_l - _gdts) ;0x08 -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) -app_code equ (3+app_code_l-_gdts) -app_data equ (3+app_data_l-_gdts) -pci_code_sel equ (pci_code_32-_gdts) -pci_data_sel equ (pci_data_32-_gdts) +sel_os_code equ (os_code_l - _gdts) ;0x10 +sel_os_stack equ (os_stacK_l - _gdts) ;0x18 +sel_app_code equ (app_code_l - _gdts +3) ;0x23 +sel_app_data equ (app_data_l - _gdts +3) ;0x2B + +sel_srv_code equ (srv_code_l - _gdts +1) ;0x31 +sel_srv_stack equ (srv_stack_l- _gdts +1) ;0x39 + +sel_pci_code equ (pci_code_32-_gdts) ;0x40 +sel_pci_data equ (pci_data_32-_gdts) ;0x48 + +sel_graph_data equ (graph_data_l-_gdts +3) + +sel_code_16 equ (code_16_l - _gdts) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; @@ -108,11 +115,9 @@ pci_data_sel equ (pci_data_32-_gdts) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -public __os_stack public _boot_mbi public _sys_pdbr public _gdts -public _high_code public __hlt public _panic_printf @@ -121,7 +126,7 @@ public _pg_balloc public _mem_amount public @balloc@4 -public __setvars +public system_init public _rd_base public _rd_fat @@ -130,6 +135,8 @@ public _rd_root public _rd_root_end public _current_slot +public _current_thread +public _k_reenter public _load_file@4 @@ -141,6 +148,7 @@ public _init_user_heap public user_alloc public user_free + public _strncmp@12 public _LoadFile ; stdcall export @@ -163,7 +171,6 @@ public _RegService ; stdcall export public _SysMsgBoardStr ; export public _SetScreen ; export FIXME make fastcall - public _PciApi ; export public _PciRead8 ; stdcall export public _PciRead16 ; stdcall export @@ -172,25 +179,35 @@ public _PciWrite8 ; stdcall export public _PciWrite16 ; stdcall export public _PciWrite32 ; stdcall export - public _SelectHwCursor ; stdcall export public _SetHwCursor ; stdcall export public _HwCursorRestore ; export public _HwCursorCreate ; export +public init_idt +public init_fpu +public init_malloc +public init_mtrr + +public sysenter_entry +public syscall_entry + +public scr_mode +public LFBAddress +public LFBSize + extrn __edata +extrn __os_stack + +extrn _pg_balloc + extrn _16bit_start extrn _16bit_end -extrn _enter_bootscreen -extrn _poweroff -extrn _init -extrn _init_mm -extrn @init_heap@8 -extrn _init_core_dll +extrn _poweroff extrn @core_alloc@4 extrn @core_free@4 @@ -203,12 +220,12 @@ extrn _MemFree @mem_alloc@8 equ _MemAlloc @mem_free@4 equ _MemFree +extrn @create_systhread@4 extrn _sys_exec ;extrn @load_pe@4 extrn @load_pe_driver@4 -extrn _slab_cache_init extrn _alloc_page extrn _get_free_mem @@ -217,6 +234,17 @@ extrn _bx_from_load extrn _sys_app_entry +extrn _i40 + +extrn test_cpu + +extrn cpu_vendor +extrn cpu_sign +extrn cpu_info +extrn cpu_caps:dword + + + section '.flat' code readable align 4096 use32 @@ -261,211 +289,10 @@ _panic_printf: align 4 include 'printf.inc' -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 - -align 4 -_copy_pg_balloc dd 0 - - -_high_code: - - mov ax,os_stack - mov dx,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 _init - - mov eax, [_pg_balloc] - mov [_copy_pg_balloc], eax - - mov [tss._ss0], os_stack - mov [tss._esp0], __os_stack - mov [tss._esp], __os_stack - 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 - ; not eax - mov ecx, 8192/4 - rep stosd ; access to 4096*8=65536 ports - - mov ax,tss0 - ltr ax - -__core_restart: - - mov ecx, 1280*1024 - fastcall _balloc - mov [_display_data], eax - - mov ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ - (unpack.lc+unpack.lp)))*4 - fastcall _balloc - mov [unpack.p], eax - -; MEMORY MODEL - - call _init_mm - mov [pg_data.pg_mutex], 0 - - call _slab_cache_init - - mov ecx, 0x80000000 - mov edx, 0x40000000 - call @init_heap@8 - - call _init_core_dll - - mov esi, _16bit_start - mov ecx, _16bit_end - shr ecx, 2 - mov edi, _16BIT_BASE - cld - rep movsd - - jmp far 0x60:_enter_bootscreen; - -align 4 -__setvars: - mov ax,os_stack - mov dx,app_data - mov ss,ax - mov esp, __os_stack - - mov ds, dx - mov es, dx - mov fs, dx - mov gs, dx - -; 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 - mov eax, cr3 - mov cr3, eax - -; SAVE REAL MODE VARIABLES - mov ax, [BOOT_VAR + 0x9031] - mov [IDEContrRegsBaseAddr], ax ; --------------- APM --------------------- +align 4 +init_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 @@ -495,198 +322,163 @@ __setvars: mov eax, [BOOT_VAR + 0x9044] ; version & flags mov [apm_vf], eax -; ----------------------------------------- -; 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 - mov al,[BOOT_VAR+0x9000] ; bpp - mov [ScreenBPP],al + ret - movzx eax,word [BOOT_VAR+0x900A] ; X max - dec eax - mov [Screen_Max_X],eax - mov [screen_workarea.right],eax - movzx eax,word [BOOT_VAR+0x900C] ; Y max - 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 +align 16 +system_init: - mov ax,[BOOT_VAR+0x9001] ; for other modes - mov [BytesPerScanLine],ax + mov [pg_data.pg_mutex], 0 + + call init_apm + +; SAVE REAL MODE VARIABLES + mov ax, [BOOT_VAR + 0x9031] + mov [IDEContrRegsBaseAddr], ax + + mov al, [BOOT_VAR+0x901F] ; DMA access + mov [allow_dma_access], al + + movzx eax, byte [BOOT_VAR+0x9000] ; bpp + mov [ScreenBPP], eax + + movzx eax,word [BOOT_VAR+0x900A] ; X max + dec eax + mov [Screen_Max_X],eax + mov [screen_workarea.right],eax + movzx eax,word [BOOT_VAR+0x900C] ; Y max + dec eax + mov [Screen_Max_Y],eax + mov [screen_workarea.bottom],eax + mov [BytesPerScanLine], 640*4 + cmp [scr_mode], 0x13 ; 320x200 + je @f + cmp [scr_mode], 0x12 ; VGA 640x480 + je @f + + movzx eax, word [BOOT_VAR+0x9001] ; for other modes + mov [BytesPerScanLine], 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 - mov byte [BOOT_VAR+0x901e],0x0 - mov eax,[BOOT_VAR+0x9018] - mov [LFBAddress],eax + mov byte [BOOT_VAR+0x901e],0x0 - cmp [SCR_MODE],word 0100000000000000b - jge setvesa20 - cmp [SCR_MODE],word 0x13 - je v20ga32 - mov [PUTPIXEL],dword Vesa12_putpixel24 ; Vesa 1.2 - mov [GETPIXEL],dword Vesa12_getpixel24 - cmp [ScreenBPP],byte 24 - jz ga24 - mov [PUTPIXEL],dword Vesa12_putpixel32 - mov [GETPIXEL],dword Vesa12_getpixel32 - ga24: - jmp v20ga24 - setvesa20: - mov [PUTPIXEL],dword Vesa20_putpixel24 ; Vesa 2.0 - mov [GETPIXEL],dword Vesa20_getpixel24 - cmp [ScreenBPP],byte 24 - jz v20ga24 - v20ga32: - mov [PUTPIXEL],dword Vesa20_putpixel32 - mov [GETPIXEL],dword Vesa20_getpixel32 - v20ga24: - cmp [SCR_MODE],word 0x12 ; 16 C VGA 640x480 - jne no_mode_0x12 - mov [PUTPIXEL],dword VGA_putpixel - mov [GETPIXEL],dword Vesa20_getpixel32 - no_mode_0x12: + cmp [scr_mode], 0100000000000000b + jge setvesa20 + cmp [scr_mode], 0x13 + je v20ga32 + mov [put_pixel], Vesa12_putpixel24 ; Vesa 1.2 + mov [get_pixel],dword Vesa12_getpixel24 + cmp byte [ScreenBPP], 24 + jz ga24 + mov [put_pixel], Vesa12_putpixel32 + mov [get_pixel],dword Vesa12_getpixel32 +ga24: + jmp v20ga24 +setvesa20: + mov [put_pixel], Vesa20_putpixel24 ; Vesa 2.0 + mov [get_pixel],dword Vesa20_getpixel24 + cmp byte [ScreenBPP], 24 + jz v20ga24 +v20ga32: + mov [put_pixel], Vesa20_putpixel32 + mov [get_pixel],dword Vesa20_getpixel32 +v20ga24: + cmp [scr_mode], 0x12 ; 16 C VGA 640x480 + jne no_mode_0x12 + mov [put_pixel], VGA_putpixel + mov [get_pixel],dword Vesa20_getpixel32 +no_mode_0x12: -; -------- 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, 1280*1024 + mov edx, PG_SW + call @mem_alloc@8 + mov [_display_data], eax - ; !!!! It`s dirty hack, fix it !!! - ; 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 ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ + (unpack.lc+unpack.lp)))*4 + mov edx, PG_SW + call @mem_alloc@8 + mov [unpack.p], eax - ; mov edx, (os_code + 16) * 65536 + os_code - mov edx, 0x1B0008 +;Set base of graphic segment to linear address of LFB - mov eax, syscall_entry - mov ecx, MSR_AMD_STAR - wrmsr -.noSYSCALL: -; ----------------------------------------- -; LOAD IDT - - call _init_idt - - mov [LFBSize], 0x800000 - call init_LFB - call init_fpu - call init_malloc + mov eax, LFB_BASE + mov [graph_data_l+2],ax + shr eax,16 + mov [graph_data_l+4],al + mov [graph_data_l+7],ah mov ecx, 0x51000 xor edx, edx call @mem_alloc@8 - mov [default_io_map], eax + 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 - 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 [CURRENT_TASK],dword 1 - mov [TASK_COUNT],dword 1 - mov [TASK_BASE],dword TASK_DATA - mov [current_slot], SLOT_BASE+256 + mov [CURRENT_TASK],dword 1 + mov [TASK_COUNT],dword 1 + mov [TASK_BASE],dword TASK_DATA + mov [current_slot], SLOT_BASE+256 ; set background - xor eax,eax - inc eax - mov [BgrDrawMode],eax - mov [BgrDataWidth],eax - mov [BgrDataHeight],eax - mov ecx, 4095 - mov edx, PG_SW - mov [mem_BACKGROUND],4095 - call @mem_alloc@8 - mov [img_background], eax + xor eax,eax + inc eax + mov [BgrDrawMode],eax + mov [BgrDataWidth],eax + mov [BgrDataHeight],eax + mov ecx, 4095 + mov edx, PG_SW + mov [mem_BACKGROUND],4095 + call @mem_alloc@8 + mov [img_background], eax - mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr + (0x100000000-OS_BASE) + mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr + (0x100000000-OS_BASE) ; 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 @@ -869,11 +661,6 @@ include 'detect/disks.inc' stdcall load_driver, szPS2MDriver ; stdcall load_driver, szCOM_MDriver - mov esi,boot_setmouse - call boot_log - call setmouse - - ; STACK AND FDC call stack_init @@ -881,14 +668,14 @@ include 'detect/disks.inc' ; PALETTE FOR 320x200 and 640x480 16 col - cmp [SCR_MODE],word 0x12 + cmp [scr_mode], 0x12 jne no_pal_vga mov esi,boot_pal_vga call boot_log call paletteVGA no_pal_vga: - cmp [SCR_MODE],word 0x13 + cmp [scr_mode], 0x13 jne no_pal_ega mov esi,boot_pal_ega call boot_log @@ -919,7 +706,6 @@ include 'detect/disks.inc' ; LOAD FIRST APPLICATION - push 0 push 0 push read_firstapp @@ -973,8 +759,6 @@ first_app_found: ; jne .bll1 ;end if -; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled - ; UNMASK ALL IRQ'S mov esi,boot_allirqs @@ -1195,27 +979,27 @@ endg set_variables: mov ecx,0x100 ; flush port 0x60 -.fl60: in al,0x60 - loop .fl60 - mov [MOUSE_BUFF_COUNT],byte 0 ; mouse buffer - mov [KEY_COUNT],byte 0 ; keyboard buffer - mov [BTN_COUNT],byte 0 ; button buffer -; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y +.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 - pop eax + mov [KEY_COUNT], 0 ; keyboard buffer + mov [BTN_COUNT], 0 ; button buffer - mov [BTN_ADDR],dword BUTTON_INFO ; address of button list + push eax + mov ax,[BOOT_VAR+0x900c] + shr ax,1 + shl eax,16 + mov ax,[BOOT_VAR+0x900A] + shr ax,1 + mov dword [MOUSE_X], eax + pop eax + + mov [btn_addr], BUTTON_INFO ; address of button list ;!! IP 04.02.2005: - mov [next_usage_update], 100 - mov byte [DONT_SWITCH], 0 ; change task if possible + mov [next_usage_update], 100 + mov [dont_switch], 0 ; change task if possible ret @@ -1801,13 +1585,13 @@ readmousepos: ja msset jmp [mousefn+eax*4] msscreen: - mov eax,[MOUSE_X] + mov eax, dword [MOUSE_X] shl eax,16 mov ax,[MOUSE_Y] mov [esp+36],eax ret mswin: - mov eax,[MOUSE_X] + mov eax, dword [MOUSE_X] shl eax,16 mov ax,[MOUSE_Y] mov esi,[TASK_BASE] @@ -1825,7 +1609,7 @@ mswin: mov [esp+36],eax ret msbutton: - movzx eax,byte [BTN_DOWN] + movzx eax,byte [btn_down] mov [esp+36],eax ret msz: @@ -1833,12 +1617,12 @@ msz: movzx edi, word [WIN_POS + edi*2] cmp edi, [CURRENT_TASK] jne @f - mov ax,[MOUSE_SCROLL_H] + mov eax,[mouse_scroll_h] shl eax,16 - mov ax,[MOUSE_SCROLL_V] + mov ax, word [mouse_scroll_v] mov [esp+36],eax - mov [MOUSE_SCROLL_H],word 0 - mov [MOUSE_SCROLL_V],word 0 + mov [mouse_scroll_h], 0 + mov [mouse_scroll_v], 0 ret @@: mov [esp+36],dword 0 @@ -2018,7 +1802,7 @@ sysfn_shutdown: ; 18.9 = system shutdown mov [BOOT_VAR+0x9030],cl mov eax,[TASK_COUNT] - mov [SYS_SHUTDOWN],al + mov [sys_shutdown], eax mov [shutdown_processes],eax and dword [esp+32], 0 exit_for_anyone: @@ -2221,7 +2005,7 @@ sysfn_mouse_acceleration: ; 18.19 = set/get mouse features .set_mouse_button: cmp ecx,5 ; set mouse button features jnz .end - mov [BTN_DOWN],dl + mov byte [btn_down],dl mov [mouse_active],1 .end: ret @@ -2408,7 +2192,7 @@ draw_background_temp: ; mov [bgrchanged],1 ;0 mov [background_defined], 1 call force_redraw_background - mov [REDRAW_BACKGROUND], byte 2 + mov [redraw_background], 2 nosb31: ret nosb3: @@ -2522,7 +2306,7 @@ force_redraw_background: mov [draw_data+32 + RECT.right],eax mov [draw_data+32 + RECT.bottom],ebx pop ebx eax - mov byte [REDRAW_BACKGROUND], 1 + mov [redraw_background], 1 ret align 4 @@ -2577,14 +2361,14 @@ sys_getkey: mov edx, [TASK_COUNT] cmp ecx, edx jne .finish - cmp [KEY_COUNT], byte 0 + cmp [KEY_COUNT], 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] + dec [KEY_COUNT] + and [KEY_COUNT], 127 + mov ecx, [KEY_COUNT] add ecx, 2 mov eax, KEY_BUFF + 1 mov ebx, KEY_BUFF @@ -2622,16 +2406,16 @@ sys_getbutton: mov edx, [TASK_COUNT] ; less than 256 processes cmp ecx, edx jne .exit - movzx eax, byte [BTN_COUNT] - test eax, eax + mov eax, [BTN_COUNT] + test eax, eax jz .exit mov eax, [BTN_BUFF] shl eax, 8 ; // Alver 22.06.2008 // { mov al, byte [btn_down_determ] - and al,0xFE ; delete left button bit + and al,0xFE ; delete left button bit ; } \\ Alver \\ - mov [BTN_COUNT], byte 0 + mov [BTN_COUNT], 0 mov [esp + 32], eax .exit: ret @@ -2810,7 +2594,7 @@ sys_redrawstat: ; buttons away mov ecx,[CURRENT_TASK] sys_newba2: - mov edi,[BTN_ADDR] + mov edi,[btn_addr] cmp [edi], dword 0 ; empty button list ? je end_of_buttons_away movzx ebx, word [edi] @@ -3187,8 +2971,8 @@ sys_set_window: add edx, ebx call calculatescreen - 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 newd: mov [edi+WDATA.fl_redraw],byte 0 ; no redraw @@ -3316,9 +3100,8 @@ sys_window_move: xor esi,esi call redrawscreen - 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 call [draw_pointer] @@ -3487,8 +3270,8 @@ align 4 checkmisc: - cmp [ctrl_alt_del], 1 - jne nocpustart + cmp [ctrl_alt_del], 1 + jne nocpustart push 0 push 0 @@ -3496,7 +3279,7 @@ checkmisc: call _sys_exec add esp, 12 - mov [ctrl_alt_del], 0 + mov [ctrl_alt_del], 0 nocpustart: cmp [mouse_active], 1 @@ -3510,11 +3293,11 @@ set_mouse_event: loop set_mouse_event mouse_not_active: - cmp [REDRAW_BACKGROUND],byte 0 ; background update ? + cmp [redraw_background], 0 ; background update ? jz nobackgr cmp [background_defined], 0 jz nobackgr - cmp [REDRAW_BACKGROUND], byte 2 + cmp [redraw_background], 2 jnz no_set_bgr_event xor edi, edi mov ecx, [TASK_COUNT] @@ -3530,19 +3313,19 @@ no_set_bgr_event: ; mov [draw_data+32 + RECT.right],eax ; mov [draw_data+32 + RECT.bottom],ebx call drawbackground - mov [REDRAW_BACKGROUND],byte 0 - mov [MOUSE_BACKGROUND],byte 0 + mov [redraw_background], 0 + mov [redraw_background], 0 nobackgr: ; system shutdown request - cmp [SYS_SHUTDOWN],byte 0 + cmp [sys_shutdown], 0 je noshutdown mov edx,[shutdown_processes] - cmp [SYS_SHUTDOWN],dl + cmp [sys_shutdown], edx jne no_mark_system_shutdown lea ecx,[edx-1] @@ -3558,7 +3341,7 @@ markz: call [disable_mouse] - dec byte [SYS_SHUTDOWN] + dec [sys_shutdown] je system_shutdown noshutdown: @@ -3646,7 +3429,7 @@ redrawscreen: cmp ecx,1 jnz .az - mov al,[REDRAW_BACKGROUND] + mov al, byte [redraw_background] cmp al,2 jz newdw8 test al,al @@ -3691,7 +3474,7 @@ redrawscreen: cmp dword [esp],1 jne nobgrd - mov byte [REDRAW_BACKGROUND], 1 + mov [redraw_background], 1 newdw8: nobgrd: @@ -3727,7 +3510,7 @@ calculatebackground: ; background mov ecx,1280*1024 / 4 rep stosd - mov byte [REDRAW_BACKGROUND], 0 ; do not draw background! + mov [redraw_background], 0 ; do not draw background! ret @@ -4229,12 +4012,12 @@ endg drawbackground: inc [mouse_pause] - cmp [SCR_MODE],word 0x12 + cmp [scr_mode], 0x12 je dbrv20 dbrv12: - cmp [SCR_MODE],word 0100000000000000b + cmp [scr_mode], 0100000000000000b jge dbrv20 - cmp [SCR_MODE],word 0x13 + cmp [scr_mode], 0x13 je dbrv20 call vesa12_drawbackground dec [mouse_pause] @@ -4278,12 +4061,12 @@ sys_putimage: sys_putimage_bpp: ; call [disable_mouse] ; this will be done in xxx_putimage ; mov eax, vga_putimage - cmp [SCR_MODE], word 0x12 + cmp [scr_mode], 0x12 jz @f ;.doit mov eax, vesa12_putimage - cmp [SCR_MODE], word 0100000000000000b + cmp [scr_mode], 0100000000000000b jae @f - cmp [SCR_MODE], word 0x13 + cmp [scr_mode], 0x13 jnz .doit @@: mov eax, vesa20_putimage @@ -4527,12 +4310,12 @@ __sys_drawbar: .forced: inc [mouse_pause] ; call [disable_mouse] - cmp [SCR_MODE],word 0x12 + cmp [scr_mode], 0x12 je dbv20 sdbv20: - cmp [SCR_MODE],word 0100000000000000b + cmp [scr_mode], 0100000000000000b jge dbv20 - cmp [SCR_MODE],word 0x13 + cmp [scr_mode], 0x13 je dbv20 call vesa12_drawbar dec [mouse_pause] @@ -4654,16 +4437,6 @@ kb_cmd: ret -setmouse: ; set mousepicture -pointer - ; ps2 mouse enable - - mov [MOUSE_PICTURE],dword mousepointer - - cli - - ret - - _rdtsc: bt [cpu_caps], CAPS_TSC jnc ret_rdtsc @@ -4678,56 +4451,31 @@ rerouteirqs: 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,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,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 al,255 ; mask all irq's out 0xA1,al - call pic_delay out 0x21,al - call pic_delay - ret - -pic_delay: - - jmp pdl1 -pdl1: ret - - align 4 _SysMsgBoardStr: sys_msg_board_str: @@ -4953,7 +4701,7 @@ sys_gs: ; direct screen access jne no_gs1 mov eax,[Screen_Max_X] shl eax,16 - mov ax,[Screen_Max_Y] + mov ax, word [Screen_Max_Y] add eax,0x00010001 mov [esp+36],eax ret @@ -4961,7 +4709,7 @@ sys_gs: ; direct screen access cmp eax,2 ; bits per pixel jne no_gs2 - movzx eax,byte [ScreenBPP] + mov eax, [ScreenBPP] mov [esp+36],eax ret no_gs2: @@ -5065,9 +4813,9 @@ syscall_drawrect: ; DrawRect align 4 syscall_getscreensize: ; GetScreenSize - mov ax, [Screen_Max_X] + mov eax, [Screen_Max_X] shl eax, 16 - mov ax, [Screen_Max_Y] + mov ax, word [Screen_Max_Y] mov [esp + 32], eax ret @@ -5139,7 +4887,7 @@ syscall_getpixel: ; GetPixel div ecx mov ebx, edx xchg eax, ebx - call dword [GETPIXEL] ; eax - x, ebx - y + call dword [get_pixel] ; eax - x, ebx - y mov [esp + 32], ecx ret @@ -5381,14 +5129,15 @@ yes_shutdown_param: mov eax, _sys_pdbr + (0x100000000-OS_BASE) mov cr3, eax - jmp far 0x60:_poweroff; + jmp far sel_code_16:_poweroff; +align 4 _sys_restart: - mov ax,os_stack - mov dx,app_data - mov ss,ax + mov ax, sel_os_stack + mov dx, sel_app_data + mov ss, ax mov esp, __os_stack mov ds, dx @@ -5404,7 +5153,7 @@ _sys_restart: mov ecx,0x10000/4 rep movsd - mov eax, [_copy_pg_balloc] + ; mov eax, [_copy_pg_balloc] mov [_pg_balloc], eax mov dword [_sys_pdbr], PG_LARGE+PG_SW diff --git a/kernel/branches/kolibri_pe/ld.x b/kernel/branches/kolibri_pe/ld.x index 42327c1d4c..4217419724 100644 --- a/kernel/branches/kolibri_pe/ld.x +++ b/kernel/branches/kolibri_pe/ld.x @@ -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): diff --git a/kernel/branches/kolibri_pe/makefile b/kernel/branches/kolibri_pe/makefile index a467aebe18..18635c58c9 100644 --- a/kernel/branches/kolibri_pe/makefile +++ b/kernel/branches/kolibri_pe/makefile @@ -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 @@ -63,6 +66,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) $< $@ diff --git a/kernel/branches/kolibri_pe/video/cursors.inc b/kernel/branches/kolibri_pe/video/cursors.inc index e6810186a4..f530e2197b 100644 --- a/kernel/branches/kolibri_pe/video/cursors.inc +++ b/kernel/branches/kolibri_pe/video/cursors.inc @@ -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] diff --git a/kernel/branches/kolibri_pe/video/vesa12.inc b/kernel/branches/kolibri_pe/video/vesa12.inc index e02293cd12..ee2bcb95e7 100644 --- a/kernel/branches/kolibri_pe/video/vesa12.inc +++ b/kernel/branches/kolibri_pe/video/vesa12.inc @@ -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 diff --git a/kernel/branches/kolibri_pe/video/vesa20.inc b/kernel/branches/kolibri_pe/video/vesa20.inc index d4c4ae440d..cea271151a 100644 --- a/kernel/branches/kolibri_pe/video/vesa20.inc +++ b/kernel/branches/kolibri_pe/video/vesa20.inc @@ -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 @@: diff --git a/kernel/branches/kolibri_pe/video/vga.inc b/kernel/branches/kolibri_pe/video/vga.inc index 942f6a41ad..6da4e95314 100644 --- a/kernel/branches/kolibri_pe/video/vga.inc +++ b/kernel/branches/kolibri_pe/video/vga.inc @@ -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