|
From: kosmirror <kos...@us...> - 2025-11-02 20:07:47
|
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 cacf38ee9915fda00c4158c381727c5e7ce11e42 (commit)
via 772a117830f3d6993d7b8fd2fae3b0b3a4513430 (commit)
via 0dc220f323c883daa8b7e892a026b4ead19149eb (commit)
via cf46e2d0b5f44ca364f669d5775ce6b1d6c4fc28 (commit)
via fcecd3733fc87bbd37a3985b56d2b21230fa2090 (commit)
via c4172c57772036732e17111e2868543734aa60f2 (commit)
from fab88066d4176b37d037b9d28af82d87589cd145 (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 cacf38ee9915fda00c4158c381727c5e7ce11e42
Author: DC-SWAT <sw...@21...>
Date: Thu Oct 30 14:18:57 2025 +0700
[arch] Cached hardware_sys_mode().
commit 772a117830f3d6993d7b8fd2fae3b0b3a4513430
Author: DC-SWAT <sw...@21...>
Date: Thu Oct 30 14:10:58 2025 +0700
[sci] Used hardware_sys_mode() for CS pin selection.
commit 0dc220f323c883daa8b7e892a026b4ead19149eb
Author: DC-SWAT <sw...@21...>
Date: Thu Oct 30 14:10:43 2025 +0700
[video] Used hardware_sys_mode() for cable detection.
commit cf46e2d0b5f44ca364f669d5775ce6b1d6c4fc28
Author: DC-SWAT <sw...@21...>
Date: Thu Oct 30 14:09:57 2025 +0700
[aica] Used hardware_sys_mode() for memory size detection.
commit fcecd3733fc87bbd37a3985b56d2b21230fa2090
Author: DC-SWAT <sw...@21...>
Date: Thu Oct 30 14:09:44 2025 +0700
[pvr] Used hardware_sys_mode() for memory size detection.
commit c4172c57772036732e17111e2868543734aa60f2
Author: DC-SWAT <sw...@21...>
Date: Fri Oct 24 11:30:13 2025 +0700
[arch] Add HW_TYPE_NAOMI for hardware_sys_mode().
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/hardware.c | 8 ++++----
kernel/arch/dreamcast/hardware/sci.c | 18 ++++++++++--------
kernel/arch/dreamcast/hardware/video.c | 2 +-
kernel/arch/dreamcast/include/arch/arch.h | 3 +++
kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h | 6 +++---
kernel/arch/dreamcast/sound/snd_mem.c | 12 +++++++++---
6 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/kernel/arch/dreamcast/hardware/hardware.c b/kernel/arch/dreamcast/hardware/hardware.c
index 9b1ad726..d5dd4532 100644
--- a/kernel/arch/dreamcast/hardware/hardware.c
+++ b/kernel/arch/dreamcast/hardware/hardware.c
@@ -19,16 +19,15 @@
#include <dc/vblank.h>
static int initted = 0;
+static uint32_t sysmode;
#define SYSMODE_REG 0xA05F74B0
int hardware_sys_mode(int *region) {
- uint32 sm = *((vuint32 *)SYSMODE_REG);
-
if(region)
- *region = sm & 0x0F;
+ *region = sysmode & 0x0F;
- return (sm >> 4) & 0x0F;
+ return (sysmode >> 4) & 0x0F;
}
int hardware_sys_init(void) {
@@ -38,6 +37,7 @@ int hardware_sys_init(void) {
/* VBlank multiplexer */
vblank_init();
+ sysmode = *((volatile uint32_t *)SYSMODE_REG);
initted = 1;
return 0;
diff --git a/kernel/arch/dreamcast/hardware/sci.c b/kernel/arch/dreamcast/hardware/sci.c
index 8b839880..cf117b81 100644
--- a/kernel/arch/dreamcast/hardware/sci.c
+++ b/kernel/arch/dreamcast/hardware/sci.c
@@ -6,6 +6,7 @@
#include <dc/sci.h>
#include <dc/math.h>
+#include <arch/arch.h>
#include <arch/cache.h>
#include <arch/dmac.h>
#include <kos/timer.h>
@@ -333,14 +334,15 @@ sci_result_t sci_init(uint32_t baud_rate, sci_mode_t mode, sci_clock_t clock_src
else if(mode == SCI_MODE_SPI) {
/* Use 512 bytes DMA buffer for SPI operations by default,
because it's sector size of SD cards. */
-#ifdef __DREAMCAST__
- /* On Dreamcast, we use GPIO for CS (anyway need soldering all pins),
- because RTS can be used for VS-link cable */
- sci_configure_spi(SCI_SPI_CS_GPIO, 512);
-#else
- /* On Naomi, we use SCIF RTS for CS, because no GPIO pins on CN1 connector */
- sci_configure_spi(SCI_SPI_CS_RTS, 512);
-#endif
+ if(hardware_sys_mode(NULL) == HW_TYPE_RETAIL) {
+ /* On Dreamcast, we use GPIO for CS (anyway need soldering all pins),
+ because RTS can be used for VS-link cable */
+ sci_configure_spi(SCI_SPI_CS_GPIO, 512);
+ }
+ else {
+ /* On NAOMI, we use SCIF RTS for CS, because no GPIO pins on CN1 connector */
+ sci_configure_spi(SCI_SPI_CS_RTS, 512);
+ }
/* Set CA bit for 8-bit synchronous mode */
scsmr1 |= SCSMR_CA;
}
diff --git a/kernel/arch/dreamcast/hardware/video.c b/kernel/arch/dreamcast/hardware/video.c
index b5f69ce4..96c585cd 100644
--- a/kernel/arch/dreamcast/hardware/video.c
+++ b/kernel/arch/dreamcast/hardware/video.c
@@ -211,7 +211,7 @@ uint32_t *vram_l;
int8_t vid_check_cable(void) {
volatile uint32_t * porta = (vuint32 *)0xff80002c;
- if(KOS_PLATFORM_IS_NAOMI) {
+ if(hardware_sys_mode(NULL) != HW_TYPE_RETAIL) {
/* XXXX: This still needs to be figured out for NAOMI. For now, assume
VGA mode. */
return CT_VGA;
diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h
index a152d691..39c20aa1 100644
--- a/kernel/arch/dreamcast/include/arch/arch.h
+++ b/kernel/arch/dreamcast/include/arch/arch.h
@@ -253,6 +253,7 @@ void hardware_shutdown(void);
*/
#define HW_TYPE_RETAIL 0x0 /**< \brief A retail Dreamcast. */
#define HW_TYPE_SET5 0x9 /**< \brief A Set5.xx devkit. */
+#define HW_TYPE_NAOMI 0xa /**< \brief A NAOMI arcade. */
/** @} */
/** \defgroup hw_regions Region Codes
@@ -290,6 +291,8 @@ void hardware_shutdown(void);
-- otherwise, you must retrieve the region from the
flashrom.
\return The console type (one of the \ref hw_consoles).
+
+ \note Do not use before hardware_sys_init() has been called.
*/
int hardware_sys_mode(int *region);
diff --git a/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h b/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h
index 10076d6e..2b4981b0 100644
--- a/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h
+++ b/kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h
@@ -3,7 +3,7 @@
dc/pvr/pvr_regs.h
Copyright (C) 2002 Megan Potter
Copyright (C) 2014 Lawrence Sebald
- Copyright (C) 2023 Ruslan Rostovtsev
+ Copyright (C) 2023, 2025 Ruslan Rostovtsev
Copyright (C) 2024 Falco Girgis
*/
@@ -30,7 +30,7 @@
#include <kos/cdefs.h>
__BEGIN_DECLS
-#include <kos/platform.h>
+#include <arch/arch.h>
/**** Register macros ***************************************************/
@@ -175,7 +175,7 @@ __BEGIN_DECLS
#define PVR_RAM_BASE 0xa5000000 /**< \brief VRAM 32-bit, P2 area, PVR->VRAM */
#define PVR_RAM_INT_BASE 0xa4000000 /**< \brief VRAM 64-bit, P2 area, PVR->VRAM */
-#define PVR_RAM_SIZE_MB (KOS_PLATFORM_IS_NAOMI ? 16 : 8) /**< \brief RAM size in MiB */
+#define PVR_RAM_SIZE_MB (hardware_sys_mode(NULL) == HW_TYPE_RETAIL ? 8 : 16) /**< \brief RAM size in MiB */
#define PVR_RAM_SIZE (PVR_RAM_SIZE_MB*1024*1024) /**< \brief RAM size in bytes */
#define PVR_RAM_TOP (PVR_RAM_BASE + PVR_RAM_SIZE) /**< \brief Top of raw PVR RAM */
diff --git a/kernel/arch/dreamcast/sound/snd_mem.c b/kernel/arch/dreamcast/sound/snd_mem.c
index cba2494c..5344d147 100644
--- a/kernel/arch/dreamcast/sound/snd_mem.c
+++ b/kernel/arch/dreamcast/sound/snd_mem.c
@@ -2,7 +2,7 @@
snd_mem.c
Copyright (C) 2002 Megan Potter
- Copyright (C) 2023 Ruslan Rostovtsev
+ Copyright (C) 2023, 2025 Ruslan Rostovtsev
*/
@@ -13,6 +13,7 @@
#include <errno.h>
#include <sys/queue.h>
#include <dc/sound/sound.h>
+#include <arch/arch.h>
#include <arch/spinlock.h>
#include <kos/dbglog.h>
@@ -94,7 +95,12 @@ int snd_mem_init(uint32 reserve) {
memset(blk, 0, sizeof(snd_block_t));
blk->addr = reserve;
- blk->size = 2 * 1024 * 1024 - reserve;
+
+ if(hardware_sys_mode(NULL) == HW_TYPE_RETAIL)
+ blk->size = 2 * 1024 * 1024 - reserve;
+ else
+ blk->size = 8 * 1024 * 1024 - reserve;
+
blk->inuse = 0;
TAILQ_INSERT_HEAD(&pool, blk, qent);
@@ -137,7 +143,7 @@ void snd_mem_shutdown(void) {
/* Allocate a chunk of SPU RAM; we will return an offset into SPU RAM. */
uint32 snd_mem_malloc(size_t size) {
snd_block_t *e, *best = NULL;
- size_t best_size = 4 * 1024 * 1024;
+ size_t best_size = SIZE_MAX;
assert_msg(initted, "Use of snd_mem_malloc before snd_mem_init");
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|