2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2024-12-23 06:18:47 +01:00

refactor: have debug logs show PCI device info as well

This commit is contained in:
ramenu 2024-04-21 17:10:09 -04:00
parent a4a57c3b44
commit ea51f45bc6

View File

@ -49,7 +49,6 @@ proc START c, reason:dword
ret ret
.err: .err:
DEBUGF DBG_INFO, "(NVMe) Cleaning up...\n"
call nvme_cleanup call nvme_cleanup
xor eax, eax xor eax, eax
ret ret
@ -135,7 +134,7 @@ proc detect_nvme
ret ret
.found_dev: .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 push eax
mov eax, dword [pcidevs_len] mov eax, dword [pcidevs_len]
cmp eax, MAX_NVM_PCIDEVS cmp eax, MAX_NVM_PCIDEVS
@ -170,8 +169,8 @@ proc detect_nvme
jmp .check_dev jmp .check_dev
.err: .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 ret
endp endp
@ -189,7 +188,9 @@ proc device_is_compat, bus:dword, devfn:dword
mov [p_mmap], eax mov [p_mmap], eax
.exit_fail: .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 endp
@ -200,10 +201,10 @@ proc nvme_init, bus:dword, devfn:dword
jz .exit_fail jz .exit_fail
mov eax, dword [p_mmap] mov eax, dword [p_mmap]
mov ebx, dword [eax + NVME_REG_MAP.CAP] 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 test ebx, CAP_CQR
jz .cqr_not_req 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: .cqr_not_req:
mov ebx, dword [eax + NVME_REG_MAP.CAP + 4] mov ebx, dword [eax + NVME_REG_MAP.CAP + 4]
@ -216,8 +217,8 @@ proc nvme_init, bus:dword, devfn:dword
and ecx, CAP_MPSMAX and ecx, CAP_MPSMAX
shr ebx, 16 shr ebx, 16
shr ecx, 16 shr ecx, 16
DEBUGF DBG_INFO, "(NVMe) Memory page size minimum: %u\n", ebx PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe memory page size minimum: %u\n", [bus], byte [devfn], ebx
DEBUGF DBG_INFO, "(NVMe) Memory page size maximum: %u\n", ecx 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 ebx, dword [eax + NVME_REG_MAP.CC]
mov ecx, ebx mov ecx, ebx
@ -227,8 +228,8 @@ proc nvme_init, bus:dword, devfn:dword
shl ecx, 16 shl ecx, 16
; TODO: Change entry sizes to their appropriate values ; TODO: Change entry sizes to their appropriate values
DEBUGF DBG_INFO, "(NVMe) I/O Submission Queue entry Size: %u\n", ebx PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe I/O submission queue entry size: %u\n", [bus], byte [devfn], ebx
DEBUGF DBG_INFO, "(NVMe) I/O completion queue entry size: %u\n", ecx PDEBUGF DBG_INFO, "PCI(%u.%u.%u): NVMe I/O completion queue entry size: %u\n", [bus], byte [devfn], ecx
end if end if
xor eax, eax xor eax, eax
@ -236,7 +237,7 @@ proc nvme_init, bus:dword, devfn:dword
ret ret
.exit_fail: .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 xor eax, eax
ret ret
@ -244,6 +245,7 @@ endp
proc nvme_cleanup proc nvme_cleanup
DEBUGF DBG_INFO, "(NVMe): Cleaning up...\n"
xor ecx, ecx xor ecx, ecx
mov eax, dword [p_nvme_devices] mov eax, dword [p_nvme_devices]
test eax, eax test eax, eax