4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
29 * smedia.h header for libsmedia library
36 #include <sys/types.h>
40 #include <sys/scsi/scsi.h>
46 typedef struct smdevice_info
{
48 int32_t sm_interface_type
; /* Interface type */
49 char *sm_vendor_name
; /* Vendor name */
50 char *sm_product_name
; /* Product name */
51 char *sm_firmware_version
; /* Firmware version */
54 typedef void *smedia_handle_t
;
57 #define SMDEVICE_INFO_V_1 1
67 typedef struct smmedium_property
{
69 int32_t sm_media_type
; /* Medium type */
70 int32_t sm_blocksize
; /* Medium block size in bytes */
71 int32_t sm_capacity
; /* Medium capacity in no. of blocks */
72 int32_t sm_pcyl
; /* No. of cylinders on the medium */
73 int32_t sm_nhead
; /* No. of heads */
74 int32_t sm_nsect
; /* No. of sectors per cylinder */
77 #define SMMEDIA_PROP_V_1 1
80 * Media types not defined for DKIOCGMEDIAINFO
83 #define SM_REMOVABLE_DISK 0x20005 /* Removable disk */
84 /* FIXED_DISK + REMOVABLE */
85 #define SM_FLOPPY 0x10002 /* Floppy media */
86 #define SM_SCSI_FLOPPY 0x10005 /* SCSI floppy device */
87 #define SM_PCMCIA_MEM 0x20006 /* PCMCIA memory card (Obsolete) */
88 #define SM_PCMCIA_ATA 0x20007 /* PCMCIA ata card */
89 #define SM_BLOCK 0x20008 /* Generic block device */
90 #define SM_NOT_PRESENT 0xFFFF
93 #define MAX_PASSWD_LENGTH 32
97 #define SM_WRITE_PROTECT_DISABLE (PASSWD|0x0)
98 #define SM_WRITE_PROTECT_NOPASSWD (PASSWD|0x2)
99 #define SM_WRITE_PROTECT_PASSWD (PASSWD|0x4)
100 #define SM_READ_WRITE_PROTECT (PASSWD|0x8)
101 #define SM_TEMP_UNLOCK_MODE (PASSWD|0x10)
102 #define SM_STATUS_UNKNOWN (PASSWD|0xFF)
104 #define SM_UNPROTECTED SM_WRITE_PROTECT_DISABLE
105 #define SM_WRITE_PROTECTED SM_WRITE_PROTECT_NOPASSWD
106 #define SM_WRITE_PROTECTED_WP SM_WRITE_PROTECT_PASSWD
107 #define SM_READ_WRITE_PROTECTED SM_READ_WRITE_PROTECT
110 typedef struct smwp_state
{
112 int32_t sm_new_state
;
113 int32_t sm_passwd_len
;
114 char sm_passwd
[MAX_PASSWD_LENGTH
];
117 #define SMWP_STATE_V_1 1
119 #define FORMAT 0x2000
121 #define SM_FORMAT_LONG (FORMAT|0x0001)
122 #define SM_FORMAT_QUICK (FORMAT|0x0002)
123 #define SM_FORMAT_FORCE (FORMAT|0x0003)
125 /* Floppy specific options */
126 #define SM_FORMAT_HD (FORMAT|0x0011) /* Format high density (1.44MB) */
127 #define SM_FORMAT_DD (FORMAT|0x0012) /* Format Double density (720KB) */
128 #define SM_FORMAT_ED (FORMAT|0x0013) /* Format Extended density (2.88MB) */
129 #define SM_FORMAT_MD (FORMAT|0x0014) /* Format Medium density (1.2MB) */
131 #define SM_FORMAT_IMMEDIATE (FORMAT|0x0021)
132 #define SM_FORMAT_BLOCKED (FORMAT|0x0022)
135 /* New Library interface prototypes */
137 int smedia_get_device_info(smedia_handle_t handle
, smdevice_info_t
*smdevinfop
);
138 int smedia_free_device_info(smedia_handle_t handle
,
139 smdevice_info_t
*smdevinfop
);
140 int smedia_get_medium_property(smedia_handle_t handle
,
141 smmedium_prop_t
*smpropp
);
142 int smedia_get_protection_status(smedia_handle_t handle
,
143 smwp_state_t
*wpstatep
);
144 int smedia_set_protection_status(smedia_handle_t handle
,
145 smwp_state_t
*wpstatep
);
146 size_t smedia_raw_read(smedia_handle_t handle
, diskaddr_t blockno
,
149 size_t smedia_raw_write(smedia_handle_t handle
, diskaddr_t blockno
,
152 int smedia_format(smedia_handle_t handle
, uint_t flavor
, uint_t mode
);
153 int smedia_check_format_status(smedia_handle_t handle
);
154 int smedia_format_track(smedia_handle_t handle
, uint_t trackno
, uint_t head
,
156 int smedia_eject(smedia_handle_t handle
);
157 int smedia_reassign_block(smedia_handle_t handle
, diskaddr_t blockno
);
158 smedia_handle_t
smedia_get_handle(int32_t);
159 int smedia_release_handle(smedia_handle_t handle
);
160 int smedia_uscsi_cmd(smedia_handle_t handle
, struct uscsi_cmd
*cmd
);
167 #endif /* _SMEDIA_H_ */