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

add more struct fields and change NVM_ASQS value

This commit is contained in:
Abdur-Rahman Mansoor 2024-05-28 17:55:06 -04:00
parent 3124682b45
commit ff1ebbc7c6
2 changed files with 61 additions and 3 deletions

View File

@ -279,14 +279,14 @@ proc nvme_init stdcall, pci:dword
mov dword [edi + NVME_MMIO.AQA], eax
; Configure Admin Submission/Completion Queue Base Address
invoke AllocPages, NVM_ASQS
invoke AllocPage
test eax, eax
jz .exit_fail
;or eax, PG_SW or PG_NOCACHE
mov dword [edi + NVME_MMIO.ASQ], eax
and dword [edi + NVME_MMIO.ASQ + 4], 0
DEBUGF DBG_INFO, "(NVMe) ASQ = 0x%x\n", eax
invoke AllocPages, NVM_ACQS
invoke AllocPage
test eax, eax
jz .exit_fail
;or eax, PG_SW or PG_NOCACHE
@ -362,6 +362,47 @@ proc nvme_wait stdcall, mmio:dword
endp
proc cq0thbl_write stdcall, dstrd:dword
; 1000h + (2 * (4 << CAP.DSTRD))
mov eax, [dstrd]
shl eax, 4
imul eax, 2
add eax, 0x1000
ret
endp
proc get_dstrd stdcall, pci:dword
; Stride is (2 ^ (2 + DSTRD)) bytes
mov eax, [pci]
mov eax, dword [eax + pcidev.mmio_ptr]
mov eax, dword [eax + NVME_MMIO.CAP + 4]
and eax, CAP_DSTRD
add eax, 2
stdcall pow2, eax
ret
endp
; Calculates 2^x
proc pow2 stdcall, x:dword
push ecx
mov ecx, [x]
mov eax, 2
@@:
shl eax, 1
dec ecx
test ecx, ecx
jnz @b
pop ecx
ret
endp
proc nvme_cleanup
DEBUGF DBG_INFO, "(NVMe): Cleaning up...\n"

View File

@ -12,7 +12,7 @@
NVM_SUPPORTED_CONTROLLER_VERSION = 0x00010400 ; (v1.4.0)
NVM_MPS = 0 ; Memory Page Size (2 ^ (12 + MPS))
NVM_ASQS = 2 ; Admin Submission Queue Size
NVM_ASQS = 64 ; Admin Submission Queue Size
NVM_ACQS = NVM_ASQS ; Admin Completion Queue Size
; Opcodes for NVM commands
@ -184,6 +184,20 @@ struct NVME_MMIO
ASQ dq ? ; Admin Submission Queue Base Address
ACQ dq ? ; Admin Completion Queue Base Address
CMBLOC dd ? ; Controller Memory Buffer Location
CMBSZ dd ? ; Controller Memory Buffer Size
BPINFO dd ? ; Boot Partition Information
BPRSEL dd ? ; Boot Partition Read Select
BPMBL dq ? ; Boot Partition Memory Buffer Location
CMBMSC dd ? ; Controller Memory Buffer Memory Space
CMBSTS dd ? ; Controller Memory Buffer Status
rb 3491 ; Reserved
PMRCAP dd ? ; Persistent Memory Capabilities
PMRCTL dd ? ; Persistent Memory Region Control
PMRSTS dd ? ; Persistent Memory Region Status
PMREBS dd ? ; Persistent Memory Region Elasticity Buffer Size
PMRSWTP dd ? ; Persistent Memory Region Sustained Write Throughput
PMRMSC dq ? ; Persistent Memory Region Controller Memory Space Control
SQ0TDBL dd ? ; Submission Queue 0 Tail Doorbell (Admin)
ends
; Submission Queue Entry (64 bytes)
@ -217,6 +231,9 @@ struct pcidev
devfn db ?
rw 1
mmio_ptr dd ?
sq_ptr dd ?
cq_ptr dd ?
ends
TOTAL_PCIDEVS = 4
TOTAL_PCIDEVS_MALLOC_SZ = TOTAL_PCIDEVS * sizeof.pcidev