mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2025-02-08 13:16:52 +01:00
perf: remove some unneeded code bloat
This commit is contained in:
parent
1b88a4ff17
commit
39dcfd2edc
@ -565,48 +565,48 @@ endp
|
|||||||
|
|
||||||
proc alloc_dptr stdcall, ns:dword, prps_ptr:dword, numsectors:dword, prp_list_ptr:dword, buf:dword
|
proc alloc_dptr stdcall, ns:dword, prps_ptr:dword, numsectors:dword, prp_list_ptr:dword, buf:dword
|
||||||
|
|
||||||
push esi edi
|
push ebx esi edi
|
||||||
|
mov esi, [ns]
|
||||||
|
|
||||||
; the pointer to our PRP list (virtual), needed so
|
; the pointer to our PRP list (virtual), needed so
|
||||||
; that the caller can free the PRP list afterwards
|
; that the caller can free the PRP list afterwards
|
||||||
mov edi, [prp_list_ptr]
|
mov edi, [prp_list_ptr]
|
||||||
mov dword [edi], 0
|
mov dword [edi], 0
|
||||||
|
|
||||||
mov edi, [prps_ptr]
|
mov edi, [prps_ptr]
|
||||||
mov dword [edi], 0 ; PRP1 default value
|
|
||||||
mov dword [edi + 4], 0 ; PRP2 default value
|
mov dword [edi + 4], 0 ; PRP2 default value
|
||||||
mov eax, [buf]
|
mov eax, [buf]
|
||||||
invoke GetPhysAddr
|
invoke GetPhysAddr
|
||||||
mov dword [edi], eax
|
mov dword [edi], eax
|
||||||
mov edx, [numsectors]
|
mov cl, byte [esi + NSINFO.lbads]
|
||||||
|
mov ebx, PAGE_SIZE
|
||||||
|
shr ebx, cl
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
mov [numsectors], 0
|
cmp eax, ebx
|
||||||
cmp eax, dword [esi + NSINFO.pg_sectors]
|
|
||||||
jbe @f
|
jbe @f
|
||||||
sub eax, dword [esi + NSINFO.pg_sectors]
|
sub eax, ebx
|
||||||
mov [numsectors], eax
|
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
|
mov edx, [numsectors]
|
||||||
mov esi, [ns]
|
|
||||||
mov eax, dword [esi + NSINFO.pg_sectors]
|
|
||||||
|
|
||||||
; is the buffer offset portion equal to 0?
|
; is the buffer offset portion equal to 0?
|
||||||
mov ecx, [buf]
|
mov eax, [buf]
|
||||||
and ecx, PAGE_SIZE - 1
|
mov ecx, eax
|
||||||
|
and eax, PAGE_SIZE - 1
|
||||||
jnz @f
|
jnz @f
|
||||||
|
|
||||||
; is the number of sectors less than or equal to one memory page?
|
; is the number of sectors less than or equal to one memory page?
|
||||||
cmp edx, eax
|
cmp edx, ebx
|
||||||
jbe .success
|
jbe .success
|
||||||
shl eax, 1 ; it is page aligned, so set eax to 2 memory pages
|
shl eax, 1 ; it is page aligned, so set eax to 2 memory pages
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
; is the number of sectors greater than one or two memory pages?
|
; is the number of sectors greater than one or two memory pages?
|
||||||
cmp edx, eax
|
cmp edx, ebx
|
||||||
ja .build_prp_list
|
ja .build_prp_list
|
||||||
|
|
||||||
; set PRP2
|
; set PRP2
|
||||||
mov eax, dword [buf]
|
mov eax, ecx
|
||||||
and eax, not (PAGE_SIZE - 1)
|
and eax, not (PAGE_SIZE - 1)
|
||||||
add eax, PAGE_SIZE
|
add eax, PAGE_SIZE
|
||||||
invoke GetPhysAddr
|
invoke GetPhysAddr
|
||||||
@ -614,40 +614,29 @@ proc alloc_dptr stdcall, ns:dword, prps_ptr:dword, numsectors:dword, prp_list_pt
|
|||||||
jmp .success
|
jmp .success
|
||||||
|
|
||||||
.build_prp_list:
|
.build_prp_list:
|
||||||
DEBUGF DBG_INFO, "Allocating PRP list\n"
|
xchg ecx, ebx
|
||||||
; allocate PRP list for PRP2
|
and ebx, not (PAGE_SIZE - 1)
|
||||||
|
add ebx, PAGE_SIZE
|
||||||
mov eax, [numsectors]
|
mov eax, [numsectors]
|
||||||
mov ecx, dword [esi + NSINFO.pg_sectors]
|
mov ecx, ebx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
div ecx
|
div ecx
|
||||||
;test edx, edx
|
stdcall build_prp_list, eax, ebx, [prp_list_ptr]
|
||||||
;jz @f
|
|
||||||
;inc eax
|
|
||||||
;test eax, eax
|
|
||||||
;jz @f
|
|
||||||
;dec eax
|
|
||||||
|
|
||||||
@@:
|
|
||||||
mov edx, [buf]
|
|
||||||
and edx, not (PAGE_SIZE - 1)
|
|
||||||
add edx, PAGE_SIZE
|
|
||||||
stdcall build_prp_list, eax, edx, [prp_list_ptr]
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err
|
jz .err
|
||||||
mov dword [edi + 4], eax
|
mov dword [edi + 4], eax
|
||||||
jmp .success
|
|
||||||
|
|
||||||
.err:
|
|
||||||
xor eax, eax
|
|
||||||
pop edi esi
|
|
||||||
ret
|
|
||||||
|
|
||||||
.success:
|
.success:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
inc eax
|
inc eax
|
||||||
pop edi esi
|
pop edi esi ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.err:
|
||||||
|
xor eax, eax
|
||||||
|
pop edi esi ebx
|
||||||
|
ret
|
||||||
|
|
||||||
endp
|
endp
|
||||||
|
|
||||||
nvme_read:
|
nvme_read:
|
||||||
@ -1120,10 +1109,6 @@ proc nvme_init stdcall, pci:dword
|
|||||||
jne .exit_fail
|
jne .exit_fail
|
||||||
|
|
||||||
mov dword [ebx + NSINFO.lbads], eax
|
mov dword [ebx + NSINFO.lbads], eax
|
||||||
mov eax, PAGE_SIZE
|
|
||||||
mov cl, dl
|
|
||||||
shr eax, cl
|
|
||||||
mov dword [ebx + NSINFO.pg_sectors], eax
|
|
||||||
invoke KernelFree, edi
|
invoke KernelFree, edi
|
||||||
if 0
|
if 0
|
||||||
invoke KernelAlloc, 0x6000
|
invoke KernelAlloc, 0x6000
|
||||||
|
@ -311,10 +311,9 @@ ends
|
|||||||
struct NSINFO
|
struct NSINFO
|
||||||
capacity dq ?
|
capacity dq ?
|
||||||
size dq ?
|
size dq ?
|
||||||
lbads dd ?
|
|
||||||
nsid dd ?
|
nsid dd ?
|
||||||
pg_sectors dd ? ; how many sectors equal 1 page?
|
|
||||||
pci dd ?
|
pci dd ?
|
||||||
|
lbads db ?
|
||||||
features db ?
|
features db ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user