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 <kos/cdefs.h>
#include <stdint.h>
#include <stdbool.h>
#include <dc/syscalls.h>
#include <kos/regfield.h>

Go to the source code of this file.

Macros

#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 CDDA_TRACKS   1
 Play by track number.
 
#define CDDA_SECTORS   2
 Play by sector number.
 
#define CDROM_TOC   __depr("Use the type cd_toc_t rather than CDROM_TOC.") cd_toc_t
 
#define TOC_LBA(n)
 Get the FAD address of a TOC entry.
 
#define TOC_ADR(n)
 Get the address of a TOC entry.
 
#define TOC_CTRL(n)
 Get the control data of a TOC entry.
 
#define TOC_TRACK(n)
 Get the track number of a TOC entry.
 

Typedefs

typedef void(* cdrom_stream_callback_t) (void *data)
 CD-ROM streams callback.
 

Functions

int cdrom_set_sector_size (int size)
 Set the sector size for read sectors.
 
int cdrom_exec_cmd (cd_cmd_code_t cmd, void *param)
 Execute a CD-ROM command.
 
int cdrom_exec_cmd_timed (cd_cmd_code_t cmd, void *param, uint32_t timeout)
 Execute a CD-ROM command with timeout.
 
int cdrom_abort_cmd (uint32_t timeout, bool abort_dma)
 Abort 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_datatype (cd_read_sec_part_t sector_part, int track_type, int sector_size)
 Change the datatype of disc.
 
int cdrom_reinit (void)
 Re-initialize the GD-ROM drive.
 
int cdrom_reinit_ex (cd_read_sec_part_t sector_part, int cdxa, int sector_size)
 Re-initialize the GD-ROM drive with custom parameters.
 
int cdrom_read_toc (cd_toc_t *toc_buffer, bool high_density)
 Read the table of contents from the disc.
 
int cdrom_read_sectors_ex (void *buffer, uint32_t sector, size_t cnt, bool dma)
 Read one or more sector from a CD-ROM.
 
int cdrom_read_sectors (void *buffer, uint32_t sector, size_t cnt)
 Read one or more sector from a CD-ROM in PIO mode.
 
int cdrom_stream_start (int sector, int cnt, bool dma)
 Start streaming from a CD-ROM.
 
int cdrom_stream_stop (bool abort_dma)
 Stop streaming from a CD-ROM.
 
int cdrom_stream_request (void *buffer, size_t size, bool block)
 Request stream transfer.
 
int cdrom_stream_progress (size_t *size)
 Check requested stream transfer.
 
void cdrom_stream_set_callback (cdrom_stream_callback_t callback, void *param)
 Setting up a callback for transfers.
 
int cdrom_get_subcode (void *buffer, size_t buflen, cd_sub_type_t which)
 Read subcode data from the most recently read sectors.
 
uint32_t cdrom_locate_data_track (cd_toc_t *toc)
 Locate the sector of the data track.
 
int cdrom_cdda_play (uint32_t start, uint32_t end, uint32_t 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.
 

Variables

static const uint8_t CMD_CHECK_LICENSE = CD_CMD_CHECK_LICENSE
 
static const uint8_t CMD_REQ_SPI_CMD = CD_CMD_REQ_SPI_CMD
 
static const uint8_t CMD_PIOREAD = CD_CMD_PIOREAD
 
static const uint8_t CMD_DMAREAD = CD_CMD_DMAREAD
 
static const uint8_t CMD_GETTOC = CD_CMD_GETTOC
 
static const uint8_t CMD_GETTOC2 = CD_CMD_GETTOC2
 
static const uint8_t CMD_PLAY = CD_CMD_PLAY_TRACKS
 
static const uint8_t CMD_PLAY2 = CD_CMD_PLAY_SECTORS
 
static const uint8_t CMD_PAUSE = CD_CMD_PAUSE
 
static const uint8_t CMD_RELEASE = CD_CMD_RELEASE
 
static const uint8_t CMD_INIT = CD_CMD_INIT
 
static const uint8_t CMD_DMA_ABORT = CD_CMD_DMA_ABORT
 
static const uint8_t CMD_OPEN_TRAY = CD_CMD_OPEN_TRAY
 
static const uint8_t CMD_SEEK = CD_CMD_SEEK
 
static const uint8_t CMD_DMAREAD_STREAM = CD_CMD_DMAREAD_STREAM
 
static const uint8_t CMD_NOP = CD_CMD_NOP
 
static const uint8_t CMD_REQ_MODE = CD_CMD_REQ_MODE
 
static const uint8_t CMD_SET_MODE = CD_CMD_SET_MODE
 
static const uint8_t CMD_SCAN_CD = CD_CMD_SCAN_CD
 
static const uint8_t CMD_STOP = CD_CMD_STOP
 
static const uint8_t CMD_GETSCD = CD_CMD_GETSCD
 
static const uint8_t CMD_GETSES = CD_CMD_GETSES
 
static const uint8_t CMD_REQ_STAT = CD_CMD_REQ_STAT
 
static const uint8_t CMD_PIOREAD_STREAM = CD_CMD_PIOREAD_STREAM
 
static const uint8_t CMD_DMAREAD_STREAM_EX = CD_CMD_DMAREAD_STREAM_EX
 
static const uint8_t CMD_PIOREAD_STREAM_EX = CD_CMD_PIOREAD_STREAM_EX
 
static const uint8_t CMD_GET_VERS = CD_CMD_GET_VERS
 
static const uint8_t CMD_MAX = CD_CMD_MAX
 
static const uint8_t FAILED = CD_CMD_FAILED
 
static const uint8_t NO_ACTIVE = CD_CMD_NOT_FOUND
 
static const uint8_t PROCESSING = CD_CMD_PROCESSING
 
static const uint8_t COMPLETED = CD_CMD_COMPLETED
 
static const uint8_t STREAMING = CD_CMD_STREAMING
 
static const uint8_t BUSY = CD_CMD_BUSY
 
static const bool CDROM_READ_PIO = false
 
static const bool CDROM_READ_DMA = true
 

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.

If you're looking for even lower level things with CDs, see the gdrom related syscalls or g1ata.

Author
Megan Potter
Donald Haase
Ruslan Rostovtsev
See also
kos/fs.h
dc/fs_iso9660.h
dc/syscalls.h
dc/g1ata.h

Macro Definition Documentation

◆ CDROM_TOC

#define CDROM_TOC   __depr("Use the type cd_toc_t rather than CDROM_TOC.") cd_toc_t

Typedef Documentation

◆ cdrom_stream_callback_t

typedef void(* cdrom_stream_callback_t) (void *data)

CD-ROM streams callback.

Variable Documentation

◆ BUSY

const uint8_t BUSY = CD_CMD_BUSY
static

◆ CDROM_READ_DMA

const bool CDROM_READ_DMA = true
static

◆ CDROM_READ_PIO

const bool CDROM_READ_PIO = false
static

◆ CMD_CHECK_LICENSE

const uint8_t CMD_CHECK_LICENSE = CD_CMD_CHECK_LICENSE
static

◆ CMD_DMA_ABORT

const uint8_t CMD_DMA_ABORT = CD_CMD_DMA_ABORT
static

◆ CMD_DMAREAD

const uint8_t CMD_DMAREAD = CD_CMD_DMAREAD
static

◆ CMD_DMAREAD_STREAM

const uint8_t CMD_DMAREAD_STREAM = CD_CMD_DMAREAD_STREAM
static

◆ CMD_DMAREAD_STREAM_EX

const uint8_t CMD_DMAREAD_STREAM_EX = CD_CMD_DMAREAD_STREAM_EX
static

◆ CMD_GET_VERS

const uint8_t CMD_GET_VERS = CD_CMD_GET_VERS
static

◆ CMD_GETSCD

const uint8_t CMD_GETSCD = CD_CMD_GETSCD
static

◆ CMD_GETSES

const uint8_t CMD_GETSES = CD_CMD_GETSES
static

◆ CMD_GETTOC

const uint8_t CMD_GETTOC = CD_CMD_GETTOC
static

◆ CMD_GETTOC2

const uint8_t CMD_GETTOC2 = CD_CMD_GETTOC2
static

◆ CMD_INIT

const uint8_t CMD_INIT = CD_CMD_INIT
static

◆ CMD_MAX

const uint8_t CMD_MAX = CD_CMD_MAX
static

◆ CMD_NOP

const uint8_t CMD_NOP = CD_CMD_NOP
static

◆ CMD_OPEN_TRAY

const uint8_t CMD_OPEN_TRAY = CD_CMD_OPEN_TRAY
static

◆ CMD_PAUSE

const uint8_t CMD_PAUSE = CD_CMD_PAUSE
static

◆ CMD_PIOREAD

const uint8_t CMD_PIOREAD = CD_CMD_PIOREAD
static

◆ CMD_PIOREAD_STREAM

const uint8_t CMD_PIOREAD_STREAM = CD_CMD_PIOREAD_STREAM
static

◆ CMD_PIOREAD_STREAM_EX

const uint8_t CMD_PIOREAD_STREAM_EX = CD_CMD_PIOREAD_STREAM_EX
static

◆ CMD_PLAY

const uint8_t CMD_PLAY = CD_CMD_PLAY_TRACKS
static

◆ CMD_PLAY2

const uint8_t CMD_PLAY2 = CD_CMD_PLAY_SECTORS
static

◆ CMD_RELEASE

const uint8_t CMD_RELEASE = CD_CMD_RELEASE
static

◆ CMD_REQ_MODE

const uint8_t CMD_REQ_MODE = CD_CMD_REQ_MODE
static

◆ CMD_REQ_SPI_CMD

const uint8_t CMD_REQ_SPI_CMD = CD_CMD_REQ_SPI_CMD
static

◆ CMD_REQ_STAT

const uint8_t CMD_REQ_STAT = CD_CMD_REQ_STAT
static

◆ CMD_SCAN_CD

const uint8_t CMD_SCAN_CD = CD_CMD_SCAN_CD
static

◆ CMD_SEEK

const uint8_t CMD_SEEK = CD_CMD_SEEK
static

◆ CMD_SET_MODE

const uint8_t CMD_SET_MODE = CD_CMD_SET_MODE
static

◆ CMD_STOP

const uint8_t CMD_STOP = CD_CMD_STOP
static

◆ COMPLETED

const uint8_t COMPLETED = CD_CMD_COMPLETED
static

◆ FAILED

const uint8_t FAILED = CD_CMD_FAILED
static

◆ NO_ACTIVE

const uint8_t NO_ACTIVE = CD_CMD_NOT_FOUND
static

◆ PROCESSING

const uint8_t PROCESSING = CD_CMD_PROCESSING
static

◆ STREAMING

const uint8_t STREAMING = CD_CMD_STREAMING
static