mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2025-01-30 17:20:12 +01:00
initialize command entries
This commit is contained in:
parent
6a8ab65661
commit
a88a44c627
@ -963,7 +963,8 @@ proc nvme_init stdcall, pci:dword
|
||||
; Allocate submission/completion queue pointers
|
||||
; TODO: Make these queues physically contiguous
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
|
||||
.init_queues:
|
||||
push ecx
|
||||
invoke CreateRingBuffer, 0x1000, PG_SW
|
||||
pop ecx
|
||||
@ -979,10 +980,38 @@ proc nvme_init stdcall, pci:dword
|
||||
mov dword [edi + ecx + NVM_QUEUE_ENTRY.cq_ptr], eax
|
||||
push ecx
|
||||
stdcall memsetdz, eax, sizeof.CQ_ENTRY * CQ_ENTRIES / 4
|
||||
|
||||
; Initialize command entries
|
||||
invoke KernelAlloc, sizeof.NVMQCMD * CQ_ENTRIES
|
||||
pop ecx
|
||||
test eax, eax
|
||||
jz .exit_fail
|
||||
mov dword [edi + ecx + NVM_QUEUE_ENTRY.cmd_ptr], eax
|
||||
mov esi, eax
|
||||
push ecx
|
||||
xor ecx, ecx
|
||||
|
||||
.init_cmd_entries:
|
||||
push ecx
|
||||
; BUG: Won't pop ecx if allocation fails
|
||||
invoke KernelAlloc, sizeof.MUTEX
|
||||
test eax, eax
|
||||
jz .exit_fail
|
||||
pop ecx
|
||||
mov dword [esi + ecx * NVMQCMD.mutex_ptr], eax
|
||||
mov dword [esi + ecx * NVMQCMD.cid], ecx
|
||||
push ecx
|
||||
mov ecx, eax
|
||||
invoke MutexInit
|
||||
pop ecx
|
||||
inc ecx
|
||||
cmp ecx, CQ_ENTRIES
|
||||
jne .init_cmd_entries
|
||||
|
||||
pop ecx
|
||||
add ecx, sizeof.NVM_QUEUE_ENTRY
|
||||
cmp ecx, (LAST_QUEUE_ID + 1) * sizeof.NVM_QUEUE_ENTRY
|
||||
jne @b
|
||||
jne .init_queues
|
||||
|
||||
; Configure Admin Submission/Completion Queue Base Address
|
||||
mov esi, [pci]
|
||||
|
@ -343,9 +343,9 @@ ends
|
||||
TOTAL_PCIDEVS = 4
|
||||
TOTAL_PCIDEVS_MALLOC_SZ = TOTAL_PCIDEVS * sizeof.pcidev
|
||||
|
||||
struct DPTR
|
||||
prp1 dd ?
|
||||
prp2 dd ?
|
||||
struct NVMQCMD
|
||||
cid dd ?
|
||||
mutex_ptr MUTEX
|
||||
ends
|
||||
|
||||
struct NVM_QUEUE_ENTRY
|
||||
@ -353,7 +353,7 @@ struct NVM_QUEUE_ENTRY
|
||||
head dw ?
|
||||
sq_ptr dd ?
|
||||
cq_ptr dd ?
|
||||
cid_slots dq ?
|
||||
cmd_ptr dd ?
|
||||
ends
|
||||
|
||||
; Identify Controller Data Structure
|
||||
|
Loading…
x
Reference in New Issue
Block a user