Changeset e6acc15 in rtems-libbsd


Ignore:
Timestamp:
Sep 20, 2019, 5:57:01 AM (3 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Parents:
615fb19
git-author:
Sebastian Huber <sebastian.huber@…> (09/20/19 05:57:01)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/13/19 12:04:09)
Message:

NVMECONTROL(8): Port to RTEMS

Update #3821.

Files:
1 added
24 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sbin/nvmecontrol/comnd.c

    r615fb19 re6acc15  
    2828 */
    2929
     30#ifdef __rtems__
     31#define __need_getopt_newlib
     32#include <getopt.h>
     33#include <machine/rtems-bsd-program.h>
     34#endif /* __rtems__ */
    3035#include <sys/cdefs.h>
    3136__FBSDID("$FreeBSD$");
     
    183188        const struct opts *opts = f->opts;
    184189        const struct args *args = f->args;
     190#ifdef __rtems__
     191        struct getopt_data getopt_data;
     192        memset(&getopt_data, 0, sizeof(getopt_data));
     193#define optind getopt_data.optind
     194#define optarg getopt_data.optarg
     195#define opterr getopt_data.opterr
     196#define optopt getopt_data.optopt
     197#define getopt_long(argc, argv, shortopts, longopts, longind) \
     198    getopt_long_r(argc, argv, shortopts, longopts, longind, &getopt_data)
     199#endif /* __rtems__ */
    185200
    186201        if (opts == NULL)
     
    195210        if (shortopts == NULL)
    196211                err(1, "shortopts memory");
     212#ifdef __rtems__
     213        *p++ = '+';
     214#endif /* __rtems__ */
    197215        idx = 0;
    198216        for (i = 0; i < n; i++) {
     
    285303}
    286304
     305#ifndef __rtems__
    287306/*
    288307 * Loads all the .so's from the specified directory.
     
    316335        closedir(d);
    317336}
     337#endif /* __rtems__ */
    318338
    319339void
  • freebsd/sbin/nvmecontrol/comnd.h

    r615fb19 re6acc15  
    8787
    8888void cmd_register(struct cmd *, struct cmd *);
     89#ifndef __rtems__
    8990#define CMD_COMMAND(c)                                                  \
    9091    static void cmd_register_##c(void) __attribute__((constructor));    \
     
    9394    static void cmd_register_##c_##sc(void) __attribute__((constructor)); \
    9495    static void cmd_register_##c_##sc(void) { cmd_register(&c, &sc); }
     96#else /* __rtems__ */
     97#define CMD_COMMAND(c)                                                  \
     98    void cmd_register_##c(void) { cmd_register(NULL, &c); }
     99#define CMD_SUBCOMMAND(c,sc)                                            \
     100    void cmd_register_##c##_##sc(void) { cmd_register(&c, &sc); }
     101void cmd_register_admin_pass_cmd(void);
     102void cmd_register_devlist_cmd(void);
     103void cmd_register_firmware_cmd(void);
     104void cmd_register_format_cmd(void);
     105void cmd_register_identify_cmd(void);
     106void cmd_register_io_pass_cmd(void);
     107void cmd_register_logpage_cmd(void);
     108void cmd_register_ns_cmd(void);
     109void cmd_register_ns_cmd_active_cmd(void);
     110void cmd_register_ns_cmd_allocated_cmd(void);
     111void cmd_register_ns_cmd_attach_cmd(void);
     112void cmd_register_ns_cmd_attached_cmd(void);
     113void cmd_register_ns_cmd_controllers_cmd(void);
     114void cmd_register_ns_cmd_create_cmd(void);
     115void cmd_register_ns_cmd_delete_cmd(void);
     116void cmd_register_ns_cmd_detach_cmd(void);
     117void cmd_register_ns_cmd_identify_cmd(void);
     118void cmd_register_nsid_cmd(void);
     119void cmd_register_perftest_cmd(void);
     120void cmd_register_power_cmd(void);
     121void cmd_register_reset_cmd(void);
     122void cmd_register_resv_cmd(void);
     123void cmd_register_resv_cmd_acquire_cmd(void);
     124void cmd_register_resv_cmd_register_cmd(void);
     125void cmd_register_resv_cmd_release_cmd(void);
     126void cmd_register_resv_cmd_report_cmd(void);
     127void cmd_register_sanitize_cmd(void);
     128void cmd_register_wdc_cmd(void);
     129void cmd_register_wdc_cmd_cap_diag_cmd(void);
     130#endif /* __rtems__ */
    95131
    96132int arg_parse(int argc, char * const *argv, const struct cmd *f);
  • freebsd/sbin/nvmecontrol/devlist.c

    r615fb19 re6acc15  
    2929 */
    3030
     31#ifdef __rtems__
     32#include <machine/rtems-bsd-program.h>
     33#endif /* __rtems__ */
    3134#include <sys/cdefs.h>
    3235__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/firmware.c

    r615fb19 re6acc15  
    3232 */
    3333
     34#ifdef __rtems__
     35#include <machine/rtems-bsd-program.h>
     36#endif /* __rtems__ */
    3437#include <sys/cdefs.h>
    3538__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/format.c

    r615fb19 re6acc15  
    2828 */
    2929
     30#ifdef __rtems__
     31#include <machine/rtems-bsd-program.h>
     32#endif /* __rtems__ */
    3033#include <sys/cdefs.h>
    3134__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/identify.c

    r615fb19 re6acc15  
    3030 */
    3131
     32#ifdef __rtems__
     33#include <machine/rtems-bsd-program.h>
     34#endif /* __rtems__ */
    3235#include <sys/cdefs.h>
    3336__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/identify_ext.c

    r615fb19 re6acc15  
    3030 */
    3131
     32#ifdef __rtems__
     33#include <machine/rtems-bsd-program.h>
     34#endif /* __rtems__ */
    3235#include <sys/cdefs.h>
    3336__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/logpage.c

    r615fb19 re6acc15  
    3333 */
    3434
     35#ifdef __rtems__
     36#include <machine/rtems-bsd-program.h>
     37#endif /* __rtems__ */
    3538#include <sys/cdefs.h>
    3639__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/modules/intel/intel.c

    r615fb19 re6acc15  
    3232 */
    3333
     34#ifdef __rtems__
     35#include <machine/rtems-bsd-program.h>
     36#endif /* __rtems__ */
    3437#include <sys/cdefs.h>
    3538__FBSDID("$FreeBSD$");
     
    4952#include <sys/endian.h>
    5053
    51 #include "nvmecontrol.h"
     54#include "../../nvmecontrol.h"
    5255
    5356/*
  • freebsd/sbin/nvmecontrol/modules/wdc/wdc.c

    r615fb19 re6acc15  
    2626 */
    2727
     28#ifdef __rtems__
     29#include <machine/rtems-bsd-program.h>
     30#endif /* __rtems__ */
    2831#include <sys/cdefs.h>
    2932__FBSDID("$FreeBSD$");
     
    4245#include <unistd.h>
    4346
    44 #include "nvmecontrol.h"
     47#include "../../nvmecontrol.h"
    4548
    4649/* Tables for command line parsing */
  • freebsd/sbin/nvmecontrol/nc_util.c

    r615fb19 re6acc15  
    2828 */
    2929
     30#ifdef __rtems__
     31#include <machine/rtems-bsd-program.h>
     32#endif /* __rtems__ */
    3033#include <sys/cdefs.h>
    3134__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/ns.c

    r615fb19 re6acc15  
    2929 */
    3030
     31#ifdef __rtems__
     32#include <machine/rtems-bsd-program.h>
     33#endif /* __rtems__ */
    3134#include <sys/cdefs.h>
    3235__FBSDID("$FreeBSD$");
     
    369372};
    370373
    371 static struct ns_result_str ns_result[] = {
     374static const struct ns_result_str ns_result[] = {
    372375        { 0x2,  "Invalid Field"},
    373376        { 0xa,  "Invalid Format"},
     
    388391get_res_str(uint16_t res)
    389392{
    390         struct ns_result_str *t = ns_result;
     393        const struct ns_result_str *t = ns_result;
    391394
    392395        while (t->res != 0xFFFF) {
  • freebsd/sbin/nvmecontrol/nsid.c

    r615fb19 re6acc15  
    2828 */
    2929
     30#ifdef __rtems__
     31#include <machine/rtems-bsd-program.h>
     32#endif /* __rtems__ */
    3033#include <sys/cdefs.h>
    3134__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/nvmecontrol.c

    r615fb19 re6acc15  
    2929 */
    3030
     31#ifdef __rtems__
     32#include <machine/rtems-bsd-program.h>
     33#include <machine/rtems-bsd-commands.h>
     34#include <pthread.h>
     35#endif /* __rtems__ */
    3136#include <sys/cdefs.h>
    3237__FBSDID("$FreeBSD$");
     
    176181}
    177182
     183#ifdef __rtems__
     184static int main(int argc, char *argv[]);
     185
     186static pthread_once_t nvmecontrol_once = PTHREAD_ONCE_INIT;
     187
     188static void
     189nvmecontrol_cmd_register(void)
     190{
     191
     192        cmd_register_admin_pass_cmd();
     193        cmd_register_devlist_cmd();
     194        cmd_register_firmware_cmd();
     195        cmd_register_format_cmd();
     196        cmd_register_identify_cmd();
     197        cmd_register_io_pass_cmd();
     198        cmd_register_logpage_cmd();
     199        cmd_register_ns_cmd();
     200        cmd_register_ns_cmd_active_cmd();
     201        cmd_register_ns_cmd_allocated_cmd();
     202        cmd_register_ns_cmd_attach_cmd();
     203        cmd_register_ns_cmd_attached_cmd();
     204        cmd_register_ns_cmd_controllers_cmd();
     205        cmd_register_ns_cmd_create_cmd();
     206        cmd_register_ns_cmd_delete_cmd();
     207        cmd_register_ns_cmd_detach_cmd();
     208        cmd_register_ns_cmd_identify_cmd();
     209        cmd_register_nsid_cmd();
     210        cmd_register_power_cmd();
     211        cmd_register_reset_cmd();
     212        cmd_register_resv_cmd();
     213        cmd_register_resv_cmd_acquire_cmd();
     214        cmd_register_resv_cmd_register_cmd();
     215        cmd_register_resv_cmd_release_cmd();
     216        cmd_register_resv_cmd_report_cmd();
     217        cmd_register_sanitize_cmd();
     218}
     219
     220int
     221rtems_bsd_command_nvmecontrol(int argc, char *argv[])
     222{
     223        int exit_code;
     224
     225        pthread_once(&nvmecontrol_once, nvmecontrol_cmd_register);
     226
     227        rtems_bsd_program_lock();
     228        exit_code = rtems_bsd_program_call_main("nvmecontrol", main, argc,
     229            argv);
     230        rtems_bsd_program_unlock();
     231
     232        return exit_code;
     233}
     234#endif /* __rtems__ */
    178235int
    179236main(int argc, char *argv[])
     
    182239        cmd_init();
    183240
     241#ifndef __rtems__
    184242        cmd_load_dir("/lib/nvmecontrol", NULL, NULL);
    185243        cmd_load_dir("/usr/local/lib/nvmecontrol", NULL, NULL);
     244#endif /* __rtems__ */
    186245
    187246        cmd_dispatch(argc, argv, NULL);
  • freebsd/sbin/nvmecontrol/nvmecontrol.h

    r615fb19 re6acc15  
    3434#include <dev/nvme/nvme.h>
    3535#include "comnd.h"
     36#ifdef __rtems__
     37#include <sys/ioctl.h>
     38#endif /* __rtems__ */
    3639
    3740typedef void (*print_fn_t)(const struct nvme_controller_data *cdata, void *buf, uint32_t size);
     
    8891 */
    8992#define UINT128_DIG     39
     93#ifndef __rtems__
    9094#ifdef __i386__
    9195typedef uint64_t uint128_t;
     
    99103        return *(uint128_t *)p;
    100104}
     105#else /* __rtems__ */
     106#if __SIZEOF_LONG__ < 8
     107typedef uint64_t uint128_t;
     108#else
     109typedef unsigned __int128 uint128_t;
     110#endif
     111
     112static __inline uint128_t
     113to128(void *p)
     114{
     115#if __SIZEOF_LONG__ < 8 && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
     116        return *(uint128_t *)(char *)(p + 8);
     117#else
     118        return *(uint128_t *)p;
     119#endif
     120}
     121#endif /* __rtems__ */
    101122
    102123uint64_t le48dec(const void *pp);
  • freebsd/sbin/nvmecontrol/passthru.c

    r615fb19 re6acc15  
    2929 */
    3030
     31#ifdef __rtems__
     32#include <machine/rtems-bsd-program.h>
     33#endif /* __rtems__ */
    3134#include <sys/cdefs.h>
    3235__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/perftest.c

    r615fb19 re6acc15  
    2929 */
    3030
     31#ifdef __rtems__
     32#include <machine/rtems-bsd-program.h>
     33#endif /* __rtems__ */
    3134#include <sys/cdefs.h>
    3235__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/power.c

    r615fb19 re6acc15  
    2626 */
    2727
     28#ifdef __rtems__
     29#include <machine/rtems-bsd-program.h>
     30#endif /* __rtems__ */
    2831#include <sys/cdefs.h>
    2932__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/reset.c

    r615fb19 re6acc15  
    2929 */
    3030
     31#ifdef __rtems__
     32#include <machine/rtems-bsd-program.h>
     33#endif /* __rtems__ */
    3134#include <sys/cdefs.h>
    3235__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/resv.c

    r615fb19 re6acc15  
    2828 */
    2929
     30#ifdef __rtems__
     31#include <machine/rtems-bsd-program.h>
     32#endif /* __rtems__ */
    3033#include <sys/cdefs.h>
    3134__FBSDID("$FreeBSD$");
  • freebsd/sbin/nvmecontrol/sanitize.c

    r615fb19 re6acc15  
    2828 */
    2929
     30#ifdef __rtems__
     31#include <machine/rtems-bsd-program.h>
     32#endif /* __rtems__ */
    3033#include <sys/cdefs.h>
    3134__FBSDID("$FreeBSD$");
  • libbsd.py

    r615fb19 re6acc15  
    182182                'rtems/rtems-bsd-shell-ifconfig.c',
    183183                'rtems/rtems-bsd-shell-netstat.c',
     184                'rtems/rtems-bsd-shell-nvmecontrol.c',
    184185                'rtems/rtems-bsd-shell-pfctl.c',
    185186                'rtems/rtems-bsd-shell-ping.c',
  • rtemsbsd/include/machine/rtems-bsd-commands.h

    r615fb19 re6acc15  
    5353int rtems_bsd_command_netstat(int argc, char **argv);
    5454
     55int rtems_bsd_command_nvmecontrol(int argc, char **argv);
     56
    5557int rtems_bsd_command_pfctl(int argc, char **argv);
    5658
  • rtemsbsd/include/rtems/netcmds-config.h

    r615fb19 re6acc15  
    5858
    5959extern rtems_shell_cmd_t rtems_shell_OPENSSL_Command;
     60
     61extern rtems_shell_cmd_t rtems_shell_NVMECONTROL_Command;
     62
    6063#ifdef __cplusplus
    6164}
Note: See TracChangeset for help on using the changeset viewer.