2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2024-11-13 03:37:28 +01:00

feat: get reading from PRP2 entry working

This commit is contained in:
Abdur-Rahman Mansoor 2024-07-09 16:48:39 -04:00
parent f3a8ed0f6f
commit b57c530854

View File

@ -570,11 +570,12 @@ proc alloc_dptr stdcall, ns:dword, prps_ptr:dword, numsectors:dword
cmp edx, eax cmp edx, eax
jbe .success jbe .success
; is the number of sectors equal to two memory pages in size? (todo: fix???) ; is the number of sectors greater than to two memory pages?
shl eax, 1 shl eax, 1
cmp eax, edx cmp edx, eax
jne @f jae @f
DEBUGF DBG_INFO, "Allocating single entry for PRP2\n"
; allocate a single PRP entry for PRP2 ; allocate a single PRP entry for PRP2
invoke AllocPage invoke AllocPage
test eax, eax test eax, eax
@ -743,6 +744,7 @@ proc nvme_readwrite stdcall, ns:dword, buf:dword, start_sector:qword, numsectors
stdcall alloc_dptr, esi, ebx, edx stdcall alloc_dptr, esi, ebx, edx
test eax, eax test eax, eax
jz .end jz .end
DEBUGF DBG_INFO, "PRP1: %x, PRP2: %x\n", [ebx], [ebx + 4]
stdcall nvme_io_rw, [esi + NSINFO.pci], \ stdcall nvme_io_rw, [esi + NSINFO.pci], \
1, \ 1, \
[esi + NSINFO.nsid], \ [esi + NSINFO.nsid], \
@ -763,6 +765,7 @@ proc nvme_readwrite stdcall, ns:dword, buf:dword, start_sector:qword, numsectors
test eax, eax test eax, eax
jz .end jz .end
DEBUGF DBG_INFO, "Successfully wrote PRP1\n"
; check if PRP2 is needed at all ; check if PRP2 is needed at all
mov ecx, dword [esi + NSINFO.pg_sectors] mov ecx, dword [esi + NSINFO.pg_sectors]
mov edx, dword [ebx + 12] mov edx, dword [ebx + 12]
@ -771,9 +774,10 @@ proc nvme_readwrite stdcall, ns:dword, buf:dword, start_sector:qword, numsectors
; check if PRP2 should be a PRP list or a regular entry ; check if PRP2 should be a PRP list or a regular entry
shl ecx, 1 shl ecx, 1
cmp ecx, edx cmp edx, ecx
ja .is_prp_list ja .is_prp_list
DEBUGF DBG_INFO, "PRP2 entry\n"
; PRP2 is a PRP entry ; PRP2 is a PRP entry
mov eax, dword [ebx + 12] mov eax, dword [ebx + 12]
imul eax, dword [esi + NSINFO.lbads] imul eax, dword [esi + NSINFO.lbads]
@ -1193,7 +1197,7 @@ proc nvme_init stdcall, pci:dword
test eax, eax test eax, eax
jz .exit_fail jz .exit_fail
mov edx, NVM_CMD_READ mov edx, NVM_CMD_READ
mov dword [eax], 0x1 mov dword [eax], 0x9
stdcall nvme_readwrite, [esi + pcidev.nsinfo], edi, 0, 0, eax stdcall nvme_readwrite, [esi + pcidev.nsinfo], edi, 0, 0, eax
test eax, eax test eax, eax
jz .exit_fail jz .exit_fail