xref: /illumos-gate/usr/src/cmd/hal/utils/cdutils.h (revision 2a8bcb4e)
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 #ifndef CDUTILS_H
13 #define CDUTILS_H
14 
15 #include <sys/types.h>
16 #include <sys/dkio.h>
17 #include <sys/cdio.h>
18 #include <sys/scsi/impl/uscsi.h>
19 
20 enum {
21 	CDUTIL_WALK_CONTINUE,
22 	CDUTIL_WALK_STOP
23 };
24 
25 typedef struct intlist {
26 	int	val;
27 	struct intlist *next;
28 } intlist_t;
29 
30 typedef struct disc_info {
31 	int	disc_status;
32 	int	erasable;
33 	uint_t	capacity;
34 } disc_info_t;
35 
36 #define	min(a, b)	((a) < (b) ? (a) : (b))
37 #define	max(a, b)	((a) > (b) ? (a) : (b))
38 
39 void		uscsi_cmd_init(struct uscsi_cmd *scmd, char *cdb, int cdblen);
40 int		uscsi(int fd, struct uscsi_cmd *scmd);
41 int		mode_sense(int fd, uchar_t pc, int dbd, int page_len,
42 		uchar_t *buffer);
43 int		get_mode_page(int fd, int page_no, int pc, int buf_len,
44 		uchar_t *buffer, int *plen);
45 int		get_configuration(int fd, uint16_t feature, int bufsize,
46 		uchar_t *buf);
47 boolean_t	get_current_profile(int fd, int *profile);
48 void		walk_profiles(int fd, int (*f)(void *, int, boolean_t), void *);
49 void		get_read_write_speeds(int fd, int *read_speed, int *write_speed,
50 		intlist_t **wspeeds, int *n_wspeeds, intlist_t **wspeeds_mem);
51 boolean_t	get_disc_info(int fd, disc_info_t *);
52 boolean_t	read_format_capacity(int fd, uint64_t *capacity);
53 boolean_t	get_media_info(int fd, struct dk_minfo *minfop);
54 boolean_t	get_disc_capacity_for_profile(int fd, int profile,
55 		uint64_t *capacity);
56 boolean_t	read_toc(int fd, int format, int trackno, int buflen,
57 		uchar_t *buf);
58 
59 #endif /* CDUTILS_H */
60