From ea51f45bc60f989e15bf5c7be0b18af5533a1861 Mon Sep 17 00:00:00 2001 From: ramenu Date: Sun, 21 Apr 2024 17:10:09 -0400 Subject: [PATCH] refactor: have debug logs show PCI device info as well --- drivers/nvme/nvme.asm | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/nvme/nvme.asm b/drivers/nvme/nvme.asm index 24893c1..b609c25 100644 --- a/drivers/nvme/nvme.asm +++ b/drivers/nvme/nvme.asm @@ -49,7 +49,6 @@ proc START c, reason:dword ret .err: - DEBUGF DBG_INFO, "(NVMe) Cleaning up...\n" call nvme_cleanup xor eax, eax ret @@ -135,7 +134,7 @@ proc detect_nvme ret .found_dev: - PCI_DEBUGF DBG_INFO, eax, "PCI(%u.%u.%u): Detected NVMe device...\n" + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): Detected NVMe device...\n", [eax + PCIDEV.bus], byte [eax + PCIDEV.devfn] push eax mov eax, dword [pcidevs_len] cmp eax, MAX_NVM_PCIDEVS @@ -170,8 +169,8 @@ proc detect_nvme jmp .check_dev .err: - DEBUGF DBG_INFO, "error initializing NVMe driver: unable to allocate memory\n" - pop eax + pop eax + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): error initializing NVMe driver, unable to allocate memory\n", [eax + PCIDEV.bus], byte [eax + PCIDEV.devfn] ret endp @@ -189,7 +188,9 @@ proc device_is_compat, bus:dword, devfn:dword mov [p_mmap], eax .exit_fail: - DEBUGF DBG_INFO, "(NVMe) Device is incompatible\n" + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): incompatible NVMe device\n", [bus], byte [devfn] + xor eax, eax + ret endp @@ -200,10 +201,10 @@ proc nvme_init, bus:dword, devfn:dword jz .exit_fail mov eax, dword [p_mmap] mov ebx, dword [eax + NVME_REG_MAP.CAP] - DEBUGF DBG_INFO, "(NVMe) Maximum queue entries supported: %u\n", bx + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe maximum queue entries supported: %u\n", [bus], byte [devfn], bx test ebx, CAP_CQR jz .cqr_not_req - DEBUGF DBG_INFO, "(NVMe) Contiguous queues required\n" + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe contiguous queues required\n", [bus], byte [devfn] .cqr_not_req: mov ebx, dword [eax + NVME_REG_MAP.CAP + 4] @@ -216,8 +217,8 @@ proc nvme_init, bus:dword, devfn:dword and ecx, CAP_MPSMAX shr ebx, 16 shr ecx, 16 - DEBUGF DBG_INFO, "(NVMe) Memory page size minimum: %u\n", ebx - DEBUGF DBG_INFO, "(NVMe) Memory page size maximum: %u\n", ecx + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe memory page size minimum: %u\n", [bus], byte [devfn], ebx + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe memory page size maximum: %u\n", [bus], byte [devfn], ecx mov ebx, dword [eax + NVME_REG_MAP.CC] mov ecx, ebx @@ -227,8 +228,8 @@ proc nvme_init, bus:dword, devfn:dword shl ecx, 16 ; TODO: Change entry sizes to their appropriate values - DEBUGF DBG_INFO, "(NVMe) I/O Submission Queue entry Size: %u\n", ebx - DEBUGF DBG_INFO, "(NVMe) I/O completion queue entry size: %u\n", ecx + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe I/O submission queue entry size: %u\n", [bus], byte [devfn], ebx + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe I/O completion queue entry size: %u\n", [bus], byte [devfn], ecx end if xor eax, eax @@ -236,7 +237,7 @@ proc nvme_init, bus:dword, devfn:dword ret .exit_fail: - DEBUGF DBG_INFO, "ERROR: failed to initialize NVMe controller\n" + PDEBUGF DBG_INFO, "PCI(%u.%u.%u): failed to initialize NVMe controller\n", [bus], byte [devfn] xor eax, eax ret @@ -244,6 +245,7 @@ endp proc nvme_cleanup + DEBUGF DBG_INFO, "(NVMe): Cleaning up...\n" xor ecx, ecx mov eax, dword [p_nvme_devices] test eax, eax