import less(1)
[unleashed/tickless.git] / usr / src / lib / libsmedia / library / inc / smedia.h
blobf7d291ac0885237ab6ca01738d95ba7c91cfee93
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 #ifndef _SMEDIA_H_
26 #define _SMEDIA_H_
29 * smedia.h header for libsmedia library
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <sys/dkio.h>
39 #include <sys/vtoc.h>
40 #include <sys/scsi/scsi.h>
41 #include <fcntl.h>
42 #include <stdio.h>
43 #include <errno.h>
44 #include <synch.h>
46 typedef struct smdevice_info {
47 uchar_t sm_version;
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 */
52 }smdevice_info_t;
54 typedef void *smedia_handle_t;
57 #define SMDEVICE_INFO_V_1 1
59 /* Interface Types */
61 #define IF_SCSI 0x0
62 #define IF_FLOPPY 0x1
63 #define IF_PCMCIA 0x2
64 #define IF_BLOCK 0x3
67 typedef struct smmedium_property {
68 int32_t sm_version;
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 */
75 }smmedium_prop_t;
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
95 #define PASSWD 0x1000
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 {
111 uchar_t sm_version;
112 int32_t sm_new_state;
113 int32_t sm_passwd_len;
114 char sm_passwd[MAX_PASSWD_LENGTH];
115 }smwp_state_t;
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,
147 caddr_t buffer,
148 size_t nbytes);
149 size_t smedia_raw_write(smedia_handle_t handle, diskaddr_t blockno,
150 caddr_t buffer,
151 size_t nbytes);
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,
155 uint_t density);
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);
163 #ifdef __cplusplus
165 #endif
167 #endif /* _SMEDIA_H_ */