1 #ifndef _LINUX_HDREG_H
2 #define _LINUX_HDREG_H
3
4 /*
5 * This file contains some defines for the AT-hd-controller.
6 * Various sources. Check out some definitions (see comments with
7 * a ques).
8 */
9
10 /* Hd controller regs. Ref: IBM AT Bios-listing */
11 #define HD_DATA 0x1f0 /* _CTL when writing */
12 #define HD_ERROR 0x1f1 /* see err-bits */
13 #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
14 #define HD_SECTOR 0x1f3 /* starting sector */
15 #define HD_LCYL 0x1f4 /* starting cylinder */
16 #define HD_HCYL 0x1f5 /* high byte of starting cyl */
17 #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
18 #define HD_STATUS 0x1f7 /* see status-bits */
19 #define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */
20 #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
21
22 #define HD_CMD 0x3f6
23
24 /* Bits of HD_STATUS */
25 #define ERR_STAT 0x01
26 #define INDEX_STAT 0x02
27 #define ECC_STAT 0x04 /* Corrected error */
28 #define DRQ_STAT 0x08
29 #define SEEK_STAT 0x10
30 #define WRERR_STAT 0x20
31 #define READY_STAT 0x40
32 #define BUSY_STAT 0x80
33
34 /* Values for HD_COMMAND */
35 #define WIN_RESTORE 0x10
36 #define WIN_READ 0x20
37 #define WIN_WRITE 0x30
38 #define WIN_VERIFY 0x40
39 #define WIN_FORMAT 0x50
40 #define WIN_INIT 0x60
41 #define WIN_SEEK 0x70
42 #define WIN_DIAGNOSE 0x90
43 #define WIN_SPECIFY 0x91
44
45 #define WIN_MULTREAD 0xC4 /* read multiple sectors */
46 #define WIN_MULTWRITE 0xC5 /* write multiple sectors */
47 #define WIN_SETMULT 0xC6 /* enable read multiple */
48 #define WIN_IDENTIFY 0xEC /* ask drive to identify itself */
49 #define WIN_SETFEATURES 0xEF /* set special drive features */
50
51 /* Bits for HD_ERROR */
52 #define MARK_ERR 0x01 /* Bad address mark */
53 #define TRK0_ERR 0x02 /* couldn't find track 0 */
54 #define ABRT_ERR 0x04 /* Command aborted */
55 #define ID_ERR 0x10 /* ID field not found */
56 #define ECC_ERR 0x40 /* Uncorrectable ECC error */
57 #define BBD_ERR 0x80 /* block marked bad */
58
59
60 /* HDIO_GETGEO is the preferred choice - HDIO_REQ will be removed at some
61 later date */
62 #define HDIO_REQ 0x301
63 #define HDIO_GETGEO 0x301
64 struct hd_geometry {
65 unsigned char heads;
66 unsigned char sectors;
67 unsigned short cylinders;
68 unsigned long start;
69 };
70 #define HDIO_GETUNMASKINTR 0x302
71 #define HDIO_SETUNMASKINTR 0x303
72 #define HDIO_GETMULTCOUNT 0x304
73 #define HDIO_SETMULTCOUNT 0x305
74 #define HDIO_GETIDENTITY 0x307
75 #endif
76
77 /* structure returned by HDIO_GETIDENTITY, as per ASC X3T9.2 rev 4a */
78 struct hd_driveid {
79 unsigned short config; /* lots of obsolete bit flags */
80 unsigned short cyls; /* "physical" cyls */
81 unsigned short reserved2; /* reserved (word 2) */
82 unsigned short heads; /* "physical" heads */
83 unsigned short track_bytes; /* unformatted bytes per track */
84 unsigned short sector_bytes; /* unformatted bytes per sector */
85 unsigned short sectors; /* "physical" sectors per track */
86 unsigned short vendor0; /* vendor unique */
87 unsigned short vendor1; /* vendor unique */
88 unsigned short vendor2; /* vendor unique */
89 unsigned char serial_no[20]; /* 0 = not_specified */
90 unsigned short buf_type;
91 unsigned short buf_size; /* 512 byte increments; 0 = not_specified */
92 unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */
93 unsigned char fw_rev[8]; /* 0 = not_specified */
94 unsigned char model[40]; /* 0 = not_specified */
95 unsigned char max_multsect; /* 0=not_implemented */
96 unsigned char vendor3; /* vendor unique */
97 unsigned short dword_io; /* 0=not_implemented; 1=implemented */
98 unsigned char vendor4; /* vendor unique */
99 unsigned char capability; /* bits 0:DMA 1:LBA 2:IORDYsw 3:IORDYsup*/
100 unsigned short reserved50; /* reserved (word 50) */
101 unsigned char vendor5; /* vendor unique */
102 unsigned char tPIO; /* 0=slow, 1=medium, 2=fast */
103 unsigned char vendor6; /* vendor unique */
104 unsigned char tDMA; /* 0=slow, 1=medium, 2=fast */
105 unsigned short field_valid; /* bits 0:cur_ok 1:eide_ok */
106 unsigned short cur_cyls; /* logical cylinders */
107 unsigned short cur_heads; /* logical heads */
108 unsigned short cur_sectors; /* logical sectors per track */
109 unsigned short cur_capacity0; /* logical total sectors on drive */
110 unsigned short cur_capacity1; /* (2 words, misaligned int) */
111 unsigned char multsect; /* current multiple sector count */
112 unsigned char multsect_valid; /* when (bit0==1) multsect is ok */
113 unsigned int lba_capacity; /* total number of sectors */
114 unsigned short dma_1word; /* single-word dma info */
115 unsigned short dma_mword; /* multiple-word dma info */
116 unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */
117 unsigned short eide_dma_min; /* min mword dma cycle time (ns) */
118 unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */
119 unsigned short eide_pio; /* min cycle time (ns), no IORDY */
120 unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */
121 unsigned short reserved69; /* reserved (word 69) */
122 unsigned short reserved70; /* reserved (word 70) */
123 /* unsigned short reservedxx[57];*/ /* reserved (words 71-127) */
124 /* unsigned short vendor7 [32];*/ /* vendor unique (words 128-159) */
125 /* unsigned short reservedyy[96];*/ /* reserved (words 160-255) */
126 };