mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2025-02-07 04:36:50 +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
|
; Allocate submission/completion queue pointers
|
||||||
; TODO: Make these queues physically contiguous
|
; TODO: Make these queues physically contiguous
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
@@:
|
|
||||||
|
.init_queues:
|
||||||
push ecx
|
push ecx
|
||||||
invoke CreateRingBuffer, 0x1000, PG_SW
|
invoke CreateRingBuffer, 0x1000, PG_SW
|
||||||
pop ecx
|
pop ecx
|
||||||
@ -979,10 +980,38 @@ proc nvme_init stdcall, pci:dword
|
|||||||
mov dword [edi + ecx + NVM_QUEUE_ENTRY.cq_ptr], eax
|
mov dword [edi + ecx + NVM_QUEUE_ENTRY.cq_ptr], eax
|
||||||
push ecx
|
push ecx
|
||||||
stdcall memsetdz, eax, sizeof.CQ_ENTRY * CQ_ENTRIES / 4
|
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
|
pop ecx
|
||||||
add ecx, sizeof.NVM_QUEUE_ENTRY
|
add ecx, sizeof.NVM_QUEUE_ENTRY
|
||||||
cmp ecx, (LAST_QUEUE_ID + 1) * 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
|
; Configure Admin Submission/Completion Queue Base Address
|
||||||
mov esi, [pci]
|
mov esi, [pci]
|
||||||
|
@ -343,9 +343,9 @@ ends
|
|||||||
TOTAL_PCIDEVS = 4
|
TOTAL_PCIDEVS = 4
|
||||||
TOTAL_PCIDEVS_MALLOC_SZ = TOTAL_PCIDEVS * sizeof.pcidev
|
TOTAL_PCIDEVS_MALLOC_SZ = TOTAL_PCIDEVS * sizeof.pcidev
|
||||||
|
|
||||||
struct DPTR
|
struct NVMQCMD
|
||||||
prp1 dd ?
|
cid dd ?
|
||||||
prp2 dd ?
|
mutex_ptr MUTEX
|
||||||
ends
|
ends
|
||||||
|
|
||||||
struct NVM_QUEUE_ENTRY
|
struct NVM_QUEUE_ENTRY
|
||||||
@ -353,7 +353,7 @@ struct NVM_QUEUE_ENTRY
|
|||||||
head dw ?
|
head dw ?
|
||||||
sq_ptr dd ?
|
sq_ptr dd ?
|
||||||
cq_ptr dd ?
|
cq_ptr dd ?
|
||||||
cid_slots dq ?
|
cmd_ptr dd ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
; Identify Controller Data Structure
|
; Identify Controller Data Structure
|
||||||
|
Loading…
x
Reference in New Issue
Block a user