xref: /onnv-gate/usr/src/cmd/smserverd/smserver.h (revision 1137:32f68d2364fc)
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
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*1137Sarutz  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SMSERVER_H_
280Sstevel@tonic-gate #define	_SMSERVER_H_
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef __cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <door.h>
370Sstevel@tonic-gate #include <thread.h>
380Sstevel@tonic-gate #include <synch.h>
390Sstevel@tonic-gate #include <sys/dkio.h>
400Sstevel@tonic-gate #include <bsm/audit.h>
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #define	RQ_LEN 18
430Sstevel@tonic-gate #define	MAX_RQ_LEN 32
440Sstevel@tonic-gate #define	MAX_CDB_LEN 32
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #define	smedia_service	"/var/run/smedia_svc"
470Sstevel@tonic-gate #define	DEFAULT_SMEDIAD_DEVDIR	"/usr/lib/smedia"
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #define	INIT_NOT_DONE		0
500Sstevel@tonic-gate #define	INIT_DONE		1
510Sstevel@tonic-gate #define	INIT_IN_PROGRESS	2
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /* SCSI FORMAT UNIT cdb[1] #defines */
540Sstevel@tonic-gate #define	FMTDATA			0x10
550Sstevel@tonic-gate #define	CMPLIST			0x08
560Sstevel@tonic-gate 
570Sstevel@tonic-gate /* Defect list header data[1] #defines */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #define	VS			0x1
600Sstevel@tonic-gate #define	IMMED			0x2
610Sstevel@tonic-gate #define	DSP			0x4
620Sstevel@tonic-gate #define	IP			0x8
630Sstevel@tonic-gate #define	STPF			0x10
640Sstevel@tonic-gate #define	DCRT			0x20
650Sstevel@tonic-gate #define	DPRY			0x40
660Sstevel@tonic-gate #define	FOV			0x80
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	DEFERRED_ERROR		0x71
690Sstevel@tonic-gate #define	AWRE			0x80
700Sstevel@tonic-gate 
710Sstevel@tonic-gate #define	MODE_SENSE_PARAM_HDR_LEN		4
720Sstevel@tonic-gate #define	MODE_PARAM_BLOCK_LEN			8
730Sstevel@tonic-gate #define	AWRE_OFFSET	(MODE_SENSE_PARAM_HDR_LEN + MODE_PARAM_BLOCK_LEN + 2)
740Sstevel@tonic-gate #define	BLOCK_LEN_OFFSET			(MODE_SENSE_PARAM_HDR_LEN + 5)
750Sstevel@tonic-gate #define	SKSV_FIELD				0x80
760Sstevel@tonic-gate #define	SKSV_OFFSET				15
770Sstevel@tonic-gate #define	FORMAT_PROGRESS_INDICATOR_OFFSET_0	16
780Sstevel@tonic-gate #define	FORMAT_PROGRESS_INDICATOR_OFFSET_1	17
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /* #defines for protect medode field */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate #define	UNLOCK_MODE			0x0
830Sstevel@tonic-gate #define	WRITE_PROTECT_MODE		0x2
840Sstevel@tonic-gate #define	PASSWD_WRITE_PROTECT_MODE	0x3
850Sstevel@tonic-gate #define	READ_WRITE_PROTECT_MODE		0x5
860Sstevel@tonic-gate #define	TEMP_UNLOCK_MODE		0x8
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /* #defines for CARTRIDGE STATUS PAGE */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #define	CARTRIDGE_STATUS_PAGE		2
910Sstevel@tonic-gate #define	NON_SENSE_HDR_LEN		0x2
920Sstevel@tonic-gate #define	PROTECT_MODE_OFFSET		19
930Sstevel@tonic-gate #define	DISK_STATUS_OFFSET		1
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /* error reporting mechanism */
970Sstevel@tonic-gate void	fatal(const char *, ...);
980Sstevel@tonic-gate void	info(const char *, ...);
990Sstevel@tonic-gate void	warning(const char *, ...);
1000Sstevel@tonic-gate void	debug(uint_t, const char *, ...);
1010Sstevel@tonic-gate void	setlog(const char *);
1020Sstevel@tonic-gate void	flushlog();
1030Sstevel@tonic-gate void	quit(const char *, ...);
1040Sstevel@tonic-gate void	noise(const char *, ...);
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate typedef struct server_data {
1070Sstevel@tonic-gate 	char	sd_init_state;
1080Sstevel@tonic-gate 	mutex_t	sd_init_lock;
1090Sstevel@tonic-gate 	cond_t	sd_init_cv;
1100Sstevel@tonic-gate 	int	sd_door;
1110Sstevel@tonic-gate 	int	sd_fd;
1120Sstevel@tonic-gate } server_data_t;
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate typedef	enum {
1150Sstevel@tonic-gate 	SMEDIA_SUCCESS = 0x0,
1160Sstevel@tonic-gate 	SMEDIA_FAILURE			/* general failure */
1170Sstevel@tonic-gate } smedia_errno_t;
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate typedef struct door_data {
1200Sstevel@tonic-gate 	mutex_t		dd_lock;	/* lock to protect entire structure */
1210Sstevel@tonic-gate 	mutex_t		dd_threadlock;	/* lock to protect dd_thread field */
1220Sstevel@tonic-gate 	sigset_t	dd_newset;	/* signal set handled by the server */
1230Sstevel@tonic-gate 	cond_t		dd_cv;		/* client_door_descriptor cv */
1240Sstevel@tonic-gate 	cond_t		dd_cv_bind;	/* client door descriptor bind cv */
1250Sstevel@tonic-gate 	int32_t		dd_id;		/* for future use. To store unique id */
126*1137Sarutz 	door_desc_t	dd_desc[2];	/* [0] : Client Door descriptor */
127*1137Sarutz 					/* [1] : Death Door decriptor */
1280Sstevel@tonic-gate 	thread_t	dd_thread;	/* thread bound to the client door */
1290Sstevel@tonic-gate 	door_cred_t	dd_cred;	/* credentials of client */
1300Sstevel@tonic-gate 	int32_t		dd_fd;		/* device file descriptor */
1310Sstevel@tonic-gate 	void		*dd_buf;	/* mmapped buffer of client */
1320Sstevel@tonic-gate 	int32_t		dd_buf_len;	/* size of the mmapped buffer */
1330Sstevel@tonic-gate 	int32_t		dd_buffd;	/* mmapped file descriptor */
1340Sstevel@tonic-gate 	int32_t		dd_sector_size;	/* sector size of the device */
1350Sstevel@tonic-gate 	struct stat	dd_stat;	/* stat of the dd_fd */
1360Sstevel@tonic-gate 	struct dk_cinfo	dd_dkinfo;
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate 	au_id_t		audit_auid;	/* auid of user writing audit record */
1390Sstevel@tonic-gate 	uid_t		audit_uid;	/* uid of user writing audit record */
1400Sstevel@tonic-gate 	uid_t		audit_euid;	/* euid of user writing audit record */
1410Sstevel@tonic-gate 	gid_t		audit_gid;	/* gid of user writing audit record */
1420Sstevel@tonic-gate 	gid_t		audit_egid;	/* euid of user writing audit record */
1430Sstevel@tonic-gate 	pid_t		audit_pid;	/* pid of user writing audit record */
1440Sstevel@tonic-gate 	au_tid_addr_t	audit_tid;	/* tid of user writing audit record */
1450Sstevel@tonic-gate 	int		audit_na;	/* 0 if event is attributable */
1460Sstevel@tonic-gate 	au_mask_t	audit_namask;	/* not attributable flags */
1470Sstevel@tonic-gate 	au_event_t	audit_event;	/* id of event being audited */
1480Sstevel@tonic-gate 	int 		audit_sorf;	/* success or failure of audit_event */
1490Sstevel@tonic-gate 	char 		*audit_user;	/* text version of audit_uid */
1500Sstevel@tonic-gate 	au_asid_t	audit_asid;	/* asid of process writing record */
1510Sstevel@tonic-gate 	char 		*audit_path;	/* path token */
1520Sstevel@tonic-gate 	int		audit_policy;	/* kernel audit policy */
1530Sstevel@tonic-gate 	struct auditpinfo_addr audit_ap;
1540Sstevel@tonic-gate 	char		audit_text[128];
1550Sstevel@tonic-gate 	char		audit_text1[128];
1560Sstevel@tonic-gate } door_data_t;
1570Sstevel@tonic-gate 
158*1137Sarutz /* Symbols to simplify access of door_data_t */
159*1137Sarutz #define	dd_cdoor	dd_desc[0]	/* Client Door descriptor */
160*1137Sarutz #define	dd_ddoor	dd_desc[1]	/* Death Door descriptor */
161*1137Sarutz #define	dd_cdoor_descriptor	dd_cdoor.d_data.d_desc.d_descriptor
162*1137Sarutz #define	dd_ddoor_descriptor	dd_ddoor.d_data.d_desc.d_descriptor
163*1137Sarutz 
1640Sstevel@tonic-gate typedef enum {
1650Sstevel@tonic-gate 	SMEDIA_CNUM_OPEN_FD = 0x1,
1660Sstevel@tonic-gate 	SMEDIA_CNUM_GET_DEVICE_INFO,
1670Sstevel@tonic-gate 	SMEDIA_CNUM_GET_MEDIUM_PROPERTY,
1680Sstevel@tonic-gate 	SMEDIA_CNUM_GET_PROTECTION_STATUS,
1690Sstevel@tonic-gate 	SMEDIA_CNUM_SET_PROTECTION_STATUS,
1700Sstevel@tonic-gate 	SMEDIA_CNUM_RAW_READ,
1710Sstevel@tonic-gate 	SMEDIA_CNUM_RAW_WRITE,
1720Sstevel@tonic-gate 	SMEDIA_CNUM_FORMAT,
1730Sstevel@tonic-gate 	SMEDIA_CNUM_CHECK_FORMAT_STATUS,
1740Sstevel@tonic-gate 	SMEDIA_CNUM_EJECT,
1750Sstevel@tonic-gate 	SMEDIA_CNUM_REASSIGN_BLOCK,
1760Sstevel@tonic-gate 	SMEDIA_CNUM_ERROR,
1770Sstevel@tonic-gate 	SMEDIA_CNUM_CLOSE,
1780Sstevel@tonic-gate 	SMEDIA_CNUM_SET_SHFD,
1790Sstevel@tonic-gate 	SMEDIA_CNUM_PING,
1800Sstevel@tonic-gate 	SMEDIA_CNUM_USCSI_CMD
1810Sstevel@tonic-gate } smedia_callnumber_t;
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate typedef struct {
1840Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* service call number */
1850Sstevel@tonic-gate 	char			buf[1];	/* buffer containing input arguments */
1860Sstevel@tonic-gate } smedia_req_t;
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate typedef struct {
1890Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* service call number */
1900Sstevel@tonic-gate 	char			buf[1];	/* buffer containing the results */
1910Sstevel@tonic-gate } smedia_ret_t;
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate typedef struct smedia_reqping {
1940Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_PING */
1950Sstevel@tonic-gate } smedia_reqping_t;
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate typedef struct smedia_retping {
1980Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_PING */
1990Sstevel@tonic-gate } smedia_retping_t;
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate 	/*
2020Sstevel@tonic-gate 	 * SMEDIA open device
2030Sstevel@tonic-gate 	 */
2040Sstevel@tonic-gate typedef	struct	smedia_reqopen {
2050Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_OPEN */
2060Sstevel@tonic-gate 	int	oflag;
2070Sstevel@tonic-gate 	int	omode;
2080Sstevel@tonic-gate } smedia_reqopen_t;
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate typedef	struct	smedia_retopen {
2110Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_OPEN */
2120Sstevel@tonic-gate } smedia_retopen_t;
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate typedef struct smedia_requscsi_cmd {
2150Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_USCSI_CMD */
2160Sstevel@tonic-gate 	int32_t			uscsi_flags;
2170Sstevel@tonic-gate 	short			uscsi_timeout;
2180Sstevel@tonic-gate 	char			uscsi_cdb[MAX_CDB_LEN];
2190Sstevel@tonic-gate 	int32_t			uscsi_buflen;
2200Sstevel@tonic-gate 	uchar_t			uscsi_cdblen;
2210Sstevel@tonic-gate 	uchar_t			uscsi_rqlen;
2220Sstevel@tonic-gate } smedia_requscsi_cmd_t;
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate typedef struct smedia_retuscsi_cmd {
2250Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_USCSI_CMD */
2260Sstevel@tonic-gate 	int32_t			uscsi_retval;
2270Sstevel@tonic-gate 	int32_t			uscsi_errno;
2280Sstevel@tonic-gate 	short			uscsi_status;
2290Sstevel@tonic-gate 	int32_t			uscsi_resid;
2300Sstevel@tonic-gate 	uchar_t			uscsi_rqstatus;
2310Sstevel@tonic-gate 	uchar_t			uscsi_rqresid;
2320Sstevel@tonic-gate 	char			uscsi_rqbuf[MAX_RQ_LEN];
2330Sstevel@tonic-gate } smedia_retuscsi_cmd_t;
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate typedef struct	smedia_reqget_device_info {
2360Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_DEVICE_INFO */
2370Sstevel@tonic-gate } smedia_reqget_device_info_t;
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate typedef struct	smedia_reqset_shfd {
2400Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_SET_SHFD */
2410Sstevel@tonic-gate 	int32_t	fdbuf_len;
2420Sstevel@tonic-gate } smedia_reqset_shfd_t;
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate typedef struct	smedia_retget_device_info {
2450Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_DEVICE_INFO */
2460Sstevel@tonic-gate 	smdevice_info_t		smdevinfo;
2470Sstevel@tonic-gate 	uchar_t			sm_version;
2480Sstevel@tonic-gate 	int32_t			sm_interface_type;
2490Sstevel@tonic-gate 	char			sm_vendor_name[32];
2500Sstevel@tonic-gate 	char			sm_product_name[32];
2510Sstevel@tonic-gate 	char			sm_firmware_version[32];
2520Sstevel@tonic-gate } smedia_retget_device_info_t;
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate typedef struct	smedia_reqget_medium_property {
2550Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_MEDIUM_PROPERTY */
2560Sstevel@tonic-gate } smedia_reqget_medium_property_t;
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate typedef struct	smedia_retget_medium_property {
2590Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_MEDIUM_PROPERTY */
2600Sstevel@tonic-gate 	smmedium_prop_t		smprop;
2610Sstevel@tonic-gate } smedia_retget_medium_property_t;
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate typedef struct	smedia_reqget_protection_status {
2640Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_PROTECTION_STATUS */
2650Sstevel@tonic-gate } smedia_reqget_protection_status_t;
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate typedef struct	smedia_retget_protection_status {
2680Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_PROTECTION_STATUS */
2690Sstevel@tonic-gate 	smwp_state_t		prot_state;
2700Sstevel@tonic-gate } smedia_retget_protection_status_t;
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate typedef struct	smedia_reqset_protection_status {
2730Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_SET_PROTECTION_STATUS */
2740Sstevel@tonic-gate 	smwp_state_t		prot_state;
2750Sstevel@tonic-gate } smedia_reqset_protection_status_t;
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate typedef struct	smedia_retset_protection_status {
2780Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_SET_PROTECTION_STATUS */
2790Sstevel@tonic-gate } smedia_retset_protection_status_t;
2800Sstevel@tonic-gate 
2810Sstevel@tonic-gate typedef struct	smedia_reqraw_read {
2820Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_READ */
2830Sstevel@tonic-gate 	diskaddr_t		blockno;
2840Sstevel@tonic-gate 	int32_t			nbytes;
2850Sstevel@tonic-gate } smedia_reqraw_read_t;
2860Sstevel@tonic-gate 
2870Sstevel@tonic-gate typedef struct	smedia_retraw_read {
2880Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_READ */
2890Sstevel@tonic-gate 	int32_t			nbytes;	/* bytes read */
2900Sstevel@tonic-gate 	char			buf[1];	/* buffer size is nbytes long */
2910Sstevel@tonic-gate } smedia_retraw_read_t;
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate typedef struct	smedia_reqraw_write {
2940Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_WRITE */
2950Sstevel@tonic-gate 	diskaddr_t		blockno;
2960Sstevel@tonic-gate 	int32_t			nbytes;
2970Sstevel@tonic-gate 	char			buf[1];	/* buffer size is nbytes long */
2980Sstevel@tonic-gate } smedia_reqraw_write_t;
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate typedef struct	smedia_retraw_write {
3010Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_WRITE */
3020Sstevel@tonic-gate 	int32_t			nbytes;	/* bytes written */
3030Sstevel@tonic-gate } smedia_retraw_write_t;
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate typedef struct	smedia_reqformat {
3060Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_FORMAT */
3070Sstevel@tonic-gate 	uint_t			flavor;
3080Sstevel@tonic-gate 	uint_t			mode;
3090Sstevel@tonic-gate } smedia_reqformat_t;
3100Sstevel@tonic-gate 
3110Sstevel@tonic-gate typedef struct	smedia_retformat {
3120Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_FORMAT */
3130Sstevel@tonic-gate } smedia_retformat_t;
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate typedef struct	smedia_reqcheck_format_status {
3160Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_CHECK_FORMAT_STATUS */
3170Sstevel@tonic-gate } smedia_reqcheck_format_status_t;
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate typedef struct	smedia_retcheck_format_status {
3200Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_CHECK_FORMAT_STATUS */
3210Sstevel@tonic-gate 	int			percent_complete;
3220Sstevel@tonic-gate } smedia_retcheck_format_status_t;
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate typedef struct smedia_reqreassign_block {
3250Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_REASSIGN_BLOCK */
3260Sstevel@tonic-gate 	diskaddr_t		blockno;
3270Sstevel@tonic-gate } smedia_reqreassign_block_t;
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate typedef struct smedia_retreassign_block {
3300Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_REASSIGN_BLOCK */
3310Sstevel@tonic-gate } smedia_retreassign_block_t;
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate typedef struct	{
3340Sstevel@tonic-gate 	smedia_callnumber_t	cnum;		/* SMEDIA_CNUM_ERROR */
3350Sstevel@tonic-gate 	smedia_callnumber_t	in_cnum;	/* requested service number */
3360Sstevel@tonic-gate 	smedia_errno_t		errnum;
3370Sstevel@tonic-gate } smedia_reterror_t;
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate typedef union	{
3400Sstevel@tonic-gate 	smedia_req_t			in;		/* req arguments */
3410Sstevel@tonic-gate 	smedia_ret_t			out;		/* out results */
3420Sstevel@tonic-gate 	smedia_reqping_t		reqping;
3430Sstevel@tonic-gate 	smedia_retping_t		retping;
3440Sstevel@tonic-gate 	smedia_reqopen_t		reqopen;
3450Sstevel@tonic-gate 	smedia_retopen_t		retopen;
3460Sstevel@tonic-gate 	smedia_reqget_device_info_t	reqget_device_info;
3470Sstevel@tonic-gate 	smedia_retget_device_info_t	retget_device_info;
3480Sstevel@tonic-gate 	smedia_reqget_medium_property_t	reqget_medium_property;
3490Sstevel@tonic-gate 	smedia_retget_medium_property_t	retget_medium_property;
3500Sstevel@tonic-gate 	smedia_reqget_protection_status_t	reqget_protection_status;
3510Sstevel@tonic-gate 	smedia_retget_protection_status_t	retget_protection_status;
3520Sstevel@tonic-gate 	smedia_reqset_protection_status_t	reqset_protection_status;
3530Sstevel@tonic-gate 	smedia_retset_protection_status_t	retset_protection_status;
3540Sstevel@tonic-gate 	smedia_reqraw_read_t		reqraw_read;
3550Sstevel@tonic-gate 	smedia_retraw_read_t		retraw_read;
3560Sstevel@tonic-gate 	smedia_reqraw_write_t		reqraw_write;
3570Sstevel@tonic-gate 	smedia_retraw_write_t		retraw_write;
3580Sstevel@tonic-gate 	smedia_reqformat_t		reqformat;
3590Sstevel@tonic-gate 	smedia_retformat_t		retformat;
3600Sstevel@tonic-gate 	smedia_reqcheck_format_status_t		reqcheck_format_status;
3610Sstevel@tonic-gate 	smedia_retcheck_format_status_t		retcheck_format_status;
3620Sstevel@tonic-gate 	smedia_reqreassign_block_t	reqreassign_block;
3630Sstevel@tonic-gate 	smedia_retreassign_block_t	retreassign_block;
3640Sstevel@tonic-gate 	smedia_reterror_t		reterror;
3650Sstevel@tonic-gate 	smedia_reqset_shfd_t			reqset_shfd;
3660Sstevel@tonic-gate 	smedia_requscsi_cmd_t		requscsi_cmd;
3670Sstevel@tonic-gate 	smedia_retuscsi_cmd_t		retuscsi_cmd;
3680Sstevel@tonic-gate } smedia_services_t;
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate #define	SCSI_GENERIC	1
3710Sstevel@tonic-gate #define	SCSI_IOMEGA	2
3720Sstevel@tonic-gate #define	SCSI_FLOPPY	3
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate /*
3750Sstevel@tonic-gate  * Crude algorithm for calculating format timeout.
3760Sstevel@tonic-gate  * 30min + 5min/100MB =>
3770Sstevel@tonic-gate  * 35min for 100MB ZIP
3780Sstevel@tonic-gate  * 42.5 min for 250MB ZIP
3790Sstevel@tonic-gate  * 127 min for 2GB Jaz
3800Sstevel@tonic-gate  * It is OK for now as this is just an upper limit by which the
3810Sstevel@tonic-gate  * format should complete.
3820Sstevel@tonic-gate  */
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #define	FORMAT_TIMEOUT(n) (1800 + ((n)/682))
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate #define	WA_BIT	0x10	/* The word align bit for ATAPI devices */
3870Sstevel@tonic-gate /*
3880Sstevel@tonic-gate  * Non sense data length for catridge status page.
3890Sstevel@tonic-gate  * Should be 63, but IDE driver panics with a non-aligned
3900Sstevel@tonic-gate  * data transfer.
3910Sstevel@tonic-gate  */
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate #define	ND_LENGTH 64
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate /*
3960Sstevel@tonic-gate  * Vendor specific commands from Iomega
3970Sstevel@tonic-gate  */
3980Sstevel@tonic-gate 
3990Sstevel@tonic-gate #define	IOMEGA_NONSENSE_CMD 	0x6
4000Sstevel@tonic-gate #define	IOMEGA_CATRIDGE_PROTECT	0xC
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate #ifdef __cplusplus
4030Sstevel@tonic-gate }
4040Sstevel@tonic-gate #endif
4050Sstevel@tonic-gate 
4060Sstevel@tonic-gate #endif	/* _SMSERVER_H_ */
407