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, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * 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 1999-2002 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * l_generic.c :
2N/A * This file contains all defined interfaces for libsm.so
2N/A */
2N/A
2N/A
2N/A#include <sys/types.h>
2N/A#include <sys/stat.h>
2N/A#include <fcntl.h>
2N/A#include <stdlib.h>
2N/A#include <sys/smedia.h>
2N/A#include "../inc/rmedia.h"
2N/A#include "l_defines.h"
2N/A
2N/Aextern int32_t call_function(
2N/A rmedia_handle_t *handle, void *ip, char *func_name);
2N/Aextern smedia_handle_t get_handle(int fd);
2N/Aextern smedia_handle_t get_handle_from_path(const char *, int32_t, int32_t);
2N/Aextern smedia_handle_t get_handle_from_fd(int32_t fd);
2N/Aextern int32_t release_handle(rmedia_handle_t *);
2N/A
2N/Aint32_t
2N/Asmedia_get_device_info(smedia_handle_t handle, struct smdevice_info *dev_info)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A dev_info, "_m_get_device_info");
2N/A DPRINTF1("1....%s\n", dev_info->sm_product_name);
2N/A dev_info->sm_version = SMDEVICE_INFO_V_1;
2N/A
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_free_device_info(smedia_handle_t handle, struct smdevice_info *dev_info)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A dev_info, "_m_free_device_info");
2N/A DPRINTF1("1....%s\n", dev_info->sm_product_name);
2N/A dev_info->sm_version = SMDEVICE_INFO_V_1;
2N/A
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_get_medium_property(smedia_handle_t handle, smmedium_prop_t *med_info)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A med_info, "_m_get_media_info");
2N/A med_info->sm_version = SMMEDIA_PROP_V_1;
2N/A
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_set_protection_status(smedia_handle_t handle, struct smwp_state *wp)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A if (wp->sm_version != SMWP_STATE_V_1) {
2N/A errno = ENOTSUP;
2N/A return (-1);
2N/A }
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A wp, "_m_set_media_status");
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_get_protection_status(smedia_handle_t handle, struct smwp_state *wp)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A wp, "_m_get_media_status");
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_format(smedia_handle_t handle, uint32_t flavor, uint32_t mode)
2N/A{
2N/A struct format_flags ffl;
2N/A int32_t ret_val;
2N/A
2N/A ffl.flavor = flavor;
2N/A ffl.mode = mode;
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A &ffl, "_m_media_format");
2N/A return (ret_val);
2N/A}
2N/A
2N/Asize_t
2N/Asmedia_raw_read(smedia_handle_t handle,
2N/A diskaddr_t offset, caddr_t buffer, size_t size)
2N/A{
2N/A
2N/A struct raw_params r_p;
2N/A int32_t ret_val;
2N/A
2N/A r_p.offset = (uint32_t)offset;
2N/A r_p.buffer = buffer;
2N/A r_p.size = size;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle, &r_p, "_m_raw_read");
2N/A return (ret_val);
2N/A}
2N/A
2N/Asize_t
2N/Asmedia_raw_write(smedia_handle_t handle,
2N/A diskaddr_t offset, caddr_t buffer, size_t size)
2N/A{
2N/A
2N/A struct raw_params r_p;
2N/A int32_t ret_val;
2N/A
2N/A r_p.offset = (uint32_t)offset;
2N/A r_p.buffer = buffer;
2N/A r_p.size = (uint32_t)size;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A &r_p, "_m_raw_write");
2N/A
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_check_format_status(smedia_handle_t handle)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A NULL, "_m_check_format_status");
2N/A
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_reassign_block(smedia_handle_t handle, diskaddr_t block)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A &block, "_m_reassign_block");
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_eject(smedia_handle_t handle)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle, NULL, "_m_eject");
2N/A return (ret_val);
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_format_track(smedia_handle_t handle, uint32_t trackno, uint32_t head,
2N/A uint32_t density)
2N/A{
2N/A int32_t ret_val;
2N/A struct format_track ft;
2N/A
2N/A ft.track_no = (int32_t)trackno;
2N/A ft.head = (int32_t)head;
2N/A ft.flag = density;
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A &ft, "_m_media_format_track");
2N/A return (ret_val);
2N/A}
2N/A
2N/Asmedia_handle_t
2N/Asmedia_get_handle(int32_t fd)
2N/A{
2N/A return (get_handle_from_fd(fd));
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_release_handle(smedia_handle_t handle)
2N/A{
2N/A return (release_handle((rmedia_handle_t *)handle));
2N/A}
2N/A
2N/Aint32_t
2N/Asmedia_uscsi_cmd(smedia_handle_t handle, struct uscsi_cmd *cmd)
2N/A{
2N/A int32_t ret_val;
2N/A
2N/A ret_val = call_function((rmedia_handle_t *)handle,
2N/A cmd, "_m_uscsi_cmd");
2N/A return (ret_val);
2N/A}