2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2024-11-09 18:10:33 +01:00

refactor: rename nvme_controller_reset and nvme_controller_start

This commit is contained in:
Abdur-Rahman Mansoor 2024-08-06 11:57:46 -04:00
parent b2b0ca743d
commit 3c3bd6bd6f

View File

@ -685,7 +685,7 @@ proc nvme_init stdcall, pci:dword
; Reset controller before we configure it
test dword [edi + NVME_MMIO.CC], CC_EN
jz @f
stdcall nvme_controller_reset, esi
stdcall nvme_disable_ctrl, esi
@@:
mov eax, dword [edi + NVME_MMIO.CAP + 4]
@ -711,8 +711,7 @@ proc nvme_init stdcall, pci:dword
mov dword [edi + NVME_MMIO.CC], eax
; Configure Admin Queue Attributes
mov eax, dword [edi + NVME_MMIO.AQA]
and eax, not (AQA_ASQS or AQA_ACQS)
xor eax, eax
or eax, NVM_ASQS or (NVM_ACQS shl 16)
mov dword [edi + NVME_MMIO.AQA], eax
DEBUGF DBG_INFO, "nvme%u: Admin queue attributes: 0x%x\n", [esi + pcidev.num], eax
@ -813,7 +812,7 @@ proc nvme_init stdcall, pci:dword
DEBUGF DBG_INFO, "nvme%u: Successfully attached interrupt handler\n", [esi + pcidev.num]
; Restart the controller
stdcall nvme_controller_start, esi
stdcall nvme_enable_ctrl, esi
invoke KernelAlloc, 0x1000
test eax, eax
@ -1004,12 +1003,12 @@ proc get_new_cid stdcall, pci:dword, y:dword
endp
proc nvme_controller_reset stdcall, pci:dword
proc nvme_disable_ctrl stdcall, pci:dword
; TODO: Add timeout of CAP.TO seconds
push esi edi
mov esi, [pci]
DEBUGF DBG_INFO, "nvme%u: Resetting Controller...\n", [esi + pcidev.num]
DEBUGF DBG_INFO, "nvme%u: Disabling Controller...\n", [esi + pcidev.num]
mov edi, dword [esi + pcidev.io_addr]
and dword [edi + NVME_MMIO.CC], 0xfffffffe ; CC.EN = 0
@ -1017,18 +1016,18 @@ proc nvme_controller_reset stdcall, pci:dword
.wait:
test dword [edi + NVME_MMIO.CSTS], CSTS_RDY
jnz .wait
DEBUGF DBG_INFO, "nvme%u: Successfully reset controller...\n", [esi + pcidev.num]
DEBUGF DBG_INFO, "nvme%u: Successfully disabled controller\n", [esi + pcidev.num]
pop edi esi
ret
endp
proc nvme_controller_start stdcall, pci:dword
proc nvme_enable_ctrl stdcall, pci:dword
; TODO: Add timeout of CAP.TO seconds
push esi edi
mov esi, [pci]
DEBUGF DBG_INFO, "nvme%u: Starting Controller...\n", [esi + pcidev.num]
DEBUGF DBG_INFO, "nvme%u: Enabling Controller...\n", [esi + pcidev.num]
mov edi, dword [esi + pcidev.io_addr]
or dword [edi + NVME_MMIO.CC], 1 ; CC.EN = 1
@ -1036,7 +1035,7 @@ proc nvme_controller_start stdcall, pci:dword
.wait:
test dword [edi + NVME_MMIO.CSTS], CSTS_RDY
jz .wait
DEBUGF DBG_INFO, "nvme%u: Successfully started controller...\n", [esi + pcidev.num]
DEBUGF DBG_INFO, "nvme%u: Successfully enabled controller\n", [esi + pcidev.num]
pop edi esi
ret