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

View File

@ -594,7 +594,7 @@ proc load_file_umode stdcall, file_name:dword
jz .err_2
mov edx, [file_size] ;preallocate page memory
shr eax, 10
shr eax, 9
lea edi, [page_tabs+eax]
add edx, 4095
shr edx, 12
@ -605,6 +605,8 @@ proc load_file_umode stdcall, file_name:dword
or eax, PG_UWR
stosd
xor eax, eax
stosd
dec edx
jnz @B
@ -649,14 +651,14 @@ proc load_file_umode stdcall, file_name:dword
test eax, eax
jz .err_2
shr eax, 10 ; and remap pages.
shr eax, 9 ; and remap pages.
mov ecx, [file_size]
add ecx, 4095
shr ecx, 12
mov esi, [km_file]
shr esi, 10
shr esi, 9
add esi, page_tabs
lea edi, [page_tabs+eax]
@ -667,6 +669,8 @@ proc load_file_umode stdcall, file_name:dword
and eax, 0xFFFFF000
or eax, PG_UWR
stosd
xor eax, eax
stosd
loop @B
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 edx, ebx
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
; use copy-on-write for user-mode image, so map as readonly
xor edi, edi
mov ecx, [esi+DLLDESCR.data]
shr ecx, 12
.map_pages_loop:
mov eax, [page_tabs+ecx*4]
mov eax, [page_tabs+ecx*8]
and eax, not 0xFFF
or al, PG_UR
xchg eax, [page_tabs+edx*4]
xchg eax, [page_tabs+edx*8]
test al, 1
jz @f
call free_page

View File

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

View File

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

View File

@ -56,9 +56,6 @@ change_task:
uglobal
align 4
; far_jump:
; .offs dd ?
; .sel dw ?
context_counter dd 0 ;noname & halyavin
next_usage_update dd 0
timer_ticks dd 0
@ -103,15 +100,29 @@ do_change_task:
mov esp, [ebx+APPDATA.saved_esp]
; set new thread 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 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
mov eax, [ebx+APPDATA.process]
cmp eax, [current_process]
je @f
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
@@:
; set tss.esp0

View File

@ -306,13 +306,13 @@ show_error_parameters:
push ebx
shr ebx, 12
mov ecx, ebx
shr ecx, 10
mov edx, [master_tab+ecx*4]
shr ecx, 9
mov edx, [master_tab+ecx*8]
test edx, PG_READ
jz .fail ;page table is not created
;incorrect address in the program
mov eax, [page_tabs+ebx*4]
mov eax, [page_tabs+ebx*8]
test eax, 2
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 eax, [app_size]
add eax, 0x3FFFFF
shr eax, 22
add eax, 0x1FFFFF
shr eax, 21
mov [app_tabs], eax
stdcall kernel_alloc, 0x2000
stdcall kernel_alloc, 0x3000
test eax, eax
jz .fail
mov [process], eax
@ -371,20 +371,15 @@ proc create_process stdcall, app_size:dword
mov eax, edi
call get_pg_addr
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
rep stosd
mov ecx, (OS_BASE shr 20)/4
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]
lea edx, [edi-8192]
mov esi, [app_tabs]
.alloc_page_dir:
@ -393,6 +388,7 @@ proc create_process stdcall, app_size:dword
jz .fail
or eax, PG_UWR
mov [edx], eax
mov [edx+4], dword 0
mov edi, [tmp_task_ptab]
stdcall map_page, edi, eax, PG_SWR
@ -400,7 +396,7 @@ proc create_process stdcall, app_size:dword
xor eax, eax
rep stosd
add edx, 4
add edx, 8
dec esi
jnz .alloc_page_dir
@ -430,7 +426,7 @@ proc destroy_page_table stdcall, pg_tab:dword
push esi
mov esi, [pg_tab]
mov ecx, 1024
mov ecx, 512
.free:
mov eax, [esi]
test eax, 1
@ -441,7 +437,7 @@ proc destroy_page_table stdcall, pg_tab:dword
jnz .next ;skip shared pages
call free_page
.next:
add esi, 4
add esi, 8
dec ecx
jnz .free
pop esi
@ -467,7 +463,7 @@ align 4
mov esi, [esp]
add esi, PROC.pdt_0
mov edi, (0x80000000 shr 20)/4
mov edi, 1024
.destroy:
mov eax, [esi]
test eax, 1
@ -478,7 +474,7 @@ align 4
mov eax, [esi]
call free_page
.next:
add esi, 4
add esi, 8
dec edi
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
mov edi, page_tabs
shr esi, 10
shr esi, 9
add esi, edi
.map_image:
@ -816,6 +812,7 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
and eax, -4096
or eax, PG_UWR
stosd
movsd
dec edx
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
stosd
xor eax, eax
stosd
dec edx
jnz .map_bss
@ -867,7 +866,41 @@ common_app_entry:
add esi, ecx
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:
cmp byte [esi], '/'
jne .copy_full_path
rep movsb
stosb
@ -914,8 +947,8 @@ common_app_entry:
mov fs, dx
.cleanup:
stdcall free_kernel_space, [ebp+APP_HDR.img_base]
stdcall kernel_free, ebp
; stdcall free_kernel_space, [ebp+APP_HDR.img_base]
; stdcall kernel_free, ebp
.exit:
popad
iretd

View File

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

View File

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

View File

@ -124,29 +124,29 @@ proc init_mem
mov edx, (HEAP_BASE-OS_BASE+HEAP_MIN_SIZE)/4096
.set:
mov [pg_data.kernel_pages-OS_BASE], edx
shr edx, 10
shr edx, 9
mov [pg_data.kernel_tables-OS_BASE], edx
xor eax, eax
mov edi, sys_proc-OS_BASE
mov ecx, 8192/4
cld
rep stosd
mov edx, (sys_proc-OS_BASE+PROC.pdt_0)+ 0x800; (OS_BASE shr 20)
mov edx, sys_pml2
mov edi, 0x0070000 ;sys_proc+PROC.pdt_0-OS_BASE
bt [cpu_caps-OS_BASE], CAPS_PSE
jnc .no_PSE
mov ebx, cr4
or ebx, CR4_PSE
or ebx, CR4_PSE+CR4_PAE
mov eax, PDE_LARGE+PG_SWR
mov cr4, ebx
dec [pg_data.kernel_tables-OS_BASE]
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"
.no_PSE:
mov eax, PG_SWR
@ -161,28 +161,28 @@ proc init_mem
jnz @B
.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 eax, [tmp_page_tabs]
or eax, PG_SWR
mov edi, edx
.map_kernel_tabs:
stosd
mov [edx], eax
add eax, 0x1000
add edx, 8
dec ecx
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
endp

View File

@ -292,7 +292,7 @@ B32:
; ENABLE PAGING
mov eax, sys_proc-OS_BASE+PROC.pdt_0
mov eax, sys_pml3-OS_BASE
mov cr3, eax
mov eax, cr0
@ -358,7 +358,8 @@ high_code:
bt [cpu_caps], CAPS_PGE
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
mov eax, cr4
@ -369,7 +370,7 @@ high_code:
xor eax, 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 cr3, eax ; flush TLB
@ -649,6 +650,7 @@ high_code:
jbe @B
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 edi, thr_slot_map+4
@ -761,7 +763,7 @@ endg
mov esi, boot_v86machine
call boot_log
; Initialize system V86 machine
call init_sys_v86
; call init_sys_v86
mov esi, boot_inittimer
call boot_log
@ -859,20 +861,8 @@ include 'detect/dev_fd.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
mov esi, boot_APIC_found
cmp [irq_mode], IRQ_APIC
@ -902,16 +892,9 @@ end if
inc edi
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
stdcall load_pe_driver, szVidintel, 0
; stdcall load_pe_driver, szVidintel, 0
call usb_init
@ -1115,7 +1098,7 @@ end if
sti
call mtrr_validate
; call mtrr_validate
jmp osloop
@ -2254,7 +2237,7 @@ sysfn_terminate2:
cli
call sysfn_terminate
call unlock_application_table
sti
; sti
and dword [esp+32], 0
ret
.not_found:
@ -2847,7 +2830,7 @@ align 4
jz .nomem
mov ebx, eax
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]
shr esi, 12
mov ecx, [mem_BACKGROUND]
@ -2856,16 +2839,16 @@ align 4
;--------------------------------------
align 4
.z:
mov eax, [page_tabs+ebx*4]
mov eax, [page_tabs+ebx*8]
test al, 1
jz @f
call free_page
;--------------------------------------
align 4
@@:
mov eax, [page_tabs+esi*4]
mov eax, [page_tabs+esi*8]
or al, PG_UWR
mov [page_tabs+ebx*4], eax
mov [page_tabs+ebx*8], eax
mov eax, ebx
shl eax, 12
invlpg [eax]
@ -2891,7 +2874,7 @@ nosb6:
mov eax, ecx
mov ebx, ecx
shr eax, 12
mov ecx, [page_tabs+(eax-1)*4]
mov ecx, [page_tabs+(eax-1)*8]
test cl, USED_BLOCK+DONT_FREE_BLOCK
jz .err
jnp .err
@ -2901,7 +2884,7 @@ nosb6:
;--------------------------------------
align 4
@@:
and dword [page_tabs+eax*4], 0
and dword [page_tabs+eax*8], 0
mov edx, eax
shl edx, 12
push eax
@ -2910,7 +2893,7 @@ align 4
inc eax
loop @b
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
mov [esp+32], eax
and [bgrlockpid], 0
@ -3275,7 +3258,7 @@ sys_clock:
add ecx, edx
movzx edx, al
add ecx, edx
sti
; sti
mov [esp + 32], ecx
ret
@ -3310,7 +3293,7 @@ sys_date:
out 0x70, al
in al, 0x71
mov cl, al
sti
; sti
mov [esp+32], ecx
ret
@ -4234,7 +4217,7 @@ new_port_access:
; pop ebp
no_unmask_io:
popad ; end enable io map
sti
; sti
mov eax, [RESERVED_PORTS]
add eax, 1

View File

@ -8,7 +8,7 @@
$Revision$
; void __stdcall unpack(void* packed_data, void* unpacked_data);
; void __stdcall unpack(void* packed_data, void* unpacked_data);
unpack:
pushad
mov esi, [esp+32+4]

View File

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