KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
GDROM System Calls

GDROM Syscalls and Data Types More...

Data Structures

struct  cd_check_drive_status_t
 Status filled by Check Drive syscall. More...
 
struct  cd_read_params_t
 Params for READ commands. More...
 
struct  cd_toc_t
 TOC structure returned by the BIOS. More...
 
struct  cd_cmd_toc_params_t
 Params for GETTOC commands. More...
 
struct  cd_cmd_play_params_t
 Params for PLAY command. More...
 
struct  cd_cmd_getscd_params_t
 Params for GETSCD command. More...
 
struct  cd_cmd_chk_status_t
 GDROM Command Extra Status. More...
 
struct  cd_sec_mode_params_t
 Sector mode params. More...
 
struct  cd_transfer_params_t
 Parameters for transfer. More...
 

Typedefs

typedef int32_t gdc_cmd_hnd_t
 Handle for a requested command.
 

Enumerations

enum  cd_stat_t {
  CD_STATUS_READ_FAIL = -1 , CD_STATUS_BUSY = 0 , CD_STATUS_PAUSED = 1 , CD_STATUS_STANDBY = 2 ,
  CD_STATUS_PLAYING = 3 , CD_STATUS_SEEKING = 4 , CD_STATUS_SCANNING = 5 , CD_STATUS_OPEN = 6 ,
  CD_STATUS_NO_DISC = 7 , CD_STATUS_RETRY = 8 , CD_STATUS_ERROR = 9 , CD_STATUS_FATAL = 12
}
 Status of GDROM drive. More...
 
enum  cd_disc_types_t {
  CD_CDDA = 0x00 , CD_CDROM = 0x10 , CD_CDROM_XA = 0x20 , CD_CDI = 0x30 ,
  CD_GDROM = 0x80 , CD_FAIL = 0xf0
}
 Disc types the GDROM can identify. More...
 
enum  cd_cmd_code_t {
  CD_CMD_CHECK_LICENSE = 2 , CD_CMD_REQ_SPI_CMD = 4 , CD_CMD_PIOREAD = 16 , CD_CMD_DMAREAD = 17 ,
  CD_CMD_GETTOC = 18 , CD_CMD_GETTOC2 = 19 , CD_CMD_PLAY_TRACKS = 20 , CD_CMD_PLAY_SECTORS = 21 ,
  CD_CMD_PAUSE = 22 , CD_CMD_RELEASE = 23 , CD_CMD_INIT = 24 , CD_CMD_DMA_ABORT = 25 ,
  CD_CMD_OPEN_TRAY = 26 , CD_CMD_SEEK = 27 , CD_CMD_DMAREAD_STREAM = 28 , CD_CMD_NOP = 29 ,
  CD_CMD_REQ_MODE = 30 , CD_CMD_SET_MODE = 31 , CD_CMD_SCAN_CD = 32 , CD_CMD_STOP = 33 ,
  CD_CMD_GETSCD = 34 , CD_CMD_GETSES = 35 , CD_CMD_REQ_STAT = 36 , CD_CMD_PIOREAD_STREAM = 37 ,
  CD_CMD_DMAREAD_STREAM_EX = 38 , CD_CMD_PIOREAD_STREAM_EX = 39 , CD_CMD_GET_VERS = 40 , CD_CMD_MAX = 47
}
 Command codes for GDROM syscalls. More...
 
enum  cd_area_t { CD_AREA_LOW = 0 , CD_AREA_HIGH = 1 }
 Disc area to read TOC from. More...
 
enum  cd_sub_type_t {
  CD_SUB_Q_ALL = 0 , CD_SUB_Q_CHANNEL = 1 , CD_SUB_MEDIA_CATALOG = 2 , CD_SUB_TRACK_ISRC = 3 ,
  CD_SUB_RESERVED = 4
}
 Types of data to read from sector subcode. More...
 
enum  cd_sub_audio_t {
  CD_SUB_AUDIO_STATUS_INVALID = 0x00 , CD_SUB_AUDIO_STATUS_PLAYING = 0x11 , CD_SUB_AUDIO_STATUS_PAUSED = 0x12 , CD_SUB_AUDIO_STATUS_ENDED = 0x13 ,
  CD_SUB_AUDIO_STATUS_ERROR = 0x14 , CD_SUB_AUDIO_STATUS_NO_INFO = 0x15
}
 Subcode Audio Statuses. More...
 
enum  cd_cmd_chk_t {
  CD_CMD_FAILED = -1 , CD_CMD_NOT_FOUND = 0 , CD_CMD_PROCESSING = 1 , CD_CMD_COMPLETED = 2 ,
  CD_CMD_STREAMING = 3 , CD_CMD_BUSY = 4
}
 Responses from GDROM check command syscall. More...
 
enum  cd_cmd_chk_ata_status_t {
  ATA_STAT_INTERNAL = 0x00 , ATA_STAT_IRQ = 0x01 , ATA_STAT_DRQ_0 = 0x02 , ATA_STAT_DRQ_1 = 0x03 ,
  ATA_STAT_BUSY = 0x04
}
 ATA Statuses. More...
 
enum  cd_read_sec_part_t { CDROM_READ_WHOLE_SECTOR = 0x1000 , CDROM_READ_DATA_AREA = 0x2000 , CDROM_READ_DEFAULT = -1 }
 Read Sector Part. More...
 

Functions

void syscall_gdrom_init (void)
 Initialize the GDROM drive.
 
void syscall_gdrom_reset (void)
 Reset the GDROM drive.
 
int syscall_gdrom_check_drive (cd_check_drive_status_t *status)
 Checks the GDROM drive status.
 
gdc_cmd_hnd_t syscall_gdrom_send_command (cd_cmd_code_t cmd, void *params)
 Send a command to the GDROM command queue.
 
cd_cmd_chk_t syscall_gdrom_check_command (gdc_cmd_hnd_t hnd, cd_cmd_chk_status_t *status)
 Check status of queued command for the GDROM.
 
void syscall_gdrom_exec_server (void)
 Process queued GDROM commands.
 
int syscall_gdrom_abort_command (gdc_cmd_hnd_t hnd)
 Abort a queued GDROM command.
 
int syscall_gdrom_sector_mode (cd_sec_mode_params_t *mode)
 Sets/gets the sector mode for read commands.
 
void syscall_gdrom_dma_callback (uintptr_t callback, void *param)
 Setup GDROM DMA callback.
 
int syscall_gdrom_dma_transfer (gdc_cmd_hnd_t hnd, const cd_transfer_params_t *params)
 Initiates a GDROM DMA transfer.
 
int syscall_gdrom_dma_check (gdc_cmd_hnd_t hnd, size_t *size)
 Checks a GDROM DMA transfer.
 
void syscall_gdrom_pio_callback (uintptr_t callback, void *param)
 Setup GDROM PIO callback.
 
int syscall_gdrom_pio_transfer (gdc_cmd_hnd_t hnd, const cd_transfer_params_t *params)
 Initiates a GDROM PIO transfer.
 
int syscall_gdrom_pio_check (gdc_cmd_hnd_t hnd, size_t *size)
 Checks a GDROM PIO transfer.
 

Detailed Description

GDROM Syscalls and Data Types

These are the syscalls that allow operation of the GDROM drive as well as data types for their returns and parameters.

Typedef Documentation

◆ gdc_cmd_hnd_t

typedef int32_t gdc_cmd_hnd_t

Handle for a requested command.

This is returned by syscall_gdrom_send_command and then is passed to other syscalls to specify which command to act on.

Enumeration Type Documentation

◆ cd_area_t

enum cd_area_t

Disc area to read TOC from.

This is the allowed values for the first param of the GETTOC commands, defining which disc area to read the TOC from.

Enumerator
CD_AREA_LOW 
CD_AREA_HIGH 

◆ cd_cmd_chk_ata_status_t

ATA Statuses.

These are the different statuses that can be returned in the 4th field of cd_cmd_chk_status by syscall_gdrom_check_command.

Enumerator
ATA_STAT_INTERNAL 
ATA_STAT_IRQ 
ATA_STAT_DRQ_0 
ATA_STAT_DRQ_1 
ATA_STAT_BUSY 

◆ cd_cmd_chk_t

Responses from GDROM check command syscall.

These are return values of syscall_gdrom_check_command.

Enumerator
CD_CMD_FAILED 

Command failed.

CD_CMD_NOT_FOUND 

Command requested not found.

CD_CMD_PROCESSING 

Processing command.

CD_CMD_COMPLETED 

Command completed successfully.

CD_CMD_STREAMING 

Stream type command is in progress.

CD_CMD_BUSY 

GD syscalls is busy.

◆ cd_cmd_code_t

Command codes for GDROM syscalls.

These are the syscall command codes used to actually do stuff with the GDROM drive. These were originally provided by maiwe.

Enumerator
CD_CMD_CHECK_LICENSE 

Check license.

CD_CMD_REQ_SPI_CMD 

Request to Sega Packet Interface.

CD_CMD_PIOREAD 

Read via PIO.

CD_CMD_DMAREAD 

Read via DMA.

CD_CMD_GETTOC 

Read TOC.

CD_CMD_GETTOC2 

Read TOC.

CD_CMD_PLAY_TRACKS 

Play track.

CD_CMD_PLAY_SECTORS 

Play sectors.

CD_CMD_PAUSE 

Pause playback.

CD_CMD_RELEASE 

Resume from pause.

CD_CMD_INIT 

Initialize the drive.

CD_CMD_DMA_ABORT 

Abort DMA transfer.

CD_CMD_OPEN_TRAY 

Open CD tray (on DevBox?)

CD_CMD_SEEK 

Seek to a new position.

CD_CMD_DMAREAD_STREAM 

Stream DMA until end/abort.

CD_CMD_NOP 

No operation.

CD_CMD_REQ_MODE 

Request mode.

CD_CMD_SET_MODE 

Setup mode.

CD_CMD_SCAN_CD 

Scan CD.

CD_CMD_STOP 

Stop the disc from spinning.

CD_CMD_GETSCD 

Get subcode data.

CD_CMD_GETSES 

Get session.

CD_CMD_REQ_STAT 

Request stat.

CD_CMD_PIOREAD_STREAM 

Stream PIO until end/abort.

CD_CMD_DMAREAD_STREAM_EX 

Stream DMA transfer.

CD_CMD_PIOREAD_STREAM_EX 

Stream PIO transfer.

CD_CMD_GET_VERS 

Get syscall driver version.

CD_CMD_MAX 

Max of GD syscall commands.

◆ cd_disc_types_t

Disc types the GDROM can identify.

These are the values that can be returned as the second param of syscall_gdrom_check_drive.

Enumerator
CD_CDDA 

Audio CD (Red book) or no disc.

CD_CDROM 

CD-ROM or CD-R (Yellow book)

CD_CDROM_XA 

CD-ROM XA (Yellow book extension)

CD_CDI 

CD-i (Green book)

CD_GDROM 

GD-ROM.

CD_FAIL 

Need reset syscalls.

◆ cd_read_sec_part_t

Read Sector Part.

Parts of the a disc sector to read. These are possible values for the second parameter word sent with syscall_gdrom_sector_mode.

Note
CD_READ_DEFAULT not supported by the syscall and is provided for compatibility in cdrom_reinit_ex
Enumerator
CDROM_READ_WHOLE_SECTOR 

Read the whole sector.

CDROM_READ_DATA_AREA 

Read the data area.

CDROM_READ_DEFAULT 

cdrom_reinit default

◆ cd_stat_t

enum cd_stat_t

Status of GDROM drive.

These are the values that can be returned as the first param of syscall_gdrom_check_drive.

Enumerator
CD_STATUS_READ_FAIL 

Can't read status.

CD_STATUS_BUSY 

Drive is busy.

CD_STATUS_PAUSED 

Disc is paused.

CD_STATUS_STANDBY 

Drive is in standby.

CD_STATUS_PLAYING 

Drive is currently playing.

CD_STATUS_SEEKING 

Drive is currently seeking.

CD_STATUS_SCANNING 

Drive is scanning.

CD_STATUS_OPEN 

Disc tray is open.

CD_STATUS_NO_DISC 

No disc inserted.

CD_STATUS_RETRY 

Retry is needed.

CD_STATUS_ERROR 

System error.

CD_STATUS_FATAL 

Need reset syscalls.

◆ cd_sub_audio_t

Subcode Audio Statuses.

Information about CDDA playback returned by the GETSCD syscall command. This is returned in the second byte of the buffer.

Enumerator
CD_SUB_AUDIO_STATUS_INVALID 
CD_SUB_AUDIO_STATUS_PLAYING 
CD_SUB_AUDIO_STATUS_PAUSED 
CD_SUB_AUDIO_STATUS_ENDED 
CD_SUB_AUDIO_STATUS_ERROR 
CD_SUB_AUDIO_STATUS_NO_INFO 

◆ cd_sub_type_t

Types of data to read from sector subcode.

Types of data available to read from the sector subcode. These are possible values for the first parameter sent to the GETSCD syscall.

Enumerator
CD_SUB_Q_ALL 

Read all Subcode Data.

CD_SUB_Q_CHANNEL 

Read Q Channel Subcode Data.

CD_SUB_MEDIA_CATALOG 

Read the Media Catalog Subcode Data.

CD_SUB_TRACK_ISRC 

Read the ISRC Subcode Data.

CD_SUB_RESERVED 

Reserved.

Function Documentation

◆ syscall_gdrom_abort_command()

int syscall_gdrom_abort_command ( gdc_cmd_hnd_t hnd)

Abort a queued GDROM command.

This function tries to abort a previously queued command.

Parameters
hndThe request to abort.
Returns
0 on success, or non-zero on failure.

◆ syscall_gdrom_check_command()

cd_cmd_chk_t syscall_gdrom_check_command ( gdc_cmd_hnd_t hnd,
cd_cmd_chk_status_t * status )

Check status of queued command for the GDROM.

This function checks if a queued command has completed.

Parameters
hndThe request to check.
statuscd_cmd_chk_status_t that will receive the status.
Return values
CD_CMD_FAILEDRequest has failed.
CD_CMD_NOT_FOUNDRequest not found.
CD_CMD_PROCESSINGRequest is still being processed.
CD_CMD_COMPLETEDRequest completed successfully.
CD_CMD_STREAMINGStream type command is in progress.
CD_CMD_BUSYGD syscalls are busy.
See also
syscall_gdrom_send_command(), syscall_gdrom_exec_server()

◆ syscall_gdrom_check_drive()

int syscall_gdrom_check_drive ( cd_check_drive_status_t * status)

Checks the GDROM drive status.

This function retrieves the general condition of the GDROM drive. It populates a provided array with two elements. The first element indicates the current drive status (cd_stat_t), and the second element identifies the type of disc inserted if any (cd_disc_types_t).

Parameters
statusA cd_check_drive_status_t filled with drive status information.
Returns
0 on success, or non-zero on failure.

◆ syscall_gdrom_dma_callback()

void syscall_gdrom_dma_callback ( uintptr_t callback,
void * param )

Setup GDROM DMA callback.

This function sets up DMA transfer end callback for CMD_DMAREAD_STREAM_EX (dc/cdrom.h).

Parameters
callbackThe function to call upon completion of the DM.
paramThe data to pass to the callback function.

◆ syscall_gdrom_dma_check()

int syscall_gdrom_dma_check ( gdc_cmd_hnd_t hnd,
size_t * size )

Checks a GDROM DMA transfer.

This function checks the progress of a DMA transfer for CMD_DMAREAD_STREAM_EX (see dc/cdrom.h).

Parameters
hndThe stream request to check.
sizeThe pointer to receive the remaining amount of bytes to transfer.
Return values
0On success.
-1On failure.

◆ syscall_gdrom_dma_transfer()

int syscall_gdrom_dma_transfer ( gdc_cmd_hnd_t hnd,
const cd_transfer_params_t * params )

Initiates a GDROM DMA transfer.

This function initiates a DMA transfer for CMD_DMAREAD_STREAM_EX (dc/cdrom.h).

Parameters
hndThe stream request to start transferring.
paramsThe pointer to a cd_transfer_params_t.
Returns
0 on success, or non-zero on failure.

◆ syscall_gdrom_exec_server()

void syscall_gdrom_exec_server ( void )

Process queued GDROM commands.

This function starts processing queued commands. This must be called a few times to process all commands. An example of it in use can be seen in

See also
cdrom_exec_cmd_timed() (see hardware/cdrom.c).
syscall_gdrom_send_command(), syscall_gdrom_check_command()

◆ syscall_gdrom_init()

void syscall_gdrom_init ( void )

Initialize the GDROM drive.

This function initializes the GDROM drive. Should be called before any commands are sent.

◆ syscall_gdrom_pio_callback()

void syscall_gdrom_pio_callback ( uintptr_t callback,
void * param )

Setup GDROM PIO callback.

This function sets up PIO transfer end callback for CMD_PIOREAD_STREAM_EX (see dc/cdrom.h).

Parameters
callbackThe function to call upon completion of the transfer.
paramThe data to pass to the callback function.

◆ syscall_gdrom_pio_check()

int syscall_gdrom_pio_check ( gdc_cmd_hnd_t hnd,
size_t * size )

Checks a GDROM PIO transfer.

This function checks the progress of a PIO transfer for CMD_PIOREAD_STREAM_EX (see dc/cdrom.h).

Parameters
hndThe stream request to check.
sizeThe pointer to receive the remaining amount of bytes to transfer.
Return values
0On success.
-1On failure.

◆ syscall_gdrom_pio_transfer()

int syscall_gdrom_pio_transfer ( gdc_cmd_hnd_t hnd,
const cd_transfer_params_t * params )

Initiates a GDROM PIO transfer.

This function initiates a PIO transfer for CMD_PIOREAD_STREAM_EX (see dc/cdrom.h).

Parameters
hndThe stream request to start transferring.
paramsThe pointer to a cd_transfer_params_t.
Returns
0 on success, or non-zero on failure.

◆ syscall_gdrom_reset()

void syscall_gdrom_reset ( void )

Reset the GDROM drive.

This function resets the GDROM drive.

◆ syscall_gdrom_sector_mode()

int syscall_gdrom_sector_mode ( cd_sec_mode_params_t * mode)

Sets/gets the sector mode for read commands.

This function sets/gets the sector mode for read commands.

Parameters
modeThe pointer to a struct of four 32 bit integers containing new values, or to receive the old values.
Return values
0On success.
-1On failure.

◆ syscall_gdrom_send_command()

gdc_cmd_hnd_t syscall_gdrom_send_command ( cd_cmd_code_t cmd,
void * params )

Send a command to the GDROM command queue.

This function sends a command to the GDROM queue.

Note
Call syscall_gdrom_exec_server() to run queued commands.
Parameters
cmdThe command code (see cd_cmd_code_t above).
paramsThe pointer to parameter block for the command, can be NULL if the command does not take parameters.
Returns
The request id (>=1) on success, or 0 on failure.
See also
syscall_gdrom_check_command(), syscall_gdrom_exec_server()