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

feat: implement I/O read command

This commit is contained in:
Abdur-Rahman Mansoor 2024-07-01 13:56:00 -04:00
parent 2d1e0d4aa4
commit 383190e462

View File

@ -444,8 +444,8 @@ proc get_log_page stdcall, pci:dword, dptr:dword, lid:byte
endp endp
; See page 269-271 of the NVMe 1.4 specification for reference ; See page 258-261 (read) and 269-271 (write) of the NVMe 1.4 specification for reference
proc nvme_write stdcall, pci:dword, qid:word, nsid:dword, dptr:dword, slba_lo:dword, slba_hi:dword, nlb:word proc nvme_io_rw stdcall, pci:dword, qid:word, nsid:dword, dptr:dword, slba_lo:dword, slba_hi:dword, nlb:word, opcode:dword
; TODO: Use IDENTC.NOIOB to construct read/write commands that don't ; TODO: Use IDENTC.NOIOB to construct read/write commands that don't
; cross the I/O boundary to achieve optimal performance ; cross the I/O boundary to achieve optimal performance
@ -454,7 +454,7 @@ proc nvme_write stdcall, pci:dword, qid:word, nsid:dword, dptr:dword, slba_lo:dw
sub esp, sizeof.SQ_ENTRY sub esp, sizeof.SQ_ENTRY
stdcall memset, esp, 0, sizeof.SQ_ENTRY stdcall memset, esp, 0, sizeof.SQ_ENTRY
movzx ecx, [qid] movzx ecx, [qid]
stdcall set_cdw0, [pci], ecx, NVM_CMD_WRITE stdcall set_cdw0, [pci], ecx, [opcode]
mov dword [esp + SQ_ENTRY.cdw0], eax ; CDW0 mov dword [esp + SQ_ENTRY.cdw0], eax ; CDW0
mov eax, [dptr] mov eax, [dptr]
mov dword [esp + SQ_ENTRY.dptr], eax mov dword [esp + SQ_ENTRY.dptr], eax
@ -462,7 +462,7 @@ proc nvme_write stdcall, pci:dword, qid:word, nsid:dword, dptr:dword, slba_lo:dw
mov dword [esp + SQ_ENTRY.nsid], eax mov dword [esp + SQ_ENTRY.nsid], eax
mov eax, [slba_lo] mov eax, [slba_lo]
mov dword [esp + SQ_ENTRY.cdw10], eax mov dword [esp + SQ_ENTRY.cdw10], eax
mov eax, [slba_hi] ; SLBA + 32 (fix later) mov eax, [slba_hi]
mov dword [esp + SQ_ENTRY.cdw11], eax mov dword [esp + SQ_ENTRY.cdw11], eax
movzx eax, [nlb] movzx eax, [nlb]
mov word [esp + SQ_ENTRY.cdw12], ax mov word [esp + SQ_ENTRY.cdw12], ax
@ -473,7 +473,6 @@ proc nvme_write stdcall, pci:dword, qid:word, nsid:dword, dptr:dword, slba_lo:dw
endp endp
proc detect_nvme proc detect_nvme
invoke GetPCIList invoke GetPCIList
@ -825,8 +824,11 @@ proc nvme_init stdcall, pci:dword
invoke KernelAlloc, 0x1000 invoke KernelAlloc, 0x1000
test eax, eax test eax, eax
jz .exit_fail jz .exit_fail
mov edi, eax
;stdcall memcpy, eax, test_string, 50
invoke GetPhysAddr invoke GetPhysAddr
stdcall nvme_write, [pci], 1, [esi + pcidev.nsid], eax, 0, 0, 1 stdcall nvme_io_rw, [pci], 1, [esi + pcidev.nsid], eax, 0, 0, 1, NVM_CMD_READ
DEBUGF DBG_INFO, "%s\n", edi
DEBUGF DBG_INFO, "nvme%u: Successfully initialized driver\n", [esi + pcidev.num] DEBUGF DBG_INFO, "nvme%u: Successfully initialized driver\n", [esi + pcidev.num]
xor eax, eax xor eax, eax
inc eax inc eax