xref: /illumos-gate/usr/src/uts/common/sys/hdio.h (revision dd72704bd9e794056c558153663c739e2012d721)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_HDIO_H
28 #define	_SYS_HDIO_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Used for generic commands
36  */
37 struct hdk_cmd {
38 	ushort_t hdkc_cmd;		/* command to be executed */
39 	int	hdkc_flags;		/* execution flags */
40 	daddr_t	hdkc_blkno;		/* disk address for command */
41 	int	hdkc_secnt;		/* sector count for command */
42 	caddr_t	hdkc_bufaddr;		/* user's buffer address */
43 	uint_t	hdkc_buflen;		/* size of user's buffer */
44 };
45 
46 /*
47  * Used for drive info
48  */
49 struct hdk_type {
50 	ushort_t hdkt_hsect;		/* hard sector count (read only) */
51 	ushort_t hdkt_promrev;		/* prom revision (read only) */
52 	uchar_t	hdkt_drtype;		/* drive type (ctlr specific) */
53 	uchar_t	hdkt_drstat;		/* drive status (ctlr specific, ro) */
54 };
55 
56 /*
57  * Used for bad sector map
58  */
59 struct hdk_badmap {
60 	caddr_t hdkb_bufaddr;		/* address of user's map buffer */
61 };
62 
63 /*
64  * Execution flags.
65  */
66 #define	HDK_SILENT	0x01		/* no error messages */
67 #define	HDK_DIAGNOSE	0x02		/* fail if any error occurs */
68 #define	HDK_ISOLATE	0x04		/* isolate from normal commands */
69 #define	HDK_READ	0x08		/* read from device */
70 #define	HDK_WRITE	0x10		/* write to device */
71 #define	HDK_KBUF	0x20		/* write to device */
72 
73 /*
74  * Used for disk diagnostics
75  */
76 struct hdk_diag {
77 	ushort_t hdkd_errcmd;		/* most recent command in error */
78 	daddr_t	hdkd_errsect;		/* most recent sector in error */
79 	uchar_t	hdkd_errno;		/* most recent error number */
80 	uchar_t	hdkd_severe;		/* severity of most recent error */
81 };
82 
83 /*
84  * Used for getting disk error log.
85  */
86 struct hdk_loghdr {
87 	long	hdkl_entries;		/* number of dk_log entries */
88 	long	hdkl_max_size;		/* max. size of dk_log table */
89 	caddr_t	hdkl_logbfr;		/* pointer to dk_log table */
90 };
91 
92 /*
93  * Disk error log table entry.
94  */
95 struct hdk_log {
96 	daddr_t	hdkl_block;		/* location of block in error */
97 	ulong_t	hdkl_count;		/* number of failures */
98 	short	hdkl_type;		/* type of error (e.g. soft error) */
99 	short	hdkl_err1;		/* primary error code (e.g sense key) */
100 	short	hdkl_err2;		/* secondary error code */
101 };
102 
103 /*
104  * Dk_log type flags.
105  *
106  * FIXME:  Really should specify dkd_errno error codes.
107  *	For some reason they're specified in the drivers
108  *	instead of here??  Should also use those here for
109  *	dk_log.type too.
110  */
111 #define	HDKL_SOFT	0x01		/* recoverable erro */
112 #define	HDKL_HARD	0x02		/* unrecoverable error */
113 
114 /*
115  * Severity values
116  */
117 #define	HDK_NOERROR	0
118 #define	HDK_CORRECTED	1
119 #define	HDK_RECOVERED	2
120 #define	HDK_FATAL	3
121 
122 /*
123  * Error types
124  */
125 #define	HDK_NONMEDIA	0		/* not caused by a media defect */
126 #define	HDK_ISMEDIA	1		/* caused by a media defect */
127 
128 
129 #define	HDIOC		(0x04 << 8)
130 #define	HDKIOCSTYPE	(HDIOC|101)		/* Set drive info */
131 #define	HDKIOCGTYPE	(HDIOC|102)		/* Get drive info */
132 #define	HDKIOCSBAD	(HDIOC|103)		/* Set bad sector map */
133 #define	HDKIOCGBAD	(HDIOC|104)		/* Get bad sector map */
134 #define	HDKIOCSCMD	(HDIOC|105)		/* Set generic cmd */
135 #define	HDKIOCGDIAG	(HDIOC|106)		/* Get diagnostics */
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_HDIO_H */
142