From d9e04ec7cdd00a27d4eb4b03a2dd28917d3b0b40 Mon Sep 17 00:00:00 2001 From: Abdur-Rahman Mansoor Date: Thu, 8 Aug 2024 15:23:39 -0400 Subject: [PATCH] fix: set bus master, memory space access, and I/O space access bit in PCI command register --- drivers/nvme/nvme.asm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/nvme/nvme.asm b/drivers/nvme/nvme.asm index 1fe3327..75bd176 100644 --- a/drivers/nvme/nvme.asm +++ b/drivers/nvme/nvme.asm @@ -605,10 +605,16 @@ proc nvme_init stdcall, pci:dword push ebx esi edi mov esi, dword [pci] + ; Check the PCI header to see if interrupts are disabled, if so ; we have to re-enable them invoke PciRead16, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.command and eax, not (1 shl 10) + ; Enable Bus Master bit, memory space access, and I/O space access. QEMU automatically sets the + ; bus master bit, but Virtualbox does not. Not sure about the other bits though, but let's set them + ; to 1 to anyway just to be extra cautious. + ; See: https://git.kolibrios.org/GSoC/kolibrios-nvme-driver/issues/1#issuecomment-467 + or eax, (1 shl 2) or (1 shl 1) or 1 invoke PciWrite16, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.command, eax ; Check if the device has a pointer to the capabilities list (status register bit 4 set to 1)