2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2025-01-03 03:15:56 +01:00

fix: command wrapping

This commit is contained in:
Abdur-Rahman Mansoor 2024-08-10 13:05:28 -04:00
parent 37b926d2e1
commit f98d3b95b6

View File

@ -1128,13 +1128,13 @@ proc sqytdbl_write stdcall, pci:dword, y:word, cmd:dword
invoke MutexLock invoke MutexLock
mov esi, [pci] mov esi, [pci]
movzx eax, word [edi + NVM_QUEUE_ENTRY.tail] mov ax, word [edi + NVM_QUEUE_ENTRY.tail]
cmp ax, (NVM_ASQS - 1) inc ax
jb @f cmp ax, NVM_ASQS
jb @f
xor ax, ax xor ax, ax
@@: @@:
inc ax
; 1000h + (2y * (4 << CAP.DSTRD)) ; 1000h + (2y * (4 << CAP.DSTRD))
movzx ebx, [y] movzx ebx, [y]
shl ebx, 1 shl ebx, 1
@ -1194,30 +1194,17 @@ proc consume_cq_entries stdcall, pci:dword, queue:dword
shl ecx, SIZEOF_NVM_QUEUE_ENTRY shl ecx, SIZEOF_NVM_QUEUE_ENTRY
mov esi, dword [esi + pcidev.queue_entries] mov esi, dword [esi + pcidev.queue_entries]
lea esi, [esi + ecx] lea esi, [esi + ecx]
mov edi, dword [esi + NVM_QUEUE_ENTRY.cq_ptr]
movzx eax, word [esi + NVM_QUEUE_ENTRY.tail]
movzx ecx, word [esi + NVM_QUEUE_ENTRY.head] movzx ecx, word [esi + NVM_QUEUE_ENTRY.head]
;stdcall is_queue_full, eax, ecx
;test eax, eax
;jnz .end
movzx ecx, word [esi + NVM_QUEUE_ENTRY.head]
cmp ecx, (NVM_ACQS - 1)
jb .loop
xor ecx, ecx
mov word [esi + NVM_QUEUE_ENTRY.head], cx
.loop:
cmp cx, word [esi + NVM_QUEUE_ENTRY.tail] cmp cx, word [esi + NVM_QUEUE_ENTRY.tail]
je .end je .end
mov edx, ecx inc ecx
shl edx, SIZEOF_CQ_ENTRY cmp ecx, NVM_ACQS
mov ax, word [edi + edx + CQ_ENTRY.status] jb @f
;DEBUGF DBG_INFO, "Status: 0x%x\n", ax xor ecx, ecx
inc cx mov word [esi + NVM_QUEUE_ENTRY.head], cx
push ecx
@@:
stdcall cqyhdbl_write, [pci], [queue], ecx stdcall cqyhdbl_write, [pci], [queue], ecx
pop ecx
jmp .loop
.end: .end:
pop edi esi pop edi esi