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

minor tweaks

This commit is contained in:
Abdur-Rahman Mansoor 2024-05-28 15:01:25 -04:00
parent a181eccd9c
commit f372a0c9dd

View File

@ -86,40 +86,43 @@ endp
proc memset stdcall, p_data:dword, val:byte, sz:dword
push ebx ecx edx
mov edx, [sz]
push ebx ecx
mov eax, [p_data]
mov ecx, [sz]
mov bl, [val]
xor ecx, ecx
@@:
mov byte [p_data + ecx], bl
inc ecx
cmp ecx, edx
jne @b
pop edx ecx ebx
mov byte [eax + ecx], bl
dec ecx
test ecx, ecx
jnz @b
pop ecx ebx
ret
endp
; Submit a Command in the Admin Submission Queue
proc submit_asq stdcall, p_sq:dword
proc submit_asq stdcall, sq_ptr:dword
mov esi, [sq_ptr]
xor eax, eax
ret
endp
proc nvme_identify stdcall, nsid:dword, dptr:dword, cns:byte
proc nvme_identify stdcall, nsid:dword, dptr:dword, cid:word, cns:byte
sub esp, sizeof.SQ_ENTRY
stdcall memset, esp, 0, sizeof.SQ_ENTRY
mov eax, dword [nsid]
mov eax, [nsid]
mov dword [esp + SQ_ENTRY.nsid], eax
mov eax, dword [dptr]
mov eax, [dptr]
mov dword [esp + SQ_ENTRY.dptr], eax
mov dword [esp + SQ_ENTRY.cdw0], ADM_CMD_IDENTIFY ; TODO: setting CID to 0 for now but later on keep a unique list of identifiers
mov al, byte [cns]
mov ax, [cid]
or dword [esp + SQ_ENTRY.cdw0], ADM_CMD_IDENTIFY
or dword [esp + SQ_ENTRY.cdw0], ax
mov al, [cns]
mov byte [esp + SQ_ENTRY.cdw10], al
stdcall submit_asq, esp
@ -263,11 +266,11 @@ proc nvme_init stdcall, pci:dword
cmp eax, NVM_MPS
jl .exit_fail
; Configure IOSQES, IOCQES, MPS, CSS
; Configure AMS, MPS, CSS
mov eax, dword [edi + NVME_MMIO.CC]
and eax, not (CC_IOSQES or CC_IOCQES or CC_MPS or CC_CSS)
or eax, (4 shl 16) or (6 shl 20)
mov dword [edi + NVME_MMIO.CC], eax
and eax, not (CC_AMS or CC_MPS or CC_CSS)
or eax, 111b shl 4 ; Admin Command Set Only (temporary)
and dword [edi + NVME_MMIO.CC], eax
; Configure Admin Queue Attributes
mov eax, dword [edi + NVME_MMIO.AQA]
@ -293,6 +296,12 @@ proc nvme_init stdcall, pci:dword
; Restart the controller
stdcall nvme_controller_start, edi
invoke AllocPage
test eax, eax
jz .exit_fail
; nsid:dword, dptr:dword, cid:word, cns:byte
stdcall nvme_identify, 0, eax, 0, CNS_IDCS
xor eax, eax
inc eax