[KERNEL]: Replaced magic numbers with constants:
PAGE_SIZE, -PAGE_SIZE, PAGE_SIZE-1 git-svn-id: svn://kolibrios.org@9900 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
aae65fd398
commit
dd33210115
@ -137,7 +137,7 @@ proc init_kernel_heap
|
|||||||
mov [edi + MEM_BLOCK.list.next], eax
|
mov [edi + MEM_BLOCK.list.next], eax
|
||||||
mov [edi + MEM_BLOCK.list.prev], eax
|
mov [edi + MEM_BLOCK.list.prev], eax
|
||||||
mov [edi + MEM_BLOCK.base], HEAP_BASE
|
mov [edi + MEM_BLOCK.base], HEAP_BASE
|
||||||
mov [edi + MEM_BLOCK.size], 4096*sizeof.MEM_BLOCK
|
mov [edi + MEM_BLOCK.size], PAGE_SIZE * sizeof.MEM_BLOCK
|
||||||
mov [edi + MEM_BLOCK.flags], MEM_BLOCK_USED
|
mov [edi + MEM_BLOCK.flags], MEM_BLOCK_USED
|
||||||
|
|
||||||
mov [ecx + MEM_BLOCK.next_block], eax
|
mov [ecx + MEM_BLOCK.next_block], eax
|
||||||
@ -150,11 +150,11 @@ proc init_kernel_heap
|
|||||||
|
|
||||||
mov [ebx + MEM_BLOCK.next_block], ecx
|
mov [ebx + MEM_BLOCK.next_block], ecx
|
||||||
mov [ebx + MEM_BLOCK.prev_block], edi
|
mov [ebx + MEM_BLOCK.prev_block], edi
|
||||||
mov [ebx + MEM_BLOCK.base], HEAP_BASE + 4096*sizeof.MEM_BLOCK
|
mov [ebx + MEM_BLOCK.base], HEAP_BASE + PAGE_SIZE * sizeof.MEM_BLOCK
|
||||||
|
|
||||||
mov ecx, [pg_data.kernel_pages]
|
mov ecx, [pg_data.kernel_pages]
|
||||||
shl ecx, 12
|
shl ecx, 12
|
||||||
sub ecx, HEAP_BASE-OS_BASE + 4096*sizeof.MEM_BLOCK
|
sub ecx, HEAP_BASE-OS_BASE + PAGE_SIZE * sizeof.MEM_BLOCK
|
||||||
mov [heap_size], ecx
|
mov [heap_size], ecx
|
||||||
mov [heap_free], ecx
|
mov [heap_free], ecx
|
||||||
mov [ebx + MEM_BLOCK.size], ecx
|
mov [ebx + MEM_BLOCK.size], ecx
|
||||||
@ -166,7 +166,7 @@ proc init_kernel_heap
|
|||||||
mov ecx, mem_block_list + 63*8
|
mov ecx, mem_block_list + 63*8
|
||||||
list_add ebx, ecx
|
list_add ebx, ecx
|
||||||
|
|
||||||
mov ecx, 4096-3-1
|
mov ecx, PAGE_SIZE -3-1
|
||||||
mov eax, HEAP_BASE + sizeof.MEM_BLOCK*4
|
mov eax, HEAP_BASE + sizeof.MEM_BLOCK*4
|
||||||
|
|
||||||
mov [next_memblock], HEAP_BASE + sizeof.MEM_BLOCK *3
|
mov [next_memblock], HEAP_BASE + sizeof.MEM_BLOCK *3
|
||||||
@ -268,8 +268,8 @@ proc alloc_kernel_space stdcall, size:dword
|
|||||||
push edi
|
push edi
|
||||||
|
|
||||||
mov eax, [size]
|
mov eax, [size]
|
||||||
add eax, 4095
|
add eax, PAGE_SIZE-1
|
||||||
and eax, not 4095
|
and eax, -PAGE_SIZE
|
||||||
mov [size], eax
|
mov [size], eax
|
||||||
|
|
||||||
cmp eax, [heap_free]
|
cmp eax, [heap_free]
|
||||||
@ -461,8 +461,8 @@ proc kernel_alloc stdcall, size:dword
|
|||||||
push edi
|
push edi
|
||||||
|
|
||||||
mov eax, [size]
|
mov eax, [size]
|
||||||
add eax, 4095
|
add eax, PAGE_SIZE-1
|
||||||
and eax, not 4095;
|
and eax, -PAGE_SIZE;
|
||||||
mov [size], eax
|
mov [size], eax
|
||||||
and eax, eax
|
and eax, eax
|
||||||
jz .err
|
jz .err
|
||||||
@ -502,7 +502,7 @@ proc kernel_alloc stdcall, size:dword
|
|||||||
jz .err
|
jz .err
|
||||||
|
|
||||||
stdcall map_page, edx, eax, dword (PG_GLOBAL + PG_SWR)
|
stdcall map_page, edx, eax, dword (PG_GLOBAL + PG_SWR)
|
||||||
add edx, 0x1000
|
add edx, PAGE_SIZE
|
||||||
dec ebx
|
dec ebx
|
||||||
jnz @B
|
jnz @B
|
||||||
.end:
|
.end:
|
||||||
@ -565,8 +565,8 @@ proc init_heap
|
|||||||
call mutex_init
|
call mutex_init
|
||||||
|
|
||||||
mov esi, [ebx + PROC.mem_used]
|
mov esi, [ebx + PROC.mem_used]
|
||||||
add esi, 4095
|
add esi, PAGE_SIZE-1
|
||||||
and esi, not 4095
|
and esi, -PAGE_SIZE
|
||||||
mov [ebx + PROC.mem_used], esi
|
mov [ebx + PROC.mem_used], esi
|
||||||
mov eax, HEAP_TOP
|
mov eax, HEAP_TOP
|
||||||
mov [ebx + PROC.heap_base], esi
|
mov [ebx + PROC.heap_base], esi
|
||||||
@ -592,7 +592,7 @@ proc user_alloc stdcall, alloc_size:dword
|
|||||||
|
|
||||||
mov ecx, [alloc_size]
|
mov ecx, [alloc_size]
|
||||||
add ecx, (4095 + PAGE_SIZE)
|
add ecx, (4095 + PAGE_SIZE)
|
||||||
and ecx, not 4095
|
and ecx, -PAGE_SIZE
|
||||||
mov esi, [ebx + PROC.heap_base]
|
mov esi, [ebx + PROC.heap_base]
|
||||||
mov edi, [ebx + PROC.heap_top]
|
mov edi, [ebx + PROC.heap_top]
|
||||||
.scan:
|
.scan:
|
||||||
@ -604,7 +604,7 @@ proc user_alloc stdcall, alloc_size:dword
|
|||||||
mov eax, [page_tabs + ebx*4]
|
mov eax, [page_tabs + ebx*4]
|
||||||
test al, MEM_BLOCK_FREE
|
test al, MEM_BLOCK_FREE
|
||||||
jz .test_used
|
jz .test_used
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
cmp eax, ecx ;alloc_size
|
cmp eax, ecx ;alloc_size
|
||||||
jb .m_next
|
jb .m_next
|
||||||
jz @f
|
jz @f
|
||||||
@ -630,14 +630,14 @@ proc user_alloc stdcall, alloc_size:dword
|
|||||||
|
|
||||||
mov edx, [current_process]
|
mov edx, [current_process]
|
||||||
mov ebx, [alloc_size]
|
mov ebx, [alloc_size]
|
||||||
add ebx, 0xFFF
|
add ebx, PAGE_SIZE-1
|
||||||
and ebx, not 0xFFF
|
and ebx, -PAGE_SIZE
|
||||||
add [edx + PROC.mem_used], ebx
|
add [edx + PROC.mem_used], ebx
|
||||||
|
|
||||||
lea ecx, [edx + PROC.heap_lock]
|
lea ecx, [edx + PROC.heap_lock]
|
||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
|
|
||||||
lea eax, [esi + 4096]
|
lea eax, [esi + PAGE_SIZE]
|
||||||
|
|
||||||
pop edi
|
pop edi
|
||||||
pop esi
|
pop esi
|
||||||
@ -647,7 +647,7 @@ proc user_alloc stdcall, alloc_size:dword
|
|||||||
test al, MEM_BLOCK_USED
|
test al, MEM_BLOCK_USED
|
||||||
jz .m_exit
|
jz .m_exit
|
||||||
|
|
||||||
and eax, 0xFFFFF000 ; not PAGESIZE
|
and eax, -PAGE_SIZE
|
||||||
.m_next:
|
.m_next:
|
||||||
add esi, eax
|
add esi, eax
|
||||||
jmp .scan
|
jmp .scan
|
||||||
@ -675,9 +675,9 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
|
|
||||||
mov edx, [address]
|
mov edx, [address]
|
||||||
and edx, not 0xFFF
|
and edx, -PAGE_SIZE
|
||||||
mov [address], edx
|
mov [address], edx
|
||||||
sub edx, 0x1000
|
sub edx, PAGE_SIZE
|
||||||
jb .error
|
jb .error
|
||||||
mov esi, [ebx + PROC.heap_base]
|
mov esi, [ebx + PROC.heap_base]
|
||||||
mov edi, [ebx + PROC.heap_top]
|
mov edi, [ebx + PROC.heap_top]
|
||||||
@ -690,7 +690,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
|
|||||||
shr ebx, 12
|
shr ebx, 12
|
||||||
mov eax, [page_tabs + ebx*4]
|
mov eax, [page_tabs + ebx*4]
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
and ecx, 0xFFFFF000
|
and ecx, -PAGE_SIZE
|
||||||
add ecx, esi
|
add ecx, esi
|
||||||
cmp edx, ecx
|
cmp edx, ecx
|
||||||
jb .found
|
jb .found
|
||||||
@ -711,7 +711,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
|
|||||||
jz .error
|
jz .error
|
||||||
mov eax, ecx
|
mov eax, ecx
|
||||||
sub eax, edx
|
sub eax, edx
|
||||||
sub eax, 0x1000
|
sub eax, PAGE_SIZE
|
||||||
cmp eax, [alloc_size]
|
cmp eax, [alloc_size]
|
||||||
jb .error
|
jb .error
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
|
|||||||
.nofirst:
|
.nofirst:
|
||||||
mov eax, [alloc_size]
|
mov eax, [alloc_size]
|
||||||
add eax, 0x1FFF
|
add eax, 0x1FFF
|
||||||
and eax, not 0xFFF
|
and eax, -PAGE_SIZE
|
||||||
mov ebx, edx
|
mov ebx, edx
|
||||||
add edx, eax
|
add edx, eax
|
||||||
shr ebx, 12
|
shr ebx, 12
|
||||||
@ -754,8 +754,8 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword
|
|||||||
.nothird:
|
.nothird:
|
||||||
mov edx, [current_process]
|
mov edx, [current_process]
|
||||||
mov ebx, [alloc_size]
|
mov ebx, [alloc_size]
|
||||||
add ebx, 0xFFF
|
add ebx, PAGE_SIZE-1
|
||||||
and ebx, not 0xFFF
|
and ebx, -PAGE_SIZE
|
||||||
add [edx + PROC.mem_used], ebx
|
add [edx + PROC.mem_used], ebx
|
||||||
|
|
||||||
lea ecx, [edx + PROC.heap_lock]
|
lea ecx, [edx + PROC.heap_lock]
|
||||||
@ -792,11 +792,11 @@ proc user_free stdcall, base:dword
|
|||||||
test al, MEM_BLOCK_DONT_FREE
|
test al, MEM_BLOCK_DONT_FREE
|
||||||
jnz .cantfree
|
jnz .cantfree
|
||||||
|
|
||||||
and eax, not 4095
|
and eax, -PAGE_SIZE
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
or al, MEM_BLOCK_FREE
|
or al, MEM_BLOCK_FREE
|
||||||
mov [page_tabs + (esi-1)*4], eax
|
mov [page_tabs + (esi-1)*4], eax
|
||||||
sub ecx, 4096
|
sub ecx, PAGE_SIZE
|
||||||
mov ebx, ecx
|
mov ebx, ecx
|
||||||
shr ecx, 12
|
shr ecx, 12
|
||||||
jz .released
|
jz .released
|
||||||
@ -873,7 +873,7 @@ proc user_unmap stdcall, base:dword, offset:dword, size:dword
|
|||||||
lea edx, [page_tabs + edx*4] ; unmap offset
|
lea edx, [page_tabs + edx*4] ; unmap offset
|
||||||
|
|
||||||
mov ecx, [size]
|
mov ecx, [size]
|
||||||
add ecx, 4095
|
add ecx, PAGE_SIZE-1
|
||||||
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
|
||||||
@ -884,7 +884,7 @@ proc user_unmap stdcall, base:dword, offset:dword, size:dword
|
|||||||
ja .error
|
ja .error
|
||||||
|
|
||||||
mov ebx, [offset]
|
mov ebx, [offset]
|
||||||
and ebx, not 4095 ; is it required ?
|
and ebx, -PAGE_SIZE ; is it required ?
|
||||||
add ebx, [base]
|
add ebx, [base]
|
||||||
|
|
||||||
.unmap:
|
.unmap:
|
||||||
@ -898,7 +898,7 @@ proc user_unmap stdcall, base:dword, offset:dword, size:dword
|
|||||||
invlpg [ebx] ; when we start using
|
invlpg [ebx] ; when we start using
|
||||||
call free_page ; empty c-o-w page instead this ?
|
call free_page ; empty c-o-w page instead this ?
|
||||||
@@:
|
@@:
|
||||||
add ebx, 4096 ; PAGESIZE?
|
add ebx, PAGE_SIZE
|
||||||
add edx, 4
|
add edx, 4
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .unmap
|
jnz .unmap
|
||||||
@ -948,7 +948,7 @@ user_normalize:
|
|||||||
jz .err
|
jz .err
|
||||||
and dword[page_tabs + edx*4], 0
|
and dword[page_tabs + edx*4], 0
|
||||||
add eax, ebx
|
add eax, ebx
|
||||||
and eax, not 4095 ; not (PAGESIZE - 1) ?
|
and eax, -PAGE_SIZE
|
||||||
or eax, MEM_BLOCK_FREE
|
or eax, MEM_BLOCK_FREE
|
||||||
mov [page_tabs + esi*4], eax
|
mov [page_tabs + esi*4], eax
|
||||||
jmp @B
|
jmp @B
|
||||||
@ -978,7 +978,7 @@ user_realloc:
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
lea ecx, [eax - 0x1000]
|
lea ecx, [eax - PAGE_SIZE]
|
||||||
shr ecx, 12
|
shr ecx, 12
|
||||||
mov edx, [page_tabs + ecx*4]
|
mov edx, [page_tabs + ecx*4]
|
||||||
test dl, MEM_BLOCK_USED
|
test dl, MEM_BLOCK_USED
|
||||||
@ -1022,11 +1022,11 @@ user_realloc:
|
|||||||
cmp ebx, 1
|
cmp ebx, 1
|
||||||
jnz .nofreeall
|
jnz .nofreeall
|
||||||
mov eax, [page_tabs + ecx*4]
|
mov eax, [page_tabs + ecx*4]
|
||||||
and eax, not 0xFFF
|
and eax, -PAGE_SIZE
|
||||||
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, PAGE_SIZE
|
||||||
or al, MEM_BLOCK_FREE
|
or al, MEM_BLOCK_FREE
|
||||||
mov [page_tabs + ecx*4], eax
|
mov [page_tabs + ecx*4], eax
|
||||||
push esi edi
|
push esi edi
|
||||||
@ -1174,7 +1174,7 @@ user_realloc:
|
|||||||
shl eax, 12
|
shl eax, 12
|
||||||
push eax
|
push eax
|
||||||
mov eax, [page_tabs + ecx*4]
|
mov eax, [page_tabs + ecx*4]
|
||||||
and eax, not 0xFFF
|
and eax, -PAGE_SIZE
|
||||||
or al, MEM_BLOCK_FREE
|
or al, MEM_BLOCK_FREE
|
||||||
sub edx, ecx
|
sub edx, ecx
|
||||||
mov [page_tabs + ecx*4], eax
|
mov [page_tabs + ecx*4], eax
|
||||||
@ -1333,8 +1333,8 @@ align 4
|
|||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
add ecx, 4095
|
add ecx, PAGE_SIZE-1
|
||||||
and ecx, -4096
|
and ecx, -PAGE_SIZE
|
||||||
mov [size], ecx
|
mov [size], ecx
|
||||||
|
|
||||||
mov eax, sizeof.SMEM
|
mov eax, sizeof.SMEM
|
||||||
@ -1438,7 +1438,7 @@ align 4
|
|||||||
or edx, PG_SHARED + PG_UR
|
or edx, PG_SHARED + PG_UR
|
||||||
@@:
|
@@:
|
||||||
lodsd
|
lodsd
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
or eax, edx
|
or eax, edx
|
||||||
stosd
|
stosd
|
||||||
loop @B
|
loop @B
|
||||||
|
@ -173,10 +173,10 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
|
|||||||
push edi
|
push edi
|
||||||
mov eax, [size]
|
mov eax, [size]
|
||||||
add eax, [base]
|
add eax, [base]
|
||||||
add eax, 4095
|
add eax, PAGE_SIZE-1
|
||||||
and eax, -4096
|
and eax, -PAGE_SIZE
|
||||||
mov ecx, [base]
|
mov ecx, [base]
|
||||||
and ecx, -4096
|
and ecx, -PAGE_SIZE
|
||||||
sub eax, ecx
|
sub eax, ecx
|
||||||
mov [size], eax
|
mov [size], eax
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
|
|||||||
jz .fail
|
jz .fail
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
mov edi, 0x1000
|
mov edi, PAGE_SIZE
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
mov ecx, [size]
|
mov ecx, [size]
|
||||||
mov edx, [base]
|
mov edx, [base]
|
||||||
@ -203,7 +203,7 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
|
|||||||
|
|
||||||
pop eax
|
pop eax
|
||||||
mov edx, [base]
|
mov edx, [base]
|
||||||
and edx, 4095
|
and edx, PAGE_SIZE-1
|
||||||
add eax, edx
|
add eax, edx
|
||||||
.fail:
|
.fail:
|
||||||
pop edi
|
pop edi
|
||||||
@ -236,8 +236,8 @@ commit_pages:
|
|||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
invlpg [ebx]
|
invlpg [ebx]
|
||||||
add eax, 0x1000
|
add eax, PAGE_SIZE
|
||||||
add ebx, 0x1000
|
add ebx, PAGE_SIZE
|
||||||
loop @B
|
loop @B
|
||||||
|
|
||||||
pop edi
|
pop edi
|
||||||
@ -294,7 +294,7 @@ release_pages:
|
|||||||
|
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
.next:
|
.next:
|
||||||
add edi, 0x1000
|
add edi, PAGE_SIZE
|
||||||
add esi, 4
|
add esi, 4
|
||||||
loop @B
|
loop @B
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ unmap_pages:
|
|||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
invlpg [edx]
|
invlpg [edx]
|
||||||
add edx, 0x1000
|
add edx, PAGE_SIZE
|
||||||
loop @b
|
loop @b
|
||||||
|
|
||||||
pop edi
|
pop edi
|
||||||
@ -340,7 +340,7 @@ proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
|
|||||||
mov ebx, [lin_addr]
|
mov ebx, [lin_addr]
|
||||||
shr ebx, 22
|
shr ebx, 22
|
||||||
mov eax, [phis_addr]
|
mov eax, [phis_addr]
|
||||||
and eax, not 0xFFF
|
and eax, -PAGE_SIZE
|
||||||
or eax, PG_UWR
|
or eax, PG_UWR
|
||||||
mov dword [master_tab + ebx*4], eax
|
mov dword [master_tab + ebx*4], eax
|
||||||
mov eax, [lin_addr]
|
mov eax, [lin_addr]
|
||||||
@ -389,7 +389,7 @@ proc create_trampoline_pgmap
|
|||||||
; Therefore, allocate memory with kernel_alloc,
|
; Therefore, allocate memory with kernel_alloc,
|
||||||
; this will allocate physical page and a linear address somewhere,
|
; this will allocate physical page and a linear address somewhere,
|
||||||
; and deallocate only linear address with free_kernel_space.
|
; and deallocate only linear address with free_kernel_space.
|
||||||
stdcall kernel_alloc, 0x1000
|
stdcall kernel_alloc, PAGE_SIZE
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
mov esi, master_tab
|
mov esi, master_tab
|
||||||
mov ecx, 1024
|
mov ecx, 1024
|
||||||
@ -418,12 +418,12 @@ proc new_mem_resize stdcall, new_size:dword
|
|||||||
jne .exit
|
jne .exit
|
||||||
|
|
||||||
mov edi, [new_size]
|
mov edi, [new_size]
|
||||||
add edi, 4095
|
add edi, PAGE_SIZE-1
|
||||||
and edi, not 4095
|
and edi, not 4095
|
||||||
mov [new_size], edi
|
mov [new_size], edi
|
||||||
|
|
||||||
mov esi, [ebx + PROC.mem_used]
|
mov esi, [ebx + PROC.mem_used]
|
||||||
add esi, 4095
|
add esi, PAGE_SIZE-1
|
||||||
and esi, not 4095
|
and esi, not 4095
|
||||||
|
|
||||||
cmp edi, esi
|
cmp edi, esi
|
||||||
@ -447,7 +447,7 @@ proc new_mem_resize stdcall, new_size:dword
|
|||||||
|
|
||||||
.next:
|
.next:
|
||||||
inc edi
|
inc edi
|
||||||
add ebx, 0x1000
|
add ebx, PAGE_SIZE
|
||||||
cmp edi, esi
|
cmp edi, esi
|
||||||
jb @B
|
jb @B
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ get_pg_addr:
|
|||||||
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))*4]
|
||||||
@@:
|
@@:
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ proc page_fault_handler
|
|||||||
stdcall map_page, [.err_addr], eax, PG_UWR
|
stdcall map_page, [.err_addr], eax, PG_UWR
|
||||||
|
|
||||||
mov edi, [.err_addr]
|
mov edi, [.err_addr]
|
||||||
and edi, 0xFFFFF000
|
and edi, -PAGE_SIZE
|
||||||
mov ecx, 1024
|
mov ecx, 1024
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
;cld ;caller is duty for this
|
;cld ;caller is duty for this
|
||||||
@ -619,7 +619,7 @@ proc page_fault_handler
|
|||||||
.err_access:
|
.err_access:
|
||||||
; access denied? this may be a result of copy-on-write protection for DLL
|
; access denied? this may be a result of copy-on-write protection for DLL
|
||||||
; check list of HDLLs
|
; check list of HDLLs
|
||||||
and ebx, not 0xFFF
|
and ebx, -PAGE_SIZE
|
||||||
mov eax, [current_process]
|
mov eax, [current_process]
|
||||||
mov eax, [eax + PROC.dlls_list_ptr]
|
mov eax, [eax + PROC.dlls_list_ptr]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -680,7 +680,7 @@ proc page_fault_handler
|
|||||||
stdcall map_page, [.err_addr], eax, dword PG_SWR
|
stdcall map_page, [.err_addr], eax, dword PG_SWR
|
||||||
pop eax
|
pop eax
|
||||||
mov edi, [.err_addr]
|
mov edi, [.err_addr]
|
||||||
and edi, -4096
|
and edi, -PAGE_SIZE
|
||||||
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
|
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
|
||||||
|
|
||||||
mov ebx, esi
|
mov ebx, esi
|
||||||
@ -690,7 +690,7 @@ proc page_fault_handler
|
|||||||
mov [edx + APPDATA.io_map + ebx*4], eax
|
mov [edx + APPDATA.io_map + ebx*4], eax
|
||||||
|
|
||||||
add esi, [default_io_map]
|
add esi, [default_io_map]
|
||||||
mov ecx, 4096/4
|
mov ecx, PAGE_SIZE/4
|
||||||
;cld ;caller is duty for this
|
;cld ;caller is duty for this
|
||||||
rep movsd
|
rep movsd
|
||||||
jmp .exit
|
jmp .exit
|
||||||
@ -719,14 +719,14 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
|
|||||||
shr ebx, 22
|
shr ebx, 22
|
||||||
mov eax, [eax + PROC.pdt_0 + ebx*4] ;get page table
|
mov eax, [eax + PROC.pdt_0 + ebx*4] ;get page table
|
||||||
mov esi, [ipc_ptab]
|
mov esi, [ipc_ptab]
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
jz .exit
|
jz .exit
|
||||||
stdcall map_page, esi, eax, PG_SWR
|
stdcall map_page, esi, eax, PG_SWR
|
||||||
@@:
|
@@:
|
||||||
mov edi, [lin_addr]
|
mov edi, [lin_addr]
|
||||||
and edi, 0xFFFFF000
|
and edi, -PAGE_SIZE
|
||||||
mov ecx, [buf_size]
|
mov ecx, [buf_size]
|
||||||
add ecx, 4095
|
add ecx, PAGE_SIZE-1
|
||||||
shr ecx, 12
|
shr ecx, 12
|
||||||
inc ecx ; ???????????
|
inc ecx ; ???????????
|
||||||
|
|
||||||
@ -749,7 +749,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
|
|||||||
inc ebx
|
inc ebx
|
||||||
mov eax, [process]
|
mov eax, [process]
|
||||||
mov eax, [eax + PROC.pdt_0 + ebx*4]
|
mov eax, [eax + PROC.pdt_0 + ebx*4]
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
stdcall map_page, esi, eax, PG_SWR
|
stdcall map_page, esi, eax, PG_SWR
|
||||||
@ -782,14 +782,14 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
|
|||||||
shr ebx, 22
|
shr ebx, 22
|
||||||
mov eax, [eax + PROC.pdt_0 + ebx*4] ;get page table
|
mov eax, [eax + PROC.pdt_0 + ebx*4] ;get page table
|
||||||
mov esi, [proc_mem_tab]
|
mov esi, [proc_mem_tab]
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
jz .exit
|
jz .exit
|
||||||
stdcall map_page, esi, eax, PG_SWR
|
stdcall map_page, esi, eax, PG_SWR
|
||||||
@@:
|
@@:
|
||||||
mov edi, [lin_addr]
|
mov edi, [lin_addr]
|
||||||
and edi, 0xFFFFF000
|
and edi, -PAGE_SIZE
|
||||||
mov ecx, [buf_size]
|
mov ecx, [buf_size]
|
||||||
add ecx, 4095
|
add ecx, PAGE_SIZE-1
|
||||||
shr ecx, 12
|
shr ecx, 12
|
||||||
inc ecx ; ???????????
|
inc ecx ; ???????????
|
||||||
|
|
||||||
@ -812,7 +812,7 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
|
|||||||
inc ebx
|
inc ebx
|
||||||
mov eax, [process]
|
mov eax, [process]
|
||||||
mov eax, [eax + PROC.pdt_0 + ebx*4]
|
mov eax, [eax + PROC.pdt_0 + ebx*4]
|
||||||
and eax, 0xFFFFF000
|
and eax, -PAGE_SIZE
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
stdcall map_page, esi, eax, PG_SWR
|
stdcall map_page, esi, eax, PG_SWR
|
||||||
@ -874,7 +874,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
|
|||||||
cmp ecx, eax
|
cmp ecx, eax
|
||||||
jz .no_hdll
|
jz .no_hdll
|
||||||
mov ebx, [ofs]
|
mov ebx, [ofs]
|
||||||
and ebx, not 0xFFF
|
and ebx, -PAGE_SIZE
|
||||||
sub ebx, [ecx + HDLL.base]
|
sub ebx, [ecx + HDLL.base]
|
||||||
cmp ebx, [ecx + HDLL.size]
|
cmp ebx, [ecx + HDLL.size]
|
||||||
jb .hdll_found
|
jb .hdll_found
|
||||||
@ -897,7 +897,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
|
|||||||
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
|
||||||
mov ecx, 4096/4
|
mov ecx, PAGE_SIZE/4
|
||||||
rep movsd
|
rep movsd
|
||||||
pop edi esi
|
pop edi esi
|
||||||
pop ecx ebx
|
pop ecx ebx
|
||||||
@ -926,12 +926,12 @@ sys_IPC:
|
|||||||
mov [eax + APPDATA.ipc_size], edx
|
mov [eax + APPDATA.ipc_size], edx
|
||||||
|
|
||||||
add edx, ecx
|
add edx, ecx
|
||||||
add edx, 4095
|
add edx, PAGE_SIZE-1
|
||||||
and edx, not 4095
|
and edx, -PAGE_SIZE
|
||||||
|
|
||||||
.touch:
|
.touch:
|
||||||
mov eax, [ecx]
|
mov eax, [ecx]
|
||||||
add ecx, 0x1000
|
add ecx, PAGE_SIZE
|
||||||
cmp ecx, edx
|
cmp ecx, edx
|
||||||
jb .touch
|
jb .touch
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ 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 - PAGE_SIZE + PROC.pdt_0_phys], eax
|
||||||
|
|
||||||
mov ecx, (OS_BASE shr 20)/4
|
mov ecx, (OS_BASE shr 20)/4
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -384,9 +384,9 @@ proc create_process stdcall, app_size:dword
|
|||||||
|
|
||||||
mov eax, [edi - 8192 + PROC.pdt_0_phys]
|
mov eax, [edi - 8192 + PROC.pdt_0_phys]
|
||||||
or eax, PG_SWR
|
or eax, PG_SWR
|
||||||
mov [edi - 4096 + (page_tabs shr 20)], eax
|
mov [edi - PAGE_SIZE + (page_tabs shr 20)], eax
|
||||||
|
|
||||||
lea edx, [edi-4096]
|
lea edx, [edi - PAGE_SIZE]
|
||||||
mov esi, [app_tabs]
|
mov esi, [app_tabs]
|
||||||
|
|
||||||
.alloc_page_dir:
|
.alloc_page_dir:
|
||||||
@ -474,7 +474,7 @@ align 4
|
|||||||
mov eax, [esi]
|
mov eax, [esi]
|
||||||
test eax, 1
|
test eax, 1
|
||||||
jz .next
|
jz .next
|
||||||
and eax, not 0xFFF
|
and eax, -PAGE_SIZE
|
||||||
stdcall map_page, [tmp_task_ptab], eax, PG_SWR
|
stdcall map_page, [tmp_task_ptab], eax, PG_SWR
|
||||||
stdcall destroy_page_table, [tmp_task_ptab]
|
stdcall destroy_page_table, [tmp_task_ptab]
|
||||||
mov eax, [esi]
|
mov eax, [esi]
|
||||||
@ -730,7 +730,7 @@ proc new_sys_threads
|
|||||||
jz @F
|
jz @F
|
||||||
|
|
||||||
push edx
|
push edx
|
||||||
stdcall user_alloc, 4096
|
stdcall user_alloc, PAGE_SIZE
|
||||||
pop edx
|
pop edx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .failed1;eax=0
|
jz .failed1;eax=0
|
||||||
@ -763,8 +763,8 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
|
|||||||
mov edx, [img_size]
|
mov edx, [img_size]
|
||||||
mov esi, [file_base]
|
mov esi, [file_base]
|
||||||
mov ecx, [file_size]
|
mov ecx, [file_size]
|
||||||
add edx, 4095
|
add edx, PAGE_SIZE-1
|
||||||
add ecx, 4095
|
add ecx, PAGE_SIZE-1
|
||||||
shr edx, 12 ; total pages
|
shr edx, 12 ; total pages
|
||||||
shr ecx, 12 ; image pages
|
shr ecx, 12 ; image pages
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
|
|||||||
|
|
||||||
.map_image:
|
.map_image:
|
||||||
lodsd
|
lodsd
|
||||||
and eax, -4096
|
and eax, -PAGE_SIZE
|
||||||
or eax, PG_UWR
|
or eax, PG_UWR
|
||||||
stosd
|
stosd
|
||||||
dec edx
|
dec edx
|
||||||
@ -794,10 +794,10 @@ proc map_process_image stdcall, img_size:dword, file_base:dword, file_size:dword
|
|||||||
|
|
||||||
mov edi, [file_size]
|
mov edi, [file_size]
|
||||||
mov ecx, [img_size]
|
mov ecx, [img_size]
|
||||||
add edi, 4095
|
add edi, PAGE_SIZE-1
|
||||||
and edi, -4096
|
and edi, -PAGE_SIZE
|
||||||
add ecx, 4095
|
add ecx, PAGE_SIZE-1
|
||||||
and ecx, -4096
|
and ecx, -PAGE_SIZE
|
||||||
sub ecx, edi
|
sub ecx, edi
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -843,8 +843,8 @@ common_app_entry:
|
|||||||
cmp ecx, 256
|
cmp ecx, 256
|
||||||
jb .copy_cmdline
|
jb .copy_cmdline
|
||||||
mov edi, [ebp + APP_HDR._emem]
|
mov edi, [ebp + APP_HDR._emem]
|
||||||
add edi, 4095
|
add edi, PAGE_SIZE-1
|
||||||
and edi, -4096
|
and edi, -PAGE_SIZE
|
||||||
sub edi, ecx
|
sub edi, ecx
|
||||||
dec edi
|
dec edi
|
||||||
cmp word [6], '00'
|
cmp word [6], '00'
|
||||||
@ -864,7 +864,7 @@ common_app_entry:
|
|||||||
cmp word [6], '02'
|
cmp word [6], '02'
|
||||||
jne .try_load_dll ;.cleanup
|
jne .try_load_dll ;.cleanup
|
||||||
call init_heap
|
call init_heap
|
||||||
stdcall user_alloc, 4096
|
stdcall user_alloc, PAGE_SIZE
|
||||||
mov edx, [current_slot]
|
mov edx, [current_slot]
|
||||||
mov [edx + APPDATA.tls_base], eax
|
mov [edx + APPDATA.tls_base], eax
|
||||||
mov [tls_data_l+2], ax
|
mov [tls_data_l+2], ax
|
||||||
|
Loading…
Reference in New Issue
Block a user