xref: /freebsd/sbin/camcontrol/camcontrol.h (revision 47dd1d1b619cc035b82b49a91a25544309ff95ae)
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_ATA_BEHIND_SCSI,
46 	CC_DT_ATA,
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 void mode_sense(struct cam_device *device, int dbd, int pc, int page,
90 		int subpage, int task_attr, int retry_count, int timeout,
91 		uint8_t *data, int datalen);
92 void mode_select(struct cam_device *device, int save_pages, int task_attr,
93 		 int retry_count, int timeout, u_int8_t *data, int datalen);
94 void mode_edit(struct cam_device *device, int dbd, int pc, int page,
95 	       int subpage, int edit, int binary, int task_attr,
96 	       int retry_count, int timeout);
97 void mode_list(struct cam_device *device, int dbd, int pc, int subpages,
98 	       int task_attr, int retry_count, int timeout);
99 int scsidoinquiry(struct cam_device *device, int argc, char **argv,
100 		  char *combinedopt, int task_attr, int retry_count,
101 		  int timeout);
102 int scsigetopcodes(struct cam_device *device, int opcode_set, int opcode,
103 		   int show_sa_errors, int sa_set, int service_action,
104 		   int timeout_desc, int task_attr, int retry_count,
105 		   int timeout, int verbosemode, uint32_t *fill_len,
106 		   uint8_t **data_ptr);
107 int scsipersist(struct cam_device *device, int argc, char **argv,
108 		char *combinedopt, int task_attr, int retry_count,
109 		int timeout, int verbose, int err_recover);
110 int scsiattrib(struct cam_device *device, int argc, char **argv,
111 	       char *combinedopt, int task_attr, int retry_count, int timeout,
112 	       int verbose, int err_recover);
113 char *cget(void *hook, char *name);
114 int iget(void *hook, char *name);
115 void arg_put(void *hook, int letter, void *arg, int count, char *name);
116 int get_confirmation(void);
117 void usage(int printlong);
118 #endif /* _CAMCONTROL_H */
119