summaryrefslogtreecommitdiff
path: root/sys/include/dev/ic
diff options
context:
space:
mode:
Diffstat (limited to 'sys/include/dev/ic')
-rw-r--r--sys/include/dev/ic/ahciregs.h7
-rw-r--r--sys/include/dev/ic/ahcivar.h6
-rw-r--r--sys/include/dev/ic/nvmevar.h83
3 files changed, 96 insertions, 0 deletions
diff --git a/sys/include/dev/ic/ahciregs.h b/sys/include/dev/ic/ahciregs.h
index f959a1e..232b41e 100644
--- a/sys/include/dev/ic/ahciregs.h
+++ b/sys/include/dev/ic/ahciregs.h
@@ -88,6 +88,7 @@ struct hba_memspace {
*/
#define AHCI_PXSSTS_DET(SSTS) (SSTS & 0xF)
#define AHCI_PXSSTS_IPM(SSTS) ((SSTS >> 8) & 0xF)
+#define AHCI_PXSSTS_SPD(SSTS) ((SSTS >> 4) & 0xF)
/*
* Port SATA control bits
@@ -100,6 +101,7 @@ struct hba_memspace {
* See section 3.3.7 of the AHCI spec.
*/
#define AHCI_PXCMD_ST BIT(0) /* Start */
+#define AHCI_PXCMD_SUD BIT(1) /* Spin-up device */
#define AHCI_PXCMD_FRE BIT(4) /* FIS Receive Enable */
#define AHCI_PXCMD_FR BIT(14) /* FIS Receive Running */
#define AHCI_PXCMD_CR BIT(15) /* Command List Running */
@@ -137,6 +139,9 @@ struct hba_memspace {
#define AHCI_DET_PRESENT 1 /* Device present (no PHY comm) */
#define AHCI_DET_COMM 3 /* Device present and phy comm established */
#define AHCI_IPM_ACTIVE 1
+#define AHCI_SPD_GEN1 1 /* 1.5 Gb/s */
+#define AHCI_SPD_GEN2 2 /* 3 Gb/s */
+#define AHCI_SPD_GEN3 3 /* 6 Gb/s */
/*
* PxSERR bits
@@ -158,6 +163,8 @@ struct hba_memspace {
#define AHCI_DIAG_T BIT(24) /* Transport state transition error */
#define AHCI_DIAG_F BIT(25) /* Unknown FIS type */
+#define ATAPI_SIG 0xEB140101
+
/*
* Device detection initialization values
* See section 3.3.11 of the AHCI spec.
diff --git a/sys/include/dev/ic/ahcivar.h b/sys/include/dev/ic/ahcivar.h
index fa24812..67f2efe 100644
--- a/sys/include/dev/ic/ahcivar.h
+++ b/sys/include/dev/ic/ahcivar.h
@@ -33,9 +33,12 @@
#include <sys/param.h>
#include <sys/types.h>
#include <sys/device.h>
+#include <dev/dcdr/cache.h>
#include <dev/ic/ahciregs.h>
#include <fs/ctlfs.h>
+#define AHCI_DCDR_CAP 16
+
struct ahci_cmd_hdr;
extern const struct ctlops g_sata_bsize_ops;
@@ -93,6 +96,7 @@ struct ahci_hba {
* @io: Memory mapped port registers
* @hba: HBA descriptor
* @cmdlist: Command list [p]
+ * @nlba: Max number of addressable blocks
* @fra: FIS receive area [p]
* @dev: Device minor number.
*/
@@ -100,6 +104,8 @@ struct hba_device {
struct hba_port *io;
struct ahci_hba *hba;
struct ahci_cmd_hdr *cmdlist;
+ struct dcdr *dcdr;
+ uint32_t nlba;
void *fra;
dev_t dev;
};
diff --git a/sys/include/dev/ic/nvmevar.h b/sys/include/dev/ic/nvmevar.h
index eab8b52..3b06ad0 100644
--- a/sys/include/dev/ic/nvmevar.h
+++ b/sys/include/dev/ic/nvmevar.h
@@ -34,6 +34,7 @@
/* Admin commands */
#define NVME_OP_CREATE_IOSQ 0x01
+#define NVME_OP_GET_LOGPAGE 0x02
#define NVME_OP_CREATE_IOCQ 0x05
#define NVME_OP_IDENTIFY 0x06
@@ -45,6 +46,67 @@
#define NVME_OP_WRITE 0x01
#define NVME_OP_READ 0x02
+/* Log page identifiers */
+#define NVME_LOGPAGE_SMART 0x02
+
+/*
+ * S.M.A.R.T health / information log
+ *
+ * See section 5.16.1.3, figure 207 of the
+ * NVMe base spec (rev 2.0a)
+ *
+ * @cwarn: Critical warning
+ * @temp: Composite tempature (kelvin)
+ * @avail_spare: Available spare (in percentage)
+ * @avail_spare_thr: Available spare threshold
+ * @percent_used: Estimate NVMe life used percentage
+ * @end_cwarn: Endurance group critical warning summary
+ * @data_units_read: Number of 512 byte data units read
+ * @data_units_written: Number of 512 byte data units written
+ * @host_reads: Number of host read commands completed
+ * @host_writes: Number of host write commands completed
+ * @ctrl_busy_time: Controller busy time
+ * @power_cycles: Number of power cycles
+ * @power_on_hours: Number of power on hours
+ * @unsafe_shutdowns: Number of unsafe shutdowns
+ * @media_errors: Media and data integrity errors
+ * @n_errlog_entries: Number of error log info entries
+ * @warning_temp_time: Warning composite tempature time
+ * @critical_comp_time: Critical composite tempature time
+ * @temp_sensor: Tempature sensor <n> data
+ * @temp1_trans_cnt: Tempature 1 transition count
+ * @temp2_trans_cnt: Tempature 2 transition count
+ * @temp1_total_time: Total time for tempature 1
+ * @temp2_total_time: Total time for tempature 2
+ */
+struct nvme_smart_data {
+ uint8_t cwarn;
+ uint16_t temp;
+ uint8_t avail_spare;
+ uint8_t avail_spare_thr;
+ uint8_t percent_used;
+ uint8_t end_cwarn;
+ uint8_t reserved[25];
+ uint8_t data_units_read[16];
+ uint8_t data_units_written[16];
+ uint8_t host_reads[16];
+ uint8_t host_writes[16];
+ uint8_t ctrl_busy_time[16];
+ uint8_t power_cycles[16];
+ uint8_t power_on_hours[16];
+ uint8_t unsafe_shutdowns[16];
+ uint8_t media_errors[16];
+ uint8_t n_errlog_entries[16];
+ uint32_t warning_temp_time;
+ uint32_t critical_comp_time;
+ uint16_t temp_sensor[8];
+ uint32_t temp1_trans_cnt;
+ uint32_t temp2_trans_cnt;
+ uint32_t temp1_total_time;
+ uint32_t temp2_total_time;
+ uint8_t reserved1[280];
+};
+
struct nvme_identify_cmd {
uint8_t opcode;
uint8_t flags;
@@ -98,6 +160,26 @@ struct nvme_create_iosq_cmd {
uint64_t unused3[2];
};
+/* Get log page */
+struct nvme_get_logpage_cmd {
+ uint8_t opcode;
+ uint8_t flags;
+ uint16_t cid;
+ uint32_t nsid;
+ uint64_t unused[2];
+ uint64_t prp1;
+ uint64_t prp2;
+ uint8_t lid;
+ uint8_t lsp;
+ uint16_t numdl;
+ uint16_t numdu;
+ uint16_t lsi;
+ uint64_t lpo;
+ uint8_t unused1[3];
+ uint8_t csi;
+ uint32_t unused2;
+};
+
/* Read/write */
struct nvme_rw_cmd {
uint8_t opcode;
@@ -123,6 +205,7 @@ struct nvme_cmd {
struct nvme_identify_cmd identify;
struct nvme_create_iocq_cmd create_iocq;
struct nvme_create_iosq_cmd create_iosq;
+ struct nvme_get_logpage_cmd get_logpage;
struct nvme_rw_cmd rw;
};
};