xref: /illumos-gate/usr/src/uts/common/sys/hdio.h (revision a0955b86cd77e22e80846428a5065e871b6d8eb8)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Used for generic commands
38  */
39 struct hdk_cmd {
40 	ushort_t hdkc_cmd;		/* command to be executed */
41 	int	hdkc_flags;		/* execution flags */
42 	daddr_t	hdkc_blkno;		/* disk address for command */
43 	int	hdkc_secnt;		/* sector count for command */
44 	caddr_t	hdkc_bufaddr;		/* user's buffer address */
45 	uint_t	hdkc_buflen;		/* size of user's buffer */
46 };
47 
48 /*
49  * Used for drive info
50  */
51 struct hdk_type {
52 	ushort_t hdkt_hsect;		/* hard sector count (read only) */
53 	ushort_t hdkt_promrev;		/* prom revision (read only) */
54 	uchar_t	hdkt_drtype;		/* drive type (ctlr specific) */
55 	uchar_t	hdkt_drstat;		/* drive status (ctlr specific, ro) */
56 };
57 
58 /*
59  * Used for bad sector map
60  */
61 struct hdk_badmap {
62 	caddr_t hdkb_bufaddr;		/* address of user's map buffer */
63 };
64 
65 /*
66  * Execution flags.
67  */
68 #define	HDK_SILENT	0x01		/* no error messages */
69 #define	HDK_DIAGNOSE	0x02		/* fail if any error occurs */
70 #define	HDK_ISOLATE	0x04		/* isolate from normal commands */
71 #define	HDK_READ	0x08		/* read from device */
72 #define	HDK_WRITE	0x10		/* write to device */
73 #define	HDK_KBUF	0x20		/* write to device */
74 
75 /*
76  * Used for disk diagnostics
77  */
78 struct hdk_diag {
79 	ushort_t hdkd_errcmd;		/* most recent command in error */
80 	daddr_t	hdkd_errsect;		/* most recent sector in error */
81 	uchar_t	hdkd_errno;		/* most recent error number */
82 	uchar_t	hdkd_severe;		/* severity of most recent error */
83 };
84 
85 /*
86  * Used for getting disk error log.
87  */
88 struct hdk_loghdr {
89 	long	hdkl_entries;		/* number of dk_log entries */
90 	long	hdkl_max_size;		/* max. size of dk_log table */
91 	caddr_t	hdkl_logbfr;		/* pointer to dk_log table */
92 };
93 
94 /*
95  * Disk error log table entry.
96  */
97 struct hdk_log {
98 	daddr_t	hdkl_block;		/* location of block in error */
99 	ulong_t	hdkl_count;		/* number of failures */
100 	short	hdkl_type;		/* type of error (e.g. soft error) */
101 	short	hdkl_err1;		/* primary error code (e.g sense key) */
102 	short	hdkl_err2;		/* secondary error code */
103 };
104 
105 /*
106  * Dk_log type flags.
107  *
108  * FIXME:  Really should specify dkd_errno error codes.
109  *	For some reason they're specified in the drivers
110  *	instead of here??  Should also use those here for
111  *	dk_log.type too.
112  */
113 #define	HDKL_SOFT	0x01		/* recoverable erro */
114 #define	HDKL_HARD	0x02		/* unrecoverable error */
115 
116 /*
117  * Severity values
118  */
119 #define	HDK_NOERROR	0
120 #define	HDK_CORRECTED	1
121 #define	HDK_RECOVERED	2
122 #define	HDK_FATAL	3
123 
124 /*
125  * Error types
126  */
127 #define	HDK_NONMEDIA	0		/* not caused by a media defect */
128 #define	HDK_ISMEDIA	1		/* caused by a media defect */
129 
130 
131 #define	HDIOC		(0x04 << 8)
132 #define	HDKIOCSTYPE	(HDIOC|101)		/* Set drive info */
133 #define	HDKIOCGTYPE	(HDIOC|102)		/* Get drive info */
134 #define	HDKIOCSBAD	(HDIOC|103)		/* Set bad sector map */
135 #define	HDKIOCGBAD	(HDIOC|104)		/* Get bad sector map */
136 #define	HDKIOCSCMD	(HDIOC|105)		/* Set generic cmd */
137 #define	HDKIOCGDIAG	(HDIOC|106)		/* Get diagnostics */
138 
139 #ifdef	__cplusplus
140 }
141 #endif
142 
143 #endif	/* _SYS_HDIO_H */
144