|
|
1.1 root 1: /*
2: * Copyright (c) 1994 Shantanu Goel
3: * All Rights Reserved.
4: *
5: * Permission to use, copy, modify and distribute this software and its
6: * documentation is hereby granted, provided that both the copyright
7: * notice and this permission notice appear in all copies of the
8: * software, derivative works or modified versions, and any portions
9: * thereof, and that both notices appear in supporting documentation.
10: *
11: * THE AUTHOR ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
12: * CONDITION. THE AUTHOR DISCLAIMS ANY LIABILITY OF ANY KIND FOR
13: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
14: */
15:
16: /*
17: * Hard disk controller.
18: */
19:
20: #define HD_DATA(p) (p) /* data register */
21: #define HD_ERROR(p) ((p) + 1) /* error register */
22: #define HD_PRECOMP(p) ((p) + 1) /* precomp register */
23: #define HD_SECTCNT(p) ((p) + 2) /* sector count register */
24: #define HD_SECT(p) ((p) + 3) /* sector number register */
25: #define HD_CYLLO(p) ((p) + 4) /* cylinder number low */
26: #define HD_CYLHI(p) ((p) + 5) /* cylinder number high */
27: #define HD_DRVHD(p) ((p) + 6) /* drive head register */
28: #define HD_STATUS(p) ((p) + 7) /* status register */
29: #define HD_CMD(p) ((p) + 7) /* command register */
30:
31: /*
32: * Status register
33: */
34: #define ST_BUSY 0x80 /* controller is busy */
35: #define ST_READY 0x40 /* drive is ready */
36: #define ST_WRTFLT 0x20 /* write fault */
37: #define ST_SEEK 0x10 /* seek complete */
38: #define ST_DREQ 0x08 /* data request */
39: #define ST_ECC 0x04 /* ECC corrected data */
40: #define ST_INDEX 0x02 /* index pulse */
41: #define ST_ERROR 0x01 /* an operation resulted in error */
42:
43: /*
44: * Error register
45: */
46: #define ERR_DAM 0x01 /* data address mark not found */
47: #define ERR_TR0 0x02 /* track 0 not found */
48: #define ERR_ABORT 0x04 /* command aborted */
49: #define ERR_ID 0x10 /* sector not found */
50: #define ERR_ECC 0x40 /* uncorrectable ECC error */
51: #define ERR_BADBLK 0x80 /* bad block detected */
52:
53: /*
54: * Commands
55: */
56: #define CMD_RESTORE 0x10
57: #define CMD_READ 0x20
58: #define CMD_WRITE 0x30
59: #define CMD_SETPARAM 0x91
60: #define CMD_READMULTI 0xc4
61: #define CMD_WRITEMULTI 0xc5
62: #define CMD_SETMULTI 0xc6
63: #define CMD_IDENTIFY 0xec
64:
65: #if 0
66: #define PDLOCATION 29 /* XXX: belongs in <i386at/disk.h> */
67: #endif
68:
69: #define BAD_BLK 0x80
70: #define SECSIZE 512
71:
72: /*
73: * Information returned by IDENTIFY command.
74: */
75: struct hdident {
76: u_short id_config; /* flags */
77: u_short id_npcyl; /* # physical cylinders */
78: u_short id_rsvd2; /* reserved (word 2) */
79: u_short id_nptrk; /* # physical tracks */
80: u_short id_bptrk; /* unformatted bytes/track */
81: u_short id_bpsect; /* unformatted bytes/sector */
82: u_short id_npsect; /* # physical sectors/track */
83: u_short id_vendor0; /* vendor unique */
84: u_short id_vendor1; /* vendor unique */
85: u_short id_vendor2; /* vendor unique */
86: u_char id_serno[20]; /* serial #: 0 = unspecified */
87: u_short id_buftype; /* ??? */
88: u_short id_bufsize; /* 512 byte increments: 0 = unspecified */
89: u_short id_eccbytes; /* for R/W LONG commands: 0 = unspecified */
90: u_char id_rev[8]; /* firmware revision: 0 = unspecified */
91: u_char id_model[40]; /* model name: 0 = unspecified */
92: u_char id_multisize; /* max multiple I/O size: 0 = unsupported */
93: u_char id_vendor3; /* vendor unique */
94: u_short id_dwordio; /* 0 = unsupported; 1 = implemented */
95: u_char id_vendor4; /* vendor unique */
96: u_char id_capability; /* 0:DMA 1:LBA 2:IORDYsw 3:IORDY:sup */
97: u_short id_rsvd50; /* reserved (word 50) */
98: u_char id_vendor5; /* vendor unique */
99: u_char id_pio; /* 0=slow, 1=medium, 2=fast */
100: u_char id_vendor6; /* vendor unique */
101: u_char id_dma; /* 0=slow, 1=medium, 2=fast */
102: u_short id_valid; /* 0:logical 1:eide */
103: u_short id_nlcyl; /* # logical cylinders */
104: u_short id_nltrk; /* # logical tracks */
105: u_short id_nlsect; /* # logical sectors/track */
106: u_short id_capacity0; /* logical total sectors on drive */
107: u_short id_capacity1; /* (2 words, misaligned int) */
108: u_char id_multisect; /* current multiple sector count */
109: u_char id_multivalid; /* bit 0=1, multisect field is valid */
110: u_short id_totsect; /* total number of sectors */
111: u_short id_dma1; /* single word DMA info */
112: u_short id_dmamulti; /* multiple word DMA info */
113: u_short id_eidepiomode; /* 0:mode3 1:mode4 */
114: u_short id_eidedmamin; /* min multiple word DMA cycle time (ns) */
115: u_short id_eidedmatime; /* recomended DMA cycle time (ns) */
116: u_short id_eidepio; /* min cycle time (ns), no IORDY */
117: u_short id_eidepioiordy;/* min cycle time (ns, with IORDY */
118: u_short id_rsvd69; /* reserved (word 69) */
119: u_short id_rsvd70; /* reserved (word 70) */
120: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.