xref: /onnv-gate/usr/src/lib/libsmedia/library/inc/smedia.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 1999-2002 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SMEDIA_H_
28*0Sstevel@tonic-gate #define	_SMEDIA_H_
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * smedia.h header for libsmedia library
34*0Sstevel@tonic-gate  */
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifdef __cplusplus
37*0Sstevel@tonic-gate extern "C" {
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #include <sys/types.h>
41*0Sstevel@tonic-gate #include <sys/stat.h>
42*0Sstevel@tonic-gate #include <sys/dkio.h>
43*0Sstevel@tonic-gate #include <sys/vtoc.h>
44*0Sstevel@tonic-gate #include <sys/scsi/scsi.h>
45*0Sstevel@tonic-gate #include <fcntl.h>
46*0Sstevel@tonic-gate #include <stdio.h>
47*0Sstevel@tonic-gate #include <errno.h>
48*0Sstevel@tonic-gate #include <synch.h>
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate typedef struct smdevice_info {
51*0Sstevel@tonic-gate 	uchar_t	sm_version;
52*0Sstevel@tonic-gate 	int32_t	sm_interface_type;	/* Interface type */
53*0Sstevel@tonic-gate 	char	*sm_vendor_name;	/* Vendor name */
54*0Sstevel@tonic-gate 	char 	*sm_product_name;	/* Product name */
55*0Sstevel@tonic-gate 	char 	*sm_firmware_version;	/* Firmware version */
56*0Sstevel@tonic-gate }smdevice_info_t;
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate typedef	void	*smedia_handle_t;
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate #define	SMDEVICE_INFO_V_1	1
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /* Interface Types */
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate #define	IF_SCSI		0x0
66*0Sstevel@tonic-gate #define	IF_FLOPPY	0x1
67*0Sstevel@tonic-gate #define	IF_PCMCIA	0x2
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate typedef struct smmedium_property {
71*0Sstevel@tonic-gate 	int32_t sm_version;
72*0Sstevel@tonic-gate 	int32_t sm_media_type;	/* Medium type */
73*0Sstevel@tonic-gate 	int32_t sm_blocksize;	/* Medium block size in bytes */
74*0Sstevel@tonic-gate 	int32_t sm_capacity;	/* Medium capacity in no. of blocks */
75*0Sstevel@tonic-gate 	int32_t sm_pcyl;	/* No. of cylinders on the medium */
76*0Sstevel@tonic-gate 	int32_t sm_nhead;	/* No. of heads */
77*0Sstevel@tonic-gate 	int32_t sm_nsect;	/* No. of sectors per cylinder */
78*0Sstevel@tonic-gate }smmedium_prop_t;
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate #define	SMMEDIA_PROP_V_1	1
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * Media types not defined for DKIOCGMEDIAINFO
84*0Sstevel@tonic-gate  */
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate #define	SM_REMOVABLE_DISK	0x20005 /* Removable disk */
87*0Sstevel@tonic-gate 					/* FIXED_DISK + REMOVABLE */
88*0Sstevel@tonic-gate #define	SM_FLOPPY		0x10002 /* Floppy media */
89*0Sstevel@tonic-gate #define	SM_SCSI_FLOPPY		0x10005 /* SCSI floppy device */
90*0Sstevel@tonic-gate #define	SM_PCMCIA_MEM		0x20006 /* PCMCIA memory card */
91*0Sstevel@tonic-gate #define	SM_PCMCIA_ATA		0x20007 /* PCMCIA ata card */
92*0Sstevel@tonic-gate #define	SM_NOT_PRESENT		0xFFFF
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #define	MAX_PASSWD_LENGTH		32
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate #define	PASSWD		0x1000
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate #define	SM_WRITE_PROTECT_DISABLE	(PASSWD|0x0)
100*0Sstevel@tonic-gate #define	SM_WRITE_PROTECT_NOPASSWD	(PASSWD|0x2)
101*0Sstevel@tonic-gate #define	SM_WRITE_PROTECT_PASSWD		(PASSWD|0x4)
102*0Sstevel@tonic-gate #define	SM_READ_WRITE_PROTECT		(PASSWD|0x8)
103*0Sstevel@tonic-gate #define	SM_TEMP_UNLOCK_MODE		(PASSWD|0x10)
104*0Sstevel@tonic-gate #define	SM_STATUS_UNKNOWN		(PASSWD|0xFF)
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate #define	SM_UNPROTECTED			SM_WRITE_PROTECT_DISABLE
107*0Sstevel@tonic-gate #define	SM_WRITE_PROTECTED 		SM_WRITE_PROTECT_NOPASSWD
108*0Sstevel@tonic-gate #define	SM_WRITE_PROTECTED_WP   	SM_WRITE_PROTECT_PASSWD
109*0Sstevel@tonic-gate #define	SM_READ_WRITE_PROTECTED 	SM_READ_WRITE_PROTECT
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate typedef struct smwp_state {
113*0Sstevel@tonic-gate 	uchar_t sm_version;
114*0Sstevel@tonic-gate 	int32_t	sm_new_state;
115*0Sstevel@tonic-gate 	int32_t	sm_passwd_len;
116*0Sstevel@tonic-gate 	char	sm_passwd[MAX_PASSWD_LENGTH];
117*0Sstevel@tonic-gate }smwp_state_t;
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate #define	SMWP_STATE_V_1			1
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate #define	FORMAT	0x2000
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate #define	SM_FORMAT_LONG		(FORMAT|0x0001)
124*0Sstevel@tonic-gate #define	SM_FORMAT_QUICK		(FORMAT|0x0002)
125*0Sstevel@tonic-gate #define	SM_FORMAT_FORCE		(FORMAT|0x0003)
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate /* Floppy specific options */
128*0Sstevel@tonic-gate #define	SM_FORMAT_HD	(FORMAT|0x0011) /* Format high density (1.44MB) */
129*0Sstevel@tonic-gate #define	SM_FORMAT_DD	(FORMAT|0x0012) /* Format Double density (720KB) */
130*0Sstevel@tonic-gate #define	SM_FORMAT_ED	(FORMAT|0x0013) /* Format Extended density (2.88MB) */
131*0Sstevel@tonic-gate #define	SM_FORMAT_MD	(FORMAT|0x0014) /* Format Medium density (1.2MB) */
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate #define	SM_FORMAT_IMMEDIATE	(FORMAT|0x0021)
134*0Sstevel@tonic-gate #define	SM_FORMAT_BLOCKED	(FORMAT|0x0022)
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate 
137*0Sstevel@tonic-gate /* New Library interface prototypes */
138*0Sstevel@tonic-gate 
139*0Sstevel@tonic-gate int smedia_get_device_info(smedia_handle_t handle, smdevice_info_t *smdevinfop);
140*0Sstevel@tonic-gate int smedia_free_device_info(smedia_handle_t handle,
141*0Sstevel@tonic-gate 		smdevice_info_t *smdevinfop);
142*0Sstevel@tonic-gate int smedia_get_medium_property(smedia_handle_t handle,
143*0Sstevel@tonic-gate 		smmedium_prop_t *smpropp);
144*0Sstevel@tonic-gate int smedia_get_protection_status(smedia_handle_t handle,
145*0Sstevel@tonic-gate 		smwp_state_t *wpstatep);
146*0Sstevel@tonic-gate int smedia_set_protection_status(smedia_handle_t handle,
147*0Sstevel@tonic-gate 		smwp_state_t *wpstatep);
148*0Sstevel@tonic-gate size_t smedia_raw_read(smedia_handle_t handle, diskaddr_t blockno,
149*0Sstevel@tonic-gate 		caddr_t buffer,
150*0Sstevel@tonic-gate 							size_t nbytes);
151*0Sstevel@tonic-gate size_t smedia_raw_write(smedia_handle_t handle, diskaddr_t blockno,
152*0Sstevel@tonic-gate 		caddr_t buffer,
153*0Sstevel@tonic-gate 							size_t nbytes);
154*0Sstevel@tonic-gate int smedia_format(smedia_handle_t handle, uint_t flavor, uint_t mode);
155*0Sstevel@tonic-gate int smedia_check_format_status(smedia_handle_t handle);
156*0Sstevel@tonic-gate int smedia_format_track(smedia_handle_t handle, uint_t trackno, uint_t head,
157*0Sstevel@tonic-gate 							uint_t density);
158*0Sstevel@tonic-gate int smedia_eject(smedia_handle_t handle);
159*0Sstevel@tonic-gate int smedia_reassign_block(smedia_handle_t handle, diskaddr_t blockno);
160*0Sstevel@tonic-gate smedia_handle_t smedia_get_handle(int32_t);
161*0Sstevel@tonic-gate int smedia_release_handle(smedia_handle_t handle);
162*0Sstevel@tonic-gate int smedia_uscsi_cmd(smedia_handle_t handle, struct uscsi_cmd *cmd);
163*0Sstevel@tonic-gate 
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate #ifdef __cplusplus
166*0Sstevel@tonic-gate }
167*0Sstevel@tonic-gate #endif
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate #endif /* _SMEDIA_H_ */
170