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

API for the Dreamcast's system calls More...

Files

file  syscalls.h
 Functions to access the system calls of the Dreamcast ROM.
 

Functions

void syscall_sysinfo_init (void)
 Inits data needed by sysinfo id/icon.
 
int syscall_sysinfo_icon (uint32_t icon, uint8_t *dest)
 Reads an icon from the flashrom.
 
uint64_t syscall_sysinfo_id (void)
 Reads the ID of the Dreamcast.
 
uint8_t * syscall_font_address (void)
 Gets the romfont address.
 
int syscall_font_lock (void)
 Locks access to ROM font.
 
void syscall_font_unlock (void)
 Unlocks access to ROM font.
 
int syscall_flashrom_info (uint32_t part, void *info)
 Gets info on partition in the flashrom.
 
int syscall_flashrom_read (uint32_t pos, void *dest, size_t n)
 Read data from the flashrom.
 
int syscall_flashrom_write (uint32_t pos, const void *src, size_t n)
 Write data to the flashrom.
 
int syscall_flashrom_delete (uint32_t pos)
 Delete a partition of the flashrom.
 
void syscall_gdrom_init (void)
 Initialize the GDROM drive.
 
void syscall_gdrom_reset (void)
 Reset the GDROM drive.
 
int syscall_gdrom_check_drive (uint32_t status[2])
 Checks the GDROM drive status.
 
uint32_t syscall_gdrom_send_command (uint32_t cmd, void *params)
 Send a command to the GDROM command queue.
 
int syscall_gdrom_check_command (uint32_t id, int32_t status[4])
 Check status of queued command for the GDROM.
 
void syscall_gdrom_exec_server (void)
 Process queued GDROM commands.
 
int syscall_gdrom_abort_command (uint32_t id)
 Abort a queued GDROM command.
 
int syscall_gdrom_sector_mode (uint32_t mode[4])
 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 (uint32_t id, const int32_t params[2])
 Initiates a GDROM DMA transfer.
 
int syscall_gdrom_dma_check (uint32_t id, 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 (uint32_t id, const int32_t params[2])
 Initiates a GDROM PIO transfer.
 
int syscall_gdrom_pio_check (uint32_t id, size_t *size)
 Checks a GDROM PIO transfer.
 
int syscall_misc_init (void)
 Initializes all the syscall vectors.
 
int syscall_misc_setvector (uint32_t super, uintptr_t handler)
 Set/Clear a user defined super function.
 
void syscall_system_reset (void) __noreturn
 Resets the Dreamcast.
 
void syscall_system_bios_menu (void) __noreturn
 Go to the BIOS menu.
 
void syscall_system_cd_menu (void) __noreturn
 Exit to CD menu.
 

Detailed Description

API for the Dreamcast's system calls

This module encapsulates all the system calls available in the Dreamcast BIOS, allowing direct interaction with system hardware components such as the GDROM drive, flash ROM, and bios fonts. These functions are essential for performing low-level operations that are not handled by standard user-space APIs.

Function Documentation

◆ syscall_flashrom_delete()

int syscall_flashrom_delete ( uint32_t pos)

Delete a partition of the flashrom.

This function returns a flashrom partition to all 1's, so that it may be rewritten.

Warning
ALL data in the entire partition will be lost.
Parameters
posThe offset from the start of the flashrom you want to delete.
Return values
0On success.
-1On failure.
See also
syscall_flashrom_read(), syscall_flashrom_write()

◆ syscall_flashrom_info()

int syscall_flashrom_info ( uint32_t part,
void * info )

Gets info on partition in the flashrom.

This function fetches the info of a partition in the flashrom.

Parameters
partThe partition number (0-4).
infoThe buffer to store info (8 bytes in size).
Return values
0On success.
-1On failure.

◆ syscall_flashrom_read()

int syscall_flashrom_read ( uint32_t pos,
void * dest,
size_t n )

Read data from the flashrom.

This function reads data from an offset into the flashrom to the destination buffer.

Parameters
posThe read start position into the flashrom.
destThe destination buffer.
nThe number of bytes to read.
Returns
Number of bytes read on success, or -1 on failure.
See also
syscall_flashrom_write(), syscall_flashrom_delete()

◆ syscall_flashrom_write()

int syscall_flashrom_write ( uint32_t pos,
const void * src,
size_t n )

Write data to the flashrom.

This function writes data to an offset into the flashrom from the source buffer.

Warning
It is only possible to overwrite 1's with 0's. 0's can not be written back to 1's so general overwriting is therefore not possible. You would need to delete a whole partition to overwrite it.
Parameters
posThe start position to write into the flashrom.
srcThe source buffer.
nThe number of bytes to write.
Returns
Number of bytes written on success, or -1 on failure.
See also
syscall_flashrom_read(), syscall_flashrom_delete()

◆ syscall_font_address()

uint8_t * syscall_font_address ( void )

Gets the romfont address.

This function returns the address of the ROM font.

Warning
Before attempting to access the font data, you should always call syscall_font_lock() to ensure that you have exclusive access to the G1 BUS the ROM is located on. Call syscall_font_unlock() when you're done accessing the data.
Note
Defined in syscall_font.s
Returns
The address of the font.

◆ syscall_font_lock()

int syscall_font_lock ( void )

Locks access to ROM font.

This function tries to lock a mutex for exclusive access to the ROM font. This is needed because you can't access the BIOS font during G1 DMA.

Note
Defined in syscall_font.s
Return values
0On success.
-1On failure.
See also
syscall_font_unlock()

◆ syscall_font_unlock()

void syscall_font_unlock ( void )

Unlocks access to ROM font.

This function releases the mutex locked with syscall_font_lock().

Note
Defined in syscall_font.s
See also
syscall_font_lock()

◆ syscall_gdrom_abort_command()

int syscall_gdrom_abort_command ( uint32_t id)

Abort a queued GDROM command.

This function tries to abort a previously queued command.

Parameters
idThe request id (>=1) to abort.
Returns
0 on success, or non-zero on failure.

◆ syscall_gdrom_check_command()

int syscall_gdrom_check_command ( uint32_t id,
int32_t status[4] )

Check status of queued command for the GDROM.

This function checks if a queued command has completed.

Parameters
idThe request id (>=1).
statusThe pointer to four 32-bit integers to receive status information.
Return values
-1Request has failed.
0Request not found.
1Request is still being processed.
2Request completed successfully.
3Stream type command is in progress.
4GD syscalls are busy.
See also
syscall_gdrom_send_command(), syscall_gdrom_exec_server()

◆ syscall_gdrom_check_drive()

int syscall_gdrom_check_drive ( uint32_t status[2])

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, and the second element identifies the type of disk inserted (if any).

Parameters
statusThe pointer to two 32-bit unsigned integers to receive extended 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 ( uint32_t id,
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
idThe request id (>=1).
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 ( uint32_t id,
const int32_t params[2] )

Initiates a GDROM DMA transfer.

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

Parameters
idThe request id (>=1).
paramsThe pointer to two 32-bit integers. The first element indicates the destination address, and the second element identifies how many bytes to transfer.
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 ( uint32_t id,
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
idThe request id (>=1).
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 ( uint32_t id,
const int32_t params[2] )

Initiates a GDROM PIO transfer.

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

Parameters
idThe request id (>=1).
paramsThe pointer to two 32-bit integers. The first element indicates the destination address, and the second element identifies how many bytes to transfer.
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 ( uint32_t mode[4])

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()

uint32_t syscall_gdrom_send_command ( uint32_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 CMD_* in dc/cdrom.h).
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()

◆ syscall_misc_init()

int syscall_misc_init ( void )

Initializes all the syscall vectors.

This function initializes all the syscall vectors to their default values.

Returns
0

◆ syscall_misc_setvector()

int syscall_misc_setvector ( uint32_t super,
uintptr_t handler )

Set/Clear a user defined super function.

This function sets/clears the handler for one of the seven user defined super functions. Setting a handler is only allowed if it not currently set.

Parameters
superThe super function number (1-7).
handlerThe pointer to handler function, or NULL to clear.
Return values
0On success.
-1On failure.

◆ syscall_sysinfo_icon()

int syscall_sysinfo_icon ( uint32_t icon,
uint8_t * dest )

Reads an icon from the flashrom.

This function reads an icon from the flashrom into a destination buffer.

Note
The format of these icons is not known.
Parameters
iconThe icon number (0-9, 5-9 seems to really be icons).
destThe destination buffer (704 bytes in size).
Returns
Number of bytes read on success, or -1 on failure.

◆ syscall_sysinfo_id()

uint64_t syscall_sysinfo_id ( void )

Reads the ID of the Dreamcast.

This function returns the unique 64-bit ID for the Dreamcast.

Returns
The Dreamcast ID.

◆ syscall_sysinfo_init()

void syscall_sysinfo_init ( void )

Inits data needed by sysinfo id/icon.

Note
This is called automatically by KOS during initialization. This function prepares syscall_sysinfo_icon and syscall_sysinfo_id calls for use by copying the relevant data from the system flashrom into 8C000068-8C00007F.

◆ syscall_system_bios_menu()

void syscall_system_bios_menu ( void )

Go to the BIOS menu.

This function exits the program to the BIOS menu.

◆ syscall_system_cd_menu()

void syscall_system_cd_menu ( void )

Exit to CD menu.

This function exits the program to the BIOS CD menu.

◆ syscall_system_reset()

void syscall_system_reset ( void )

Resets the Dreamcast.

This function soft resets the Dreamcast console.