11de7b4b8SPedro F. Giffuni /*- 2b61a5730SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 31de7b4b8SPedro F. Giffuni * 4525689f1SJustin T. Gibbs * Copyright (c) 1998 Kenneth D. Merry. 5525689f1SJustin T. Gibbs * All rights reserved. 6525689f1SJustin T. Gibbs * 7525689f1SJustin T. Gibbs * Redistribution and use in source and binary forms, with or without 8525689f1SJustin T. Gibbs * modification, are permitted provided that the following conditions 9525689f1SJustin T. Gibbs * are met: 10525689f1SJustin T. Gibbs * 1. Redistributions of source code must retain the above copyright 11525689f1SJustin T. Gibbs * notice, this list of conditions and the following disclaimer. 12525689f1SJustin T. Gibbs * 2. Redistributions in binary form must reproduce the above copyright 13525689f1SJustin T. Gibbs * notice, this list of conditions and the following disclaimer in the 14525689f1SJustin T. Gibbs * documentation and/or other materials provided with the distribution. 15525689f1SJustin T. Gibbs * 3. The name of the author may not be used to endorse or promote products 16525689f1SJustin T. Gibbs * derived from this software without specific prior written permission. 17525689f1SJustin T. Gibbs * 18525689f1SJustin T. Gibbs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19525689f1SJustin T. Gibbs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20525689f1SJustin T. Gibbs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21525689f1SJustin T. Gibbs * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22525689f1SJustin T. Gibbs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23525689f1SJustin T. Gibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24525689f1SJustin T. Gibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25525689f1SJustin T. Gibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26525689f1SJustin T. Gibbs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27525689f1SJustin T. Gibbs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28525689f1SJustin T. Gibbs * SUCH DAMAGE. 29525689f1SJustin T. Gibbs */ 30525689f1SJustin T. Gibbs 31525689f1SJustin T. Gibbs #ifndef _CAMCONTROL_H 32525689f1SJustin T. Gibbs #define _CAMCONTROL_H 3308df2e3eSKenneth D. Merry 3408df2e3eSKenneth D. Merry typedef enum { 3508df2e3eSKenneth D. Merry CC_OR_NOT_FOUND, 3608df2e3eSKenneth D. Merry CC_OR_AMBIGUOUS, 3708df2e3eSKenneth D. Merry CC_OR_FOUND 3808df2e3eSKenneth D. Merry } camcontrol_optret; 3908df2e3eSKenneth D. Merry 400e358df0SKenneth D. Merry typedef enum { 410e358df0SKenneth D. Merry CC_DT_NONE, 420e358df0SKenneth D. Merry CC_DT_SCSI, 4340152db5SWarner Losh CC_DT_SATL, 440e358df0SKenneth D. Merry CC_DT_ATA, 45a5a8266aSWarner Losh CC_DT_NVME, 46a5a8266aSWarner Losh CC_DT_MMCSD, 470e358df0SKenneth D. Merry CC_DT_UNKNOWN 480e358df0SKenneth D. Merry } camcontrol_devtype; 490e358df0SKenneth D. Merry 50525689f1SJustin T. Gibbs /* 51525689f1SJustin T. Gibbs * get_hook: Structure for evaluating args in a callback. 52525689f1SJustin T. Gibbs */ 53525689f1SJustin T. Gibbs struct get_hook 54525689f1SJustin T. Gibbs { 55525689f1SJustin T. Gibbs int argc; 56525689f1SJustin T. Gibbs char **argv; 57525689f1SJustin T. Gibbs int got; 58525689f1SJustin T. Gibbs }; 59525689f1SJustin T. Gibbs 60bf70beceSEd Schouten extern int verbose; 61bf70beceSEd Schouten 620e358df0SKenneth D. Merry int ata_do_identify(struct cam_device *device, int retry_count, int timeout, 630e358df0SKenneth D. Merry union ccb *ccb, struct ata_params **ident_bufp); 640e358df0SKenneth D. Merry int dev_has_vpd_page(struct cam_device *dev, uint8_t page_id, int retry_count, 650e358df0SKenneth D. Merry int timeout, int verbosemode); 660e358df0SKenneth D. Merry int get_device_type(struct cam_device *dev, int retry_count, int timeout, 670e358df0SKenneth D. Merry int verbosemode, camcontrol_devtype *devtype); 689a6844d5SKenneth D. Merry int build_ata_cmd(union ccb *ccb, uint32_t retry_count, uint32_t flags, 690e358df0SKenneth D. Merry uint8_t tag_action, uint8_t protocol, uint8_t ata_flags, 700e358df0SKenneth D. Merry uint16_t features, uint16_t sector_count, uint64_t lba, 719a6844d5SKenneth D. Merry uint8_t command, uint32_t auxiliary, uint8_t *data_ptr, 729a6844d5SKenneth D. Merry uint32_t dxfer_len, uint8_t *cdb_storage, 739a6844d5SKenneth D. Merry size_t cdb_storage_len, uint8_t sense_len, uint32_t timeout, 749a6844d5SKenneth D. Merry int is48bit, camcontrol_devtype devtype); 759a6844d5SKenneth D. Merry int get_ata_status(struct cam_device *dev, union ccb *ccb, uint8_t *error, 769a6844d5SKenneth D. Merry uint16_t *count, uint64_t *lba, uint8_t *device, 779a6844d5SKenneth D. Merry uint8_t *status); 780e358df0SKenneth D. Merry int camxferrate(struct cam_device *device); 791f4782a4SEd Maste int fwdownload(struct cam_device *device, int argc, char **argv, 80492a2ef5SKenneth D. Merry char *combinedopt, int printerrors, int task_attr, 81492a2ef5SKenneth D. Merry int retry_count, int timeout); 829a6844d5SKenneth D. Merry int zone(struct cam_device *device, int argc, char **argv, char *combinedopt, 83492a2ef5SKenneth D. Merry int task_attr, int retry_count, int timeout, int verbosemode); 849a6844d5SKenneth D. Merry int epc(struct cam_device *device, int argc, char **argv, char *combinedopt, 859a6844d5SKenneth D. Merry int retry_count, int timeout, int verbosemode); 8628db0a5eSKenneth D. Merry int timestamp(struct cam_device *device, int argc, char **argv, 87492a2ef5SKenneth D. Merry char *combinedopt, int task_attr, int retry_count, int timeout, 8828db0a5eSKenneth D. Merry int verbosemode); 8953cce2e7SWarner Losh int depop(struct cam_device *device, int argc, char **argv, 9053cce2e7SWarner Losh char *combinedopt, int task_attr, int retry_count, int timeout, 9153cce2e7SWarner Losh int verbosemode); 9209128776SAlexander Motin void mode_sense(struct cam_device *device, int *cdb_len, int dbd, int llbaa, 9309128776SAlexander Motin int pc, int page, int subpage, int task_attr, int retry_count, 94e341cfd2SAlexander Motin int timeout, uint8_t *data, int datalen); 95e341cfd2SAlexander Motin void mode_select(struct cam_device *device, int cdb_len, int save_pages, 96*efff068cSWarner Losh int task_attr, int retry_count, int timeout, uint8_t *data, 97e341cfd2SAlexander Motin int datalen); 9809128776SAlexander Motin void mode_edit(struct cam_device *device, int cdb_len, int desc, int dbd, 9909128776SAlexander Motin int llbaa, int pc, int page, int subpage, int edit, int binary, 10009128776SAlexander Motin int task_attr, int retry_count, int timeout); 101e341cfd2SAlexander Motin void mode_list(struct cam_device *device, int cdb_len, int dbd, int pc, 102e341cfd2SAlexander Motin int subpages, int task_attr, int retry_count, int timeout); 1031f4782a4SEd Maste int scsidoinquiry(struct cam_device *device, int argc, char **argv, 104492a2ef5SKenneth D. Merry char *combinedopt, int task_attr, int retry_count, 105492a2ef5SKenneth D. Merry int timeout); 1060e358df0SKenneth D. Merry int scsigetopcodes(struct cam_device *device, int opcode_set, int opcode, 1070e358df0SKenneth D. Merry int show_sa_errors, int sa_set, int service_action, 108492a2ef5SKenneth D. Merry int timeout_desc, int task_attr, int retry_count, 109492a2ef5SKenneth D. Merry int timeout, int verbosemode, uint32_t *fill_len, 110492a2ef5SKenneth D. Merry uint8_t **data_ptr); 11108df2e3eSKenneth D. Merry int scsipersist(struct cam_device *device, int argc, char **argv, 112492a2ef5SKenneth D. Merry char *combinedopt, int task_attr, int retry_count, 113492a2ef5SKenneth D. Merry int timeout, int verbose, int err_recover); 1145672fac9SKenneth D. Merry int scsiattrib(struct cam_device *device, int argc, char **argv, 115492a2ef5SKenneth D. Merry char *combinedopt, int task_attr, int retry_count, int timeout, 116492a2ef5SKenneth D. Merry int verbose, int err_recover); 117525689f1SJustin T. Gibbs char *cget(void *hook, char *name); 118525689f1SJustin T. Gibbs int iget(void *hook, char *name); 119525689f1SJustin T. Gibbs void arg_put(void *hook, int letter, void *arg, int count, char *name); 1201f4782a4SEd Maste int get_confirmation(void); 121bf70beceSEd Schouten void usage(int printlong); 122525689f1SJustin T. Gibbs #endif /* _CAMCONTROL_H */ 123