KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
cdrom.h File Reference

CD access to the GD-ROM drive. More...

#include <sys/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Data Structures

struct  CDROM_TOC
 TOC structure returned by the BIOS. More...
 

Macros

#define CMD_CHECK_LICENSE   2
 Check license.
 
#define CMD_REQ_SPI_CMD   4
 Request to Sega Packet Interface.
 
#define CMD_PIOREAD   16
 Read via PIO.
 
#define CMD_DMAREAD   17
 Read via DMA.
 
#define CMD_GETTOC   18
 Read TOC.
 
#define CMD_GETTOC2   19
 Read TOC.
 
#define CMD_PLAY   20
 Play track.
 
#define CMD_PLAY2   21
 Play sectors.
 
#define CMD_PAUSE   22
 Pause playback.
 
#define CMD_RELEASE   23
 Resume from pause.
 
#define CMD_INIT   24
 Initialize the drive.
 
#define CMD_DMA_ABORT   25
 Abort DMA transfer.
 
#define CMD_OPEN_TRAY   26
 Open CD tray (on DevBox?)
 
#define CMD_SEEK   27
 Seek to a new position.
 
#define CMD_DMAREAD_STREAM   28
 Stream DMA until end/abort.
 
#define CMD_NOP   29
 No operation.
 
#define CMD_REQ_MODE   30
 Request mode.
 
#define CMD_SET_MODE   31
 Setup mode.
 
#define CMD_SCAN_CD   32
 Scan CD.
 
#define CMD_STOP   33
 Stop the disc from spinning.
 
#define CMD_GETSCD   34
 Get subcode data.
 
#define CMD_GETSES   35
 Get session.
 
#define CMD_REQ_STAT   36
 Request stat.
 
#define CMD_PIOREAD_STREAM   37
 Stream PIO until end/abort.
 
#define CMD_DMAREAD_STREAM_EX   38
 Stream DMA transfer.
 
#define CMD_PIOREAD_STREAM_EX   39
 Stream PIO transfer.
 
#define CMD_GET_VERS   40
 Get syscall driver version.
 
#define CMD_MAX   47
 Max of GD syscall commands.
 
#define ERR_OK   0
 No error.
 
#define ERR_NO_DISC   1
 No disc in drive.
 
#define ERR_DISC_CHG   2
 Disc changed, but not reinitted yet.
 
#define ERR_SYS   3
 System error.
 
#define ERR_ABORTED   4
 Command aborted.
 
#define ERR_NO_ACTIVE   5
 System inactive?
 
#define ERR_TIMEOUT   6
 Aborted due to timeout.
 
#define FAILED   -1
 Command failed.
 
#define NO_ACTIVE   0
 System inactive?
 
#define PROCESSING   1
 Processing command.
 
#define COMPLETED   2
 Command completed successfully.
 
#define STREAMING   3
 Stream type command is in progress.
 
#define BUSY   4
 GD syscalls is busy.
 
#define ATA_STAT_INTERNAL   0x00
 
#define ATA_STAT_IRQ   0x01
 
#define ATA_STAT_DRQ_0   0x02
 
#define ATA_STAT_DRQ_1   0x03
 
#define ATA_STAT_BUSY   0x04
 
#define CDDA_TRACKS   1
 Play by track number.
 
#define CDDA_SECTORS   2
 Play by sector number.
 
#define CDROM_READ_WHOLE_SECTOR   0x1000
 Read the whole sector.
 
#define CDROM_READ_DATA_AREA   0x2000
 Read the data area.
 
#define CD_SUB_Q_ALL   0
 Read all Subcode Data.
 
#define CD_SUB_Q_CHANNEL   1
 Read Q Channel Subcode Data.
 
#define CD_SUB_MEDIA_CATALOG   2
 Read the Media Catalog Subcode Data.
 
#define CD_SUB_TRACK_ISRC   3
 Read the ISRC Subcode Data.
 
#define CD_SUB_RESERVED   4
 Reserved.
 
#define CD_SUB_AUDIO_STATUS_INVALID   0x00
 
#define CD_SUB_AUDIO_STATUS_PLAYING   0x11
 
#define CD_SUB_AUDIO_STATUS_PAUSED   0x12
 
#define CD_SUB_AUDIO_STATUS_ENDED   0x13
 
#define CD_SUB_AUDIO_STATUS_ERROR   0x14
 
#define CD_SUB_AUDIO_STATUS_NO_INFO   0x15
 
#define CDROM_READ_PIO   0
 Read sector(s) in PIO mode.
 
#define CDROM_READ_DMA   1
 Read sector(s) in DMA mode.
 
#define CD_STATUS_READ_FAIL   -1
 Can't read status.
 
#define CD_STATUS_BUSY   0
 Drive is busy.
 
#define CD_STATUS_PAUSED   1
 Disc is paused.
 
#define CD_STATUS_STANDBY   2
 Drive is in standby.
 
#define CD_STATUS_PLAYING   3
 Drive is currently playing.
 
#define CD_STATUS_SEEKING   4
 Drive is currently seeking.
 
#define CD_STATUS_SCANNING   5
 Drive is scanning.
 
#define CD_STATUS_OPEN   6
 Disc tray is open.
 
#define CD_STATUS_NO_DISC   7
 No disc inserted.
 
#define CD_STATUS_RETRY   8
 Retry is needed.
 
#define CD_STATUS_ERROR   9
 System error.
 
#define CD_STATUS_FATAL   12
 Need reset syscalls.
 
#define CD_CDDA   0x00
 Audio CD (Red book) or no disc.
 
#define CD_CDROM   0x10
 CD-ROM or CD-R (Yellow book)
 
#define CD_CDROM_XA   0x20
 CD-ROM XA (Yellow book extension)
 
#define CD_CDI   0x30
 CD-i (Green book)
 
#define CD_GDROM   0x80
 GD-ROM.
 
#define CD_FAIL   0xf0
 Need reset syscalls.
 
#define TOC_LBA(n)   ((n) & 0x00ffffff)
 Get the FAD address of a TOC entry.
 
#define TOC_ADR(n)   ( ((n) & 0x0f000000) >> 24 )
 Get the address of a TOC entry.
 
#define TOC_CTRL(n)   ( ((n) & 0xf0000000) >> 28 )
 Get the control data of a TOC entry.
 
#define TOC_TRACK(n)   ( ((n) & 0x00ff0000) >> 16 )
 Get the track number of a TOC entry.
 

Functions

int cdrom_set_sector_size (int size)
 Set the sector size for read sectors.
 
int cdrom_exec_cmd (int cmd, void *param)
 Execute a CD-ROM command.
 
int cdrom_exec_cmd_timed (int cmd, void *param, int timeout)
 Execute a CD-ROM command with timeout.
 
int cdrom_get_status (int *status, int *disc_type)
 Get the status of the GD-ROM drive.
 
int cdrom_change_dataype (int sector_part, int cdxa, int sector_size) __depr("Use cdrom_change_datatype instead.")
 Change the datatype of disc.
 
int cdrom_change_datatype (int sector_part, int cdxa, int sector_size)
 Change the datatype of disc.
 
int cdrom_reinit (void)
 Re-initialize the GD-ROM drive.
 
int cdrom_reinit_ex (int sector_part, int cdxa, int sector_size)
 Re-initialize the GD-ROM drive with custom parameters.
 
int cdrom_read_toc (CDROM_TOC *toc_buffer, int session)
 Read the table of contents from the disc.
 
int cdrom_read_sectors_ex (void *buffer, int sector, int cnt, int mode)
 Read one or more sector from a CD-ROM.
 
int cdrom_read_sectors (void *buffer, int sector, int cnt)
 Read one or more sector from a CD-ROM in PIO mode.
 
int cdrom_get_subcode (void *buffer, int buflen, int which)
 Read subcode data from the most recently read sectors.
 
uint32 cdrom_locate_data_track (CDROM_TOC *toc)
 Locate the sector of the data track.
 
int cdrom_cdda_play (uint32 start, uint32 end, uint32 loops, int mode)
 Play CDDA audio tracks or sectors.
 
int cdrom_cdda_pause (void)
 Pause CDDA audio playback.
 
int cdrom_cdda_resume (void)
 Resume CDDA audio playback after a pause.
 
int cdrom_spin_down (void)
 Spin down the CD.
 
void cdrom_init (void)
 Initialize the GD-ROM for reading CDs.
 
void cdrom_shutdown (void)
 Shutdown the CD reading system.
 

Detailed Description

CD access to the GD-ROM drive.

This file contains the interface to the Dreamcast's GD-ROM drive. It is simply called cdrom.h and cdrom.c because, by design, you cannot directly use this code to read the high-density area of GD-ROMs. This is the way it always has been, and always will be.

The way things are set up, as long as you're using fs_iso9660 to access the CD, it will automatically detect and react to disc changes for you.

This file only facilitates reading raw sectors and doing other fairly low- level things with CDs. If you're looking for higher-level stuff, like normal file reading, consult with the stuff for the fs and for fs_iso9660.

Author
Megan Potter
Ruslan Rostovtsev
See also
kos/fs.h
dc/fs_iso9660.h