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

remap entire MMIO

This commit is contained in:
Abdur-Rahman Mansoor 2024-05-29 19:29:01 -04:00
parent 97d9fc0c76
commit f5534dbdcf

View File

@ -196,12 +196,14 @@ endp
proc device_is_compat stdcall, pci:dword
push esi
push esi edx ecx
mov esi, [pci]
invoke PciRead32, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.base_addr_0
and eax, 0xfffffff0
test eax, eax
jz .failure
mov edx, eax
push edx
invoke MapIoMem, eax, sizeof.NVME_MMIO, PG_SW+PG_NOCACHE
test eax, eax
@ -214,21 +216,32 @@ proc device_is_compat stdcall, pci:dword
; Stride is (2 ^ (2 + DSTRD)) bytes
add eax, 2
stdcall pow2, eax
mov ecx, eax
mov dword [esi + pcidev.dstrd], eax
; TODO: Remap I/O with new size
; 1003h + ((2y + 1) * (4 << CAP.DSTRD))
mov eax, 4
shl ax, cl
mov ecx, NVM_ASQS
shl ecx, 1
inc ecx
imul ecx, eax
add ecx, 0x1003
mov esi, dword [esi + pcidev.mmio_ptr]
mov eax, dword [esi + NVME_MMIO.VS]
;invoke FreePage, dword [esi + pcidev.mmio_ptr]
pop edx
invoke MapIoMem, edx, ecx, PG_SW+PG_NOCACHE
mov dword [esi + pcidev.mmio_ptr], eax
mov eax, dword [eax + NVME_MMIO.VS]
DEBUGF DBG_INFO, "(NVMe) Controller version: 0x%x\n", eax
pop esi
pop ecx edx esi
xor eax, eax
inc eax
ret
.failure:
PDEBUGF DBG_INFO, "PCI(%u.%u.%u): something went wrong checking NVMe device compatibility\n", byte [esi + pcidev.bus], byte [esi + pcidev.devfn]
pop esi
pop ecx edx esi
xor eax, eax
ret
@ -384,18 +397,19 @@ proc cq0thbl_write stdcall, dstrd:dword
endp
; Calculates 2^x
proc pow2 stdcall, x:dword
proc pow2 stdcall, x:byte
push ecx
mov ecx, [x]
mov cl, [x]
xor eax, eax
inc eax
test ecx, ecx
test cl, cl
jnz @f
pop ecx
ret
@@:
shl eax, ecx
shl eax, cl
pop ecx
ret