2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2025-09-21 09:30:08 +02:00

save changes for now

This commit is contained in:
2024-08-10 23:29:02 -04:00
parent 998d51f9e8
commit d4d59184fe

View File

@@ -48,7 +48,7 @@ local AnythingLoadedSuccessfully db 0
.entry: .entry:
DEBUGF DBG_INFO, "Detecting NVMe device...\n" DEBUGF DBG_INFO, "Detecting NVMe device...\n"
call detect_nvme stdcall detect_nvme, TRUE
test eax, eax test eax, eax
jz .err jz .err
xor ebx, ebx xor ebx, ebx
@@ -86,7 +86,7 @@ local AnythingLoadedSuccessfully db 0
ret ret
.err: .err:
;call nvme_cleanup call nvme_cleanup
pop edi esi pop edi esi
ret ret
@@ -505,7 +505,7 @@ proc nvme_readwrite stdcall, ns:dword, buf:dword, start_sector:qword, numsectors
endp endp
proc detect_nvme proc detect_nvme stdcall, exit_if_already_allocated:dword
invoke GetPCIList invoke GetPCIList
mov esi, eax mov esi, eax
@@ -527,7 +527,31 @@ proc detect_nvme
inc eax inc eax
ret ret
.pcidev_already_has_owner:
cmp dword [esi + PCIDEV.owner], 0
jnz .next_dev
mov eax, dword [p_nvme_devices]
test eax, eax
jnz @f
invoke KernelAlloc, sizeof.pcidev * TOTAL_PCIDEVS
test eax, eax
jz .err
@@:
mov ecx, dword [pcidevs_len]
cmp ecx, TOTAL_PCIDEVS
je .exit_success
inc ecx
mov dword [pcidevs_len], ecx
mov edx, dword [esi + PCIDEV.owner]
imul ecx, sizeof.pcidev
mov dword [eax + ecx], edx
jmp .next_dev
.found_dev: .found_dev:
cmp byte [exit_if_already_allocated], 0
je .pcidev_already_has_owner
; skip PCIDEV.owner check if the PCI device pointer has already been ; skip PCIDEV.owner check if the PCI device pointer has already been
; allocated (without this check, more than 1 NVMe device cannot be ; allocated (without this check, more than 1 NVMe device cannot be
; registered) ; registered)
@@ -540,11 +564,7 @@ proc detect_nvme
@@: @@:
PDEBUGF DBG_INFO, "PCI(%u.%u.%u): Detected NVMe device...\n", [esi + PCIDEV.bus], [esi + PCIDEV.devfn] PDEBUGF DBG_INFO, "PCI(%u.%u.%u): Detected NVMe device...\n", [esi + PCIDEV.bus], [esi + PCIDEV.devfn]
cmp dword [pcidevs_len], TOTAL_PCIDEVS cmp dword [pcidevs_len], TOTAL_PCIDEVS
jne @f je .exit_success
DEBUGF DBG_INFO, "Can't add any more NVMe devices...\n"
jmp .exit_success
@@:
inc dword [pcidevs_len] inc dword [pcidevs_len]
cmp dword [p_nvme_devices], 0 cmp dword [p_nvme_devices], 0
jnz @f ; was the pointer already allocated? jnz @f ; was the pointer already allocated?
@@ -1252,7 +1272,7 @@ endp
proc nvme_cleanup proc nvme_cleanup
DEBUGF DBG_INFO, "nvme_cleanup called\n" ;stdcall detect_nvme, FALSE
mov esi, dword [p_nvme_devices] mov esi, dword [p_nvme_devices]
test esi, esi test esi, esi
jnz @f jnz @f
@@ -1328,6 +1348,7 @@ proc nvme_cleanup
.free_pcidevs: .free_pcidevs:
invoke KernelFree, dword [p_nvme_devices] invoke KernelFree, dword [p_nvme_devices]
pop edi esi
ret ret
endp endp