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

feat: get reading from single prp entry working

This commit is contained in:
Abdur-Rahman Mansoor 2024-07-09 15:43:45 -04:00
parent 405dcb5155
commit f3a8ed0f6f

View File

@ -724,7 +724,7 @@ nvme_read:
nvme_write: nvme_write:
mov edx, NVM_CMD_WRITE mov edx, NVM_CMD_WRITE
proc nvme_readwrite stdcall, ns:dword, dst:dword, start_sector:qword, numsectors_ptr:dword proc nvme_readwrite stdcall, ns:dword, buf:dword, start_sector:qword, numsectors_ptr:dword
push ebx esi edi push ebx esi edi
sub esp, 16 sub esp, 16
@ -734,7 +734,7 @@ proc nvme_readwrite stdcall, ns:dword, dst:dword, start_sector:qword, numsectors
mov dword [ebx + 8], edx ; command type (read or write) mov dword [ebx + 8], edx ; command type (read or write)
mov dword [ebx + 12], eax ; save original numsectors value mov dword [ebx + 12], eax ; save original numsectors value
mov esi, [ns] mov esi, [ns]
mov edi, [dst] mov edi, [buf]
mov edx, [numsectors_ptr] mov edx, [numsectors_ptr]
mov edx, [edx] mov edx, [edx]
@ -756,14 +756,16 @@ proc nvme_readwrite stdcall, ns:dword, dst:dword, start_sector:qword, numsectors
; assume command completes successfully for now ; assume command completes successfully for now
; Write PRP1 ; Write PRP1
; investigate: why does this change the value of esi??
push esi ebx edi
stdcall write_prp_buf, esi, dword [ebx], edi, [numsectors_ptr] stdcall write_prp_buf, esi, dword [ebx], edi, [numsectors_ptr]
DEBUGF DBG_INFO, "Successfully wrote PRP1\n" pop edi ebx esi
test eax, eax test eax, eax
jz .end jz .end
; 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 + 8] mov edx, dword [ebx + 12]
cmp edx, ecx cmp edx, ecx
jbe .end jbe .end
@ -788,7 +790,7 @@ proc nvme_readwrite stdcall, ns:dword, dst:dword, start_sector:qword, numsectors
mov ecx, dword [esi + NSINFO.lbads] mov ecx, dword [esi + NSINFO.lbads]
div ecx div ecx
mov ebx, eax mov ebx, eax
stdcall write_prp_list_buf, dword [ebx + 4], [dst], ebx stdcall write_prp_list_buf, dword [ebx + 4], [buf], ebx
stdcall free_prp_list, dword [ebx + 4], ebx, FALSE stdcall free_prp_list, dword [ebx + 4], ebx, FALSE
.end: .end:
@ -1192,9 +1194,10 @@ proc nvme_init stdcall, pci:dword
jz .exit_fail jz .exit_fail
mov edx, NVM_CMD_READ mov edx, NVM_CMD_READ
mov dword [eax], 0x1 mov dword [eax], 0x1
stdcall nvme_readwrite, [esi + pcidev.nsinfo], edi, 1, 0, eax stdcall nvme_readwrite, [esi + pcidev.nsinfo], edi, 0, 0, eax
test eax, eax test eax, eax
jz .exit_fail jz .exit_fail
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