mirror of
https://git.missingno.dev/kolibrios-nvme-driver/
synced 2025-01-03 19:35:56 +01:00
wip: submit command support
This commit is contained in:
parent
a0cc2ec6a5
commit
7393da0eb5
@ -101,8 +101,8 @@ proc memset stdcall, p_data:dword, val:byte, sz:dword
|
|||||||
|
|
||||||
endp
|
endp
|
||||||
|
|
||||||
; Submit a Command in the Admin Submission Queue
|
; Submit a Administrator Command in the Submission Queue
|
||||||
proc submit_asq stdcall, sq_ptr:dword
|
proc submit_admin_cmd stdcall, sq_ptr:dword, slot:dword
|
||||||
|
|
||||||
mov esi, [sq_ptr]
|
mov esi, [sq_ptr]
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -110,24 +110,25 @@ proc submit_asq stdcall, sq_ptr:dword
|
|||||||
|
|
||||||
endp
|
endp
|
||||||
|
|
||||||
proc nvme_identify stdcall, nsid:dword, dptr:dword, cid:word, cns:byte
|
proc nvme_identify stdcall, pci:dword, slot:dword, nsid:dword, dptr:dword, cid:word, cns:byte
|
||||||
|
|
||||||
sub esp, sizeof.SQ_ENTRY
|
|
||||||
stdcall memset, esp, 0, sizeof.SQ_ENTRY
|
|
||||||
|
|
||||||
|
push esi
|
||||||
|
mov esi, [pci]
|
||||||
|
mov esi, [esi + pcidev.sq_ptr]
|
||||||
|
mov eax, [slot]
|
||||||
|
imul eax, sizeof.SQ_ENTRY
|
||||||
|
add esi, eax
|
||||||
mov eax, [nsid]
|
mov eax, [nsid]
|
||||||
mov dword [esp + SQ_ENTRY.nsid], eax
|
mov dword [esi + SQ_ENTRY.nsid], eax
|
||||||
mov eax, [dptr]
|
mov eax, [dptr]
|
||||||
mov dword [esp + SQ_ENTRY.dptr], eax
|
mov dword [esi + SQ_ENTRY.dptr], eax
|
||||||
movzx eax, [cid]
|
movzx eax, [cid]
|
||||||
or dword [esp + SQ_ENTRY.cdw0], ADM_CMD_IDENTIFY
|
or dword [esi + SQ_ENTRY.cdw0], ADM_CMD_IDENTIFY
|
||||||
or dword [esp + SQ_ENTRY.cdw0], eax
|
or dword [esi + SQ_ENTRY.cdw0], eax
|
||||||
mov al, [cns]
|
mov al, [cns]
|
||||||
mov byte [esp + SQ_ENTRY.cdw10], al
|
mov byte [esi + SQ_ENTRY.cdw10], al
|
||||||
stdcall submit_asq, esp
|
stdcall sqytdbl_write, [pci], 0, 0
|
||||||
|
pop esi
|
||||||
add esp, sizeof.SQ_ENTRY
|
|
||||||
xor eax, eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
endp
|
endp
|
||||||
@ -202,10 +203,8 @@ proc device_is_compat stdcall, pci:dword
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .failure
|
jz .failure
|
||||||
mov byte [esi + pcidev.ipin], al
|
mov byte [esi + pcidev.ipin], al
|
||||||
DEBUGF DBG_INFO, "(NVMe) pcidev.ipin = %u\n", al
|
|
||||||
invoke PciRead8, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.interrupt_line
|
invoke PciRead8, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.interrupt_line
|
||||||
mov byte [esi + pcidev.iline], al
|
mov byte [esi + pcidev.iline], al
|
||||||
DEBUGF DBG_INFO, "(NVMe) pcidev.iline = %u\n", al
|
|
||||||
invoke PciRead32, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.base_addr_0
|
invoke PciRead32, dword [esi + pcidev.bus], dword [esi + pcidev.devfn], PCI_header00.base_addr_0
|
||||||
and eax, 0xfffffff0
|
and eax, 0xfffffff0
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -345,8 +344,8 @@ proc nvme_init stdcall, pci:dword
|
|||||||
invoke AllocPage
|
invoke AllocPage
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .exit_fail
|
jz .exit_fail
|
||||||
; nsid:dword, dptr:dword, cid:word, cns:byte
|
; pci:dword, nsid:dword, dptr:dword, cid:word, cns:byte
|
||||||
stdcall nvme_identify, 0, eax, 0, CNS_IDCS
|
stdcall nvme_identify, [pci], 0, eax, 0, CNS_IDCS
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
inc eax
|
inc eax
|
||||||
@ -427,15 +426,26 @@ proc cqyhdbl_write stdcall, mmio:dword, dstrd:byte, y:byte
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
; Writes to submission queue 'y' tail doorbell
|
; Writes to submission queue 'y' tail doorbell
|
||||||
proc sqytdbl_write stdcall, mmio:dword, dstrd:byte, y:byte
|
proc sqytdbl_write stdcall, pci:dword, y:byte, offset:dword
|
||||||
|
|
||||||
|
push ebx esi edi
|
||||||
|
mov esi, [pci]
|
||||||
|
mov edi, [esi + pcidev.sq_ptr]
|
||||||
|
add edi, [offset]
|
||||||
|
mov esi, [esi + pcidev.mmio_ptr]
|
||||||
|
|
||||||
; 1000h + (2y * (4 << CAP.DSTRD))
|
; 1000h + (2y * (4 << CAP.DSTRD))
|
||||||
xor ecx, ecx
|
mov ecx, dword [esi + pcidev.dstrd]
|
||||||
shl ecx, [y]
|
|
||||||
mov eax, 4
|
mov eax, 4
|
||||||
shl eax, [dstrd]
|
shl eax, cl
|
||||||
imul eax, ecx
|
mov cl, [y]
|
||||||
add eax, 0x1000
|
xor ebx, ebx
|
||||||
|
shl ebx, cl
|
||||||
|
imul ebx, eax
|
||||||
|
add ebx, 0x1000
|
||||||
|
|
||||||
|
mov dword [esi + ebx], edi ; Write to register
|
||||||
|
pop edi esi ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
endp
|
endp
|
||||||
@ -460,6 +470,9 @@ proc pow2 stdcall, x:byte
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
proc irq_handler
|
proc irq_handler
|
||||||
|
|
||||||
|
DEBUGF DBG_INFO, "HI, I GOT CALLED!\n"
|
||||||
|
|
||||||
endp
|
endp
|
||||||
|
|
||||||
proc nvme_cleanup
|
proc nvme_cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user