summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-09-20 07:57:01 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-11-13 13:22:36 +0100
commitafaeccc05a556f6aa25ba044a7e49d6aa634a59e (patch)
tree09021686e43641fe7f2ec89996a808a5ca3f06e4
parent380ef1755df322afdc22278f1011a5893472e5cf (diff)
downloadrtems-libbsd-afaeccc05a556f6aa25ba044a7e49d6aa634a59e.tar.bz2
NVMECONTROL(8): Port to RTEMS
Update #3821.
-rw-r--r--freebsd/sbin/nvmecontrol/comnd.c26
-rw-r--r--freebsd/sbin/nvmecontrol/comnd.h36
-rw-r--r--freebsd/sbin/nvmecontrol/devlist.c3
-rw-r--r--freebsd/sbin/nvmecontrol/firmware.c3
-rw-r--r--freebsd/sbin/nvmecontrol/format.c3
-rw-r--r--freebsd/sbin/nvmecontrol/identify.c3
-rw-r--r--freebsd/sbin/nvmecontrol/identify_ext.c3
-rw-r--r--freebsd/sbin/nvmecontrol/logpage.c3
-rw-r--r--freebsd/sbin/nvmecontrol/modules/intel/intel.c5
-rw-r--r--freebsd/sbin/nvmecontrol/modules/wdc/wdc.c5
-rw-r--r--freebsd/sbin/nvmecontrol/nc_util.c3
-rw-r--r--freebsd/sbin/nvmecontrol/ns.c7
-rw-r--r--freebsd/sbin/nvmecontrol/nsid.c3
-rw-r--r--freebsd/sbin/nvmecontrol/nvmecontrol.c61
-rw-r--r--freebsd/sbin/nvmecontrol/nvmecontrol.h21
-rw-r--r--freebsd/sbin/nvmecontrol/passthru.c3
-rw-r--r--freebsd/sbin/nvmecontrol/perftest.c3
-rw-r--r--freebsd/sbin/nvmecontrol/power.c3
-rw-r--r--freebsd/sbin/nvmecontrol/reset.c3
-rw-r--r--freebsd/sbin/nvmecontrol/resv.c3
-rw-r--r--freebsd/sbin/nvmecontrol/sanitize.c3
-rw-r--r--freebsd/sbin/nvmecontrol/wdc.c5
-rw-r--r--libbsd.py1
-rw-r--r--rtemsbsd/include/machine/rtems-bsd-commands.h2
-rw-r--r--rtemsbsd/include/rtems/netcmds-config.h3
-rw-r--r--rtemsbsd/rtems/rtems-bsd-shell-nvmecontrol.c34
26 files changed, 241 insertions, 7 deletions
diff --git a/freebsd/sbin/nvmecontrol/comnd.c b/freebsd/sbin/nvmecontrol/comnd.c
index 3074cfb9..a4fa686f 100644
--- a/freebsd/sbin/nvmecontrol/comnd.c
+++ b/freebsd/sbin/nvmecontrol/comnd.c
@@ -27,6 +27,11 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#define __need_getopt_newlib
+#include <getopt.h>
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -182,6 +187,16 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
char *shortopts, *p;
const struct opts *opts = f->opts;
const struct args *args = f->args;
+#ifdef __rtems__
+ struct getopt_data getopt_data;
+ memset(&getopt_data, 0, sizeof(getopt_data));
+#define optind getopt_data.optind
+#define optarg getopt_data.optarg
+#define opterr getopt_data.opterr
+#define optopt getopt_data.optopt
+#define getopt_long(argc, argv, shortopts, longopts, longind) \
+ getopt_long_r(argc, argv, shortopts, longopts, longind, &getopt_data)
+#endif /* __rtems__ */
if (opts == NULL)
n = 0;
@@ -191,9 +206,16 @@ arg_parse(int argc, char * const * argv, const struct cmd *f)
lopts = malloc((n + 2) * sizeof(struct option));
if (lopts == NULL)
err(1, "option memory");
- p = shortopts = malloc((n + 3) * sizeof(char));
+#ifndef __rtems__
+ p = shortopts = malloc((2 * n + 2) * sizeof(char));
+#else /* __rtems__ */
+ p = shortopts = malloc((2 * n + 3) * sizeof(char));
+#endif /* __rtems__ */
if (shortopts == NULL)
err(1, "shortopts memory");
+#ifdef __rtems__
+ *p++ = '+';
+#endif /* __rtems__ */
idx = 0;
for (i = 0; i < n; i++) {
lopts[i].name = opts[i].long_arg;
@@ -284,6 +306,7 @@ bad_arg:
exit(1);
}
+#ifndef __rtems__
/*
* Loads all the .so's from the specified directory.
*/
@@ -315,6 +338,7 @@ cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __u
}
closedir(d);
}
+#endif /* __rtems__ */
void
cmd_register(struct cmd *up, struct cmd *cmd)
diff --git a/freebsd/sbin/nvmecontrol/comnd.h b/freebsd/sbin/nvmecontrol/comnd.h
index 91c97d4a..0f06cd29 100644
--- a/freebsd/sbin/nvmecontrol/comnd.h
+++ b/freebsd/sbin/nvmecontrol/comnd.h
@@ -86,12 +86,48 @@ struct cmd {
};
void cmd_register(struct cmd *, struct cmd *);
+#ifndef __rtems__
#define CMD_COMMAND(c) \
static void cmd_register_##c(void) __attribute__((constructor)); \
static void cmd_register_##c(void) { cmd_register(NULL, &c); }
#define CMD_SUBCOMMAND(c,sc) \
static void cmd_register_##c_##sc(void) __attribute__((constructor)); \
static void cmd_register_##c_##sc(void) { cmd_register(&c, &sc); }
+#else /* __rtems__ */
+#define CMD_COMMAND(c) \
+ void cmd_register_##c(void) { cmd_register(NULL, &c); }
+#define CMD_SUBCOMMAND(c,sc) \
+ void cmd_register_##c##_##sc(void) { cmd_register(&c, &sc); }
+void cmd_register_admin_pass_cmd(void);
+void cmd_register_devlist_cmd(void);
+void cmd_register_firmware_cmd(void);
+void cmd_register_format_cmd(void);
+void cmd_register_identify_cmd(void);
+void cmd_register_io_pass_cmd(void);
+void cmd_register_logpage_cmd(void);
+void cmd_register_ns_cmd(void);
+void cmd_register_ns_cmd_active_cmd(void);
+void cmd_register_ns_cmd_allocated_cmd(void);
+void cmd_register_ns_cmd_attach_cmd(void);
+void cmd_register_ns_cmd_attached_cmd(void);
+void cmd_register_ns_cmd_controllers_cmd(void);
+void cmd_register_ns_cmd_create_cmd(void);
+void cmd_register_ns_cmd_delete_cmd(void);
+void cmd_register_ns_cmd_detach_cmd(void);
+void cmd_register_ns_cmd_identify_cmd(void);
+void cmd_register_nsid_cmd(void);
+void cmd_register_perftest_cmd(void);
+void cmd_register_power_cmd(void);
+void cmd_register_reset_cmd(void);
+void cmd_register_resv_cmd(void);
+void cmd_register_resv_cmd_acquire_cmd(void);
+void cmd_register_resv_cmd_register_cmd(void);
+void cmd_register_resv_cmd_release_cmd(void);
+void cmd_register_resv_cmd_report_cmd(void);
+void cmd_register_sanitize_cmd(void);
+void cmd_register_wdc_cmd(void);
+void cmd_register_wdc_cmd_cap_diag_cmd(void);
+#endif /* __rtems__ */
int arg_parse(int argc, char * const *argv, const struct cmd *f);
void arg_help(int argc, char * const *argv, const struct cmd *f);
diff --git a/freebsd/sbin/nvmecontrol/devlist.c b/freebsd/sbin/nvmecontrol/devlist.c
index 58e1153b..543c358f 100644
--- a/freebsd/sbin/nvmecontrol/devlist.c
+++ b/freebsd/sbin/nvmecontrol/devlist.c
@@ -28,6 +28,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/firmware.c b/freebsd/sbin/nvmecontrol/firmware.c
index 482ceb3c..0c4a264e 100644
--- a/freebsd/sbin/nvmecontrol/firmware.c
+++ b/freebsd/sbin/nvmecontrol/firmware.c
@@ -31,6 +31,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/format.c b/freebsd/sbin/nvmecontrol/format.c
index 95b57cb4..0ed693f9 100644
--- a/freebsd/sbin/nvmecontrol/format.c
+++ b/freebsd/sbin/nvmecontrol/format.c
@@ -27,6 +27,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/identify.c b/freebsd/sbin/nvmecontrol/identify.c
index be2fb00c..e494fb59 100644
--- a/freebsd/sbin/nvmecontrol/identify.c
+++ b/freebsd/sbin/nvmecontrol/identify.c
@@ -29,6 +29,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/identify_ext.c b/freebsd/sbin/nvmecontrol/identify_ext.c
index 2ec8f100..44e0011b 100644
--- a/freebsd/sbin/nvmecontrol/identify_ext.c
+++ b/freebsd/sbin/nvmecontrol/identify_ext.c
@@ -29,6 +29,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/logpage.c b/freebsd/sbin/nvmecontrol/logpage.c
index 7a36f17a..8ab50bea 100644
--- a/freebsd/sbin/nvmecontrol/logpage.c
+++ b/freebsd/sbin/nvmecontrol/logpage.c
@@ -30,6 +30,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/modules/intel/intel.c b/freebsd/sbin/nvmecontrol/modules/intel/intel.c
index 8c6c2564..1dcd3a09 100644
--- a/freebsd/sbin/nvmecontrol/modules/intel/intel.c
+++ b/freebsd/sbin/nvmecontrol/modules/intel/intel.c
@@ -31,6 +31,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -48,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <sys/endian.h>
-#include "nvmecontrol.h"
+#include "../../nvmecontrol.h"
/*
* Intel specific log pages from
diff --git a/freebsd/sbin/nvmecontrol/modules/wdc/wdc.c b/freebsd/sbin/nvmecontrol/modules/wdc/wdc.c
index 4a6a90dc..3cd5cdb7 100644
--- a/freebsd/sbin/nvmecontrol/modules/wdc/wdc.c
+++ b/freebsd/sbin/nvmecontrol/modules/wdc/wdc.c
@@ -26,6 +26,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -42,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-#include "nvmecontrol.h"
+#include "../../nvmecontrol.h"
/* Tables for command line parsing */
diff --git a/freebsd/sbin/nvmecontrol/nc_util.c b/freebsd/sbin/nvmecontrol/nc_util.c
index 443bef24..f2818871 100644
--- a/freebsd/sbin/nvmecontrol/nc_util.c
+++ b/freebsd/sbin/nvmecontrol/nc_util.c
@@ -26,6 +26,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/ns.c b/freebsd/sbin/nvmecontrol/ns.c
index bb9b0011..841c1a87 100644
--- a/freebsd/sbin/nvmecontrol/ns.c
+++ b/freebsd/sbin/nvmecontrol/ns.c
@@ -28,6 +28,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -368,7 +371,7 @@ struct ns_result_str {
const char * str;
};
-static struct ns_result_str ns_result[] = {
+static const struct ns_result_str ns_result[] = {
{ 0x2, "Invalid Field"},
{ 0xa, "Invalid Format"},
{ 0xb, "Invalid Namespace or format"},
@@ -387,7 +390,7 @@ static struct ns_result_str ns_result[] = {
static const char *
get_res_str(uint16_t res)
{
- struct ns_result_str *t = ns_result;
+ const struct ns_result_str *t = ns_result;
while (t->res != 0xFFFF) {
if (t->res == res)
diff --git a/freebsd/sbin/nvmecontrol/nsid.c b/freebsd/sbin/nvmecontrol/nsid.c
index 74ed06c8..f12b78ea 100644
--- a/freebsd/sbin/nvmecontrol/nsid.c
+++ b/freebsd/sbin/nvmecontrol/nsid.c
@@ -27,6 +27,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/nvmecontrol.c b/freebsd/sbin/nvmecontrol/nvmecontrol.c
index c33d42ef..4fcef3b5 100644
--- a/freebsd/sbin/nvmecontrol/nvmecontrol.c
+++ b/freebsd/sbin/nvmecontrol/nvmecontrol.c
@@ -1,4 +1,4 @@
-#include <machine/rtems-bsd-kernel-space.h>
+#include <machine/rtems-bsd-user-space.h>
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -28,6 +28,11 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include <machine/rtems-bsd-commands.h>
+#include <pthread.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -175,14 +180,68 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid)
*nsid = gnsid.nsid;
}
+#ifdef __rtems__
+static int main(int argc, char *argv[]);
+
+static pthread_once_t nvmecontrol_once = PTHREAD_ONCE_INIT;
+
+static void
+nvmecontrol_cmd_register(void)
+{
+
+ cmd_register_admin_pass_cmd();
+ cmd_register_devlist_cmd();
+ cmd_register_firmware_cmd();
+ cmd_register_format_cmd();
+ cmd_register_identify_cmd();
+ cmd_register_io_pass_cmd();
+ cmd_register_logpage_cmd();
+ cmd_register_ns_cmd();
+ cmd_register_ns_cmd_active_cmd();
+ cmd_register_ns_cmd_allocated_cmd();
+ cmd_register_ns_cmd_attach_cmd();
+ cmd_register_ns_cmd_attached_cmd();
+ cmd_register_ns_cmd_controllers_cmd();
+ cmd_register_ns_cmd_create_cmd();
+ cmd_register_ns_cmd_delete_cmd();
+ cmd_register_ns_cmd_detach_cmd();
+ cmd_register_ns_cmd_identify_cmd();
+ cmd_register_nsid_cmd();
+ cmd_register_power_cmd();
+ cmd_register_reset_cmd();
+ cmd_register_resv_cmd();
+ cmd_register_resv_cmd_acquire_cmd();
+ cmd_register_resv_cmd_register_cmd();
+ cmd_register_resv_cmd_release_cmd();
+ cmd_register_resv_cmd_report_cmd();
+ cmd_register_sanitize_cmd();
+}
+
+int
+rtems_bsd_command_nvmecontrol(int argc, char *argv[])
+{
+ int exit_code;
+
+ pthread_once(&nvmecontrol_once, nvmecontrol_cmd_register);
+
+ rtems_bsd_program_lock();
+ exit_code = rtems_bsd_program_call_main("nvmecontrol", main, argc,
+ argv);
+ rtems_bsd_program_unlock();
+
+ return exit_code;
+}
+#endif /* __rtems__ */
int
main(int argc, char *argv[])
{
cmd_init();
+#ifndef __rtems__
cmd_load_dir("/lib/nvmecontrol", NULL, NULL);
cmd_load_dir("/usr/local/lib/nvmecontrol", NULL, NULL);
+#endif /* __rtems__ */
cmd_dispatch(argc, argv, NULL);
diff --git a/freebsd/sbin/nvmecontrol/nvmecontrol.h b/freebsd/sbin/nvmecontrol/nvmecontrol.h
index f5dc61f2..138ca80c 100644
--- a/freebsd/sbin/nvmecontrol/nvmecontrol.h
+++ b/freebsd/sbin/nvmecontrol/nvmecontrol.h
@@ -33,6 +33,9 @@
#include <dev/nvme/nvme.h>
#include "comnd.h"
+#ifdef __rtems__
+#include <sys/ioctl.h>
+#endif /* __rtems__ */
typedef void (*print_fn_t)(const struct nvme_controller_data *cdata, void *buf, uint32_t size);
@@ -87,6 +90,7 @@ void print_intel_add_smart(const struct nvme_controller_data *cdata __unused, vo
* ints in sofware.
*/
#define UINT128_DIG 39
+#ifndef __rtems__
#ifdef __i386__
typedef uint64_t uint128_t;
#else
@@ -98,6 +102,23 @@ to128(void *p)
{
return *(uint128_t *)p;
}
+#else /* __rtems__ */
+#if __SIZEOF_LONG__ < 8
+typedef uint64_t uint128_t;
+#else
+typedef unsigned __int128 uint128_t;
+#endif
+
+static __inline uint128_t
+to128(void *p)
+{
+#if __SIZEOF_LONG__ < 8 && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ return *(uint128_t *)(char *)(p + 8);
+#else
+ return *(uint128_t *)p;
+#endif
+}
+#endif /* __rtems__ */
uint64_t le48dec(const void *pp);
char * uint128_to_str(uint128_t u, char *buf, size_t buflen);
diff --git a/freebsd/sbin/nvmecontrol/passthru.c b/freebsd/sbin/nvmecontrol/passthru.c
index 979cc873..5705ec1f 100644
--- a/freebsd/sbin/nvmecontrol/passthru.c
+++ b/freebsd/sbin/nvmecontrol/passthru.c
@@ -28,6 +28,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/perftest.c b/freebsd/sbin/nvmecontrol/perftest.c
index 6f6bacbf..5d135400 100644
--- a/freebsd/sbin/nvmecontrol/perftest.c
+++ b/freebsd/sbin/nvmecontrol/perftest.c
@@ -28,6 +28,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/power.c b/freebsd/sbin/nvmecontrol/power.c
index e33680a0..9f6eeda4 100644
--- a/freebsd/sbin/nvmecontrol/power.c
+++ b/freebsd/sbin/nvmecontrol/power.c
@@ -26,6 +26,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/reset.c b/freebsd/sbin/nvmecontrol/reset.c
index 519594e3..ad5cfc6a 100644
--- a/freebsd/sbin/nvmecontrol/reset.c
+++ b/freebsd/sbin/nvmecontrol/reset.c
@@ -28,6 +28,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/resv.c b/freebsd/sbin/nvmecontrol/resv.c
index 5f615941..b22b390a 100644
--- a/freebsd/sbin/nvmecontrol/resv.c
+++ b/freebsd/sbin/nvmecontrol/resv.c
@@ -27,6 +27,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/sanitize.c b/freebsd/sbin/nvmecontrol/sanitize.c
index cc8e2417..21b6927a 100644
--- a/freebsd/sbin/nvmecontrol/sanitize.c
+++ b/freebsd/sbin/nvmecontrol/sanitize.c
@@ -27,6 +27,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/freebsd/sbin/nvmecontrol/wdc.c b/freebsd/sbin/nvmecontrol/wdc.c
index 0c7f3c90..f12a2284 100644
--- a/freebsd/sbin/nvmecontrol/wdc.c
+++ b/freebsd/sbin/nvmecontrol/wdc.c
@@ -26,6 +26,9 @@
* SUCH DAMAGE.
*/
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -53,7 +56,7 @@ static void wdc_cap_diag(int argc, char *argv[]);
#define WDC_CAP_DIAG_USAGE "\tnvmecontrol wdc cap-diag [-o path-template]\n"
-static struct nvme_function wdc_funcs[] = {
+static const struct nvme_function wdc_funcs[] = {
{"cap-diag", wdc_cap_diag, WDC_CAP_DIAG_USAGE},
{NULL, NULL, NULL},
};
diff --git a/libbsd.py b/libbsd.py
index e632e5be..efa30faf 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -179,6 +179,7 @@ class rtems(builder.Module):
'rtems/rtems-bsd-shell-arp.c',
'rtems/rtems-bsd-shell-ifconfig.c',
'rtems/rtems-bsd-shell-netstat.c',
+ 'rtems/rtems-bsd-shell-nvmecontrol.c',
'rtems/rtems-bsd-shell-pfctl.c',
'rtems/rtems-bsd-shell-ping.c',
'rtems/rtems-bsd-shell-route.c',
diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h b/rtemsbsd/include/machine/rtems-bsd-commands.h
index 1b022902..036734ee 100644
--- a/rtemsbsd/include/machine/rtems-bsd-commands.h
+++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
@@ -52,6 +52,8 @@ int rtems_bsd_command_ifconfig(int argc, char **argv);
int rtems_bsd_command_netstat(int argc, char **argv);
+int rtems_bsd_command_nvmecontrol(int argc, char **argv);
+
int rtems_bsd_command_pfctl(int argc, char **argv);
int rtems_bsd_command_ping(int argc, char **argv);
diff --git a/rtemsbsd/include/rtems/netcmds-config.h b/rtemsbsd/include/rtems/netcmds-config.h
index f8dcdcdc..bba2d307 100644
--- a/rtemsbsd/include/rtems/netcmds-config.h
+++ b/rtemsbsd/include/rtems/netcmds-config.h
@@ -55,6 +55,9 @@ extern rtems_shell_cmd_t rtems_shell_RACOON_Command;
extern rtems_shell_cmd_t rtems_shell_SETKEY_Command;
extern rtems_shell_cmd_t rtems_shell_OPENSSL_Command;
+
+extern rtems_shell_cmd_t rtems_shell_NVMECONTROL_Command;
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/rtemsbsd/rtems/rtems-bsd-shell-nvmecontrol.c b/rtemsbsd/rtems/rtems-bsd-shell-nvmecontrol.c
new file mode 100644
index 00000000..56ae8c41
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-shell-nvmecontrol.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <rtems/netcmds-config.h>
+#include <machine/rtems-bsd-commands.h>
+
+rtems_shell_cmd_t rtems_shell_NVMECONTROL_Command = {
+ .name = "nvmecontrol",
+ .usage = "nvmecontrol [args]",
+ .topic = "net",
+ .command = rtems_bsd_command_nvmecontrol
+};