xref: /freebsd/sbin/camcontrol/camcontrol.h (revision 90aac0d83bc9645f51ef0c2aeae6f9c0540bb031)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 1998 Kenneth D. Merry.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #ifndef _CAMCONTROL_H
32 #define _CAMCONTROL_H
33 
34 typedef enum {
35 	CC_OR_NOT_FOUND,
36 	CC_OR_AMBIGUOUS,
37 	CC_OR_FOUND
38 } camcontrol_optret;
39 
40 typedef enum {
41 	CC_DT_NONE,
42 	CC_DT_SCSI,
43 	CC_DT_SATL,
44 	CC_DT_ATA,
45 	CC_DT_NVME,
46 	CC_DT_MMCSD,
47 	CC_DT_UNKNOWN
48 } camcontrol_devtype;
49 
50 /*
51  * get_hook: Structure for evaluating args in a callback.
52  */
53 struct get_hook
54 {
55 	int argc;
56 	char **argv;
57 	int got;
58 };
59 
60 extern int verbose;
61 
62 int ata_do_identify(struct cam_device *device, int retry_count, int timeout,
63 		    union ccb *ccb, struct ata_params **ident_bufp);
64 int dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count,
65 		     int timeout, int verbosemode);
66 int get_device_type(struct cam_device *dev, int retry_count, int timeout,
67 		    int verbosemode, camcontrol_devtype *devtype);
68 int build_ata_cmd(union ccb *ccb, uint32_t retry_count, uint32_t flags,
69 		  uint8_t tag_action, uint8_t protocol, uint8_t ata_flags,
70 		  uint16_t features, uint16_t sector_count, uint64_t lba,
71 		  uint8_t command, uint32_t auxiliary, uint8_t *data_ptr,
72 		  uint32_t dxfer_len, uint8_t *cdb_storage,
73 		  size_t cdb_storage_len, uint8_t sense_len, uint32_t timeout,
74 		  int is48bit, camcontrol_devtype devtype);
75 int get_ata_status(struct cam_device *dev, union ccb *ccb, uint8_t *error,
76 		   uint16_t *count, uint64_t *lba, uint8_t *device,
77 		   uint8_t *status);
78 int camxferrate(struct cam_device *device);
79 int fwdownload(struct cam_device *device, int argc, char **argv,
80 	       char *combinedopt, int printerrors, int task_attr,
81 	       int retry_count, int timeout);
82 int zone(struct cam_device *device, int argc, char **argv, char *combinedopt,
83 	 int task_attr, int retry_count, int timeout, int verbosemode);
84 int epc(struct cam_device *device, int argc, char **argv, char *combinedopt,
85 	int retry_count, int timeout, int verbosemode);
86 int timestamp(struct cam_device *device, int argc, char **argv,
87 	      char *combinedopt, int task_attr, int retry_count, int timeout,
88 	      int verbosemode);
89 int depop(struct cam_device *device, int argc, char **argv,
90 	  char *combinedopt, int task_attr, int retry_count, int timeout,
91 	  int verbosemode);
92 void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa,
93 		int pc, int page, int subpage, int task_attr, int retry_count,
94 		int timeout, uint8_t *data, int datalen);
95 void mode_select(struct cam_device *device, int cdb_len, int save_pages,
96 		 int task_attr, int retry_count, int timeout, uint8_t *data,
97 		 int datalen);
98 void mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd,
99 	       int llbaa, int pc, int page, int subpage, int edit, int binary,
100 	       int task_attr, int retry_count, int timeout);
101 void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc,
102 	       int subpages, int task_attr, int retry_count, int timeout);
103 int scsidoinquiry(struct cam_device *device, int argc, char **argv,
104 		  char *combinedopt, int task_attr, int retry_count,
105 		  int timeout);
106 int scsigetopcodes(struct cam_device *device, int opcode_set, int opcode,
107 		   int show_sa_errors, int sa_set, int service_action,
108 		   int timeout_desc, int task_attr, int retry_count,
109 		   int timeout, int verbosemode, uint32_t *fill_len,
110 		   uint8_t **data_ptr);
111 int scsipersist(struct cam_device *device, int argc, char **argv,
112 		char *combinedopt, int task_attr, int retry_count,
113 		int timeout, int verbose, int err_recover);
114 int scsiattrib(struct cam_device *device, int argc, char **argv,
115 	       char *combinedopt, int task_attr, int retry_count, int timeout,
116 	       int verbose, int err_recover);
117 char *cget(void *hook, char *name);
118 int iget(void *hook, char *name);
119 void arg_put(void *hook, int letter, void *arg, int count, char *name);
120 int get_confirmation(void);
121 void usage(int printlong);
122 #endif /* _CAMCONTROL_H */
123