xref: /titanic_52/usr/src/cmd/hal/utils/cdutils.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
1 /***************************************************************************
2  *
3  * cdutils.h : definitions for CD/DVD utilities
4  *
5  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
6  * Use is subject to license terms.
7  *
8  * Licensed under the Academic Free License version 2.1
9  *
10  **************************************************************************/
11 
12 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13 
14 #ifndef CDUTILS_H
15 #define CDUTILS_H
16 
17 #include <sys/types.h>
18 #include <sys/dkio.h>
19 #include <sys/cdio.h>
20 #include <sys/scsi/impl/uscsi.h>
21 
22 enum {
23 	CDUTIL_WALK_CONTINUE,
24 	CDUTIL_WALK_STOP
25 };
26 
27 typedef struct intlist {
28 	int	val;
29 	struct intlist *next;
30 } intlist_t;
31 
32 typedef struct disc_info {
33 	int	disc_status;
34 	int	erasable;
35 	uint_t	capacity;
36 } disc_info_t;
37 
38 #define	min(a, b)	((a) < (b) ? (a) : (b))
39 #define	max(a, b)	((a) > (b) ? (a) : (b))
40 
41 void		uscsi_cmd_init(struct uscsi_cmd *scmd, char *cdb, int cdblen);
42 int		uscsi(int fd, struct uscsi_cmd *scmd);
43 int		mode_sense(int fd, uchar_t pc, int dbd, int page_len,
44 		uchar_t *buffer);
45 int		get_mode_page(int fd, int page_no, int pc, int buf_len,
46 		uchar_t *buffer, int *plen);
47 int		get_configuration(int fd, uint16_t feature, int bufsize,
48 		uchar_t *buf);
49 boolean_t	get_current_profile(int fd, int *profile);
50 void		walk_profiles(int fd, int (*f)(void *, int, boolean_t), void *);
51 void		get_read_write_speeds(int fd, int *read_speed, int *write_speed,
52 		intlist_t **wspeeds, int *n_wspeeds, intlist_t **wspeeds_mem);
53 boolean_t	get_disc_info(int fd, disc_info_t *);
54 boolean_t	read_format_capacity(int fd, uint64_t *capacity);
55 boolean_t	get_media_info(int fd, struct dk_minfo *minfop);
56 boolean_t	get_disc_capacity_for_profile(int fd, int profile,
57 		uint64_t *capacity);
58 boolean_t	read_toc(int fd, int format, int trackno, int buflen,
59 		uchar_t *buf);
60 
61 #endif /* CDUTILS_H */
62