mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2024-12-22 05:48:47 +01:00
refactor: use named constants for queue allocation
This commit is contained in:
parent
4cbae17ecf
commit
b2b0ca743d
@ -701,13 +701,12 @@ proc nvme_init stdcall, pci:dword
|
|||||||
DEBUGF DBG_INFO, "nvme%u: OK... memory page size supported\n", [esi + pcidev.num]
|
DEBUGF DBG_INFO, "nvme%u: OK... memory page size supported\n", [esi + pcidev.num]
|
||||||
|
|
||||||
; Configure IOSQES, IOCQES, AMS, MPS, CSS
|
; Configure IOSQES, IOCQES, AMS, MPS, CSS
|
||||||
and dword [edi + NVME_MMIO.CC], not (CC_AMS or CC_MPS or CC_CSS or CC_IOSQES or CC_IOCQES)
|
|
||||||
mov eax, dword [edi + NVME_MMIO.CC]
|
|
||||||
; CSS = 0 (NVM Command Set)
|
; CSS = 0 (NVM Command Set)
|
||||||
; AMS = 0 (Round Robin)
|
; AMS = 0 (Round Robin)
|
||||||
; MPS = 0 (4KiB Pages)
|
; MPS = 0 (4KiB Pages)
|
||||||
; IOSQES = 6 (64B)
|
; IOSQES = 6 (64B)
|
||||||
; IOCQES = 4 (16B)
|
; IOCQES = 4 (16B)
|
||||||
|
xor eax, eax
|
||||||
or eax, (4 shl 20) or (6 shl 16)
|
or eax, (4 shl 20) or (6 shl 16)
|
||||||
mov dword [edi + NVME_MMIO.CC], eax
|
mov dword [edi + NVME_MMIO.CC], eax
|
||||||
|
|
||||||
@ -730,26 +729,26 @@ proc nvme_init stdcall, pci:dword
|
|||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
|
|
||||||
.init_queues:
|
.init_queues:
|
||||||
invoke AllocPages, 2
|
invoke AllocPages, QUEUE_ALLOC_SIZE / PAGE_SIZE
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .exit_fail
|
jz .exit_fail
|
||||||
or eax, PG_SW+PG_NOCACHE
|
or eax, PG_SW+PG_NOCACHE
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
invoke KernelAlloc, 0x2000
|
invoke KernelAlloc, QUEUE_ALLOC_SIZE
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .exit_fail
|
jz .exit_fail
|
||||||
mov dword [edi + ebx + NVM_QUEUE_ENTRY.cq_ptr], eax
|
mov dword [edi + ebx + NVM_QUEUE_ENTRY.cq_ptr], eax
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
mov eax, esi
|
mov eax, esi
|
||||||
mov ecx, 2
|
mov ecx, QUEUE_ALLOC_SIZE / PAGE_SIZE
|
||||||
invoke CommitPages
|
invoke CommitPages
|
||||||
pop ebx
|
pop ebx
|
||||||
mov eax, dword [edi + ebx + NVM_QUEUE_ENTRY.cq_ptr]
|
mov eax, dword [edi + ebx + NVM_QUEUE_ENTRY.cq_ptr]
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
add eax, 0x1000
|
add eax, CQ_ALLOC_SIZE
|
||||||
mov dword [edi + ebx + NVM_QUEUE_ENTRY.sq_ptr], eax
|
mov dword [edi + ebx + NVM_QUEUE_ENTRY.sq_ptr], eax
|
||||||
stdcall memsetdz, edx, 0x2000 / 4
|
stdcall memsetdz, edx, QUEUE_ALLOC_SIZE / 4
|
||||||
|
|
||||||
; Initialize command entries
|
; Initialize command entries
|
||||||
invoke KernelAlloc, sizeof.NVMQCMD * CQ_ENTRIES
|
invoke KernelAlloc, sizeof.NVMQCMD * CQ_ENTRIES
|
||||||
|
Loading…
Reference in New Issue
Block a user