mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2025-01-08 22:16:13 +01:00
wip: setup controller configuration
This commit is contained in:
parent
a940d7e963
commit
d172666be2
@ -231,6 +231,10 @@ proc nvme_init stdcall, pci:dword
|
|||||||
DEBUGF DBG_INFO, "(NVMe) CAP (0-31): 0x%x\n", ebx
|
DEBUGF DBG_INFO, "(NVMe) CAP (0-31): 0x%x\n", ebx
|
||||||
mov ebx, dword [eax + NVME_MMIO.CAP + 4]
|
mov ebx, dword [eax + NVME_MMIO.CAP + 4]
|
||||||
DEBUGF DBG_INFO, "(NVMe) CAP (32-63): 0x%x\n", ebx
|
DEBUGF DBG_INFO, "(NVMe) CAP (32-63): 0x%x\n", ebx
|
||||||
|
mov ebx, dword [eax + NVME_MMIO.CC]
|
||||||
|
DEBUGF DBG_INFO, "(NVMe) CC: 0x%x\n", ebx
|
||||||
|
mov ebx, dword [eax + NVME_MMIO.CSTS]
|
||||||
|
DEBUGF DBG_INFO, "(NVMe) CSTS: 0x%x\n", ebx
|
||||||
end if
|
end if
|
||||||
|
|
||||||
mov ebx, dword [eax + NVME_MMIO.CAP]
|
mov ebx, dword [eax + NVME_MMIO.CAP]
|
||||||
@ -244,8 +248,25 @@ proc nvme_init stdcall, pci:dword
|
|||||||
test ebx, CAP_CSS_NVM_CMDSET
|
test ebx, CAP_CSS_NVM_CMDSET
|
||||||
jz .exit_fail
|
jz .exit_fail
|
||||||
|
|
||||||
; Reset controller
|
; Reset controller before we configure it
|
||||||
stdcall nvme_controller_reset, [pci]
|
stdcall nvme_controller_reset, [pci]
|
||||||
|
mov eax, [pci]
|
||||||
|
mov eax, [eax + pcidev.mmio_ptr]
|
||||||
|
mov ebx, dword [eax + NVME_MMIO.CC]
|
||||||
|
and ebx, CAP_MPSMAX
|
||||||
|
shr ebx, 20
|
||||||
|
cmp ebx, NVM_MPS
|
||||||
|
jl .exit_fail
|
||||||
|
|
||||||
|
; Configure IOSQES, IOCQES, MPS, CSS
|
||||||
|
mov ebx, dword [eax + NVME_MMIO.CC]
|
||||||
|
or ebx, (4 shl 16) or (6 shl 20)
|
||||||
|
and ebx, not (CC_MPS or CC_CSS)
|
||||||
|
mov dword [eax + NVME_MMIO.CC], ebx
|
||||||
|
|
||||||
|
; Configure Admin Queue Attributes
|
||||||
|
|
||||||
|
; Configure Admin Submission/Completion Queue Base Address
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
inc eax
|
inc eax
|
||||||
@ -266,15 +287,12 @@ proc nvme_controller_reset stdcall, pci:dword
|
|||||||
push ebx
|
push ebx
|
||||||
mov ebx, dword [pci]
|
mov ebx, dword [pci]
|
||||||
mov ebx, dword [ebx + pcidev.mmio_ptr]
|
mov ebx, dword [ebx + pcidev.mmio_ptr]
|
||||||
mov eax, dword [ebx + NVME_MMIO.CC]
|
and dword [ebx + NVME_MMIO.CC], 0xfffffffe
|
||||||
and eax, 0xfffffffe ; CC.EN = 0
|
|
||||||
mov dword [ebx + NVME_MMIO.CC], eax
|
|
||||||
stdcall nvme_wait, [pci]
|
stdcall nvme_wait, [pci]
|
||||||
|
|
||||||
; Wait for controller to be brought to idle state, CSTS.RDY should be cleared to 0 when this happens
|
; Wait for controller to be brought to idle state, CSTS.RDY should be cleared to 0 when this happens
|
||||||
.wait:
|
.wait:
|
||||||
mov eax, dword [ebx + NVME_MMIO.CSTS]
|
test dword [ebx + NVME_MMIO.CSTS], CSTS_RDY
|
||||||
test eax, CSTS_RDY
|
|
||||||
jnz .wait
|
jnz .wait
|
||||||
DEBUGF DBG_INFO, "(NVMe) Successfully reset controller...\n"
|
DEBUGF DBG_INFO, "(NVMe) Successfully reset controller...\n"
|
||||||
pop ebx
|
pop ebx
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
; Supported NVMe Controller Version
|
; Supported NVMe Controller Version
|
||||||
NVM_SUPPORTED_CONTROLLER_VERSION = 0x00010400 ; (v1.4)
|
NVM_SUPPORTED_CONTROLLER_VERSION = 0x00010400 ; (v1.4)
|
||||||
|
|
||||||
|
NVM_MPS = 0
|
||||||
|
|
||||||
; Opcodes for NVM commands
|
; Opcodes for NVM commands
|
||||||
NVM_CMD_FLUSH = 0x00
|
NVM_CMD_FLUSH = 0x00
|
||||||
NVM_CMD_WRITE = 0x01
|
NVM_CMD_WRITE = 0x01
|
||||||
|
Loading…
Reference in New Issue
Block a user