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