Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36854f1382 | ||
|
|
f990a48b98 | ||
|
|
fb2906bc1d | ||
|
|
9c58dc1f04 |
No files matched your search
@@ -463,7 +463,7 @@ proc kernel_alloc stdcall, size:dword
|
|||||||
and eax, -PAGE_SIZE;
|
and eax, -PAGE_SIZE;
|
||||||
mov [size], eax
|
mov [size], eax
|
||||||
and eax, eax
|
and eax, eax
|
||||||
jz .err
|
jz .err0
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
shr ebx, 12
|
shr ebx, 12
|
||||||
mov [pages_count], ebx
|
mov [pages_count], ebx
|
||||||
@@ -509,6 +509,13 @@ proc kernel_alloc stdcall, size:dword
|
|||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
.err:
|
.err:
|
||||||
|
mov eax, [lin_addr]
|
||||||
|
test eax, eax
|
||||||
|
jz .err0
|
||||||
|
mov ecx, [pages_count]
|
||||||
|
call release_pages
|
||||||
|
stdcall free_kernel_space, [lin_addr]
|
||||||
|
.err0:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop edi
|
pop edi
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|||||||
@@ -1397,7 +1397,9 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
|
|||||||
mov [page_tabs + edi], eax
|
mov [page_tabs + edi], eax
|
||||||
mov [page_tabs + edi + edx], eax
|
mov [page_tabs + edi + edx], eax
|
||||||
invlpg [ebx]
|
invlpg [ebx]
|
||||||
invlpg [ebx+0x10000]
|
add ebx, [size]
|
||||||
|
invlpg [ebx] ; the mirror half
|
||||||
|
sub ebx, [size]
|
||||||
add eax, 0x1000
|
add eax, 0x1000
|
||||||
add ebx, 0x1000
|
add ebx, 0x1000
|
||||||
add edi, 4
|
add edi, 4
|
||||||
@@ -1416,6 +1418,62 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
; Same as create_ring_buffer, but from non-contiguous pages.
|
||||||
|
; Not for DMA. Free with kernel_free.
|
||||||
|
align 4
|
||||||
|
proc create_ring_buffer_sparse stdcall, size:dword, flags:dword
|
||||||
|
locals
|
||||||
|
buf_ptr dd ?
|
||||||
|
endl
|
||||||
|
|
||||||
|
mov eax, [size]
|
||||||
|
test eax, eax
|
||||||
|
jz .fail
|
||||||
|
|
||||||
|
add eax, eax
|
||||||
|
stdcall alloc_kernel_space, eax
|
||||||
|
test eax, eax
|
||||||
|
jz .fail
|
||||||
|
mov [buf_ptr], eax
|
||||||
|
|
||||||
|
push ebx esi edi
|
||||||
|
mov ebx, eax ; page being mapped
|
||||||
|
mov esi, [size] ; distance to its mirror
|
||||||
|
mov edi, esi
|
||||||
|
shr edi, 12 ; pages left
|
||||||
|
.page:
|
||||||
|
call alloc_page
|
||||||
|
test eax, eax
|
||||||
|
jz .mm_fail
|
||||||
|
or eax, [flags]
|
||||||
|
mov edx, ebx
|
||||||
|
shr edx, 12
|
||||||
|
mov [page_tabs + edx*4], eax
|
||||||
|
invlpg [ebx]
|
||||||
|
lea edx, [ebx + esi]
|
||||||
|
shr edx, 12
|
||||||
|
mov [page_tabs + edx*4], eax
|
||||||
|
invlpg [ebx + esi]
|
||||||
|
add ebx, PAGE_SIZE
|
||||||
|
dec edi
|
||||||
|
jnz .page
|
||||||
|
|
||||||
|
mov eax, [buf_ptr]
|
||||||
|
pop edi esi ebx
|
||||||
|
ret
|
||||||
|
|
||||||
|
.mm_fail:
|
||||||
|
mov eax, [buf_ptr]
|
||||||
|
mov ecx, [size]
|
||||||
|
shr ecx, 11 ; both halves, in pages
|
||||||
|
call release_pages
|
||||||
|
stdcall free_kernel_space, [buf_ptr]
|
||||||
|
pop edi esi ebx
|
||||||
|
xor eax, eax
|
||||||
|
.fail:
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc print_mem
|
proc print_mem
|
||||||
|
|||||||
@@ -198,6 +198,10 @@ ends
|
|||||||
|
|
||||||
SOCKET_STRUCT_SIZE = 4096 ; in bytes
|
SOCKET_STRUCT_SIZE = 4096 ; in bytes
|
||||||
|
|
||||||
|
if sizeof.STREAM_SOCKET > SOCKET_STRUCT_SIZE
|
||||||
|
err "STREAM_SOCKET does not fit in SOCKET_STRUCT_SIZE"
|
||||||
|
end if
|
||||||
|
|
||||||
SOCKET_QUEUE_SIZE = 10 ; maximum number of incoming packets queued for 1 socket
|
SOCKET_QUEUE_SIZE = 10 ; maximum number of incoming packets queued for 1 socket
|
||||||
; the incoming packet queue for sockets is placed in the socket struct itself, at this location from start
|
; the incoming packet queue for sockets is placed in the socket struct itself, at this location from start
|
||||||
SOCKET_QUEUE_LOCATION = (SOCKET_STRUCT_SIZE - SOCKET_QUEUE_SIZE*sizeof.socket_queue_entry - sizeof.queue)
|
SOCKET_QUEUE_LOCATION = (SOCKET_STRUCT_SIZE - SOCKET_QUEUE_SIZE*sizeof.socket_queue_entry - sizeof.queue)
|
||||||
@@ -1647,7 +1651,7 @@ socket_ring_create:
|
|||||||
mov esi, eax
|
mov esi, eax
|
||||||
|
|
||||||
push edx
|
push edx
|
||||||
stdcall create_ring_buffer, SOCKET_BUFFER_SIZE, PG_SWR
|
stdcall create_ring_buffer_sparse, SOCKET_BUFFER_SIZE, PG_SWR
|
||||||
pop edx
|
pop edx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|||||||
Reference in new issue
Block a user