Turnstone Operating System
Loading...
Searching...
No Matches
nvme.h File Reference

nvme interface More...

#include <types.h>
#include <memory.h>
#include <list.h>
#include <pci.h>
#include <utils.h>
#include <future.h>
#include <hashmap.h>
#include <disk.h>

Classes

union  nvme_controller_cap_t
 nvme nvme_controller_registers_t nvme cap field More...
 
struct  nvme_controller_cap_t::nvme_controller_cap_fields_t
 
struct  nvme_controller_version_t
 nvme nvme_controller_registers_t version field More...
 
struct  nvme_controller_cfg_t
 nvme controller configuration More...
 
struct  nvme_controller_sts_t
 nvme controller status filed More...
 
struct  nvme_controller_aqa_t
 nvme admin queue attributes More...
 
struct  nvme_controller_cmbloc_t
 controller memory buffer location More...
 
struct  nvme_controller_cmbsz_t
 nvme controller memory buffer size field More...
 
struct  nvme_controller_bpinfo_t
 nvme controller boot partition information More...
 
struct  nvme_controller_bprsel_t
 nvme controller boot partition read select field More...
 
struct  nvme_controller_cmbmsc_t
 nvme controller controller memory buffer memory space control field More...
 
struct  nvme_controller_cmbsts_t
 nvme controller controller memory buffer status field More...
 
struct  nvme_controller_registers_t
 nvme controller register at bar0 and bar1 More...
 
struct  nvme_submission_queue_entry_t
 nvme submission queue entry More...
 
union  nvme_submission_queue_entry_t::nvme_submission_queue_entry_datapointer_t
 
struct  nvme_submission_queue_entry_t::nvme_submission_queue_entry_datapointer_t::nvme_submission_queue_entry_prplist_t
 
struct  nvme_completion_queue_entry_t
 nvme completion queue entry fields More...
 
struct  nvme_identify_t
 nvme identify data fields More...
 
struct  nvme_lba_format_t
 
struct  nvme_ns_identify_t
 nvme namespace identify data fields More...
 
struct  nvme_disk_t
 

Macros

#define ___DRIVER_NVME_H   0
 

Typedefs

typedef union nvme_controller_cap_t nvme_controller_cap_t
 union shorthand
 
typedef struct nvme_controller_version_t nvme_controller_version_t
 shorthand for struct
 
typedef struct nvme_controller_cfg_t nvme_controller_cfg_t
 shorthand for struct
 
typedef struct nvme_controller_sts_t nvme_controller_sts_t
 shorthand for struct
 
typedef union nvme_controller_aqa_t nvme_controller_aqa_t
 shorthand for struct
 
typedef struct nvme_controller_cmbloc_t nvme_controller_cmbloc_t
 shorthand for struct
 
typedef struct nvme_controller_cmbsz_t nvme_controller_cmbsz_t
 shorthand for struct
 
typedef struct nvme_controller_bpinfo_t nvme_controller_bpinfo_t
 shorthand for struct
 
typedef struct nvme_controller_bprsel_t nvme_controller_bprsel_t
 shorthand for struct
 
typedef struct nvme_controller_cmbmsc_t nvme_controller_cmbmsc_t
 shorthand for struct
 
typedef struct nvme_controller_cmbsts_t nvme_controller_cmbsts_t
 
typedef struct nvme_controller_registers_t nvme_controller_registers_t
 shorthand for struct
 
typedef struct nvme_submission_queue_entry_t nvme_submission_queue_entry_t
 
typedef struct nvme_completion_queue_entry_t nvme_completion_queue_entry_t
 shorthand for struct
 
typedef struct nvme_identify_t nvme_identify_t
 shorthand for struct
 
typedef struct nvme_lba_format_t nvme_lba_format_t
 
typedef struct nvme_ns_identify_t nvme_ns_identify_t
 shorthand for struct
 
typedef enum nvme_admin_cmd_opcode_t nvme_admin_cmd_opcode_t
 shorthand for enum
 
typedef enum nvme_cmd_opcode_t nvme_cmd_opcode_t
 shorthand for enum
 
typedef enum nvme_feat_id_t nvme_feat_id_t
 shorthand for enum
 
typedef enum nvme_cmd_status_t nvme_cmd_status_t
 shorthand for enum
 
typedef struct nvme_disk_t nvme_disk_t
 shorthand for struct
 

Enumerations

enum  nvme_admin_cmd_opcode_t {
  NVME_ADMIN_CMD_DELETE_SQ = 0X00 , NVME_ADMIN_CMD_CREATE_SQ = 0X01 , NVME_ADMIN_CMD_GET_LOG_PAGE = 0X02 , NVME_ADMIN_CMD_DELETE_CQ = 0X04 ,
  NVME_ADMIN_CMD_CREATE_CQ = 0X05 , NVME_ADMIN_CMD_IDENTIFY = 0X06 , NVME_ADMIN_CMD_ABORT = 0X08 , NVME_ADMIN_CMD_SET_FEATURES = 0X09 ,
  NVME_ADMIN_CMD_GET_FEATURES = 0X0A , NVME_ADMIN_CMD_ASYNC_EVNT_REQ = 0X0C , NVME_ADMIN_CMD_FIRMWARE_COMMIT = 0X10 , NVME_ADMIN_CMD_FIRMWARE_DOWNLOAD = 0X11 ,
  NVME_ADMIN_CMD_NS_ATTACH = 0X15 , NVME_ADMIN_CMD_KEEP_ALIVE = 0X18 , NVME_ADMIN_CMD_FORMAT_NVM = 0X80
}
 nvme admin commands More...
 
enum  nvme_cmd_opcode_t {
  NVME_CMD_FLUSH = 0X00 , NVME_CMD_WRITE = 0X01 , NVME_CMD_READ = 0X02 , NVME_CMD_WRITE_UNCORRECTABLE = 0X4 ,
  NVME_CMD_COMPARE = 0X05 , NVME_CMD_WRITE_ZEROS = 0X08 , NVME_CMD_DATASET_MGMT = 0X09 , NVME_CMD_RESERVATION_REG = 0X0D ,
  NVME_CMD_RESERVATION_REP = 0X0E , NVME_CMD_RESERVATION_ACQ = 0X11 , NVME_CMD_RESERVATION_REL = 0X15
}
 nvme io commands More...
 
enum  nvme_feat_id_t { NVME_FEAT_HOST_MEM_BUF = 0XD , NVME_FEAT_NUM_QUEUES = 0X07 }
 nvme feature id's
 
enum  nvme_cmd_status_t {
  NVME_CMD_STATUS_SUCCESS = 0X0 , NVME_CMD_STATUS_INVALID_CMD = 0X1 , NVME_CMD_STATUS_INVALID_FIELD = 0X2 , NVME_CMD_STATUS_CMD_ID_CONFLICT = 0X3 ,
  NVME_CMD_STATUS_DATA_XFER_ERROR = 0X4 , NVME_CMD_STATUS_ABORTED_PWR_LOSS = 0X5 , NVME_CMD_STATUS_INTERNAL_ERROR = 0X6 , NVME_CMD_STATUS_CMD_ABORT_REQUESTED = 0X7 ,
  NVME_CMD_STATUS_CMD_ABORT_SQ_DELETED = 0X8 , NVME_CMD_STATUS_CMD_ABORT_FUSED_CMD = 0X9 , NVME_CMD_STATUS_CMD_ABORT_MISSING_FUSED_CMD = 0XA , NVME_CMD_STATUS_INVALID_NS_OR_FMT = 0XB ,
  NVME_CMD_STATUS_CMD_SEQ_ERROR = 0XC , NVME_CMD_STATUS_INVALID_SGL_SEG_DESC = 0XD , NVME_CMD_STATUS_INVALID_SGL_COUNT = 0XE , NVME_CMD_STATUS_INVALID_DATA_SGL_LEN = 0XF ,
  NVME_CMD_STATUS_INVALID_MD_GL_LEN = 0X10 , NVME_CMD_STATUS_INVALID_SGL_DESC_TYPE = 0X11 , NVME_CMD_STATUS_INVALID_USE_CTRL_MEM = 0X12 , NVME_CMD_STATUS_INVALID_PRP_OFS = 0X13 ,
  NVME_CMD_STATUS_ATOMIC_WRITE_UNIT_EXCEEDED = 0X14 , NVME_CMD_STATUS_INVALID_SGL_OFS = 0X16 , NVME_CMD_STATUS_INVALID_SGL_SUBTYPE = 0X17 , NVME_CMD_STATUS_INCONSISTENT_HOST_ID = 0X18 ,
  NVME_CMD_STATUS_KEEPALIVE_EXPIRED = 0X19 , NVME_CMD_STATUS_KEEPALIVE_INVALID = 0X1A , NVME_CMD_STATUS_LBA_OUT_OF_RANGE = 0X80 , NVME_CMD_STATUS_CAPACITY_EXCEEDED = 0X81 ,
  NVME_CMD_STATUS_NS_NOT_READY = 0X82 , NVME_CMD_STATUS_RESERVATION_CONFLICT = 0X83 , NVME_CMD_STATUS_FORMAT_IN_PROGRESS = 0X84
}
 nvme command's status codes More...
 

Functions

int8_t nvme_init (memory_heap_t *heap, list_t *nvme_pci_devices)
 initialize nvme devices More...
 
 _Static_assert (offsetof_field(nvme_ns_identify_t, lbaf)==128, "nvme_ns_identify_t size mismatch")
 
future_tnvme_read (uint64_t disk_id, uint64_t lba, uint32_t size, uint8_t *buffer)
 
future_tnvme_write (uint64_t disk_id, uint64_t lba, uint32_t size, uint8_t *buffer)
 
future_tnvme_flush (uint64_t disk_id)
 
disk_tnvme_disk_impl_open (nvme_disk_t *nvme_disk)
 
const nvme_disk_tnvme_get_disk_by_id (uint64_t disk_id)
 

Detailed Description

nvme interface

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ ___DRIVER_NVME_H

#define ___DRIVER_NVME_H   0

prevent duplicate header error macro

Enumeration Type Documentation

◆ nvme_admin_cmd_opcode_t

nvme admin commands

Enumerator
NVME_ADMIN_CMD_DELETE_SQ 

nvme admin command for deleting submission queue

NVME_ADMIN_CMD_CREATE_SQ 

nvme admin command for creating submission queue

NVME_ADMIN_CMD_GET_LOG_PAGE 

nvme admin command for getting log page entries

NVME_ADMIN_CMD_DELETE_CQ 

nvme admin command for deleting completion queue

NVME_ADMIN_CMD_CREATE_CQ 

nvme admin command for creating completion queue

NVME_ADMIN_CMD_IDENTIFY 

nvme admin command for identify controller and name space

NVME_ADMIN_CMD_ABORT 

nvme admin command for aborting another command

NVME_ADMIN_CMD_SET_FEATURES 

nvme admin command for setting nvme features not in registers

NVME_ADMIN_CMD_GET_FEATURES 

nvme admin command for getting nvme features not in registers

NVME_ADMIN_CMD_FIRMWARE_COMMIT 

nvme admin command for uploading firmare

NVME_ADMIN_CMD_FIRMWARE_DOWNLOAD 

nvme admin command for downloading firmware

NVME_ADMIN_CMD_NS_ATTACH 

nvme admin command for attaching namespace

NVME_ADMIN_CMD_KEEP_ALIVE 

nvme admin command for keeping alive

NVME_ADMIN_CMD_FORMAT_NVM 

nvme admin command for formatting nvme

◆ nvme_cmd_opcode_t

nvme io commands

Enumerator
NVME_CMD_FLUSH 

nvme io command for flush

NVME_CMD_WRITE 

nvme io command for write

NVME_CMD_READ 

nvme io command for read

◆ nvme_cmd_status_t

nvme command's status codes

Enumerator
NVME_CMD_STATUS_SUCCESS 

nvme command is succeed

NVME_CMD_STATUS_INVALID_CMD 

nvme command is invalid

NVME_CMD_STATUS_NS_NOT_READY 

namespace is not ready

NVME_CMD_STATUS_FORMAT_IN_PROGRESS 

nvme formatting in progress

Function Documentation

◆ nvme_init()

int8_t nvme_init ( memory_heap_t heap,
list_t nvme_pci_devices 
)

initialize nvme devices

Parameters
[in]heapthe heap for storing data
[in]nvme_pci_devicespci device list contains nvmes
Returns
nvme disk count