From 907e29249b7b9b0fee1b3892ed9866823c930a66 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 8 Mar 2007 11:28:22 +0000 Subject: [PATCH] 1) high LFB 2) ixed fat12 & RD write error git-svn-id: svn://kolibrios.org@400 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/flat_kernel/blkdev/rd.inc | 4 +- kernel/branches/flat_kernel/const.inc | 8 +- kernel/branches/flat_kernel/core/memory.inc | 7 +- kernel/branches/flat_kernel/core/syscall.inc | 42 +++-- kernel/branches/flat_kernel/core/taskman.inc | 20 +-- kernel/branches/flat_kernel/fs/fat12.inc | 3 +- kernel/branches/flat_kernel/init.inc | 60 ++++--- kernel/branches/flat_kernel/kernel.asm | 3 +- kernel/branches/flat_kernel/memmap.inc | 166 ++++++++++--------- 9 files changed, 167 insertions(+), 146 deletions(-) diff --git a/kernel/branches/flat_kernel/blkdev/rd.inc b/kernel/branches/flat_kernel/blkdev/rd.inc index b521d6ad65..83f75e23b4 100644 --- a/kernel/branches/flat_kernel/blkdev/rd.inc +++ b/kernel/branches/flat_kernel/blkdev/rd.inc @@ -598,6 +598,8 @@ fat_get_name: @@: cmp byte [edi+11], 0xF jz .longname + test byte [edi+11], 8 + jnz .no push ecx push edi ebp test byte [ebp-4], 1 @@ -1800,7 +1802,7 @@ fs_RamdiskRewrite: ; lea eax, [edi-(RAMDISK_FAT)] mov eax, edi - sub edi, RAMDISK_FAT + sub eax, RAMDISK_FAT shr eax, 1 ; eax = cluster mov word [edi], 0xFFF ; mark as last cluster diff --git a/kernel/branches/flat_kernel/const.inc b/kernel/branches/flat_kernel/const.inc index 7f84779e2f..11c5a841ae 100644 --- a/kernel/branches/flat_kernel/const.inc +++ b/kernel/branches/flat_kernel/const.inc @@ -255,9 +255,11 @@ skin_data equ (OS_BASE+0x0778000) tss_data equ (OS_BASE+0x780000) draw_data equ (OS_BASE+0x988000) -HEAP_BASE equ (OS_BASE+0x01000000) +tmp_page_tab equ 0x98B000; draw_data+sizeof(drw_data) -LFB_BASE equ 0x7DC00000 +HEAP_BASE equ (OS_BASE+tmp_page_tab) + +LFB_BASE equ 0xFE000000 page_tabs equ 0x7FC00000 master_tab equ 0x7FDFF000 @@ -267,7 +269,7 @@ sys_pgdir equ (OS_BASE+0x00050000) sys_pgmap equ (OS_BASE+0x00052000) -new_app_base equ 0x01000000 ; 0= flat +new_app_base equ 0; 0x01000000 twdw equ (CURRENT_TASK-window_data) diff --git a/kernel/branches/flat_kernel/core/memory.inc b/kernel/branches/flat_kernel/core/memory.inc index 38fc19d447..dbead4aeb6 100644 --- a/kernel/branches/flat_kernel/core/memory.inc +++ b/kernel/branches/flat_kernel/core/memory.inc @@ -248,10 +248,9 @@ proc init_LFB bt [cpu_caps], CAPS_PSE jnc .map_page_tables or esi, PG_LARGE+PG_UW - shr edx, 20 - mov ecx, edx + mov edx, sys_pgdir+(LFB_BASE shr 20) @@: - mov [sys_pgdir+edx], esi + mov [edx], esi add edx, 4 add esi, 0x00400000 dec edi @@ -259,7 +258,7 @@ proc init_LFB bt [cpu_caps], CAPS_PGE jnc @F - or dword [sys_pgdir+ecx], PG_GLOBAL + or dword [sys_pgdir+(LFB_BASE shr 20)], PG_GLOBAL @@: mov dword [LFBAddress], LFB_BASE mov eax, cr3 ;flush TLB diff --git a/kernel/branches/flat_kernel/core/syscall.inc b/kernel/branches/flat_kernel/core/syscall.inc index d3da45d84c..1708a3b9cf 100644 --- a/kernel/branches/flat_kernel/core/syscall.inc +++ b/kernel/branches/flat_kernel/core/syscall.inc @@ -50,13 +50,18 @@ align 32 SYSENTER_VAR equ 0 sysenter_entry: ; Настраиваем стек - cli - push eax - mov eax, [ss:CURRENT_TASK] - shl eax, 8 - mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] - lea esp, [ss:eax + RING0_STACK_SIZE] ; configure ESP - mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app + ; cli sysenter clear IF + ; push eax + ; mov eax, [ss:CURRENT_TASK] + ; shl eax, 8 + ; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] + ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP + ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app + + mov esp, [ss:CURRENT_TASK] + shl esp, 8 + mov esp, [ss:SLOT_BASE + esp + APPDATA.pl0_stack] + add esp, RING0_STACK_SIZE ; configure ESP sti ;------------------ push ds es @@ -93,15 +98,22 @@ sysenter_entry: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 32 syscall_entry: - cli + ; cli syscall clear IF xchg ecx, [esp] mov [SYSENTER_VAR + 4], esp - mov [ss:sysenter_stack - 4], eax - mov eax, [ss:CURRENT_TASK] - shl eax, 8 - mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] - lea esp, [ss:eax + RING0_STACK_SIZE] ; configure ESP - mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app + + ; mov [ss:sysenter_stack - 4], eax + ; mov eax, [ss:CURRENT_TASK] + ; shl eax, 8 + ; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] + ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP + ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app + + mov esp, [ss:CURRENT_TASK] + shl esp, 8 + mov esp, [ss:SLOT_BASE + esp + APPDATA.pl0_stack] + add esp, RING0_STACK_SIZE ; configure ESP + sti ;------------------ push ds es @@ -127,6 +139,8 @@ syscall_entry: popad pop es ds ;------------------ + + cli mov esp, [SYSENTER_VAR + 4] xchg ecx, [esp] sysret diff --git a/kernel/branches/flat_kernel/core/taskman.inc b/kernel/branches/flat_kernel/core/taskman.inc index 9bc097b3ec..68d1b12903 100644 --- a/kernel/branches/flat_kernel/core/taskman.inc +++ b/kernel/branches/flat_kernel/core/taskman.inc @@ -226,7 +226,6 @@ end if mov eax, [save_cr3] call set_cr3 - ; popfd xor ebx, ebx mov [application_table_status],ebx ;unlock application_table_status mutex mov eax,[process_number] ;set result @@ -235,7 +234,6 @@ end if mov eax, [save_cr3] call set_cr3 .err: - ; popfd .err_hdr: stdcall kernel_free,[file_base] .err_file: @@ -334,9 +332,7 @@ proc get_new_process_place cmp eax,256 jge .failed ;it should be <256 mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) - ; mov [new_process_place], eax ret - .failed: xor eax,eax ret @@ -393,20 +389,19 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword stdcall map_page,[tmp_task_pdir],eax,dword PG_SW mov edi, [tmp_task_pdir] - mov ecx, (LFB_BASE shr 20)/4 ;(page_tabs shr 20)/4 + mov ecx, (page_tabs shr 20)/4 xor eax, eax rep stosd - mov esi, sys_pgdir+(LFB_BASE shr 20) ;(OS_BASE shr 20) + mov eax, [dir_addr] + or eax, PG_SW + stosd + + mov esi, sys_pgdir+(OS_BASE shr 20) mov ecx, (OS_BASE shr 20)/4 cld rep movsd - mov edi, [tmp_task_pdir] - mov eax, [dir_addr] - or eax, PG_SW - mov [edi+(page_tabs shr 20)], eax - mov eax, [dir_addr] call set_cr3 @@ -531,7 +526,6 @@ proc destroy_app_space stdcall, pg_dir:dword xor edx,edx mov eax,0x2 mov ebx, [pg_dir] - .loop: ;eax = current slot of process mov ecx,eax @@ -557,7 +551,7 @@ proc destroy_app_space stdcall, pg_dir:dword and eax, not 0xFFF stdcall map_page,[tmp_task_pdir],eax,dword PG_SW mov esi, [tmp_task_pdir] - mov edi, (LFB_BASE shr 20)/4 + mov edi, (page_tabs shr 20)/4 .destroy: mov eax, [esi] test eax, 1 diff --git a/kernel/branches/flat_kernel/fs/fat12.inc b/kernel/branches/flat_kernel/fs/fat12.inc index 3739a9f033..d7df53b1fc 100644 --- a/kernel/branches/flat_kernel/fs/fat12.inc +++ b/kernel/branches/flat_kernel/fs/fat12.inc @@ -1889,12 +1889,13 @@ fs_FloppyRewrite: repnz scasw mov al, ERROR_DISK_FULL jnz .ret + dec edi dec edi ; lea eax, [edi-FLOPPY_FAT] mov eax, edi - sub edi, FLOPPY_FAT + sub eax, FLOPPY_FAT shr eax, 1 ; eax = cluster mov word [edi], 0xFFF ; mark as last cluster diff --git a/kernel/branches/flat_kernel/init.inc b/kernel/branches/flat_kernel/init.inc index c57d3fe7fa..77c99d6b1d 100644 --- a/kernel/branches/flat_kernel/init.inc +++ b/kernel/branches/flat_kernel/init.inc @@ -3,8 +3,6 @@ MEM_WB equ 6 ;write-back memory MEM_WC equ 1 ;write combined memory MEM_UC equ 0 ;uncached memory -tmp_page_tab equ 0x1000000 ; HEAP_BASE - align 4 proc mem_test @@ -53,19 +51,21 @@ proc init_mem xor eax, eax mov edi, sys_pgdir-OS_BASE - mov ecx, 2048 + mov ecx, 4096/4 cld rep stosd - mov edx, sys_pgdir-OS_BASE -; bt [cpu_caps], CAPS_PSE -; jnc .no_PSE + mov edx, (sys_pgdir-OS_BASE)+ 0x800; (OS_BASE shr 20) + bt [cpu_caps-OS_BASE], CAPS_PSE + jnc .no_PSE mov ebx, cr4 or ebx, CR4_PSE mov eax, PG_LARGE+PG_SW + bt [cpu_caps-OS_BASE], CAPS_PGE jnc @F + or eax, PG_GLOBAL or ebx, CR4_PGE @@: @@ -73,35 +73,23 @@ proc init_mem sub [pg_data.kernel_tables-OS_BASE], 2 mov [edx], eax - mov [edx+(OS_BASE shr 20)], eax add eax, 0x00400000 - mov [edx+4], eax - mov [edx+(OS_BASE shr 20)+4], eax - add eax, 0x00400000 + add edx, 8 - mov [edx+8], eax - mov [edx+(OS_BASE shr 20)+8], eax - add eax, 0x00400000 - - mov [edx+12], eax - mov [edx+(OS_BASE shr 20)+12], eax - add edx, (OS_BASE shr 20)+16 - add eax, 0x00400000 - -; mov eax, 0x800000+PG_SW -; mov ecx, (HEAP_BASE-0x800000)/4096 -; jmp .map_low -;.no_PSE: -; mov eax, PG_SW -; mov ecx, HEAP_BASE/4096 -;.map_low: + mov eax, 0x800000+PG_SW + mov ecx, (tmp_page_tab-0x800000)/4096 + jmp .map_low +.no_PSE: + mov eax, PG_SW + mov ecx, tmp_page_tab/4096 +.map_low: mov edi, tmp_page_tab -;@@: ; -; stosd -; add eax, 0x1000 -; dec ecx -; jnz @B +@@: ; + stosd + add eax, 0x1000 + dec ecx + jnz @B mov ecx, [pg_data.kernel_tables-OS_BASE] shl ecx, 10 @@ -120,9 +108,17 @@ proc init_mem jnz .map_kernel_tabs mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE + + mov edi, (sys_pgdir-OS_BASE) + lea esi, [edi+(OS_BASE shr 20)] + movsd + movsd + movsd ret endp + + align 4 proc init_page_map @@ -158,7 +154,7 @@ proc init_page_map shl eax, cl mov [edi], eax add edi, OS_BASE - mov [page_start-OS_BASE], edi; sys_pgmap+384 + mov [page_start-OS_BASE], edi; mov ebx, sys_pgmap add ebx, [pg_data.pagemap_size-OS_BASE] diff --git a/kernel/branches/flat_kernel/kernel.asm b/kernel/branches/flat_kernel/kernel.asm index bc25b26828..a93341dabe 100644 --- a/kernel/branches/flat_kernel/kernel.asm +++ b/kernel/branches/flat_kernel/kernel.asm @@ -225,9 +225,8 @@ high_code: mov dword [sys_pgdir], 0 mov dword [sys_pgdir+4], 0 mov dword [sys_pgdir+8], 0 - mov dword [sys_pgdir+12], 0 - mov eax, sys_pgdir-OS_BASE + mov eax, cr3 mov cr3, eax ; SAVE REAL MODE VARIABLES diff --git a/kernel/branches/flat_kernel/memmap.inc b/kernel/branches/flat_kernel/memmap.inc index 9b2bbe6dcc..69765eee13 100644 --- a/kernel/branches/flat_kernel/memmap.inc +++ b/kernel/branches/flat_kernel/memmap.inc @@ -24,7 +24,11 @@ ; ; Runtime: ; -; 0000 -> 1FFF window_data - 256 entries +; 0x00000000 -> 0x7FBFFFFF application 2Gb-4Mb +; 0x7FC00000 -> 0x7FFFFFFF page tables 4Mb + + +; 0x80000000 -> 1FFF window_data - 256 entries ; ; 0000 dword x start ; 0004 dword y start @@ -119,90 +123,103 @@ ; FFF5 byte 1 do not draw pointer ; FFFF byte do not change task for 1/100 sec. ; -; 10000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb) -; 3DC00 -> 3EBFF stack at boot time (4Kb) -; 3EC00 -> 3F5FF basic text font II -; 3F600 -> 3FFFF basic text font I -; 40000 -> 4FFFF data of retrieved disks and partitions (Mario79) +; 0x80010000 -> 3DBFF kernel, 32-bit run-time code (up to 183 Kb) +; 0x8003DC00 -> 3EBFF stack at boot time (4Kb) +; 0x8003EC00 -> 3F5FF basic text font II +; 0x8003F600 -> 3FFFF basic text font I +; 0x80040000 -> 4FFFF data of retrieved disks and partitions (Mario79) -; 50000 -> 50FFF main page directory -; 50200 -> 5FFFF pages bitmap +; 0x80050000 -> 50FFF main page directory +; 0x80050200 -> 5FFFF pages bitmap -; 60000 -> 7FFFF free (128 Kb) -; 80000 -> 8FFFF additional app info, in 256 byte steps - 256 entries +; 0x80060000 -> 7FFFF free (128 Kb) +; 0x80080000 -> 8FFFF additional app info, in 256 byte steps - 256 entries ; -; 00 11db name of app running -; 10 108db floating point unit save area -; 7f byte 0= no fpu saved , 1= fpu saved to 0x10 -> restore -; 80 dword address of random shaped window area -; 84 byte shape area scale -; 88 dword free -; 8C dword application memory size -; 90 dword window X position save -; 94 dword window Y position save -; 98 dword window X size save -; 9C dword window Y size save -; A0 dword IPC memory start -; A4 dword IPC memory size -; A8 dword event bits: mouse, stack,.. -; AC dword 0 or debugger slot -; B0 dword free -; B4 byte keyboard mode: 0 = keymap, 1 = scancodes -; B8 dword physical address of directory table -; BC dword address of debug event memory -; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7 +; 00 11db name of app running +; 10 dword pointer to fpu save area +; 14 dword event count +; 18 dword user fpu exceptoins handler +; 1c dword user sse exceptions handler +; 20 dword PL0 stack base +; 24 dword user heap base +; 28 dword user heap top +; 2c dword window cursor handle +; 30 dword first event in list +; 34 dword last event in list +; 38 dword first kernel object in list +; 3c dword last kernel object in list ; -; 90000 -> 9FFFF tmp -; A0000 -> AFFFF screen access area -; B0000 -> FFFFF bios rest in peace -area -; 100000 -> 27FFFF diskette image -; 280000 -> 281FFF ramdisk fat -; 282000 -> 283FFF floppy fat +; 40-7F unused ; -; 284000 -> 29FFFF free (112 Kb) +; 80 dword address of random shaped window area +; 84 byte shape area scale +; 88 dword free +; 8C dword application memory size +; 90 dword window X position save +; 94 dword window Y position save +; 98 dword window X size save +; 9C dword window Y size save +; A0 dword IPC memory start +; A4 dword IPC memory size +; A8 dword event bits: mouse, stack,.. +; AC dword 0 or debugger slot +; B0 dword free +; B4 byte keyboard mode: 0 = keymap, 1 = scancodes +; B8 dword physical address of directory table +; BC dword address of debug event memory +; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7 ; -; 2A0000 -> 2B00ff wav device data -; 2C0000 -> 2C3fff button info +; 0x80090000 -> 9FFFF tmp +; 0x800A0000 -> AFFFF screen access area +; 0x800B0000 -> FFFFF bios rest in peace -area +; 0x80100000 -> 27FFFF diskette image +; 0x80280000 -> 281FFF ramdisk fat +; 0x80282000 -> 283FFF floppy fat ; -; 0000 word number of buttons +; 0x80284000 -> 29FFFF free (112 Kb) +; +; 0x802A0000 -> 2B00ff wav device data +; 0x802C0000 -> 2C3fff button info +; +; 0000 word number of buttons ; first button entry at 0x10 -; +0000 word process number -; +0002 word button id number : bits 00-15 -; +0004 word x start -; +0006 word x size -; +0008 word y start -; +000A word y size -; +000C word button id number : bits 16-31 +; +0000 word process number +; +0002 word button id number : bits 00-15 +; +0004 word x start +; +0006 word x size +; +0008 word y start +; +000A word y size +; +000C word button id number : bits 16-31 ; -; 2C4000 -> 2CFFFF free (48Kb) +; 0x802C4000 -> 2CFFFF free (48Kb) ; -; 2D0000 -> 2DFFFF reserved port area +; 0x802D0000 -> 2DFFFF reserved port area ; -; 0000 dword no of port areas reserved -; 0010 dword process id -; dword start port -; dword end port -; dword 0 +; 0000 dword no of port areas reserved +; 0010 dword process id +; dword start port +; dword end port +; dword 0 ; -; 2E0000 -> 2EFFFF irq data area -; 2F0000 -> 2FFFFF low memory save +; 0x802E0000 -> 2EFFFF irq data area +; 0x802F0000 -> 2FFFFF low memory save ; -; 300000 -> 45FFFF background image, max 1,375 M +; 0x80300000 -> 45FFFF background image, max 1,375 M ; -; 460000 -> 5FFFFF display info +; 0x80460000 -> 5FFFFF display info ; -; 600000 -> 6FFFFF hd cache +; 0x80600000 -> 6FFFFF hd cache ; -; 700000 -> 71ffff tcp memory (128 kb) -; 720000 -> 75ffff free (256 kb) +; 0x80700000 -> 71ffff tcp memory (128 kb) +; 0x80720000 -> 75ffff free (256 kb) ; -; 760000 -> 76ffff !vrr driver -; 770000 -> 777fff tcp memory ( 32 kb) +; 0x80760000 -> 76ffff !vrr driver +; 0x80770000 -> 777fff tcp memory ( 32 kb) ; -; 780000 -> 987FFF TSS and IO map for (8192*8)=65536 ports -; (128+8192)*256 = 2129920 = 0x208000 +; 0x80780000 -> 0x80987FFF TSS and IO map for (8192*8)=65536 ports +; (128+8192)*256 = 2129920 = 0x208000 ; -; 988000 -> 98AFFF draw_data - 256 entries +; 0x80988000 -> 0x8098AFFF draw_data - 256 entries ; ; 00 dword draw limit - x start ; 04 dword draw limit - y start @@ -210,15 +227,12 @@ ; 0C dword draw limit - y end ; ; -; 0x0098B000 -> kernel heap -; -; 0x01FFFFFF heap min limit -; 0x7DBFFFFF heap max limit -; 0x7DC00000 -> 0x7FBFFFFF LFB 32Mb -; 0x7DC00000 -> 0x7E3FFFFF application available LFB 8Mb -; 0x7E400000 -> 0x7FBFFFFF kernel LFB part 24 Mb -; 0x7FC00000 -> 0x7FFFFFFF page tables 4Mb -; 0x80000000 -> 0xFFFFFFFF application 2Gb - +; 0x8098B000 -> kernel heap +; 0x81FFFFFF heap min limit +; 0xFDFFFFFF heap max limit + +; 0xFE000000 -> 0xFFFFFFFF LFB 32Mb +; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb +; 0xFE800000 -> 0xFFFFFFFF kernel LFB part 24 Mb