diff --git a/drivers/nvme/nvme.asm b/drivers/nvme/nvme.asm index 652ff9d..225d64b 100644 --- a/drivers/nvme/nvme.asm +++ b/drivers/nvme/nvme.asm @@ -143,6 +143,7 @@ proc create_io_completion_queue stdcall, pci:dword, prp1:dword, qid:word, ien:by or ebx, eax ; CDW.PC mov esi, [esi + pcidev.sq_ptr] stdcall memset, esi, 0, sizeof.SQ_ENTRY + ; Since we are not using MSI-X or MSI vector (yet), CDW11.IV must be set to 0 mov dword [esi + SQ_ENTRY.cdw11], ebx mov bx, [qid] ; CDW10.QID or ebx, (sizeof.CQ_ENTRY shl 16) ; CDW10.QSIZE @@ -156,6 +157,34 @@ proc create_io_completion_queue stdcall, pci:dword, prp1:dword, qid:word, ien:by endp +; See page 103-104 of the NVMe 1.4 specification for reference +proc create_io_submission_queue stdcall, pci:dword, prp1:dword, qid:word, cqid:word + + push esi ebx + mov esi, [pci] + + movzx ebx, byte [esi + pcidev.pc] + and ebx, 0x1 ; CDW11.PC + mov esi, [esi + pcidev.sq_ptr] + stdcall memset, esi, 0, sizeof.SQ_ENTRY + movzx eax, [cqid] + shl eax, 16 + or ebx, eax ; CDW11.CQID + ; TODO: Set CDW10.QPRIO + mov dword [esi + SQ_ENTRY.cdw11], ebx + movzx ebx, sizeof.SQ_ENTRY + shl ebx, 16 ; CDW10.QSIZE + or ebx, [qid] ; CDW10.QID + mov dword [esi + SQ_ENTRY.cdw10], ebx + mov ebx, [prp1] + mov dword [esi + SQ_ENTRY.dptr], ebx + stdcall sqytdbl_write, [pci], [qid], 0 ; setting last param to 0 for now, change later + + pop ebx esi + ret + +endp + proc detect_nvme invoke GetPCIList