kos-acpi: PAE support

git-svn-id: svn://kolibrios.org@6339 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-03-14 03:45:15 +00:00
parent 22e9386a23
commit 03c7eb4fa9
13 changed files with 243 additions and 198 deletions

View File

@ -223,6 +223,7 @@ TASK_ACTIVATE equ (OS_BASE+0x000FF01)
TMP_STACK_TOP equ 0x006CC00 TMP_STACK_TOP equ 0x006CC00
sys_proc equ (OS_BASE+0x006F000) sys_proc equ (OS_BASE+0x006F000)
sys_pml2 equ 0x0072000
SLOT_BASE equ (OS_BASE+0x0080000) SLOT_BASE equ (OS_BASE+0x0080000)
@ -239,10 +240,10 @@ end virtual
HEAP_BASE equ (OS_BASE+0x0800000) HEAP_BASE equ (OS_BASE+0x0800000)
HEAP_MIN_SIZE equ 0x01000000 HEAP_MIN_SIZE equ 0x01000000
page_tabs equ 0xFDC00000 page_tabs equ 0xFD800000
app_page_tabs equ 0xFDC00000 app_page_tabs equ 0xFD800000
kernel_tabs equ (page_tabs+ (OS_BASE shr 10)) ;0xFDE00000 kernel_tabs equ (page_tabs+ (OS_BASE shr 9)) ;0xFDE00000
master_tab equ (page_tabs+ (page_tabs shr 10)) ;0xFDFF70000 master_tab equ (page_tabs+ (page_tabs shr 9)) ;0xFDFF70000
LFB_BASE equ 0xFE000000 LFB_BASE equ 0xFE000000
@ -281,7 +282,7 @@ PG_PWT equ 0x010
PG_ACCESSED equ 0x020 PG_ACCESSED equ 0x020
PG_DIRTY equ 0x040 PG_DIRTY equ 0x040
PG_PAT equ 0x080 PG_PAT equ 0x080
PG_GLOBAL equ 0x100 PG_GLOBAL equ 0; 0x100
PG_SHARED equ 0x200 PG_SHARED equ 0x200
PG_SWR equ 0x003 ; (PG_WRITE+PG_READ) PG_SWR equ 0x003 ; (PG_WRITE+PG_READ)
@ -428,9 +429,7 @@ struct PROC
ht_free rd 1 ;htab[0] stdin ht_free rd 1 ;htab[0] stdin
ht_next rd 1 ;htab[1] stdout ht_next rd 1 ;htab[1] stdout
htab rd (4096-$)/4 ;htab[2] stderr htab rd (4096-$)/4 ;htab[2] stderr
; htab rd (4096+3072-$)/4 ;htab[2] stderr pdt_0 rd 2048
; workdir rb 1024
pdt_0 rd 1024
ends ends
struct DBG_REGS struct DBG_REGS

View File

@ -594,7 +594,7 @@ proc load_file_umode stdcall, file_name:dword
jz .err_2 jz .err_2
mov edx, [file_size] ;preallocate page memory mov edx, [file_size] ;preallocate page memory
shr eax, 10 shr eax, 9
lea edi, [page_tabs+eax] lea edi, [page_tabs+eax]
add edx, 4095 add edx, 4095
shr edx, 12 shr edx, 12
@ -605,6 +605,8 @@ proc load_file_umode stdcall, file_name:dword
or eax, PG_UWR or eax, PG_UWR
stosd stosd
xor eax, eax
stosd
dec edx dec edx
jnz @B jnz @B
@ -649,14 +651,14 @@ proc load_file_umode stdcall, file_name:dword
test eax, eax test eax, eax
jz .err_2 jz .err_2
shr eax, 10 ; and remap pages. shr eax, 9 ; and remap pages.
mov ecx, [file_size] mov ecx, [file_size]
add ecx, 4095 add ecx, 4095
shr ecx, 12 shr ecx, 12
mov esi, [km_file] mov esi, [km_file]
shr esi, 10 shr esi, 9
add esi, page_tabs add esi, page_tabs
lea edi, [page_tabs+eax] lea edi, [page_tabs+eax]
@ -667,6 +669,8 @@ proc load_file_umode stdcall, file_name:dword
and eax, 0xFFFFF000 and eax, 0xFFFFF000
or eax, PG_UWR or eax, PG_UWR
stosd stosd
xor eax, eax
stosd
loop @B loop @B
stdcall free_kernel_space, [km_file] ; release allocated kernel space stdcall free_kernel_space, [km_file] ; release allocated kernel space
@ -1222,17 +1226,17 @@ proc load_library stdcall, file_name:dword
mov [eax+HDLL.parent], esi mov [eax+HDLL.parent], esi
mov edx, ebx mov edx, ebx
shr edx, 12 shr edx, 12
or dword [page_tabs+(edx-1)*4], DONT_FREE_BLOCK or dword [page_tabs+(edx-1)*8], DONT_FREE_BLOCK
; copy entries of page table from kernel-side image to usermode ; copy entries of page table from kernel-side image to usermode
; use copy-on-write for user-mode image, so map as readonly ; use copy-on-write for user-mode image, so map as readonly
xor edi, edi xor edi, edi
mov ecx, [esi+DLLDESCR.data] mov ecx, [esi+DLLDESCR.data]
shr ecx, 12 shr ecx, 12
.map_pages_loop: .map_pages_loop:
mov eax, [page_tabs+ecx*4] mov eax, [page_tabs+ecx*8]
and eax, not 0xFFF and eax, not 0xFFF
or al, PG_UR or al, PG_UR
xchg eax, [page_tabs+edx*4] xchg eax, [page_tabs+edx*8]
test al, 1 test al, 1
jz @f jz @f
call free_page call free_page

View File

@ -585,7 +585,7 @@ proc init_heap
mov [ebx+PROC.heap_top], eax mov [ebx+PROC.heap_top], eax
sub eax, esi sub eax, esi
shr esi, 10 shr esi, 9
mov ecx, eax mov ecx, eax
sub eax, PAGE_SIZE sub eax, PAGE_SIZE
or ecx, FREE_BLOCK or ecx, FREE_BLOCK
@ -616,7 +616,7 @@ proc user_alloc stdcall, alloc_size:dword
mov ebx, esi mov ebx, esi
shr ebx, 12 shr ebx, 12
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*8]
test al, FREE_BLOCK test al, FREE_BLOCK
jz .test_used jz .test_used
and eax, 0xFFFFF000 and eax, 0xFFFFF000
@ -628,16 +628,16 @@ proc user_alloc stdcall, alloc_size:dword
sub eax, ecx sub eax, ecx
or al, FREE_BLOCK or al, FREE_BLOCK
shr edx, 12 shr edx, 12
mov [page_tabs+edx*4], eax mov [page_tabs+edx*8], eax
@@: @@:
or ecx, USED_BLOCK or ecx, USED_BLOCK
mov [page_tabs+ebx*4], ecx mov [page_tabs+ebx*8], ecx
shr ecx, 12 shr ecx, 12
inc ebx inc ebx
dec ecx dec ecx
jz .no jz .no
@@: @@:
mov dword [page_tabs+ebx*4], 2 mov dword [page_tabs+ebx*8], 2
inc ebx inc ebx
dec ecx dec ecx
jnz @B jnz @B
@ -703,7 +703,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
jae .error jae .error
mov ebx, esi mov ebx, esi
shr ebx, 12 shr ebx, 12
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*8]
mov ecx, eax mov ecx, eax
and ecx, 0xFFFFF000 and ecx, 0xFFFFF000
add ecx, esi add ecx, esi
@ -740,7 +740,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
sub eax, esi sub eax, esi
jz .nofirst jz .nofirst
or al, FREE_BLOCK or al, FREE_BLOCK
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
.nofirst: .nofirst:
mov eax, [alloc_size] mov eax, [alloc_size]
add eax, 0x1FFF add eax, 0x1FFF
@ -749,13 +749,13 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
add edx, eax add edx, eax
shr ebx, 12 shr ebx, 12
or al, USED_BLOCK or al, USED_BLOCK
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
shr eax, 12 shr eax, 12
dec eax dec eax
jz .second_nofill jz .second_nofill
inc ebx inc ebx
.fill: .fill:
mov dword [page_tabs+ebx*4], 2 mov dword [page_tabs+ebx*8], 2
inc ebx inc ebx
dec eax dec eax
jnz .fill jnz .fill
@ -764,7 +764,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
sub ecx, edx sub ecx, edx
jz .nothird jz .nothird
or cl, FREE_BLOCK or cl, FREE_BLOCK
mov [page_tabs+ebx*4], ecx mov [page_tabs+ebx*8], ecx
.nothird: .nothird:
mov edx, [current_process] mov edx, [current_process]
@ -801,7 +801,7 @@ proc user_free stdcall, base:dword
xor ebx, ebx xor ebx, ebx
shr esi, 12 shr esi, 12
mov eax, [page_tabs+(esi-1)*4] mov eax, [page_tabs+(esi-1)*8]
test al, USED_BLOCK test al, USED_BLOCK
jz .cantfree jz .cantfree
test al, DONT_FREE_BLOCK test al, DONT_FREE_BLOCK
@ -810,14 +810,14 @@ proc user_free stdcall, base:dword
and eax, not 4095 and eax, not 4095
mov ecx, eax mov ecx, eax
or al, FREE_BLOCK or al, FREE_BLOCK
mov [page_tabs+(esi-1)*4], eax mov [page_tabs+(esi-1)*8], eax
sub ecx, 4096 sub ecx, 4096
mov ebx, ecx mov ebx, ecx
shr ecx, 12 shr ecx, 12
jz .released jz .released
.release: .release:
xor eax, eax xor eax, eax
xchg eax, [page_tabs+esi*4] xchg eax, [page_tabs+esi*8]
test al, 1 test al, 1
jz @F jz @F
test eax, PG_SHARED test eax, PG_SHARED
@ -877,7 +877,7 @@ proc user_unmap stdcall, base:dword, offset:dword, size:dword
js .error js .error
shr ebx, 12 ; chek block attributes shr ebx, 12 ; chek block attributes
lea ebx, [page_tabs+ebx*4] lea ebx, [page_tabs+ebx*8]
mov eax, [ebx-4] ; block attributes mov eax, [ebx-4] ; block attributes
test al, USED_BLOCK test al, USED_BLOCK
jz .error jz .error
@ -885,15 +885,15 @@ proc user_unmap stdcall, base:dword, offset:dword, size:dword
jnz .error jnz .error
shr edx, 12 shr edx, 12
lea edx, [page_tabs+edx*4] ; unmap offset lea edx, [page_tabs+edx*8] ; unmap offset
mov ecx, [size] mov ecx, [size]
add ecx, 4095 add ecx, 4095
shr ecx, 12 ; unmap size in pages shr ecx, 12 ; unmap size in pages
shr eax, 12 ; block size + 1 page shr eax, 12 ; block size + 1 page
lea ebx, [ebx+eax*4-4] ; block end ptr lea ebx, [ebx+eax*8-8] ; block end ptr
lea eax, [edx+ecx*4] ; unmap end ptr lea eax, [edx+ecx*8] ; unmap end ptr
cmp eax, ebx ; check for overflow cmp eax, ebx ; check for overflow
ja .error ja .error
@ -914,7 +914,7 @@ proc user_unmap stdcall, base:dword, offset:dword, size:dword
call free_page ; empty c-o-w page instead this ? call free_page ; empty c-o-w page instead this ?
@@: @@:
add ebx, 4096 add ebx, 4096
add edx, 4 add edx, 8
dec ecx dec ecx
jnz .unmap jnz .unmap
@ -935,7 +935,7 @@ user_normalize:
shr esi, 12 shr esi, 12
shr edi, 12 shr edi, 12
@@: @@:
mov eax, [page_tabs+esi*4] mov eax, [page_tabs+esi*8]
test al, USED_BLOCK test al, USED_BLOCK
jz .test_free jz .test_free
shr eax, 12 shr eax, 12
@ -950,7 +950,7 @@ user_normalize:
cmp edx, edi cmp edx, edi
jae .exit jae .exit
mov ebx, [page_tabs+edx*4] mov ebx, [page_tabs+edx*8]
test bl, USED_BLOCK test bl, USED_BLOCK
jz .next_free jz .next_free
@ -961,11 +961,11 @@ user_normalize:
.next_free: .next_free:
test bl, FREE_BLOCK test bl, FREE_BLOCK
jz .err jz .err
and dword [page_tabs+edx*4], 0 and dword [page_tabs+edx*8], 0
add eax, ebx add eax, ebx
and eax, not 4095 and eax, not 4095
or eax, FREE_BLOCK or eax, FREE_BLOCK
mov [page_tabs+esi*4], eax mov [page_tabs+esi*8], eax
jmp @B jmp @B
.exit: .exit:
xor eax, eax xor eax, eax
@ -995,7 +995,7 @@ user_realloc:
lea ecx, [eax - 0x1000] lea ecx, [eax - 0x1000]
shr ecx, 12 shr ecx, 12
mov edx, [page_tabs+ecx*4] mov edx, [page_tabs+ecx*8]
test dl, USED_BLOCK test dl, USED_BLOCK
jnz @f jnz @f
; attempt to realloc invalid pointer ; attempt to realloc invalid pointer
@ -1024,7 +1024,7 @@ user_realloc:
jz .release_done jz .release_done
dec edx dec edx
xor eax, eax xor eax, eax
xchg eax, [page_tabs+edx*4] xchg eax, [page_tabs+edx*8]
test al, 1 test al, 1
jz .loop jz .loop
call free_page call free_page
@ -1036,14 +1036,14 @@ user_realloc:
sub ebx, ecx sub ebx, ecx
cmp ebx, 1 cmp ebx, 1
jnz .nofreeall jnz .nofreeall
mov eax, [page_tabs+ecx*4] mov eax, [page_tabs+ecx*8]
and eax, not 0xFFF and eax, not 0xFFF
mov edx, [current_process] mov edx, [current_process]
mov ebx, [edx+PROC.mem_used] mov ebx, [edx+PROC.mem_used]
sub ebx, eax sub ebx, eax
add ebx, 0x1000 add ebx, 0x1000
or al, FREE_BLOCK or al, FREE_BLOCK
mov [page_tabs+ecx*4], eax mov [page_tabs+ecx*8], eax
push esi edi push esi edi
mov esi, [edx+PROC.heap_base] mov esi, [edx+PROC.heap_base]
mov edi, [edx+PROC.heap_top] mov edi, [edx+PROC.heap_top]
@ -1055,7 +1055,7 @@ user_realloc:
sub edx, ecx sub edx, ecx
shl ebx, 12 shl ebx, 12
or ebx, USED_BLOCK or ebx, USED_BLOCK
xchg [page_tabs+ecx*4], ebx xchg [page_tabs+ecx*8], ebx
shr ebx, 12 shr ebx, 12
sub ebx, edx sub ebx, edx
push ebx ecx edx push ebx ecx edx
@ -1079,10 +1079,10 @@ user_realloc:
@@: @@:
cmp edx, esi cmp edx, esi
jae .merge_done jae .merge_done
mov eax, [page_tabs+edx*4] mov eax, [page_tabs+edx*8]
test al, USED_BLOCK test al, USED_BLOCK
jnz .merge_done jnz .merge_done
and dword [page_tabs+edx*4], 0 and dword [page_tabs+edx*8], 0
shr eax, 12 shr eax, 12
add edx, eax add edx, eax
shl eax, 12 shl eax, 12
@ -1091,7 +1091,7 @@ user_realloc:
.merge_done: .merge_done:
pop esi pop esi
or ebx, FREE_BLOCK or ebx, FREE_BLOCK
mov [page_tabs+ecx*4], ebx mov [page_tabs+ecx*8], ebx
.ret: .ret:
mov ecx, [current_process] mov ecx, [current_process]
lea ecx, [ecx+PROC.heap_lock] lea ecx, [ecx+PROC.heap_lock]
@ -1106,7 +1106,7 @@ user_realloc:
shr eax, 12 shr eax, 12
cmp edx, eax cmp edx, eax
jae .cant_inplace jae .cant_inplace
mov eax, [page_tabs+edx*4] mov eax, [page_tabs+edx*8]
test al, FREE_BLOCK test al, FREE_BLOCK
jz .cant_inplace jz .cant_inplace
shr eax, 12 shr eax, 12
@ -1116,18 +1116,18 @@ user_realloc:
jz @f jz @f
shl eax, 12 shl eax, 12
or al, FREE_BLOCK or al, FREE_BLOCK
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
@@: @@:
mov eax, ebx mov eax, ebx
sub eax, ecx sub eax, ecx
shl eax, 12 shl eax, 12
or al, USED_BLOCK or al, USED_BLOCK
mov [page_tabs+ecx*4], eax mov [page_tabs+ecx*8], eax
lea eax, [ecx+1] lea eax, [ecx+1]
shl eax, 12 shl eax, 12
push eax push eax
push edi push edi
lea edi, [page_tabs+edx*4] lea edi, [page_tabs+edx*8]
mov eax, 2 mov eax, 2
sub ebx, edx sub ebx, edx
mov ecx, ebx mov ecx, ebx
@ -1155,7 +1155,7 @@ user_realloc:
.find_place: .find_place:
cmp esi, edi cmp esi, edi
jae .place_not_found jae .place_not_found
mov eax, [page_tabs+esi*4] mov eax, [page_tabs+esi*8]
test al, FREE_BLOCK test al, FREE_BLOCK
jz .next_place jz .next_place
shr eax, 12 shr eax, 12
@ -1177,30 +1177,30 @@ user_realloc:
add esi, ebx add esi, ebx
shl eax, 12 shl eax, 12
or al, FREE_BLOCK or al, FREE_BLOCK
mov [page_tabs+esi*4], eax mov [page_tabs+esi*8], eax
pop esi pop esi
@@: @@:
mov eax, ebx mov eax, ebx
shl eax, 12 shl eax, 12
or al, USED_BLOCK or al, USED_BLOCK
mov [page_tabs+esi*4], eax mov [page_tabs+esi*8], eax
inc esi inc esi
mov eax, esi mov eax, esi
shl eax, 12 shl eax, 12
push eax push eax
mov eax, [page_tabs+ecx*4] mov eax, [page_tabs+ecx*8]
and eax, not 0xFFF and eax, not 0xFFF
or al, FREE_BLOCK or al, FREE_BLOCK
sub edx, ecx sub edx, ecx
mov [page_tabs+ecx*4], eax mov [page_tabs+ecx*8], eax
inc ecx inc ecx
dec ebx dec ebx
dec edx dec edx
jz .no jz .no
@@: @@:
xor eax, eax xor eax, eax
xchg eax, [page_tabs+ecx*4] xchg eax, [page_tabs+ecx*8]
mov [page_tabs+esi*4], eax mov [page_tabs+esi*8], eax
mov eax, ecx mov eax, ecx
shl eax, 12 shl eax, 12
invlpg [eax] invlpg [eax]
@ -1216,7 +1216,7 @@ user_realloc:
add [edx+PROC.mem_used], ebx add [edx+PROC.mem_used], ebx
pop ebx pop ebx
@@: @@:
mov dword [page_tabs+esi*4], 2 mov dword [page_tabs+esi*8], 2
inc esi inc esi
dec ebx dec ebx
jnz @b jnz @b
@ -1441,10 +1441,10 @@ align 4
mov [size], ecx mov [size], ecx
shr ecx, 12 shr ecx, 12
shr eax, 10 shr eax, 9
mov esi, [esi+SMEM.base] mov esi, [esi+SMEM.base]
shr esi, 10 shr esi, 9
lea edi, [page_tabs+eax] lea edi, [page_tabs+eax]
add esi, page_tabs add esi, page_tabs
@ -1457,6 +1457,7 @@ align 4
and eax, 0xFFFFF000 and eax, 0xFFFFF000
or eax, edx or eax, edx
stosd stosd
movsd
loop @B loop @B
xor edx, edx xor edx, edx

View File

@ -131,7 +131,7 @@ map_page:
and eax, [pte_valid_mask] and eax, [pte_valid_mask]
mov ebx, [esp+8] ; lin_addr mov ebx, [esp+8] ; lin_addr
shr ebx, 12 shr ebx, 12
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
mov eax, [esp+8] ; lin_addr mov eax, [esp+8] ; lin_addr
pop ebx pop ebx
invlpg [eax] invlpg [eax]
@ -194,7 +194,8 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
or edx, [flags] or edx, [flags]
and edx, [pte_valid_mask] and edx, [pte_valid_mask]
@@: @@:
mov [page_tabs+eax*4], edx mov [page_tabs+eax*8], edx
mov [page_tabs+eax*8+4], dword 0
invlpg [ebx] invlpg [ebx]
inc eax inc eax
add ebx, edi add ebx, edi
@ -232,12 +233,14 @@ commit_pages:
and eax, [pte_valid_mask ] and eax, [pte_valid_mask ]
mov edi, ebx mov edi, ebx
shr edi, 12 shr edi, 12
lea edi, [page_tabs+edi*4] lea edi, [page_tabs+edi*8]
@@: @@:
stosd mov [edi], eax
mov [edi+4], dword 0
invlpg [ebx] invlpg [ebx]
add eax, 0x1000 add eax, 0x1000
add ebx, 0x1000 add ebx, 0x1000
add edi, 8
loop @B loop @B
pop edi pop edi
@ -264,7 +267,7 @@ release_pages:
mov edi, eax mov edi, eax
shr esi, 12 shr esi, 12
lea esi, [page_tabs+esi*4] lea esi, [page_tabs+esi*8]
push ecx push ecx
mov ecx, pg_data.mutex mov ecx, pg_data.mutex
@ -295,7 +298,7 @@ release_pages:
mov ebx, eax mov ebx, eax
.next: .next:
add edi, 0x1000 add edi, 0x1000
add esi, 4 add esi, 8
loop @B loop @B
mov [pg_data.pages_free], ebp mov [pg_data.pages_free], ebp
@ -320,11 +323,12 @@ unmap_pages:
mov edi, eax mov edi, eax
mov edx, eax mov edx, eax
shr edi, 10 shr edi, 9
add edi, page_tabs add edi, page_tabs
xor eax, eax xor eax, eax
@@: @@:
stosd
stosd stosd
invlpg [edx] invlpg [edx]
add edx, 0x1000 add edx, 0x1000
@ -338,13 +342,14 @@ align 4
proc map_page_table stdcall, lin_addr:dword, phis_addr:dword proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
push ebx push ebx
mov ebx, [lin_addr] mov ebx, [lin_addr]
shr ebx, 22 shr ebx, 21
mov eax, [phis_addr] mov eax, [phis_addr]
and eax, not 0xFFF and eax, not 0xFFF
or eax, PG_UWR or eax, PG_UWR
mov dword [master_tab+ebx*4], eax mov [master_tab+ebx*8], eax
mov [master_tab+ebx*8+4], dword 0
mov eax, [lin_addr] mov eax, [lin_addr]
shr eax, 10 shr eax, 9
add eax, page_tabs add eax, page_tabs
invlpg [eax] invlpg [eax]
pop ebx pop ebx
@ -437,11 +442,11 @@ proc new_mem_resize stdcall, new_size:dword
mov ecx, pg_data.mutex mov ecx, pg_data.mutex
call mutex_lock call mutex_lock
@@: @@:
mov eax, [app_page_tabs+edi*4] mov eax, [app_page_tabs+edi*8]
test eax, 1 test eax, 1
jz .next jz .next
mov dword [app_page_tabs+edi*4], 0 mov dword [app_page_tabs+edi*8], 0
invlpg [ebx] invlpg [ebx]
call free_page call free_page
@ -476,10 +481,10 @@ proc new_mem_resize stdcall, new_size:dword
push esi ;new size push esi ;new size
push edi ;old size push edi ;old size
add edi, 0x3FFFFF add edi, 0x1FFFFF
and edi, not(0x3FFFFF) and edi, not(0x1FFFFF)
add esi, 0x3FFFFF add esi, 0x1FFFFF
and esi, not(0x3FFFFF) and esi, not(0x1FFFFF)
cmp edi, esi cmp edi, esi
jae .grow jae .grow
@ -491,7 +496,7 @@ proc new_mem_resize stdcall, new_size:dword
stdcall map_page_table, edi, eax stdcall map_page_table, edi, eax
push edi push edi
shr edi, 10 shr edi, 9
add edi, page_tabs add edi, page_tabs
mov ecx, 1024 mov ecx, 1024
xor eax, eax xor eax, eax
@ -499,7 +504,7 @@ proc new_mem_resize stdcall, new_size:dword
rep stosd rep stosd
pop edi pop edi
add edi, 0x00400000 add edi, 0x00200000
cmp edi, esi cmp edi, esi
jb @B jb @B
.grow: .grow:
@ -546,7 +551,7 @@ get_pg_addr:
cmp eax, 0x400000 cmp eax, 0x400000
jb @f jb @f
shr eax, 12 shr eax, 12
mov eax, [page_tabs+(eax+(OS_BASE shr 12))*4] mov eax, [page_tabs+(eax+(OS_BASE shr 12))*8]
@@: @@:
and eax, 0xFFFFF000 and eax, 0xFFFFF000
ret ret
@ -588,13 +593,13 @@ proc page_fault_handler
shr ebx, 12 shr ebx, 12
mov ecx, ebx mov ecx, ebx
shr ecx, 10 shr ecx, 9
mov edx, [master_tab+ecx*4] mov edx, [master_tab+ecx*8]
test edx, PG_READ test edx, PG_READ
jz .fail ;таблица страниц не создана jz .fail ;таблица страниц не создана
;неверный адрес в программе ;неверный адрес в программе
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*8]
test eax, 2 test eax, 2
jz .fail ;адрес не зарезервирован для ; jz .fail ;адрес не зарезервирован для ;
;использования. Ошибка ;использования. Ошибка
@ -703,7 +708,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
count dd ? count dd ?
process dd ? process dd ?
endl endl
xchg bx, bx
mov [count], 0 mov [count], 0
cmp [buf_size], 0 cmp [buf_size], 0
jz .exit jz .exit
@ -829,7 +834,7 @@ endp
; out: CF cleared <=> failed ; out: CF cleared <=> failed
; destroys: only eax ; destroys: only eax
proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
mov eax, [esi+edx*4] mov eax, [esi+edx*8]
test al, PG_READ test al, PG_READ
jz .not_present jz .not_present
test al, PG_WRITE test al, PG_WRITE
@ -851,7 +856,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
test eax, eax test eax, eax
jz .fail jz .fail
or al, PG_UWR or al, PG_UWR
mov [esi+edx*4], eax mov [esi+edx*8], eax
jmp .map jmp .map
.resolve_readonly: .resolve_readonly:
; readonly page, probably copy-on-write ; readonly page, probably copy-on-write
@ -893,7 +898,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
test eax, eax test eax, eax
jz .no_hdll jz .no_hdll
or al, PG_UWR or al, PG_UWR
mov [esi+edx*4], eax mov [esi+edx*8], eax
stdcall map_page, edi, eax, [req_access] stdcall map_page, edi, eax, [req_access]
push esi edi push esi edi
mov esi, ebx mov esi, ebx
@ -1024,21 +1029,24 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov edx, ebx mov edx, ebx
shr ebx, 12 shr ebx, 12
xor eax, eax xor eax, eax
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
mov [page_tabs+ebx*8+4], eax
invlpg [edx] invlpg [edx]
mov ebx, [ipc_pdir] mov ebx, [ipc_pdir]
mov edx, ebx mov edx, ebx
shr ebx, 12 shr ebx, 12
xor eax, eax xor eax, eax
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
mov [page_tabs+ebx*8+4], eax
invlpg [edx] invlpg [edx]
mov ebx, [ipc_ptab] mov ebx, [ipc_ptab]
mov edx, ebx mov edx, ebx
shr ebx, 12 shr ebx, 12
xor eax, eax xor eax, eax
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
mov [page_tabs+ebx*8+4], eax
invlpg [edx] invlpg [edx]
mov eax, [dst_slot] mov eax, [dst_slot]

View File

@ -56,9 +56,6 @@ change_task:
uglobal uglobal
align 4 align 4
; far_jump:
; .offs dd ?
; .sel dw ?
context_counter dd 0 ;noname & halyavin context_counter dd 0 ;noname & halyavin
next_usage_update dd 0 next_usage_update dd 0
timer_ticks dd 0 timer_ticks dd 0
@ -103,15 +100,29 @@ do_change_task:
mov esp, [ebx+APPDATA.saved_esp] mov esp, [ebx+APPDATA.saved_esp]
; set new thread io-map ; set new thread io-map
mov eax, [ebx+APPDATA.io_map] mov eax, [ebx+APPDATA.io_map]
mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)], eax ; mov dword [page_tabs+((tss._io_map_0 and -4096) shr 9)], eax
mov eax, [ebx+APPDATA.io_map+4] mov eax, [ebx+APPDATA.io_map+4]
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], eax ; mov dword [page_tabs+((tss._io_map_1 and -4096) shr 9)], eax
; set new thread memory-map ; set new thread memory-map
mov eax, [ebx+APPDATA.process] mov eax, [ebx+APPDATA.process]
cmp eax, [current_process] cmp eax, [current_process]
je @f je @f
mov [current_process], eax mov [current_process], eax
mov eax, [eax+PROC.pdt_0_phys]
mov ecx, [eax+PROC.pdt_0_phys]
mov eax, [eax+PROC.pdt_1_phys]
or ecx, PG_READ
or eax, PG_READ
mov [sys_pml3], ecx
mov [sys_pml3+8], eax
or ecx, PG_SWR
or eax, PG_SWR
mov [sys_pml2+OS_BASE+8192-20*8], ecx
mov [sys_pml2+OS_BASE+8192-19*8], eax
mov eax, sys_pml3-OS_BASE
mov cr3, eax mov cr3, eax
@@: @@:
; set tss.esp0 ; set tss.esp0

View File

@ -306,13 +306,13 @@ show_error_parameters:
push ebx push ebx
shr ebx, 12 shr ebx, 12
mov ecx, ebx mov ecx, ebx
shr ecx, 10 shr ecx, 9
mov edx, [master_tab+ecx*4] mov edx, [master_tab+ecx*8]
test edx, PG_READ test edx, PG_READ
jz .fail ;page table is not created jz .fail ;page table is not created
;incorrect address in the program ;incorrect address in the program
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*8]
test eax, 2 test eax, 2
jz .fail ;address not reserved for use. error jz .fail ;address not reserved for use. error

View File

@ -337,11 +337,11 @@ proc create_process stdcall, app_size:dword
mov [process], eax mov [process], eax
mov eax, [app_size] mov eax, [app_size]
add eax, 0x3FFFFF add eax, 0x1FFFFF
shr eax, 22 shr eax, 21
mov [app_tabs], eax mov [app_tabs], eax
stdcall kernel_alloc, 0x2000 stdcall kernel_alloc, 0x3000
test eax, eax test eax, eax
jz .fail jz .fail
mov [process], eax mov [process], eax
@ -371,20 +371,15 @@ proc create_process stdcall, app_size:dword
mov eax, edi mov eax, edi
call get_pg_addr call get_pg_addr
mov [edi-4096+PROC.pdt_0_phys], eax mov [edi-4096+PROC.pdt_0_phys], eax
lea eax, [edi+4096]
call get_pg_addr
mov [edi-4096+PROC.pdt_1_phys], eax
mov ecx, (OS_BASE shr 20)/4 mov ecx, 2048
xor eax, eax xor eax, eax
rep stosd rep stosd
mov ecx, (OS_BASE shr 20)/4 lea edx, [edi-8192]
mov esi, sys_proc+PROC.pdt_0+(OS_BASE shr 20)
rep movsd
mov eax, [edi-8192+PROC.pdt_0_phys]
or eax, PG_SWR
mov [edi-4096+(page_tabs shr 20)], eax
lea edx, [edi-4096]
mov esi, [app_tabs] mov esi, [app_tabs]
.alloc_page_dir: .alloc_page_dir:
@ -393,6 +388,7 @@ proc create_process stdcall, app_size:dword
jz .fail jz .fail
or eax, PG_UWR or eax, PG_UWR
mov [edx], eax mov [edx], eax
mov [edx+4], dword 0
mov edi, [tmp_task_ptab] mov edi, [tmp_task_ptab]
stdcall map_page, edi, eax, PG_SWR stdcall map_page, edi, eax, PG_SWR
@ -400,7 +396,7 @@ proc create_process stdcall, app_size:dword
xor eax, eax xor eax, eax
rep stosd rep stosd
add edx, 4 add edx, 8
dec esi dec esi
jnz .alloc_page_dir jnz .alloc_page_dir
@ -430,7 +426,7 @@ proc destroy_page_table stdcall, pg_tab:dword
push esi push esi
mov esi, [pg_tab] mov esi, [pg_tab]
mov ecx, 1024 mov ecx, 512
.free: .free:
mov eax, [esi] mov eax, [esi]
test eax, 1 test eax, 1
@ -441,7 +437,7 @@ proc destroy_page_table stdcall, pg_tab:dword
jnz .next ;skip shared pages jnz .next ;skip shared pages
call free_page call free_page
.next: .next:
add esi, 4 add esi, 8
dec ecx dec ecx
jnz .free jnz .free
pop esi pop esi
@ -467,7 +463,7 @@ align 4
mov esi, [esp] mov esi, [esp]
add esi, PROC.pdt_0 add esi, PROC.pdt_0
mov edi, (0x80000000 shr 20)/4 mov edi, 1024
.destroy: .destroy:
mov eax, [esi] mov eax, [esi]
test eax, 1 test eax, 1
@ -478,7 +474,7 @@ align 4
mov eax, [esi] mov eax, [esi]
call free_page call free_page
.next: .next:
add esi, 4 add esi, 8
dec edi dec edi
jnz .destroy jnz .destroy
@ -808,7 +804,7 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
shr ecx, 12 ; image pages shr ecx, 12 ; image pages
mov edi, page_tabs mov edi, page_tabs
shr esi, 10 shr esi, 9
add esi, edi add esi, edi
.map_image: .map_image:
@ -816,6 +812,7 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
and eax, -4096 and eax, -4096
or eax, PG_UWR or eax, PG_UWR
stosd stosd
movsd
dec edx dec edx
loop .map_image loop .map_image
@ -828,6 +825,8 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
or eax, PG_UWR or eax, PG_UWR
stosd stosd
xor eax, eax
stosd
dec edx dec edx
jnz .map_bss jnz .map_bss
@ -867,7 +866,41 @@ common_app_entry:
add esi, ecx add esi, ecx
jmp .check_cmdline jmp .check_cmdline
.copy_full_path:
mov esi, [current_slot]
mov esi, [esi+APPDATA.cur_dir]
mov ebx, 1023
mov al, '/'
stosb
.copy_path:
dec ebx
jz .finish_path
lodsb
stosb
test al, al
jnz .copy_path
mov byte [edi-1], '/'
cmp ecx, ebx
jbe @F
mov ecx, ebx
@@:
lea esi, [ebp+sizeof.APP_HDR]
xor eax, eax
rep movsb
stosb
jmp .check_cmdline
.finish_path:
xor eax, eax
stosb
jmp .check_cmdline
.copy_filename: .copy_filename:
cmp byte [esi], '/'
jne .copy_full_path
rep movsb rep movsb
stosb stosb
@ -914,8 +947,8 @@ common_app_entry:
mov fs, dx mov fs, dx
.cleanup: .cleanup:
stdcall free_kernel_space, [ebp+APP_HDR.img_base] ; stdcall free_kernel_space, [ebp+APP_HDR.img_base]
stdcall kernel_free, ebp ; stdcall kernel_free, ebp
.exit: .exit:
popad popad
iretd iretd

View File

@ -107,8 +107,10 @@ v86_create:
add eax, edx add eax, edx
loop @b loop @b
mov eax, [sys_proc+PROC.pdt_0_phys] mov eax, sys_proc
mov cr3, eax push ebx
; call set_cr3
pop ebx
popfd popfd
pop edi pop edi

View File

@ -333,7 +333,10 @@ gdte:
diff16 "end of .data segment",0,$ diff16 "end of .data segment",0,$
align 16 align 32
sys_pml3 rd 4*2
cur_saved_data: cur_saved_data:
rb 4096 rb 4096
fpu_data: fpu_data:

View File

@ -124,29 +124,29 @@ proc init_mem
mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096 mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096
.set: .set:
mov [pg_data.kernel_pages-OS_BASE], edx mov [pg_data.kernel_pages-OS_BASE], edx
shr edx, 10 shr edx, 9
mov [pg_data.kernel_tables-OS_BASE], edx mov [pg_data.kernel_tables-OS_BASE], edx
xor eax, eax mov edx, sys_pml2
mov edi, sys_proc-OS_BASE mov edi, 0x0070000 ;sys_proc+PROC.pdt_0-OS_BASE
mov ecx, 8192/4
cld
rep stosd
mov edx, (sys_proc-OS_BASE+PROC.pdt_0)+ 0x800; (OS_BASE shr 20)
bt [cpu_caps-OS_BASE], CAPS_PSE bt [cpu_caps-OS_BASE], CAPS_PSE
jnc .no_PSE jnc .no_PSE
mov ebx, cr4 mov ebx, cr4
or ebx, CR4_PSE or ebx, CR4_PSE+CR4_PAE
mov eax, PDE_LARGE+PG_SWR mov eax, PDE_LARGE+PG_SWR
mov cr4, ebx mov cr4, ebx
dec [pg_data.kernel_tables-OS_BASE] dec [pg_data.kernel_tables-OS_BASE]
mov [edx], eax mov [edx], eax
add edx, 4 mov [edi], eax
add edx, 8
add edi, 8
add eax, 0x200000
mov [edx], eax
mov [edi], eax
add edx, 8
mov edi, [tmp_page_tabs]
jmp .map_kernel_heap ; new kernel fits to the first 4Mb - nothing to do with ".map_low" jmp .map_kernel_heap ; new kernel fits to the first 4Mb - nothing to do with ".map_low"
.no_PSE: .no_PSE:
mov eax, PG_SWR mov eax, PG_SWR
@ -161,28 +161,28 @@ proc init_mem
jnz @B jnz @B
.map_kernel_heap: .map_kernel_heap:
mov ecx, [pg_data.kernel_tables-OS_BASE]
shl ecx, 10
xor eax, eax
rep stosd
mov ecx, [pg_data.kernel_tables-OS_BASE] mov ecx, [pg_data.kernel_tables-OS_BASE]
mov eax, [tmp_page_tabs] mov eax, [tmp_page_tabs]
or eax, PG_SWR or eax, PG_SWR
mov edi, edx
.map_kernel_tabs: .map_kernel_tabs:
stosd mov [edx], eax
add eax, 0x1000 add eax, 0x1000
add edx, 8
dec ecx dec ecx
jnz .map_kernel_tabs jnz .map_kernel_tabs
mov dword [sys_proc-OS_BASE+PROC.pdt_0+(page_tabs shr 20)], sys_proc+PROC.pdt_0+PG_SWR-OS_BASE mov dword [sys_pml2+8192-20*8], sys_proc+PROC.pdt_0+PG_SWR-OS_BASE
mov dword [sys_pml2+8192-19*8], sys_proc+PROC.pdt_0+4096+PG_SWR-OS_BASE
mov dword [sys_pml2+8192-18*8], sys_pml2+PG_SWR
mov dword [sys_pml2+8192-17*8], sys_pml2+4096+PG_SWR
mov [sys_pml3-OS_BASE], 0x0070000+PG_READ ;sys_proc+PROC.pdt_0+PG_UWR-OS_BASE
mov [sys_pml3+8-OS_BASE], 0x0071000+PG_READ ;sys_proc+PROC.pdt_0+4096+PG_UWR-OS_BASE
mov [sys_pml3+16-OS_BASE],0x0072000+PG_READ ;sys_pml2+PG_SWR
mov [sys_pml3+24-OS_BASE],0x0073000+PG_READ ;sys_pml2+4096+PG_SWR
mov edi, (sys_proc+PROC.pdt_0-OS_BASE)
lea esi, [edi+(OS_BASE shr 20)]
movsd
movsd
ret ret
endp endp

View File

@ -292,7 +292,7 @@ B32:
; ENABLE PAGING ; ENABLE PAGING
mov eax, sys_proc-OS_BASE+PROC.pdt_0 mov eax, sys_pml3-OS_BASE
mov cr3, eax mov cr3, eax
mov eax, cr0 mov eax, cr0
@ -358,7 +358,8 @@ high_code:
bt [cpu_caps], CAPS_PGE bt [cpu_caps], CAPS_PGE
jnc @F jnc @F
or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax or [sys_pml2], eax
or [sys_pml2+8], eax
or ebx, eax or ebx, eax
mov eax, cr4 mov eax, cr4
@ -369,7 +370,7 @@ high_code:
xor eax, eax xor eax, eax
mov dword [sys_proc+PROC.pdt_0], eax mov dword [sys_proc+PROC.pdt_0], eax
mov dword [sys_proc+PROC.pdt_0+4], eax mov dword [sys_proc+PROC.pdt_0+8], eax
mov eax, cr3 mov eax, cr3
mov cr3, eax ; flush TLB mov cr3, eax ; flush TLB
@ -649,6 +650,7 @@ high_code:
jbe @B jbe @B
mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0
mov [sys_proc+PROC.pdt_1_phys], sys_proc-OS_BASE+PROC.pdt_0+4096
mov eax, -1 mov eax, -1
mov edi, thr_slot_map+4 mov edi, thr_slot_map+4
@ -761,7 +763,7 @@ endg
mov esi, boot_v86machine mov esi, boot_v86machine
call boot_log call boot_log
; Initialize system V86 machine ; Initialize system V86 machine
call init_sys_v86 ; call init_sys_v86
mov esi, boot_inittimer mov esi, boot_inittimer
call boot_log call boot_log
@ -859,20 +861,8 @@ include 'detect/dev_fd.inc'
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
include 'detect/init_ata.inc' include 'detect/init_ata.inc'
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
if 0
mov ax, [OS_BASE+0x10000+bx_from_load]
cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba}
je no_lib_load
mov esi, boot_loadlibs
call boot_log
; LOADING LIBRARES
stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files)
call load_file_parse_table ; prepare file parse table
call set_kernel_conf ; configure devices and gui
no_lib_load:
end if
cli
; Display APIC status ; Display APIC status
mov esi, boot_APIC_found mov esi, boot_APIC_found
cmp [irq_mode], IRQ_APIC cmp [irq_mode], IRQ_APIC
@ -902,16 +892,9 @@ end if
inc edi inc edi
call display_number_force call display_number_force
; BUILD SCHEDULER
; call build_scheduler; sys32.inc
; mov esi, boot_devices
; call boot_log
include "detect/vortex86.inc" ; Vortex86 SoC detection code include "detect/vortex86.inc" ; Vortex86 SoC detection code
stdcall load_pe_driver, szVidintel, 0 ; stdcall load_pe_driver, szVidintel, 0
call usb_init call usb_init
@ -1115,7 +1098,7 @@ end if
sti sti
call mtrr_validate ; call mtrr_validate
jmp osloop jmp osloop
@ -2254,7 +2237,7 @@ sysfn_terminate2:
cli cli
call sysfn_terminate call sysfn_terminate
call unlock_application_table call unlock_application_table
sti ; sti
and dword [esp+32], 0 and dword [esp+32], 0
ret ret
.not_found: .not_found:
@ -2847,7 +2830,7 @@ align 4
jz .nomem jz .nomem
mov ebx, eax mov ebx, eax
shr ebx, 12 shr ebx, 12
or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK or dword [page_tabs+(ebx-1)*8], DONT_FREE_BLOCK
mov esi, [img_background] mov esi, [img_background]
shr esi, 12 shr esi, 12
mov ecx, [mem_BACKGROUND] mov ecx, [mem_BACKGROUND]
@ -2856,16 +2839,16 @@ align 4
;-------------------------------------- ;--------------------------------------
align 4 align 4
.z: .z:
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*8]
test al, 1 test al, 1
jz @f jz @f
call free_page call free_page
;-------------------------------------- ;--------------------------------------
align 4 align 4
@@: @@:
mov eax, [page_tabs+esi*4] mov eax, [page_tabs+esi*8]
or al, PG_UWR or al, PG_UWR
mov [page_tabs+ebx*4], eax mov [page_tabs+ebx*8], eax
mov eax, ebx mov eax, ebx
shl eax, 12 shl eax, 12
invlpg [eax] invlpg [eax]
@ -2891,7 +2874,7 @@ nosb6:
mov eax, ecx mov eax, ecx
mov ebx, ecx mov ebx, ecx
shr eax, 12 shr eax, 12
mov ecx, [page_tabs+(eax-1)*4] mov ecx, [page_tabs+(eax-1)*8]
test cl, USED_BLOCK+DONT_FREE_BLOCK test cl, USED_BLOCK+DONT_FREE_BLOCK
jz .err jz .err
jnp .err jnp .err
@ -2901,7 +2884,7 @@ nosb6:
;-------------------------------------- ;--------------------------------------
align 4 align 4
@@: @@:
and dword [page_tabs+eax*4], 0 and dword [page_tabs+eax*8], 0
mov edx, eax mov edx, eax
shl edx, 12 shl edx, 12
push eax push eax
@ -2910,7 +2893,7 @@ align 4
inc eax inc eax
loop @b loop @b
pop eax pop eax
and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK and dword [page_tabs+(eax-1)*8], not DONT_FREE_BLOCK
stdcall user_free, ebx stdcall user_free, ebx
mov [esp+32], eax mov [esp+32], eax
and [bgrlockpid], 0 and [bgrlockpid], 0
@ -3275,7 +3258,7 @@ sys_clock:
add ecx, edx add ecx, edx
movzx edx, al movzx edx, al
add ecx, edx add ecx, edx
sti ; sti
mov [esp + 32], ecx mov [esp + 32], ecx
ret ret
@ -3310,7 +3293,7 @@ sys_date:
out 0x70, al out 0x70, al
in al, 0x71 in al, 0x71
mov cl, al mov cl, al
sti ; sti
mov [esp+32], ecx mov [esp+32], ecx
ret ret
@ -4234,7 +4217,7 @@ new_port_access:
; pop ebp ; pop ebp
no_unmask_io: no_unmask_io:
popad ; end enable io map popad ; end enable io map
sti ; sti
mov eax, [RESERVED_PORTS] mov eax, [RESERVED_PORTS]
add eax, 1 add eax, 1

View File

@ -20,7 +20,7 @@ struct FRB
pitch rd 1 pitch rd 1
format rd 1 format rd 1
private rd 1 private rd 1
pde rd 8 pde rd 16*2
ends ends
align 4 align 4
@ -126,17 +126,17 @@ init_video:
bt [cpu_caps], CAPS_PSE bt [cpu_caps], CAPS_PSE
jnc .create_page_tables jnc .create_page_tables
mov edx, 0x00400000 mov edx, 0x00200000
or esi, PG_GLOBAL+PAT_WC+PG_UWR or esi, PG_GLOBAL+PAT_WC+PG_UWR
and esi, [pte_valid_mask] and esi, [pte_valid_mask]
or esi, PDE_LARGE or esi, PDE_LARGE
mov [ebp+FRB.pde], esi mov [ebp+FRB.pde], esi
add esi, edx add esi, edx
mov [ebp+FRB.pde+4], esi
add esi, edx
mov [ebp+FRB.pde+8], esi mov [ebp+FRB.pde+8], esi
add esi, edx add esi, edx
mov [ebp+FRB.pde+12], esi mov [ebp+FRB.pde+16], esi
add esi, edx
mov [ebp+FRB.pde+24], esi
add esi, edx add esi, edx
.ok: .ok:
call calculate_fast_getting_offset_for_WinMapAddress call calculate_fast_getting_offset_for_WinMapAddress
@ -154,7 +154,7 @@ init_video:
stdcall alloc_kernel_space, 0x1000 stdcall alloc_kernel_space, 0x1000
mov edi, eax mov edi, eax
mov ebx, 4 mov ebx, 8
.new_pd: .new_pd:
call alloc_page call alloc_page
@ -164,13 +164,15 @@ init_video:
stdcall map_page, edi, eax, PG_SWR stdcall map_page, edi, eax, PG_SWR
mov eax, esi mov eax, esi
mov ecx, 1024 mov ecx, 512
@@: @@:
stosd mov [edi], eax
mov [edi+4], dword 0
add eax, 0x1000 add eax, 0x1000
add edi, 8
loop @B loop @B
add esi, 0x400000 add esi, 0x200000
add ebp, 4 add ebp, 4
sub edi, 4096 sub edi, 4096
dec ebx dec ebx
@ -198,8 +200,10 @@ init_video:
and eax, [pte_valid_mask] and eax, [pte_valid_mask]
mov ecx, (1228800+81920)/4096 mov ecx, (1228800+81920)/4096
@@: @@:
stosd mov [edi], eax
mov [edi+4],dword 0
add eax, 0x1000 add eax, 0x1000
add edi, 8
loop @B loop @B
call free_kernel_space call free_kernel_space
@ -210,20 +214,17 @@ set_framebuffer:
push esi push esi
push edi push edi
lea esi, [ecx+FRB.pde] lea esi, [ecx+FRB.pde]
mov eax, sys_proc mov edi, sys_pml2+OS_BASE+8192-16*8
cld cld
pushfd pushfd
cli cli
mov [_display.current_lfb], ecx mov [_display.current_lfb], ecx
.patch_pde: .patch_pde:
lea edi, [eax+PROC.pdt_0+4096-32] ;last 8 pd entries up to 32Mb framebuffer mov ecx, 16*2
mov ecx, 4 rep movsd
rep movsd ;patch pde
sub esi, 16
mov eax, [eax+PROC.list.next] ;next process/address space
cmp eax, sys_proc
jne .patch_pde
bt [cpu_caps], CAPS_PGE bt [cpu_caps], CAPS_PGE
jnc .cr3_flush jnc .cr3_flush