4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 * This file contains all defined interfaces for libsm.so
35 #include <sys/types.h>
39 #include <sys/smedia.h>
40 #include "../inc/rmedia.h"
41 #include "l_defines.h"
43 extern int32_t call_function(
44 rmedia_handle_t
*handle
, void *ip
, char *func_name
);
45 extern smedia_handle_t
get_handle(int fd
);
46 extern smedia_handle_t
get_handle_from_path(const char *, int32_t, int32_t);
47 extern smedia_handle_t
get_handle_from_fd(int32_t fd
);
48 extern int32_t release_handle(rmedia_handle_t
*);
51 smedia_get_device_info(smedia_handle_t handle
, struct smdevice_info
*dev_info
)
55 ret_val
= call_function((rmedia_handle_t
*)handle
,
56 dev_info
, "_m_get_device_info");
57 DPRINTF1("1....%s\n", dev_info
->sm_product_name
);
58 dev_info
->sm_version
= SMDEVICE_INFO_V_1
;
64 smedia_free_device_info(smedia_handle_t handle
, struct smdevice_info
*dev_info
)
68 ret_val
= call_function((rmedia_handle_t
*)handle
,
69 dev_info
, "_m_free_device_info");
70 DPRINTF1("1....%s\n", dev_info
->sm_product_name
);
71 dev_info
->sm_version
= SMDEVICE_INFO_V_1
;
77 smedia_get_medium_property(smedia_handle_t handle
, smmedium_prop_t
*med_info
)
81 ret_val
= call_function((rmedia_handle_t
*)handle
,
82 med_info
, "_m_get_media_info");
83 med_info
->sm_version
= SMMEDIA_PROP_V_1
;
89 smedia_set_protection_status(smedia_handle_t handle
, struct smwp_state
*wp
)
93 if (wp
->sm_version
!= SMWP_STATE_V_1
) {
97 ret_val
= call_function((rmedia_handle_t
*)handle
,
98 wp
, "_m_set_media_status");
103 smedia_get_protection_status(smedia_handle_t handle
, struct smwp_state
*wp
)
107 ret_val
= call_function((rmedia_handle_t
*)handle
,
108 wp
, "_m_get_media_status");
113 smedia_format(smedia_handle_t handle
, uint32_t flavor
, uint32_t mode
)
115 struct format_flags ffl
;
120 ret_val
= call_function((rmedia_handle_t
*)handle
,
121 &ffl
, "_m_media_format");
126 smedia_raw_read(smedia_handle_t handle
,
127 diskaddr_t offset
, caddr_t buffer
, size_t size
)
130 struct raw_params r_p
;
133 r_p
.offset
= (uint32_t)offset
;
137 ret_val
= call_function((rmedia_handle_t
*)handle
, &r_p
, "_m_raw_read");
142 smedia_raw_write(smedia_handle_t handle
,
143 diskaddr_t offset
, caddr_t buffer
, size_t size
)
146 struct raw_params r_p
;
149 r_p
.offset
= (uint32_t)offset
;
151 r_p
.size
= (uint32_t)size
;
153 ret_val
= call_function((rmedia_handle_t
*)handle
,
154 &r_p
, "_m_raw_write");
160 smedia_check_format_status(smedia_handle_t handle
)
164 ret_val
= call_function((rmedia_handle_t
*)handle
,
165 NULL
, "_m_check_format_status");
171 smedia_reassign_block(smedia_handle_t handle
, diskaddr_t block
)
175 ret_val
= call_function((rmedia_handle_t
*)handle
,
176 &block
, "_m_reassign_block");
181 smedia_eject(smedia_handle_t handle
)
185 ret_val
= call_function((rmedia_handle_t
*)handle
, NULL
, "_m_eject");
190 smedia_format_track(smedia_handle_t handle
, uint32_t trackno
, uint32_t head
,
194 struct format_track ft
;
196 ft
.track_no
= (int32_t)trackno
;
197 ft
.head
= (int32_t)head
;
199 ret_val
= call_function((rmedia_handle_t
*)handle
,
200 &ft
, "_m_media_format_track");
205 smedia_get_handle(int32_t fd
)
207 return (get_handle_from_fd(fd
));
211 smedia_release_handle(smedia_handle_t handle
)
213 return (release_handle((rmedia_handle_t
*)handle
));
217 smedia_uscsi_cmd(smedia_handle_t handle
, struct uscsi_cmd
*cmd
)
221 ret_val
= call_function((rmedia_handle_t
*)handle
,
222 cmd
, "_m_uscsi_cmd");