2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2025-01-08 22:16:13 +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 proc memset stdcall, p_data:dword, val:byte, sz:dword
push ebx ecx edx push ebx ecx
mov edx, [sz] mov eax, [p_data]
mov ecx, [sz]
mov bl, [val] mov bl, [val]
xor ecx, ecx
@@: @@:
mov byte [p_data + ecx], bl mov byte [eax + ecx], bl
inc ecx dec ecx
cmp ecx, edx test ecx, ecx
jne @b jnz @b
pop edx ecx ebx pop ecx ebx
ret ret
endp endp
; Submit a Command in the Admin Submission Queue ; 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 xor eax, eax
ret ret
endp 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 sub esp, sizeof.SQ_ENTRY
stdcall memset, esp, 0, 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 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.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 ax, [cid]
mov al, byte [cns] 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 mov byte [esp + SQ_ENTRY.cdw10], al
stdcall submit_asq, esp stdcall submit_asq, esp
@ -263,11 +266,11 @@ proc nvme_init stdcall, pci:dword
cmp eax, NVM_MPS cmp eax, NVM_MPS
jl .exit_fail jl .exit_fail
; Configure IOSQES, IOCQES, MPS, CSS ; Configure AMS, MPS, CSS
mov eax, dword [edi + NVME_MMIO.CC] mov eax, dword [edi + NVME_MMIO.CC]
and eax, not (CC_IOSQES or CC_IOCQES or CC_MPS or CC_CSS) and eax, not (CC_AMS or CC_MPS or CC_CSS)
or eax, (4 shl 16) or (6 shl 20) or eax, 111b shl 4 ; Admin Command Set Only (temporary)
mov dword [edi + NVME_MMIO.CC], eax and dword [edi + NVME_MMIO.CC], eax
; Configure Admin Queue Attributes ; Configure Admin Queue Attributes
mov eax, dword [edi + NVME_MMIO.AQA] mov eax, dword [edi + NVME_MMIO.AQA]
@ -293,6 +296,12 @@ proc nvme_init stdcall, pci:dword
; Restart the controller ; Restart the controller
stdcall nvme_controller_start, edi 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 xor eax, eax
inc eax inc eax