xref: /aosp_15_r20/external/sg3_utils/lib/sg_lib_names.c (revision 44704f698541f6367e81f991ef8bb54ccbf3fc18)
1 /*
2  * Copyright (c) 2022 Douglas Gilbert.
3  * All rights reserved.
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the BSD_LICENSE file.
6  *
7  * SPDX-License-Identifier: BSD-2-Clause
8  */
9 
10 #include <stdlib.h>
11 
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #else
15 #define SG_SCSI_STRINGS 1
16 #endif
17 
18 #include "sg_lib.h"
19 #include "sg_lib_data.h"
20 #include "sg_lib_names.h"
21 
22 /* List of SPC, then SBC, the ZBC mode page names. Tape and other mode pages
23  * are squeezed into this list as long as they don't conflict.
24  * The value is: (mode_page << 8) | mode_subpage
25  * Maintain the list in numerical order to allow binary search. */
26 struct sg_lib_simple_value_name_t sg_lib_names_mode_arr[] = {
27     {0x0000, "Unit Attention condition"},  /* common vendor specific page */
28     {0x0100, "Read-Write error recovery"},      /* SBC */
29     {0x0200, "Disconnect-Reconnect"},           /* SPC */
30     {0x0300, "Format (obsolete)"},              /* SBC */
31     {0x0400, "Rigid disk geometry (obsolete)"}, /* SBC */
32     {0x0500, "Flexible disk (obsolete)"},       /* SBC */
33     {0x0700, "Verify error recovery"},          /* SBC */
34     {0x0800, "Caching"},                        /* SBC */
35     {0x0900, "Peripheral device (obsolete)"},   /* SPC */
36     {0x0a00, "Control"},                        /* SPC */
37     {0x0a01, "Control extension"},              /* SPC */
38     {0x0a02, "Application tag"},                /* SBC */
39     {0x0a03, "Command duration limit A"},       /* SPC */
40     {0x0a04, "Command duration limit B"},       /* SPC */
41     {0x0a05, "IO Advice Hints Grouping"},       /* SBC */
42     {0x0a06, "Background operation control"},   /* SBC */
43     {0x0af0, "Control data protection"},        /* SSC */
44     {0x0af1, "PATA control"},                   /* SAT */
45     {0x0b00, "Medium Types Supported (obsolete)"},   /* SSC */
46     {0x0c00, "Notch and partition (obsolete)"}, /* SBC */
47     {0x0d00, "Power condition (obsolete), CD device parameters"},
48     {0x0e00, "CD audio control"},               /* MMC */
49     {0x0e01, "Target device"},                  /* ADC */
50     {0x0e02, "DT device primary port"},         /* ADC */
51     {0x0e03, "Logical unit"},                   /* ADC */
52     {0x0e04, "Target device serial number"},    /* ADC */
53     {0x0f00, "Data compression"},               /* SSC */
54     {0x1000, "XOR control (obsolete, Device configuration"}, /* SBC,SSC */
55     {0x1001, "Device configuration extension"}, /* SSC */
56     {0x1100, "Medium partition (1)"},           /* SSC */
57     {0x1400, "Enclosure services management"},  /* SES */
58     {0x1800, "Protocol specific logical unit"}, /* transport */
59     {0x1900, "Protocol specific port"},         /* transport */
60     {0x1901, "Phy control and discovery"},      /* SPL */
61     {0x1902, "Shared port control"},            /* SPL */
62     {0x1903, "Enhanced phy control"},           /* SPL */
63     {0x1904, "Out of band  management control"}, /* SPL */
64     {0x1A00, "Power condition"},                /* SPC */
65     {0x1A01, "Power consumption"},              /* SPC */
66     {0x1Af1, "ATA Power condition"},            /* SPC */
67     {0x1b00, "LUN mapping"},                    /* ADC */
68     {0x1c00, "Information exceptions control"}, /* SPC */
69     {0x1c01, "Background control"},             /* SBC */
70     {0x1c02, "Logical block provisioning"},     /* SBC */
71     {0x1c02, "Logical block provisioning"},     /* SBC */
72     {0x1d00, "Medium configuration, CD/DVD timeout, "
73              "element address assignments"},    /* SSC,MMC,SMC */
74     {0x1e00, "Transport geometry assignments"}, /* SMC */
75     {0x1f00, "Device capabilities"},            /* SMC */
76 
77     {-1, NULL},                                 /* sentinel */
78 };
79 
80 /* Don't count sentinel when doing binary searches, etc */
81 const size_t sg_lib_names_mode_len =
82                 SG_ARRAY_SIZE(sg_lib_names_mode_arr) - 1;
83 
84 /* List of SPC, then SBC, the ZBC VPD page names. Tape and other VPD pages
85  * are squeezed into this list as long as they don't conflict.
86  * For VPDs > 0 the value is: (vpd << 8) | vpd_number
87  * Maintain the list in numerical order to allow binary search. */
88 struct sg_lib_simple_value_name_t sg_lib_names_vpd_arr[] = {
89     {0x00, "Supported VPD pages"},              /* SPC */
90     {0x80, "Unit serial number"},               /* SPC */
91     {0x81, "Implemented operating definition (obsolete)"}, /* SPC */
92     {0x82, "ASCII implemented operating definition (obsolete)"}, /* SPC */
93     {0x83, "Device identification"},            /* SPC */
94     {0x84, "Software interface identification"}, /* SPC */
95     {0x85, "Management network addresses"},     /* SPC */
96     {0x86, "Extended INQUIRY data"},            /* SPC */
97     {0x87, "Mode page policy"},                 /* SPC */
98     {0x88, "SCSI ports"},                       /* SPC */
99     {0x89, "ATA information"},                  /* SAT */
100     {0x8a, "Power condition"},                  /* SPC */
101     {0x8b, "Device constituents"},              /* SSC */
102     {0x8c, "CFA profile information"},          /* SPC */
103     {0x8d, "Power consumption"},                /* SPC */
104     {0x8f, "Third party copy"},                 /* SPC */
105     {0x90, "Protocol specific logical unit information"}, /* transport */
106     {0x91, "Protocol specific port information"}, /* transport */
107     {0x92, "SCSI feature sets"},                /* SPC,SBC */
108     {0xb0, "Block limits"},                     /* SBC */
109     {0xb1, "Block device characteristics"},     /* SBC */
110     {0xb2, "Logical block provisioning"},       /* SBC */
111     {0xb3, "Referrals"},                        /* SBC */
112     {0xb4, "Supported Block Lengths and Protection Types"}, /* SBC */
113     {0xb5, "Block device characteristics extension"}, /* SBC */
114     {0xb6, "Zoned block device characteristics"}, /* ZBC */
115     {0xb7, "Block limits extension"},           /* SBC */
116     {0xb8, "Format presets"},                   /* SBC */
117     {0xb9, "Concurrent positioning ranges"},    /* SBC */
118     {0x01b0, "Sequential access Device Capabilities"}, /* SSC */
119     {0x01b1, "Manufacturer-assigned serial number"}, /* SSC */
120     {0x01b2, "TapeAlert supported flags"},      /* SSC */
121     {0x01b3, "Automation device serial number"}, /* SSC */
122     {0x01b4, "Data transfer device element address"}, /* SSC */
123     {0x01b5, "Data transfer device element address"}, /* SSC */
124     {0x11b0, "OSD information"},                /* OSD */
125     {0x11b1, "Security token"},                 /* OSD */
126 
127     {-1, NULL},                                 /* sentinel */
128 };
129 
130 /* Don't count sentinel when doing binary searches, etc */
131 const size_t sg_lib_names_vpd_len =
132                 SG_ARRAY_SIZE(sg_lib_names_vpd_arr) - 1;
133