diff --git a/drivers/nvme/nvme.asm b/drivers/nvme/nvme.asm index c9b4931..06f926e 100644 --- a/drivers/nvme/nvme.asm +++ b/drivers/nvme/nvme.asm @@ -710,10 +710,35 @@ proc nvme_init stdcall, pci:dword invoke GetPhysAddr stdcall create_io_submission_queue, [pci], eax, 1, 1 + if 1 stdcall determine_active_nsids, [pci] test eax, eax jz .exit_fail ; No active NSIDS + mov esi, [pci] + mov dword [esi + pcidev.nsid], eax DEBUGF DBG_INFO, "(NVMe) Found active NSID: %u\n", eax + else + mov esi, [pci] + xor eax, eax + inc eax + mov dword [esi + pcidev.nsid], eax + end if + invoke KernelAlloc, 0x1000 + test eax, eax + jz .exit_fail + mov edi, eax + invoke GetPhysAddr + stdcall nvme_identify, [pci], [esi + pcidev.nsid], eax, CNS_IDNS + mov al, byte [edi + IDENTN.nsfeat] + DEBUGF DBG_INFO, "(nvme%un%u): Namespace Features: 0x%x\n", 0, [esi + pcidev.nsid], al + DEBUGF DBG_INFO, "(nvme%un%u): Namespace Size: %u + %u logical blocks\n", 0, [esi + pcidev.nsid], [edi + IDENTN.nsze], [edi + IDENTN.nsze + 4] + DEBUGF DBG_INFO, "(nvme%un%u): Namespace Capacity: %u + %u logical blocks\n", 0, [esi + pcidev.nsid], [edi + IDENTN.ncap], [edi + IDENTN.ncap + 4] + mov eax, dword [edi + IDENTN.lbaf0] + shr eax, 16 ; Get LBADS + and eax, 0xff + stdcall pow2, eax + DEBUGF DBG_INFO, "(nvme%un%u): Namespace LBA Data Size: %u\n", 0, [esi + pcidev.nsid], eax + invoke KernelFree, edi DEBUGF DBG_INFO, "(NVMe) Successfully initialized driver!\n" xor eax, eax diff --git a/drivers/nvme/nvme.inc b/drivers/nvme/nvme.inc index 87f213a..3a975c2 100644 --- a/drivers/nvme/nvme.inc +++ b/drivers/nvme/nvme.inc @@ -311,7 +311,7 @@ struct pcidev io_addr dd ? queue_entries dd ? version dd ? - nsids dd ? + nsid dd ? nn dd ? dstrd db ? rb 3 ; align