| 1 | /* $NetBSD: linux_fdio.h,v 1.4 2007/03/04 06:01:23 christos Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2000 Wasabi Systems, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Written by Frank van der Linden for Wasabi Systems, Inc. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * 3. All advertising materials mentioning features or use of this software |
| 18 | * must display the following acknowledgement: |
| 19 | * This product includes software developed for the NetBSD Project by |
| 20 | * Wasabi Systems, Inc. |
| 21 | * 4. The name of Wasabi Systems, Inc. may not be used to endorse |
| 22 | * or promote products derived from this software without specific prior |
| 23 | * written permission. |
| 24 | * |
| 25 | * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND |
| 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
| 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 35 | * POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ |
| 37 | |
| 38 | #ifndef _LINUX_FDIO_H |
| 39 | #define _LINUX_FDIO_H |
| 40 | |
| 41 | /* |
| 42 | * Linux floppy ioctl call structures and defines. |
| 43 | */ |
| 44 | |
| 45 | struct linux_floppy_struct { |
| 46 | u_int size; |
| 47 | u_int sect; |
| 48 | u_int head; |
| 49 | u_int track; |
| 50 | u_int stretch; |
| 51 | u_char gap; |
| 52 | u_char rate; |
| 53 | u_char spec1; |
| 54 | u_char fmt_gap; |
| 55 | const char *name; |
| 56 | }; |
| 57 | |
| 58 | struct linux_floppy_max_errors { |
| 59 | u_int abort; |
| 60 | u_int read_track; |
| 61 | u_int reset; |
| 62 | u_int recal; |
| 63 | u_int reporting; |
| 64 | }; |
| 65 | |
| 66 | struct linux_floppy_drive_params { |
| 67 | char cmos; |
| 68 | u_long max_dtr; |
| 69 | u_long hlt; |
| 70 | u_long hut; |
| 71 | u_long srt; |
| 72 | u_long spinup; |
| 73 | u_long spindown; |
| 74 | u_char spindown_offset; |
| 75 | u_char select_delay; |
| 76 | u_char rps; |
| 77 | u_char tracks; |
| 78 | u_long timeout; |
| 79 | u_char interleave_sect; |
| 80 | struct linux_floppy_max_errors max_errors; |
| 81 | char flags; |
| 82 | char read_track; |
| 83 | short autodetect[8]; |
| 84 | int checkfreq; |
| 85 | int native_format; |
| 86 | }; |
| 87 | |
| 88 | struct linux_floppy_drive_struct { |
| 89 | u_long flags; |
| 90 | u_long spinup_date; |
| 91 | u_long select_date; |
| 92 | u_long first_read_date; |
| 93 | short probed_format; |
| 94 | short track; |
| 95 | short maxblock; |
| 96 | short maxtrack; |
| 97 | int generation; |
| 98 | int keep_data; |
| 99 | int fd_ref; |
| 100 | int fd_device; |
| 101 | u_long last_checked; |
| 102 | char *dmabuf; |
| 103 | int bufblocks; |
| 104 | }; |
| 105 | |
| 106 | #define LINUX_FD_NEED_TWADDLE 0x01 |
| 107 | #define LINUX_FD_VERIFY 0x02 |
| 108 | #define LINUX_FD_DISK_NEWCHANGE 0x04 |
| 109 | #define LINUX_FD_DISK_CHANGED 0x10 |
| 110 | #define LINUX_FD_DISK_WRITABLE 0x20 |
| 111 | |
| 112 | |
| 113 | struct linux_floppy_fdc_state { |
| 114 | int spec1; |
| 115 | int spec2; |
| 116 | int dtr; |
| 117 | u_char version; |
| 118 | u_char dor; |
| 119 | u_long address; |
| 120 | u_int rawcmd:2; |
| 121 | u_int reset:1; |
| 122 | u_int need_configure:1; |
| 123 | u_int perp_mode:2; |
| 124 | u_int has_fifo:1; |
| 125 | u_int driver_version; |
| 126 | u_char track[4]; |
| 127 | }; |
| 128 | |
| 129 | struct linux_floppy_write_errors { |
| 130 | u_int write_errors; |
| 131 | u_long first_error_sector; |
| 132 | u_int first_error_generation; |
| 133 | u_long last_error_sector; |
| 134 | u_int last_error_generation; |
| 135 | u_int badness; |
| 136 | }; |
| 137 | |
| 138 | struct linux_floppy_raw_cmd { |
| 139 | u_int flags; |
| 140 | void *data; |
| 141 | void *kernel_data; |
| 142 | struct floppy_raw_cmd *next; |
| 143 | long length; |
| 144 | long phys_length; |
| 145 | int buffer_length; |
| 146 | u_char rate; |
| 147 | u_char cmd_count; |
| 148 | u_char cmd[16]; |
| 149 | u_char reply_count; |
| 150 | u_char reply[16]; |
| 151 | int track; |
| 152 | int resultcode; |
| 153 | int reserved1; |
| 154 | int reserved2; |
| 155 | }; |
| 156 | |
| 157 | struct linux_format_descr { |
| 158 | u_int device; |
| 159 | u_int head; |
| 160 | u_int track; |
| 161 | }; |
| 162 | |
| 163 | typedef char linux_floppy_drive_name[16]; |
| 164 | |
| 165 | #define LINUX_FDCLRPRM _LINUX_IO(2, 0x41) |
| 166 | #define LINUX_FDSETPRM _LINUX_IOW(2, 0x42, struct linux_floppy_struct) |
| 167 | #define LINUX_FDDEFPRM _LINUX_IOW(2, 0x43, struct linux_floppy_struct) |
| 168 | #define LINUX_FDGETPRM _LINUX_IOR(2, 0x04, struct linux_floppy_struct) |
| 169 | #define LINUX_FDMSGON _LINUX_IO(2, 0x45) |
| 170 | #define LINUX_FDMSGOFF _LINUX_IO(2, 0x46) |
| 171 | #define LINUX_FDFMTBEG _LINUX_IO(2, 0x47) |
| 172 | #define LINUX_FDFMTTRK _LINUX_IOW(2, 0x48, struct linux_format_descr) |
| 173 | #define LINUX_FDFMTEND _LINUX_IO(2, 0x49) |
| 174 | #define LINUX_FDSETEMSGTRESH _LINUX_IO(2, 0x4a) |
| 175 | #define LINUX_FDFLUSH _LINUX_IO(2, 0x4b) |
| 176 | #define LINUX_FDSETMAXERRS \ |
| 177 | _LINUX_IOW(2, 0x4c, struct linux_floppy_max_errors) |
| 178 | #define LINUX_FDGETMAXERRS \ |
| 179 | _LINUX_IOR(2, 0x0e, struct linux_floppy_max_errors) |
| 180 | #define LINUX_FDGETDRVTYP _LINUX_IOR(2, 0x0f, linux_floppy_drive_name) |
| 181 | /* 0x90 is not a typo, that's how it's listed in the Linux include file */ |
| 182 | #define LINUX_FDSETDRVPRM \ |
| 183 | _LINUX_IOW(2, 0x90, struct linux_floppy_drive_params) |
| 184 | #define LINUX_FDGETDRVPRM \ |
| 185 | _LINUX_IOR(2, 0x11, struct linux_floppy_drive_params) |
| 186 | #define LINUX_FDGETDRVSTAT \ |
| 187 | _LINUX_IOR(2, 0x12, struct linux_floppy_drive_struct) |
| 188 | #define LINUX_FDPOLLDRVSTAT \ |
| 189 | _LINUX_IOR(2, 0x13, struct linux_floppy_drive_struct) |
| 190 | #define LINUX_FDRESET _LINUX_IO(2, 0x54) |
| 191 | #define LINUX_FDGETFDCSTAT \ |
| 192 | _LINUX_IOR(2, 0x15, struct linux_floppy_fdc_state) |
| 193 | #define LINUX_FDWERRORCLR _LINUX_IO(2, 0x56) |
| 194 | #define LINUX_FDWERRORGET \ |
| 195 | _LINUX_IOR(2, 0x17, struct linux_floppy_write_errors) |
| 196 | #define LINUX_FDRAWCMD _LINUX_IO(2, 0x58) |
| 197 | #define LINUX_FDTWADDLE _LINUX_IO(2, 0x59) |
| 198 | #define LINUX_FDEJECT _LINUX_IO(2, 0x5a) |
| 199 | |
| 200 | #endif /* _LINUX_FDIO_H */ |
| 201 | |