xref: /onnv-gate/usr/src/lib/libsmedia/library/inc/smedia.h (revision 12426:cdff5d2ea989)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
511215Sgdamore@opensolaris.org  * Common Development and Distribution License (the "License").
611215Sgdamore@opensolaris.org  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12426Sgdamore@opensolaris.org  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef _SMEDIA_H_
260Sstevel@tonic-gate #define	_SMEDIA_H_
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * smedia.h header for libsmedia library
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef __cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include <sys/stat.h>
380Sstevel@tonic-gate #include <sys/dkio.h>
390Sstevel@tonic-gate #include <sys/vtoc.h>
400Sstevel@tonic-gate #include <sys/scsi/scsi.h>
410Sstevel@tonic-gate #include <fcntl.h>
420Sstevel@tonic-gate #include <stdio.h>
430Sstevel@tonic-gate #include <errno.h>
440Sstevel@tonic-gate #include <synch.h>
450Sstevel@tonic-gate 
460Sstevel@tonic-gate typedef struct smdevice_info {
470Sstevel@tonic-gate 	uchar_t	sm_version;
480Sstevel@tonic-gate 	int32_t	sm_interface_type;	/* Interface type */
490Sstevel@tonic-gate 	char	*sm_vendor_name;	/* Vendor name */
500Sstevel@tonic-gate 	char 	*sm_product_name;	/* Product name */
510Sstevel@tonic-gate 	char 	*sm_firmware_version;	/* Firmware version */
520Sstevel@tonic-gate }smdevice_info_t;
530Sstevel@tonic-gate 
540Sstevel@tonic-gate typedef	void	*smedia_handle_t;
550Sstevel@tonic-gate 
560Sstevel@tonic-gate 
570Sstevel@tonic-gate #define	SMDEVICE_INFO_V_1	1
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /* Interface Types */
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #define	IF_SCSI		0x0
620Sstevel@tonic-gate #define	IF_FLOPPY	0x1
630Sstevel@tonic-gate #define	IF_PCMCIA	0x2
64*12426Sgdamore@opensolaris.org #define	IF_BLOCK	0x3
650Sstevel@tonic-gate 
660Sstevel@tonic-gate 
670Sstevel@tonic-gate typedef struct smmedium_property {
680Sstevel@tonic-gate 	int32_t sm_version;
690Sstevel@tonic-gate 	int32_t sm_media_type;	/* Medium type */
700Sstevel@tonic-gate 	int32_t sm_blocksize;	/* Medium block size in bytes */
710Sstevel@tonic-gate 	int32_t sm_capacity;	/* Medium capacity in no. of blocks */
720Sstevel@tonic-gate 	int32_t sm_pcyl;	/* No. of cylinders on the medium */
730Sstevel@tonic-gate 	int32_t sm_nhead;	/* No. of heads */
740Sstevel@tonic-gate 	int32_t sm_nsect;	/* No. of sectors per cylinder */
750Sstevel@tonic-gate }smmedium_prop_t;
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #define	SMMEDIA_PROP_V_1	1
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /*
800Sstevel@tonic-gate  * Media types not defined for DKIOCGMEDIAINFO
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate #define	SM_REMOVABLE_DISK	0x20005 /* Removable disk */
840Sstevel@tonic-gate 					/* FIXED_DISK + REMOVABLE */
850Sstevel@tonic-gate #define	SM_FLOPPY		0x10002 /* Floppy media */
860Sstevel@tonic-gate #define	SM_SCSI_FLOPPY		0x10005 /* SCSI floppy device */
8711215Sgdamore@opensolaris.org #define	SM_PCMCIA_MEM		0x20006 /* PCMCIA memory card (Obsolete) */
880Sstevel@tonic-gate #define	SM_PCMCIA_ATA		0x20007 /* PCMCIA ata card */
89*12426Sgdamore@opensolaris.org #define	SM_BLOCK		0x20008	/* Generic block device */
900Sstevel@tonic-gate #define	SM_NOT_PRESENT		0xFFFF
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #define	MAX_PASSWD_LENGTH		32
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #define	PASSWD		0x1000
960Sstevel@tonic-gate 
970Sstevel@tonic-gate #define	SM_WRITE_PROTECT_DISABLE	(PASSWD|0x0)
980Sstevel@tonic-gate #define	SM_WRITE_PROTECT_NOPASSWD	(PASSWD|0x2)
990Sstevel@tonic-gate #define	SM_WRITE_PROTECT_PASSWD		(PASSWD|0x4)
1000Sstevel@tonic-gate #define	SM_READ_WRITE_PROTECT		(PASSWD|0x8)
1010Sstevel@tonic-gate #define	SM_TEMP_UNLOCK_MODE		(PASSWD|0x10)
1020Sstevel@tonic-gate #define	SM_STATUS_UNKNOWN		(PASSWD|0xFF)
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate #define	SM_UNPROTECTED			SM_WRITE_PROTECT_DISABLE
1050Sstevel@tonic-gate #define	SM_WRITE_PROTECTED 		SM_WRITE_PROTECT_NOPASSWD
1060Sstevel@tonic-gate #define	SM_WRITE_PROTECTED_WP   	SM_WRITE_PROTECT_PASSWD
1070Sstevel@tonic-gate #define	SM_READ_WRITE_PROTECTED 	SM_READ_WRITE_PROTECT
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate typedef struct smwp_state {
1110Sstevel@tonic-gate 	uchar_t sm_version;
1120Sstevel@tonic-gate 	int32_t	sm_new_state;
1130Sstevel@tonic-gate 	int32_t	sm_passwd_len;
1140Sstevel@tonic-gate 	char	sm_passwd[MAX_PASSWD_LENGTH];
1150Sstevel@tonic-gate }smwp_state_t;
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate #define	SMWP_STATE_V_1			1
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #define	FORMAT	0x2000
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate #define	SM_FORMAT_LONG		(FORMAT|0x0001)
1220Sstevel@tonic-gate #define	SM_FORMAT_QUICK		(FORMAT|0x0002)
1230Sstevel@tonic-gate #define	SM_FORMAT_FORCE		(FORMAT|0x0003)
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate /* Floppy specific options */
1260Sstevel@tonic-gate #define	SM_FORMAT_HD	(FORMAT|0x0011) /* Format high density (1.44MB) */
1270Sstevel@tonic-gate #define	SM_FORMAT_DD	(FORMAT|0x0012) /* Format Double density (720KB) */
1280Sstevel@tonic-gate #define	SM_FORMAT_ED	(FORMAT|0x0013) /* Format Extended density (2.88MB) */
1290Sstevel@tonic-gate #define	SM_FORMAT_MD	(FORMAT|0x0014) /* Format Medium density (1.2MB) */
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate #define	SM_FORMAT_IMMEDIATE	(FORMAT|0x0021)
1320Sstevel@tonic-gate #define	SM_FORMAT_BLOCKED	(FORMAT|0x0022)
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /* New Library interface prototypes */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate int smedia_get_device_info(smedia_handle_t handle, smdevice_info_t *smdevinfop);
1380Sstevel@tonic-gate int smedia_free_device_info(smedia_handle_t handle,
1390Sstevel@tonic-gate 		smdevice_info_t *smdevinfop);
1400Sstevel@tonic-gate int smedia_get_medium_property(smedia_handle_t handle,
1410Sstevel@tonic-gate 		smmedium_prop_t *smpropp);
1420Sstevel@tonic-gate int smedia_get_protection_status(smedia_handle_t handle,
1430Sstevel@tonic-gate 		smwp_state_t *wpstatep);
1440Sstevel@tonic-gate int smedia_set_protection_status(smedia_handle_t handle,
1450Sstevel@tonic-gate 		smwp_state_t *wpstatep);
1460Sstevel@tonic-gate size_t smedia_raw_read(smedia_handle_t handle, diskaddr_t blockno,
1470Sstevel@tonic-gate 		caddr_t buffer,
1480Sstevel@tonic-gate 							size_t nbytes);
1490Sstevel@tonic-gate size_t smedia_raw_write(smedia_handle_t handle, diskaddr_t blockno,
1500Sstevel@tonic-gate 		caddr_t buffer,
1510Sstevel@tonic-gate 							size_t nbytes);
1520Sstevel@tonic-gate int smedia_format(smedia_handle_t handle, uint_t flavor, uint_t mode);
1530Sstevel@tonic-gate int smedia_check_format_status(smedia_handle_t handle);
1540Sstevel@tonic-gate int smedia_format_track(smedia_handle_t handle, uint_t trackno, uint_t head,
1550Sstevel@tonic-gate 							uint_t density);
1560Sstevel@tonic-gate int smedia_eject(smedia_handle_t handle);
1570Sstevel@tonic-gate int smedia_reassign_block(smedia_handle_t handle, diskaddr_t blockno);
1580Sstevel@tonic-gate smedia_handle_t smedia_get_handle(int32_t);
1590Sstevel@tonic-gate int smedia_release_handle(smedia_handle_t handle);
1600Sstevel@tonic-gate int smedia_uscsi_cmd(smedia_handle_t handle, struct uscsi_cmd *cmd);
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate #ifdef __cplusplus
1640Sstevel@tonic-gate }
1650Sstevel@tonic-gate #endif
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate #endif /* _SMEDIA_H_ */
168