From: darcagn <da...@us...> - 2023-11-18 05:12:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c27fb0a93183016b5b68eb7e42958f48808b8097 (commit) via dd72b80ef83078d266503e181ab8c1d762ebb02c (commit) via 9cdc816f98dd777e61fa7331b452b894d65cba1e (commit) from 9462865fd8e91ea45d2241c3bead0722c55a020d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c27fb0a93183016b5b68eb7e42958f48808b8097 Merge: dd72b80 9cdc816 Author: darcagn <da...@pr...> Date: Fri Nov 17 23:11:07 2023 -0600 Merge pull request #369 from KallistiOS/c99_formatters_default Enable C99 printf() Formatters in Toolchain Config Samples commit dd72b80ef83078d266503e181ab8c1d762ebb02c Author: Ruslan Rostovtsev <sw...@21...> Date: Sat Nov 18 11:53:35 2023 +0700 Complete description of BIOS syscalls for GD-ROM. (#366) commit 9cdc816f98dd777e61fa7331b452b894d65cba1e Author: Falco Girgis <gyr...@gm...> Date: Fri Nov 17 21:31:53 2023 -0600 Dc-chain configs enable c99 formatters by default - Modified all of the sample configuration files in dc-chain to enable the C99 printf formatter option by default. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 84 +++++++++++++++++----- kernel/arch/dreamcast/include/dc/cdrom.h | 79 +++++++++++++++----- utils/dc-chain/config/config.mk.10.5.0.sample | 2 +- utils/dc-chain/config/config.mk.11.4.0.sample | 2 +- utils/dc-chain/config/config.mk.12.3.0.sample | 2 +- utils/dc-chain/config/config.mk.9.3.0.sample | 2 +- utils/dc-chain/config/config.mk.devel.sample | 2 +- utils/dc-chain/config/config.mk.legacy.sample | 2 +- utils/dc-chain/config/config.mk.stable.sample | 2 +- .../dc-chain/config/config.mk.winxp-latest.sample | 2 +- 10 files changed, 136 insertions(+), 43 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index 3beec3c..c0ad6a9 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -5,8 +5,10 @@ Copyright (C) 2000 Megan Potter Copyright (C) 2014 Lawrence Sebald Copyright (C) 2014 Donald Haase + Copyright (C) 2023 Ruslan Rostovtsev */ +#include <assert.h> #include <dc/cdrom.h> #include <dc/g1ata.h> @@ -81,18 +83,47 @@ static int gdc_change_data_type(void *param) { MAKE_SYSCALL(return, param, 0, 10); } -/* Reset the GD-ROM */ -/* Stop gcc from complaining that we don't use it */ -static void gdc_reset(void) __attribute__((unused)); +/* Abort the current command */ +static void gdc_abort_cmd(int cmd) { + MAKE_SYSCALL(/**/, cmd, 0, 8); +} +#if 0 /* Not used yet */ +/* Reset the GD-ROM syscalls */ static void gdc_reset(void) { MAKE_SYSCALL(/**/, 0, 0, 9); } -/* Abort the current command */ -static void gdc_abort_cmd(int cmd) { - MAKE_SYSCALL(/**/, cmd, 0, 8); +/* DMA end interrupt handler */ +static void gdc_dma_end(uintptr_t callback, void *param) { + MAKE_SYSCALL(/**/, callback, param, 5); +} + +/* Request DMA transfer for DMAREAD_STREAM commands */ +static int gdc_req_dma_transfer(int f, int *params) { + MAKE_SYSCALL(return, f, params, 6); +} + +/* Check DMA transfer for DMAREAD_STREAM commands */ +static int gdc_check_dma_transfer(int f, int *size) { + MAKE_SYSCALL(return, f, size, 7); +} + +/* Setup PIO transfer end callback for PIOREAD_STREAM commands */ +static void gdc_set_pio_callback(uintptr_t callback, void *param) { + MAKE_SYSCALL(/**/, callback, param, 11); } +/* Request PIO transfer for PIOREAD_STREAM commands */ +static int gdc_req_pio_transfer(int f, int *params) { + MAKE_SYSCALL(return, f, params, 12); +} + +/* Check PIO transfer for PIOREAD_STREAM commands */ +static int gdc_check_pio_transfer(int f, int *size) { + MAKE_SYSCALL(return, f, size, 13); +} +#endif + /* The G1 ATA access mutex */ mutex_t _g1_ata_mutex = RECURSIVE_MUTEX_INITIALIZER; @@ -104,33 +135,50 @@ int cdrom_set_sector_size(int size) { /* Command execution sequence */ /* XXX: It might make sense to have a version of this that takes a timeout. */ int cdrom_exec_cmd(int cmd, void *param) { - int status[4] = {0}; + int status[4] = { + 0, /* Error code 1 */ + 0, /* Error code 2 */ + 0, /* Transfered size */ + 0 /* ATA status waiting */ + }; int f, n; + assert(cmd > 0 && cmd < CMD_MAX); mutex_lock(&_g1_ata_mutex); /* Make sure to select the GD-ROM drive. */ g1_ata_select_device(G1_ATA_MASTER); - /* Submit the command and wait for it to finish */ - f = gdc_req_cmd(cmd, param); + /* Submit the command */ + for(n = 0; n < 10; ++n) { + f = gdc_req_cmd(cmd, param); + if (f > 0) { + break; + } + gdc_exec_server(); + thd_pass(); + } + + if(f <= 0) { + mutex_unlock(&_g1_ata_mutex); + return ERR_SYS; + } + /* Wait command to finish */ do { gdc_exec_server(); n = gdc_get_cmd_stat(f, status); - if(n == PROCESSING) - thd_pass(); - } - while(n == PROCESSING) - ; + if(n != PROCESSING && n != BUSY) { + break; + } + thd_pass(); + } while(1); mutex_unlock(&_g1_ata_mutex); - if(n == COMPLETED) + if(n == COMPLETED || n == STREAMING) return ERR_OK; - else if(n == ABORTED) - return ERR_ABORTED; else if(n == NO_ACTIVE) return ERR_NO_ACTIVE; else { @@ -142,6 +190,8 @@ int cdrom_exec_cmd(int cmd, void *param) { default: return ERR_SYS; } + if(status[1] != 0) + return ERR_SYS; } } diff --git a/kernel/arch/dreamcast/include/dc/cdrom.h b/kernel/arch/dreamcast/include/dc/cdrom.h index c50c63e..8bf16b4 100644 --- a/kernel/arch/dreamcast/include/dc/cdrom.h +++ b/kernel/arch/dreamcast/include/dc/cdrom.h @@ -3,6 +3,7 @@ dc/cdrom.h Copyright (C) 2000-2001 Megan Potter Copyright (C) 2014 Donald Haase + Copyright (C) 2023 Ruslan Rostovtsev */ #ifndef __DC_CDROM_H @@ -29,6 +30,7 @@ __BEGIN_DECLS normal file reading, consult with the stuff for the fs and for fs_iso9660. \author Megan Potter + \author Ruslan Rostovtsev \see kos/fs.h \see dc/fs_iso9660.h */ @@ -40,20 +42,34 @@ __BEGIN_DECLS @{ */ -#define CMD_PIOREAD 16 /**< \brief Read via PIO */ -#define CMD_DMAREAD 17 /**< \brief Read via DMA */ -#define CMD_GETTOC 18 /**< \brief Read TOC */ -#define CMD_GETTOC2 19 /**< \brief Read TOC */ -#define CMD_PLAY 20 /**< \brief Play track */ -#define CMD_PLAY2 21 /**< \brief Play sectors */ -#define CMD_PAUSE 22 /**< \brief Pause playback */ -#define CMD_RELEASE 23 /**< \brief Resume from pause */ -#define CMD_INIT 24 /**< \brief Initialize the drive */ -#define CMD_SEEK 27 /**< \brief Seek to a new position */ -#define CMD_READ 28 /**< \brief Read raw sectors */ -#define CMD_STOP 33 /**< \brief Stop the disc from spinning */ -#define CMD_GETSCD 34 /**< \brief Get subcode data */ -#define CMD_GETSES 35 /**< \brief Get session */ +#define CMD_CHECK_LICENSE 2 /**< \brief Check license */ +#define CMD_REQ_SPI_CMD 4 /**< \brief Request to Sega Packet Interface */ +#define CMD_PIOREAD 16 /**< \brief Read via PIO */ +#define CMD_DMAREAD 17 /**< \brief Read via DMA */ +#define CMD_GETTOC 18 /**< \brief Read TOC */ +#define CMD_GETTOC2 19 /**< \brief Read TOC */ +#define CMD_PLAY 20 /**< \brief Play track */ +#define CMD_PLAY2 21 /**< \brief Play sectors */ +#define CMD_PAUSE 22 /**< \brief Pause playback */ +#define CMD_RELEASE 23 /**< \brief Resume from pause */ +#define CMD_INIT 24 /**< \brief Initialize the drive */ +#define CMD_DMA_ABORT 25 /**< \brief Abort DMA transfer */ +#define CMD_OPEN_TRAY 26 /**< \brief Open CD tray (on DevBox?) */ +#define CMD_SEEK 27 /**< \brief Seek to a new position */ +#define CMD_DMAREAD_STREAM 28 /**< \brief Stream DMA until end/abort */ +#define CMD_NOP 29 /**< \brief No operation */ +#define CMD_REQ_MODE 30 /**< \brief Request mode */ +#define CMD_SET_MODE 31 /**< \brief Setup mode */ +#define CMD_SCAN_CD 32 /**< \brief Scan CD */ +#define CMD_STOP 33 /**< \brief Stop the disc from spinning */ +#define CMD_GETSCD 34 /**< \brief Get subcode data */ +#define CMD_GETSES 35 /**< \brief Get session */ +#define CMD_REQ_STAT 36 /**< \brief Request stat */ +#define CMD_PIOREAD_STREAM 37 /**< \brief Stream PIO until end/abort */ +#define CMD_DMAREAD_STREAM_EX 38 /**< \brief Stream DMA transfer */ +#define CMD_PIOREAD_STREAM_EX 39 /**< \brief Stream PIO transfer */ +#define CMD_GET_VERS 40 /**< \brief Get syscall driver version */ +#define CMD_MAX 47 /**< \brief Max of GD syscall commands */ /** @} */ /** \defgroup cd_cmd_response CD-ROM command responses @@ -78,7 +94,18 @@ __BEGIN_DECLS #define NO_ACTIVE 0 /**< \brief System inactive? */ #define PROCESSING 1 /**< \brief Processing command */ #define COMPLETED 2 /**< \brief Command completed successfully */ -#define ABORTED 3 /**< \brief Command aborted before completion */ +#define STREAMING 3 /**< \brief Stream type command is in progress */ +#define BUSY 4 /**< \brief GD syscalls is busy */ +/** @} */ + +/** \defgroup cd_cmd_ata_status CD-ROM ATA status + @{ +*/ +#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 /** @} */ /** \defgroup cdda_read_modes CDDA read modes @@ -107,12 +134,25 @@ __BEGIN_DECLS possible values for the first parameter sent to the GETSCD syscall. @{ */ -#define CD_SUB_Q_CHANNEL 0 /**< \brief Read Q Channel Subcode Data */ -#define CD_SUB_CURRENT_POSITION 1 /**< \brief Read all Subcode Data for - most recent sector */ +#define CD_SUB_Q_ALL 0 /**< \brief Read all Subcode Data */ +#define CD_SUB_Q_CHANNEL 1 /**< \brief Read Q Channel Subcode Data */ #define CD_SUB_MEDIA_CATALOG 2 /**< \brief Read the Media Catalog Subcode Data */ #define CD_SUB_TRACK_ISRC 3 /**< \brief Read the ISRC Subcode Data */ +#define CD_SUB_RESERVED 4 /**< \brief Reserved */ +/** @} */ + +/** \defgroup cd_subcode_audio CD-ROM Subcode audio status + + Information about CDDA playback from GETSCD syscall. + @{ +*/ +#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 /** @} */ /** \defgroup cd_read_sector_mode CD-ROM Read Sector Mode @@ -131,6 +171,7 @@ __BEGIN_DECLS cdrom_get_status() function. @{ */ +#define CD_STATUS_READ_FAIL -1 /**< \brief Can't read status */ #define CD_STATUS_BUSY 0 /**< \brief Drive is busy */ #define CD_STATUS_PAUSED 1 /**< \brief Disc is paused */ #define CD_STATUS_STANDBY 2 /**< \brief Drive is in standby */ @@ -139,6 +180,8 @@ __BEGIN_DECLS #define CD_STATUS_SCANNING 5 /**< \brief Drive is scanning */ #define CD_STATUS_OPEN 6 /**< \brief Disc tray is open */ #define CD_STATUS_NO_DISC 7 /**< \brief No disc inserted */ +#define CD_STATUS_RETRY 8 /**< \brief Retry is needed */ +#define CD_STATUS_ERROR 9 /**< \brief System error */ /** @} */ /** \defgroup cd_disc_types CD-ROM drive disc types diff --git a/utils/dc-chain/config/config.mk.10.5.0.sample b/utils/dc-chain/config/config.mk.10.5.0.sample index da52ff1..3ceb19c 100644 --- a/utils/dc-chain/config/config.mk.10.5.0.sample +++ b/utils/dc-chain/config/config.mk.10.5.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.11.4.0.sample b/utils/dc-chain/config/config.mk.11.4.0.sample index 0132602..d4458e6 100644 --- a/utils/dc-chain/config/config.mk.11.4.0.sample +++ b/utils/dc-chain/config/config.mk.11.4.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.12.3.0.sample b/utils/dc-chain/config/config.mk.12.3.0.sample index 64d6924..2840d3b 100644 --- a/utils/dc-chain/config/config.mk.12.3.0.sample +++ b/utils/dc-chain/config/config.mk.12.3.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.9.3.0.sample b/utils/dc-chain/config/config.mk.9.3.0.sample index 4b2866c..61c25fd 100644 --- a/utils/dc-chain/config/config.mk.9.3.0.sample +++ b/utils/dc-chain/config/config.mk.9.3.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.devel.sample b/utils/dc-chain/config/config.mk.devel.sample index b000f59..7400930 100644 --- a/utils/dc-chain/config/config.mk.devel.sample +++ b/utils/dc-chain/config/config.mk.devel.sample @@ -146,7 +146,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.legacy.sample b/utils/dc-chain/config/config.mk.legacy.sample index 8a2349e..47a6c14 100644 --- a/utils/dc-chain/config/config.mk.legacy.sample +++ b/utils/dc-chain/config/config.mk.legacy.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.stable.sample b/utils/dc-chain/config/config.mk.stable.sample index 1223da6..2541df1 100644 --- a/utils/dc-chain/config/config.mk.stable.sample +++ b/utils/dc-chain/config/config.mk.stable.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.winxp-latest.sample b/utils/dc-chain/config/config.mk.winxp-latest.sample index 50a638b..5d0d6cc 100644 --- a/utils/dc-chain/config/config.mk.winxp-latest.sample +++ b/utils/dc-chain/config/config.mk.winxp-latest.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will hooks/post-receive -- A pseudo Operating System for the Dreamcast. |