summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-03 14:21:14 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-11-13 13:22:10 +0100
commitda6b9a1891abffa328f44e87443c97f1ed0721ee (patch)
tree4398a05b779639d1242a49cd4188faedf29cdf53
parentfed6e9be675f86cc19cdb72a77c7c7ef3d4fc5fe (diff)
downloadrtems-libbsd-da6b9a1891abffa328f44e87443c97f1ed0721ee.tar.bz2
NVME(4): Port to RTEMS
Update #3821.
-rw-r--r--buildset/default.ini1
-rw-r--r--freebsd/sys/dev/nvme/nvme.c2
-rw-r--r--freebsd/sys/dev/nvme/nvme_ctrlr.c6
-rw-r--r--freebsd/sys/dev/nvme/nvme_ns.c12
-rw-r--r--freebsd/sys/dev/nvme/nvme_ns_cmd.c4
-rw-r--r--freebsd/sys/dev/nvme/nvme_private.h4
-rw-r--r--freebsd/sys/dev/nvme/nvme_qpair.c2
-rw-r--r--rtemsbsd/include/rtems/bsd/local/opt_nvme.h0
8 files changed, 31 insertions, 0 deletions
diff --git a/buildset/default.ini b/buildset/default.ini
index f25fe9a3..43ea82a3 100644
--- a/buildset/default.ini
+++ b/buildset/default.ini
@@ -49,6 +49,7 @@ net80211 = off
netinet = on
netinet6 = on
netipsec = off
+nvme = on
opencrypto = on
pci = on
pf = on
diff --git a/freebsd/sys/dev/nvme/nvme.c b/freebsd/sys/dev/nvme/nvme.c
index a9ac0e77..20b328c9 100644
--- a/freebsd/sys/dev/nvme/nvme.c
+++ b/freebsd/sys/dev/nvme/nvme.c
@@ -73,6 +73,7 @@ nvme_init(void)
SYSINIT(nvme_register, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_init, NULL);
+#ifndef __rtems__
static void
nvme_uninit(void)
{
@@ -80,6 +81,7 @@ nvme_uninit(void)
}
SYSUNINIT(nvme_unregister, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_uninit, NULL);
+#endif /* __rtems__ */
int
nvme_shutdown(device_t dev)
diff --git a/freebsd/sys/dev/nvme/nvme_ctrlr.c b/freebsd/sys/dev/nvme/nvme_ctrlr.c
index e05cd961..4e6e9320 100644
--- a/freebsd/sys/dev/nvme/nvme_ctrlr.c
+++ b/freebsd/sys/dev/nvme/nvme_ctrlr.c
@@ -997,7 +997,9 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
{
struct nvme_request *req;
struct mtx *mtx;
+#ifndef __rtems__
struct buf *buf = NULL;
+#endif /* __rtems__ */
int ret = 0;
vm_offset_t addr, end;
@@ -1019,6 +1021,7 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
ctrlr->max_xfer_size);
return EIO;
}
+#ifndef __rtems__
if (is_user_buffer) {
/*
* Ensure the user buffer is wired for the duration of
@@ -1036,6 +1039,7 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
req = nvme_allocate_request_vaddr(buf->b_data, pt->len,
nvme_pt_done, pt);
} else
+#endif /* __rtems__ */
req = nvme_allocate_request_vaddr(pt->buf, pt->len,
nvme_pt_done, pt);
} else
@@ -1068,11 +1072,13 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr,
mtx_sleep(pt, mtx, PRIBIO, "nvme_pt", 0);
mtx_unlock(mtx);
+#ifndef __rtems__
err:
if (buf != NULL) {
relpbuf(buf, NULL);
PRELE(curproc);
}
+#endif /* __rtems__ */
return (ret);
}
diff --git a/freebsd/sys/dev/nvme/nvme_ns.c b/freebsd/sys/dev/nvme/nvme_ns.c
index 7cc59071..d23061da 100644
--- a/freebsd/sys/dev/nvme/nvme_ns.c
+++ b/freebsd/sys/dev/nvme/nvme_ns.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include "nvme_private.h"
+#ifndef __rtems__
static void nvme_bio_child_inbed(struct bio *parent, int bio_error);
static void nvme_bio_child_done(void *arg,
const struct nvme_completion *cpl);
@@ -63,6 +64,7 @@ static struct bio ** nvme_construct_child_bios(struct bio *bp,
static int nvme_ns_split_bio(struct nvme_namespace *ns,
struct bio *bp,
uint32_t alignment);
+#endif /* __rtems__ */
static int
nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
@@ -76,10 +78,12 @@ nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
ctrlr = ns->ctrlr;
switch (cmd) {
+#ifndef __rtems__
case NVME_IO_TEST:
case NVME_BIO_TEST:
nvme_ns_test(ns, cmd, arg);
break;
+#endif /* __rtems__ */
case NVME_PASSTHROUGH_CMD:
pt = (struct nvme_pt_command *)arg;
return (nvme_ctrlr_passthrough_cmd(ctrlr, pt, ns->id,
@@ -125,6 +129,7 @@ nvme_ns_close(struct cdev *dev __unused, int flags, int fmt __unused,
return (0);
}
+#ifndef __rtems__
static void
nvme_ns_strategy_done(void *arg, const struct nvme_completion *cpl)
{
@@ -161,15 +166,20 @@ nvme_ns_strategy(struct bio *bp)
}
}
+#endif /* __rtems__ */
static struct cdevsw nvme_ns_cdevsw = {
.d_version = D_VERSION,
.d_flags = D_DISK,
+#ifndef __rtems__
.d_read = physread,
.d_write = physwrite,
+#endif /* __rtems__ */
.d_open = nvme_ns_open,
.d_close = nvme_ns_close,
+#ifndef __rtems__
.d_strategy = nvme_ns_strategy,
+#endif /* __rtems__ */
.d_ioctl = nvme_ns_ioctl
};
@@ -240,6 +250,7 @@ nvme_ns_get_stripesize(struct nvme_namespace *ns)
return (ns->boundary);
}
+#ifndef __rtems__
static void
nvme_ns_bio_done(void *arg, const struct nvme_completion *status)
{
@@ -496,6 +507,7 @@ nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
return (err);
}
+#endif /* __rtems__ */
int
nvme_ns_ioctl_process(struct nvme_namespace *ns, u_long cmd, caddr_t arg,
diff --git a/freebsd/sys/dev/nvme/nvme_ns_cmd.c b/freebsd/sys/dev/nvme/nvme_ns_cmd.c
index 5fe2820e..70260869 100644
--- a/freebsd/sys/dev/nvme/nvme_ns_cmd.c
+++ b/freebsd/sys/dev/nvme/nvme_ns_cmd.c
@@ -52,6 +52,7 @@ nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload, uint64_t lba,
return (0);
}
+#ifndef __rtems__
int
nvme_ns_cmd_read_bio(struct nvme_namespace *ns, struct bio *bp,
nvme_cb_fn_t cb_fn, void *cb_arg)
@@ -73,6 +74,7 @@ nvme_ns_cmd_read_bio(struct nvme_namespace *ns, struct bio *bp,
return (0);
}
+#endif /* __rtems__ */
int
nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba,
@@ -93,6 +95,7 @@ nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba,
return (0);
}
+#ifndef __rtems__
int
nvme_ns_cmd_write_bio(struct nvme_namespace *ns, struct bio *bp,
nvme_cb_fn_t cb_fn, void *cb_arg)
@@ -113,6 +116,7 @@ nvme_ns_cmd_write_bio(struct nvme_namespace *ns, struct bio *bp,
return (0);
}
+#endif /* __rtems__ */
int
nvme_ns_cmd_deallocate(struct nvme_namespace *ns, void *payload,
diff --git a/freebsd/sys/dev/nvme/nvme_private.h b/freebsd/sys/dev/nvme/nvme_private.h
index d26d376c..7176fb3a 100644
--- a/freebsd/sys/dev/nvme/nvme_private.h
+++ b/freebsd/sys/dev/nvme/nvme_private.h
@@ -168,7 +168,11 @@ struct nvme_tracker {
uint16_t cid;
uint64_t *prp;
+#ifndef __rtems__
bus_addr_t prp_bus_addr;
+#else /* __rtems__ */
+ uint64_t prp_bus_addr;
+#endif /* __rtems__ */
};
struct nvme_qpair {
diff --git a/freebsd/sys/dev/nvme/nvme_qpair.c b/freebsd/sys/dev/nvme/nvme_qpair.c
index a9a3217c..a3afe73b 100644
--- a/freebsd/sys/dev/nvme/nvme_qpair.c
+++ b/freebsd/sys/dev/nvme/nvme_qpair.c
@@ -1064,6 +1064,7 @@ _nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req)
case NVME_REQUEST_NULL:
nvme_qpair_submit_tracker(tr->qpair, tr);
break;
+#ifndef __rtems__
case NVME_REQUEST_BIO:
KASSERT(req->u.bio->bio_bcount <= qpair->ctrlr->max_xfer_size,
("bio->bio_bcount (%jd) exceeds max_xfer_size (%d)\n",
@@ -1083,6 +1084,7 @@ _nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req)
nvme_printf(qpair->ctrlr,
"bus_dmamap_load_ccb returned 0x%x!\n", err);
break;
+#endif /* __rtems__ */
default:
panic("unknown nvme request type 0x%x\n", req->type);
break;
diff --git a/rtemsbsd/include/rtems/bsd/local/opt_nvme.h b/rtemsbsd/include/rtems/bsd/local/opt_nvme.h
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/opt_nvme.h