blob: 352620d34b976ad3bc11d32705e9810e3926c5cb [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef _UAPI_LINUX_FD_H
8#define _UAPI_LINUX_FD_H
9#include <linux/ioctl.h>
10#include <linux/compiler.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070011struct floppy_struct {
Tao Baod7db5942015-01-28 10:07:51 -080012 unsigned int size, sect, head, track, stretch;
Ben Cheng655a7c02013-10-16 16:09:24 -070013#define FD_STRETCH 1
14#define FD_SWAPSIDES 2
Ben Cheng655a7c02013-10-16 16:09:24 -070015#define FD_ZEROBASED 4
16#define FD_SECTBASEMASK 0x3FC
17#define FD_MKSECTBASE(s) (((s) ^ 1) << 2)
18#define FD_SECTBASE(floppy) ((((floppy)->stretch & FD_SECTBASEMASK) >> 2) ^ 1)
Tao Baod7db5942015-01-28 10:07:51 -080019 unsigned char gap, rate,
Ben Cheng655a7c02013-10-16 16:09:24 -070020#define FD_2M 0x4
21#define FD_SIZECODEMASK 0x38
Tao Baod7db5942015-01-28 10:07:51 -080022#define FD_SIZECODE(floppy) (((((floppy)->rate & FD_SIZECODEMASK) >> 3) + 2) % 8)
Tao Baod7db5942015-01-28 10:07:51 -080023#define FD_SECTSIZE(floppy) ((floppy)->rate & FD_2M ? 512 : 128 << FD_SIZECODE(floppy))
Ben Cheng655a7c02013-10-16 16:09:24 -070024#define FD_PERP 0x40
Tao Baod7db5942015-01-28 10:07:51 -080025 spec1, fmt_gap;
26 const char * name;
Ben Cheng655a7c02013-10-16 16:09:24 -070027};
28#define FDCLRPRM _IO(2, 0x41)
Ben Cheng655a7c02013-10-16 16:09:24 -070029#define FDSETPRM _IOW(2, 0x42, struct floppy_struct)
30#define FDSETMEDIAPRM FDSETPRM
31#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct)
32#define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
Ben Cheng655a7c02013-10-16 16:09:24 -070033#define FDDEFMEDIAPRM FDDEFPRM
34#define FDGETMEDIAPRM FDGETPRM
Tao Baod7db5942015-01-28 10:07:51 -080035#define FDMSGON _IO(2, 0x45)
36#define FDMSGOFF _IO(2, 0x46)
Ben Cheng655a7c02013-10-16 16:09:24 -070037#define FD_FILL_BYTE 0xF6
38struct format_descr {
Tao Baod7db5942015-01-28 10:07:51 -080039 unsigned int device, head, track;
40};
41#define FDFMTBEG _IO(2, 0x47)
42#define FDFMTTRK _IOW(2, 0x48, struct format_descr)
Tao Baod7db5942015-01-28 10:07:51 -080043#define FDFMTEND _IO(2, 0x49)
Ben Cheng655a7c02013-10-16 16:09:24 -070044struct floppy_max_errors {
Tao Baod7db5942015-01-28 10:07:51 -080045 unsigned int abort, read_track, reset, recal, reporting;
Ben Cheng655a7c02013-10-16 16:09:24 -070046};
Tao Baod7db5942015-01-28 10:07:51 -080047#define FDSETEMSGTRESH _IO(2, 0x4a)
48#define FDFLUSH _IO(2, 0x4b)
Ben Cheng655a7c02013-10-16 16:09:24 -070049#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors)
50#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors)
Tao Baod7db5942015-01-28 10:07:51 -080051typedef char floppy_drive_name[16];
Ben Cheng655a7c02013-10-16 16:09:24 -070052#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name)
53struct floppy_drive_params {
Tao Baod7db5942015-01-28 10:07:51 -080054 signed char cmos;
Tao Baod7db5942015-01-28 10:07:51 -080055 unsigned long max_dtr;
56 unsigned long hlt;
57 unsigned long hut;
58 unsigned long srt;
Tao Baod7db5942015-01-28 10:07:51 -080059 unsigned long spinup;
60 unsigned long spindown;
61 unsigned char spindown_offset;
62 unsigned char select_delay;
Tao Baod7db5942015-01-28 10:07:51 -080063 unsigned char rps;
64 unsigned char tracks;
65 unsigned long timeout;
66 unsigned char interleave_sect;
Tao Baod7db5942015-01-28 10:07:51 -080067 struct floppy_max_errors max_errors;
68 char flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070069#define FTD_MSG 0x10
70#define FD_BROKEN_DCL 0x20
Tao Baod7db5942015-01-28 10:07:51 -080071#define FD_DEBUG 0x02
Ben Cheng655a7c02013-10-16 16:09:24 -070072#define FD_SILENT_DCL_CLEAR 0x4
73#define FD_INVERTED_DCL 0x80
Tao Baod7db5942015-01-28 10:07:51 -080074 char read_track;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070075#define FD_AUTODETECT_SIZE 8
76 short autodetect[FD_AUTODETECT_SIZE];
Tao Baod7db5942015-01-28 10:07:51 -080077 int checkfreq;
78 int native_format;
Ben Cheng655a7c02013-10-16 16:09:24 -070079};
80enum {
Tao Baod7db5942015-01-28 10:07:51 -080081 FD_NEED_TWADDLE_BIT,
82 FD_VERIFY_BIT,
83 FD_DISK_NEWCHANGE_BIT,
Tao Baod7db5942015-01-28 10:07:51 -080084 FD_UNUSED_BIT,
85 FD_DISK_CHANGED_BIT,
86 FD_DISK_WRITABLE_BIT,
87 FD_OPEN_SHOULD_FAIL_BIT
Ben Cheng655a7c02013-10-16 16:09:24 -070088};
Christopher Ferris38062f92014-07-09 15:33:25 -070089#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
Ben Cheng655a7c02013-10-16 16:09:24 -070090#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params)
91struct floppy_drive_struct {
Tao Baod7db5942015-01-28 10:07:51 -080092 unsigned long flags;
Christopher Ferris38062f92014-07-09 15:33:25 -070093#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
Ben Cheng655a7c02013-10-16 16:09:24 -070094#define FD_VERIFY (1 << FD_VERIFY_BIT)
95#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT)
96#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
Christopher Ferris38062f92014-07-09 15:33:25 -070097#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
Tao Baod7db5942015-01-28 10:07:51 -080098 unsigned long spinup_date;
99 unsigned long select_date;
Tao Baod7db5942015-01-28 10:07:51 -0800100 unsigned long first_read_date;
101 short probed_format;
102 short track;
103 short maxblock;
Tao Baod7db5942015-01-28 10:07:51 -0800104 short maxtrack;
105 int generation;
106 int keep_data;
107 int fd_ref;
Tao Baod7db5942015-01-28 10:07:51 -0800108 int fd_device;
109 unsigned long last_checked;
110 char * dmabuf;
111 int bufblocks;
Ben Cheng655a7c02013-10-16 16:09:24 -0700112};
Christopher Ferris38062f92014-07-09 15:33:25 -0700113#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct)
Ben Cheng655a7c02013-10-16 16:09:24 -0700114#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct)
115enum reset_mode {
Tao Baod7db5942015-01-28 10:07:51 -0800116 FD_RESET_IF_NEEDED,
117 FD_RESET_IF_RAWCMD,
118 FD_RESET_ALWAYS
Ben Cheng655a7c02013-10-16 16:09:24 -0700119};
120#define FDRESET _IO(2, 0x54)
Christopher Ferris38062f92014-07-09 15:33:25 -0700121struct floppy_fdc_state {
Tao Baod7db5942015-01-28 10:07:51 -0800122 int spec1;
123 int spec2;
Tao Baod7db5942015-01-28 10:07:51 -0800124 int dtr;
125 unsigned char version;
126 unsigned char dor;
127 unsigned long address;
Tao Baod7db5942015-01-28 10:07:51 -0800128 unsigned int rawcmd : 2;
129 unsigned int reset : 1;
130 unsigned int need_configure : 1;
131 unsigned int perp_mode : 2;
Tao Baod7db5942015-01-28 10:07:51 -0800132 unsigned int has_fifo : 1;
133 unsigned int driver_version;
Ben Cheng655a7c02013-10-16 16:09:24 -0700134#define FD_DRIVER_VERSION 0x100
Tao Baod7db5942015-01-28 10:07:51 -0800135 unsigned char track[4];
Tao Baod7db5942015-01-28 10:07:51 -0800136};
Christopher Ferris38062f92014-07-09 15:33:25 -0700137#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state)
Ben Cheng655a7c02013-10-16 16:09:24 -0700138struct floppy_write_errors {
Tao Baod7db5942015-01-28 10:07:51 -0800139 unsigned int write_errors;
Tao Baod7db5942015-01-28 10:07:51 -0800140 unsigned long first_error_sector;
141 int first_error_generation;
142 unsigned long last_error_sector;
143 int last_error_generation;
Tao Baod7db5942015-01-28 10:07:51 -0800144 unsigned int badness;
Christopher Ferris38062f92014-07-09 15:33:25 -0700145};
Ben Cheng655a7c02013-10-16 16:09:24 -0700146#define FDWERRORCLR _IO(2, 0x56)
147#define FDWERRORGET _IOR(2, 0x17, struct floppy_write_errors)
148#define FDHAVEBATCHEDRAWCMD
Christopher Ferris38062f92014-07-09 15:33:25 -0700149struct floppy_raw_cmd {
Tao Baod7db5942015-01-28 10:07:51 -0800150 unsigned int flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700151#define FD_RAW_READ 1
Tao Baod7db5942015-01-28 10:07:51 -0800152#define FD_RAW_WRITE 2
Christopher Ferris38062f92014-07-09 15:33:25 -0700153#define FD_RAW_NO_MOTOR 4
Ben Cheng655a7c02013-10-16 16:09:24 -0700154#define FD_RAW_DISK_CHANGE 4
155#define FD_RAW_INTR 8
Tao Baod7db5942015-01-28 10:07:51 -0800156#define FD_RAW_SPIN 0x10
Christopher Ferris38062f92014-07-09 15:33:25 -0700157#define FD_RAW_NO_MOTOR_AFTER 0x20
Ben Cheng655a7c02013-10-16 16:09:24 -0700158#define FD_RAW_NEED_DISK 0x40
159#define FD_RAW_NEED_SEEK 0x80
Tao Baod7db5942015-01-28 10:07:51 -0800160#define FD_RAW_MORE 0x100
Christopher Ferris38062f92014-07-09 15:33:25 -0700161#define FD_RAW_STOP_IF_FAILURE 0x200
Ben Cheng655a7c02013-10-16 16:09:24 -0700162#define FD_RAW_STOP_IF_SUCCESS 0x400
163#define FD_RAW_SOFTFAILURE 0x800
164#define FD_RAW_FAILURE 0x10000
Christopher Ferris38062f92014-07-09 15:33:25 -0700165#define FD_RAW_HARDFAILURE 0x20000
Elliott Hughes0f0c18f2023-03-29 15:53:31 -0700166 void * data;
Tao Baod7db5942015-01-28 10:07:51 -0800167 char * kernel_data;
Tao Baod7db5942015-01-28 10:07:51 -0800168 struct floppy_raw_cmd * next;
169 long length;
170 long phys_length;
171 int buffer_length;
Tao Baod7db5942015-01-28 10:07:51 -0800172 unsigned char rate;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700173#define FD_RAW_CMD_SIZE 16
174#define FD_RAW_REPLY_SIZE 16
175#define FD_RAW_CMD_FULLSIZE (FD_RAW_CMD_SIZE + 1 + FD_RAW_REPLY_SIZE)
Tao Baod7db5942015-01-28 10:07:51 -0800176 unsigned char cmd_count;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700177 union {
178 struct {
179 unsigned char cmd[FD_RAW_CMD_SIZE];
180 unsigned char reply_count;
181 unsigned char reply[FD_RAW_REPLY_SIZE];
182 };
183 unsigned char fullcmd[FD_RAW_CMD_FULLSIZE];
184 };
Tao Baod7db5942015-01-28 10:07:51 -0800185 int track;
186 int resultcode;
187 int reserved1;
Tao Baod7db5942015-01-28 10:07:51 -0800188 int reserved2;
Christopher Ferris38062f92014-07-09 15:33:25 -0700189};
Ben Cheng655a7c02013-10-16 16:09:24 -0700190#define FDRAWCMD _IO(2, 0x58)
191#define FDTWADDLE _IO(2, 0x59)
Tao Baod7db5942015-01-28 10:07:51 -0800192#define FDEJECT _IO(2, 0x5a)
Christopher Ferris38062f92014-07-09 15:33:25 -0700193#endif