mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2024-12-22 13:58:47 +01:00
add code for freeing cid slots
This commit is contained in:
parent
9c1147b31d
commit
3b1028b5dd
@ -702,31 +702,6 @@ proc nvme_wait stdcall, mmio:dword
|
||||
|
||||
endp
|
||||
|
||||
; Writes to submission queue 'y' tail doorbell
|
||||
proc sqytdbl_write stdcall, pci:dword, y:byte, sqt:word
|
||||
|
||||
push ebx esi
|
||||
mov esi, [pci]
|
||||
|
||||
; 1000h + (2y * (4 << CAP.DSTRD))
|
||||
mov ecx, dword [esi + pcidev.dstrd]
|
||||
mov eax, 4
|
||||
shl eax, cl
|
||||
mov cl, [y]
|
||||
xor ebx, ebx
|
||||
shl ebx, cl
|
||||
imul ebx, eax
|
||||
add ebx, 0x1000
|
||||
DEBUGF DBG_INFO, "(NVMe) Writing to submission queue 0x%x doorbell register\n", ebx
|
||||
|
||||
mov esi, [esi + pcidev.io_addr]
|
||||
mov ax, [sqt]
|
||||
mov word [esi + ebx], ax ; Write to register
|
||||
pop esi ebx
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
; Writes to completion queue 'y' head doorbell
|
||||
proc cqyhdbl_write stdcall, pci:dword, y:byte, cqh:word
|
||||
|
||||
@ -816,13 +791,56 @@ proc irq_handler
|
||||
; of a submission or completion queue (section 10.1 - page 400 of NVMe 1.4 spec)
|
||||
stdcall nvme_controller_reset, esi
|
||||
stdcall nvme_controller_start, esi
|
||||
jmp .exit
|
||||
jmp .cleanup
|
||||
|
||||
@@:
|
||||
stdcall cqyhdbl_write, [p_nvme_devices], 0x0, 0x1
|
||||
|
||||
.cleanup:
|
||||
; Mark this CID as unused in the bitmap
|
||||
xor eax, eax
|
||||
inc eax
|
||||
mov cl, byte [edi + CQ_ENTRY.cid]
|
||||
shl eax, cl
|
||||
movzx ecx, word [edi + CQ_ENTRY.sqid]
|
||||
imul ecx, sizeof.NVM_QUEUE_ENTRY
|
||||
mov esi, dword [p_nvme_devices]
|
||||
mov esi, dword [esi + pcidev.queue_entries]
|
||||
lea esi, dword [esi + ecx]
|
||||
DEBUGF DBG_INFO, "(NVMe) Freeing CID: %u - 1\n", eax
|
||||
not eax
|
||||
cmp word [edi + CQ_ENTRY.cid], 32
|
||||
jge @f
|
||||
if __DEBUG__
|
||||
not eax
|
||||
test dword [esi + NVM_QUEUE_ENTRY.cid_slots], eax
|
||||
jnz .not_fail0
|
||||
DEBUGF DBG_INFO, "(NVMe) BUG: CID %u is supposed to be taken\n", cl
|
||||
.fail0:
|
||||
jmp .fail0
|
||||
.not_fail0:
|
||||
end if
|
||||
and dword [esi + NVM_QUEUE_ENTRY.cid_slots], eax
|
||||
jmp .end
|
||||
|
||||
@@:
|
||||
if __DEBUG__
|
||||
not eax
|
||||
test dword [esi + NVM_QUEUE_ENTRY.cid_slots], eax
|
||||
jnz .not_fail1
|
||||
DEBUGF DBG_INFO, "(NVMe) BUG: CID %u is supposed to be taken\n", cl
|
||||
.fail1:
|
||||
jmp .fail0
|
||||
.not_fail1:
|
||||
end if
|
||||
and dword [esi + NVM_QUEUE_ENTRY.cid_slots + 4], eax
|
||||
|
||||
.end:
|
||||
|
||||
mov esi, dword [p_nvme_devices]
|
||||
mov esi, dword [esi + pcidev.io_addr]
|
||||
mov dword [esi + NVME_MMIO.INTMC], 0x1
|
||||
|
||||
.exit:
|
||||
; Interrupt handled by driver, return 1
|
||||
xor eax, eax
|
||||
inc eax
|
||||
|
@ -310,9 +310,8 @@ struct pcidev
|
||||
cq_ptr dd ?
|
||||
queue_entries dd ?
|
||||
version dd ?
|
||||
pc db ?
|
||||
dstrd db ?
|
||||
rb 2 ; align
|
||||
dstrd db ?
|
||||
rb 3 ; align
|
||||
serial dt ?, ?
|
||||
model dt ?, ?, ?, ?
|
||||
ends
|
||||
|
Loading…
Reference in New Issue
Block a user