2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #define CAM_ATA_ALL_H 1
39 u_int8_t flags; /* ATA command flags */
40 #define CAM_ATAIO_48BIT 0x01 /* Command has 48-bit format */
41 #define CAM_ATAIO_FPDMA 0x02 /* FPDMA command */
42 #define CAM_ATAIO_CONTROL 0x04 /* Control, not a command */
43 #define CAM_ATAIO_NEEDRESULT 0x08 /* Request requires result. */
55 u_int8_t lba_high_exp;
56 u_int8_t features_exp;
58 u_int8_t sector_count;
59 u_int8_t sector_count_exp;
64 u_int8_t flags; /* ATA command flags */
65 #define CAM_ATAIO_48BIT 0x01 /* Command has 48-bit format */
77 u_int8_t lba_high_exp;
79 u_int8_t sector_count;
80 u_int8_t sector_count_exp;
83 int ata_version(int ver);
84 void ata_print_ident(struct ata_params *ident_data);
86 void ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features,
87 uint32_t lba, uint8_t sector_count);
88 void ata_48bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint16_t features,
89 uint64_t lba, uint16_t sector_count);
90 void ata_ncq_cmd(struct ccb_ataio *ataio, uint8_t cmd,
91 uint64_t lba, uint16_t sector_count);
92 void ata_reset_cmd(struct ccb_ataio *ataio);
93 void ata_pm_read_cmd(struct ccb_ataio *ataio, int reg, int port);
94 void ata_pm_write_cmd(struct ccb_ataio *ataio, int reg, int port, uint64_t val);
96 void ata_bswap(int8_t *buf, int len);
97 void ata_btrim(int8_t *buf, int len);
98 void ata_bpack(int8_t *src, int8_t *dst, int len);
100 int ata_max_pmode(struct ata_params *ap);
101 int ata_max_wmode(struct ata_params *ap);
102 int ata_max_umode(struct ata_params *ap);
103 int ata_max_mode(struct ata_params *ap, int mode, int maxmode);