2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _SMEDIA_H_
2N/A#define _SMEDIA_H_
2N/A
2N/A/*
2N/A * smedia.h header for libsmedia library
2N/A */
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/stat.h>
2N/A#include <sys/dkio.h>
2N/A#include <sys/vtoc.h>
2N/A#include <sys/scsi/scsi.h>
2N/A#include <fcntl.h>
2N/A#include <stdio.h>
2N/A#include <errno.h>
2N/A#include <synch.h>
2N/A
2N/Atypedef struct smdevice_info {
2N/A uchar_t sm_version;
2N/A int32_t sm_interface_type; /* Interface type */
2N/A char *sm_vendor_name; /* Vendor name */
2N/A char *sm_product_name; /* Product name */
2N/A char *sm_firmware_version; /* Firmware version */
2N/A}smdevice_info_t;
2N/A
2N/Atypedef void *smedia_handle_t;
2N/A
2N/A
2N/A#define SMDEVICE_INFO_V_1 1
2N/A
2N/A/* Interface Types */
2N/A
2N/A#define IF_SCSI 0x0
2N/A#define IF_FLOPPY 0x1
2N/A#define IF_PCMCIA 0x2
2N/A#define IF_BLOCK 0x3
2N/A
2N/A
2N/Atypedef struct smmedium_property {
2N/A int32_t sm_version;
2N/A int32_t sm_media_type; /* Medium type */
2N/A int32_t sm_blocksize; /* Medium block size in bytes */
2N/A int32_t sm_capacity; /* Medium capacity in no. of blocks */
2N/A int32_t sm_pcyl; /* No. of cylinders on the medium */
2N/A int32_t sm_nhead; /* No. of heads */
2N/A int32_t sm_nsect; /* No. of sectors per cylinder */
2N/A}smmedium_prop_t;
2N/A
2N/A#define SMMEDIA_PROP_V_1 1
2N/A
2N/A/*
2N/A * Media types not defined for DKIOCGMEDIAINFO
2N/A */
2N/A
2N/A#define SM_REMOVABLE_DISK 0x20005 /* Removable disk */
2N/A /* FIXED_DISK + REMOVABLE */
2N/A#define SM_FLOPPY 0x10002 /* Floppy media */
2N/A#define SM_SCSI_FLOPPY 0x10005 /* SCSI floppy device */
2N/A#define SM_PCMCIA_MEM 0x20006 /* PCMCIA memory card (Obsolete) */
2N/A#define SM_PCMCIA_ATA 0x20007 /* PCMCIA ata card */
2N/A#define SM_BLOCK 0x20008 /* Generic block device */
2N/A#define SM_NOT_PRESENT 0xFFFF
2N/A
2N/A
2N/A#define MAX_PASSWD_LENGTH 32
2N/A
2N/A#define PASSWD 0x1000
2N/A
2N/A#define SM_WRITE_PROTECT_DISABLE (PASSWD|0x0)
2N/A#define SM_WRITE_PROTECT_NOPASSWD (PASSWD|0x2)
2N/A#define SM_WRITE_PROTECT_PASSWD (PASSWD|0x4)
2N/A#define SM_READ_WRITE_PROTECT (PASSWD|0x8)
2N/A#define SM_TEMP_UNLOCK_MODE (PASSWD|0x10)
2N/A#define SM_STATUS_UNKNOWN (PASSWD|0xFF)
2N/A
2N/A#define SM_UNPROTECTED SM_WRITE_PROTECT_DISABLE
2N/A#define SM_WRITE_PROTECTED SM_WRITE_PROTECT_NOPASSWD
2N/A#define SM_WRITE_PROTECTED_WP SM_WRITE_PROTECT_PASSWD
2N/A#define SM_READ_WRITE_PROTECTED SM_READ_WRITE_PROTECT
2N/A
2N/A
2N/Atypedef struct smwp_state {
2N/A uchar_t sm_version;
2N/A int32_t sm_new_state;
2N/A int32_t sm_passwd_len;
2N/A char sm_passwd[MAX_PASSWD_LENGTH];
2N/A}smwp_state_t;
2N/A
2N/A#define SMWP_STATE_V_1 1
2N/A
2N/A#define FORMAT 0x2000
2N/A
2N/A#define SM_FORMAT_LONG (FORMAT|0x0001)
2N/A#define SM_FORMAT_QUICK (FORMAT|0x0002)
2N/A#define SM_FORMAT_FORCE (FORMAT|0x0003)
2N/A
2N/A/* Floppy specific options */
2N/A#define SM_FORMAT_HD (FORMAT|0x0011) /* Format high density (1.44MB) */
2N/A#define SM_FORMAT_DD (FORMAT|0x0012) /* Format Double density (720KB) */
2N/A#define SM_FORMAT_ED (FORMAT|0x0013) /* Format Extended density (2.88MB) */
2N/A#define SM_FORMAT_MD (FORMAT|0x0014) /* Format Medium density (1.2MB) */
2N/A
2N/A#define SM_FORMAT_IMMEDIATE (FORMAT|0x0021)
2N/A#define SM_FORMAT_BLOCKED (FORMAT|0x0022)
2N/A
2N/A
2N/A/* New Library interface prototypes */
2N/A
2N/Aint smedia_get_device_info(smedia_handle_t handle, smdevice_info_t *smdevinfop);
2N/Aint smedia_free_device_info(smedia_handle_t handle,
2N/A smdevice_info_t *smdevinfop);
2N/Aint smedia_get_medium_property(smedia_handle_t handle,
2N/A smmedium_prop_t *smpropp);
2N/Aint smedia_get_protection_status(smedia_handle_t handle,
2N/A smwp_state_t *wpstatep);
2N/Aint smedia_set_protection_status(smedia_handle_t handle,
2N/A smwp_state_t *wpstatep);
2N/Asize_t smedia_raw_read(smedia_handle_t handle, diskaddr_t blockno,
2N/A caddr_t buffer,
2N/A size_t nbytes);
2N/Asize_t smedia_raw_write(smedia_handle_t handle, diskaddr_t blockno,
2N/A caddr_t buffer,
2N/A size_t nbytes);
2N/Aint smedia_format(smedia_handle_t handle, uint_t flavor, uint_t mode);
2N/Aint smedia_check_format_status(smedia_handle_t handle);
2N/Aint smedia_format_track(smedia_handle_t handle, uint_t trackno, uint_t head,
2N/A uint_t density);
2N/Aint smedia_eject(smedia_handle_t handle);
2N/Aint smedia_reassign_block(smedia_handle_t handle, diskaddr_t blockno);
2N/Asmedia_handle_t smedia_get_handle(int32_t);
2N/Aint smedia_release_handle(smedia_handle_t handle);
2N/Aint smedia_uscsi_cmd(smedia_handle_t handle, struct uscsi_cmd *cmd);
2N/A
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SMEDIA_H_ */