xref: /onnv-gate/usr/src/cmd/hal/utils/cdutils.h (revision 2916:ba92c662e4ef)
12912Sartem /***************************************************************************
22912Sartem  *
32912Sartem  * cdutils.h : definitions for CD/DVD utilities
42912Sartem  *
52912Sartem  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
62912Sartem  * Use is subject to license terms.
72912Sartem  *
82912Sartem  * Licensed under the Academic Free License version 2.1
92912Sartem  *
102912Sartem  **************************************************************************/
112912Sartem 
12*2916Sartem #pragma ident	"%Z%%M%	%I%	%E% SMI"
132912Sartem 
142912Sartem #ifndef CDUTILS_H
152912Sartem #define CDUTILS_H
162912Sartem 
172912Sartem #include <sys/types.h>
182912Sartem #include <sys/dkio.h>
192912Sartem #include <sys/cdio.h>
202912Sartem #include <sys/scsi/impl/uscsi.h>
212912Sartem 
222912Sartem enum {
232912Sartem 	CDUTIL_WALK_CONTINUE,
242912Sartem 	CDUTIL_WALK_STOP
252912Sartem };
262912Sartem 
272912Sartem typedef struct intlist {
282912Sartem 	int	val;
292912Sartem 	struct intlist *next;
302912Sartem } intlist_t;
312912Sartem 
322912Sartem typedef struct disc_info {
332912Sartem 	int	disc_status;
342912Sartem 	int	erasable;
352912Sartem 	uint_t	capacity;
362912Sartem } disc_info_t;
372912Sartem 
382912Sartem #define	min(a, b)	((a) < (b) ? (a) : (b))
392912Sartem #define	max(a, b)	((a) > (b) ? (a) : (b))
402912Sartem 
412912Sartem void		uscsi_cmd_init(struct uscsi_cmd *scmd, char *cdb, int cdblen);
422912Sartem int		uscsi(int fd, struct uscsi_cmd *scmd);
432912Sartem int		mode_sense(int fd, uchar_t pc, int dbd, int page_len,
442912Sartem 		uchar_t *buffer);
452912Sartem int		get_mode_page(int fd, int page_no, int pc, int buf_len,
462912Sartem 		uchar_t *buffer, int *plen);
472912Sartem int		get_configuration(int fd, uint16_t feature, int bufsize,
482912Sartem 		uchar_t *buf);
492912Sartem boolean_t	get_current_profile(int fd, int *profile);
502912Sartem void		walk_profiles(int fd, int (*f)(void *, int, boolean_t), void *);
512912Sartem void		get_read_write_speeds(int fd, int *read_speed, int *write_speed,
522912Sartem 		intlist_t **wspeeds, int *n_wspeeds, intlist_t **wspeeds_mem);
532912Sartem boolean_t	get_disc_info(int fd, disc_info_t *);
542912Sartem boolean_t	read_format_capacity(int fd, uint64_t *capacity);
552912Sartem boolean_t	get_media_info(int fd, struct dk_minfo *minfop);
562912Sartem boolean_t	get_disc_capacity_for_profile(int fd, int profile,
572912Sartem 		uint64_t *capacity);
582912Sartem boolean_t	read_toc(int fd, int format, int trackno, int buflen,
592912Sartem 		uchar_t *buf);
602912Sartem 
612912Sartem #endif /* CDUTILS_H */
62