summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2020-07-27 19:19:51 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2020-07-27 19:19:51 +0000
commit98bb39bf51d5f80ac60a8bf1bb913f270045aaa3 (patch)
tree9c208adc68aa8528043f4ab32df6e3030e8e637a /sys/scsi
parent556cb5012e7fac3be7de5359b8eaaeb2517f4dd2 (diff)
Refactor scsi_show_flags() to allow 32-bit flags. Display unnamed flags as one
hex value after named flags. Make flag name arrays NULL terminated rathar than fixed size.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/scsi_base.c53
-rw-r--r--sys/scsi/scsi_debug.h8
2 files changed, 34 insertions, 27 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index aa9f3dc57ad..20c04e165a0 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.267 2020/07/27 13:08:25 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.268 2020/07/27 19:19:49 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -2643,7 +2643,7 @@ u_int32_t scsidebug_targets = SCSIDEBUG_TARGETS;
u_int32_t scsidebug_luns = SCSIDEBUG_LUNS;
int scsidebug_level = SCSIDEBUG_LEVEL;
-const char *flagnames[16] = {
+const char *flagnames[] = {
"REMOVABLE",
"MEDIA LOADED",
"READONLY",
@@ -2654,31 +2654,30 @@ const char *flagnames[16] = {
"DB4",
"EJECTING",
"ATAPI",
- "FLAG0x0400",
+ "",
"UMASS",
"VIRTUAL",
- "OWN",
- "FLAG0x4000",
- "FLAG0x8000"
+ "OWN_IOPL",
+ NULL
};
-const char *quirknames[16] = {
+const char *quirknames[] = {
"AUTOSAVE",
"NOSYNC",
"NOWIDE",
"NOTAGS",
- "QUIRK0x0010",
- "QUIRK0x0020",
- "QUIRK0x0040",
- "QUIRK0x0080",
+ "",
+ "",
+ "",
+ "",
"NOSYNCCACHE",
"NOSENSE",
"LITTLETOC",
"NOCAPACITY",
- "QUIRK0x1000",
+ "",
"NODOORLOCK",
"ONLYBIG",
- "QUIRK0x8000",
+ NULL
};
const char *devicetypenames[32] = {
@@ -2797,21 +2796,29 @@ scsi_show_mem(u_char *address, int num)
}
void
-scsi_show_flags(u_int16_t flags, const char **names)
+scsi_show_flags(u_int32_t flags, const char **names)
{
- int i, first;
+ int i, first, exhausted;
+ u_int32_t unnamed;
- first = 1;
printf("<");
- for (i = 0; i < 16; i++) {
- if (ISSET(flags, 1 << i)) {
- if (first == 0)
- printf(", ");
- else
- first = 0;
- printf("%s", names[i]);
+ for (first = 1, exhausted = 0, unnamed = 0, i = 0; i < 32; i++) {
+ if (!ISSET(flags, 1 << i))
+ continue;
+ if (exhausted == 0 && names[i] == NULL)
+ exhausted = 1;
+ if (exhausted || strlen(names[i]) == 0) {
+ SET(unnamed, 1 << i);
+ continue;
}
+ if (first == 0)
+ printf(", ");
+ else
+ first = 0;
+ printf("%s", names[i]);
}
+ if (unnamed != 0)
+ printf("%s0x%08x", first ? "" : ", ", unnamed);
printf(">");
}
#endif /* SCSIDEBUG */
diff --git a/sys/scsi/scsi_debug.h b/sys/scsi/scsi_debug.h
index 5ae59526faf..b150306ce04 100644
--- a/sys/scsi/scsi_debug.h
+++ b/sys/scsi/scsi_debug.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_debug.h,v 1.21 2019/09/30 11:27:37 krw Exp $ */
+/* $OpenBSD: scsi_debug.h,v 1.22 2020/07/27 19:19:50 krw Exp $ */
/* $NetBSD: scsi_debug.h,v 1.7 1996/10/12 23:23:16 christos Exp $ */
/*
@@ -36,8 +36,8 @@
extern u_int32_t scsidebug_buses, scsidebug_targets, scsidebug_luns;
extern int scsidebug_level;
-extern const char *flagnames[16];
-extern const char *quirknames[16];
+extern const char *flagnames[];
+extern const char *quirknames[];
extern const char *devicetypenames[32];
struct scsi_xfer;
@@ -45,7 +45,7 @@ struct scsi_xfer;
void scsi_show_sense(struct scsi_xfer *);
void scsi_show_xs(struct scsi_xfer *);
void scsi_show_mem(u_char *, int);
-void scsi_show_flags(u_int16_t, const char **);
+void scsi_show_flags(u_int32_t, const char **);
/*
* This is the usual debug macro for use with the above bits