;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; GNU GENERAL PUBLIC LICENSE ;; ;; Version 2, June 1991 ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; NVMe Registers NVME_REG_CAP = 0x0 ; Controller Capabilities NVME_REG_VS = 0x8 ; Version NVME_REG_INTMS = 0xC ; Interrupt Mask Set NVME_REG_INTMC = 0xF ; Interrupt Mask Clear NVME_REG_CC = 0x14 ; Controller Configuration NVME_REG_CSTS = 0x1C ; Controller Status NVME_REG_NSSR = 0x20 ; NVM Subsystem Reset NVME_REG_AQA = 0x24 ; Admin Queue Attributes NVME_REG_ASQ = 0x28 ; Admin Submission Queue Base Address NVME_REG_ACQ = 0x30 ; Admin Completion Queue Base Address NVME_REG_CMBLOC = 0x38 ; Controller Memory Buffer Location ; Opcodes for NVM commands NVM_CMD_FLUSH = 0x00 NVM_CMD_WRITE = 0x01 NVM_CMD_READ = 0x02 NVM_CMD_WRITE_UNCORRECTABLE = 0x04 NVM_CMD_COMPARE = 0x05 NVM_CMD_WRITE_ZEROES = 0x08 NVM_CMD_DATASET_MANAGEMENT = 0x09 NVM_CMD_VERIFY = 0x0C NVM_CMD_RESERVATION_REG = 0x0D NVM_CMD_RESERVATION_REPORT = 0x0E NVM_CMD_RESERVATION_ACQUIRE = 0x11 NVM_CMD_RESERVATION_RELEASE = 0x15 NVM_CMD_COPY = 0x19 ; Opcodes for admin commands ADM_CMD_DEL_IO_SUBMISSION_QUEUE = 0x00 ADM_CMD_CRE_IO_SUBMISSION_QUEUE = 0x01 ADM_CMD_GET_LOG_PAGE = 0x02 ADM_CMD_DEL_IO_COMPLETION_QUEUE = 0x04 ADM_CMD_CRE_IO_COMPLETION_QUEUE = 0x05 ADM_CMD_IDENTIFY = 0x06 ADM_CMD_ABORT = 0x08 ADM_CMD_SET_FEATURES = 0x09 ADM_CMD_GET_FEATURES = 0x0A ; fuse (fused operation): In a fused operation, a complex command is created by 'fusing' together ; two simpler commands. This field specifies whether this command is part ; of a fused operation, and if so, which command it is in the sequence: ; 00b -> Normal operation ; 01b -> Fused operation, first command ; 10b -> Fused operation, second command ; 11b -> Reserved NO_FUSE = 0 FUSE_OP_FIRST_CMD = 1 shl 8 FUSE_OP_SECOND_CMD = 2 shl 8 ; sel (PRP or SGL for data transfer): This field specifies whether PRPs or SGLs are used for any ; data transfer associated with the command. PRPs shall be ; used for all Admin commands for NVMe over PCIe implementations. ; SGLs shall be used for all Admin and I/O commands for NVMe over ; Fabrics implementations (i.e., field set to 01b): ; 00b -> PRPs are used for this transfer ; 01b -> SGLs are used for this transfer, MPTR will contain address of ; a single contiguous physical buffer that is byte aligned ; 10b -> SGLs are used for this transfer. MPTR will contain address of ; an SGL segment containing exactly one SGL descriptor that is ; QWORD aligned ; 11b -> Reserved SEL_PRP = 0 SEL_SGL = 1 shl 14 ; Controller or Namespace Structure (CNS) specifies the information to be returned to the host. CNS_IDNS = 0x0 ; Namespace data structure (NSID) CNS_IDCS = 0x1 ; Controller data structure CNS_ANIDL = 0x2 ; Active namespace ID list (NSID) CNS_NIDL = 0x3 ; Namespace identification descriptor list (NSID) CNS_NVM_SL = 0x4 ; NVM Set List ; Optional Admin Command Support (OACS) values OACS_SEC_SEN_RECV_SUPPORTED = 1 shl 0 OACS_FMT_NVM_SUPPORTED = 1 shl 1 OACS_FIRM_COMDL_SUPPORTED = 1 shl 2 OACS_NSMAN_SUPPORTED = 1 shl 3 ; scope is all attached namespaces or all namespaces in NVM subsystem NSID_BROADCAST = 0xFFFFFFFF ; Submission Queue Entry (64 bytes) struc sq_entry { .cdw0 dd ? .nsid dd ? .cdw2 dd ? .cdw3 dd ? .mptr dq ? .dptr dq ? .cdw10 dd ? .cdw11 dd ? .cdw12 dd ? .cdw13 dd ? .cdw14 dd ? .cdw15 dd ? } struc nvme_dev { .pci_bus dd ? .pci_devfn dd ? .bar0 dd ? .serial db 20 .model db 40 } struct id_controller pci_vid dw ? pci_ssvid dw ? serial db 20 model db 40 firm_rev dq ? rab db ? ieee db 3 cmic db ? mdts db ? ctrlid dw ? ver db 3 rtd3r dd ? rtd3e dd ? ctrlatt dd ? rrls dw ? reserved db 9 ctrltyp db ? fguid dq 2 crdt1 dw ? ctdt2 dw ? crdt3 dw ? rb 106 ; reserved rb 13 ; reserved (NVMMI) nvmsr db ? vmci db ? mec db ? oacs dw ? acl db ? aerl db ? frmw db ? lpa db ? elpe db ? npss db ? avscc db ? apsta db ? wctemp dw ? cctemp dw ? mtfa dw ? hmpre dd ? hmmin dd ? tnvmcap dq 2 unvmcap dq 2 rpmbs dd ? edstt dw ? dsto db ? fwug db ? kas dw ? hctma dw ? mntmt dw ? mxtmt dw ? sanicap dd ? hmminds dd ? hmmaxd dw ? nsetidmax dw ? endgidmax dw ? anatt db ? anacap db ? anagrpmax dd ? nanagrpid dd ? pels dd ? domid dw ? rb 10 ; reserved megcap dq 2 rb 128 ; reserved sqes db ? cqes db ? maxcmd dw ? nn dd ? oncs dw ? fuses dw ? fna db ? vwc db ? awun dw ? awupf dw ? icsvscc db ? nwpc db ? acwu dw ? ocfs dw ? sgls dd ? mnan dd ? maxdna dq 2 maxcna dd ? rb 204 ; reserved subnqn db 256 rb 768 ; reserved ioccsz dd ? iorcsz dd ? icdoff dw ? fcatt db ? msdbd db ? ofcs dw ? rb 242 ; reserved psd0 db 32 psd1 db 32 psd2 db 32 psd3 db 32 psd4 db 32 psd5 db 32 psd6 db 32 psd7 db 32 psd8 db 32 psd9 db 32 psd10 db 32 psd11 db 32 psd12 db 32 psd13 db 32 psd14 db 32 psd15 db 32 psd16 db 32 psd17 db 32 psd18 db 32 psd19 db 32 psd20 db 32 psd21 db 32 psd22 db 32 psd23 db 32 psd24 db 32 psd25 db 32 psd26 db 32 psd27 db 32 psd28 db 32 psd29 db 32 psd30 db 32 psd31 db 32 venspec db 1024 ends