From 2b9f8d7f37679aefbbe38b945b8a1e987228613c Mon Sep 17 00:00:00 2001 From: Abdur-Rahman Mansoor Date: Tue, 4 Jun 2024 14:44:06 -0400 Subject: [PATCH] feat: implement `create_io_completion_queue` --- drivers/nvme/nvme.asm | 28 ++++++++++++++++++++++++++++ drivers/nvme/nvme.inc | 2 ++ 2 files changed, 30 insertions(+) diff --git a/drivers/nvme/nvme.asm b/drivers/nvme/nvme.asm index 174c2ee..652ff9d 100644 --- a/drivers/nvme/nvme.asm +++ b/drivers/nvme/nvme.asm @@ -128,6 +128,34 @@ proc nvme_identify stdcall, pci:dword, slot:dword, nsid:dword, dptr:dword, cid:w endp +; See page 101 of the NVMe 1.4 specification for reference +proc create_io_completion_queue stdcall, pci:dword, prp1:dword, qid:word, ien:byte + + push esi ebx + mov esi, [pci] + + xor ebx, ebx + movzx eax, [ien] + and eax, 10b + or ebx, eax + movzx eax, byte [esi + pcidev.pc] + and eax, 0x1 + or ebx, eax ; CDW.PC + mov esi, [esi + pcidev.sq_ptr] + stdcall memset, esi, 0, sizeof.SQ_ENTRY + mov dword [esi + SQ_ENTRY.cdw11], ebx + mov bx, [qid] ; CDW10.QID + or ebx, (sizeof.CQ_ENTRY shl 16) ; CDW10.QSIZE + 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 diff --git a/drivers/nvme/nvme.inc b/drivers/nvme/nvme.inc index 6dbf271..a1fc5ef 100644 --- a/drivers/nvme/nvme.inc +++ b/drivers/nvme/nvme.inc @@ -237,6 +237,8 @@ struct pcidev sq_ptr dd ? cq_ptr dd ? dstrd dd ? + pc db ? + rb 3 ; align ends TOTAL_PCIDEVS = 4 TOTAL_PCIDEVS_MALLOC_SZ = TOTAL_PCIDEVS * sizeof.pcidev