xref: /freebsd/sbin/camcontrol/camcontrol.h (revision f4c129f5fb1669b284d76a838b1e509f97c2d299)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
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  * $FreeBSD$
31  */
32 
33 #ifndef _CAMCONTROL_H
34 #define _CAMCONTROL_H
35 
36 typedef enum {
37 	CC_OR_NOT_FOUND,
38 	CC_OR_AMBIGUOUS,
39 	CC_OR_FOUND
40 } camcontrol_optret;
41 
42 typedef enum {
43 	CC_DT_NONE,
44 	CC_DT_SCSI,
45 	CC_DT_SATL,
46 	CC_DT_ATA,
47 	CC_DT_NVME,
48 	CC_DT_MMCSD,
49 	CC_DT_UNKNOWN
50 } camcontrol_devtype;
51 
52 /*
53  * get_hook: Structure for evaluating args in a callback.
54  */
55 struct get_hook
56 {
57 	int argc;
58 	char **argv;
59 	int got;
60 };
61 
62 extern int verbose;
63 
64 int ata_do_identify(struct cam_device *device, int retry_count, int timeout,
65 		    union ccb *ccb, struct ata_params **ident_bufp);
66 int dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count,
67 		     int timeout, int verbosemode);
68 int get_device_type(struct cam_device *dev, int retry_count, int timeout,
69 		    int verbosemode, camcontrol_devtype *devtype);
70 int build_ata_cmd(union ccb *ccb, uint32_t retry_count, uint32_t flags,
71 		  uint8_t tag_action, uint8_t protocol, uint8_t ata_flags,
72 		  uint16_t features, uint16_t sector_count, uint64_t lba,
73 		  uint8_t command, uint32_t auxiliary, uint8_t *data_ptr,
74 		  uint32_t dxfer_len, uint8_t *cdb_storage,
75 		  size_t cdb_storage_len, uint8_t sense_len, uint32_t timeout,
76 		  int is48bit, camcontrol_devtype devtype);
77 int get_ata_status(struct cam_device *dev, union ccb *ccb, uint8_t *error,
78 		   uint16_t *count, uint64_t *lba, uint8_t *device,
79 		   uint8_t *status);
80 int camxferrate(struct cam_device *device);
81 int fwdownload(struct cam_device *device, int argc, char **argv,
82 	       char *combinedopt, int printerrors, int task_attr,
83 	       int retry_count, int timeout);
84 int zone(struct cam_device *device, int argc, char **argv, char *combinedopt,
85 	 int task_attr, int retry_count, int timeout, int verbosemode);
86 int epc(struct cam_device *device, int argc, char **argv, char *combinedopt,
87 	int retry_count, int timeout, int verbosemode);
88 int timestamp(struct cam_device *device, int argc, char **argv,
89 	      char *combinedopt, int task_attr, int retry_count, int timeout,
90 	      int verbosemode);
91 int depop(struct cam_device *device, int argc, char **argv,
92 	  char *combinedopt, int task_attr, int retry_count, int timeout,
93 	  int verbosemode);
94 void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa,
95 		int pc, int page, int subpage, int task_attr, int retry_count,
96 		int timeout, uint8_t *data, int datalen);
97 void mode_select(struct cam_device *device, int cdb_len, int save_pages,
98 		 int task_attr, int retry_count, int timeout, u_int8_t *data,
99 		 int datalen);
100 void mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd,
101 	       int llbaa, int pc, int page, int subpage, int edit, int binary,
102 	       int task_attr, int retry_count, int timeout);
103 void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc,
104 	       int subpages, int task_attr, int retry_count, int timeout);
105 int scsidoinquiry(struct cam_device *device, int argc, char **argv,
106 		  char *combinedopt, int task_attr, int retry_count,
107 		  int timeout);
108 int scsigetopcodes(struct cam_device *device, int opcode_set, int opcode,
109 		   int show_sa_errors, int sa_set, int service_action,
110 		   int timeout_desc, int task_attr, int retry_count,
111 		   int timeout, int verbosemode, uint32_t *fill_len,
112 		   uint8_t **data_ptr);
113 int scsipersist(struct cam_device *device, int argc, char **argv,
114 		char *combinedopt, int task_attr, int retry_count,
115 		int timeout, int verbose, int err_recover);
116 int scsiattrib(struct cam_device *device, int argc, char **argv,
117 	       char *combinedopt, int task_attr, int retry_count, int timeout,
118 	       int verbose, int err_recover);
119 char *cget(void *hook, char *name);
120 int iget(void *hook, char *name);
121 void arg_put(void *hook, int letter, void *arg, int count, char *name);
122 int get_confirmation(void);
123 void usage(int printlong);
124 #endif /* _CAMCONTROL_H */
125