2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2024-11-09 18:10:33 +01:00

perf: use memcpyd instead of memcpy

This commit is contained in:
Abdur-Rahman Mansoor 2024-08-01 12:02:07 -04:00
parent 7cc1601d90
commit 0cbf662a9f
2 changed files with 18 additions and 26 deletions

View File

@ -20,13 +20,13 @@ proc memsetdz stdcall, dest:dword, sz:dword
endp
proc memcpy stdcall, dest:dword, src:dword, sz:dword
proc memcpyd stdcall, dest:dword, src:dword, sz:dword
push esi edi
mov esi, [src]
mov edi, [dest]
mov ecx, [sz]
rep movsb
rep movsd
pop edi esi
ret

View File

@ -437,7 +437,7 @@ proc nvme_readwrite stdcall, ns:dword, buf:dword, start_sector:qword, numsectors
test eax, eax
jz .fail
DEBUGF DBG_INFO, "PRP1: %x, PRP2: %x\n", [ebx], [ebx + 4]
;DEBUGF DBG_INFO, "PRP1: %x, PRP2: %x\n", [ebx], [ebx + 4]
mov eax, dword [start_sector]
; According to the NVMe specification, the NLB field in the I/O read and write
@ -810,11 +810,11 @@ proc nvme_init stdcall, pci:dword
DEBUGF DBG_INFO, "nvme%u: Namespace Count: %u\n", [esi + pcidev.num], eax
lea ebx, byte [edi + IDENTC.sn]
lea eax, byte [esi + pcidev.serial]
stdcall memcpy, eax, ebx, 20
stdcall memcpyd, eax, ebx, 20 / 4
DEBUGF DBG_INFO, "nvme%u: Serial Number: %s\n", [esi + pcidev.num], eax
add ebx, 20
lea eax, byte [esi + pcidev.model]
stdcall memcpy, eax, ebx, 40
stdcall memcpyd, eax, ebx, 40 / 4
DEBUGF DBG_INFO, "nvme%u: Model: %s\n", [esi + pcidev.num], eax
mov edx, dword [esi + pcidev.version]
@ -862,7 +862,7 @@ proc nvme_init stdcall, pci:dword
mov esi, [pci]
mov edi, esi
mov esi, dword [esi + pcidev.queue_entries]
lea esi, [esi + sizeof.NVM_QUEUE_ENTRY]
add esi, sizeof.NVM_QUEUE_ENTRY
mov eax, dword [esi + NVM_QUEUE_ENTRY.cq_ptr]
invoke GetPhysAddr
stdcall create_io_completion_queue, [pci], eax, 1, IEN_ON
@ -1078,33 +1078,29 @@ proc sqytdbl_write stdcall, pci:dword, y:word, cmd:dword
push ebx esi edi
mov edi, [pci]
mov edi, dword [edi + pcidev.queue_entries]
movzx ecx, [y]
imul ecx, sizeof.NVM_QUEUE_ENTRY
;mov eax, dword [edi + ecx + NVM_QUEUE_ENTRY.cmd_ptr]
mov edi, dword [edi + ecx + NVM_QUEUE_ENTRY.sq_ptr]
movzx ebx, [y]
imul ebx, sizeof.NVM_QUEUE_ENTRY
lea edi, [edi + ebx]
;mov eax, dword [edi + NVM_QUEUE_ENTRY.cmd_ptr]
mov edx, dword [edi + NVM_QUEUE_ENTRY.sq_ptr]
mov esi, [cmd]
mov ecx, dword [esi + SQ_ENTRY.cdw0]
shr ecx, 16 ; Get CID
imul ecx, sizeof.SQ_ENTRY
lea edi, [edi + ecx]
;mov ecx, [eax + ecx + NVMQCMD.mutex_ptr]
lea edx, [edx + ecx]
;mov ecx, dword [eax + ecx + NVMQCMD.mutex_ptr]
;push ecx
stdcall memcpy, edi, esi, sizeof.SQ_ENTRY
stdcall memcpyd, edx, esi, sizeof.SQ_ENTRY / 4
;pop ecx
;invoke MutexLock
mov edi, [pci]
mov esi, dword [edi + pcidev.io_addr]
mov edi, dword [edi + pcidev.queue_entries]
movzx ecx, [y]
imul ecx, sizeof.NVM_QUEUE_ENTRY
movzx eax, word [edi + ecx + NVM_QUEUE_ENTRY.tail]
mov esi, [pci]
movzx eax, word [edi + NVM_QUEUE_ENTRY.tail]
cmp ax, (NVM_ASQS - 1)
jb @f
xor ax, ax
@@:
mov esi, [pci]
inc ax
; 1000h + (2y * (4 << CAP.DSTRD))
movzx ebx, [y]
@ -1114,14 +1110,10 @@ proc sqytdbl_write stdcall, pci:dword, y:word, cmd:dword
shl edx, cl
imul edx, ebx
add edx, 0x1000
;DEBUGF DBG_INFO, "nvme%u: Writing to submission queue tail doorbell 0x%x: %u\n", [esi + pcidev.num], edx, ax
DEBUGF DBG_INFO, "nvme%u: Writing to submission queue tail doorbell 0x%x: %u\n", [esi + pcidev.num], edx, ax
mov word [edi + NVM_QUEUE_ENTRY.tail], ax
mov esi, dword [esi + pcidev.io_addr]
mov word [esi + edx], ax
movzx ecx, [y]
imul ecx, sizeof.NVM_QUEUE_ENTRY
mov word [edi + ecx + NVM_QUEUE_ENTRY.tail], ax
dec ax
movzx ecx, [y]
pop edi esi ebx
ret