xref: /titanic_41/usr/src/cmd/smserverd/smserver.h (revision 96093503d6c90cc5a0cd2ce8c88e1975be2d00b3)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*96093503SMarek Pospisil  * Common Development and Distribution License (the "License").
6*96093503SMarek Pospisil  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*96093503SMarek Pospisil  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SMSERVER_H_
277c478bd9Sstevel@tonic-gate #define	_SMSERVER_H_
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef __cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <door.h>
347c478bd9Sstevel@tonic-gate #include <thread.h>
357c478bd9Sstevel@tonic-gate #include <synch.h>
367c478bd9Sstevel@tonic-gate #include <sys/dkio.h>
377c478bd9Sstevel@tonic-gate #include <bsm/audit.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	RQ_LEN 18
407c478bd9Sstevel@tonic-gate #define	MAX_RQ_LEN 32
417c478bd9Sstevel@tonic-gate #define	MAX_CDB_LEN 32
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #define	smedia_service	"/var/run/smedia_svc"
447c478bd9Sstevel@tonic-gate #define	DEFAULT_SMEDIAD_DEVDIR	"/usr/lib/smedia"
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	INIT_NOT_DONE		0
477c478bd9Sstevel@tonic-gate #define	INIT_DONE		1
487c478bd9Sstevel@tonic-gate #define	INIT_IN_PROGRESS	2
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /* SCSI FORMAT UNIT cdb[1] #defines */
517c478bd9Sstevel@tonic-gate #define	FMTDATA			0x10
527c478bd9Sstevel@tonic-gate #define	CMPLIST			0x08
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /* Defect list header data[1] #defines */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	VS			0x1
577c478bd9Sstevel@tonic-gate #define	IMMED			0x2
587c478bd9Sstevel@tonic-gate #define	DSP			0x4
597c478bd9Sstevel@tonic-gate #define	IP			0x8
607c478bd9Sstevel@tonic-gate #define	STPF			0x10
617c478bd9Sstevel@tonic-gate #define	DCRT			0x20
627c478bd9Sstevel@tonic-gate #define	DPRY			0x40
637c478bd9Sstevel@tonic-gate #define	FOV			0x80
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	DEFERRED_ERROR		0x71
667c478bd9Sstevel@tonic-gate #define	AWRE			0x80
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	MODE_SENSE_PARAM_HDR_LEN		4
697c478bd9Sstevel@tonic-gate #define	MODE_PARAM_BLOCK_LEN			8
707c478bd9Sstevel@tonic-gate #define	AWRE_OFFSET	(MODE_SENSE_PARAM_HDR_LEN + MODE_PARAM_BLOCK_LEN + 2)
717c478bd9Sstevel@tonic-gate #define	BLOCK_LEN_OFFSET			(MODE_SENSE_PARAM_HDR_LEN + 5)
727c478bd9Sstevel@tonic-gate #define	SKSV_FIELD				0x80
737c478bd9Sstevel@tonic-gate #define	SKSV_OFFSET				15
747c478bd9Sstevel@tonic-gate #define	FORMAT_PROGRESS_INDICATOR_OFFSET_0	16
757c478bd9Sstevel@tonic-gate #define	FORMAT_PROGRESS_INDICATOR_OFFSET_1	17
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /* #defines for protect medode field */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #define	UNLOCK_MODE			0x0
807c478bd9Sstevel@tonic-gate #define	WRITE_PROTECT_MODE		0x2
817c478bd9Sstevel@tonic-gate #define	PASSWD_WRITE_PROTECT_MODE	0x3
827c478bd9Sstevel@tonic-gate #define	READ_WRITE_PROTECT_MODE		0x5
837c478bd9Sstevel@tonic-gate #define	TEMP_UNLOCK_MODE		0x8
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /* #defines for CARTRIDGE STATUS PAGE */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	CARTRIDGE_STATUS_PAGE		2
887c478bd9Sstevel@tonic-gate #define	NON_SENSE_HDR_LEN		0x2
897c478bd9Sstevel@tonic-gate #define	PROTECT_MODE_OFFSET		19
907c478bd9Sstevel@tonic-gate #define	DISK_STATUS_OFFSET		1
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /* error reporting mechanism */
947c478bd9Sstevel@tonic-gate void	fatal(const char *, ...);
957c478bd9Sstevel@tonic-gate void	info(const char *, ...);
967c478bd9Sstevel@tonic-gate void	warning(const char *, ...);
977c478bd9Sstevel@tonic-gate void	debug(uint_t, const char *, ...);
987c478bd9Sstevel@tonic-gate void	setlog(const char *);
997c478bd9Sstevel@tonic-gate void	flushlog();
1007c478bd9Sstevel@tonic-gate void	quit(const char *, ...);
1017c478bd9Sstevel@tonic-gate void	noise(const char *, ...);
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate typedef struct server_data {
1047c478bd9Sstevel@tonic-gate 	char	sd_init_state;
1057c478bd9Sstevel@tonic-gate 	mutex_t	sd_init_lock;
1067c478bd9Sstevel@tonic-gate 	cond_t	sd_init_cv;
1077c478bd9Sstevel@tonic-gate 	int	sd_door;
1087c478bd9Sstevel@tonic-gate 	int	sd_fd;
1097c478bd9Sstevel@tonic-gate } server_data_t;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate typedef	enum {
1127c478bd9Sstevel@tonic-gate 	SMEDIA_SUCCESS = 0x0,
1137c478bd9Sstevel@tonic-gate 	SMEDIA_FAILURE			/* general failure */
1147c478bd9Sstevel@tonic-gate } smedia_errno_t;
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate typedef struct door_data {
1177c478bd9Sstevel@tonic-gate 	mutex_t		dd_lock;	/* lock to protect entire structure */
1187c478bd9Sstevel@tonic-gate 	mutex_t		dd_threadlock;	/* lock to protect dd_thread field */
1197c478bd9Sstevel@tonic-gate 	sigset_t	dd_newset;	/* signal set handled by the server */
1207c478bd9Sstevel@tonic-gate 	cond_t		dd_cv;		/* client_door_descriptor cv */
1217c478bd9Sstevel@tonic-gate 	cond_t		dd_cv_bind;	/* client door descriptor bind cv */
1227c478bd9Sstevel@tonic-gate 	int32_t		dd_id;		/* for future use. To store unique id */
1235363f09cSarutz 	door_desc_t	dd_desc[2];	/* [0] : Client Door descriptor */
1245363f09cSarutz 					/* [1] : Death Door decriptor */
1257c478bd9Sstevel@tonic-gate 	thread_t	dd_thread;	/* thread bound to the client door */
1267c478bd9Sstevel@tonic-gate 	door_cred_t	dd_cred;	/* credentials of client */
1277c478bd9Sstevel@tonic-gate 	int32_t		dd_fd;		/* device file descriptor */
1287c478bd9Sstevel@tonic-gate 	void		*dd_buf;	/* mmapped buffer of client */
1297c478bd9Sstevel@tonic-gate 	int32_t		dd_buf_len;	/* size of the mmapped buffer */
1307c478bd9Sstevel@tonic-gate 	int32_t		dd_buffd;	/* mmapped file descriptor */
1317c478bd9Sstevel@tonic-gate 	int32_t		dd_sector_size;	/* sector size of the device */
1327c478bd9Sstevel@tonic-gate 	struct stat	dd_stat;	/* stat of the dd_fd */
1337c478bd9Sstevel@tonic-gate 	struct dk_cinfo	dd_dkinfo;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 	au_id_t		audit_auid;	/* auid of user writing audit record */
1367c478bd9Sstevel@tonic-gate 	uid_t		audit_uid;	/* uid of user writing audit record */
1377c478bd9Sstevel@tonic-gate 	uid_t		audit_euid;	/* euid of user writing audit record */
1387c478bd9Sstevel@tonic-gate 	gid_t		audit_gid;	/* gid of user writing audit record */
1397c478bd9Sstevel@tonic-gate 	gid_t		audit_egid;	/* euid of user writing audit record */
1407c478bd9Sstevel@tonic-gate 	pid_t		audit_pid;	/* pid of user writing audit record */
1417c478bd9Sstevel@tonic-gate 	au_tid_addr_t	audit_tid;	/* tid of user writing audit record */
1427c478bd9Sstevel@tonic-gate 	int		audit_na;	/* 0 if event is attributable */
1437c478bd9Sstevel@tonic-gate 	au_mask_t	audit_namask;	/* not attributable flags */
1447c478bd9Sstevel@tonic-gate 	au_event_t	audit_event;	/* id of event being audited */
1457c478bd9Sstevel@tonic-gate 	int 		audit_sorf;	/* success or failure of audit_event */
1467c478bd9Sstevel@tonic-gate 	char 		*audit_user;	/* text version of audit_uid */
1477c478bd9Sstevel@tonic-gate 	au_asid_t	audit_asid;	/* asid of process writing record */
1487c478bd9Sstevel@tonic-gate 	char 		*audit_path;	/* path token */
149*96093503SMarek Pospisil 	uint32_t	audit_policy;	/* kernel audit policy */
1507c478bd9Sstevel@tonic-gate 	struct auditpinfo_addr audit_ap;
1517c478bd9Sstevel@tonic-gate 	char		audit_text[128];
1527c478bd9Sstevel@tonic-gate 	char		audit_text1[128];
1537c478bd9Sstevel@tonic-gate } door_data_t;
1547c478bd9Sstevel@tonic-gate 
1555363f09cSarutz /* Symbols to simplify access of door_data_t */
1565363f09cSarutz #define	dd_cdoor	dd_desc[0]	/* Client Door descriptor */
1575363f09cSarutz #define	dd_ddoor	dd_desc[1]	/* Death Door descriptor */
1585363f09cSarutz #define	dd_cdoor_descriptor	dd_cdoor.d_data.d_desc.d_descriptor
1595363f09cSarutz #define	dd_ddoor_descriptor	dd_ddoor.d_data.d_desc.d_descriptor
1605363f09cSarutz 
1617c478bd9Sstevel@tonic-gate typedef enum {
1627c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_OPEN_FD = 0x1,
1637c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_GET_DEVICE_INFO,
1647c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_GET_MEDIUM_PROPERTY,
1657c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_GET_PROTECTION_STATUS,
1667c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_SET_PROTECTION_STATUS,
1677c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_RAW_READ,
1687c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_RAW_WRITE,
1697c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_FORMAT,
1707c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_CHECK_FORMAT_STATUS,
1717c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_EJECT,
1727c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_REASSIGN_BLOCK,
1737c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_ERROR,
1747c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_CLOSE,
1757c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_SET_SHFD,
1767c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_PING,
1777c478bd9Sstevel@tonic-gate 	SMEDIA_CNUM_USCSI_CMD
1787c478bd9Sstevel@tonic-gate } smedia_callnumber_t;
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate typedef struct {
1817c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* service call number */
1827c478bd9Sstevel@tonic-gate 	char			buf[1];	/* buffer containing input arguments */
1837c478bd9Sstevel@tonic-gate } smedia_req_t;
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate typedef struct {
1867c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* service call number */
1877c478bd9Sstevel@tonic-gate 	char			buf[1];	/* buffer containing the results */
1887c478bd9Sstevel@tonic-gate } smedia_ret_t;
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate typedef struct smedia_reqping {
1917c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_PING */
1927c478bd9Sstevel@tonic-gate } smedia_reqping_t;
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate typedef struct smedia_retping {
1957c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_PING */
1967c478bd9Sstevel@tonic-gate } smedia_retping_t;
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 	/*
1997c478bd9Sstevel@tonic-gate 	 * SMEDIA open device
2007c478bd9Sstevel@tonic-gate 	 */
2017c478bd9Sstevel@tonic-gate typedef	struct	smedia_reqopen {
2027c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_OPEN */
2037c478bd9Sstevel@tonic-gate 	int	oflag;
2047c478bd9Sstevel@tonic-gate 	int	omode;
2057c478bd9Sstevel@tonic-gate } smedia_reqopen_t;
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate typedef	struct	smedia_retopen {
2087c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_OPEN */
2097c478bd9Sstevel@tonic-gate } smedia_retopen_t;
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate typedef struct smedia_requscsi_cmd {
2127c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_USCSI_CMD */
2137c478bd9Sstevel@tonic-gate 	int32_t			uscsi_flags;
2147c478bd9Sstevel@tonic-gate 	short			uscsi_timeout;
2157c478bd9Sstevel@tonic-gate 	char			uscsi_cdb[MAX_CDB_LEN];
2167c478bd9Sstevel@tonic-gate 	int32_t			uscsi_buflen;
2177c478bd9Sstevel@tonic-gate 	uchar_t			uscsi_cdblen;
2187c478bd9Sstevel@tonic-gate 	uchar_t			uscsi_rqlen;
2197c478bd9Sstevel@tonic-gate } smedia_requscsi_cmd_t;
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate typedef struct smedia_retuscsi_cmd {
2227c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_USCSI_CMD */
2237c478bd9Sstevel@tonic-gate 	int32_t			uscsi_retval;
2247c478bd9Sstevel@tonic-gate 	int32_t			uscsi_errno;
2257c478bd9Sstevel@tonic-gate 	short			uscsi_status;
2267c478bd9Sstevel@tonic-gate 	int32_t			uscsi_resid;
2277c478bd9Sstevel@tonic-gate 	uchar_t			uscsi_rqstatus;
2287c478bd9Sstevel@tonic-gate 	uchar_t			uscsi_rqresid;
2297c478bd9Sstevel@tonic-gate 	char			uscsi_rqbuf[MAX_RQ_LEN];
2307c478bd9Sstevel@tonic-gate } smedia_retuscsi_cmd_t;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate typedef struct	smedia_reqget_device_info {
2337c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_DEVICE_INFO */
2347c478bd9Sstevel@tonic-gate } smedia_reqget_device_info_t;
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate typedef struct	smedia_reqset_shfd {
2377c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_SET_SHFD */
2387c478bd9Sstevel@tonic-gate 	int32_t	fdbuf_len;
2397c478bd9Sstevel@tonic-gate } smedia_reqset_shfd_t;
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate typedef struct	smedia_retget_device_info {
2427c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_DEVICE_INFO */
2437c478bd9Sstevel@tonic-gate 	smdevice_info_t		smdevinfo;
2447c478bd9Sstevel@tonic-gate 	uchar_t			sm_version;
2457c478bd9Sstevel@tonic-gate 	int32_t			sm_interface_type;
2467c478bd9Sstevel@tonic-gate 	char			sm_vendor_name[32];
2477c478bd9Sstevel@tonic-gate 	char			sm_product_name[32];
2487c478bd9Sstevel@tonic-gate 	char			sm_firmware_version[32];
2497c478bd9Sstevel@tonic-gate } smedia_retget_device_info_t;
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate typedef struct	smedia_reqget_medium_property {
2527c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_MEDIUM_PROPERTY */
2537c478bd9Sstevel@tonic-gate } smedia_reqget_medium_property_t;
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate typedef struct	smedia_retget_medium_property {
2567c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_MEDIUM_PROPERTY */
2577c478bd9Sstevel@tonic-gate 	smmedium_prop_t		smprop;
2587c478bd9Sstevel@tonic-gate } smedia_retget_medium_property_t;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate typedef struct	smedia_reqget_protection_status {
2617c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_PROTECTION_STATUS */
2627c478bd9Sstevel@tonic-gate } smedia_reqget_protection_status_t;
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate typedef struct	smedia_retget_protection_status {
2657c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_GET_PROTECTION_STATUS */
2667c478bd9Sstevel@tonic-gate 	smwp_state_t		prot_state;
2677c478bd9Sstevel@tonic-gate } smedia_retget_protection_status_t;
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate typedef struct	smedia_reqset_protection_status {
2707c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_SET_PROTECTION_STATUS */
2717c478bd9Sstevel@tonic-gate 	smwp_state_t		prot_state;
2727c478bd9Sstevel@tonic-gate } smedia_reqset_protection_status_t;
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate typedef struct	smedia_retset_protection_status {
2757c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_SET_PROTECTION_STATUS */
2767c478bd9Sstevel@tonic-gate } smedia_retset_protection_status_t;
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate typedef struct	smedia_reqraw_read {
2797c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_READ */
2807c478bd9Sstevel@tonic-gate 	diskaddr_t		blockno;
2817c478bd9Sstevel@tonic-gate 	int32_t			nbytes;
2827c478bd9Sstevel@tonic-gate } smedia_reqraw_read_t;
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate typedef struct	smedia_retraw_read {
2857c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_READ */
2867c478bd9Sstevel@tonic-gate 	int32_t			nbytes;	/* bytes read */
2877c478bd9Sstevel@tonic-gate 	char			buf[1];	/* buffer size is nbytes long */
2887c478bd9Sstevel@tonic-gate } smedia_retraw_read_t;
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate typedef struct	smedia_reqraw_write {
2917c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_WRITE */
2927c478bd9Sstevel@tonic-gate 	diskaddr_t		blockno;
2937c478bd9Sstevel@tonic-gate 	int32_t			nbytes;
2947c478bd9Sstevel@tonic-gate 	char			buf[1];	/* buffer size is nbytes long */
2957c478bd9Sstevel@tonic-gate } smedia_reqraw_write_t;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate typedef struct	smedia_retraw_write {
2987c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_RAW_WRITE */
2997c478bd9Sstevel@tonic-gate 	int32_t			nbytes;	/* bytes written */
3007c478bd9Sstevel@tonic-gate } smedia_retraw_write_t;
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate typedef struct	smedia_reqformat {
3037c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_FORMAT */
3047c478bd9Sstevel@tonic-gate 	uint_t			flavor;
3057c478bd9Sstevel@tonic-gate 	uint_t			mode;
3067c478bd9Sstevel@tonic-gate } smedia_reqformat_t;
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate typedef struct	smedia_retformat {
3097c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_FORMAT */
3107c478bd9Sstevel@tonic-gate } smedia_retformat_t;
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate typedef struct	smedia_reqcheck_format_status {
3137c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_CHECK_FORMAT_STATUS */
3147c478bd9Sstevel@tonic-gate } smedia_reqcheck_format_status_t;
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate typedef struct	smedia_retcheck_format_status {
3177c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_CHECK_FORMAT_STATUS */
3187c478bd9Sstevel@tonic-gate 	int			percent_complete;
3197c478bd9Sstevel@tonic-gate } smedia_retcheck_format_status_t;
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate typedef struct smedia_reqreassign_block {
3227c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_REASSIGN_BLOCK */
3237c478bd9Sstevel@tonic-gate 	diskaddr_t		blockno;
3247c478bd9Sstevel@tonic-gate } smedia_reqreassign_block_t;
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate typedef struct smedia_retreassign_block {
3277c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;	/* SMEDIA_CNUM_REASSIGN_BLOCK */
3287c478bd9Sstevel@tonic-gate } smedia_retreassign_block_t;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate typedef struct	{
3317c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	cnum;		/* SMEDIA_CNUM_ERROR */
3327c478bd9Sstevel@tonic-gate 	smedia_callnumber_t	in_cnum;	/* requested service number */
3337c478bd9Sstevel@tonic-gate 	smedia_errno_t		errnum;
3347c478bd9Sstevel@tonic-gate } smedia_reterror_t;
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate typedef union	{
3377c478bd9Sstevel@tonic-gate 	smedia_req_t			in;		/* req arguments */
3387c478bd9Sstevel@tonic-gate 	smedia_ret_t			out;		/* out results */
3397c478bd9Sstevel@tonic-gate 	smedia_reqping_t		reqping;
3407c478bd9Sstevel@tonic-gate 	smedia_retping_t		retping;
3417c478bd9Sstevel@tonic-gate 	smedia_reqopen_t		reqopen;
3427c478bd9Sstevel@tonic-gate 	smedia_retopen_t		retopen;
3437c478bd9Sstevel@tonic-gate 	smedia_reqget_device_info_t	reqget_device_info;
3447c478bd9Sstevel@tonic-gate 	smedia_retget_device_info_t	retget_device_info;
3457c478bd9Sstevel@tonic-gate 	smedia_reqget_medium_property_t	reqget_medium_property;
3467c478bd9Sstevel@tonic-gate 	smedia_retget_medium_property_t	retget_medium_property;
3477c478bd9Sstevel@tonic-gate 	smedia_reqget_protection_status_t	reqget_protection_status;
3487c478bd9Sstevel@tonic-gate 	smedia_retget_protection_status_t	retget_protection_status;
3497c478bd9Sstevel@tonic-gate 	smedia_reqset_protection_status_t	reqset_protection_status;
3507c478bd9Sstevel@tonic-gate 	smedia_retset_protection_status_t	retset_protection_status;
3517c478bd9Sstevel@tonic-gate 	smedia_reqraw_read_t		reqraw_read;
3527c478bd9Sstevel@tonic-gate 	smedia_retraw_read_t		retraw_read;
3537c478bd9Sstevel@tonic-gate 	smedia_reqraw_write_t		reqraw_write;
3547c478bd9Sstevel@tonic-gate 	smedia_retraw_write_t		retraw_write;
3557c478bd9Sstevel@tonic-gate 	smedia_reqformat_t		reqformat;
3567c478bd9Sstevel@tonic-gate 	smedia_retformat_t		retformat;
3577c478bd9Sstevel@tonic-gate 	smedia_reqcheck_format_status_t		reqcheck_format_status;
3587c478bd9Sstevel@tonic-gate 	smedia_retcheck_format_status_t		retcheck_format_status;
3597c478bd9Sstevel@tonic-gate 	smedia_reqreassign_block_t	reqreassign_block;
3607c478bd9Sstevel@tonic-gate 	smedia_retreassign_block_t	retreassign_block;
3617c478bd9Sstevel@tonic-gate 	smedia_reterror_t		reterror;
3627c478bd9Sstevel@tonic-gate 	smedia_reqset_shfd_t			reqset_shfd;
3637c478bd9Sstevel@tonic-gate 	smedia_requscsi_cmd_t		requscsi_cmd;
3647c478bd9Sstevel@tonic-gate 	smedia_retuscsi_cmd_t		retuscsi_cmd;
3657c478bd9Sstevel@tonic-gate } smedia_services_t;
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate #define	SCSI_GENERIC	1
3687c478bd9Sstevel@tonic-gate #define	SCSI_IOMEGA	2
3697c478bd9Sstevel@tonic-gate #define	SCSI_FLOPPY	3
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate /*
3727c478bd9Sstevel@tonic-gate  * Crude algorithm for calculating format timeout.
3737c478bd9Sstevel@tonic-gate  * 30min + 5min/100MB =>
3747c478bd9Sstevel@tonic-gate  * 35min for 100MB ZIP
3757c478bd9Sstevel@tonic-gate  * 42.5 min for 250MB ZIP
3767c478bd9Sstevel@tonic-gate  * 127 min for 2GB Jaz
3777c478bd9Sstevel@tonic-gate  * It is OK for now as this is just an upper limit by which the
3787c478bd9Sstevel@tonic-gate  * format should complete.
3797c478bd9Sstevel@tonic-gate  */
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate #define	FORMAT_TIMEOUT(n) (1800 + ((n)/682))
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate #define	WA_BIT	0x10	/* The word align bit for ATAPI devices */
3847c478bd9Sstevel@tonic-gate /*
3857c478bd9Sstevel@tonic-gate  * Non sense data length for catridge status page.
3867c478bd9Sstevel@tonic-gate  * Should be 63, but IDE driver panics with a non-aligned
3877c478bd9Sstevel@tonic-gate  * data transfer.
3887c478bd9Sstevel@tonic-gate  */
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate #define	ND_LENGTH 64
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate /*
3937c478bd9Sstevel@tonic-gate  * Vendor specific commands from Iomega
3947c478bd9Sstevel@tonic-gate  */
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate #define	IOMEGA_NONSENSE_CMD 	0x6
3977c478bd9Sstevel@tonic-gate #define	IOMEGA_CATRIDGE_PROTECT	0xC
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate #ifdef __cplusplus
4007c478bd9Sstevel@tonic-gate }
4017c478bd9Sstevel@tonic-gate #endif
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate #endif	/* _SMSERVER_H_ */
404