filename | src/gdrom/gdrom.h |
changeset | 143:9446fb6df0c5 |
prev | 142:2f631c3a3946 |
next | 149:d88dd2e9a190 |
author | nkeynes |
date | Wed May 03 12:52:38 2006 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Add (track) mode parameter to read sectors call Fix missing interrupt on end-of-packet read. |
view | annotate | diff | log | raw |
1 /**
2 * $Id: gdrom.h,v 1.4 2006-05-03 12:52:38 nkeynes Exp $
3 *
4 * This file defines the structures and functions used by the GD-Rom
5 * disc driver. (ie, the modules that supply a CD image to be used by the
6 * system).
7 *
8 * Copyright (c) 2005 Nathan Keynes.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 */
21 #ifndef dream_gdrom_H
22 #define dream_gdrom_H 1
24 #include "dream.h"
26 struct gdrom_toc {
27 uint32_t track[99];
28 uint32_t first, last, leadout;
29 };
31 #define GDROM_PREGAP 150 /* Sectors */
33 extern uint32_t gdrom_sector_size[];
34 #define GDROM_SECTOR_SIZE(x) gdrom_sector_size[x]
35 typedef enum {
36 GDROM_MODE1,
37 GDROM_MODE2,
38 GDROM_MODE2_XA1,
39 GDROM_MODE2_XA2,
40 GDROM_CDDA,
41 GDROM_GD,
42 GDROM_RAW
43 } gdrom_track_mode_t;
45 /* The disc register indicates the current contents of the drive. When open
46 * contains 0x06.
47 */
48 #define IDE_DISC_AUDIO 0x00
49 #define IDE_DISC_NONE 0x06
50 #define IDE_DISC_CDROM 0x20
51 #define IDE_DISC_GDROM 0x80
52 #define IDE_DISC_READY 0x01 /* ored with above */
53 #define IDE_DISC_IDLE 0x02 /* ie spun-down */
55 #define TRACK_PRE_EMPHASIS 0x10
56 #define TRACK_COPY_PERMITTED 0x20
57 #define TRACK_DATA 0x40
58 #define TRACK_FOUR_CHANNEL 0x80
60 struct gdrom_track {
61 gdrom_track_mode_t mode;
62 uint8_t flags; /* Track flags */
63 int session; /* session # containing this track */
64 uint32_t lba; /* start sector address */
65 uint32_t sector_size; /* For convenience, determined by mode */
66 uint32_t sector_count;
67 uint32_t offset; /* File offset of start of track - image files only */
68 };
71 typedef struct gdrom_disc {
72 int disc_type;
73 int track_count;
74 struct gdrom_track track[99];
75 gchar mcn[14]; /* Media catalogue number */
76 const gchar *filename; /* Image filename */
77 FILE *file; /* Stream, for image files */
78 uint32_t (*read_sectors)( struct gdrom_disc *disc,
79 uint32_t lba, uint32_t sector_count,
80 int mode, char *buf, uint32_t *length );
81 void (*close)( struct gdrom_disc *disc );
82 } *gdrom_disc_t;
84 /**
85 * Construct a new image file using the default methods.
86 */
87 gdrom_disc_t gdrom_image_new( FILE *file );
89 /**
90 * Open an image file
91 */
92 gdrom_disc_t gdrom_image_open( const gchar *filename );
93 gdrom_disc_t nrg_image_open( const gchar *filename );
95 /**
96 * Retrieve the disc table of contents, and write it into the buffer in the
97 * format expected by the DC.
98 * @return TRUE on success, FALSE on failure (eg no disc mounted)
99 */
100 gboolean gdrom_get_toc( char *buf );
102 /**
103 * Shortcut to open and mount an image file
104 */
105 gdrom_disc_t gdrom_mount_image( const gchar *filename );
107 void gdrom_mount_disc( gdrom_disc_t disc );
109 void gdrom_unmount_disc( void );
111 gboolean gdrom_is_mounted( void );
113 uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
114 int mode, char *buf, uint32_t *length );
116 #endif
.