You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
| 2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
| 2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
| 2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
| 2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
| 2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
| 2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
| 2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
| 2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
| 2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
| 2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
| 2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
| 2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
| 2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
| 2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
| 2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
(26) |
Aug
(48) |
Sep
(30) |
Oct
(8) |
Nov
(9) |
Dec
|
|
From: kosmirror <kos...@us...> - 2025-08-06 13:46:55
|
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 f68aa6ceeb9a229bb964091fb8786c88d3cd8d68 (commit)
from 0d611105f71621c9688172ca2988c77065c089c8 (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 f68aa6ceeb9a229bb964091fb8786c88d3cd8d68
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 5 01:07:16 2025 +0200
cmake: Make CMake toolchain script arch-agnostic
Rename the toolchain script kallistios.toolchain.cmake, and move all
Dreamcast-specific stuff to the Platform/dreamcast.cmake file (renamed
to match $KOS_ARCH).
Rename the utility script dreamcast.cmake to kallistios.cmake, as it did
not contain anything Dreamcast specific. Also, it is no more included
from the toolchain script, which should do the bare minimum. Projects
that wish to use the KOS specific macros should include(kallistios) now.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 2 +-
utils/build_wrappers/kos-ccmake | 2 +-
utils/build_wrappers/kos-cmake | 2 +-
utils/cmake/Platform/{Dreamcast.cmake => dreamcast.cmake} | 5 +++++
utils/cmake/{dreamcast.cmake => kallistios.cmake} | 0
.../{dreamcast.toolchain.cmake => kallistios.toolchain.cmake} | 9 ++-------
6 files changed, 10 insertions(+), 10 deletions(-)
rename utils/cmake/Platform/{Dreamcast.cmake => dreamcast.cmake} (69%)
rename utils/cmake/{dreamcast.cmake => kallistios.cmake} (100%)
rename utils/cmake/{dreamcast.toolchain.cmake => kallistios.toolchain.cmake} (92%)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index e9cf952d..abfb4733 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -75,7 +75,7 @@ export DC_TOOLS_BASE="/opt/toolchains/dc/bin"
# Specifies the path to the toolchain file used to target
# KOS with the "cmake" build utility.
#
-export KOS_CMAKE_TOOLCHAIN="${KOS_BASE}/utils/cmake/dreamcast.toolchain.cmake"
+export KOS_CMAKE_TOOLCHAIN="${KOS_BASE}/utils/cmake/kallistios.toolchain.cmake"
# Genromfs Utility Path
#
diff --git a/utils/build_wrappers/kos-ccmake b/utils/build_wrappers/kos-ccmake
index c63d2be4..e79d1208 100755
--- a/utils/build_wrappers/kos-ccmake
+++ b/utils/build_wrappers/kos-ccmake
@@ -13,6 +13,6 @@ if [ -z "$(which ccmake)" ]; then
fi
ccmake \
- -DCMAKE_TOOLCHAIN_FILE="${KOS_BASE}/utils/cmake/${KOS_ARCH}.toolchain.cmake" \
+ -DCMAKE_TOOLCHAIN_FILE="${KOS_BASE}/utils/cmake/kallistios.toolchain.cmake" \
"$@"
diff --git a/utils/build_wrappers/kos-cmake b/utils/build_wrappers/kos-cmake
index 8db8c946..1603e15c 100755
--- a/utils/build_wrappers/kos-cmake
+++ b/utils/build_wrappers/kos-cmake
@@ -8,6 +8,6 @@ if [ -z "${KOS_BASE}" ]; then
fi
cmake \
- -DCMAKE_TOOLCHAIN_FILE="${KOS_BASE}/utils/cmake/${KOS_ARCH}.toolchain.cmake" \
+ -DCMAKE_TOOLCHAIN_FILE="${KOS_BASE}/utils/cmake/kallistios.toolchain.cmake" \
"$@"
diff --git a/utils/cmake/Platform/Dreamcast.cmake b/utils/cmake/Platform/dreamcast.cmake
similarity index 69%
rename from utils/cmake/Platform/Dreamcast.cmake
rename to utils/cmake/Platform/dreamcast.cmake
index 87e31a20..530369a7 100644
--- a/utils/cmake/Platform/Dreamcast.cmake
+++ b/utils/cmake/Platform/dreamcast.cmake
@@ -7,3 +7,8 @@ set(CMAKE_EXECUTABLE_SUFFIX .elf)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Install prefix" FORCE)
endif()
+
+set(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_SYSTEM_PROCESSOR SH4)
+set(CMAKE_SIZEOF_VOID_P 4)
+set(PLATFORM_DREAMCAST TRUE)
diff --git a/utils/cmake/dreamcast.cmake b/utils/cmake/kallistios.cmake
similarity index 100%
rename from utils/cmake/dreamcast.cmake
rename to utils/cmake/kallistios.cmake
diff --git a/utils/cmake/dreamcast.toolchain.cmake b/utils/cmake/kallistios.toolchain.cmake
similarity index 92%
rename from utils/cmake/dreamcast.toolchain.cmake
rename to utils/cmake/kallistios.toolchain.cmake
index 4ff699b6..b7e008c0 100644
--- a/utils/cmake/dreamcast.toolchain.cmake
+++ b/utils/cmake/kallistios.toolchain.cmake
@@ -7,7 +7,7 @@
# This file is to be passed to CMake when compiling a regular CMake project
# to cross-compile for the Dreamcast, using the KOS environment and settings.
#
-# cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=${KOS_BASE}/kos/utils/cmake/dreamcast.toolchain.cmake
+# cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=${KOS_BASE}/kos/utils/cmake/kallistios.toolchain.cmake
#
# or alternatively:
#
@@ -47,11 +47,7 @@ set(KOS_ADDONS ${KOS_BASE}/addons)
list(APPEND CMAKE_MODULE_PATH $ENV{KOS_BASE}/utils/cmake)
##### Configure CMake System #####
-set(CMAKE_SYSTEM_NAME Dreamcast)
-set(CMAKE_SYSTEM_VERSION 1)
-set(CMAKE_SYSTEM_PROCESSOR SH4)
-set(CMAKE_SIZEOF_VOID_P 4)
-set(PLATFORM_DREAMCAST TRUE)
+set(CMAKE_SYSTEM_NAME ${KOS_ARCH})
##### Configure Cross-Compiler #####
set(CMAKE_CROSSCOMPILING TRUE)
@@ -90,4 +86,3 @@ endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR ${KOS_ADDONS}/lib/${KOS_ARCH})
endif()
-include("${KOS_BASE}/utils/cmake/dreamcast.cmake")
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-06 13:05:41
|
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 0d611105f71621c9688172ca2988c77065c089c8 (commit)
from 412d64c645f788feed54dd2c1f205b307cae22e9 (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 0d611105f71621c9688172ca2988c77065c089c8
Author: QuzarDC <qu...@co...>
Date: Mon Aug 4 18:43:50 2025 -0400
Adjust dbglog usage in examples.
After #1118 some examples became completely silent by default as they
were written presuming dbglog output set to maximum all the time.
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/cdrom/stream/cd-stream-test.c | 4 ++--
.../filesystem/sd/speedtest/sd-speedtest.c | 24 ++++++++++----------
examples/dreamcast/g1ata/atatest/atatest.c | 26 +++++++++++-----------
.../dreamcast/gldc/benchmarks/quadmark/quadmark.c | 2 +-
.../dreamcast/gldc/benchmarks/trimark/trimark.c | 2 +-
.../gldc/benchmarks/tristripmark/tristripmark.c | 2 +-
.../dreamcast/kgl/benchmarks/quadmark/quadmark.c | 2 +-
.../dreamcast/kgl/benchmarks/trimark/trimark.c | 2 +-
.../kgl/benchmarks/tristripmark/tristripmark.c | 2 +-
examples/dreamcast/library/library-test.c | 14 ++++++------
.../loadable-dependence/library-dependence.c | 8 +++----
.../library/loadable-dependent/library-dependent.c | 6 ++---
.../dreamcast/parallax/delay_cube/delay_cube.c | 2 +-
examples/dreamcast/parallax/rotocube/rotocube.c | 2 +-
examples/dreamcast/parallax/serpent_dma/serpent.c | 2 +-
examples/dreamcast/pvr/pvrmark/pvrmark.c | 2 +-
.../dreamcast/pvr/pvrmark_strips/pvrmark_strips.c | 2 +-
.../pvrmark_strips_direct/pvrmark_strips_direct.c | 2 +-
18 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/examples/dreamcast/cdrom/stream/cd-stream-test.c b/examples/dreamcast/cdrom/stream/cd-stream-test.c
index 7a9e83bb..12b9846e 100644
--- a/examples/dreamcast/cdrom/stream/cd-stream-test.c
+++ b/examples/dreamcast/cdrom/stream/cd-stream-test.c
@@ -60,7 +60,7 @@ static int cd_stream_test(uint32_t lba, uint8_t *buffer, size_t size, int mode)
size_t cb_count = 0;
char *stream_name = (mode == CDROM_READ_PIO ? "PIO" : "DMA");
- dbglog(DBG_DEBUG, "Start %s stream.\n", stream_name);
+ dbglog(DBG_INFO, "Start %s stream.\n", stream_name);
rs = cdrom_stream_start(lba, size / 2048, mode);
if (rs != ERR_OK) {
@@ -112,7 +112,7 @@ static int cd_stream_test(uint32_t lba, uint8_t *buffer, size_t size, int mode)
return -1;
}
- dbglog(DBG_DEBUG, "%s transfer is done.\n", stream_name);
+ dbglog(DBG_INFO, "%s transfer is done.\n", stream_name);
return 0;
}
diff --git a/examples/dreamcast/filesystem/sd/speedtest/sd-speedtest.c b/examples/dreamcast/filesystem/sd/speedtest/sd-speedtest.c
index f2489049..318d0cc3 100644
--- a/examples/dreamcast/filesystem/sd/speedtest/sd-speedtest.c
+++ b/examples/dreamcast/filesystem/sd/speedtest/sd-speedtest.c
@@ -68,14 +68,14 @@ static int run_speed_test(sd_interface_t interface, bool check_crc) {
const char *interface_name = (interface == SD_IF_SCI) ? "SCI-SPI" : "SCIF-SPI";
while(sd_init_ex(¶ms)) {
- dbglog(DBG_DEBUG, "Could not initialize the SD card on %s interface.\n", interface_name);
+ dbglog(DBG_ERROR, "Could not initialize the SD card on %s interface.\n", interface_name);
return -1;
}
/* Grab the block device for the first partition on the SD card. Note that
you must have the SD card formatted with an MBR partitioning scheme. */
if(sd_blockdev_for_partition(0, &sd_dev, &pt)) {
- dbglog(DBG_DEBUG, "Could not find the first partition on the SD card!\n");
+ dbglog(DBG_ERROR, "Could not find the first partition on the SD card!\n");
sd_shutdown();
return -1;
}
@@ -84,7 +84,7 @@ static int run_speed_test(sd_interface_t interface, bool check_crc) {
begin = timer_ms_gettime64();
if(sd_dev.read_blocks(&sd_dev, 0, TEST_BLOCK_COUNT, tbuf)) {
- dbglog(DBG_DEBUG, "couldn't read block: %s\n", strerror(errno));
+ dbglog(DBG_ERROR, "couldn't read block: %s\n", strerror(errno));
sd_shutdown();
return -1;
}
@@ -96,7 +96,7 @@ static int run_speed_test(sd_interface_t interface, bool check_crc) {
average = sum / 10;
- dbglog(DBG_DEBUG, "%s: read average took %llu ms (%.3f KB/sec)\n",
+ dbglog(DBG_INFO, "%s: read average took %llu ms (%.3f KB/sec)\n",
interface_name, average, (512 * TEST_BLOCK_COUNT) / ((double)average));
sd_shutdown();
@@ -106,27 +106,27 @@ static int run_speed_test(sd_interface_t interface, bool check_crc) {
int main(int argc, char *argv[]) {
// dbgio_dev_select("fb");
- dbglog(DBG_DEBUG, "Starting SD card speed tests\n");
+ dbglog(DBG_INFO, "Starting SD card speed tests\n");
- dbglog(DBG_DEBUG, "Testing SCI-SPI interface with CRC disabled\n");
+ dbglog(DBG_INFO, "Testing SCI-SPI interface with CRC disabled\n");
if (run_speed_test(SD_IF_SCI, false) == 0) {
- dbglog(DBG_DEBUG, "Testing SCI-SPI interface with CRC enabled\n");
+ dbglog(DBG_INFO, "Testing SCI-SPI interface with CRC enabled\n");
run_speed_test(SD_IF_SCI, true);
}
else {
- dbglog(DBG_DEBUG, "Skipping SCI-SPI interface with CRC enabled\n");
+ dbglog(DBG_INFO, "Skipping SCI-SPI interface with CRC enabled\n");
}
- dbglog(DBG_DEBUG, "Testing SCIF-SPI interface with CRC disabled\n");
+ dbglog(DBG_INFO, "Testing SCIF-SPI interface with CRC disabled\n");
if (run_speed_test(SD_IF_SCIF, false) == 0) {
- dbglog(DBG_DEBUG, "Testing SCIF-SPI interface with CRC enabled\n");
+ dbglog(DBG_INFO, "Testing SCIF-SPI interface with CRC enabled\n");
run_speed_test(SD_IF_SCIF, true);
}
else {
- dbglog(DBG_DEBUG, "Skipping SCIF-SPI interface with CRC enabled\n");
+ dbglog(DBG_INFO, "Skipping SCIF-SPI interface with CRC enabled\n");
}
- dbglog(DBG_DEBUG, "All tests completed\n");
+ dbglog(DBG_INFO, "All tests completed\n");
wait_exit();
return 0;
diff --git a/examples/dreamcast/g1ata/atatest/atatest.c b/examples/dreamcast/g1ata/atatest/atatest.c
index f3f94f5b..32296e13 100644
--- a/examples/dreamcast/g1ata/atatest/atatest.c
+++ b/examples/dreamcast/g1ata/atatest/atatest.c
@@ -30,63 +30,63 @@ int main(int argc, char *argv[]) {
uint64_t spio, epio, sdma, edma, timer;
uint8_t pt;
- dbglog(DBG_DEBUG, "Starting G1 ATA test program...\n");
+ dbglog(DBG_INFO, "Starting G1 ATA test program...\n");
g1_ata_init();
/* Grab the blockdevs that we'll use to access the partitions. */
- dbglog(DBG_DEBUG, "Looking for first partition...\n");
+ dbglog(DBG_INFO, "Looking for first partition...\n");
if(g1_ata_blockdev_for_partition(0, 0, &bd_pio, &pt)) {
- dbglog(DBG_DEBUG, "Couldn't get PIO blockdev for partition!\n");
+ dbglog(DBG_ERROR, "Couldn't get PIO blockdev for partition!\n");
return -1;
}
if(g1_ata_blockdev_for_partition(0, 1, &bd_dma, &pt)) {
- dbglog(DBG_DEBUG, "Couldn't get DMA blockdev for partition!\n");
+ dbglog(DBG_ERROR, "Couldn't get DMA blockdev for partition!\n");
return -1;
}
/* For some reason, the first DMA read takes a while... So, read one sector
and discard it so to not mess up the timing stuff below. */
if(bd_dma.read_blocks(&bd_dma, 1024, 1, tmp)) {
- dbglog(DBG_DEBUG, "Couldn't read block 1024 by dma: %s\n",
+ dbglog(DBG_ERROR, "Couldn't read block 1024 by dma: %s\n",
strerror(errno));
return -1;
}
/* Read blocks 0 - 1023 by DMA and print out timing information. */
- dbglog(DBG_DEBUG, "Reading 1024 blocks by DMA!\n");
+ dbglog(DBG_INFO, "Reading 1024 blocks by DMA!\n");
sdma = timer_ms_gettime64();
if(bd_dma.read_blocks(&bd_dma, 0, 1024, dmabuf)) {
- dbglog(DBG_DEBUG, "couldn't read block by DMA: %s\n", strerror(errno));
+ dbglog(DBG_ERROR, "couldn't read block by DMA: %s\n", strerror(errno));
return -1;
}
edma = timer_ms_gettime64();
timer = edma - sdma;
- dbglog(DBG_DEBUG, "DMA read took %llu ms (%f MB/sec)\n", timer,
+ dbglog(DBG_INFO, "DMA read took %llu ms (%f MB/sec)\n", timer,
(512 * 1024) / ((double)timer) / 1000.0);
/* Read blocks 0 - 1023 by PIO and print out timing information. */
- dbglog(DBG_DEBUG, "Reading 1024 blocks by PIO!\n");
+ dbglog(DBG_INFO, "Reading 1024 blocks by PIO!\n");
spio = timer_ms_gettime64();
if(bd_pio.read_blocks(&bd_pio, 0, 1024, piobuf)) {
- dbglog(DBG_DEBUG, "couldn't read block by PIO: %s\n", strerror(errno));
+ dbglog(DBG_ERROR, "couldn't read block by PIO: %s\n", strerror(errno));
return -1;
}
epio = timer_ms_gettime64();
timer = epio - spio;
- dbglog(DBG_DEBUG, "PIO read took %llu ms (%f MB/sec)\n", timer,
+ dbglog(DBG_INFO, "PIO read took %llu ms (%f MB/sec)\n", timer,
(512 * 1024) / ((double)timer) / 1000.0);
/* Check the buffers for consistency... */
if(memcmp(piobuf, dmabuf, 1024 * 512)) {
- dbglog(DBG_DEBUG, "Buffers do not match?!\n");
+ dbglog(DBG_INFO, "Buffers do not match?!\n");
}
else {
- dbglog(DBG_DEBUG, "Both buffers matched!\n");
+ dbglog(DBG_INFO, "Both buffers matched!\n");
}
/* Clean up... */
diff --git a/examples/dreamcast/gldc/benchmarks/quadmark/quadmark.c b/examples/dreamcast/gldc/benchmarks/quadmark/quadmark.c
index 492470b8..5a9c40ef 100644
--- a/examples/dreamcast/gldc/benchmarks/quadmark/quadmark.c
+++ b/examples/dreamcast/gldc/benchmarks/quadmark/quadmark.c
@@ -39,7 +39,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, stats.frame_rate);
}
diff --git a/examples/dreamcast/gldc/benchmarks/trimark/trimark.c b/examples/dreamcast/gldc/benchmarks/trimark/trimark.c
index 39cb93b6..85ea0e00 100644
--- a/examples/dreamcast/gldc/benchmarks/trimark/trimark.c
+++ b/examples/dreamcast/gldc/benchmarks/trimark/trimark.c
@@ -39,7 +39,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, stats.frame_rate);
}
diff --git a/examples/dreamcast/gldc/benchmarks/tristripmark/tristripmark.c b/examples/dreamcast/gldc/benchmarks/tristripmark/tristripmark.c
index fd524d4f..65de53d7 100644
--- a/examples/dreamcast/gldc/benchmarks/tristripmark/tristripmark.c
+++ b/examples/dreamcast/gldc/benchmarks/tristripmark/tristripmark.c
@@ -39,7 +39,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, stats.frame_rate);
}
diff --git a/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c b/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c
index 7c036316..65af5506 100644
--- a/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c
+++ b/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c
@@ -39,7 +39,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, (double)stats.frame_rate);
}
diff --git a/examples/dreamcast/kgl/benchmarks/trimark/trimark.c b/examples/dreamcast/kgl/benchmarks/trimark/trimark.c
index a27d36ee..c4aeb50a 100644
--- a/examples/dreamcast/kgl/benchmarks/trimark/trimark.c
+++ b/examples/dreamcast/kgl/benchmarks/trimark/trimark.c
@@ -39,7 +39,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, (double)stats.frame_rate);
}
diff --git a/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c b/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c
index 67aa529a..cd595491 100644
--- a/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c
+++ b/examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c
@@ -39,7 +39,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, (double)stats.frame_rate);
}
diff --git a/examples/dreamcast/library/library-test.c b/examples/dreamcast/library/library-test.c
index 680db5c1..d245b43c 100644
--- a/examples/dreamcast/library/library-test.c
+++ b/examples/dreamcast/library/library-test.c
@@ -42,7 +42,7 @@ static void __attribute__((__noreturn__)) wait_exit(void) {
maple_device_t *dev;
cont_state_t *state;
- dbglog(DBG_DEBUG, "Press any button to exit.\n");
+ dbglog(DBG_INFO, "Press any button to exit.\n");
for(;;) {
dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
@@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
library_test_func2_t library_test_func2;
// dbgio_dev_select("fb");
- dbglog(DBG_DEBUG, "Initializing exports.\n");
+ dbglog(DBG_INFO, "Initializing exports.\n");
if(nmmgr_handler_add(&st_libtest.nmmgr) < 0) {
dbglog(DBG_ERROR, "Failed.");
@@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
return -1;
}
- dbglog(DBG_DEBUG, "Loading /rd/library-dependence.klf\n");
+ dbglog(DBG_INFO, "Loading /rd/library-dependence.klf\n");
lib_dependence = library_open("dependence", "/rd/library-dependence.klf");
if (lib_dependence == NULL) {
@@ -87,11 +87,11 @@ int main(int argc, char *argv[]) {
ver = library_get_version(lib_dependence);
- dbglog(DBG_DEBUG, "Successfully loaded: %s v%ld.%ld.%ld\n",
+ dbglog(DBG_INFO, "Successfully loaded: %s v%ld.%ld.%ld\n",
library_get_name(lib_dependence),
(ver >> 16) & 0xff, (ver >> 8) & 0xff, ver & 0xff);
- dbglog(DBG_DEBUG, "Loading /rd/library-dependence.klf\n");
+ dbglog(DBG_INFO, "Loading /rd/library-dependence.klf\n");
lib_dependent = library_open("dependent", "/rd/library-dependent.klf");
if (lib_dependence == NULL) {
@@ -102,11 +102,11 @@ int main(int argc, char *argv[]) {
ver = library_get_version(lib_dependent);
- dbglog(DBG_DEBUG, "Successfully loaded: %s v%ld.%ld.%ld\n",
+ dbglog(DBG_INFO, "Successfully loaded: %s v%ld.%ld.%ld\n",
library_get_name(lib_dependent),
(ver >> 16) & 0xff, (ver >> 8) & 0xff, ver & 0xff);
- dbglog(DBG_DEBUG, "Testing exports runtime on host\n");
+ dbglog(DBG_INFO, "Testing exports runtime on host\n");
sym = export_lookup("library_test_func");
diff --git a/examples/dreamcast/library/loadable-dependence/library-dependence.c b/examples/dreamcast/library/loadable-dependence/library-dependence.c
index 28dd0b76..4b22ed71 100644
--- a/examples/dreamcast/library/loadable-dependence/library-dependence.c
+++ b/examples/dreamcast/library/loadable-dependence/library-dependence.c
@@ -35,21 +35,21 @@ uint32_t lib_get_version() {
}
int lib_open(klibrary_t *lib) {
- dbglog(DBG_DEBUG, "Library \"%s\" opened.\n", lib_get_name());
+ dbglog(DBG_INFO, "Library \"%s\" opened.\n", lib_get_name());
return nmmgr_handler_add(&library_hnd.nmmgr);
}
int lib_close(klibrary_t *lib) {
- dbglog(DBG_DEBUG, "Library \"%s\" closed.\n", lib_get_name());
+ dbglog(DBG_INFO, "Library \"%s\" closed.\n", lib_get_name());
return nmmgr_handler_remove(&library_hnd.nmmgr);
}
/* Exported functions */
int library_test_func(int arg) {
- dbglog(DBG_DEBUG, "Library \"%s\" test int: %d\n", lib_get_name(), arg);
+ dbglog(DBG_INFO, "Library \"%s\" test int: %d\n", lib_get_name(), arg);
return 0;
}
void library_test_func2(const char *arg) {
- dbglog(DBG_DEBUG, "Library \"%s\" test char: %s\n", lib_get_name(), arg);
+ dbglog(DBG_INFO, "Library \"%s\" test char: %s\n", lib_get_name(), arg);
}
diff --git a/examples/dreamcast/library/loadable-dependent/library-dependent.c b/examples/dreamcast/library/loadable-dependent/library-dependent.c
index e2fad53a..0b1e4b51 100644
--- a/examples/dreamcast/library/loadable-dependent/library-dependent.c
+++ b/examples/dreamcast/library/loadable-dependent/library-dependent.c
@@ -27,7 +27,7 @@ uint32_t lib_get_version() {
int lib_open(klibrary_t *lib) {
uint8_t output[16];
- dbglog(DBG_DEBUG, "Library \"%s\" opened.\n", lib_get_name());
+ dbglog(DBG_INFO, "Library \"%s\" opened.\n", lib_get_name());
// Test exports from dependence library
library_test_func(333);
@@ -35,7 +35,7 @@ int lib_open(klibrary_t *lib) {
// Test libkosutils from dependence library
kos_md5((const uint8_t *)lib_get_name(), strlen(lib_get_name()), output);
- dbglog(DBG_DEBUG, "MD5 of \"%s\": %02X%02X%02X%02X...\n",
+ dbglog(DBG_INFO, "MD5 of \"%s\": %02X%02X%02X%02X...\n",
lib_get_name(), output[0], output[1], output[2], output[3]);
// Test host exported newlib
@@ -47,6 +47,6 @@ int lib_open(klibrary_t *lib) {
}
int lib_close(klibrary_t *lib) {
- dbglog(DBG_DEBUG, "Library \"%s\" closed.\n", lib_get_name());
+ dbglog(DBG_INFO, "Library \"%s\" closed.\n", lib_get_name());
return 0;
}
diff --git a/examples/dreamcast/parallax/delay_cube/delay_cube.c b/examples/dreamcast/parallax/delay_cube/delay_cube.c
index 9b34fcfa..d0b2c58d 100644
--- a/examples/dreamcast/parallax/delay_cube/delay_cube.c
+++ b/examples/dreamcast/parallax/delay_cube/delay_cube.c
@@ -185,7 +185,7 @@ int main(int argc, char **argv) {
// You have to keep a watch on these, especially the vertex used
// for really poly intensive effects.
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d vblanks, frame rate ~%f fps, max vertex used %d bytes\n",
+ dbglog(DBG_INFO, "3D Stats: %d vblanks, frame rate ~%f fps, max vertex used %d bytes\n",
stats.vbl_count, (double)stats.frame_rate, stats.vtx_buffer_used_max);
return 0;
diff --git a/examples/dreamcast/parallax/rotocube/rotocube.c b/examples/dreamcast/parallax/rotocube/rotocube.c
index 10b54ff9..3b54afaa 100644
--- a/examples/dreamcast/parallax/rotocube/rotocube.c
+++ b/examples/dreamcast/parallax/rotocube/rotocube.c
@@ -178,7 +178,7 @@ int main(int argc, char **argv) {
// You have to keep a watch on these, especially the vertex used
// for really poly intensive effects.
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d vblanks, frame rate ~%f fps, max vertex used %d bytes\n",
+ dbglog(DBG_INFO, "3D Stats: %d vblanks, frame rate ~%f fps, max vertex used %d bytes\n",
stats.vbl_count, (double)stats.frame_rate, stats.vtx_buffer_used_max);
return 0;
diff --git a/examples/dreamcast/parallax/serpent_dma/serpent.c b/examples/dreamcast/parallax/serpent_dma/serpent.c
index 2ad8f68b..a1d281c7 100644
--- a/examples/dreamcast/parallax/serpent_dma/serpent.c
+++ b/examples/dreamcast/parallax/serpent_dma/serpent.c
@@ -295,7 +295,7 @@ int main(int argc, char **argv) {
do_sphere_test();
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %u vblanks, frame rate ~%f fps, max vertex used %u bytes\n",
+ dbglog(DBG_INFO, "3D Stats: %u vblanks, frame rate ~%f fps, max vertex used %u bytes\n",
stats.vbl_count, stats.frame_rate, stats.vtx_buffer_used_max);
free(big_sphere.data);
diff --git a/examples/dreamcast/pvr/pvrmark/pvrmark.c b/examples/dreamcast/pvr/pvrmark/pvrmark.c
index d5f8c32a..200c6add 100644
--- a/examples/dreamcast/pvr/pvrmark/pvrmark.c
+++ b/examples/dreamcast/pvr/pvrmark/pvrmark.c
@@ -33,7 +33,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, (double)stats.frame_rate);
}
diff --git a/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c b/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c
index d24d61d4..1a58436a 100644
--- a/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c
+++ b/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c
@@ -33,7 +33,7 @@ void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d VBLs, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d VBLs, frame rate ~%f fps\n",
stats.vbl_count, (double)stats.frame_rate);
}
diff --git a/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c b/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c
index 46de7984..3cf1bc60 100644
--- a/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c
+++ b/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c
@@ -42,7 +42,7 @@ static void stats(void) {
pvr_stats_t stats;
pvr_get_stats(&stats);
- dbglog(DBG_DEBUG, "3D Stats: %d frames, frame rate ~%f fps\n",
+ dbglog(DBG_INFO, "3D Stats: %d frames, frame rate ~%f fps\n",
stats.vbl_count, (double)stats.frame_rate);
}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-06 12:47:26
|
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 412d64c645f788feed54dd2c1f205b307cae22e9 (commit)
via f43d4bd83719f02e9eb85815a26893a953751a67 (commit)
via 28d6de2e3863d68424875b8272997d1c4b667b40 (commit)
via 99b905a977d5949f5cf7ff890e55a365f6dfd0cc (commit)
from f7ee03a8533adbba8dd6f03cc458a28b69802a89 (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 412d64c645f788feed54dd2c1f205b307cae22e9
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 18:30:38 2025 -0400
Remove trailing whitespaces.
commit f43d4bd83719f02e9eb85815a26893a953751a67
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 10:22:59 2025 -0400
Replace windows-style EOL with unix-style.
commit 28d6de2e3863d68424875b8272997d1c4b667b40
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 10:17:34 2025 -0400
Replace extraneous tabs with appropriate numbers of spaces.
commit 99b905a977d5949f5cf7ff890e55a365f6dfd0cc
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 10:07:26 2025 -0400
Remove extraneous spaces between conditionals and parens.
-----------------------------------------------------------------------
Summary of changes:
addons/libkosutils/netcfg.c | 2 +-
addons/libnavi/navi_ide.c | 4 +-
kernel/arch/dreamcast/fs/fs_iso9660.c | 4 +-
kernel/arch/dreamcast/fs/fs_vmu.c | 4 +-
kernel/arch/dreamcast/fs/vmufs.c | 2 +-
kernel/arch/dreamcast/hardware/asic.c | 10 +-
kernel/arch/dreamcast/hardware/flashrom.c | 2 +-
kernel/arch/dreamcast/hardware/g2dma.c | 22 +-
kernel/arch/dreamcast/hardware/hardware.c | 8 +-
kernel/arch/dreamcast/hardware/maple/keyboard.c | 4 +-
kernel/arch/dreamcast/hardware/maple/maple_irq.c | 10 +-
kernel/arch/dreamcast/hardware/maple/vmu.c | 6 +-
kernel/arch/dreamcast/hardware/modem/modem.c | 8 +-
kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 2 +-
kernel/arch/dreamcast/hardware/pvr/pvr_prim.c | 16 +-
kernel/arch/dreamcast/hardware/sci.c | 6 +-
kernel/arch/dreamcast/hardware/sd.c | 6 +-
kernel/arch/dreamcast/hardware/spu.c | 2 +-
kernel/arch/dreamcast/hardware/sq.c | 18 +-
kernel/arch/dreamcast/hardware/video.c | 26 +-
kernel/arch/dreamcast/include/arch/dmac.h | 2 +-
kernel/arch/dreamcast/include/arch/memory.h | 730 +++++++++++------------
kernel/arch/dreamcast/include/arch/rtc.h | 2 +-
kernel/arch/dreamcast/include/arch/timer.h | 2 +-
kernel/arch/dreamcast/include/arch/tls_static.h | 6 +-
kernel/arch/dreamcast/include/arch/trap.h | 6 +-
kernel/arch/dreamcast/include/arch/wdt.h | 36 +-
kernel/arch/dreamcast/include/dc/asic.h | 2 +-
kernel/arch/dreamcast/include/dc/biosfont.h | 28 +-
kernel/arch/dreamcast/include/dc/fifo.h | 12 +-
kernel/arch/dreamcast/include/dc/math.h | 2 +-
kernel/arch/dreamcast/include/dc/matrix.h | 4 +-
kernel/arch/dreamcast/include/dc/minifont.h | 4 +-
kernel/arch/dreamcast/include/dc/perf_monitor.h | 2 +-
kernel/arch/dreamcast/include/dc/perfctr.h | 34 +-
kernel/arch/dreamcast/include/dc/pvr.h | 30 +-
kernel/arch/dreamcast/include/dc/sd.h | 2 +-
kernel/arch/dreamcast/include/dc/sound/sfxmgr.h | 12 +-
kernel/arch/dreamcast/include/dc/sound/sound.h | 6 +-
kernel/arch/dreamcast/include/dc/vmu_fb.h | 2 +-
kernel/arch/dreamcast/kernel/irq.c | 2 +-
kernel/arch/dreamcast/kernel/perfctr.c | 2 +-
kernel/arch/dreamcast/kernel/timer.c | 2 +-
kernel/arch/dreamcast/sound/arm/aica.c | 4 +-
kernel/arch/dreamcast/sound/snd_sfxmgr.c | 18 +-
kernel/arch/dreamcast/util/screenshot.c | 6 +-
kernel/arch/dreamcast/util/vmu_fb.c | 6 +-
kernel/arch/dreamcast/util/vmu_printf.c | 32 +-
kernel/exports/exports.c | 2 +-
kernel/fs/fs_dev.c | 8 +-
kernel/fs/fs_null.c | 2 +-
kernel/fs/fs_pty.c | 2 +-
kernel/fs/fs_utils.c | 6 +-
kernel/libc/c11/thrd_join.c | 2 +-
kernel/thread/oneshot_timer.c | 4 +-
kernel/thread/worker.c | 10 +-
56 files changed, 597 insertions(+), 597 deletions(-)
diff --git a/addons/libkosutils/netcfg.c b/addons/libkosutils/netcfg.c
index 3d5cd963..df38d593 100644
--- a/addons/libkosutils/netcfg.c
+++ b/addons/libkosutils/netcfg.c
@@ -333,7 +333,7 @@ int netcfg_save_to(const char * fn, const netcfg_t * cfg) {
#define WRITESTR(fmt, data) \
sprintf(buf, fmt, data); \
- if (fwrite(buf, strlen(buf), 1, f) != 1) \
+ if(fwrite(buf, strlen(buf), 1, f) != 1) \
goto error;
WRITESTR("driver=%s\n", cfg->driver);
diff --git a/addons/libnavi/navi_ide.c b/addons/libnavi/navi_ide.c
index 4e1185ca..7961e0f4 100644
--- a/addons/libnavi/navi_ide.c
+++ b/addons/libnavi/navi_ide.c
@@ -141,7 +141,7 @@ static int ide_read_chs(uint32 cyl, uint32 head, uint32 sector, uint32 numsects,
wait_data(); /* wait for data to be read */
for(o = 0; o < 256; o++) {
- /*if (inp(0x1f7) & 1) {
+ /*if(inp(0x1f7) & 1) {
printf("as of %d, error code is %x/%x\n", o, inp(0x1f7), inp(0x1f1));
return -1;
} */
@@ -175,7 +175,7 @@ static int ide_write_chs(uint32 cyl, uint32 head, uint32 sector, uint32 numsects
wait_data(); /* wait for data to be ready */
for(o = 0; o < 256; o++) {
- /* if (inp(0x1f7) & 1) {
+ /* if(inp(0x1f7) & 1) {
printf("as of %d, error code is %x/%x\n", o, inp(0x1f7), inp(0x1f1));
return -1;
} */
diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c
index d67e465f..7c745482 100644
--- a/kernel/arch/dreamcast/fs/fs_iso9660.c
+++ b/kernel/arch/dreamcast/fs/fs_iso9660.c
@@ -1103,7 +1103,7 @@ static int iso_stat(vfs_handler_t *vfs, const char *path, struct stat *st,
mode_t md;
iso_dirent_t *de;
size_t len = strlen(path);
-
+
(void)vfs;
(void)flag;
@@ -1134,7 +1134,7 @@ static int iso_stat(vfs_handler_t *vfs, const char *path, struct stat *st,
errno = ENOENT;
return -1;
}
-
+
memset(st, 0, sizeof(struct stat));
st->st_dev = (dev_t)('c' | ('d' << 8));
st->st_mode = md | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH;
diff --git a/kernel/arch/dreamcast/fs/fs_vmu.c b/kernel/arch/dreamcast/fs/fs_vmu.c
index 54b97c1f..5c0ac872 100644
--- a/kernel/arch/dreamcast/fs/fs_vmu.c
+++ b/kernel/arch/dreamcast/fs/fs_vmu.c
@@ -415,8 +415,8 @@ static int vmu_close(void * hnd) {
case VMU_FILE:
if((fh->mode & O_MODE_MASK) == O_WRONLY ||
(fh->mode & O_MODE_MASK) == O_RDWR) {
- if ((st = vmu_write_close(hnd))) {
- if (st == -7)
+ if((st = vmu_write_close(hnd))) {
+ if(st == -7)
errno = ENOSPC;
else
errno = EIO;
diff --git a/kernel/arch/dreamcast/fs/vmufs.c b/kernel/arch/dreamcast/fs/vmufs.c
index f80b8613..d9e2a135 100644
--- a/kernel/arch/dreamcast/fs/vmufs.c
+++ b/kernel/arch/dreamcast/fs/vmufs.c
@@ -759,7 +759,7 @@ int vmufs_write(maple_device_t * dev, const char * fn, void * inbuf, int insize,
fnlength = strlen(fn);
fnlength = fnlength > 12 ? 12 : fnlength;
memcpy(nd.filename, fn, fnlength);
- if (fnlength < 12) {
+ if(fnlength < 12) {
memset(nd.filename + fnlength, '\0', 12 - fnlength);
}
diff --git a/kernel/arch/dreamcast/hardware/asic.c b/kernel/arch/dreamcast/hardware/asic.c
index 30c610e4..725ff3ae 100644
--- a/kernel/arch/dreamcast/hardware/asic.c
+++ b/kernel/arch/dreamcast/hardware/asic.c
@@ -255,14 +255,14 @@ static void asic_threaded_irq(void *data) {
thdata->hdl(thdata->source, thdata->data);
- if (thdata->unmask)
+ if(thdata->unmask)
thdata->unmask(thdata->source);
}
static void asic_thirq_dispatch(uint32_t source, void *data) {
struct asic_thdata *thdata = data;
- if (thdata->ack_and_mask)
+ if(thdata->ack_and_mask)
thdata->ack_and_mask(source);
thdata->source = source;
@@ -280,7 +280,7 @@ int asic_evt_request_threaded_handler(uint16_t code, asic_evt_handler hnd,
kthread_t *thd;
thdata = malloc(sizeof(*thdata));
- if (!thdata)
+ if(!thdata)
return -1; /* TODO: What return code? */
thdata->hdl = hnd;
@@ -291,7 +291,7 @@ int asic_evt_request_threaded_handler(uint16_t code, asic_evt_handler hnd,
flags = irq_disable();
thdata->worker = thd_worker_create(asic_threaded_irq, thdata);
- if (!thdata->worker) {
+ if(!thdata->worker) {
irq_restore(flags);
free(thdata);
return -1; /* TODO: What return code? */
@@ -325,7 +325,7 @@ void asic_evt_remove_handler(uint16_t code)
entry = asic_evt_handlers[evtreg][evt];
asic_evt_set_handler(code, NULL, NULL);
- if (entry.hdl == asic_thirq_dispatch) {
+ if(entry.hdl == asic_thirq_dispatch) {
thdata = entry.data;
thd_worker_destroy(thdata->worker);
diff --git a/kernel/arch/dreamcast/hardware/flashrom.c b/kernel/arch/dreamcast/hardware/flashrom.c
index 764e4327..19a66f2a 100644
--- a/kernel/arch/dreamcast/hardware/flashrom.c
+++ b/kernel/arch/dreamcast/hardware/flashrom.c
@@ -28,7 +28,7 @@ static void strcpy_no_term(char *dest, const char *src, size_t destsize) {
srclength = strlen(src);
srclength = srclength > destsize ? destsize : srclength;
memcpy(dest, src, srclength);
- if (srclength < destsize) {
+ if(srclength < destsize) {
memset(dest + srclength, '\0', destsize - srclength);
}
}
diff --git a/kernel/arch/dreamcast/hardware/g2dma.c b/kernel/arch/dreamcast/hardware/g2dma.c
index a70a83af..6d1120e2 100644
--- a/kernel/arch/dreamcast/hardware/g2dma.c
+++ b/kernel/arch/dreamcast/hardware/g2dma.c
@@ -51,11 +51,11 @@ static int dma_init;
#define G2_DMA_REG_BASE 0xa05f7800
static volatile g2_dma_reg_t * const g2_dma = (g2_dma_reg_t *)G2_DMA_REG_BASE;
-/*
+/*
List of possible initiation triggers values to assign to trigger_select:
CPU_TRIGGER: Software-driven. (Setting enable and start to 1)
HARDWARE_TRIGGER: Via AICA (DMA0) or expansion device.
- INTERRUPT_TRIGGER: Based on interrupt signals.
+ INTERRUPT_TRIGGER: Based on interrupt signals.
*/
#define CPU_TRIGGER 0
#define HARDWARE_TRIGGER 1
@@ -72,9 +72,9 @@ static volatile g2_dma_reg_t * const g2_dma = (g2_dma_reg_t *)G2_DMA_REG_BASE;
#define DMA_SUSPEND_ENABLED 0x00000004
#define DMA_SUSPEND_DISABLED 0x00000000
-/*
- For sh4 and g2bus addresses, ensure bits 31-29 & 4-0 are '0' to avoid
- illegal interrupts. Only bits 28-5 are used for valid addresses.
+/*
+ For sh4 and g2bus addresses, ensure bits 31-29 & 4-0 are '0' to avoid
+ illegal interrupts. Only bits 28-5 are used for valid addresses.
*/
#define MASK_ADDRESS 0x1fffffe0
@@ -88,9 +88,9 @@ static volatile g2_dma_reg_t * const g2_dma = (g2_dma_reg_t *)G2_DMA_REG_BASE;
#define PRESERVE_ENABLED 0x00000000
#define RESET_ENABLED 0x80000000
-/*
+/*
Specifies system memory address range for G2-DMA across channels 0-3.
- If a DMA transfer is generated outside of this range, an overrun error
+ If a DMA transfer is generated outside of this range, an overrun error
occurs.
Previous range (0x4659404f):
@@ -115,12 +115,12 @@ static volatile g2_dma_reg_t * const g2_dma = (g2_dma_reg_t *)G2_DMA_REG_BASE;
#define DISABLE_SYS_MEM_PROTECTION (SYS_MEM_SECURITY_CODE << 16 | 0x007F)
#define ENABLE_SYS_MEM_PROTECTION (SYS_MEM_SECURITY_CODE << 16 | 0x7F00)
-/*
- Set the DS# (Data Strobe) timeout to 27 clock cycles for the external DMA.
+/*
+ Set the DS# (Data Strobe) timeout to 27 clock cycles for the external DMA.
If data isn't ready for latching by this time, an interrupt will be
triggered.
-
- Not sure why its 27 but can be changed later. Default value
+
+ Not sure why its 27 but can be changed later. Default value
is 1023 cycles (0x3ff).
*/
#define DS_CYCLE_OVERRIDE 27
diff --git a/kernel/arch/dreamcast/hardware/hardware.c b/kernel/arch/dreamcast/hardware/hardware.c
index d97130f8..9b1ad726 100644
--- a/kernel/arch/dreamcast/hardware/hardware.c
+++ b/kernel/arch/dreamcast/hardware/hardware.c
@@ -66,7 +66,7 @@ int hardware_periph_init(void) {
spu_init();
g2_dma_init();
- if (!KOS_PLATFORM_IS_NAOMI) {
+ if(!KOS_PLATFORM_IS_NAOMI) {
/* Init CD-ROM.. NOTE: NO GD-ROM SUPPORT. ONLY CDs/CDRs. */
KOS_INIT_FLAG_CALL(cdrom_init);
}
@@ -77,7 +77,7 @@ int hardware_periph_init(void) {
/* Init video */
vid_init(DEFAULT_VID_MODE, DEFAULT_PIXEL_MODE);
- if (!KOS_PLATFORM_IS_NAOMI)
+ if(!KOS_PLATFORM_IS_NAOMI)
KOS_INIT_FLAG_CALL(bba_la_init);
initted = 2;
@@ -90,10 +90,10 @@ KOS_INIT_FLAG_WEAK(maple_shutdown, true);
void hardware_shutdown(void) {
switch(initted) {
case 2:
- if (!KOS_PLATFORM_IS_NAOMI)
+ if(!KOS_PLATFORM_IS_NAOMI)
KOS_INIT_FLAG_CALL(bba_la_shutdown);
KOS_INIT_FLAG_CALL(maple_shutdown);
- if (!KOS_PLATFORM_IS_NAOMI)
+ if(!KOS_PLATFORM_IS_NAOMI)
KOS_INIT_FLAG_CALL(cdrom_shutdown);
g2_dma_shutdown();
spu_shutdown();
diff --git a/kernel/arch/dreamcast/hardware/maple/keyboard.c b/kernel/arch/dreamcast/hardware/maple/keyboard.c
index 13d3d409..8599f774 100644
--- a/kernel/arch/dreamcast/hardware/maple/keyboard.c
+++ b/kernel/arch/dreamcast/hardware/maple/keyboard.c
@@ -49,7 +49,7 @@ typedef struct kbd_state_private {
kbd_leds_t leds; /**< \brief Persistent LED state for toggles */
struct {
- kbd_key_t key; /**< \brief Key that is repeating. */
+ kbd_key_t key; /**< \brief Key that is repeating. */
uint64_t timeout; /**< \brief Time that the next repeat will trigger. */
} repeater;
} kbd_state_private_t;
@@ -651,7 +651,7 @@ static void kbd_check_poll(maple_frame_t *frm) {
}
// Sync persistent LED state to cond
- state->cond.leds = pstate->leds;
+ state->cond.leds = pstate->leds;
/* If the key hadn't been pressed. */
if(state->key_states[cond->keys[i]].value == KEY_STATE_CHANGED_DOWN) {
if(key != KBD_KEY_NONE) {
diff --git a/kernel/arch/dreamcast/hardware/maple/maple_irq.c b/kernel/arch/dreamcast/hardware/maple/maple_irq.c
index 0f116a4a..f5d02e41 100644
--- a/kernel/arch/dreamcast/hardware/maple/maple_irq.c
+++ b/kernel/arch/dreamcast/hardware/maple/maple_irq.c
@@ -64,7 +64,7 @@ static void vbl_chk_next_subdev(maple_state_t *state, maple_frame_t *frm, int p)
maple_device_t *dev = maple_enum_dev(p, 0);
int u;
- if (dev && dev->probe_mask) {
+ if(dev && dev->probe_mask) {
u = __builtin_ffs(dev->probe_mask);
dev->probe_mask &= ~(1 << (u - 1));
@@ -78,7 +78,7 @@ static void vbl_chk_next_subdev(maple_state_t *state, maple_frame_t *frm, int p)
static void vbl_dev_probed(int p, int u) {
maple_device_t *dev = maple_enum_dev(p, 0);
- if (dev)
+ if(dev)
dev->dev_mask |= 1 << (u - 1);
}
@@ -91,7 +91,7 @@ static void vbl_chk_subdevs(maple_state_t *state, int p, uint8 newmask) {
/* Disconnect any device that disappeared */
for(u = 1; u < MAPLE_UNIT_COUNT; u++) {
- if (dev->dev_mask & ~newmask & (1 << (u - 1))) {
+ if(dev->dev_mask & ~newmask & (1 << (u - 1))) {
vbl_chk_disconnect(state, p, u);
}
}
@@ -115,7 +115,7 @@ static void vbl_autodet_callback(maple_state_t *state, maple_frame_t *frm) {
maple_device_t *dev;
int p, u;
- if (irq_inside_int() && !malloc_irq_safe()) {
+ if(irq_inside_int() && !malloc_irq_safe()) {
/* We can't create or remove a device now. Fail silently as the device
* will be re-probed in the next loop of the periodic IRQ. */
maple_frame_unlock(frm);
@@ -200,7 +200,7 @@ static void vbl_autodetect(maple_state_t *state) {
state->detect_port_next, 0);
/* Move to the next device */
- if (queued) {
+ if(queued) {
state->detect_port_next++;
if(state->detect_port_next >= MAPLE_PORT_COUNT)
diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c
index 30420641..d95a392c 100644
--- a/kernel/arch/dreamcast/hardware/maple/vmu.c
+++ b/kernel/arch/dreamcast/hardware/maple/vmu.c
@@ -177,7 +177,7 @@ void vmu_set_buttons_enabled(int enable) {
}
/* Determine whether polling for button input is enabled or not by presence of periodic callback. */
-int vmu_get_buttons_enabled(void) {
+int vmu_get_buttons_enabled(void) {
return !!vmu_drv.periodic;
}
@@ -249,7 +249,7 @@ int vmu_set_custom_color(maple_device_t *dev, uint8_t red, uint8_t green, uint8_
int vmu_set_icon_shape(maple_device_t *dev, uint8_t icon_shape) {
vmu_root_t root;
- if (KOS_PLATFORM_IS_NAOMI)
+ if(KOS_PLATFORM_IS_NAOMI)
return -1;
if(icon_shape < BFONT_ICON_VMUICON || icon_shape > BFONT_ICON_EMBROIDERY)
@@ -351,7 +351,7 @@ int vmu_draw_lcd_rotated(maple_device_t *dev, const void *bitmap) {
uint32_t bitmap_inverted[48];
unsigned int i;
- for (i = 0; i < 48; i++) {
+ for(i = 0; i < 48; i++) {
bitmap_inverted[i] = bit_reverse(((uint32 *)bitmap)[47 - i]);
}
diff --git a/kernel/arch/dreamcast/hardware/modem/modem.c b/kernel/arch/dreamcast/hardware/modem/modem.c
index 90052809..940a02b2 100644
--- a/kernel/arch/dreamcast/hardware/modem/modem.c
+++ b/kernel/arch/dreamcast/hardware/modem/modem.c
@@ -744,8 +744,8 @@ void modem_disconnect(void) {
modemSetBits(REGLOC(0x15), 0x4); /* Set RREN */
/* Wait for a disconnection or a timeout */
- for (i = 0; i < 500; i++) {
- if (!(modemRead(REGLOC(0xF)) & 0x80))
+ for(i = 0; i < 500; i++) {
+ if(!(modemRead(REGLOC(0xF)) & 0x80))
break;
thd_sleep(10);
@@ -756,8 +756,8 @@ void modem_disconnect(void) {
modemWrite(REGLOC(0x12), 0xC0);
modemSetBits(REGLOC(0x15), 0x4); /* Set RREN */
- for (i = 0; i < 500; i++) {
- if (!(modemRead(REGLOC(0xF)) & 0x80) ||
+ for(i = 0; i < 500; i++) {
+ if(!(modemRead(REGLOC(0xF)) & 0x80) ||
modemRead(REGLOC(0x14)) == 0x96) {
break;
}
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c
index fe298e21..4bbcb747 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c
@@ -166,7 +166,7 @@ void pvr_int_handler(uint32 code, void *data) {
case ASIC_EVT_PVR_RENDERDONE_TSP:
//DBG(("irq_renderdone\n"));
pvr_state.render_busy = 0;
- if (!pvr_state.was_to_texture)
+ if(!pvr_state.was_to_texture)
pvr_state.render_completed = 1;
pvr_sync_stats(PVR_SYNC_RNDDONE);
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c
index a7460a4e..904c0511 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c
@@ -68,9 +68,9 @@ void pvr_poly_compile(pvr_poly_hdr_t *dst, const pvr_poly_cxt_t *src) {
}
else {
assert_msg(__builtin_popcount(src->txr.width) == 1
- && src->txr.width <= 1024, "Invalid texture U size");
+ && src->txr.width <= 1024, "Invalid texture U size");
assert_msg(__builtin_popcount(src->txr.height) == 1
- && src->txr.height <= 1024, "Invalid texture V size");
+ && src->txr.height <= 1024, "Invalid texture V size");
mode2 |= FIELD_PREP(PVR_TA_PM2_TXRALPHA, src->txr.alpha)
| FIELD_PREP(PVR_TA_PM2_UVFLIP, src->txr.uv_flip)
@@ -304,9 +304,9 @@ void pvr_sprite_compile(pvr_sprite_hdr_t *dst, const pvr_sprite_cxt_t *src) {
}
else {
assert_msg(__builtin_popcount(src->txr.width) == 1
- && src->txr.width <= 1024, "Invalid texture U size");
+ && src->txr.width <= 1024, "Invalid texture U size");
assert_msg(__builtin_popcount(src->txr.height) == 1
- && src->txr.height <= 1024, "Invalid texture V size");
+ && src->txr.height <= 1024, "Invalid texture V size");
mode2 |= FIELD_PREP(PVR_TA_PM2_TXRALPHA, src->txr.alpha)
| FIELD_PREP(PVR_TA_PM2_UVFLIP, src->txr.uv_flip)
@@ -393,9 +393,9 @@ void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src) {
}
else {
assert_msg(__builtin_popcount(src->txr.width) == 1
- && src->txr.width <= 1024, "Invalid texture U size");
+ && src->txr.width <= 1024, "Invalid texture U size");
assert_msg(__builtin_popcount(src->txr.height) == 1
- && src->txr.height <= 1024, "Invalid texture V size");
+ && src->txr.height <= 1024, "Invalid texture V size");
mode2 |= FIELD_PREP(PVR_TA_PM2_TXRALPHA, src->txr.alpha)
| FIELD_PREP(PVR_TA_PM2_UVFLIP, src->txr.uv_flip)
@@ -432,9 +432,9 @@ void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src) {
}
else {
assert_msg(__builtin_popcount(src->txr2.width) == 1
- && src->txr2.width <= 1024, "Invalid texture U size");
+ && src->txr2.width <= 1024, "Invalid texture U size");
assert_msg(__builtin_popcount(src->txr2.height) == 1
- && src->txr2.height <= 1024, "Invalid texture V size");
+ && src->txr2.height <= 1024, "Invalid texture V size");
mode2 |= FIELD_PREP(PVR_TA_PM2_TXRALPHA, src->txr2.alpha)
| FIELD_PREP(PVR_TA_PM2_UVFLIP, src->txr2.uv_flip)
diff --git a/kernel/arch/dreamcast/hardware/sci.c b/kernel/arch/dreamcast/hardware/sci.c
index 40f6898f..82322412 100644
--- a/kernel/arch/dreamcast/hardware/sci.c
+++ b/kernel/arch/dreamcast/hardware/sci.c
@@ -443,7 +443,7 @@ void sci_configure_spi(sci_spi_cs_mode_t cs, size_t buffer_size) {
sci_shutdown_spi_cs();
/* Allocate a single aligned buffer for both TX and RX DMA operations */
- if (buffer_size > 0) {
+ if(buffer_size > 0) {
if(spi_dma_buffer != NULL && spi_buffer_size != buffer_size) {
free(spi_dma_buffer);
spi_dma_buffer = NULL;
@@ -451,7 +451,7 @@ void sci_configure_spi(sci_spi_cs_mode_t cs, size_t buffer_size) {
if(spi_dma_buffer == NULL) {
spi_dma_buffer = aligned_alloc(32, buffer_size);
- if (spi_dma_buffer == NULL) {
+ if(spi_dma_buffer == NULL) {
dbglog(DBG_ERROR, "SCI: Failed to allocate DMA buffer\n");
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 18:13:02
|
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 f7ee03a8533adbba8dd6f03cc458a28b69802a89 (commit)
via 85c46b357012ae25be83f811bf826d05b43397b8 (commit)
via e8887270d1f896f2888791d905c620babd5fafab (commit)
from c5243a942b2389d5231a32a5fffe0f0ce67e6592 (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 f7ee03a8533adbba8dd6f03cc458a28b69802a89
Author: Falco Girgis <gyr...@gm...>
Date: Tue Aug 5 13:05:31 2025 -0500
Addressed review feedback.
commit 85c46b357012ae25be83f811bf826d05b43397b8
Author: Falco Girgis <gyr...@gm...>
Date: Tue Aug 5 09:19:07 2025 -0500
Addressed review feedback.
commit e8887270d1f896f2888791d905c620babd5fafab
Author: Falco Girgis <gyr...@gm...>
Date: Sun Jun 8 22:30:52 2025 -0500
Faster IRQ enable/disable/restore + SR fetch.
Despite being tiny little routines that clobber either just one register
or nothing at all, the following routines were being implemented in pure
out-of-line ASM, which meant the compiler could never inline them even
with LTO:
a. irq_get_sr()
b. irq_restore()
c. irq_disable()
d. irq_enable()
This PR moves them into inline functions as inline ASM where the
compiler should definitely be inlining them at even low optimization
levels for pretty high perf gainz, since these are very hot throughout
the codebase.
1) Removed all out-of-line implementations of theses routines from
entry.s.
2) Rewrote them as inlined functions in inline ASM within irq.h
3) Had to tweak the following ASM routines to no longer call into the
removed routines, since ASM cannot call inline C functions:
a. irq_save_regs() [entry.s]
b. thd_block_now() [thdswitch.s]
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/include/arch/irq.h | 47 ++++++++++++-------
kernel/arch/dreamcast/kernel/entry.s | 77 +++++++-------------------------
kernel/arch/dreamcast/kernel/thdswitch.s | 22 +++++----
3 files changed, 59 insertions(+), 87 deletions(-)
diff --git a/kernel/arch/dreamcast/include/arch/irq.h b/kernel/arch/dreamcast/include/arch/irq.h
index f0a50bf9..a6167499 100644
--- a/kernel/arch/dreamcast/include/arch/irq.h
+++ b/kernel/arch/dreamcast/include/arch/irq.h
@@ -1,9 +1,9 @@
/* KallistiOS ##version##
arch/dreamcast/include/arch/irq.h
- Copyright (C) 2000-2001 Megan Potter
+ Copyright (C) 2000, 2001 Megan Potter
Copyright (C) 2024 Paul Cercueil
- Copyright (C) 2024 Falco Girgis
+ Copyright (C) 2024, 2025 Falco Girgis
*/
@@ -308,7 +308,25 @@ typedef uint32_t irq_mask_t;
\retval Status register word
\sa irq_disable()
*/
-irq_mask_t irq_get_sr(void);
+static inline irq_mask_t irq_get_sr(void) {
+ irq_mask_t value;
+ __asm__ volatile("stc sr, %0" : "=r" (value));
+ return value;
+}
+
+/** Restore IRQ state.
+
+ This function will restore the interrupt state to the value specified. This
+ should correspond to a value returned by irq_disable().
+
+ \param v The IRQ state to restore. This should be a value
+ returned by irq_disable().
+
+ \sa irq_disable()
+*/
+static inline void irq_restore(irq_mask_t old) {
+ __asm__ volatile("ldc %0, sr" : : "r" (old));
+}
/** Disable interrupts.
@@ -321,7 +339,11 @@ irq_mask_t irq_get_sr(void);
\sa irq_restore(), irq_enable()
*/
-irq_mask_t irq_disable(void);
+static inline irq_mask_t irq_disable(void) {
+ uint32_t mask = (uint32_t)irq_get_sr();
+ irq_restore((mask & 0xefffff0f) | 0x000000f0);
+ return mask;
+}
/** Enable all interrupts.
@@ -329,19 +351,10 @@ irq_mask_t irq_disable(void);
\sa irq_disable()
*/
-void irq_enable(void);
-
-/** Restore IRQ state.
-
- This function will restore the interrupt state to the value specified. This
- should correspond to a value returned by irq_disable().
-
- \param v The IRQ state to restore. This should be a value
- returned by irq_disable().
-
- \sa irq_disable()
-*/
-void irq_restore(irq_mask_t v);
+static inline void irq_enable(void) {
+ uint32_t mask = ((uint32_t)irq_get_sr() & 0xefffff0f);
+ irq_restore(mask);
+}
/** \brief Disable interrupts with scope management.
diff --git a/kernel/arch/dreamcast/kernel/entry.s b/kernel/arch/dreamcast/kernel/entry.s
index 4f01bae7..1ee06592 100644
--- a/kernel/arch/dreamcast/kernel/entry.s
+++ b/kernel/arch/dreamcast/kernel/entry.s
@@ -1,8 +1,9 @@
! KallistiOS ##version##
!
! arch/dreamcast/kernel/entry.s
-! (c)2000-2001 Megan Potter
+! Copyright (C) 2000, 2001 Megan Potter
! Copyright (C) 2023 Paul Cercueil <pa...@cr...>
+! Copyright (C) 2025 Falco Girgis
!
! Assembler code for entry and exit to/from the kernel via exceptions
!
@@ -111,8 +112,12 @@ _irq_save_regs:
! Before we enter the main C code again, re-enable exceptions
! (but not interrupts) so we can still debug inside handlers.
- bsr _irq_disable
- nop
+ mov.l irqd_and,r1
+ mov.l irqd_or,r2
+ stc sr,r0
+ and r0,r1
+ or r2,r1
+ ldc r1,sr
! R4 still contains the exception code
mov.l hdl_except,r2 ! Call handle_exception
@@ -121,6 +126,12 @@ _irq_save_regs:
bra _save_regs_finish
nop
+ .align 2
+irqd_and:
+ .long 0xefffff0f
+irqd_or:
+ .long 0x000000f0
+
! irq_force_return() jumps here; make sure we're in register
! bank 1 (as opposed to 0)
_irq_force_return:
@@ -331,62 +342,4 @@ _vma_table_400: ! TLB miss exceptions (MMU)
_vma_table_600: ! IRQs
nop
bra _irq_save_regs
- mov #3,r4 ! Set exception code
-
-
-! Disable interrupts, but leave exceptions enabled. Returns the old
-! interrupt status.
-!
-! Calling this inside an exception/interrupt handler will generally not have
-! any effect.
-!
- .globl _irq_disable
-_irq_disable:
- mov.l _irqd_and,r1
- mov.l _irqd_or,r2
- stc sr,r0
- and r0,r1
- or r2,r1
- ldc r1,sr
- rts
- nop
-
- .align 2
-_irqd_and:
- .long 0xefffff0f
-_irqd_or:
- .long 0x000000f0
-
-
-! Enable interrupts and exceptions. Returns the old interrupt status.
-!
-! Call this inside an exception/interrupt handler only with GREAT CARE.
-!
- .globl _irq_enable
-_irq_enable:
- mov.l _irqe_and,r1
- stc sr,r0
- and r0,r1
- ldc r1,sr
- rts
- nop
-
- .align 2
-_irqe_and:
- .long 0xefffff0f
-
-
-! Restore interrupts to the state returned by irq_disable()
-! or irq_enable().
- .globl _irq_restore
-_irq_restore:
- ldc r4,sr
- rts
- nop
-
-
-! Retrieve SR
- .globl _irq_get_sr
-_irq_get_sr:
- rts
- stc sr,r0
+ mov #3,r4 ! Set exception code
\ No newline at end of file
diff --git a/kernel/arch/dreamcast/kernel/thdswitch.s b/kernel/arch/dreamcast/kernel/thdswitch.s
index 26be2830..bf19c959 100644
--- a/kernel/arch/dreamcast/kernel/thdswitch.s
+++ b/kernel/arch/dreamcast/kernel/thdswitch.s
@@ -1,8 +1,9 @@
! KallistiOS ##version##
!
! arch/dreamcast/kernel/thdswitch.s
-! Copyright (c)2003 Megan Potter
+! Copyright (C) 2003 Megan Potter
! Copyright (C) 2023 Paul Cercueil <pa...@cr...>
+! Copyright (C) 2025 Falco Girgis
!
! Assembler code for swapping out running threads
!
@@ -33,12 +34,13 @@ _thd_block_now:
! and start at R8.
! Save SR and disable interrupts
- sts.l pr,@-r15
- mov.l idaddr,r0
- jsr @r0
- nop
+ mov.l irqd_and,r1
+ mov.l irqd_or,r2
+ stc sr,r0
+ and r0,r1
+ or r2,r1
+ ldc r1,sr
- lds.l @r15+,pr
add #0x72,r4
mov r0,r1
@@ -122,9 +124,13 @@ _thd_block_now:
jmp @r1
mov r0,r4
+ .align 2
+irqd_and:
+ .long 0xefffff0f
+irqd_or:
+ .long 0x000000f0
+
.balign 4
-idaddr:
- .long _irq_disable
ifraddr:
.long _irq_force_return
tcnaddr:
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 17:39:56
|
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 c5243a942b2389d5231a32a5fffe0f0ce67e6592 (commit)
from 584c550e134979fc69b86e0efb63546764146d4e (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 c5243a942b2389d5231a32a5fffe0f0ce67e6592
Author: darc <da...@pr...>
Date: Tue Aug 5 12:28:15 2025 -0500
dc-chain: Add gdb_ver in profiles in which it's missing
-----------------------------------------------------------------------
Summary of changes:
utils/dc-chain/profiles/aica/stable.mk | 1 +
utils/dc-chain/profiles/dreamcast/15.0.0-lra.mk | 1 +
2 files changed, 2 insertions(+)
diff --git a/utils/dc-chain/profiles/aica/stable.mk b/utils/dc-chain/profiles/aica/stable.mk
index 096dc347..3a28606e 100644
--- a/utils/dc-chain/profiles/aica/stable.mk
+++ b/utils/dc-chain/profiles/aica/stable.mk
@@ -9,6 +9,7 @@ cpu_configure_args=--with-arch=armv4 --with-mode=arm --disable-multilib
binutils_ver=2.44
gcc_ver=8.5.0
newlib_ver=4.5.0.20241231
+gdb_ver=16.3
# GCC custom dependencies
# Specify here if you want to use custom GMP, MPFR and MPC libraries when
diff --git a/utils/dc-chain/profiles/dreamcast/15.0.0-lra.mk b/utils/dc-chain/profiles/dreamcast/15.0.0-lra.mk
index d53bc2b8..693c564b 100644
--- a/utils/dc-chain/profiles/dreamcast/15.0.0-lra.mk
+++ b/utils/dc-chain/profiles/dreamcast/15.0.0-lra.mk
@@ -16,6 +16,7 @@ cpu_configure_args=--with-multilib-list=$(precision_modes) --with-endian=little
binutils_ver=2.44
gcc_ver=15.0.0
newlib_ver=4.5.0.20241231
+gdb_ver=16.3
# Overide SH toolchain download type
gcc_download_type=git
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 16:49:12
|
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 584c550e134979fc69b86e0efb63546764146d4e (commit)
via 0899526b0a9e358228149f933f3f06c03ea2074e (commit)
from c71cc6e505324e35235208c574c04b3a872c2fba (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 584c550e134979fc69b86e0efb63546764146d4e
Author: Falco Girgis <gyr...@gm...>
Date: Tue Aug 5 11:21:31 2025 -0500
Fixed building "library" example with LTO.
...by disabling LTO within its specific Makefiles to still work with
globally enabled LTO using fat objects.
commit 0899526b0a9e358228149f933f3f06c03ea2074e
Author: Falco Girgis <gyr...@gm...>
Date: Tue Aug 5 11:18:26 2025 -0500
Updated environ.sh.sample.
1) New defaults for using builtins and no position-independent code.
2) New option for LTO, which automatically uses fat objects for
compatibility.
3) New optional flags for various optimizations such as -fipa-pta.
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 49 +++++++++++++++-------
.../dreamcast/library/loadable-dependence/Makefile | 2 +-
.../dreamcast/library/loadable-dependent/Makefile | 2 +-
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index e23238c7..e9cf952d 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -138,23 +138,42 @@ export DC_ARM_LDFLAGS=""
# Controls the baseline optimization level to use when building.
# Typically this is -Og (debugging), -O0, -O1, -O2, or -O3.
# NOTE: For our target, -O4 is a valid optimization level that has
-# been seen to have some performance impact as well.
+# been seen to have some performance impact as well.
#
export KOS_CFLAGS="${KOS_CFLAGS} -O2"
+# Link-Time Optimization
+#
+# Uncomment this to enable LTO, which can substantially improve performance
+# of the generated code by enabling the linker to perform inlining, at the
+# cost of longer build times and fatter object files.
+# NOTE: Certain ports and examples require fat LTO objects to work with LTO,
+# and LTO itself is known to cause issues in code with undefined behavior.
+#
+#export KOS_CFLAGS="${KOS_CFLAGS} -flto=auto -ffat-lto-objects"
+
# Additional Optimizations
#
-# Uncomment this to enable what has been found empirically to be
-# the optimal set of additional flags for release build performance
-# on the current stable toolchain. NOTE: Certain KOS-ports and examples
-# do not work properly with "-flto=auto"!
+# Uncomment these to enable what have been found empirically to be a decent
+# set of additional flags for optimal release build performance with the
+# current stable toolchain.
+#
+#export KOS_CFLAGS="${KOS_CFLAGS} -freorder-blocks-algorithm=simple"
+#export KOS_CFLAGS="${KOS_CFLAGS} -fipa-pta"
+
+# Position-Independent Code
+#
+# Comment this line out to enable position-dependent code. Codegen is slightly
+# slower, and you lose a register, but it's required when building dynamically
+# linked libraries or code whose symbols aren't resolved until runtime.
#
-#export KOS_CFLAGS="${KOS_CFLAGS} -freorder-blocks-algorithm=simple -flto=auto"
+export KOS_CFLAGS="${KOS_CFLAGS} -fno-PIC -fno-PIE"
# Frame Pointers
#
-# Controls whether frame pointers are emitted or not. Disabled by
-# default. Enable them if you plan to use GDB for debugging.
+# Controls whether frame pointers are emitted or not. Disabled by default, as
+# they use an extra register. Enable them if you plan to use GDB for debugging
+# or need additional stack trace
#
export KOS_CFLAGS="${KOS_CFLAGS} -fomit-frame-pointer"
#export KOS_CFLAGS="${KOS_CFLAGS} -fno-omit-frame-pointer -DFRAME_POINTERS"
@@ -172,13 +191,12 @@ export KOS_CFLAGS="${KOS_CFLAGS} -fomit-frame-pointer"
# GCC Builtin Functions
#
-# Comment out this line to enable GCC to use its own builtin implementations of
-# certain standard library functions. Under certain conditions, this can allow
-# compiler-optimized implementations to replace standard function invocations.
-# The downside of this is that it COULD interfere with Newlib or KOS implementations
-# of these functions, and it has not been tested thoroughly to ensure compatibility.
+# Uncomment this line to prevent GCC from using its own builtin implementations of
+# certain standard library functions. Under certain conditions, using builtins
+# allows for compiler-optimized routines to replace function calls to the C standard
+# library which are backed by Newlib or KOS.
#
-export KOS_CFLAGS="${KOS_CFLAGS} -fno-builtin"
+#export KOS_CFLAGS="${KOS_CFLAGS} -fno-builtin"
# Fast Math Instructions
#
@@ -186,7 +204,8 @@ export KOS_CFLAGS="${KOS_CFLAGS} -fno-builtin"
# FSCA, and FSQRT) for calculating sin/cos, inverse square root, and square roots.
# These can result in substantial performance gains for these kinds of operations;
# however, they do so at the price of accuracy and are not IEEE compliant.
-# NOTE: Enabling this option will also override -fno-builtin!
+# NOTE: If these cause issues when enabled globally, it's advised to try to enable
+# them on individual files in the critical path to still gain performance.
#
#export KOS_CFLAGS="${KOS_CFLAGS} -fbuiltin -ffast-math -ffp-contract=fast"
diff --git a/examples/dreamcast/library/loadable-dependence/Makefile b/examples/dreamcast/library/loadable-dependence/Makefile
index 4037085e..73a52088 100644
--- a/examples/dreamcast/library/loadable-dependence/Makefile
+++ b/examples/dreamcast/library/loadable-dependence/Makefile
@@ -10,7 +10,7 @@ TARGET_LIB = lib$(TARGET_NAME).a
OBJS = $(TARGET_NAME).o
# For exporting kos_md5
-LIBS = -lkosutils
+LIBS = -lkosutils -fno-lto
# library-test exported stub for link test
DBG_LIBS = -llibrary-test
diff --git a/examples/dreamcast/library/loadable-dependent/Makefile b/examples/dreamcast/library/loadable-dependent/Makefile
index 772a00a4..a11990e1 100644
--- a/examples/dreamcast/library/loadable-dependent/Makefile
+++ b/examples/dreamcast/library/loadable-dependent/Makefile
@@ -13,6 +13,6 @@ DBG_LIBS = -llibrary-dependence -llibrary-test
KOS_LIB_PATHS += -L../loadable-dependence -L../
# Dependence include
-KOS_CFLAGS += -I../loadable-dependence
+KOS_CFLAGS += -fno-lto -I../loadable-dependence
include $(KOS_BASE)/loadable/Makefile.prefab
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 13:34:45
|
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 c71cc6e505324e35235208c574c04b3a872c2fba (commit)
via 3c96383b3b06c4448bdac3bd6702a4c3eff2a638 (commit)
from 892ca798ed79edfc507e447755c630e0ea2f9930 (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 c71cc6e505324e35235208c574c04b3a872c2fba
Author: Falco Girgis <gyr...@gm...>
Date: Tue Aug 5 00:51:51 2025 -0500
Forgot to remove manual NULL terminator.
commit 3c96383b3b06c4448bdac3bd6702a4c3eff2a638
Author: Falco Girgis <gyr...@gm...>
Date: Tue Aug 5 00:50:37 2025 -0500
Fixed string-related warnings.
The following functions:
1) realpath()
2) fs_normalize_path()
had annoying warnings about strncpy() calls which don't copy enough from
the source buffer to include its NULL terminator... which... it's not
actually a problem, since the lines right after had us manually
terminating the strings, but... this appeases GCC, so whatever.
-----------------------------------------------------------------------
Summary of changes:
kernel/fs/fs_utils.c | 3 +--
kernel/libc/koslib/realpath.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/fs/fs_utils.c b/kernel/fs/fs_utils.c
index 41190f43..b65c285e 100644
--- a/kernel/fs/fs_utils.c
+++ b/kernel/fs/fs_utils.c
@@ -203,8 +203,7 @@ char *fs_normalize_path(const char *__restrict path, char *__restrict resolved)
/* Handle absolute path. */
if(path[0] == '/') {
- strncpy(temp_path, path, len);
- temp_path[len] = '\0';
+ strcpy(temp_path, path);
}
else {
/* Handle relative path: prepend current working directory. */
diff --git a/kernel/libc/koslib/realpath.c b/kernel/libc/koslib/realpath.c
index 8db7516b..ab4892c8 100644
--- a/kernel/libc/koslib/realpath.c
+++ b/kernel/libc/koslib/realpath.c
@@ -42,8 +42,7 @@ char *realpath(const char *__restrict path, char *__restrict resolved) {
/* Handle absolute path. */
if(path[0] == '/') {
- strncpy(temp_path, path, len);
- temp_path[len] = '\0';
+ strcpy(temp_path, path);
}
else {
/* Handle relative path: prepend current working directory. */
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 05:28:31
|
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 892ca798ed79edfc507e447755c630e0ea2f9930 (commit)
from b4d54adf23275f7682359ab32c7df3349cda0393 (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 892ca798ed79edfc507e447755c630e0ea2f9930
Author: QuzarDC <qu...@co...>
Date: Tue Aug 5 01:20:45 2025 -0400
thread: Correct missing commas from init/reaper attrs.
Additionally provide disable_tls for default to avoid warning.
-----------------------------------------------------------------------
Summary of changes:
kernel/thread/thread.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c
index 1a4b20f0..36e57aa1 100644
--- a/kernel/thread/thread.c
+++ b/kernel/thread/thread.c
@@ -482,7 +482,7 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr,
}
kthread_t *thd_create(bool detach, void *(*routine)(void *), void *param) {
- kthread_attr_t attrs = { detach, 0, NULL, 0, NULL };
+ kthread_attr_t attrs = { detach, 0, NULL, 0, NULL, false };
return thd_create_ex(&attrs, routine, param);
}
@@ -1010,7 +1010,7 @@ int thd_init(void) {
.stack_size = sizeof(thd_reaper_stack),
.stack_ptr = thd_reaper_stack,
.prio = 1,
- .label = "[reaper]"
+ .label = "[reaper]",
.disable_tls = true
};
@@ -1018,7 +1018,7 @@ int thd_init(void) {
.stack_size = sizeof(thd_idle_stack),
.stack_ptr = thd_idle_stack,
.prio = PRIO_MAX,
- .label = "[idle]"
+ .label = "[idle]",
.disable_tls = true
};
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 05:23:12
|
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 b4d54adf23275f7682359ab32c7df3349cda0393 (commit)
via db307a62b687d6a1f4cf9ce4f89a25eb5f99ec91 (commit)
via 6e74c3487262e469d2a6a6980c3e282c9b83a7fd (commit)
from f26ec6edfd6df6508242b53122b8a9d51557a849 (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 b4d54adf23275f7682359ab32c7df3349cda0393
Author: QuzarDC <qu...@co...>
Date: Sat May 10 14:13:53 2025 -0400
fmath mark functions __pure.
commit db307a62b687d6a1f4cf9ce4f89a25eb5f99ec91
Author: QuzarDC <qu...@co...>
Date: Sat May 10 14:08:35 2025 -0400
Mark functions __pure.
Additionally clean up some white space in `net.h`
commit 6e74c3487262e469d2a6a6980c3e282c9b83a7fd
Author: QuzarDC <qu...@co...>
Date: Sat May 10 14:02:46 2025 -0400
Remove KOS redefinition of `__pure`.
I believe this may have been correct in the past,
but now gcc offers an actual 'pure' attribute which
differs from const. Unlike const, pure allows data
pointed to by pointer arguments to change.
Now, not only does `__pure` not have to fall back to
`const` but newlib offers it in their cdefs so we
shouldn't need to redefine it.
-----------------------------------------------------------------------
Summary of changes:
include/kos/cdefs.h | 11 ---
include/kos/net.h | 102 ++++++++++-----------
kernel/arch/dreamcast/fs/vmufs.c | 2 +-
kernel/arch/dreamcast/hardware/maple/controller.c | 4 +-
kernel/arch/dreamcast/hardware/ubc.c | 6 +-
kernel/arch/dreamcast/include/arch/arch.h | 6 +-
kernel/arch/dreamcast/include/dc/fmath.h | 23 +++--
.../arch/dreamcast/include/dc/maple/controller.h | 4 +-
kernel/arch/dreamcast/kernel/banner.c | 7 +-
kernel/arch/dreamcast/kernel/gdb_stub.c | 8 +-
kernel/arch/dreamcast/math/fmath.c | 22 ++---
kernel/arch/dreamcast/util/vmu_fb.c | 2 +-
kernel/arch/dreamcast/util/vmu_pkg.c | 6 +-
kernel/net/net_crc.c | 6 +-
kernel/net/net_dhcp.c | 6 +-
kernel/net/net_ipv4.c | 10 +-
kernel/net/net_ipv4.h | 4 +-
kernel/net/net_ipv4_frag.c | 2 +-
kernel/net/net_ipv6.c | 2 +-
kernel/thread/mutex.c | 2 +-
20 files changed, 112 insertions(+), 123 deletions(-)
diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h
index dcb1f192..87ddcaa2 100644
--- a/include/kos/cdefs.h
+++ b/include/kos/cdefs.h
@@ -47,12 +47,6 @@
#define __noreturn __attribute__((__noreturn__))
#endif
-#ifndef __pure
-/** \brief Identify a function that has no side effects other than its return,
- and only uses its arguments for any work. */
-#define __pure __attribute__((__const__))
-#endif
-
#ifndef __unused
/** \brief Identify a function or variable that may be unused. */
#define __unused __attribute__((__unused__))
@@ -78,11 +72,6 @@
#define __dead2 __noreturn /* BSD compat */
#endif
-#ifndef __pure2
-/** \brief Alias for \ref __pure. For BSD compatibility. */
-#define __pure2 __pure /* ditto */
-#endif
-
#ifndef __likely
/** \brief Directive to inform the compiler the condition is in the likely path.
diff --git a/include/kos/net.h b/include/kos/net.h
index a23929af..786cac7b 100644
--- a/include/kos/net.h
+++ b/include/kos/net.h
@@ -299,7 +299,7 @@ void net_arp_shutdown(void);
\param timestamp The entry's timestamp. Set to 0 for a permanent
entry, otherwise set to the current number of
milliseconds since boot (i.e, timer_ms_gettime64()).
-
+
\retval 0 On success.
\retval -1 Error allocating memory.
*/
@@ -320,7 +320,7 @@ int net_arp_insert(netif_t *nif, const uint8_t mac[6], const uint8_t ip[4],
response comes in (if not found immediately).
\param data Packet data to go with the header.
\param data_size The size of data.
-
+
\retval 0 On success.
\retval -1 A query is outstanding for that address.
\retval -2 Address not found, query generated.
@@ -338,7 +338,7 @@ int net_arp_lookup(netif_t *nif, const uint8_t ip_in[4], uint8_t mac_out[6],
\param nif The network device in use.
\param ip_out Storage for the IPv4 address.
\param mac_in The MAC address to look up.
-
+
\retval 0 On success.
\retval -1 On failure.
*/
@@ -350,7 +350,7 @@ int net_arp_revlookup(netif_t *nif, uint8_t ip_out[4], const uint8_t mac_in[6]);
\param nif The network device in use.
\param pkt The packet received.
\param len The length of the packet.
-
+
\retval 0 On success (no error conditions defined).
*/
int net_arp_input(netif_t *nif, const uint8_t *pkt, int len);
@@ -360,7 +360,7 @@ int net_arp_input(netif_t *nif, const uint8_t *pkt, int len);
\param nif The network device to use.
\param ip The IP to query.
-
+
\retval 0 On success (no error conditions defined).
*/
int net_arp_query(netif_t *nif, const uint8_t ip[4]);
@@ -374,12 +374,12 @@ int net_arp_query(netif_t *nif, const uint8_t ip[4]);
\param nif The network device in use.
\param pkt The packet received.
\param len The length of the packet, in bytes.
-
+
\return 0 on success, <0 on failure.
*/
typedef int (*net_input_func)(netif_t *nif, const uint8_t *pkt, int len);
-/** \brief Where will input packets be routed?
+/** \brief Where will input packets be routed?
\ingroup networking_drivers
*/
extern net_input_func net_input_target;
@@ -394,7 +394,7 @@ extern net_input_func net_input_target;
\param device The network device submitting packets.
\param data The packet to submit.
\param len The length of the packet, in bytes.
-
+
\return 0 on success, <0 on failure.
*/
int net_input(netif_t *device, const uint8_t *data, int len);
@@ -403,7 +403,7 @@ int net_input(netif_t *device, const uint8_t *data, int len);
\ingroup networking_drivers
\param t The new target callback.
-
+
\return The old target.
*/
net_input_func net_input_set_target(net_input_func t);
@@ -448,13 +448,13 @@ extern net_echo_cb net_icmp_echo_cb;
\param seq A packet sequence number.
\param data Data to send with the packet.
\param size The size of the data to send.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp_send_echo(netif_t *net, const uint8_t ipaddr[4], uint16_t ident,
uint16_t seq, const uint8_t *data, size_t size);
-/** \defgroup networking_icmp_unreach Unreachable Values
+/** \defgroup networking_icmp_unreach Unreachable Values
\brief Valid values for net_icmp_send_dest_unreach().
\ingroup networking_icmpv4
@{
@@ -470,7 +470,7 @@ int net_icmp_send_echo(netif_t *net, const uint8_t ipaddr[4], uint16_t ident,
\param net The network device to use.
\param code The type of message this is.
\param msg The message that caused this error.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *msg);
@@ -483,11 +483,11 @@ int net_icmp_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *msg);
/** \brief Send an ICMP Time Exceeded packet in reply to the given message.
\ingroup networking_icmp
-
+
\param net The network device to use.
\param code The type of message this is.
\param msg The message that caused this error.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *msg);
@@ -523,15 +523,15 @@ net_ipv4_stats_t net_ipv4_get_stats(void);
\ingroup networking_ipv4
\param addr Array of IP address octets.
-
+
\return The address, in host byte order.
*/
-uint32_t net_ipv4_address(const uint8_t addr[4]);
+uint32_t __pure net_ipv4_address(const uint8_t addr[4]);
/** \brief Parse an IP address that is packet into a uint32 into an array of
the individual bytes.
\ingroup networking_ipv4
-
+
\param addr The full address, in host byte order.
\param out The output buffer.
*/
@@ -547,7 +547,7 @@ void net_ipv4_parse_address(uint32_t addr, uint8_t out[4]);
/** \brief ICMPv6 echo reply callback type.
\ingroup networking_icmpv6
-
+
\param ip The IPv6 address the reply is from.
\param seq The sequence number of the packet.
\param delta_us The time difference, in microseconds.
@@ -566,14 +566,14 @@ extern net6_echo_cb net_icmp6_echo_cb;
/** \brief Send an ICMPv6 Echo (PING6) packet to the specified device.
\ingroup networking_icmpv6
-
+
\param net The network device to use.
\param dst The address to send to.
\param ident A packet identifier.
\param seq A packet sequence number.
\param data Data to send with the packet.
\param size Length of the data, in bytes.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16_t ident,
@@ -581,12 +581,12 @@ int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16_t ident
/** \brief Send a Neighbor Solicitation packet on the specified device.
\ingroup networking_icmpv6
-
+
\param net The network device to use.
\param dst The destination address.
\param target The target address.
\param dupdet 1 if this is for duplicate detection.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_nsol(netif_t *net, const struct in6_addr *dst,
@@ -594,12 +594,12 @@ int net_icmp6_send_nsol(netif_t *net, const struct in6_addr *dst,
/** \brief Send a Neighbor Advertisement packet on the specified device.
\ingroup networking_icmpv6
-
+
\param net The network device to use.
\param dst The destination address.
\param target The target address.
\param sol 1 if solicited, 0 otherwise.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_nadv(netif_t *net, const struct in6_addr *dst,
@@ -607,9 +607,9 @@ int net_icmp6_send_nadv(netif_t *net, const struct in6_addr *dst,
/** \brief Send a Router Solicitation request on the specified interface.
\ingroup networking_icmpv6
-
+
\param net The network device to use.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_rsol(netif_t *net);
@@ -638,7 +638,7 @@ int net_icmp6_send_rsol(netif_t *net);
\param code The type of message this is.
\param ppkt The message that caused this error.
\param psz Size of the original message.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt,
@@ -648,7 +648,7 @@ int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt,
\brief Time exceeded codes for ICMPv6
\ingroup networking_icmpv6
- Only fragment reassembly time exceeded makes sense
+ Only fragment reassembly time exceeded makes sense
@{
*/
@@ -658,12 +658,12 @@ int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt,
/** \brief Send a time exceeded message on the specified interface.
\ingroup networking_icmpv6
-
+
\param net The network device to use.
\param code The error code.
\param ppkt The message that caused this error.
\param psz Size of the original packet.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *ppkt,
@@ -681,13 +681,13 @@ int net_icmp6_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *ppkt
/** \brief Send an ICMPv6 Parameter Problem about the given packet.
\ingroup networking_icmpv6
-
+
\param net The network device to use.
\param code The error code.
\param ptr Where in the packet is the error?
\param ppkt The message that caused the error.
\param psz Size of the original packet.
-
+
\return 0 on success, <0 on failure.
*/
int net_icmp6_send_param_prob(netif_t *net, uint8_t code, uint32_t ptr,
@@ -795,13 +795,13 @@ typedef struct net_udp_stats {
} net_udp_stats_t;
/** \brief Retrieve statistics from the UDP layer.
-
+
\return The global UDP stats struct.
*/
net_udp_stats_t net_udp_get_stats(void);
/** \brief Init UDP.
-
+
\retval 0 On success (no error conditions defined).
*/
int net_udp_init(void);
@@ -838,25 +838,25 @@ void net_tcp_shutdown(void);
*/
/** \brief Calculate a "little-endian" CRC-32 over a block of data.
-
+
\param data The data to calculate over.
\param size The size of the data, in bytes.
-
+
\return The calculated CRC-32.
*/
-uint32_t net_crc32le(const uint8_t *data, int size);
+uint32_t __pure net_crc32le(const uint8_t *data, int size);
/** \brief Calculate a "big-endian" CRC-32 over a block of data.
-
+
\param data The data to calculate over.
\param size The size of the data, in bytes.
-
+
\return The calculated CRC-32.
*/
-uint32_t net_crc32be(const uint8_t *data, int size);
+uint32_t __pure net_crc32be(const uint8_t *data, int size);
/** \brief Calculate a CRC16-CCITT over a block of data.
-
+
\note Based on code found online at
http://www.ccsinfo.com/forum/viewtopic.php?t=24977
@@ -866,10 +866,10 @@ uint32_t net_crc32be(const uint8_t *data, int size);
return value from this function (if continuing a
previous calculation) or some initial seed value
(typically 0xFFFF or 0x0000).
-
+
\return The calculated CRC16-CCITT.
*/
-uint16_t net_crc16ccitt(const uint8_t *data, int size, uint16_t start);
+uint16_t __pure net_crc16ccitt(const uint8_t *data, int size, uint16_t start);
/** @} */
@@ -921,14 +921,14 @@ void net_multicast_shutdown(void);
/***** net_core.c *********************************************************/
-/** \brief Interface list; note: do not manipulate directly!
+/** \brief Interface list; note: do not manipulate directly!
\ingroup networking_drivers
*/
extern struct netif_list net_if_list;
/** \brief Function to retrieve the interface list.
\ingroup networking_drivers
-
+
\warning
Do not manipulate what this returns to you!
@@ -936,8 +936,8 @@ extern struct netif_list net_if_list;
*/
struct netif_list * net_get_if_list(void);
-/** \brief The default network device, used with sockets (read-only).
- \ingroup networking_drivers
+/** \brief The default network device, used with sockets (read-only).
+ \ingroup networking_drivers
*/
extern netif_t *net_default_dev;
@@ -945,7 +945,7 @@ extern netif_t *net_default_dev;
\ingroup networking_drivers
\param n The device to set as default.
-
+
\return The old default device.
*/
netif_t *net_set_default(netif_t *n);
@@ -963,14 +963,14 @@ int net_reg_device(netif_t *device);
\ingroup networking_drivers
\param device The device to unregister.
-
+
\return 0 on success, <0 on failure.
*/
int net_unreg_device(netif_t *device);
/** \brief Init network support.
\ingroup networking_drivers
-
+
\note To auto-detect the IP address to assign to the
default device (i.e, over DHCP or from the flashrom
on the Dreamcast), pass 0 as the IP parameter.
@@ -982,7 +982,7 @@ int net_unreg_device(netif_t *device);
*/
int net_init(uint32_t ip);
-/** \brief Shutdown network support.
+/** \brief Shutdown network support.
\ingroup networking_drivers
*/
void net_shutdown(void);
diff --git a/kernel/arch/dreamcast/fs/vmufs.c b/kernel/arch/dreamcast/fs/vmufs.c
index 726c223f..f80b8613 100644
--- a/kernel/arch/dreamcast/fs/vmufs.c
+++ b/kernel/arch/dreamcast/fs/vmufs.c
@@ -49,7 +49,7 @@ Function comments located in vmufs.h.
static mutex_t mutex;
/* Convert a decimal number to BCD; max of two digits */
-static uint8 dec_to_bcd(int dec) {
+static uint8 __pure dec_to_bcd(int dec) {
uint8 rv = 0;
rv = dec % 10;
diff --git a/kernel/arch/dreamcast/hardware/maple/controller.c b/kernel/arch/dreamcast/hardware/maple/controller.c
index eb60f696..e20f21fe 100644
--- a/kernel/arch/dreamcast/hardware/maple/controller.c
+++ b/kernel/arch/dreamcast/hardware/maple/controller.c
@@ -51,13 +51,13 @@ static TAILQ_HEAD(cont_btn_callback_list, cont_callback_params) btn_cbs;
static mutex_t btn_cbs_mtx = MUTEX_INITIALIZER;
/* Check whether the controller has EXACTLY the given capabilities. */
-int cont_is_type(const maple_device_t *cont, uint32_t type) {
+int __pure cont_is_type(const maple_device_t *cont, uint32_t type) {
return cont ? cont->info.function_data[CONT_FUNCTION_DATA_INDEX] == type :
-1;
}
/* Check whether the controller has at LEAST the given capabilities. */
-int cont_has_capabilities(const maple_device_t *cont, uint32_t capabilities) {
+int __pure cont_has_capabilities(const maple_device_t *cont, uint32_t capabilities) {
return cont ? ((cont->info.function_data[CONT_FUNCTION_DATA_INDEX]
& capabilities) == capabilities) : -1;
}
diff --git a/kernel/arch/dreamcast/hardware/ubc.c b/kernel/arch/dreamcast/hardware/ubc.c
index ba59bc9e..4e96c666 100755
--- a/kernel/arch/dreamcast/hardware/ubc.c
+++ b/kernel/arch/dreamcast/hardware/ubc.c
@@ -76,7 +76,7 @@ static struct ubc_channel_state {
} channel_state[ubc_channel_count] = { 0 };
/* Translates ubc_access_t to BBR.ID field format. */
-inline static uint8_t get_access_mask(ubc_access_t access) {
+inline static uint8_t __pure get_access_mask(ubc_access_t access) {
switch(access) {
case ubc_access_either:
return 0x3;
@@ -86,7 +86,7 @@ inline static uint8_t get_access_mask(ubc_access_t access) {
}
/* Translates ubc_rw_t to BBR.RW field format. */
-inline static uint8_t get_rw_mask(ubc_rw_t rw) {
+inline static uint8_t __pure get_rw_mask(ubc_rw_t rw) {
switch(rw) {
case ubc_rw_either:
return 0x3;
@@ -96,7 +96,7 @@ inline static uint8_t get_rw_mask(ubc_rw_t rw) {
}
/* Translates ubc_address_mask_t to BASR.BAM field format. */
-inline static uint8_t get_address_mask(ubc_address_mask_t addr_mask) {
+inline static uint8_t __pure get_address_mask(ubc_address_mask_t addr_mask) {
switch(addr_mask) {
case ubc_address_mask_all:
return 3;
diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h
index cbc731cc..972bbd6a 100644
--- a/kernel/arch/dreamcast/include/arch/arch.h
+++ b/kernel/arch/dreamcast/include/arch/arch.h
@@ -340,7 +340,7 @@ int hardware_sys_mode(int *region);
\return A pointer to the banner string.
*/
-const char *kos_get_banner(void);
+const char * __pure kos_get_banner(void);
/** \brief Retrieve the license information for the compiled copy of KOS.
\ingroup attribution
@@ -351,7 +351,7 @@ const char *kos_get_banner(void);
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 05:05:23
|
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 f26ec6edfd6df6508242b53122b8a9d51557a849 (commit)
via 38ab23e4824f6ddc8f4359f039b5749c54b61714 (commit)
from 7744fa682cf1ead22f6242439dfac52c45ec16ec (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 f26ec6edfd6df6508242b53122b8a9d51557a849
Author: darc <da...@pr...>
Date: Mon Aug 4 16:28:10 2025 -0500
Make sysconf() arch agnostic and provide L2 cache specs
commit 38ab23e4824f6ddc8f4359f039b5749c54b61714
Author: darc <da...@pr...>
Date: Mon Aug 4 16:26:03 2025 -0500
Replace CPU_CACHE_BLOCK_SIZE with more detailed CPU cache specifications
atomics.c and cdrom.c are also updated to reflect the new definitions.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/cdrom.c | 4 +--
kernel/arch/dreamcast/include/arch/cache.h | 55 ++++++++++++++++++++++++++++--
kernel/libc/c11/atomics.c | 2 +-
kernel/libc/posix/sysconf.c | 22 ++++++++----
4 files changed, 71 insertions(+), 12 deletions(-)
diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c
index 8d7d3497..9d6c0922 100644
--- a/kernel/arch/dreamcast/hardware/cdrom.c
+++ b/kernel/arch/dreamcast/hardware/cdrom.c
@@ -812,8 +812,8 @@ static void unlock_dma_memory(void) {
}
}
if(patched) {
- flush_size = (patch_addr[1] - patch_addr[0]) + CPU_CACHE_BLOCK_SIZE;
- flush_size &= ~(CPU_CACHE_BLOCK_SIZE - 1);
+ flush_size = (patch_addr[1] - patch_addr[0]) + CACHE_L1_ICACHE_LINESIZE;
+ flush_size &= ~(CACHE_L1_ICACHE_LINESIZE - 1);
icache_flush_range(patch_addr[0] | MEM_AREA_P1_BASE, flush_size);
}
*prot_reg = G1_ATA_DMA_UNLOCK_ALLMEM;
diff --git a/kernel/arch/dreamcast/include/arch/cache.h b/kernel/arch/dreamcast/include/arch/cache.h
index dd29b659..28a89e19 100644
--- a/kernel/arch/dreamcast/include/arch/cache.h
+++ b/kernel/arch/dreamcast/include/arch/cache.h
@@ -4,6 +4,7 @@
Copyright (C) 2001 Megan Potter
Copyright (C) 2014, 2016, 2023 Ruslan Rostovtsev
Copyright (C) 2023 Andy Barajas
+ Copyright (C) 2025 Eric Fradella
*/
/** \file arch/cache.h
@@ -34,11 +35,59 @@ __BEGIN_DECLS
@{
*/
-/** \brief SH4 cache block size.
+/** \brief Level 1 instruction cache size.
- The size of a cache block.
+ The capacity of the L1 instruction cache in bytes.
*/
-#define CPU_CACHE_BLOCK_SIZE 32
+#define CACHE_L1_ICACHE_SIZE 8 * 1024
+
+/** \brief Level 1 instruction cache associativity.
+
+ Number of ways in the L1 instruction cache.
+*/
+#define CACHE_L1_ICACHE_ASSOC 1
+
+/** \brief L1 instruction cache line size.
+
+ The size of each cache line in the L1 instruction cache.
+*/
+#define CACHE_L1_ICACHE_LINESIZE 32
+
+/** \brief Level 1 data cache size.
+
+ The capacity of the L1 data cache in bytes.
+*/
+#define CACHE_L1_DCACHE_SIZE 16 * 1024
+
+/** \brief Level 1 data cache associativity.
+
+ Number of ways in the L1 data cache.
+*/
+#define CACHE_L1_DCACHE_ASSOC 1
+
+/** \brief L1 data cache line size.
+
+ The size of each cache line in the L1 data cache.
+*/
+#define CACHE_L1_DCACHE_LINESIZE 32
+
+/** \brief Level 2 cache size.
+
+ The capacity of the L2 cache in bytes.
+*/
+#define CACHE_L2_CACHE_SIZE 0
+
+/** \brief Level 2 cache associativity.
+
+ Number of ways in the L2 cache.
+*/
+#define CACHE_L2_CACHE_ASSOC 0
+
+/** \brief Level 2 cache line size.
+
+ The size of each cache line in the L2 cache.
+*/
+#define CACHE_L2_CACHE_LINESIZE 0
/** \brief Flush the instruction cache.
diff --git a/kernel/libc/c11/atomics.c b/kernel/libc/c11/atomics.c
index 763d3c7d..e8effd85 100644
--- a/kernel/libc/c11/atomics.c
+++ b/kernel/libc/c11/atomics.c
@@ -110,7 +110,7 @@ ATOMIC_FETCH_NAND_N_(unsigned long long, 8)
around memcpy() calls. */
/* Size of each memory region covered by an individual lock. */
-#define GENERIC_LOCK_BLOCK_SIZE (CPU_CACHE_BLOCK_SIZE * 4)
+#define GENERIC_LOCK_BLOCK_SIZE (CACHE_L1_DCACHE_LINESIZE * 4)
/* Locks have to be shared for each page with the MMU enabled,
otherwise we can fail when aliasing an address range to multiple
diff --git a/kernel/libc/posix/sysconf.c b/kernel/libc/posix/sysconf.c
index 9192f134..0ba83708 100644
--- a/kernel/libc/posix/sysconf.c
+++ b/kernel/libc/posix/sysconf.c
@@ -2,6 +2,7 @@
sysconf.c
Copyright (C) 2023, 2024, 2025 Falco Girgis
+ Copyright (C) 2025 Eric Fradella
*/
#include <arch/arch.h>
@@ -51,22 +52,31 @@ long sysconf(int name) {
return PAGESIZE;
case _SC_LEVEL1_ICACHE_SIZE:
- return 8 * 1024;
+ return CACHE_L1_ICACHE_SIZE;
case _SC_LEVEL1_ICACHE_ASSOC:
- return 1;
+ return CACHE_L1_ICACHE_ASSOC;
case _SC_LEVEL1_ICACHE_LINESIZE:
- return CPU_CACHE_BLOCK_SIZE;
+ return CACHE_L1_ICACHE_LINESIZE;
case _SC_LEVEL1_DCACHE_SIZE:
- return 16 * 1024;
+ return CACHE_L1_DCACHE_SIZE;
case _SC_LEVEL1_DCACHE_ASSOC:
- return 1;
+ return CACHE_L1_DCACHE_ASSOC;
case _SC_LEVEL1_DCACHE_LINESIZE:
- return CPU_CACHE_BLOCK_SIZE;
+ return CACHE_L1_DCACHE_LINESIZE;
+
+ case _SC_LEVEL2_CACHE_SIZE:
+ return CACHE_L2_CACHE_SIZE;
+
+ case _SC_LEVEL2_CACHE_ASSOC:
+ return CACHE_L2_CACHE_ASSOC;
+
+ case _SC_LEVEL2_CACHE_LINESIZE:
+ return CACHE_L2_CACHE_LINESIZE;
case _SC_SEM_NSEMS_MAX:
return UINT32_MAX;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 05:02:15
|
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 7744fa682cf1ead22f6242439dfac52c45ec16ec (commit)
via 59e1b7706c53f22fcd3787bd304b33695da20824 (commit)
via 844f8babb0a7fe714c15bdc4e63c4dff36e5f2d0 (commit)
via da3174025025025e2667dc383ae0e1e27c79014b (commit)
via 0965ee1e3e47afd6a4a05c2a30d18fb40d2c3246 (commit)
from 3df833497711472b1b0d8546dfcdf5031d3c6fe7 (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 7744fa682cf1ead22f6242439dfac52c45ec16ec
Author: QuzarDC <qu...@co...>
Date: Fri May 30 03:14:17 2025 -0400
Change mutex type to unsigned int.
This allows for simplified invalid type checks.
commit 59e1b7706c53f22fcd3787bd304b33695da20824
Author: QuzarDC <qu...@co...>
Date: Thu May 29 22:55:11 2025 -0400
Constify params.
Where appropriate mark that the passed pointer
will not be used to change its data. This is
mostly seen in accessors but also with genwait's
sleep `obj`.
commit 844f8babb0a7fe714c15bdc4e63c4dff36e5f2d0
Author: QuzarDC <qu...@co...>
Date: Thu May 22 21:42:58 2025 -0400
Mark function params as non-null for safety and optimization.
In each of these there are no tests being done to verify that
the input is non-null, and it has already been up to the caller
to ensure that before using.
commit da3174025025025e2667dc383ae0e1e27c79014b
Author: QuzarDC <qu...@co...>
Date: Fri May 23 10:16:17 2025 -0400
Remove deprecated dynamic sync primitive creations.
These were all deprecated in 2012. Finally being
removed. Recursive locks were additionally replaced
entirely by recursive type mutexes.
commit 0965ee1e3e47afd6a4a05c2a30d18fb40d2c3246
Author: QuzarDC <qu...@co...>
Date: Fri May 23 09:10:04 2025 -0400
Correct param name mismatch in sem.c/h
For some reason the .h had all params as `sem` while
the .c had all but one as `sm`. Shifted them all to `sm`
to match the majority within the .c.
-----------------------------------------------------------------------
Summary of changes:
addons/libpthread/pthread_mutex_init.c | 3 +-
include/kos/cond.h | 42 +++-----
include/kos/genwait.h | 16 +--
include/kos/mutex.h | 45 +++-----
include/kos/recursive_lock.h | 141 --------------------------
include/kos/rwsem.h | 58 ++++-------
include/kos/sem.h | 48 +++------
include/kos/thread.h | 1 -
kernel/arch/dreamcast/include/arch/spinlock.h | 6 +-
kernel/exports.txt | 3 -
kernel/thread/Makefile | 2 +-
kernel/thread/cond.c | 25 +----
kernel/thread/genwait.c | 30 +++---
kernel/thread/mutex.c | 41 ++------
kernel/thread/recursive_lock.c | 58 -----------
kernel/thread/rwsem.c | 28 +----
kernel/thread/sem.c | 56 +++-------
17 files changed, 112 insertions(+), 491 deletions(-)
delete mode 100644 include/kos/recursive_lock.h
delete mode 100644 kernel/thread/recursive_lock.c
diff --git a/addons/libpthread/pthread_mutex_init.c b/addons/libpthread/pthread_mutex_init.c
index fbfa038c..572d3d5b 100644
--- a/addons/libpthread/pthread_mutex_init.c
+++ b/addons/libpthread/pthread_mutex_init.c
@@ -12,7 +12,8 @@
int pthread_mutex_init(pthread_mutex_t *__RESTRICT mutex,
const pthread_mutexattr_t *__RESTRICT attr) {
- int type = MUTEX_TYPE_NORMAL, old, rv = 0;
+ unsigned int type = MUTEX_TYPE_NORMAL;
+ int old, rv = 0;
if(attr) {
switch(attr->mtype) {
diff --git a/include/kos/cond.h b/include/kos/cond.h
index 6cc9cf95..8b954007 100644
--- a/include/kos/cond.h
+++ b/include/kos/cond.h
@@ -60,48 +60,30 @@ __BEGIN_DECLS
*/
typedef struct condvar {
int dummy;
- int dynamic;
} condvar_t;
/** \brief Initializer for a transient condvar. */
-#define COND_INITIALIZER { 0, 0 }
-
-/** \brief Allocate a new condition variable.
-
- This function allocates and initializes a new condition variable for use.
-
- \deprecated
- This function is formally deprecated and should not be used in new code.
- Instead you should use either the static initializer or the cond_init()
- function.
-
- \return The created condvar on success. NULL is returned on
- failure and errno is set as appropriate.
-
- \par Error Conditions:
- \em ENOMEM - out of memory
-*/
-condvar_t *cond_create(void) __depr("Use cond_init or COND_INITIALIZER.");
+#define COND_INITIALIZER { 0 }
/** \brief Initialize a condition variable.
This function initializes a new condition variable for use.
\param cv The condition variable to initialize
- \retval 0 On success
- \retval -1 On error, sets errno as appropriate
+ \retval 0 On success (no error conditions currently defined)
*/
-int cond_init(condvar_t *cv);
+int cond_init(condvar_t *cv) __nonnull_all;
/** \brief Free a condition variable.
- This function frees a condition variable, releasing all memory associated
- with it (but not with the mutex that is associated with it). This will also
- wake all threads waiting on the condition.
+ This function destroys a condition variable (but not the mutex
+ that is associated with it). This will also wake all threads waiting
+ on the condition.
+ \param cv The condition variable to destroy
\retval 0 On success (no error conditions currently defined)
*/
-int cond_destroy(condvar_t *cv);
+int cond_destroy(condvar_t *cv) __nonnull_all;
/** \brief Wait on a condition variable.
@@ -124,7 +106,7 @@ int cond_destroy(condvar_t *cv);
\em EINVAL - the mutex is not initialized or not locked \n
\em ENOTRECOVERABLE - the condvar was destroyed while waiting
*/
-int cond_wait(condvar_t *cv, mutex_t * m);
+int cond_wait(condvar_t *cv, mutex_t * m) __nonnull_all;
/** \brief Wait on a condition variable with a timeout.
@@ -150,7 +132,7 @@ int cond_wait(condvar_t *cv, mutex_t * m);
\em EINVAL - the mutex is not initialized or not locked \n
\em ENOTRECOVERABLE - the condvar was destroyed while waiting
*/
-int cond_wait_timed(condvar_t *cv, mutex_t * m, int timeout);
+int cond_wait_timed(condvar_t *cv, mutex_t * m, int timeout) __nonnull_all;
/** \brief Signal a single thread waiting on the condition variable.
@@ -165,7 +147,7 @@ int cond_wait_timed(condvar_t *cv, mutex_t * m, int timeout);
\par Error Conditions:
\em EINVAL - the condvar was not initialized
*/
-int cond_signal(condvar_t *cv);
+int cond_signal(condvar_t *cv) __nonnull_all;
/** \brief Signal all threads waiting on the condition variable.
@@ -180,7 +162,7 @@ int cond_signal(condvar_t *cv);
\par Error Conditions:
\em EINVAL - the condvar was not initialized
*/
-int cond_broadcast(condvar_t *cv);
+int cond_broadcast(condvar_t *cv) __nonnull_all;
__END_DECLS
diff --git a/include/kos/genwait.h b/include/kos/genwait.h
index d2927f6a..0f480a73 100644
--- a/include/kos/genwait.h
+++ b/include/kos/genwait.h
@@ -47,7 +47,7 @@ __BEGIN_DECLS
\par Error Conditions:
\em EAGAIN - on timeout
*/
-int genwait_wait(void * obj, const char * mesg, int timeout, void (*callback)(void *));
+int genwait_wait(void *obj, const char *mesg, int timeout, void (*callback)(void *));
/* Wake up N threads waiting on the given object. If cnt is <=0, then we
wake all threads. Returns the number of threads actually woken. */
@@ -67,7 +67,7 @@ int genwait_wait(void * obj, const char * mesg, int timeout, void (*callback)(vo
threads.
\return The number of threads woken
*/
-int genwait_wake_cnt(void * obj, int cnt, int err);
+int genwait_wake_cnt(const void *obj, int cnt, int err);
/** \brief Wake up all threads sleeping on an object.
@@ -76,7 +76,7 @@ int genwait_wake_cnt(void * obj, int cnt, int err);
\param obj The object to wake threads that are sleeping on it
\see genwait_wake_cnt()
*/
-void genwait_wake_all(void * obj);
+void genwait_wake_all(const void *obj);
/** \brief Wake up one thread sleeping on an object.
@@ -85,7 +85,7 @@ void genwait_wake_all(void * obj);
\param obj The object to wake threads that are sleeping on it
\see genwait_wake_cnt()
*/
-void genwait_wake_one(void * obj);
+void genwait_wake_one(const void *obj);
/** \brief Wake up all threads sleeping on an object, with an error.
@@ -95,7 +95,7 @@ void genwait_wake_one(void * obj);
\param err The value to set in the threads' errno values
\see genwait_wake_cnt()
*/
-void genwait_wake_all_err(void *obj, int err);
+void genwait_wake_all_err(const void *obj, int err);
/** \brief Wake up one thread sleeping on an object, with an error.
@@ -105,7 +105,7 @@ void genwait_wake_all_err(void *obj, int err);
\param err The value to set in the threads' errno values
\see genwait_wake_cnt()
*/
-void genwait_wake_one_err(void *obj, int err);
+void genwait_wake_one_err(const void *obj, int err);
/** \brief Wake up a specific thread that is sleeping on an object.
@@ -113,7 +113,7 @@ void genwait_wake_one_err(void *obj, int err);
specified object.
\param obj The object to wake the thread from
- \param thd The specific thread to wake
+ \param thd The specific thread to wake (non-null).
\param err The errno code to set as the errno value on the
woken thread. If this is 0 (EOK), then the thread's
errno will not be changed, and the thread will get a
@@ -124,7 +124,7 @@ void genwait_wake_one_err(void *obj, int err);
\return The number of threads woken, which should be 1 on
success.
*/
-int genwait_wake_thd(void *obj, kthread_t *thd, int err);
+int genwait_wake_thd(const void *obj, kthread_t *thd, int err) __nonnull((2));
/** \brief Look for timed out genwait_wait() calls.
diff --git a/include/kos/mutex.h b/include/kos/mutex.h
index 243b5cc6..3fb273c6 100644
--- a/include/kos/mutex.h
+++ b/include/kos/mutex.h
@@ -66,8 +66,7 @@ __BEGIN_DECLS
\headerfile kos/mutex.h
*/
typedef struct kos_mutex {
- int type;
- int dynamic;
+ unsigned int type;
kthread_t *holder;
int count;
} mutex_t;
@@ -84,34 +83,20 @@ typedef struct kos_mutex {
#define MUTEX_TYPE_OLDNORMAL 1 /**< \brief Alias for MUTEX_TYPE_NORMAL */
#define MUTEX_TYPE_ERRORCHECK 2 /**< \brief Error-checking mutex type */
#define MUTEX_TYPE_RECURSIVE 3 /**< \brief Recursive mutex type */
+#define MUTEX_TYPE_DESTROYED 4 /**< \brief Mutex that has been destroyed */
/** \brief Default mutex type */
#define MUTEX_TYPE_DEFAULT MUTEX_TYPE_NORMAL
/** @} */
/** \brief Initializer for a transient mutex. */
-#define MUTEX_INITIALIZER { MUTEX_TYPE_NORMAL, 0, NULL, 0 }
+#define MUTEX_INITIALIZER { MUTEX_TYPE_NORMAL, NULL, 0 }
/** \brief Initializer for a transient error-checking mutex. */
-#define ERRORCHECK_MUTEX_INITIALIZER { MUTEX_TYPE_ERRORCHECK, 0, NULL, 0 }
+#define ERRORCHECK_MUTEX_INITIALIZER { MUTEX_TYPE_ERRORCHECK, NULL, 0 }
/** \brief Initializer for a transient recursive mutex. */
-#define RECURSIVE_MUTEX_INITIALIZER { MUTEX_TYPE_RECURSIVE, 0, NULL, 0 }
-
-/** \brief Allocate a new mutex.
-
- \deprecated
- This function allocates and initializes a new mutex for use. This function
- will always create mutexes of the type MUTEX_TYPE_NORMAL.
-
- \return The newly created mutex on success, or NULL on
- failure (errno will be set as appropriate).
-
- \note This function is formally deprecated. It should not
- be used in any future code, and may be removed in
- the future. You should instead use mutex_init().
-*/
-mutex_t *mutex_create(void) __depr("Use mutex_init or an initializer.");
+#define RECURSIVE_MUTEX_INITIALIZER { MUTEX_TYPE_RECURSIVE, NULL, 0 }
/** \brief Initialize a new mutex.
@@ -128,7 +113,7 @@ mutex_t *mutex_create(void) __depr("Use mutex_init or an initializer.");
\sa mutex_types
*/
-int mutex_init(mutex_t *m, int mtype);
+int mutex_init(mutex_t *m, unsigned int mtype) __nonnull_all;
/** \brief Destroy a mutex.
@@ -139,13 +124,15 @@ int mutex_init(mutex_t *m, int mtype);
This function can be called on statically initialized as well as dynamically
initialized mutexes.
+ \param m The mutex to destroy
+
\retval 0 On success
\retval -1 On error, errno will be set as appropriate
\par Error Conditions:
\em EBUSY - the mutex is currently locked
*/
-int mutex_destroy(mutex_t *m);
+int mutex_destroy(mutex_t *m) __nonnull_all;
/** \brief Lock a mutex.
@@ -165,7 +152,7 @@ int mutex_destroy(mutex_t *m);
\em EAGAIN - lock has been acquired too many times (recursive) \n
\em EDEADLK - would deadlock (error-checking)
*/
-int mutex_lock(mutex_t *m);
+int mutex_lock(mutex_t *m) __nonnull_all;
/** \brief Lock a mutex.
@@ -188,7 +175,7 @@ int mutex_lock(mutex_t *m);
already locked \n
\em EDEADLK - would deadlock (error-checking)
*/
-int mutex_lock_irqsafe(mutex_t *m);
+int mutex_lock_irqsafe(mutex_t *m) __nonnull_all;
/** \brief Lock a mutex (with a timeout).
@@ -211,7 +198,7 @@ int mutex_lock_irqsafe(mutex_t *m);
\em EAGAIN - lock has been acquired too many times (recursive) \n
\em EDEADLK - would deadlock (error-checking)
*/
-int mutex_lock_timed(mutex_t *m, int timeout);
+int mutex_lock_timed(mutex_t *m, int timeout) __nonnull_all;
/** \brief Check if a mutex is locked.
@@ -224,7 +211,7 @@ int mutex_lock_timed(mutex_t *m, int timeout);
\retval 0 If the mutex is not currently locked
\retval 1 If the mutex is currently locked
*/
-int mutex_is_locked(mutex_t *m);
+int mutex_is_locked(const mutex_t *m) __nonnull_all;
/** \brief Attempt to lock a mutex.
@@ -244,7 +231,7 @@ int mutex_is_locked(mutex_t *m);
\em EAGAIN - lock has been acquired too many times (recursive) \n
\em EDEADLK - would deadlock (error-checking)
*/
-int mutex_trylock(mutex_t *m);
+int mutex_trylock(mutex_t *m) __nonnull_all;
/** \brief Unlock a mutex.
@@ -259,7 +246,7 @@ int mutex_trylock(mutex_t *m);
\em EPERM - the current thread does not own the mutex (error-checking or
recursive)
*/
-int mutex_unlock(mutex_t *m);
+int mutex_unlock(mutex_t *m) __nonnull_all;
/** \brief Unlock a mutex under another thread's authority.
@@ -276,7 +263,7 @@ int mutex_unlock(mutex_t *m);
\em EPERM - the specified thread does not own the mutex \n
\em EACCES - called outside an IRQ handler
*/
-int mutex_unlock_as_thread(mutex_t *m, kthread_t *thd);
+int mutex_unlock_as_thread(mutex_t *m, kthread_t *thd) __nonnull_all;
/** \cond */
static inline void __mutex_scoped_cleanup(mutex_t **m) {
diff --git a/include/kos/recursive_lock.h b/include/kos/recursive_lock.h
deleted file mode 100644
index 83ae7588..00000000
--- a/include/kos/recursive_lock.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* KallistiOS ##version##
-
- include/kos/recursive_lock.h
- Copyright (C) 2008, 2010, 2012 Lawrence Sebald
-
-*/
-
-/** \file kos/recursive_lock.h
- \brief Definitions for a recursive mutex.
- \ingroup kthreads
-
- This file defines a recursive lock mechanism, similar to a mutex, but that a
- single thread can obtain as many times as it wants. A single thread is still
- limited to holding the lock at a time, but it can hold it an "unlimited"
- number of times (actually limited to INT_MAX, but who's counting).
-
- \deprecated
- These are now just wrappers around the MUTEX_TYPE_RECURSIVE that is now
- provided and will be removed at some point in the future. Please update your
- code to use that type instead.
-
- \author Lawrence Sebald
-*/
-
-#ifndef __KOS_RECURSIVE_LOCK_H
-#define __KOS_RECURSIVE_LOCK_H
-
-#include <kos/cdefs.h>
-
-__BEGIN_DECLS
-
-#include <kos/mutex.h>
-
-/** \brief Recursive lock structure.
-
- Recursive locks are just a simple wrapper around mutexes at this point. You
- should not use this type in any new code.
-
- \headerfile kos/recursive_lock.h
-*/
-typedef mutex_t recursive_lock_t;
-
-/** \brief Allocate a new recursive lock.
-
- \deprecated
- This function allocates a new recursive lock that is initially not locked.
-
- \return The created lock, or NULL on failure (errno will be set to ENOMEM to
- indicate that the system appears to be out of memory).
-*/
-recursive_lock_t *rlock_create(void) __depr("Use mutexes instead.");
-
-/** \brief Destroy a recursive lock.
-
- \deprecated
- This function cleans up a recursive lock. It is an error to attempt to
- destroy a locked recursive lock.
-
- \param l The recursive lock to destroy. It must be unlocked.
-*/
-void rlock_destroy(recursive_lock_t *l) __depr("Use mutexes instead.");
-
-/** \brief Lock a recursive lock.
-
- \deprecated
- This function attempts to lock the requested lock, and if it cannot it will
- block until that is possible.
-
- \param l The recursive lock to lock.
- \retval -1 On error, errno will be set to EPERM if this function is
- called inside an interrupt, or EINTR if it is interrupted.
- \retval 0 On success.
- \sa rlock_trylock
- \sa rlock_lock_timed
-*/
-int rlock_lock(recursive_lock_t *l) __depr("Use mutexes instead.");
-
-/** \brief Lock a recursive lock (with a timeout).
-
- \deprecated
- This function attempts to lock the requested lock, and if it cannot it will
- block until either it is possible to acquire the lock or timeout
- milliseconds have elapsed.
-
- \param l The recursive lock to lock.
- \param timeout The maximum number of milliseconds to wait. 0 is an
- unlimited timeout (equivalent to rlock_lock).
- \retval -1 On error, errno will be set to EPERM if this function is
- called inside an interrupt, EINTR if the function is
- interrupted, or EAGAIN if the timeout expires.
- \retval 0 On success.
- \sa rlock_trylock
- \sa rlock_lock_timed
-*/
-int rlock_lock_timed(recursive_lock_t *l, int timeout)
- __depr("Use mutexes instead.");
-
-/** \brief Unlock a recursive lock.
-
- \deprecated
- This function releases the lock one time from the current thread.
-
- \param l The recursive lock to unlock.
- \retval -1 On error, errno will be set to EPERM if the lock is not held
- by the calling thread.
- \retval 0 On success.
-*/
-int rlock_unlock(recursive_lock_t *l) __depr("Use mutexes instead.");
-
-/** \brief Attempt to lock a recursive lock without blocking.
-
- \deprecated
- This function attempts to lock a recursive lock without blocking. This
- function, unlike rlock_lock and rlock_lock_timed is safe to call inside an
- interrupt.
-
- \param l The recursive lock to lock.
- \retval -1 On error, errno will be set to EWOULDBLOCK if the lock is
- currently held by another thread.
- \retval 0 On success.
- \sa rlock_lock
- \sa rlock_lock_timed
-*/
-int rlock_trylock(recursive_lock_t *l) __depr("Use mutexes instead.");
-
-/** \brief Check if a recursive lock is currently held by any thread.
-
- \deprecated
- This function checks whether or not a lock is currently held by any thread,
- including the calling thread. Note that this is <b>NOT</b> a safe way to
- check if a lock <em>will</em> be held by the time you get around to locking
- it.
-
- \retval TRUE If the lock is held by any thread.
- \retval FALSE If the lock is not currently held by any thread.
-*/
-int rlock_is_locked(recursive_lock_t *l) __depr("Use mutexes instead.");
-
-__END_DECLS
-
-#endif /* !__KOS_RECURSIVE_LOCK_H */
diff --git a/include/kos/rwsem.h b/include/kos/rwsem.h
index ad2a05d2..d7612a63 100644
--- a/include/kos/rwsem.h
+++ b/include/kos/rwsem.h
@@ -41,9 +41,6 @@ __BEGIN_DECLS
\headerfile kos/rwsem.h
*/
typedef struct rw_semaphore {
- /** \brief Was this structure created with rwsem_create()? */
- int dynamic;
-
/** \brief The number of readers that are currently holding the lock. */
int read_count;
@@ -55,24 +52,7 @@ typedef struct rw_semaphore {
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 03:05:05
|
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 3df833497711472b1b0d8546dfcdf5031d3c6fe7 (commit)
from 5a91091e37421e9b15678dc086d111386f80fbbb (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 3df833497711472b1b0d8546dfcdf5031d3c6fe7
Author: Falco Girgis <gyr...@gm...>
Date: Mon Aug 4 22:04:49 2025 -0500
Added flag for disabling TLS for individual threads. (#1045)
I thought of a potential optimization the other day for how we handle
TLS that could lead to some RAM savings... Say that we KNOW a thread is
just some little simple task that is never accessing any TLS variables.
If we were able to tell the kernel this is the case, we could avoid
allocating a TLS segment that will never be used for that particular
thread.
...and we already have two very good use-cases immediately within the
kernel: the reaper and idle threads are not going to be accessing any
TLS variables, yet they're getting their own copies of them allocated
upon their creation.
1) Added THD_DISABLE_TLS to kthread_flags_t for signaling to the kernel
that we're not using TLS for a particular thread.
2) Added kthread_attr_t::disable_tls flag for telling the kernel we
don't want TLS when spawning a thread and passing its attributes.
- notice it's the last member of the struct, so I don't break
backwards compat, also it's the NEGATIVE so a 0 default value
keeps the old functionality
3) Added checks to thread.c when creating and destroying threads to see
whether THD_DISABLE_TLS is used, and if so, skip TLS segment
processing.
4) Made the [reaper] and [idle] threads, by default, disable TLS.
I validated these changes by rerunning my TLS test located in:
examples/dreamcast/basic/threading/compiler_tls. Everything looks good!
-----------------------------------------------------------------------
Summary of changes:
include/kos/thread.h | 18 ++++++++++--------
kernel/thread/thread.c | 33 +++++++++++++++++++--------------
2 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/include/kos/thread.h b/include/kos/thread.h
index 98457f43..581dc1af 100644
--- a/include/kos/thread.h
+++ b/include/kos/thread.h
@@ -4,7 +4,7 @@
Copyright (C) 2000, 2001, 2002, 2003 Megan Potter
Copyright (C) 2009, 2010, 2016, 2023 Lawrence Sebald
Copyright (C) 2023 Colton Pawielski
- Copyright (C) 2023, 2024 Falco Girgis
+ Copyright (C) 2023, 2024, 2025 Falco Girgis
*/
@@ -128,11 +128,12 @@ LIST_HEAD(ktlist, kthread);
@{
*/
-#define THD_DEFAULTS 0 /**< \brief Defaults: no flags */
-#define THD_USER 1 /**< \brief Thread runs in user mode */
-#define THD_QUEUED 2 /**< \brief Thread is in the run queue */
-#define THD_DETACHED 4 /**< \brief Thread is detached */
-#define THD_OWNS_STACK 8 /**< \brief Thread manages stack lifetime */
+#define THD_DEFAULTS 0x0 /**< \brief Defaults: no flags */
+#define THD_USER 0x1 /**< \brief Thread runs in user mode */
+#define THD_QUEUED 0x2 /**< \brief Thread is in the run queue */
+#define THD_DETACHED 0x4 /**< \brief Thread is detached */
+#define THD_OWNS_STACK 0x8 /**< \brief Thread manages stack lifetime */
+#define THD_DISABLE_TLS 0x10 /**< \brief Thread does not use TLS variables */
/** @} */
/** \brief Kernel thread flags type */
@@ -150,8 +151,6 @@ typedef enum kthread_state {
STATE_FINISHED = 0x0004 /**< \brief Finished execution */
} kthread_state_t;
-
-
/** \brief Structure describing one running thread.
Each thread has one of these structures assigned to it, which holds all the
@@ -289,6 +288,9 @@ typedef struct kthread_attr {
/** \brief Thread label. */
const char *label;
+
+ /** \brief 1 if the thread doesn't use thread_local variables. */
+ bool disable_tls;
} kthread_attr_t;
/** \brief kthread mode values
diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c
index 374235a2..1a4b20f0 100644
--- a/kernel/thread/thread.c
+++ b/kernel/thread/thread.c
@@ -4,7 +4,7 @@
Copyright (C) 2000, 2001, 2002, 2003 Megan Potter
Copyright (C) 2010, 2016, 2023 Lawrence Sebald
Copyright (C) 2023 Colton Pawielski
- Copyright (C) 2023, 2024 Falco Girgis
+ Copyright (C) 2023, 2024, 2025 Falco Girgis
*/
#include <assert.h>
@@ -368,7 +368,7 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr,
kthread_t *nt = NULL;
tid_t tid;
uint32_t params[4];
- kthread_attr_t real_attr = { false, THD_STACK_SIZE, NULL, PRIO_DEFAULT, NULL };
+ kthread_attr_t real_attr = { false, THD_STACK_SIZE, NULL, PRIO_DEFAULT, NULL, false };
if(attr)
real_attr = *attr;
@@ -430,8 +430,10 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr,
((uint32_t)nt->stack) + nt->stack_size,
(uint32_t)thd_birth, params, 0);
- /* Create static TLS data */
- if(!arch_tls_setup_data(nt)) {
+ /* Create static TLS data if the thread hasn't disabled it. */
+ if(real_attr.disable_tls) {
+ nt->flags |= THD_DISABLE_TLS;
+ } else if(!arch_tls_setup_data(nt)) {
if(nt->flags & THD_OWNS_STACK)
free(nt->stack);
free(nt);
@@ -526,8 +528,9 @@ int thd_destroy(kthread_t *thd) {
if(thd->flags & THD_OWNS_STACK)
free(thd->stack);
- /* Free static TLS segment */
- arch_tls_destroy_data(thd);
+ /* Free static TLS segment (if it hasn't been disabled for the thread). */
+ if(!(thd->flags & THD_DISABLE_TLS))
+ arch_tls_destroy_data(thd);
/* Free the thread */
free(thd);
@@ -1004,17 +1007,19 @@ int thd_init(void) {
};
const kthread_attr_t reaper_attr = {
- .stack_size = sizeof(thd_reaper_stack),
- .stack_ptr = thd_reaper_stack,
- .prio = 1,
- .label = "[reaper]"
+ .stack_size = sizeof(thd_reaper_stack),
+ .stack_ptr = thd_reaper_stack,
+ .prio = 1,
+ .label = "[reaper]"
+ .disable_tls = true
};
const kthread_attr_t idle_attr = {
- .stack_size = sizeof(thd_idle_stack),
- .stack_ptr = thd_idle_stack,
- .prio = PRIO_MAX,
- .label = "[idle]"
+ .stack_size = sizeof(thd_idle_stack),
+ .stack_ptr = thd_idle_stack,
+ .prio = PRIO_MAX,
+ .label = "[idle]"
+ .disable_tls = true
};
kthread_t *kern;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-05 01:37:02
|
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 5a91091e37421e9b15678dc086d111386f80fbbb (commit)
via 9eed2f87c13767ff7cd4319170590351d9032011 (commit)
via feced843b61d21e763a49076a32e2c41d630b73d (commit)
via e4cd188dfab4bff57d99af90b6dbcea1771109c6 (commit)
via fedd55333c64220d02a317c890faf5c0376c5b84 (commit)
via 8ac11fbb5c7a37a05a3a5c8e6414eefb7c0b3cec (commit)
from 1126528da063d0b81254d9a71f9fda683c1815b4 (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 5a91091e37421e9b15678dc086d111386f80fbbb
Author: Falco Girgis <gyr...@gm...>
Date: Mon Aug 4 19:06:24 2025 -0500
REALLY addressed review feedback.
commit 9eed2f87c13767ff7cd4319170590351d9032011
Author: Falco Girgis <gyr...@gm...>
Date: Mon Aug 4 19:05:20 2025 -0500
Addressed review feedback.
commit feced843b61d21e763a49076a32e2c41d630b73d
Author: Falco Girgis <gyr...@gm...>
Date: Mon Aug 4 18:57:29 2025 -0500
Addressed review feedback.
commit e4cd188dfab4bff57d99af90b6dbcea1771109c6
Author: Falco Girgis <gyr...@gm...>
Date: Mon Aug 4 15:51:30 2025 -0500
Addressed review feedback + added optional name.
commit fedd55333c64220d02a317c890faf5c0376c5b84
Author: Falco Girgis <gyr...@gm...>
Date: Sat Aug 2 16:48:28 2025 -0500
Addressed review feedback. Much cleaner now.
commit 8ac11fbb5c7a37a05a3a5c8e6414eefb7c0b3cec
Author: Falco Girgis <gyr...@gm...>
Date: Sat Aug 2 16:27:44 2025 -0500
Added kos_run_target() to CMake toolchain.
It's currently a total PITA to run a CMake project you're actively
building... you gotta go find the binary output wherever CMake puts it
by default and call dc-tool with it..
We already have a nice, convenient, standardized rule for this kind of
crap in all of our Makefiles, which you can call with "make run." It
simply uses the KOS_LOADER environment variable configured from
environ.sh.
This PR is an attempt to map this functionality to CMake as directly as
possible.
-----------------------------------------------------------------------
Summary of changes:
utils/cmake/dreamcast.cmake | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/utils/cmake/dreamcast.cmake b/utils/cmake/dreamcast.cmake
index a8f7b5a4..6c18e558 100644
--- a/utils/cmake/dreamcast.cmake
+++ b/utils/cmake/dreamcast.cmake
@@ -1,12 +1,13 @@
# Auxiliary CMake Utility Functions
# Copyright (C) 2023 Colton Pawielski
-# Copyright (C) 2024 Falco Girgis
+# Copyright (C) 2024, 2025 Falco Girgis
# Copyright (C) 2024 Paul Cercueil
#
# This file implements utilities for the following additional functionality
# which exists in the KOS Make build system:
# 1) linking to existing binaries
# 2) adding a romdisk
+# 3) running the binary using KOS_LOADER
#
# NOTE: When using the KOS CMake toolchain file, you do not need to include
# this file directly!
@@ -31,13 +32,33 @@ if(NOT DEFINED KOS_CC_BASE)
endif()
endif()
+### Adds a custom "run" target which uses $KOS_LOADER to run the given target. ###
+function(kos_run_target target)
+ # targetName is optional and defaults to "run" when not provided.
+ if(NOT ${ARGC} EQUAL 2)
+ set(runTarget run)
+ else()
+ set(runTarget ${ARGV1})
+ endif()
+
+ # Convert KOS ENV variable to semicolon-separated list of args
+ string(REPLACE " " ";" _kos_loader $ENV{KOS_LOADER})
+
+ # Create a new target which simply passes the source target to $KOS_LOADER to run
+ add_custom_target(${runTarget}
+ COMMAND ${_kos_loader};$<TARGET_FILE:${target}>
+ DEPENDS ${target}
+ USES_TERMINAL
+ )
+endfunction()
+
### Helper Function for Bin2Object ###
function(kos_bin2o inFile symbol)
# outFile is optional and defaults to the symbol name in the build directory
if(NOT ${ARGC} EQUAL 3)
set(outFile ${CMAKE_CURRENT_BINARY_DIR}/${symbol}.o)
else()
- set(outFile ${ARGN})
+ set(outFile ${ARGV2})
endif()
# Custom Command to generate romdisk object file from image
@@ -61,7 +82,7 @@ function(kos_add_romdisk target romdiskPath)
if(NOT ${ARGC} EQUAL 3)
set(romdiskName romdisk)
else()
- set(romdiskName ${ARGN})
+ set(romdiskName ${ARGV2})
endif()
file(REAL_PATH "${romdiskPath}" romdiskPath)
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-04 19:31:14
|
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 1126528da063d0b81254d9a71f9fda683c1815b4 (commit)
via b049605c316ce5cd7fe8c2c7ad7d3b5cb6dafda0 (commit)
via d8022a6cef850f16e43d4734f1fa7cd4b889b99d (commit)
via 45ea2ae4d55a8e000f868b8519a3f9ad81717920 (commit)
from 6d7a039b48130587c9063defc9454cc2b0946e51 (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 1126528da063d0b81254d9a71f9fda683c1815b4
Author: QuzarDC <qu...@co...>
Date: Fri Aug 1 15:24:11 2025 -0400
fs_vmu: Use new dbglog source functionality for verbose debug.
Additionally add the include for <kos/opts.h> which was missing.
This was getting chained in pretty much accidentally from kos/fs.h.
commit b049605c316ce5cd7fe8c2c7ad7d3b5cb6dafda0
Author: QuzarDC <qu...@co...>
Date: Fri Aug 1 15:08:09 2025 -0400
dbglog: Provide functionality for source-specific verbose debugging.
We provide many of these throughout the codebase where a single
driver, subsystem, or file will have its own define to set if
extra verbose or detailed debug info is outputted for it. These
have been cumbersome to use as they rarely had a unified style
or mechanisms, and presumed the defined would be set in the
individual source file.
Even once these options were made available in opts.h, it was
quite inconsistent as each implementation might use different
mechanisms (printf vs dbglog, for instance).
Now, instead, dbglog allows a 'level' to be passed which takes
a define that if defined means output regardless of the set level,
and if not defined will only output in the new 'DBG_MAX' setting
which explicitly has all dbglogs output.
commit d8022a6cef850f16e43d4734f1fa7cd4b889b99d
Author: QuzarDC <qu...@co...>
Date: Fri Aug 1 06:16:18 2025 -0400
dbglog: Add option to compile-time disable/limit debug logging.
This should help allow debug messages to be garbage collected,
and provide simpler steps for a release build when paired with
NDEBUG. `DBGLOG_LEVEL_SUPPORT` can be set to a dbglog level in
order to cap the level available at runtime to that amount.
`DBGLOG_DISABLED` overrides this down to disallow any output.
As the actual function backing `dbglog` is now named differently
this had to be updated in the exports. I've additionally moved it
out of the stdio section to reflect that it's kos-internal and
no longer is being shared with stdio after #1000 .
commit 45ea2ae4d55a8e000f868b8519a3f9ad81717920
Author: QuzarDC <qu...@co...>
Date: Fri Aug 1 05:30:10 2025 -0400
dbglog: Lower the default debug level.
`DBG_INFO` is noted as being a good level, so lets use that.
It never made much sense to have this default to the highest
setting, and it's a frequent user complaint.
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 11 ++++++-----
include/kos/dbglog.h | 24 +++++++++++++++++++++---
include/kos/opts.h | 15 ++++++++++++++-
kernel/arch/dreamcast/fs/fs_vmu.c | 24 +++++++++---------------
kernel/exports.txt | 2 +-
kernel/libc/koslib/dbglog.c | 9 +++++----
6 files changed, 56 insertions(+), 29 deletions(-)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index bdee2cb7..e23238c7 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -124,13 +124,14 @@ export KOS_LDFLAGS=""
export KOS_AFLAGS=""
export DC_ARM_LDFLAGS=""
-# Debug Builds
+# Debug Options
#
-# Controls whether to disable additional debugging checks and assertions,
-# such as for parameter validation or internal errors. Uncomment this if
-# you do not wish to compile with this additional logic enabled.
+# NDEBUG controls whether to disable `assert` per C standard, and
+# DBGLOG_DISABLED controls whether other debug output will be provided
+# (see ./kos/dbglog.h). Enable these if you want to remove assert checks
+# and disable logging output, as is desirable for release builds.
#
-#export KOS_CFLAGS="${KOS_CFLAGS} -DNDEBUG"
+#export KOS_CFLAGS="${KOS_CFLAGS} -DNDEBUG -DDBGLOG_DISABLED"
# Optimization Level
#
diff --git a/include/kos/dbglog.h b/include/kos/dbglog.h
index f9c87fc6..4b8bd1ca 100644
--- a/include/kos/dbglog.h
+++ b/include/kos/dbglog.h
@@ -22,13 +22,15 @@
#include <kos/cdefs.h>
__BEGIN_DECLS
+#include <kos/opts.h>
+
/** \defgroup logging Logging
\brief KOS's Logging API
\ingroup debugging
*/
/** \brief Kernel debugging printf.
- \ingroup logging
+ \ingroup logging
This function is similar to printf(), but filters its output through a log
level check before being printed. This way, you can set the level of debug
@@ -39,7 +41,14 @@ __BEGIN_DECLS
\param ... Format arguments
\see dbglog_levels
*/
-void dbglog(int level, const char *fmt, ...) __printflike(2, 3);
+void __real_dbglog(int level, const char *fmt, ...) __printflike(2, 3);
+
+/* This wrapper allows for the garbage collection of unneeded debug data */
+#define dbglog(lvl, ...) \
+do { \
+ if ((lvl) <= DBGLOG_LEVEL_SUPPORT) \
+ __real_dbglog(lvl, __VA_ARGS__); \
+} while(0)
/** \defgroup dbglog_levels Log Levels
\brief dbglog severity levels
@@ -48,8 +57,13 @@ void dbglog(int level, const char *fmt, ...) __printflike(2, 3);
This is the list of levels that are allowed to be passed into the dbglog()
function, representing different levels of importance.
+ For `DBG_SOURCE()` pass to it a define that controls specific debugging
+ and if the define is defined, the logging will be outputted. If not defined
+ the messages will only be outputted if the level is set to `DBG_MAX`.
+
@{
*/
+#define DBG_DISABLED -1 /**< \brief No output allowed */
#define DBG_DEAD 0 /**< \brief The system is dead */
#define DBG_CRITICAL 1 /**< \brief A critical error message */
#define DBG_ERROR 2 /**< \brief A normal error message */
@@ -58,13 +72,17 @@ void dbglog(int level, const char *fmt, ...) __printflike(2, 3);
#define DBG_INFO 5 /**< \brief Informational messages */
#define DBG_DEBUG 6 /**< \brief User debug messages */
#define DBG_KDEBUG 7 /**< \brief Kernel debug messages */
+#define DBG_MAX 8 /**< \brief All debug outputted */
+
+#define DBG_SOURCE(x) (__is_defined(x) ? DBG_DEAD : DBG_MAX) /**< \brief Verbose debugging of specific systems */
/** @} */
/** \brief Set the debugging log level.
\ingroup logging
This function sets the level for which dbglog() will ignore messages for if
- the message has a higher level.
+ the message has a higher level. This runtime setting does not override the
+ `DBGLOG_LEVEL_SUPPORT` define.
\param level The level to stop paying attention after.
\see dbglog_levels
diff --git a/include/kos/opts.h b/include/kos/opts.h
index 8000da10..069d9c65 100644
--- a/include/kos/opts.h
+++ b/include/kos/opts.h
@@ -42,10 +42,23 @@ __BEGIN_DECLS
@{
*/
+/* Completely disable debug logging at compile time if defined. */
+/* #define DBGLOG_DISABLED */
+
+/* Set the maximum allowed dbglog level. Normally the level is adjustable at
+ runtime, but that means keeping all debug information even in release builds. */
+#ifdef DBGLOG_DISABLED
+#define DBGLOG_LEVEL_SUPPORT -1
+#endif
+
+/* This retains the old behavior of all debugging being retained for runtime */
+#ifndef DBGLOG_LEVEL_SUPPORT
+#define DBGLOG_LEVEL_SUPPORT 127
+#endif
+
/* Enable debugging in fs_vmu. */
/* #define VMUFS_DEBUG 1 */
-
/* Enable to allow extra debugging checks in the malloc code itself. This
sometimes catches corrupted blocks. Recommended during debugging phases. */
/* #define MALLOC_DEBUG 1 */
diff --git a/kernel/arch/dreamcast/fs/fs_vmu.c b/kernel/arch/dreamcast/fs/fs_vmu.c
index 59ffc09c..54b97c1f 100644
--- a/kernel/arch/dreamcast/fs/fs_vmu.c
+++ b/kernel/arch/dreamcast/fs/fs_vmu.c
@@ -15,6 +15,7 @@
#include <arch/types.h>
#include <kos/mutex.h>
+#include <kos/opts.h>
#include <kos/dbglog.h>
#include <dc/fs_vmu.h>
#include <dc/vmufs.h>
@@ -42,11 +43,10 @@ Note: this new version now talks directly to the vmufs module and doesn't do
any block-level I/O anymore. This layer and that one are interchangeable
and may be used pretty much simultaneously in the same program.
+Define VMUFS_DEBUG in kos/opts.h, in your CFLAGS, or here if you want copious
+debug output.
*/
-/* Enable this if you want copious debug output */
-/* #define VMUFS_DEBUG */
-
#define VMU_DIR 0
#define VMU_FILE 1
#define VMU_ANY -1 /* Used for checking validity */
@@ -167,16 +167,13 @@ static vmu_fh_t *vmu_open_vmu_dir(void) {
names[num][1] = u + '0';
num++;
- if(__is_defined(VMUFS_DEBUG)) {
- dbglog(DBG_KDEBUG, "vmu_open_vmu_dir: found memcard (%c%d)\n",
- 'a' + p, u);
- }
+ dbglog(DBG_SOURCE(VMUFS_DEBUG), "vmu_open_vmu_dir: found memcard (%c%d)\n",
+ 'a' + p, u);
}
}
}
- if(__is_defined(VMUFS_DEBUG))
- dbglog(DBG_KDEBUG, "# of memcards found: %d\n", num);
+ dbglog(DBG_SOURCE(VMUFS_DEBUG), "# of memcards found: %d\n", num);
if(!(dh = malloc(sizeof(vmu_dh_t))))
return NULL;
@@ -501,8 +498,7 @@ static ssize_t vmu_write(void * hnd, const void *buffer, size_t cnt) {
n = n / 512;
- if(__is_defined(VMUFS_DEBUG))
- dbglog(DBG_KDEBUG, "VMUFS: extending file's filesize by %d\n", n);
+ dbglog(DBG_SOURCE(VMUFS_DEBUG), "VMUFS: extending file's filesize by %d\n", n);
/* We alloc another 512*n bytes for the file */
tmp = realloc(fh->data, (fh->filesize + n) * 512);
@@ -519,10 +515,8 @@ static ssize_t vmu_write(void * hnd, const void *buffer, size_t cnt) {
}
/* insert the data in buffer into fh->data at fh->loc */
- if(__is_defined(VMUFS_DEBUG)) {
- dbglog(DBG_KDEBUG, "VMUFS: adding %d bytes of data at loc %ld (%ld avail)\n",
- cnt, fh->loc, fh->filesize * 512);
- }
+ dbglog(DBG_SOURCE(VMUFS_DEBUG), "VMUFS: adding %d bytes of data at loc %ld (%ld avail)\n",
+ cnt, fh->loc, fh->filesize * 512);
memcpy(fh->data + fh->loc + fh->start, buffer, cnt);
fh->loc += cnt;
diff --git a/kernel/exports.txt b/kernel/exports.txt
index ef26e64e..676a5173 100644
--- a/kernel/exports.txt
+++ b/kernel/exports.txt
@@ -36,7 +36,6 @@ ftell
fflush
rewind
fputc
-dbglog
sprintf
vsprintf
@@ -188,6 +187,7 @@ dcache_purge_range
dcache_purge_all
# Low-level debug I/O
+__real_dbglog
dbgio_set_irq_usage
dbgio_enable
dbgio_disable
diff --git a/kernel/libc/koslib/dbglog.c b/kernel/libc/koslib/dbglog.c
index d37f529a..47a5b18e 100644
--- a/kernel/libc/koslib/dbglog.c
+++ b/kernel/libc/koslib/dbglog.c
@@ -13,6 +13,7 @@
#include <kos/thread.h>
#include <kos/dbgio.h>
#include <kos/fs.h>
+
#include <arch/spinlock.h>
/* Not re-entrant */
@@ -22,7 +23,7 @@ static spinlock_t mutex = SPINLOCK_INITIALIZER;
/* Default kernel debug log level: if a message has a level higher than this,
it won't be shown. Set to DBG_DEAD to see basically nothing, and set to
DBG_KDEBUG to see everything. DBG_INFO is generally a decent level. */
-int dbglog_level = DBG_KDEBUG;
+int dbglog_level = (DBGLOG_LEVEL_SUPPORT < DBG_INFO) ? DBGLOG_LEVEL_SUPPORT : DBG_INFO;
/* Set debug level */
void dbglog_set_level(int level) {
@@ -30,12 +31,12 @@ void dbglog_set_level(int level) {
}
/* Kernel debug logging facility */
-void dbglog(int level, const char *fmt, ...) {
+void __real_dbglog(int level, const char *fmt, ...) {
va_list args;
int i;
/* If this log level is blocked out, don't even bother */
- if(level > dbglog_level)
+ if((DBGLOG_LEVEL_SUPPORT < level) || (level > dbglog_level))
return;
/* We only try to lock if the message isn't urgent */
@@ -49,7 +50,7 @@ void dbglog(int level, const char *fmt, ...) {
if(i > 0) {
if(irq_inside_int() ||
(fs_write(STDOUT_FILENO, printf_buf, strlen(printf_buf)) < 0))
- dbgio_write_str(printf_buf);
+ dbgio_write_str(printf_buf);
}
if(level >= DBG_ERROR && !irq_inside_int())
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-04 19:30:42
|
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 6d7a039b48130587c9063defc9454cc2b0946e51 (commit)
from 75e5b0163e14034be800e1bdf5a642f0b7f0f1dc (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 6d7a039b48130587c9063defc9454cc2b0946e51
Author: darc <da...@pr...>
Date: Mon Aug 4 13:54:34 2025 -0500
Move arch-specific ELF definitions from elf.c to arch.h
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/include/arch/arch.h | 12 +++++++++++-
kernel/fs/elf.c | 10 ----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h
index 112bb187..cbc731cc 100644
--- a/kernel/arch/dreamcast/include/arch/arch.h
+++ b/kernel/arch/dreamcast/include/arch/arch.h
@@ -25,6 +25,7 @@ __BEGIN_DECLS
#include <stdbool.h>
#include <arch/types.h>
+#include <kos/elf.h>
/** \defgroup arch Architecture
\brief Dreamcast Architecture-Specific Options and high-level API
@@ -44,7 +45,7 @@ extern uint32 _arch_mem_top;
/** \brief Start and End address for .text portion of program. */
extern char _executable_start;
-extern char _etext;
+extern char _etext;
#define PAGESIZE 4096 /**< \brief Page size (for MMU) */
#define PAGESIZE_BITS 12 /**< \brief Bits for page size */
@@ -112,6 +113,15 @@ unsigned HZ __depr("Please use the new THD_SCHED_HZ macro.") = THD_SCHED_HZ;
/** \brief Length of global symbol prefix in ELF files. */
#define ELF_SYM_PREFIX_LEN 1
+/** \brief ELF class for this architecture. */
+#define ARCH_ELFCLASS ELFCLASS32
+
+/** \brief ELF data encoding for this architecture. */
+#define ARCH_ELFDATA ELFDATA2LSB
+
+/** \brief ELF machine type code for this architecture. */
+#define ARCH_CODE EM_SH
+
/** \brief Panic function.
This function will cause a kernel panic, printing the specified message.
diff --git a/kernel/fs/elf.c b/kernel/fs/elf.c
index c652806c..69b939d1 100644
--- a/kernel/fs/elf.c
+++ b/kernel/fs/elf.c
@@ -17,16 +17,6 @@
#include <kos/library.h>
#include <kos/dbglog.h>
-/* What's our architecture code we're expecting? */
-#if defined(_arch_dreamcast)
-# define ARCH_ELFCLASS ELFCLASS32 /* Dreamcast is 32-bit */
-# define ARCH_ELFDATA ELFDATA2LSB /* and little endian */
-# define ARCH_CODE EM_SH /* and uses an SH processor. */
-#else
-# error Unknown architecture
-#endif
-
-
/* Finds a given symbol in a relocated ELF symbol table */
static int find_sym(char *name, elf_sym_t *table, int tablelen) {
int i;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-04 19:00:38
|
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 75e5b0163e14034be800e1bdf5a642f0b7f0f1dc (commit)
via 32cfa1b72a5fde8f0bb83099fe2b6cd1f78f3e7c (commit)
via e7639e8b10b8542f22d94c426019f916dbf8754a (commit)
via 038db776feab17caa7986b4b29de2683fd96bdb3 (commit)
via 3b7e0bb5c55cc02b4bceec94d4cd96bc58618e2a (commit)
via 23b06506f768ac58988fd1cecd61ff7d1d42e20d (commit)
via 8de3fb5b7faffce275bb1cbf0c33ff44c720176a (commit)
via 14786c83f0905ed5e9e762dbfa282673b74f7f7e (commit)
via 261e4df25f1e5753af9c6ace43123700275f8724 (commit)
via 740e9ee6be796c7cc1d27afe8e95efcbbc63f0cf (commit)
via f6ebd5a9c477b778329e7ff5e2f4d00db134d2e1 (commit)
via d2e2655dec4ca3615a4e292ac124dc2cdc17dbba (commit)
via 7adf052d7b9ab755ad639f835355831e90ad3677 (commit)
via 36a44891ed3c905157801bf516aa17e7a7e0694a (commit)
via e31d21543d377151a3f8c9ce36496c994b457bf0 (commit)
via ccd733e30e3dd2fc072ca990b78a08cddf82da04 (commit)
via b925b8788557bbda5e85eccc8eca53991634ddb2 (commit)
via 1b51d1163db266572d062cd422f89010149c199f (commit)
via a5ffd1f2c185fc8bbb7d024608bb9b29e2365263 (commit)
via e1e1e59b628e986f228443d8f40d05551a6a7b80 (commit)
via 5c448267deae6a12bc1ccd0c70890e821b1b30d6 (commit)
via 66a2ca45e138282d4dc28c14660b2dbd8c21ad22 (commit)
via 22f208393b42b9f64b27e097296fb4d4e7684548 (commit)
via e66557eb2684e2ef1ff1d82cddee233e2f92905f (commit)
via 21c30655a9726d9e1b5fed14441b80f75c02c31f (commit)
via 35c23cac5a4e3d141cb4b285234fa7f178298b27 (commit)
from 6b306eb2fb8054fc60b46cc06ea09eb45fa4cb4a (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 75e5b0163e14034be800e1bdf5a642f0b7f0f1dc
Author: Paul Cercueil <pa...@cr...>
Date: Mon Aug 4 17:30:08 2025 +0200
dc-chain: Update build instructions
Update the build instructions in the README.md to reflect the new
changes.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 32cfa1b72a5fde8f0bb83099fe2b6cd1f78f3e7c
Author: Paul Cercueil <pa...@cr...>
Date: Fri Jul 25 00:36:59 2025 +0200
dc-chain: Drop useless change in GCC patches
Those are not needed anymore as the fake-kos.c file provides the symbols
needed to compile and link a program that calls printf().
Signed-off-by: Paul Cercueil <pa...@cr...>
commit e7639e8b10b8542f22d94c426019f916dbf8754a
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jul 24 20:45:56 2025 +0200
dc-chain: Add missing symbols to fake-kos.c
Add missing symbols that are needed for libobjc to compile properly.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 038db776feab17caa7986b4b29de2683fd96bdb3
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jul 23 10:25:04 2025 +0200
dc-chain: Add __is_aligned() macro fix to Newlib patches
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 3b7e0bb5c55cc02b4bceec94d4cd96bc58618e2a
Author: Paul Cercueil <pa...@cr...>
Date: Sun Jul 13 17:36:38 2025 +0200
dc-chain: doc: Update path of default Dreamcast Makefile config
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 23b06506f768ac58988fd1cecd61ff7d1d42e20d
Author: Paul Cercueil <pa...@cr...>
Date: Sun Jul 13 17:33:28 2025 +0200
dc-chain: doc: Update changelog
Add a description of my changes in the changelog.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 8de3fb5b7faffce275bb1cbf0c33ff44c720176a
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jul 9 16:01:28 2025 +0200
dc-chain: Add 15.0.0-lra toolchain profile
This toolchain profile can be used to test a toolchain with GCC's new
LRA register allocator instead of the old one.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 14786c83f0905ed5e9e762dbfa282673b74f7f7e
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 22:51:10 2025 +0200
dc-chain: Add AICA toolchain profile
Add a toolchain profile to build a toolchain for the Dreamcast's AICA
sound co-processor.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 261e4df25f1e5753af9c6ace43123700275f8724
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jun 26 15:31:21 2025 +0200
dc-chain: Add patches for GCC 8.5.0
GCC 8.5.0 is the last one that supports the ARM7DI processor.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 740e9ee6be796c7cc1d27afe8e95efcbbc63f0cf
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 14:21:53 2025 +0200
dc-chain: Add support for PPC toolchains and add GameCube profile
Add support for building a powerpc-eabi toolchain, and add a profile for
the Nintendo GameCube.
Update the KOS patch for newlib and cherry-pick two patches from master
to fix building on PowerPC.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit f6ebd5a9c477b778329e7ff5e2f4d00db134d2e1
Author: Paul Cercueil <pa...@cr...>
Date: Sun Jul 13 17:16:21 2025 +0200
dc-chain: Remove multiple files in one single command
There's no need to run multiple "rm -rf" commands when a single one can
do the job.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit d2e2655dec4ca3615a4e292ac124dc2cdc17dbba
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jul 2 16:32:58 2025 +0200
dc-chain: Detect and use number of CPU cores
Instead of hardcoding the default number of jobs to 2 (which is very low
by today's standards), leave the 'makejobs=' variable empty by default,
and update the Makefile scripts to automatically detect the number of
logical CPU cores, and use that as the number of jobs.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 7adf052d7b9ab755ad639f835355831e90ad3677
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jul 2 15:46:44 2025 +0200
dc-chain: Do shallow clones of git repositories
We don't need the whole history tree of the git repositories we want to
clone. Shave off the download size (and therefore the build size) by
performing shallow clones.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 36a44891ed3c905157801bf516aa17e7a7e0694a
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jul 2 15:09:09 2025 +0200
dc-chain: Don't override the toolchain's crt1.S
This is not needed anymore, as the linker script will pick the startup
code itself.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit e31d21543d377151a3f8c9ce36496c994b457bf0
Author: Paul Cercueil <pa...@cr...>
Date: Sun Jun 29 22:39:40 2025 +0200
Rework how startup code is handled
Instead of building the arch's startup.o and copying it inside the
toolchain as crt1.o, point the linker script to the correct startup
code from the KallistiOS lib folder.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit ccd733e30e3dd2fc072ca990b78a08cddf82da04
Author: Paul Cercueil <pa...@cr...>
Date: Sun Jun 29 22:37:40 2025 +0200
environ.sh: Drop $KOS_START
This was only used with GCC < 4.0, which we don't support anymore.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit b925b8788557bbda5e85eccc8eca53991634ddb2
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jun 26 15:04:15 2025 +0200
dc-chain: Drop old KOS defines, move the rest to common GCC config file
The toolchain will only now just provide the __KOS_GCC_PATCHLEVEL__
macro. From the version specified there, KallistiOS can then figure out
whether or not it supports 32 MiB of RAM.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 1b51d1163db266572d062cd422f89010149c199f
Author: Paul Cercueil <pa...@cr...>
Date: Sat Jun 28 16:39:18 2025 +0200
dreamcast: Add support for toolchains without __KOS_GCC_32MB__
Newer toolchains don't define __KOS_GCC_32MB__ anymore as KOS does not
support any of the older toolchains not capable of 32 MiB RAM support.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit a5ffd1f2c185fc8bbb7d024608bb9b29e2365263
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jun 25 21:06:24 2025 +0200
dc-chain: Replace arch-specific fake-kos.S with C code
The fake-kos.S files were only defining weak symbols as aliases to a
dummy function. This can be done in C as well; the advantage being that
the same C code can be used on all architectures.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit e1e1e59b628e986f228443d8f40d05551a6a7b80
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jun 25 15:54:17 2025 +0200
dc-chain: Rework patch folders and support target-specific patches
Differenciate between the target-specific and host-specific patches to
keep the patches folder clean.
Add a target-specific search path for patches, so that it is possible to
conditionally patch the code according to the target arch.
Drop the execution rights on the newlib-4.3.0.20230120-kos.diff patch.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 5c448267deae6a12bc1ccd0c70890e821b1b30d6
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 10:27:50 2025 +0200
dc-chain: Support multiple archs and decouple ARM
Instead of having all the scripts handle two architectures
(SH4 and ARM), with all rules duplicated, update them so that they will
support the architecture specified in the "platform" variable.
This means that the exact same scripts can be used for building the SH4
toolchain, and also the ARM toolchain. Later, it will also allow
building toolchains for other platforms.
One interesting side effect of this change is that a C library is now
built for the ARM.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 66a2ca45e138282d4dc28c14660b2dbd8c21ad22
Author: Paul Cercueil <pa...@cr...>
Date: Sun Jun 22 21:51:53 2025 +0200
dc-chain: Move gthr-kos.h to non-arch-specific path
The gthr-kos.h is not arch-specific. To avoid having to hardcode
different paths for different archs in the GCC patches, install the
gthr-kos.h file to an arch-independent path in libgcc.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 22f208393b42b9f64b27e097296fb4d4e7684548
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 21:52:14 2025 +0200
dc-chain: Move profiles to platform subdirectory
To ease the introduction of multiarch in dc-chain, move the current
profiles to a dreamcast/ subdirectory.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit e66557eb2684e2ef1ff1d82cddee233e2f92905f
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 22:43:25 2025 +0200
dc-chain: Make per-platform Makefile.cfg
Rename Makefile.default.cfg to Makefile.dreamcast.cfg.
Later, when we support more platforms, we can add
Makefile.<platform>.cfg.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 21c30655a9726d9e1b5fed14441b80f75c02c31f
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 10:31:00 2025 +0200
utils: Add kos-gdb wrapper
This is a wrapper around gdb-multiarch, which sets a few settings so
that it can be used for Dreamcast development.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 35c23cac5a4e3d141cb4b285234fa7f178298b27
Author: Paul Cercueil <pa...@cr...>
Date: Mon Jun 9 21:47:26 2025 +0200
environ.sh: Export $KOS_GDB_CPU variable
This variable is defined to the CPU architecture name used with
gdb-multiarch.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 6 +
environ_base.sh | 16 +-
environ_dreamcast.sh | 2 +
kernel/arch/dreamcast/include/arch/arch.h | 2 +-
kernel/arch/dreamcast/kernel/Makefile | 4 +-
utils/build_wrappers/kos-cc | 4 +-
utils/build_wrappers/kos-gdb | 14 ++
utils/dc-chain/Makefile | 16 +-
.../{Makefile.default.cfg => Makefile.aica.cfg} | 69 +++-----
...Makefile.default.cfg => Makefile.dreamcast.cfg} | 22 +--
...{Makefile.default.cfg => Makefile.gamecube.cfg} | 75 +++------
utils/dc-chain/README.md | 177 ++++++++-------------
utils/dc-chain/doc/CHANGELOG.md | 9 ++
utils/dc-chain/doc/CONTRIBUTORS.md | 1 +
utils/dc-chain/doc/alpine.md | 2 +-
utils/dc-chain/doc/bsd.md | 2 +-
utils/dc-chain/doc/cygwin.md | 2 +-
utils/dc-chain/doc/debian.md | 2 +-
utils/dc-chain/doc/macos.md | 2 +-
utils/dc-chain/doc/mingw/mingw-w64.md | 2 +-
utils/dc-chain/doc/mingw/mingw.md | 2 +-
utils/dc-chain/patches/gcc/fake-kos.S | 82 ----------
utils/dc-chain/patches/gcc/fake-kos.c | 64 ++++++++
.../{ => hosts}/arm-Darwin/gcc-12.2.0-kos.diff | 0
.../{ => hosts}/arm-Darwin/gcc-13.1.0-kos.diff | 0
.../{ => hosts}/arm-Darwin/gcc-13.2.0-kos.diff | 0
.../{ => hosts}/arm-Darwin/gcc-8.4.0-kos.diff | 0
.../{ => hosts}/arm-Darwin/gcc-8.5.0-kos.diff | 0
.../{ => hosts}/arm-Darwin/gcc-9.3.0-kos.diff | 0
.../{ => hosts}/arm-Darwin/gcc-9.5.0-kos.diff | 0
.../i686-pc-mingw32/binutils-2.31.1.diff | 0
.../{ => hosts}/i686-pc-mingw32/binutils-2.34.diff | 0
.../{ => hosts}/i686-pc-mingw32/gdb-10.2.diff | 0
.../{ => hosts}/i686-pc-mingw32/gdb-7.12.1.diff | 0
.../{ => hosts}/i686-pc-mingw32/gdb-8.2.diff | 0
.../{ => hosts}/i686-pc-mingw32/gdb-8.3.1.diff | 0
.../{ => hosts}/i686-pc-mingw32/gdb-9.1.diff | 0
.../{ => hosts}/i686-pc-mingw32/gdb-9.2.diff | 0
.../i686-w64-mingw32/binutils-2.40.diff | 0
.../{ => hosts}/i686-w64-mingw32/gcc-12.2.0.diff | 0
.../{ => hosts}/i686-w64-mingw32/gcc-8.4.0.diff | 0
.../{ => hosts}/i686-w64-mingw32/gcc-8.5.0.diff | 0
.../{ => hosts}/i686-w64-mingw32/gcc-9.5.0.diff | 0
.../{ => hosts}/x86_64-pc-cygwin/gcc-13.2.0.diff | 0
.../{ => hosts}/x86_64-w64-mingw32/gcc-8.5.0.diff | 0
.../{ => hosts}/x86_64-w64-mingw32/gcc-9.5.0.diff | 0
.../patches/{ => targets}/gcc-13.2.0-kos.diff | 69 ++++----
.../patches/{ => targets}/gcc-13.4.0-kos.diff | 69 ++++----
.../patches/{ => targets}/gcc-13.4.1-kos.diff | 69 ++++----
.../patches/{ => targets}/gcc-14.3.0-kos.diff | 69 ++++----
.../patches/{ => targets}/gcc-14.3.1-kos.diff | 69 ++++----
.../gcc-15.0.0-lra.diff} | 107 +++++++------
.../patches/{ => targets}/gcc-15.1.0-kos.diff | 69 ++++----
.../patches/{ => targets}/gcc-15.1.1-kos.diff | 69 ++++----
.../patches/{ => targets}/gcc-16.0.0-kos.diff | 70 ++++----
.../patches/targets/gcc-8.5.0-clang17.diff | 74 +++++++++
.../gcc-8.5.0-kos.diff} | 104 ++++++------
.../patches/{ => targets}/gcc-9.5.0-kos.diff | 54 +++----
.../{ => targets}/newlib-4.3.0.20230120-kos.diff | 13 ++
.../{ => targets}/newlib-4.5.0.20241231-kos.diff | 56 +++++--
utils/dc-chain/profiles/aica/stable.mk | 41 +++++
.../{profile.15.1.0.mk => dreamcast/13.4.0.mk} | 30 ++--
.../13.4.1-dev.mk} | 38 ++---
.../{profile.13.4.0.mk => dreamcast/14.3.0.mk} | 30 ++--
.../14.3.1-dev.mk} | 36 ++---
.../15.0.0-lra.mk} | 37 ++---
.../{profile.14.3.0.mk => dreamcast/15.1.0.mk} | 30 ++--
.../15.1.1-dev.mk} | 36 ++---
.../16.0.0-dev.mk} | 36 ++---
.../9.5.0-winxp.mk} | 30 ++--
.../{profile.stable.mk => dreamcast/stable.mk} | 30 ++--
.../{profile.15.1.0.mk => gamecube/stable.mk} | 35 ++--
utils/dc-chain/scripts/binutils.mk | 18 +--
utils/dc-chain/scripts/build.mk | 77 +++------
utils/dc-chain/scripts/clean.mk | 68 +++-----
utils/dc-chain/scripts/download.mk | 35 ++--
utils/dc-chain/scripts/gcc-pass1.mk | 8 +-
utils/dc-chain/scripts/gcc-pass2.mk | 2 +-
utils/dc-chain/scripts/gdb.mk | 12 +-
utils/dc-chain/scripts/init.mk | 38 ++---
utils/dc-chain/scripts/newlib.mk | 26 +--
utils/dc-chain/scripts/patch.mk | 110 +++++--------
utils/dc-chain/scripts/phony.mk | 8 +-
utils/dc-chain/scripts/profile-defaults.mk | 26 +--
utils/dc-chain/scripts/variables.mk | 7 +-
utils/ldscripts/shlelf.xc | 6 +-
86 files changed, 1072 insertions(+), 1316 deletions(-)
create mode 100755 utils/build_wrappers/kos-gdb
copy utils/dc-chain/{Makefile.default.cfg => Makefile.aica.cfg} (73%)
copy utils/dc-chain/{Makefile.default.cfg => Makefile.dreamcast.cfg} (95%)
rename utils/dc-chain/{Makefile.default.cfg => Makefile.gamecube.cfg} (71%)
delete mode 100644 utils/dc-chain/patches/gcc/fake-kos.S
create mode 100644 utils/dc-chain/patches/gcc/fake-kos.c
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-12.2.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-13.1.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-13.2.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-8.4.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-8.5.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-9.3.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/arm-Darwin/gcc-9.5.0-kos.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/binutils-2.31.1.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/binutils-2.34.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/gdb-10.2.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/gdb-7.12.1.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/gdb-8.2.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/gdb-8.3.1.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/gdb-9.1.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-pc-mingw32/gdb-9.2.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-w64-mingw32/binutils-2.40.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-w64-mingw32/gcc-12.2.0.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-w64-mingw32/gcc-8.4.0.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-w64-mingw32/gcc-8.5.0.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/i686-w64-mingw32/gcc-9.5.0.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/x86_64-pc-cygwin/gcc-13.2.0.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/x86_64-w64-mingw32/gcc-8.5.0.diff (100%)
rename utils/dc-chain/patches/{ => hosts}/x86_64-w64-mingw32/gcc-9.5.0.diff (100%)
rename utils/dc-chain/patches/{ => targets}/gcc-13.2.0-kos.diff (75%)
rename utils/dc-chain/patches/{ => targets}/gcc-13.4.0-kos.diff (75%)
rename utils/dc-chain/patches/{ => targets}/gcc-13.4.1-kos.diff (75%)
rename utils/dc-chain/patches/{ => targets}/gcc-14.3.0-kos.diff (75%)
rename utils/dc-chain/patches/{ => targets}/gcc-14.3.1-kos.diff (75%)
copy utils/dc-chain/patches/{gcc-15.1.0-kos.diff => targets/gcc-15.0.0-lra.diff} (55%)
rename utils/dc-chain/patches/{ => targets}/gcc-15.1.0-kos.diff (75%)
rename utils/dc-chain/patches/{ => targets}/gcc-15.1.1-kos.diff (75%)
rename utils/dc-chain/patches/{ => targets}/gcc-16.0.0-kos.diff (75%)
create mode 100644 utils/dc-chain/patches/targets/gcc-8.5.0-clang17.diff
copy utils/dc-chain/patches/{gcc-9.5.0-kos.diff => targets/gcc-8.5.0-kos.diff} (57%)
rename utils/dc-chain/patches/{ => targets}/gcc-9.5.0-kos.diff (79%)
rename utils/dc-chain/patches/{ => targets}/newlib-4.3.0.20230120-kos.diff (92%)
mode change 100755 => 100644
rename utils/dc-chain/patches/{ => targets}/newlib-4.5.0.20241231-kos.diff (85%)
create mode 100644 utils/dc-chain/profiles/aica/stable.mk
copy utils/dc-chain/profiles/{profile.15.1.0.mk => dreamcast/13.4.0.mk} (55%)
rename utils/dc-chain/profiles/{profile.13.4.1-dev.mk => dreamcast/13.4.1-dev.mk} (63%)
rename utils/dc-chain/profiles/{profile.13.4.0.mk => dreamcast/14.3.0.mk} (55%)
rename utils/dc-chain/profiles/{profile.14.3.1-dev.mk => dreamcast/14.3.1-dev.mk} (64%)
copy utils/dc-chain/profiles/{profile.16.0.0-dev.mk => dreamcast/15.0.0-lra.mk} (64%)
rename utils/dc-chain/profiles/{profile.14.3.0.mk => dreamcast/15.1.0.mk} (55%)
rename utils/dc-chain/profiles/{profile.15.1.1-dev.mk => dreamcast/15.1.1-dev.mk} (64%)
rename utils/dc-chain/profiles/{profile.16.0.0-dev.mk => dreamcast/16.0.0-dev.mk} (64%)
rename utils/dc-chain/profiles/{profile.9.5.0-winxp.mk => dreamcast/9.5.0-winxp.mk} (55%)
rename utils/dc-chain/profiles/{profile.stable.mk => dreamcast/stable.mk} (55%)
rename utils/dc-chain/profiles/{profile.15.1.0.mk => gamecube/stable.mk} (50%)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index eb846c4a..bdee2cb7 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -106,6 +106,12 @@ export KOS_LOADER="dc-tool -x"
#export KOS_LOADER="dc-tool-ip -t 192.168.1.100 -x"
#export KOS_LOADER="dc-tool-ser -t /dev/ttyS0 -x"
+# GDB utility
+#
+# The kos-gdb helper will attempt to auto-detect the proper GDB program
+# to use. You can force it by specifying the path here.
+#export KOS_GDB="sh-elf-gdb"
+
# Default Compiler Flags
#
# Resets build flags. You can also initialize them to some preset
diff --git a/environ_base.sh b/environ_base.sh
index 21b7cf01..b2fa235a 100644
--- a/environ_base.sh
+++ b/environ_base.sh
@@ -60,18 +60,4 @@ export KOS_CPPSTD="-std=gnu++17"
export KOS_GCCVER="`kos-cc -dumpversion`"
-case $KOS_GCCVER in
- 2* | 3*)
- echo "Your GCC version is too old. You probably will run into major problems!"
- export KOS_LDFLAGS="${KOS_CFLAGS} ${KOS_LDFLAGS} -nostartfiles -nostdlib ${KOS_LIB_PATHS}" ;;
- *)
- export KOS_LDFLAGS="${KOS_CFLAGS} ${KOS_LDFLAGS} ${KOS_LD_SCRIPT} -nodefaultlibs ${KOS_LIB_PATHS}" ;;
-esac
-
-# Some extra vars based on architecture.
-case $KOS_GCCVER in
- 2* | 3*)
- export KOS_START="${KOS_ARCH_DIR}/kernel/startup.o" ;;
- *)
- export KOS_START="" ;;
-esac
+export KOS_LDFLAGS="${KOS_CFLAGS} ${KOS_LDFLAGS} ${KOS_LD_SCRIPT} -nostdlib ${KOS_LIB_PATHS}"
diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh
index cacecaa4..7dd3e872 100644
--- a/environ_dreamcast.sh
+++ b/environ_dreamcast.sh
@@ -29,6 +29,8 @@ export KOS_AFLAGS="${KOS_AFLAGS} -little"
export KOS_LDFLAGS="${KOS_LDFLAGS} ${KOS_SH4_PRECISION} -ml -Wl,--gc-sections"
export KOS_LD_SCRIPT="-T${KOS_BASE}/utils/ldscripts/shlelf.xc"
+export KOS_GDB_CPU=sh4
+
if [ x${KOS_SUBARCH} = xnaomi ]; then
export KOS_CFLAGS="${KOS_CFLAGS} -D__NAOMI__"
export KOS_LDFLAGS="${KOS_LDFLAGS} -Wl,--defsym=LOAD_OFFSET=0x8c020000"
diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h
index 79a0fe83..112bb187 100644
--- a/kernel/arch/dreamcast/include/arch/arch.h
+++ b/kernel/arch/dreamcast/include/arch/arch.h
@@ -33,7 +33,7 @@ __BEGIN_DECLS
*/
/** \brief Top of memory available, depending on memory size. */
-#ifdef __KOS_GCC_32MB__
+#if defined(__KOS_GCC_32MB__) || __KOS_GCC_PATCHLEVEL__ >= 2025062800
extern uint32 _arch_mem_top;
#else
#pragma message "Outdated toolchain: not patched for 32MB support, limiting "\
diff --git a/kernel/arch/dreamcast/kernel/Makefile b/kernel/arch/dreamcast/kernel/Makefile
index 864b23f0..f3dabe6c 100644
--- a/kernel/arch/dreamcast/kernel/Makefile
+++ b/kernel/arch/dreamcast/kernel/Makefile
@@ -18,12 +18,10 @@ COPYOBJS += uname.o
OBJS = $(COPYOBJS) startup.o
SUBDIRS =
-CRT1_PATH = $(shell $(KOS_CC) $(KOS_CFLAGS) -print-file-name=crt1.o)
-
myall: $(OBJS)
-cp $(COPYOBJS) $(KOS_BASE)/kernel/build/
+ -cp startup.o $(KOS_BASE)/lib/$(KOS_ARCH)/_kos_startup.o
-rm banner.h authors.h banner.o uname.o
- -cp startup.o $(CRT1_PATH)
include $(KOS_BASE)/Makefile.prefab
diff --git a/utils/build_wrappers/kos-cc b/utils/build_wrappers/kos-cc
index 17042ef1..3bb3c289 100755
--- a/utils/build_wrappers/kos-cc
+++ b/utils/build_wrappers/kos-cc
@@ -37,9 +37,9 @@ case $USEMODE in
1)
# In link mode, add all the extra processing.
if [ x${KOS_WRAPPERS_VERBOSE} = x"1" ]; then
- echo ${KOS_CC} ${KOS_CFLAGS} ${KOS_LDFLAGS} ${KOS_START} "$@" ${KOS_LIBS}
+ echo ${KOS_CC} ${KOS_CFLAGS} ${KOS_LDFLAGS} "$@" ${KOS_LIBS}
fi
- exec ${KOS_CC} ${KOS_CFLAGS} ${KOS_LDFLAGS} ${KOS_START} "$@" ${KOS_LIBS}
+ exec ${KOS_CC} ${KOS_CFLAGS} ${KOS_LDFLAGS} "$@" ${KOS_LIBS}
;;
2)
diff --git a/utils/build_wrappers/kos-gdb b/utils/build_wrappers/kos-gdb
new file mode 100755
index 00000000..1711b878
--- /dev/null
+++ b/utils/build_wrappers/kos-gdb
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# If $KOS_GDB is not overriden, default to sh-elf-gdb if found;
+# otherwise default to gdb-multiarch; in last resort, try to use gdb.
+[ ! -x "$KOS_GDB" ] && KOS_GDB=$(which $KOS_CC_PREFIX-gdb)
+[ ! -x "$KOS_GDB" ] && KOS_GDB=$(which gdb-multiarch)
+[ ! -x "$KOS_GDB" ] && KOS_GDB=$(which gdb)
+[ ! -x "$KOS_GDB" ] && echo "GDB program not found; please set $$KOS_GDB." && exit 1
+
+# Detect if GDB actually supports the target architecture.
+RESULT=$($KOS_GDB -iex "set architecture $KOS_GDB_CPU" -iex quit 2>&1 >/dev/null)
+[ -n "$RESULT" ] && echo "GDB program does not support $KOS_GDB_CPU." && exit 1
+
+exec $KOS_GDB -iex "set architecture $KOS_GDB_CPU" -iex "set sysroot $KOS_PORTS" -iex "target remote 127.0.0.1:2159" $*
diff --git a/utils/dc-chain/Makefile b/utils/dc-chain/Makefile
index 81f68dec..27cc8bc3 100644
--- a/utils/dc-chain/Makefile
+++ b/utils/dc-chain/Makefile
@@ -14,20 +14,20 @@ ifneq ("$(wildcard $(config_file))","")
$(info +++ Using configuration from $(config_file))
include $(config_file)
else
- ifneq ("$(wildcard Makefile.default.cfg)","")
- $(info +++ Using configuration from Makefile.default.cfg)
- include Makefile.default.cfg
+ ifneq ("$(platform)","")
+ $(info +++ Using configuration from Makefile.$(platform).cfg)
+ include Makefile.$(platform).cfg
else
- $(error No configuration file found at $(config_file) or Makefile.default.cfg)
+ $(error No configuration file found at $(config_file))
endif
endif
# Toolchain profiles
include scripts/profile-defaults.mk
-ifneq ("$(wildcard profiles/profile.$(toolchain_profile).mk)","")
- include profiles/profile.$(toolchain_profile).mk
+ifneq ("$(wildcard profiles/$(platform)/$(toolchain_profile).mk)","")
+ include profiles/$(platform)/$(toolchain_profile).mk
else
- $(error No toolchain profile file found at profiles/profile.$(toolchain_profile).mk)
+ $(error No toolchain profile file found at profiles/$(platform)/$(toolchain_profile).mk)
endif
# Download functions
@@ -44,7 +44,7 @@ include scripts/variables.mk
default: build gdb
-all: build build-arm gdb
+all: build gdb
# ---- download {{{
diff --git a/utils/dc-chain/Makefile.default.cfg b/utils/dc-chain/Makefile.aica.cfg
similarity index 73%
copy from utils/dc-chain/Makefile.default.cfg
copy to utils/dc-chain/Makefile.aica.cfg
index 6658076a..e1f6bd5c 100644
--- a/utils/dc-chain/Makefile.default.cfg
+++ b/utils/dc-chain/Makefile.aica.cfg
@@ -5,18 +5,15 @@
### TOOLCHAIN PROFILE ###
#########################
+# One of the supported platforms:
+# - dreamcast: Build a toolchain for the SEGA Dreamcast
+# - aica: Build a toolchain for the Dreamcast's AICA co-processor
+# - gamecube: Build a toolchain for the Nintendo GameCube
+platform=aica
+
# Choose a toolchain profile from the following available options:
# Release toolchains:
-# - 9.5.0-winxp: Legacy: Most recent versions of tools which run on Windows XP.
-# - stable: Stable: Well-tested; based on GCC 13.2.0, released 2023-07-27.
-# - 13.4.0: Testing: Latest release in the GCC 13 series, released 2025-06-05.
-# - 14.3.0: Testing: Latest release in the GCC 14 series, released 2025-05-23.
-# - 15.1.0: Testing: Latest release in the GCC 15 series, released 2025-04-25.
-# Development toolchains:
-# - 13.4.1-dev Bleeding edge GCC 13 series from git.
-# - 14.3.1-dev Bleeding edge GCC 14 series from git.
-# - 15.1.1-dev Bleeding edge GCC 15 series from git.
-# - 16.0.0-dev Bleeding edge GCC 16 series from git.
+# - stable: Stable: Latest toolchain available.
# If unsure, select stable. See README.md for more detailed descriptions.
toolchain_profile=stable
@@ -43,23 +40,19 @@ download_protocol=https
### BUILD OPTIONS ###
#####################
-### SH toolchain install path
-# Specify the directory where the SH toolchain will be installed. This setting
+### Toolchains install path
+# Specify the directory where the toolchains will be installed. This setting
# must match the KOS_CC_BASE setting in your KOS "environ.sh" configuration.
-sh_toolchain_path=/opt/toolchains/dc/sh-elf
-
-### ARM toolchain install path
-# Specify the directory where the ARM toolchain will be installed. This setting
-# must match the DC_ARM_BASE setting in your KOS "environ.sh" configuration.
-arm_toolchain_path=/opt/toolchains/dc/arm-eabi
+toolchain_path=/opt/toolchains/dc/arm-eabi
### Make jobs (n|<empty>)
# Set this value to the number of parallel jobs you want to run with make.
-# For fastest toolchain building, set to the number of CPU threads available.
+# Leave it empty to use a number of parallel jobs that corresponds to the
+# number of CPU threads available.
# Using multiple jobs may cause issues in certain environments and may be
# automatically disabled. If you encounter errors building your toolchain,
# reduce the number of jobs to 1 to avoid issues and ease troubleshooting.
-makejobs=2
+makejobs=
### Verbose (1|0)
# Choose whether to actively display compilation messages on the screen.
@@ -85,20 +78,20 @@ erase=1
# support included. KallistiOS provides several examples with C++ support, so it
# is enabled by default. Adding C++ support requires extra disk space and
# compilation time, so you may disable it here if you do not plan on using C++.
-enable_cpp=1
+enable_cpp=0
### Enable Objective-C
# Builds Objective-C support. Currently, this builds the Obj-C compiler and
# runtime, but does not build a standard library. The GNUStep Base Library is
# currently in active development for future inclusion in the kos-ports library.
# KallistiOS provides examples with Obj-C support, so it is enabled by default.
-enable_objc=1
+enable_objc=0
### Enable Objective C++
# Builds Objective C++ support. This hybrid language allows both C++ and Obj-C
# methods to be called from both contexts. Enabled by default as both the C++
# and Obj-C languages are already enabled by default.
-enable_objcpp=1
+enable_objcpp=0
### Enable D
# Builds D support. This will build the D compiler, but does not build the
@@ -128,32 +121,8 @@ enable_objcpp=1
### GCC OPTIONS ###
###################
-### Floating-point precision support (m4-single|m4-single-only|m4|m4-nofpu)
-# Build support for various SH4 floating-point operation ABIs. KallistiOS
-# supports both the single-precision-default ABI (m4-single) and the
-# single-precision-only ABI (m4-single-only). When using m4-single, the SH4 will
-# be in single-precision mode upon function entry but will switch to double-
-# precision mode if 64-bit doubles are used. When using m4-single-only, the SH4
-# will always be in single-precision mode and 64-bit doubles will be truncated to
-# 32-bit floats. In double-precision mode (m4), which is unsupported by
-# KallistiOS, the SH4 will be in double precision mode upon function entry.
-# Finally in no fpu mode (m4-nofpu), which is also unsupported by KallistiOS and
-# objc/++, there is no support for floating-point operations at all.
-# Historically, m4-single-only was used in both official and homebrew Dreamcast
-# software, but m4-single is the default as of KOS 2.2.0 to increase
-# compatibility with newer libraries which require 64-bit doubles.
-precision_modes=m4-single,m4-single-only
-
-### Default floating-point mode (m4-single|m4-single-only|m4|m4-nofpu)
-# Choose the default floating-point precision ABI used when GCC is invoked. This
-# may be overridden by passing -m4-single, -m4-single-only, or -m4 to GCC.
-default_precision=m4-single
-
-### GCC threading model (single|kos)
-# KallistiOS patches to GCC provide a 'kos' thread model, which should be used.
-# If you want to disable threading support for C++, Objective-C, and so forth,
-# you can set this option to 'single'.
-thread_model=kos
+### GCC threading model (single)
+thread_model=single
### Automatic patching for KallistiOS (1|0)
# Uncomment this option if you want to disable applying KallistiOS patches to
@@ -175,7 +144,7 @@ thread_model=kos
# needed by KallistiOS. This will keep the generated toolchain completely raw.
# This will also disable the 'kos' thread model. Only do this if you understand
# what you are doing.
-#auto_fixup_sh4_newlib=0
+auto_fixup_sh4_newlib=0
### C99 format specifier support (1|0)
# Define this to build Newlib with additional support for the C99 format
diff --git a/utils/dc-chain/Makefile.default.cfg b/utils/dc-chain/Makefile.dreamcast.cfg
similarity index 95%
copy from utils/dc-chain/Makefile.default.cfg
copy to utils/dc-chain/Makefile.dreamcast.cfg
index 6658076a..14ac30ad 100644
--- a/utils/dc-chain/Makefile.default.cfg
+++ b/utils/dc-chain/Makefile.dreamcast.cfg
@@ -5,6 +5,12 @@
### TOOLCHAIN PROFILE ###
#########################
+# One of the supported platforms:
+# - dreamcast: Build a toolchain for the SEGA Dreamcast
+# - aica: Build a toolchain for the Dreamcast's AICA co-processor
+# - gamecube: Build a toolchain for the Nintendo GameCube
+platform=dreamcast
+
# Choose a toolchain profile from the following available options:
# Release toolchains:
# - 9.5.0-winxp: Legacy: Most recent versions of tools which run on Windows XP.
@@ -43,23 +49,19 @@ download_protocol=https
### BUILD OPTIONS ###
#####################
-### SH toolchain install path
-# Specify the directory where the SH toolchain will be installed. This setting
+### Toolchains install path
+# Specify the directory where the toolchain will be installed. This setting
# must match the KOS_CC_BASE setting in your KOS "environ.sh" configuration.
-sh_toolchain_path=/opt/toolchains/dc/sh-elf
-
-### ARM toolchain install path
-# Specify the directory where the ARM toolchain will be installed. This setting
-# must match the DC_ARM_BASE setting in your KOS "environ.sh" configuration.
-arm_toolchain_path=/opt/toolchains/dc/arm-eabi
+toolchain_path=/opt/toolchains/dc/sh-elf
### Make jobs (n|<empty>)
# Set this value to the number of parallel jobs you want to run with make.
-# For fastest toolchain building, set to the number of CPU threads available.
+# Leave it empty to use a number of parallel jobs that corresponds to the
+# number of CPU threads available.
# Using multiple jobs may cause issues in certain environments and may be
# automatically disabled. If you encounter errors building your toolchain,
# reduce the number of jobs to 1 to avoid issues and ease troubleshooting.
-makejobs=2
+makejobs=
### Verbose (1|0)
# Choose whether to actively display compilation messages on the screen.
diff --git a/utils/dc-chain/Makefile.default.cfg b/utils/dc-chain/Makefile.gamecube.cfg
similarity index 71%
rename from utils/dc-chain/Makefile.default.cfg
rename to utils/dc-chain/Makefile.gamecube.cfg
index 6658076a..2018bde0 100644
--- a/utils/dc-chain/Makefile.default.cfg
+++ b/utils/dc-chain/Makefile.gamecube.cfg
@@ -5,18 +5,14 @@
### TOOLCHAIN PROFILE ###
#########################
+# One of the supported platforms:
+# - dreamcast: Build a toolchain for the SEGA Dreamcast
+# - aica: Build a toolchain for the Dreamcast's AICA co-processor
+# - gamecube: Build a toolchain for the Nintendo GameCube
+platform=gamecube
+
# Choose a toolchain profile from the following available options:
-# Release toolchains:
-# - 9.5.0-winxp: Legacy: Most recent versions of tools which run on Windows XP.
-# - stable: Stable: Well-tested; based on GCC 13.2.0, released 2023-07-27.
-# - 13.4.0: Testing: Latest release in the GCC 13 series, released 2025-06-05.
-# - 14.3.0: Testing: Latest release in the GCC 14 series, released 2025-05-23.
-# - 15.1.0: Testing: Latest release in the GCC 15 series, released 2025-04-25.
-# Development toolchains:
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-04 17:06:33
|
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 6b306eb2fb8054fc60b46cc06ea09eb45fa4cb4a (commit)
via 33ff624892394b8ab29091f46b7739ddf8575178 (commit)
via b500e5cc8b56ab021a4515909cafe9c766716793 (commit)
via c419e767c4902aa5dba3ea633d143aa2a9d2818a (commit)
via 453e3a89db2ea72b11810c94ed06e30ef97d6927 (commit)
via 318f9046880693cd3c6a3b4d6c70cbd99fb452d6 (commit)
via ac2f4def7af390cf15ac53a5009344a338edfecf (commit)
from d8b442870398cd20937a7dcce4d23b3f3da5bc1c (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 6b306eb2fb8054fc60b46cc06ea09eb45fa4cb4a
Author: QuzarDC <qu...@co...>
Date: Wed Jul 30 17:22:35 2025 -0400
elf: Expand Sections and section flag defines
These are all aspirational. Also fixed a typo.
commit 33ff624892394b8ab29091f46b7739ddf8575178
Author: QuzarDC <qu...@co...>
Date: Wed Jul 30 16:54:09 2025 -0400
elf: Refactor and update header validation.
Move header validation to its own internal function.
Additionally remove magic numbers by adding defines
to back the values in the header.
Finally, expanded the number of internal defines being used
per-arch so that it includes the bit width and endianness
fields. This should make it simple to add new ones, though
I removed the old archs at the same time.
commit b500e5cc8b56ab021a4515909cafe9c766716793
Author: QuzarDC <qu...@co...>
Date: Wed Jul 30 15:20:58 2025 -0400
elf: Add and use header ident defines.
Additionally clean up the ident code slightly by
providing fixed character width to the printf
rather than doctoring the header to NUL terminate.
commit c419e767c4902aa5dba3ea633d143aa2a9d2818a
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 23:45:43 2025 -0400
elf: Check for `fs_read` failure.
commit 453e3a89db2ea72b11810c94ed06e30ef97d6927
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 21:52:04 2025 -0400
elf: Replace custom debug output with dbglog.
I've set it to `KDEBUG` so it's only if you want
all the output.
commit 318f9046880693cd3c6a3b4d6c70cbd99fb452d6
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 21:50:54 2025 -0400
elf: Typedef structs and clean up whitespace.
commit ac2f4def7af390cf15ac53a5009344a338edfecf
Author: QuzarDC <qu...@co...>
Date: Tue Jul 29 20:59:39 2025 -0400
fs_elf: Move to stdint types.
-----------------------------------------------------------------------
Summary of changes:
include/kos/elf.h | 164 +++++++++++++++++++++++++++++----------------
kernel/fs/elf.c | 194 +++++++++++++++++++++++++++++-------------------------
2 files changed, 210 insertions(+), 148 deletions(-)
diff --git a/include/kos/elf.h b/include/kos/elf.h
index a9398f96..43b0499a 100644
--- a/include/kos/elf.h
+++ b/include/kos/elf.h
@@ -25,38 +25,72 @@
__BEGIN_DECLS
#include <stdint.h>
-#include <arch/types.h>
#include <sys/queue.h>
+#include <kos/regfield.h>
/** \defgroup elf ELF File Format
\brief API for loading and managing ELF files
\ingroup system_libraries
*/
+/** \defgroup elf_ident ELF Identification Bytes
+ \ingroup elf
+
+ Initial bytes of the ELF file, specifying how it should be
+ interpreted. This group contains first the indexes of each
+ ident field, then defines for the values they can contain.
+
+ Some of these are shared by other header fields.
+ @{
+*/
+#define EI_MAG0 0 /**< \brief File identification: 0x7f */
+#define EI_MAG1 1 /**< \brief File identification: 'E' */
+#define EI_MAG2 2 /**< \brief File identification: 'L' */
+#define EI_MAG3 3 /**< \brief File identification: 'F' */
+#define EI_CLASS 4 /**< \brief File class (32/64-bit) */
+#define EI_DATA 5 /**< \brief Data encoding (LSB/MSB) */
+#define EI_VERSION 6 /**< \brief File version (must be 1) */
+#define EI_OSABI 7 /**< \brief Operating System/ABI identification */
+#define EI_ABIVERSION 8 /**< \brief ABI version */
+#define EI_PAD 9 /**< \brief Start of padding bytes */
+
+#define EI_NIDENT 16 /**< \brief Size of elf_hdr::ident */
+
+#define ELFCLASSNONE 0 /**< \brief Invalid class */
+#define ELFCLASS32 1 /**< \brief 32-bit objects */
+#define ELFCLASS64 2 /**< \brief 64-bit objects */
+
+#define ELFDATANONE 0 /**< \brief Invalid encoding */
+#define ELFDATA2LSB 1 /**< \brief 2's complement, little endian */
+#define ELFDATA2MSB 2 /**< \brief 2's complement, big Endian */
+
+#define EV_NONE 0 /**< \brief Invalid version */
+#define EV_CURRENT 1 /**< \brief Current version */
+/** @} */
+
/** \brief ELF file header.
\ingroup elf
This header is at the beginning of any valid ELF binary and serves to
identify the architecture of the binary and various data about it.
- \headerfile kos/elf.h
*/
-struct elf_hdr_t {
- uint8 ident[16]; /**< \brief ELF identifier */
- uint16 type; /**< \brief ELF file type */
- uint16 machine; /**< \brief ELF file architecture */
- uint32 version; /**< \brief Object file version */
- uint32 entry; /**< \brief Entry point */
- uint32 phoff; /**< \brief Program header offset */
- uint32 shoff; /**< \brief Section header offset */
- uint32 flags; /**< \brief Processor flags */
- uint16 ehsize; /**< \brief ELF header size in bytes */
- uint16 phentsize; /**< \brief Program header entry size */
- uint16 phnum; /**< \brief Program header entry count */
- uint16 shentsize; /**< \brief Section header entry size */
- uint16 shnum; /**< \brief Section header entry count */
- uint16 shstrndx; /**< \brief String table section index */
-};
+typedef struct elf_hdr {
+ uint8_t ident[EI_NIDENT]; /**< \brief ELF identifier */
+ uint16_t type; /**< \brief ELF file type */
+ uint16_t machine; /**< \brief ELF file architecture */
+ uint32_t version; /**< \brief Object file version */
+ uint32_t entry; /**< \brief Entry point */
+ uint32_t phoff; /**< \brief Program header offset */
+ uint32_t shoff; /**< \brief Section header offset */
+ uint32_t flags; /**< \brief Processor flags */
+ uint16_t ehsize; /**< \brief ELF header size in bytes */
+ uint16_t phentsize; /**< \brief Program header entry size */
+ uint16_t phnum; /**< \brief Program header entry count */
+ uint16_t shentsize; /**< \brief Section header entry size */
+ uint16_t shnum; /**< \brief Section header entry count */
+ uint16_t shstrndx; /**< \brief String table section index */
+} elf_hdr_t;
/** \defgroup elf_archs Architecture Types
\brief Relevant ELF architecture type codes
@@ -67,6 +101,7 @@ struct elf_hdr_t {
@{
*/
#define EM_386 3 /**< \brief x86 (IA32) */
+#define EM_PPC 20 /**< \brief PowerPC */
#define EM_ARM 40 /**< \brief ARM */
#define EM_SH 42 /**< \brief SuperH */
/** @} */
@@ -90,9 +125,16 @@ struct elf_hdr_t {
#define SHT_NOTE 7 /**< \brief Notes section */
#define SHT_NOBITS 8 /**< \brief A section that occupies no space in
the file */
-#define SHT_REL 9 /**< \brief Relocation table, no addends */
-#define SHT_SHLIB 10 /**< \brief Reserved */
-#define SHT_DYNSYM 11 /**< \brief Dynamic-only sym tab */
+#define SHT_REL 9 /**< \brief Relocation table, no addends */
+#define SHT_SHLIB 10 /**< \brief Reserved */
+#define SHT_DYNSYM 11 /**< \brief Dynamic linker symbol table */
+#define SHT_INIT_ARRAY 14 /**< \brief Array of constructors */
+#define SHT_FINI_ARRAY 15 /**< \brief Array of destructors */
+#define SHT_PREINIT_ARRAY 16 /**< \brief Array of pre-constructors */
+#define SHT_GROUP 17 /**< \brief Section group */
+#define SHT_SYMTAB_SHNDX 18 /**< \brief Extended section indices */
+#define SHT_NUM 19 /**< \brief Number of defined types. */
+
#define SHT_LOPROC 0x70000000 /**< \brief Start of processor specific types */
#define SHT_HIPROC 0x7fffffff /**< \brief End of processor specific types */
#define SHT_LOUSER 0x80000000 /**< \brief Start of program specific types */
@@ -108,9 +150,15 @@ the file */
@{
*/
-#define SHF_WRITE 1 /**< \brief Writable data */
-#define SHF_ALLOC 2 /**< \brief Resident */
-#define SHF_EXECINSTR 4 /**< \brief Executable instructions */
+#define SHF_WRITE BIT(0) /**< \brief Writable data */
+#define SHF_ALLOC BIT(1) /**< \brief Resident */
+#define SHF_EXECINSTR BIT(2) /**< \brief Executable instructions */
+#define SHF_MERGE BIT(4) /**< \brief Might be merged */
+#define SHF_STRINGS BIT(5) /**< \brief Contains nul-terminated strings */
+#define SHF_INFO_LINK BIT(6) /**< \brief `sh_info' contains SHT index */
+#define SHF_LINK_ORDER BIT(7) /**< \brief Preserve order after combining */
+#define SHF_GROUP BIT(9) /**< \brief Section is member of a group. */
+#define SHF_TLS BIT(10) /**< \brief Section hold thread-local data. */
#define SHF_MASKPROC 0xf0000000 /**< \brief Processor specific mask */
/** @} */
@@ -133,18 +181,18 @@ the file */
\headerfile kos/elf.h
*/
-struct elf_shdr_t {
- uint32 name; /**< \brief Index into string table */
- uint32 type; /**< \brief Section type \see elf_sections */
- uint32 flags; /**< \brief Section flags \see elf_hdrflags */
- uint32 addr; /**< \brief In-memory offset */
- uint32 offset; /**< \brief On-disk offset */
- uint32 size; /**< \brief Size (if SHT_NOBITS, amount of 0s needed) */
- uint32 link; /**< \brief Section header table index link */
- uint32 info; /**< \brief Section header extra info */
- uint32 addralign; /**< \brief Alignment constraints */
- uint32 entsize; /**< \brief Fixed-size table entry sizes */
-};
+typedef struct elf_shdr {
+ uint32_t name; /**< \brief Index into string table */
+ uint32_t type; /**< \brief Section type \see elf_sections */
+ uint32_t flags; /**< \brief Section flags \see elf_hdrflags */
+ uint32_t addr; /**< \brief In-memory offset */
+ uint32_t offset; /**< \brief On-disk offset */
+ uint32_t size; /**< \brief Size (if SHT_NOBITS, amount of 0s needed) */
+ uint32_t link; /**< \brief Section header table index link */
+ uint32_t info; /**< \brief Section header extra info */
+ uint32_t addralign; /**< \brief Alignment constraints */
+ uint32_t entsize; /**< \brief Fixed-size table entry sizes */
+} elf_shdr_t;
/* Link and info fields:
switch (sh_type) {
@@ -205,14 +253,14 @@ switch (sh_type) {
\headerfile kos/elf.h
*/
-struct elf_sym_t {
- uint32 name; /**< \brief Index into file's string table */
- uint32 value; /**< \brief Value of the symbol */
- uint32 size; /**< \brief Size of the symbol */
- uint8 info; /**< \brief Symbol type and binding */
- uint8 other; /**< \brief 0. Holds no meaning. */
- uint16 shndx; /**< \brief Section index */
-};
+typedef struct elf_sym {
+ uint32_t name; /**< \brief Index into file's string table */
+ uint32_t value; /**< \brief Value of the symbol */
+ uint32_t size; /**< \brief Size of the symbol */
+ uint8_t info; /**< \brief Symbol type and binding */
+ uint8_t other; /**< \brief 0. Holds no meaning. */
+ uint16_t shndx; /**< \brief Section index */
+} elf_sym_t;
/** \brief Retrieve the binding type for a symbol.
\ingroup elf
@@ -241,11 +289,11 @@ struct elf_sym_t {
\headerfile kos/elf.h
*/
-struct elf_rela_t {
- uint32 offset; /**< \brief Offset within section */
- uint32 info; /**< \brief Symbol and type */
- int32 addend; /**< \brief Constant addend for the symbol */
-};
+typedef struct elf_rela {
+ uint32_t offset; /**< \brief Offset within section */
+ uint32_t info; /**< \brief Symbol and type */
+ int32_t addend; /**< \brief Constant addend for the symbol */
+} elf_rela_t;
/** \brief ELF Relocation entry (without explicit addend).
\ingroup elf
@@ -256,10 +304,10 @@ struct elf_rela_t {
\headerfile kos/elf.h
*/
-struct elf_rel_t {
- uint32 offset; /**< \brief Offset within section */
- uint32 info; /**< \brief Symbol and type */
-};
+typedef struct elf_rel {
+ uint32_t offset; /**< \brief Offset within section */
+ uint32_t info; /**< \brief Symbol and type */
+} elf_rel_t;
/** \defgroup elf_reltypes Relocation Types
\brief ELF relocation type values
@@ -290,7 +338,7 @@ struct elf_rel_t {
\return The relocation type of that relocation.
\see elf_reltypes
*/
-#define ELF32_R_TYPE(i) ((uint8)(i))
+#define ELF32_R_TYPE(i) ((uint8_t)(i))
struct klibrary;
@@ -303,8 +351,8 @@ struct klibrary;
\headerfile kos/elf.h
*/
typedef struct elf_prog {
- void *data; /**< \brief Pointer to program in memory */
- uint32 size; /**< \brief Memory image size (rounded up to page size) */
+ void *data; /**< \brief Pointer to program in memory */
+ uint32_t size; /**< \brief Memory image size (rounded up to page size) */
/* Library exports */
uintptr_t lib_get_name; /**< \brief Pointer to get_name() function */
@@ -312,7 +360,7 @@ typedef struct elf_prog {
uintptr_t lib_open; /**< \brief Pointer to library's open function */
uintptr_t lib_close; /**< \brief Pointer to library's close function */
- char fn[256]; /**< \brief Filename of library */
+ char fn[256]; /**< \brief Filename of library */
} elf_prog_t;
/** \brief Load an ELF binary.
@@ -339,5 +387,5 @@ void elf_free(elf_prog_t *prog);
__END_DECLS
-#endif /* __OS_ELF_H */
+#endif /* __KOS_ELF_H */
diff --git a/kernel/fs/elf.c b/kernel/fs/elf.c
index 2d40db4b..c652806c 100644
--- a/kernel/fs/elf.c
+++ b/kernel/fs/elf.c
@@ -19,24 +19,16 @@
/* What's our architecture code we're expecting? */
#if defined(_arch_dreamcast)
-# define ARCH_CODE EM_SH
-#elif defined(_arch_ia32)
-# define ARCH_CODE EM_386
-#elif defined(_arch_gba)
-# define ARCH_CODE EM_ARM
+# define ARCH_ELFCLASS ELFCLASS32 /* Dreamcast is 32-bit */
+# define ARCH_ELFDATA ELFDATA2LSB /* and little endian */
+# define ARCH_CODE EM_SH /* and uses an SH processor. */
#else
# error Unknown architecture
#endif
-#define ELF_DEBUG 0
-
-#define DBG(x) do { \
- if(__is_defined(ELF_DEBUG)) \
- printf x; \
-} while(0)
/* Finds a given symbol in a relocated ELF symbol table */
-static int find_sym(char *name, struct elf_sym_t* table, int tablelen) {
+static int find_sym(char *name, elf_sym_t *table, int tablelen) {
int i;
for(i = 0; i < tablelen; i++) {
@@ -47,25 +39,51 @@ static int find_sym(char *name, struct elf_sym_t* table, int tablelen) {
return -1;
}
+/* This function tests the header to determine if it's valid. It's separated
+ out as this is the section of the header whose parsing needs to test
+ against arch-specific values.
+*/
+static bool elf_hdr_validate(elf_hdr_t *hdr) {
+ /* First four bytes are a magic number */
+ if(strncmp((char *)hdr->ident, "\177ELF", 4)) {
+ dbglog(DBG_ERROR, "elf_load: file is not a valid ELF file\n");
+ dbglog(DBG_ERROR, " hdr->ident is %d/%.3s\n", hdr->ident[EI_MAG0], hdr->ident + 1);
+ return false;
+ }
+
+ if(hdr->ident[EI_CLASS] != ARCH_ELFCLASS || hdr->ident[EI_DATA] != ARCH_ELFDATA) {
+ dbglog(DBG_ERROR, "elf_load: invalid architecture flags in ELF file\n");
+ return false;
+ }
+
+ if(hdr->machine != ARCH_CODE) {
+ dbglog(DBG_ERROR, "elf_load: invalid architecture %02x in ELF file\n", hdr->machine);
+ return false;
+ }
+
+ return true;
+}
+
/* Pass in a file descriptor from the virtual file system, and the
result will be NULL if the file cannot be loaded, or a pointer to
the loaded and relocated executable otherwise. The second variable
will be set to the entry point. */
/* There's a lot of shit in here that's not documented or very poorly
documented by Intel.. I hope that this works for future compilers. */
-int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
- uint8 *img, *imgout;
- int sz, i, j, sect;
- struct elf_hdr_t *hdr;
- struct elf_shdr_t *shdrs, *symtabhdr;
- struct elf_sym_t *symtab;
+int elf_load(const char *fn, klibrary_t *shell, elf_prog_t *out) {
+ uint8_t *img, *imgout;
+ size_t sz, rsz;
+ int i, j, sect;
+ elf_hdr_t *hdr;
+ elf_shdr_t *shdrs, *symtabhdr;
+ elf_sym_t *symtab;
int symtabsize;
- struct elf_rel_t *reltab;
- struct elf_rela_t *relatab;
+ elf_rel_t *reltab;
+ elf_rela_t *relatab;
int reltabsize;
- char *stringtab;
- uint32 vma;
- file_t fd;
+ char *stringtab;
+ uint32_t vma;
+ file_t fd;
(void)shell;
@@ -78,7 +96,7 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
}
sz = fs_total(fd);
- DBG(("Loading ELF file of size %d\n", sz));
+ dbglog(DBG_KDEBUG, "Loading ELF file of size %d\n", sz);
img = aligned_alloc(32, sz);
@@ -88,46 +106,41 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
return -1;
}
- fs_read(fd, img, sz);
- fs_close(fd);
+ rsz = fs_read(fd, img, sz);
- /* Header is at the front */
- hdr = (struct elf_hdr_t *)(img + 0);
+ /* We close it regardless. */
+ fs_close(fd);
- if(hdr->ident[0] != 0x7f || strncmp((char *)hdr->ident + 1, "ELF", 3)) {
- dbglog(DBG_ERROR, "elf_load: file is not a valid ELF file\n");
- hdr->ident[4] = 0;
- dbglog(DBG_ERROR, " hdr->ident is %d/%s\n", hdr->ident[0], hdr->ident + 1);
- goto error1;
+ if(rsz < sz) {
+ dbglog(DBG_ERROR, "elf_load: only read %d of %d bytes\n", rsz, sz);
+ free(img);
+ return -1;
}
- if(hdr->ident[4] != 1 || hdr->ident[5] != 1) {
- dbglog(DBG_ERROR, "elf_load: invalid architecture flags in ELF file\n");
- goto error1;
- }
+ /* Header is at the front */
+ hdr = (elf_hdr_t *)(img + 0);
- if(hdr->machine != ARCH_CODE) {
- dbglog(DBG_ERROR, "elf_load: invalid architecture %02x in ELF file\n", hdr->machine);
+ /* Test if the header is valid */
+ if(!elf_hdr_validate(hdr))
goto error1;
- }
/* Print some debug info */
- DBG(("File size is %d bytes\n", sz));
- DBG((" entry point %08lx\n", hdr->entry));
- DBG((" ph offset %08lx\n", hdr->phoff));
- DBG((" sh offset %08lx\n", hdr->shoff));
- DBG((" flags %08lx\n", hdr->flags));
- DBG((" ehsize %08x\n", hdr->ehsize));
- DBG((" phentsize %08x\n", hdr->phentsize));
- DBG((" phnum %08x\n", hdr->phnum));
- DBG((" shentsize %08x\n", hdr->shentsize));
- DBG((" shnum %08x\n", hdr->shnum));
- DBG((" shstrndx %08x\n", hdr->shstrndx));
+ dbglog(DBG_KDEBUG, "File size is %d bytes\n", sz);
+ dbglog(DBG_KDEBUG, " entry point %08lx\n", hdr->entry);
+ dbglog(DBG_KDEBUG, " ph offset %08lx\n", hdr->phoff);
+ dbglog(DBG_KDEBUG, " sh offset %08lx\n", hdr->shoff);
+ dbglog(DBG_KDEBUG, " flags %08lx\n", hdr->flags);
+ dbglog(DBG_KDEBUG, " ehsize %08x\n", hdr->ehsize);
+ dbglog(DBG_KDEBUG, " phentsize %08x\n", hdr->phentsize);
+ dbglog(DBG_KDEBUG, " phnum %08x\n", hdr->phnum);
+ dbglog(DBG_KDEBUG, " shentsize %08x\n", hdr->shentsize);
+ dbglog(DBG_KDEBUG, " shnum %08x\n", hdr->shnum);
+ dbglog(DBG_KDEBUG, " shstrndx %08x\n", hdr->shstrndx);
/* Locate the string table; SH elf files ought to have
two string tables, one for section names and one for object
string names. We'll look for the latter. */
- shdrs = (struct elf_shdr_t *)(img + hdr->shoff);
+ shdrs = (elf_shdr_t *)(img + hdr->shoff);
stringtab = NULL;
for(i = 0; i < hdr->shnum; i++) {
@@ -156,12 +169,12 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
goto error1;
}
- symtab = (struct elf_sym_t *)(img + symtabhdr->offset);
- symtabsize = symtabhdr->size / sizeof(struct elf_sym_t);
+ symtab = (elf_sym_t *)(img + symtabhdr->offset);
+ symtabsize = symtabhdr->size / sizeof(elf_sym_t);
/* Relocate symtab entries for quick access */
for(i = 0; i < symtabsize; i++)
- symtab[i].name = (uint32)(stringtab + symtab[i].name);
+ symtab[i].name = (uint32_t)(stringtab + symtab[i].name);
/* Build the final memory image */
sz = 0;
@@ -172,7 +185,7 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
sz += shdrs[i].size;
if(shdrs[i].addralign && (shdrs[i].addr % shdrs[i].addralign)) {
- uint32 orig = shdrs[i].addr;
+ uint32_t orig = shdrs[i].addr;
shdrs[i].addr = (shdrs[i].addr + shdrs[i].addralign)
& ~(shdrs[i].addralign - 1);
sz += shdrs[i].addr - orig;
@@ -180,7 +193,7 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
}
}
- DBG(("Final image is %d bytes\n", sz));
+ dbglog(DBG_KDEBUG, "Final image is %d bytes\n", sz);
out->data = imgout = malloc(sz);
if(out->data == NULL) {
@@ -189,18 +202,18 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
}
out->size = sz;
- vma = (uint32)imgout;
+ vma = (uint32_t)imgout;
for(i = 0; i < hdr->shnum; i++) {
if(shdrs[i].flags & SHF_ALLOC) {
if(shdrs[i].type == SHT_NOBITS) {
- DBG((" setting %ld bytes of zeros at %08lx\n",
- shdrs[i].size, shdrs[i].addr));
+ dbglog(DBG_KDEBUG, " setting %ld bytes of zeros at %08lx\n",
+ shdrs[i].size, shdrs[i].addr);
memset(imgout + shdrs[i].addr, 0, shdrs[i].size);
}
else {
- DBG((" copying %ld bytes from %08lx to %08lx\n",
- shdrs[i].size, shdrs[i].offset, shdrs[i].addr));
+ dbglog(DBG_KDEBUG, " copying %ld bytes from %08lx to %08lx\n",
+ shdrs[i].size, shdrs[i].offset, shdrs[i].addr);
memcpy(imgout + shdrs[i].addr,
img + shdrs[i].offset,
shdrs[i].size);
@@ -212,14 +225,14 @@ int elf_load(const char * fn, klibrary_t * shell, elf_prog_t * out) {
for(i = 1; i < symtabsize; i++) {
export_sym_t * sym;
- /* DBG((" symbol '%s': value %04lx, size %04lx, info %02x, other %02x, shndx %04lx\n",
+ /* dbglog(DBG_KDEBUG, " symbol '%s': value %04lx, size %04lx, info %02x, other %02x, shndx %04lx\n",
(const char *)(symtab[i].name),
symtab[i].value, symtab[i].size,
symtab[i].info,
symtab[i].other,
- symtab[i].shndx)); */
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-04 16:56:53
|
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 d8b442870398cd20937a7dcce4d23b3f3da5bc1c (commit)
via 7c26e725c440fd5cd475aa5696116423795734a1 (commit)
via 6ec1f394e3e450712816e07b3e156f6ff398a1ba (commit)
from b71353ca0095787e8d1ed9428cdeec65230ed7e4 (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 d8b442870398cd20937a7dcce4d23b3f3da5bc1c
Author: QuzarDC <qu...@co...>
Date: Tue Apr 8 22:53:49 2025 -0400
Catch undefined exceptions as panic.
This should not happen.
commit 7c26e725c440fd5cd475aa5696116423795734a1
Author: QuzarDC <qu...@co...>
Date: Tue Apr 8 22:52:37 2025 -0400
Whitespace and comment cleanups.
Somehow there was quite a bit of stray whitespace.
commit 6ec1f394e3e450712816e07b3e156f6ff398a1ba
Author: QuzarDC <qu...@co...>
Date: Tue Apr 8 22:29:25 2025 -0400
Remove unneeded defines.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/include/arch/irq.h | 25 ++----------------
kernel/arch/dreamcast/kernel/irq.c | 45 ++++++++++++++++----------------
2 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/kernel/arch/dreamcast/include/arch/irq.h b/kernel/arch/dreamcast/include/arch/irq.h
index f4858bd5..f0a50bf9 100644
--- a/kernel/arch/dreamcast/include/arch/irq.h
+++ b/kernel/arch/dreamcast/include/arch/irq.h
@@ -263,27 +263,6 @@ typedef enum irq_exception {
EXC_UNHANDLED_EXC = 0x07e0 /**< `[SOFT ]` Exception went unhandled */
} irq_t;
-
-/** \defgroup irq_type_offsets Exception type offsets
- \brief Offsets within exception types
- \ingroup irqs
-
- The following are a table of "type offsets" (see the Hitachi PDF). These are
- the 0x000, 0x100, 0x400, and 0x600 offsets.
-
- @{
-*/
-#define EXC_OFFSET_000 0 /**< \brief Offset 0x000 */
-#define EXC_OFFSET_100 1 /**< \brief Offset 0x100 */
-#define EXC_OFFSET_400 2 /**< \brief Offset 0x400 */
-#define EXC_OFFSET_600 3 /**< \brief Offset 0x600 */
-/** @} */
-
-/** \brief The value of the timer IRQ
- \ingroup irqs
-*/
-#define TIMER_IRQ EXC_TMU0_TUNI0
-
/** \defgroup irq_state State
\brief Methods for querying active IRQ information.
@@ -433,14 +412,14 @@ typedef struct irq_cb {
*/
/** Set or remove an IRQ handler.
-
+
Passing a NULL value for hnd will remove the current handler, if any.
\param code The IRQ type to set the handler for
(see #irq_t).
\param hnd A pointer to a procedure to handle the exception.
\param data A pointer that will be passed along to the callback.
-
+
\retval 0 On success.
\retval -1 If the code is invalid.
diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c
index a7b4c127..0e641380 100644
--- a/kernel/arch/dreamcast/kernel/irq.c
+++ b/kernel/arch/dreamcast/kernel/irq.c
@@ -131,22 +131,22 @@ static char *irq_exception_string(irq_t evt) {
case EXC_DATA_ADDRESS_WRITE:
return "Data address error (write)";
case EXC_DTLB_MISS_READ: /* or EXC_ITLB_MISS */
- return "Instruction or Data(read) TLB miss";
- case EXC_DTLB_MISS_WRITE:
+ return "Instruction or Data(read) TLB miss";
+ case EXC_DTLB_MISS_WRITE:
return "Data(write) TLB miss";
case EXC_DTLB_PV_READ: /* or EXC_ITLB_PV */
- return "Instruction or Data(read) TLB protection violation";
+ return "Instruction or Data(read) TLB protection violation";
case EXC_DTLB_PV_WRITE:
return "Data TLB protection violation (write)";
case EXC_FPU:
return "FPU exception";
- case EXC_INITIAL_PAGE_WRITE:
- return "Initial page write exception";
- case EXC_TRAPA:
- return "Unconditional trap (trapa)";
+ case EXC_INITIAL_PAGE_WRITE:
+ return "Initial page write exception";
+ case EXC_TRAPA:
+ return "Unconditional trap (trapa)";
case EXC_USER_BREAK_POST: /* or EXC_USER_BREAK_PRE */
- return "User break";
- default:
+ return "User break";
+ default:
return "Unknown exception";
}
}
@@ -169,17 +169,17 @@ void irq_dump_regs(int code, irq_t evt) {
dbglog(DBG_DEAD, " SR %08lx PR %08lx\n", irq_srt_addr->sr, irq_srt_addr->pr);
fp = regs[14];
arch_stk_trace_at(fp, 0);
-
+
if(code == 1) {
- dbglog(DBG_DEAD, "\nEncountered %s. ", irq_exception_string(evt));
-
+ dbglog(DBG_DEAD, "\nEncountered %s. ", irq_exception_string(evt));
+
valid_pc = arch_valid_text_address(irq_srt_addr->pc);
valid_pr = arch_valid_text_address(irq_srt_addr->pr);
/* Construct template message only if either PC/PR address is valid */
if(valid_pc || valid_pr) {
dbglog(DBG_DEAD, "Use this template terminal command to help"
" diagnose:\n\n\t$KOS_ADDR2LINE -f -C -i -e prog.elf");
-
+
if(valid_pc)
dbglog(DBG_DEAD, " %08lx", irq_srt_addr->pc);
@@ -217,20 +217,21 @@ void irq_handle_exception(int code) {
int handled = 0;
switch(code) {
- /* If it's a code 0, well, we shouldn't be here. */
- case 0:
- arch_panic("spurious RESET exception");
+ /* If it's a code 3, grab the event from intevt. */
+ case 3:
+ evt = INTEVT;
break;
/* If it's a code 1 or 2, grab the event from expevt. */
- case 1:
case 2:
+ case 1:
evt = EXPEVT;
break;
- /* If it's a code 3, grab the event from intevt. */
- case 3:
- evt = INTEVT;
+ /* If it's a code 0, well, we shouldn't be here. */
+ case 0:
+ default:
+ arch_panic("spurious RESET exception");
break;
}
@@ -246,7 +247,7 @@ void irq_handle_exception(int code) {
arch_panic("double fault");
}
- /* Reveal this info about the int to inside_int for better
+ /* Reveal this info about the int to inside_int for better
diagnostics returns if we try to do something in the int. */
inside_int = ((code&0xf)<<16) | (evt&0xffff);
@@ -380,7 +381,7 @@ int irq_init(void) {
/* Default to not in an interrupt */
inside_int = 0;
- /* Set a default timer handlers */
+ /* Set default timer handlers */
irq_set_handler(EXC_TMU0_TUNI0, irq_def_timer, (void *)TMU0);
irq_set_handler(EXC_TMU1_TUNI1, irq_def_timer, (void *)TMU1);
irq_set_handler(EXC_TMU2_TUNI2, irq_def_timer, (void *)TMU2);
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-03 03:44:30
|
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 b71353ca0095787e8d1ed9428cdeec65230ed7e4 (commit)
from ac44bb4422f9c2620697cbcc3dc571b6cd88990a (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 b71353ca0095787e8d1ed9428cdeec65230ed7e4
Author: darc <da...@pr...>
Date: Thu May 15 22:24:31 2025 -0500
Eliminate non-standard fixed-width integer types from examples
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/2ndmix/2ndmix.c | 45 +++++++++++-----------
examples/dreamcast/2ndmix/gfx/font14_256.h | 2 +-
.../dreamcast/basic/threading/rwsem/rwsem_test.c | 2 +-
examples/dreamcast/cpp/modplug_test/example.cpp | 8 ++--
examples/dreamcast/dreameye/basic/dreameye.c | 2 +-
examples/dreamcast/dreameye/sd/dreameye-sd.c | 4 +-
.../dreamcast/filesystem/sd/ext2fs/sd-ext2fs.c | 2 +-
examples/dreamcast/g1ata/atatest/atatest.c | 2 +-
examples/dreamcast/gldc/nehe/nehe26/nehe26.c | 2 +-
examples/dreamcast/keyboard/keytest/keytest.c | 8 ++--
.../dreamcast/kgl/basic/elements/pvr-texture.c | 4 +-
examples/dreamcast/kgl/basic/gl/pvr-texture.c | 4 +-
examples/dreamcast/kgl/basic/scissor/pvr-texture.c | 4 +-
examples/dreamcast/kgl/basic/txrenv/pvr-texture.c | 4 +-
.../dreamcast/kgl/basic/zclip_arrays/pvr-texture.c | 4 +-
examples/dreamcast/kgl/demos/blur/pvr-texture.c | 4 +-
examples/dreamcast/kgl/demos/mipmap/pvr-texture.c | 4 +-
.../kgl/demos/multitexture-arrays/pvr-texture.c | 4 +-
.../kgl/demos/multitexture-elements/pvr-texture.c | 4 +-
examples/dreamcast/kgl/demos/specular/font.c | 2 +-
examples/dreamcast/kgl/demos/specular/font.h | 4 +-
.../dreamcast/kgl/demos/specular/pvr-texture.c | 4 +-
examples/dreamcast/kgl/demos/specular/specular.c | 2 +-
examples/dreamcast/kgl/demos/specular/timer.c | 6 +--
examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c | 4 +-
examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c | 4 +-
examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c | 4 +-
examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c | 4 +-
examples/dreamcast/kgl/nehe/nehe26/nehe26.c | 2 +-
examples/dreamcast/libdream/lcd/lcd.c | 2 +-
examples/dreamcast/libdream/spu/spu.c | 2 +-
examples/dreamcast/libdream/ta/ta.c | 2 +-
examples/dreamcast/libdream/vmu/vmu.c | 22 +++++------
examples/dreamcast/lightgun/basic/lightgun.c | 2 +-
examples/dreamcast/lua/basic/lua.c | 2 +-
examples/dreamcast/mruby/dreampresent/dckos.c | 4 +-
examples/dreamcast/mruby/mrbtris/dckos.c | 4 +-
examples/dreamcast/network/ping/ping.c | 6 +--
examples/dreamcast/network/ping6/ping.c | 4 +-
examples/dreamcast/network/udpecho6/echo.c | 2 +-
.../dreamcast/parallax/delay_cube/delay_cube.c | 2 +-
examples/dreamcast/parallax/rotocube/rotocube.c | 6 +--
.../dreamcast/parallax/serpent_dma/perfmeter.c | 2 +-
examples/dreamcast/parallax/serpent_dma/serpent.c | 6 +--
examples/dreamcast/pvr/cheap_shadow/shadow.c | 2 +-
examples/dreamcast/pvr/modifier_volume/modifier.c | 2 +-
.../dreamcast/pvr/modifier_volume_tex/modifier.c | 2 +-
examples/dreamcast/pvr/plasma/plasma.c | 6 +--
.../dreamcast/pvr/texture_render/texture_render.c | 6 +--
examples/dreamcast/sound/ghettoplay-vorbis/bkg.c | 4 +-
.../dreamcast/sound/ghettoplay-vorbis/songmenu.c | 8 ++--
.../dreamcast/sound/ghettoplay-vorbis/texture.c | 6 +--
examples/dreamcast/vmu/vmu_game/vmu_game.c | 4 +-
examples/dreamcast/vmu/vmu_pkg/vmu.c | 1 -
54 files changed, 127 insertions(+), 131 deletions(-)
diff --git a/examples/dreamcast/2ndmix/2ndmix.c b/examples/dreamcast/2ndmix/2ndmix.c
index 90548f50..eac469c2 100644
--- a/examples/dreamcast/2ndmix/2ndmix.c
+++ b/examples/dreamcast/2ndmix/2ndmix.c
@@ -39,7 +39,7 @@ volatile unsigned long *snd_dbg = (unsigned long*)0xa080ffc0;
void play_s3m(char *fn) {
int idx, r;
- uint32 fd;
+ uint32_t fd;
unsigned char buffer[2048];
spu_disable();
@@ -370,25 +370,25 @@ void cubes_one_frame(void) {
a few more support bits in there before this will work fully. */
struct pcx_hdr {
- char Mfg; // manufacturer, always 0xa0
- char Ver; // encoder version number (5)
- char Enc; // encoding code, always 1
- char Bpp; // bits per pixel, 8 in mode 0x13
- uint16 Xmin, Ymin; // image origin, usually 0,0
- uint16 Xmax, Ymax; // image dimensions
- uint16 Hres; // horizontal resolution value
- uint16 Vres; // vertical resolution value
- char Pal[48]; // palette (not in mode 0x13)
- char Reserved; // who knows?
- char ClrPlanes; // number of planes, 1 in mode 0x13
- uint16 Bpl; // bytes per line, 80 in mode 0x13
- uint16 plType; // Grey or Color palette flag
- char Filler[58]; // Zsoft wanted a 128 byte header
+ char Mfg; // manufacturer, always 0xa0
+ char Ver; // encoder version number (5)
+ char Enc; // encoding code, always 1
+ char Bpp; // bits per pixel, 8 in mode 0x13
+ uint16_t Xmin, Ymin; // image origin, usually 0,0
+ uint16_t Xmax, Ymax; // image dimensions
+ uint16_t Hres; // horizontal resolution value
+ uint16_t Vres; // vertical resolution value
+ char Pal[48]; // palette (not in mode 0x13)
+ char Reserved; // who knows?
+ char ClrPlanes; // number of planes, 1 in mode 0x13
+ uint16_t Bpl; // bytes per line, 80 in mode 0x13
+ uint16_t plType; // Grey or Color palette flag
+ char Filler[58]; // Zsoft wanted a 128 byte header
};
short imageWidth, imageHeight;
-uint8 *image; /* Allocate this first */
-uint8 *pcxpal;
+uint8_t *image; /* Allocate this first */
+uint8_t *pcxpal;
char *charmap;
int load_pcx(char *pcxdata) {
@@ -732,13 +732,13 @@ void font_one_frame(void) {
void font_init(void) {
size_t x, y, c;
- uint8 pcxpall[768];
- volatile uint16 *vtex;
- uint16 val;
+ uint8_t pcxpall[768];
+ volatile uint16_t *vtex;
+ uint16_t val;
pvr_poly_cxt_t tmp;
txr_font = pvr_mem_malloc(256 * 256 * 2);
- vtex = (vuint16*)txr_font;
+ vtex = (volatile uint16_t *)txr_font;
charmap = malloc(256);
image = malloc(FONT_PIC_WIDTH * FONT_PIC_HEIGHT);
@@ -749,7 +749,7 @@ void font_init(void) {
return;
}
- printf("Drawing into 0x%08lx\r\n", (uint32)vtex);
+ printf("Drawing into 0x%08lx\r\n", (uint32_t)vtex);
for(y = 0; y < FONT_PIC_HEIGHT; y++) {
for(x = 0; x < FONT_PIC_WIDTH; x++) {
@@ -875,4 +875,3 @@ int main(int argc, const char *argv[]) {
return 0;
}
-
diff --git a/examples/dreamcast/2ndmix/gfx/font14_256.h b/examples/dreamcast/2ndmix/gfx/font14_256.h
index 5243d433..b0716a08 100644
--- a/examples/dreamcast/2ndmix/gfx/font14_256.h
+++ b/examples/dreamcast/2ndmix/gfx/font14_256.h
@@ -1,4 +1,4 @@
-uint8 font14_256_pcx[] = {
+uint8_t font14_256_pcx[] = {
10, 5, 1, 8, 0, 0, 0, 0, 255, 0, 255, 0, 44, 1, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/examples/dreamcast/basic/threading/rwsem/rwsem_test.c b/examples/dreamcast/basic/threading/rwsem/rwsem_test.c
index efeccdba..e73bcfe4 100644
--- a/examples/dreamcast/basic/threading/rwsem/rwsem_test.c
+++ b/examples/dreamcast/basic/threading/rwsem/rwsem_test.c
@@ -23,7 +23,7 @@
#define UNUSED __attribute__((unused))
rw_semaphore_t s = RWSEM_INITIALIZER;
-uint32 number = 0;
+uint32_t number = 0;
void *writer0(void *param UNUSED) {
int i;
diff --git a/examples/dreamcast/cpp/modplug_test/example.cpp b/examples/dreamcast/cpp/modplug_test/example.cpp
index 55c60f2a..cb071cd0 100644
--- a/examples/dreamcast/cpp/modplug_test/example.cpp
+++ b/examples/dreamcast/cpp/modplug_test/example.cpp
@@ -2,7 +2,7 @@
#include <modplug/stdafx.h>
#include <modplug/sndfile.h>
-uint16 sound_buffer[65536] = {0};
+uint16_t sound_buffer[65536] = {0};
CSoundFile *soundfile;
void *mod_callback(snd_stream_hnd_t hnd, int len, int * actual) {
@@ -24,8 +24,8 @@ void *mod_callback(snd_stream_hnd_t hnd, int len, int * actual) {
int main(int argc, char **argv) {
maple_device_t *cont;
cont_state_t *state;
- uint8 *mod_buffer;
- uint32 hnd;
+ uint8_t *mod_buffer;
+ uint32_t hnd;
char filename[] = "/rd/test.s3m";
printf("modplug_test beginning\n");
@@ -40,7 +40,7 @@ int main(int argc, char **argv) {
}
printf("Filesize: %i\n", fs_total(hnd));
- mod_buffer = (uint8 *)malloc(fs_total(hnd));
+ mod_buffer = (uint8_t *)malloc(fs_total(hnd));
if(!mod_buffer) {
printf("Not enough memory\n");
diff --git a/examples/dreamcast/dreameye/basic/dreameye.c b/examples/dreamcast/dreameye/basic/dreameye.c
index 0dd2f997..211db314 100644
--- a/examples/dreamcast/dreameye/basic/dreameye.c
+++ b/examples/dreamcast/dreameye/basic/dreameye.c
@@ -13,7 +13,7 @@
int main(int argc, char *argv[]) {
maple_device_t *dreameye;
dreameye_state_t *state;
- uint8 *buf;
+ uint8_t *buf;
int size, err;
FILE *fp;
diff --git a/examples/dreamcast/dreameye/sd/dreameye-sd.c b/examples/dreamcast/dreameye/sd/dreameye-sd.c
index 423ebf50..68c4beb8 100644
--- a/examples/dreamcast/dreameye/sd/dreameye-sd.c
+++ b/examples/dreamcast/dreameye/sd/dreameye-sd.c
@@ -23,13 +23,13 @@
int main(int argc, char *argv[]) {
maple_device_t *dreameye;
dreameye_state_t *state;
- uint8 *buf = NULL;
+ uint8_t *buf = NULL;
int size, err;
FILE *fp;
int img_count, i;
char fn[64];
kos_blockdev_t sd_dev;
- uint8 partition_type;
+ uint8_t partition_type;
/* We're not using these, obviously... */
(void)argc;
diff --git a/examples/dreamcast/filesystem/sd/ext2fs/sd-ext2fs.c b/examples/dreamcast/filesystem/sd/ext2fs/sd-ext2fs.c
index a2de1e83..2e7a0d31 100644
--- a/examples/dreamcast/filesystem/sd/ext2fs/sd-ext2fs.c
+++ b/examples/dreamcast/filesystem/sd/ext2fs/sd-ext2fs.c
@@ -34,7 +34,7 @@
int main(int argc, char *argv[]) {
kos_blockdev_t sd_dev;
- uint8 partition_type;
+ uint8_t partition_type;
DIR *d;
struct dirent *entry;
#ifdef ENABLE_WRITE
diff --git a/examples/dreamcast/g1ata/atatest/atatest.c b/examples/dreamcast/g1ata/atatest/atatest.c
index 07e20426..f3f94f5b 100644
--- a/examples/dreamcast/g1ata/atatest/atatest.c
+++ b/examples/dreamcast/g1ata/atatest/atatest.c
@@ -27,7 +27,7 @@ static unsigned char tmp[512] __attribute__((aligned(32)));
int main(int argc, char *argv[]) {
kos_blockdev_t bd_pio, bd_dma;
- uint64 spio, epio, sdma, edma, timer;
+ uint64_t spio, epio, sdma, edma, timer;
uint8_t pt;
dbglog(DBG_DEBUG, "Starting G1 ATA test program...\n");
diff --git a/examples/dreamcast/gldc/nehe/nehe26/nehe26.c b/examples/dreamcast/gldc/nehe/nehe26/nehe26.c
index fe1e563a..779afc01 100644
--- a/examples/dreamcast/gldc/nehe/nehe26/nehe26.c
+++ b/examples/dreamcast/gldc/nehe/nehe26/nehe26.c
@@ -321,7 +321,7 @@ void draw_gl(void) {
int main(int argc, char **argv) {
maple_device_t *cont;
cont_state_t *state;
- uint16 last = CONT_A;
+ uint16_t last = CONT_A;
xrot = yrot = zrot = 0.0f;
xspeed = yspeed = zspeed = 0.0f;
diff --git a/examples/dreamcast/keyboard/keytest/keytest.c b/examples/dreamcast/keyboard/keytest/keytest.c
index 9863c8e9..1c50c0e7 100644
--- a/examples/dreamcast/keyboard/keytest/keytest.c
+++ b/examples/dreamcast/keyboard/keytest/keytest.c
@@ -26,15 +26,15 @@ Room has been explicitly left open for further tests. It might be useful to incl
#include <kos.h>
KOS_INIT_FLAGS(INIT_DEFAULT);
-extern uint16 *vram_s;
+extern uint16_t *vram_s;
cont_state_t* first_kbd_state;
maple_device_t* first_kbd_dev = NULL;
/* Track how many times we try to find a keyboard before just quitting. */
-uint8 no_kbd_loop = 0;
+uint8_t no_kbd_loop = 0;
/* This is set up to have multiple tests in the future. */
-uint8 test_phase = 0;
+uint8_t test_phase = 0;
void basic_typing (void)
@@ -42,7 +42,7 @@ void basic_typing (void)
int charcount = 0;
int rv;
int lines = 0;
- uint32 offset = ((STARTLINE+(lines*BFONT_HEIGHT)) * WIDTH);
+ uint32_t offset = ((STARTLINE+(lines*BFONT_HEIGHT)) * WIDTH);
bfont_draw_str(vram_s + offset, WIDTH, 1, "Test of basic typing. Enter 120 characters: ");
offset = ((STARTLINE+((++lines)*BFONT_HEIGHT)) * WIDTH);
diff --git a/examples/dreamcast/kgl/basic/elements/pvr-texture.c b/examples/dreamcast/kgl/basic/elements/pvr-texture.c
index d73433f3..051738ba 100644
--- a/examples/dreamcast/kgl/basic/elements/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/elements/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/basic/gl/pvr-texture.c b/examples/dreamcast/kgl/basic/gl/pvr-texture.c
index d73433f3..051738ba 100644
--- a/examples/dreamcast/kgl/basic/gl/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/gl/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/basic/scissor/pvr-texture.c b/examples/dreamcast/kgl/basic/scissor/pvr-texture.c
index d73433f3..051738ba 100644
--- a/examples/dreamcast/kgl/basic/scissor/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/scissor/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c b/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c
index d73433f3..051738ba 100644
--- a/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c b/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c
index d73433f3..051738ba 100644
--- a/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/demos/blur/pvr-texture.c b/examples/dreamcast/kgl/demos/blur/pvr-texture.c
index 15ee4529..09e95712 100644
--- a/examples/dreamcast/kgl/demos/blur/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/blur/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c b/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c
index 15ee4529..09e95712 100644
--- a/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c b/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c
index 15ee4529..09e95712 100644
--- a/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c b/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c
index 15ee4529..09e95712 100644
--- a/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/demos/specular/font.c b/examples/dreamcast/kgl/demos/specular/font.c
index 97bcdfe6..ede5471b 100644
--- a/examples/dreamcast/kgl/demos/specular/font.c
+++ b/examples/dreamcast/kgl/demos/specular/font.c
@@ -16,7 +16,7 @@
Font *FontInit(float TexW, float TexH,
unsigned char RowStride, unsigned char ColStride,
- uint32 Color) {
+ uint32_t Color) {
Font *font = malloc(sizeof(Font));
font->TexW = TexW;
diff --git a/examples/dreamcast/kgl/demos/specular/font.h b/examples/dreamcast/kgl/demos/specular/font.h
index b1b8ed64..5e083b9b 100644
--- a/examples/dreamcast/kgl/demos/specular/font.h
+++ b/examples/dreamcast/kgl/demos/specular/font.h
@@ -25,11 +25,11 @@ typedef struct {
Font *FontInit(float TexW, float TexH,
unsigned char RowStride, unsigned char ColStride,
- uint32 Color);
+ uint32_t Color);
void FontPrintString(Font *font, char *str, float xpos, float ypos,
float width, float height);
-void FontSetColor(Font *font, uint32 color);
+void FontSetColor(Font *font, uint32_t color);
#endif
diff --git a/examples/dreamcast/kgl/demos/specular/pvr-texture.c b/examples/dreamcast/kgl/demos/specular/pvr-texture.c
index d73433f3..051738ba 100644
--- a/examples/dreamcast/kgl/demos/specular/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/specular/pvr-texture.c
@@ -24,8 +24,8 @@ static GLuint PVR_TextureColor(unsigned char *HDR);
glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */
GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) {
FILE *tex = NULL;
- uint16 *TEX0 = NULL;
- uint8 HDR[PVR_HDR_SIZE];
+ uint16_t *TEX0 = NULL;
+ uint8_t HDR[PVR_HDR_SIZE];
GLuint texID, texSize, texW, texH, texFormat, texColor;
/* Open the PVR texture file, and get its file size */
diff --git a/examples/dreamcast/kgl/demos/specular/specular.c b/examples/dreamcast/kgl/demos/specular/specular.c
index b3a8b6c0..70fa2337 100644
--- a/examples/dreamcast/kgl/demos/specular/specular.c
+++ b/examples/dreamcast/kgl/demos/specular/specular.c
@@ -61,7 +61,7 @@ void glSetCameraPosition(vector3f campos, vector3f camdst) {
glhLookAtf2(campos, camdst, up);
}
-void draw_gl_cube(float x, float y, float z, uint32 color) {
+void draw_gl_cube(float x, float y, float z, uint32_t color) {
glPushMatrix();
glDisable(GL_LIGHTING);
diff --git a/examples/dreamcast/kgl/demos/specular/timer.c b/examples/dreamcast/kgl/demos/specular/timer.c
index 9c3cd50a..4cadee8d 100644
--- a/examples/dreamcast/kgl/demos/specular/timer.c
+++ b/examples/dreamcast/kgl/demos/specular/timer.c
@@ -7,13 +7,13 @@
#include "timer.h"
-static uint32 s, ms;
-static uint64 msec;
+static uint32_t s, ms;
+static uint64_t msec;
/* Get current hardware timing using arch/timer.h */
unsigned int GetTime(void) {
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-02 03:07:02
|
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 ac44bb4422f9c2620697cbcc3dc571b6cd88990a (commit)
from 192e295702414e074ca919532918b3c3851e185e (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 ac44bb4422f9c2620697cbcc3dc571b6cd88990a
Author: QuzarDC <qu...@co...>
Date: Fri Aug 1 03:23:57 2025 -0400
Remove deprecated header.
Was replaced in 2017 by implementing `<sys/uio.h>`.
-----------------------------------------------------------------------
Summary of changes:
include/kos/iovec.h | 25 -------------------------
1 file changed, 25 deletions(-)
delete mode 100644 include/kos/iovec.h
diff --git a/include/kos/iovec.h b/include/kos/iovec.h
deleted file mode 100644
index 64322f41..00000000
--- a/include/kos/iovec.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* KallistiOS ##version##
-
- kos/iovec.h
- Copyright (C) 2001 Megan Potter
-
-*/
-
-/** \file kos/iovec.h
- \brief Deprecated header file for I/O scatter/gather arrays.
- \deprecated
-
- See <sys/uio.h> for what used to be here.
-*/
-
-#ifndef __KOS_IOVEC_H
-#define __KOS_IOVEC_H
-
-#include <sys/uio.h>
-
-/** \brief Compatibility typedef for old code.
- \deprecated
-*/
-typedef struct iovec iovec_t;
-
-#endif /* __KOS_IOVEC_H */
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-07-31 15:37:21
|
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 192e295702414e074ca919532918b3c3851e185e (commit)
via 37fc685b31e587eae2cbff7b73bd7280317818e5 (commit)
from 723c04b64a128d46fca831b68b50eb15781306d4 (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 192e295702414e074ca919532918b3c3851e185e
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jul 29 16:11:56 2025 +0200
thread: Simplify thd_schedule()
Remove the 'now' parameter which was never really used.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 37fc685b31e587eae2cbff7b73bd7280317818e5
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jul 29 20:48:44 2025 +0200
thread: Factorize genwait wake code
Factorize the genwait wake code instead of having two slightly different
functions that do more or less the same thing.
Use TAILQ_FOREACH_SAFE() to simplify the code further.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
include/kos/thread.h | 3 +-
kernel/arch/dreamcast/hardware/cdrom.c | 4 +-
kernel/arch/dreamcast/hardware/g1ata.c | 2 +-
kernel/arch/dreamcast/hardware/g2dma.c | 2 +-
.../dreamcast/hardware/network/broadband_adapter.c | 2 +-
kernel/arch/dreamcast/hardware/pvr/pvr_dma.c | 2 +-
kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 2 +-
kernel/thread/genwait.c | 50 ++++------------------
kernel/thread/thread.c | 15 +++----
9 files changed, 22 insertions(+), 60 deletions(-)
diff --git a/include/kos/thread.h b/include/kos/thread.h
index 7b1ab1e5..98457f43 100644
--- a/include/kos/thread.h
+++ b/include/kos/thread.h
@@ -456,14 +456,13 @@ void thd_exit(void *rv) __noreturn;
time for checking timeouts.
\param front_of_line Set to false, unless you have a good reason not to.
- \param now Set to 0, unless you have a good reason not to.
\sa thd_schedule_next
\warning Never call this function from outside of an
interrupt context! Doing so will almost certainly
end very poorly.
*/
-void thd_schedule(bool front_of_line, uint64_t now);
+void thd_schedule(bool front_of_line);
/** \brief Force a given thread to the front of the queue.
\relatesalso kthread_t
diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c
index 78f4aa20..8d7d3497 100644
--- a/kernel/arch/dreamcast/hardware/cdrom.c
+++ b/kernel/arch/dreamcast/hardware/cdrom.c
@@ -761,7 +761,7 @@ static void cdrom_vblank(uint32 evt, void *data) {
if(dma_blocking) {
dma_blocking = false;
sem_signal(&dma_done);
- thd_schedule(1, 0);
+ thd_schedule(true);
}
}
}
@@ -779,7 +779,7 @@ static void g1_dma_irq_hnd(uint32_t code, void *data) {
if(dma_blocking) {
dma_blocking = false;
sem_signal(&dma_done);
- thd_schedule(1, 0);
+ thd_schedule(true);
}
else if(dma_thd) {
mutex_unlock_as_thread(&_g1_ata_mutex, dma_thd);
diff --git a/kernel/arch/dreamcast/hardware/g1ata.c b/kernel/arch/dreamcast/hardware/g1ata.c
index 8071bb02..c447fee1 100644
--- a/kernel/arch/dreamcast/hardware/g1ata.c
+++ b/kernel/arch/dreamcast/hardware/g1ata.c
@@ -243,7 +243,7 @@ static void g1_dma_done(void) {
/* Signal the calling thread to continue, if it is blocking. */
if(dma_blocking) {
sem_signal(&dma_done);
- thd_schedule(1, 0);
+ thd_schedule(true);
dma_blocking = 0;
}
diff --git a/kernel/arch/dreamcast/hardware/g2dma.c b/kernel/arch/dreamcast/hardware/g2dma.c
index e8ae8e12..a70a83af 100644
--- a/kernel/arch/dreamcast/hardware/g2dma.c
+++ b/kernel/arch/dreamcast/hardware/g2dma.c
@@ -150,7 +150,7 @@ static void g2_dma_irq_hnd(uint32_t code, void *data) {
if(dma_blocking[chn]) {
dma_blocking[chn] = 0;
sem_signal(&dma_done[chn]);
- thd_schedule(1, 0);
+ thd_schedule(true);
}
/* Call the callback, if any. */
diff --git a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c
index 95de93fb..601c4db9 100644
--- a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c
+++ b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c
@@ -499,7 +499,7 @@ static void rx_finish_enq(int room) {
if(room > 0 && (((rxin + 1) % MAX_PKTS) != rxout)) {
rxin = (rxin + 1) % MAX_PKTS;
sem_signal(&bba_rx_sema);
- thd_schedule(1, 0);
+ thd_schedule(true);
}
}
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c b/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c
index aeb28b39..871052e2 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c
@@ -62,7 +62,7 @@ static void pvr_dma_irq_hnd(uint32_t code, void *data) {
/* Signal the calling thread to continue, if any. */
if(dma_blocking) {
sem_signal(&dma_done);
- thd_schedule(1, 0);
+ thd_schedule(true);
dma_blocking = false;
}
}
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c
index 711b271b..fe298e21 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c
@@ -109,7 +109,7 @@ static void pvr_render_lists(void) {
// Signal the client code to continue onwards.
genwait_wake_all((void *)&pvr_state.ta_busy);
- thd_schedule(1, 0);
+ thd_schedule(true);
}
}
diff --git a/kernel/thread/genwait.c b/kernel/thread/genwait.c
index cf1a781b..a8f8d33f 100644
--- a/kernel/thread/genwait.c
+++ b/kernel/thread/genwait.c
@@ -124,10 +124,10 @@ static void genwait_unqueue(kthread_t * thd) {
}
}
-int genwait_wake_cnt(void * obj, int cntmax, int err) {
+static int genwait_wake_thd_cnt(void *obj, int cntmax, kthread_t *thd, int err) {
kthread_t * t, * nt;
struct slpquehead * qp;
- int cnt;
+ int cnt = 0;
/* Twiddle interrupt state */
irq_disable_scoped();
@@ -136,12 +136,9 @@ int genwait_wake_cnt(void * obj, int cntmax, int err) {
qp = &slpque[LOOKUP(obj)];
/* Go through and find any matching entries */
- for(cnt = 0, t = TAILQ_FIRST(qp); t != NULL; t = nt) {
- /* Get the next thread up front */
- nt = TAILQ_NEXT(t, thdq);
-
+ TAILQ_FOREACH_SAFE(t, qp, thdq, nt) {
/* Is this thread a match? */
- if(t->wait_obj == obj) {
+ if(t->wait_obj == obj && (!thd || t == thd)) {
/* Yes, remove it from the wait queue */
genwait_unqueue(t);
@@ -167,6 +164,10 @@ int genwait_wake_cnt(void * obj, int cntmax, int err) {
return cnt;
}
+int genwait_wake_cnt(void * obj, int cntmax, int err) {
+ return genwait_wake_thd_cnt(obj, cntmax, NULL, err);
+}
+
void genwait_wake_all(void * obj) {
genwait_wake_cnt(obj, -1, 0);
}
@@ -184,40 +185,7 @@ void genwait_wake_all_err(void *obj, int err) {
}
int genwait_wake_thd(void *obj, kthread_t *thd, int err) {
- kthread_t *t, *nt;
- struct slpquehead *qp;
-
- /* Twiddle interrupt state */
- irq_disable_scoped();
-
- /* Find the queue */
- qp = &slpque[LOOKUP(obj)];
-
- /* Go through and find any matching entries */
- for(t = TAILQ_FIRST(qp); t != NULL; t = nt) {
- /* Get the next thread up front */
- nt = TAILQ_NEXT(t, thdq);
-
- /* Is this thread a match? */
- if(t->wait_obj == obj && t == thd) {
- /* Yes, remove it from the wait queue */
- genwait_unqueue(t);
-
- /* Set the wake return value */
- if(err) {
- CONTEXT_RET(t->context) = -1;
- t->thd_errno = err;
- }
- else {
- CONTEXT_RET(t->context) = 0;
- }
-
- /* We found it, so we're done... */
- return 1;
- }
- }
-
- return 0;
+ return genwait_wake_thd_cnt(obj, 1, thd, err);
}
void genwait_check_timeouts(uint64_t tm) {
diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c
index 8b56e708..374235a2 100644
--- a/kernel/thread/thread.c
+++ b/kernel/thread/thread.c
@@ -619,11 +619,11 @@ static inline void thd_schedule_inner(kthread_t *thd) {
to make sure the priorities are all straight before returning, but you
don't want a full context switch inside the same priority group.
*/
-void thd_schedule(bool front_of_line, uint64_t now) {
+void thd_schedule(bool front_of_line) {
kthread_t *thd;
+ uint64_t now;
- if(now == 0)
- now = timer_ms_gettime64();
+ now = timer_ms_gettime64();
/* If there's only two thread left, it's the idle task and the reaper task:
exit the OS */
@@ -705,12 +705,10 @@ void thd_schedule_next(kthread_t *thd) {
/* See kos/thread.h for description */
irq_context_t *thd_choose_new(void) {
- uint64_t now = timer_ms_gettime64();
-
//printf("thd_choose_new() woken at %d\n", (uint32_t)now);
/* Do any re-scheduling */
- thd_schedule(0, now);
+ thd_schedule(false);
/* Return the new IRQ context back to the caller */
return &thd_current->context;
@@ -723,14 +721,11 @@ irq_context_t *thd_choose_new(void) {
again until our next context switch (if any). For pre-empts, re-schedule
threads, swap out contexts, and sleep. */
static void thd_timer_hnd(irq_context_t *context) {
- /* Get the system time */
- uint64_t now = timer_ms_gettime64();
-
(void)context;
//printf("timer woke at %d\n", (uint32_t)now);
- thd_schedule(0, now);
+ thd_schedule(false);
timer_primary_wakeup(thd_sched_ms);
}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-07-29 21:43:07
|
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 723c04b64a128d46fca831b68b50eb15781306d4 (commit)
from e9c9785d358d78f1cc0b42011bbfe6ac713486ee (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 723c04b64a128d46fca831b68b50eb15781306d4
Author: QuzarDC <qu...@co...>
Date: Tue Jul 22 13:32:18 2025 -0400
dmac: Avoid bug with `__is_aligned` macro.
`__is_aligned` as defined in newlib was missing parens around
the first parameter, so adding them here at the call to
correct its usage. This has been fixed upstream but requires
a toolchain update to be effective.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/dmac.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/arch/dreamcast/hardware/dmac.c b/kernel/arch/dreamcast/hardware/dmac.c
index 13c47164..3ff5b44b 100644
--- a/kernel/arch/dreamcast/hardware/dmac.c
+++ b/kernel/arch/dreamcast/hardware/dmac.c
@@ -144,8 +144,9 @@ int dma_transfer(const dma_config_t *cfg, dma_addr_t dst, dma_addr_t src,
unsigned int transfer_size = dma_unit_size[cfg->unit_size];
uint32_t chcr;
- if(!__is_aligned(len | dst | src, transfer_size)) {
- dbglog(DBG_ERROR, "dmac: src/dst/len not aligned to the bus width\n");
+ if(!__is_aligned((src|dst|len), transfer_size)) {
+ dbglog(DBG_ERROR, "dmac: src=0x%08x dst=0x%08x len=%u not aligned to %u bytes\n",
+ (uintptr_t)src, (uintptr_t)dst, (uintptr_t)len, transfer_size);
errno = EFAULT;
return -1;
}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-07-29 20:01:28
|
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 e9c9785d358d78f1cc0b42011bbfe6ac713486ee (commit)
via 2031e8a1dabde221aa355827a4b52c3f683341c1 (commit)
via 4dc76d1541bb354cb27069f49053f52f8dc5963a (commit)
via 1a7a5f412dde5f2879a42b1c1625dae6ae00265e (commit)
via 5987e2609587c7828b2cea91b3fb23e2c2361204 (commit)
via f7de8a4049d971f473c60549cf1a045bfb4cb540 (commit)
via 7f391369c9789c519b14707104d7d74abf1a07e2 (commit)
via 0ea314e7e4882b8ddc5860d8987452cbea4f594a (commit)
via 776d84b647cf047a85df054a445efd9501d3d8dd (commit)
from c62573617e4718d48f0ac3fe0cb02d60b78bed32 (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 e9c9785d358d78f1cc0b42011bbfe6ac713486ee
Author: QuzarDC <qu...@co...>
Date: Mon Jul 28 20:36:57 2025 -0400
fs_romdisk: Free dangling FDs on shutdown.
It's just polite.
commit 2031e8a1dabde221aa355827a4b52c3f683341c1
Author: QuzarDC <qu...@co...>
Date: Mon Jul 28 15:49:55 2025 -0400
fs_romdisk: Dynamically allocated FD tracking.
As with #973 remove the static table and pass a pointer
to the FD object out rather than index.
This additionally means that the define for the max files
can be removed. While there I removed the one for CDFS
that should have been removed when it was obsoleted.
commit 4dc76d1541bb354cb27069f49053f52f8dc5963a
Author: QuzarDC <qu...@co...>
Date: Mon Jul 28 03:32:28 2025 -0400
fs_romdisk: Deduplicate fd validity checks.
For all but the two checks in open/close, this is
just an identical replica of what was happening.
In open, if the fd is in bounds, then index must have
already be set to `FH_INDEX_RESERVED` so it can't
make a difference. In close, if it's invalid because
it's already set to `FH_INDEX_FREE` then there's nothing
to be done anyways.
commit 1a7a5f412dde5f2879a42b1c1625dae6ae00265e
Author: QuzarDC <qu...@co...>
Date: Mon Jul 28 02:49:20 2025 -0400
fs_romdisk: Tidy romdisk_find.
Was strangely using a nested else{if/else} rather than elseif/else.
commit 5987e2609587c7828b2cea91b3fb23e2c2361204
Author: QuzarDC <qu...@co...>
Date: Mon Jul 28 02:07:31 2025 -0400
fs_romdisk: Refactor romdisk unmounting/shutdown.
`fs_romdisk_shutdown` was effectively duplicating
`fs_romdisk_unmount` in a loop over all entries in
the `romdisks` list. Should be functionally identical
except for now `fs_romdisk_shutdown` both locks the
list mutex while working on it and removes the entries
from the list.
commit f7de8a4049d971f473c60549cf1a045bfb4cb540
Author: QuzarDC <qu...@co...>
Date: Mon Jul 28 00:33:57 2025 -0400
fs_romdisk: Refactor `fs_romdisk_unmount`
Use the newer scoped mutex lock, reduce nesting, deduplicate
the own_buffer check, and remove unneded `rv`.
commit 7f391369c9789c519b14707104d7d74abf1a07e2
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 21:33:33 2025 -0400
fs_romdisk: Remove header pointer from internal image struct.
This is always simply the start of the image, and on top of
that it is never used. So just removing it. Cleaned up the
access to the magic string from the header as well.
commit 0ea314e7e4882b8ddc5860d8987452cbea4f594a
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 21:17:47 2025 -0400
fs_romdisk: Update param to `bool`.
commit 776d84b647cf047a85df054a445efd9501d3d8dd
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 20:27:02 2025 -0400
fs_romdisk: Replace arch/types with stdint.
Additionally correct minor whitespace issues around
var declarations or casts.
-----------------------------------------------------------------------
Summary of changes:
include/kos/fs_romdisk.h | 11 +-
include/kos/opts.h | 10 -
kernel/arch/dreamcast/kernel/init.c | 2 +-
kernel/fs/fs_romdisk.c | 383 +++++++++++++++++-------------------
4 files changed, 192 insertions(+), 214 deletions(-)
diff --git a/include/kos/fs_romdisk.h b/include/kos/fs_romdisk.h
index 274d00a5..3eb2d952 100644
--- a/include/kos/fs_romdisk.h
+++ b/include/kos/fs_romdisk.h
@@ -50,9 +50,10 @@
#define __KOS_FS_ROMDISK_H
#include <sys/cdefs.h>
+#include <stdbool.h>
+#include <stdint.h>
__BEGIN_DECLS
-#include <arch/types.h>
#include <kos/fs.h>
/** \defgroup vfs_romdisk Romdisk
@@ -81,22 +82,22 @@ void fs_romdisk_shutdown(void);
\param mountpoint The directory to mount this romdisk on
\param img The ROMFS image
- \param own_buffer If 0, you are still responsible for img, and must
- free it if appropriate. If non-zero, img will be
+ \param own_buffer If false, you are still responsible for img, and
+ must free it if appropriate. If true, img will be
freed when it is unmounted
\retval 0 On success
\retval -1 If fs_romdisk_init not called
\retval -2 If img is invalid
\retval -3 If a malloc fails
*/
-int fs_romdisk_mount(const char * mountpoint, const uint8 *img, int own_buffer);
+int fs_romdisk_mount(const char * mountpoint, const uint8_t *img, bool own_buffer);
/** \brief Unmount a ROMFS image.
This function unmounts a ROMFS image that has been previously mounted with
fs_romdisk_mount(). This function does not check for open files on the fs,
so make sure that all files have been closed before calling it. If the VFS
- owns the buffer (own_buffer was non-zero when you called the mount function)
+ owns the buffer (own_buffer was true when you called the mount function)
then this function will also free the buffer.
\param mountpoint The ROMFS to unmount
diff --git a/include/kos/opts.h b/include/kos/opts.h
index 66eedea2..8000da10 100644
--- a/include/kos/opts.h
+++ b/include/kos/opts.h
@@ -114,16 +114,6 @@ __BEGIN_DECLS
#define VMUFS_DEBUG 1
#endif
-/** \brief The maximum number of cd files that can be open at a time. */
-#ifndef FS_CD_MAX_FILES
-#define FS_CD_MAX_FILES 8
-#endif
-
-/** \brief The maximum number of romdisk files that can be open at a time. */
-#ifndef FS_ROMDISK_MAX_FILES
-#define FS_ROMDISK_MAX_FILES 16
-#endif
-
/** \brief The maximum number of ramdisk files that can be open at a time. */
#ifndef FS_RAMDISK_MAX_FILES
#define FS_RAMDISK_MAX_FILES 8
diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c
index 7f75feb7..9ad3b7e9 100644
--- a/kernel/arch/dreamcast/kernel/init.c
+++ b/kernel/arch/dreamcast/kernel/init.c
@@ -107,7 +107,7 @@ void vmu_fs_shutdown(void) {
/* Mount the built-in romdisk to /rd. */
void fs_romdisk_mount_builtin(void) {
- fs_romdisk_mount("/rd", __kos_romdisk, 0);
+ fs_romdisk_mount("/rd", __kos_romdisk, false);
}
void fs_romdisk_mount_builtin_legacy(void) {
diff --git a/kernel/fs/fs_romdisk.c b/kernel/fs/fs_romdisk.c
index d8516892..b2bc3784 100644
--- a/kernel/fs/fs_romdisk.c
+++ b/kernel/fs/fs_romdisk.c
@@ -16,7 +16,6 @@ on sunsite.unc.edu in /pub/Linux/system/recovery/, or as a package under Debian
*/
-#include <arch/types.h>
#include <kos/thread.h>
#include <kos/mutex.h>
#include <kos/fs_romdisk.h>
@@ -50,26 +49,26 @@ on sunsite.unc.edu in /pub/Linux/system/recovery/, or as a package under Debian
clever and made this header a variable length depending on the size of
the volume name *groan*. Its size will be a multiple of 16 bytes though. */
typedef struct {
- char magic[8]; /* Should be "-rom1fs-" */
- uint32 full_size; /* Full size of the file system */
- uint32 checksum; /* Checksum */
- char volume_name[RD_VN_MAX]; /* Volume name (zero-terminated) */
+ char magic[8]; /* Should be "-rom1fs-" */
+ uint32_t full_size; /* Full size of the file system */
+ uint32_t checksum; /* Checksum */
+ char volume_name[RD_VN_MAX]; /* Volume name (zero-terminated) */
} romdisk_hdr_t;
/* File header info; note that this header plus filename must be a multiple of
16 bytes, and the following file data must also be a multiple of 16 bytes. */
typedef struct {
- uint32 next_header; /* Offset of next header */
- uint32 spec_info; /* Spec info */
- uint32 size; /* Data size */
- uint32 checksum; /* File checksum */
- char filename[RD_FN_MAX]; /* File name (zero-terminated) */
+ uint32_t next_header; /* Offset of next header */
+ uint32_t spec_info; /* Spec info */
+ uint32_t size; /* Data size */
+ uint32_t checksum; /* File checksum */
+ char filename[RD_FN_MAX]; /* File name (zero-terminated) */
} romdisk_file_t;
-/* Util function to reverse the byte order of a uint32 */
-static uint32 ntohl_32(const void *data) {
- const uint8 *d = (const uint8*)data;
+/* Util function to reverse the byte order of a uint32_t */
+static uint32_t ntohl_32(const void *data) {
+ const uint8_t *d = (const uint8_t *)data;
return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3] << 0);
}
@@ -84,11 +83,10 @@ typedef LIST_HEAD(rdi_list, rd_image) rdi_list_t;
typedef struct rd_image {
LIST_ENTRY(rd_image) list_ent; /* List entry */
- int own_buffer; /* Do we own the memory? */
- const uint8 * image; /* The actual image */
- const romdisk_hdr_t * hdr; /* Pointer to the header */
- uint32 files; /* Offset in the image to the files area */
- vfs_handler_t * vfsh; /* Our VFS mount struct */
+ bool own_buffer; /* Do we own the memory? */
+ const uint8_t *image; /* The actual image */
+ uint32_t files; /* Offset in the image to the files area */
+ vfs_handler_t *vfsh; /* Our VFS mount struct */
} rd_image_t;
/* Global list of mounted romdisks */
@@ -97,33 +95,41 @@ static rdi_list_t romdisks;
/********************************************************************************/
/* File primitives */
-/* File handles.. I could probably do this with a linked list, but I'm just
- too lazy right now. =) */
-static struct {
- uint32 index; /* romfs image index */
- bool dir; /* true if a directory */
- uint32 ptr; /* Current read position in bytes */
- uint32 size; /* Length of file in bytes */
- dirent_t dirent; /* A static dirent to pass back to clients */
- rd_image_t * mnt; /* Which mount instance are we using? */
-} fh[FS_ROMDISK_MAX_FILES];
+/* Entries in the fd list. Pointers of this type are passed out to ref files. */
+typedef struct rd_fd {
+ uint32_t index; /* romfs image index */
+ bool dir; /* true if a directory */
+ uint32_t ptr; /* Current read position in bytes */
+ uint32_t size; /* Length of file in bytes */
+ dirent_t dirent; /* A static dirent to pass back to clients */
+ rd_image_t *mnt; /* Which mount instance are we using? */
+ TAILQ_ENTRY(rd_fd) next; /* Next handle in the linked list */
+} rd_fd_t;
+
+static TAILQ_HEAD(rd_fd_queue, rd_fd) rd_fd_queue;
#define FH_INDEX_FREE 0
#define FH_INDEX_RESERVED -1
+/* Test if an fd is invalid */
+static inline bool romdisk_fd_invalid(rd_fd_t *fd) {
+ return (!fd || (fd->index == FH_INDEX_FREE));
+}
+
/* File type */
#define ROMFH_DIR 1
#define ROMFH_MASK 3
/* Mutex for file handles */
+/* We use it for both the files list and the images list. */
static mutex_t fh_mutex;
/* Given a filename and a starting romdisk directory listing (byte offset),
search for the entry in the directory and return the byte offset to its
entry. */
static uint32_t romdisk_find_object(rd_image_t *mnt, const char *fn, size_t fnlen, bool dir, uint32_t offset) {
- uint32 i, ni, type;
+ uint32_t i, ni, type;
const romdisk_file_t *fhdr;
i = offset;
@@ -181,7 +187,7 @@ static uint32_t romdisk_find_object(rd_image_t *mnt, const char *fn, size_t fnle
It will return an offset in the romdisk image for the object. */
static uint32_t romdisk_find(rd_image_t *mnt, const char *fn, bool dir) {
const char *cur;
- uint32 i;
+ uint32_t i;
const romdisk_file_t *fhdr;
/* If the object is in a sub-tree, traverse the trees looking
@@ -202,22 +208,18 @@ static uint32_t romdisk_find(rd_image_t *mnt, const char *fn, bool dir) {
}
/* Locate the file in the resulting directory */
- if(*fn) {
- i = romdisk_find_object(mnt, fn, strlen(fn), dir, i);
+ if(*fn)
+ return romdisk_find_object(mnt, fn, strlen(fn), dir, i);
+ else if(!dir)
+ return 0;
+ else
return i;
- }
- else {
- if(!dir)
- return 0;
- else
- return i;
- }
}
/* Open a file or directory */
-static void * romdisk_open(vfs_handler_t * vfs, const char *fn, int mode) {
- file_t fd;
- uint32 filehdr;
+static void * romdisk_open(vfs_handler_t *vfs, const char *fn, int mode) {
+ rd_fd_t *fd;
+ uint32_t filehdr;
const romdisk_file_t *fhdr;
rd_image_t *mnt = (rd_image_t *)vfs->privdata;
@@ -239,62 +241,58 @@ static void * romdisk_open(vfs_handler_t * vfs, const char *fn, int mode) {
return NULL;
}
- /* Find a free file handle */
- mutex_lock(&fh_mutex);
-
- for(fd = 0; fd < FS_ROMDISK_MAX_FILES; fd++)
- if(fh[fd].index == FH_INDEX_FREE) {
- fh[fd].index = FH_INDEX_RESERVED;
- break;
- }
-
- mutex_unlock(&fh_mutex);
-
- if(fd >= FS_ROMDISK_MAX_FILES) {
- errno = ENFILE;
+ /* Allocate the fd */
+ fd = malloc(sizeof(rd_fd_t));
+ if(!fd) {
+ errno = ENOMEM;
return NULL;
}
/* Fill the fd structure */
fhdr = (const romdisk_file_t *)(mnt->image + filehdr);
- fh[fd].index = filehdr + sizeof(romdisk_file_t) + (strlen(fhdr->filename) / RD_FN_MAX) * RD_FN_MAX;
- fh[fd].dir = ((mode & O_DIR) != 0);
- fh[fd].ptr = 0;
- fh[fd].size = ntohl_32(&fhdr->size);
- fh[fd].mnt = mnt;
+ fd->index = filehdr + sizeof(romdisk_file_t) + (strlen(fhdr->filename) / RD_FN_MAX) * RD_FN_MAX;
+ fd->dir = ((mode & O_DIR) != 0);
+ fd->ptr = 0;
+ fd->size = ntohl_32(&fhdr->size);
+ fd->mnt = mnt;
+
+ /* Lock before modifying the queue. */
+ mutex_lock_scoped(&fh_mutex);
+
+ TAILQ_INSERT_TAIL(&rd_fd_queue, fd, next);
return (void *)fd;
}
/* Close a file or directory */
-static int romdisk_close(void * h) {
- file_t fd = (file_t)h;
+static int romdisk_close(void *h) {
+ rd_fd_t *fd = (rd_fd_t *)h;
+
+ /* Lock before modifying the queue. */
+ mutex_lock_scoped(&fh_mutex);
+ TAILQ_REMOVE(&rd_fd_queue, fd, next);
+ free(fd);
- /* Check that the fd is valid */
- if(fd < FS_ROMDISK_MAX_FILES) {
- /* No need to lock the mutex: this is an atomic op */
- fh[fd].index = FH_INDEX_FREE;
- }
return 0;
}
/* Read from a file */
-static ssize_t romdisk_read(void * h, void *buf, size_t bytes) {
- file_t fd = (file_t)h;
+static ssize_t romdisk_read(void *h, void *buf, size_t bytes) {
+ rd_fd_t *fd = (rd_fd_t *)h;
/* Check that the fd is valid */
- if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) {
+ if(romdisk_fd_invalid(fd) || fd->dir) {
errno = EINVAL;
return -1;
}
/* Is there enough left? */
- if((fh[fd].ptr + bytes) > fh[fd].size)
- bytes = fh[fd].size - fh[fd].ptr;
+ if((fd->ptr + bytes) > fd->size)
+ bytes = fd->size - fd->ptr;
/* Copy out the requested amount */
- memcpy(buf, fh[fd].mnt->image + fh[fd].index + fh[fd].ptr, bytes);
- fh[fd].ptr += bytes;
+ memcpy(buf, fd->mnt->image + fd->index + fd->ptr, bytes);
+ fd->ptr += bytes;
return bytes;
}
@@ -310,11 +308,11 @@ static ssize_t romdisk_write(void *h, const void *buf, size_t bytes) {
}
/* Seek elsewhere in a file */
-static off_t romdisk_seek(void * h, off_t offset, int whence) {
- file_t fd = (file_t)h;
+static off_t romdisk_seek(void *h, off_t offset, int whence) {
+ rd_fd_t *fd = (rd_fd_t *)h;
/* Check that the fd is valid */
- if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) {
+ if(romdisk_fd_invalid(fd) || fd->dir) {
errno = EBADF;
return -1;
}
@@ -327,25 +325,25 @@ static off_t romdisk_seek(void * h, off_t offset, int whence) {
return -1;
}
- fh[fd].ptr = offset;
+ fd->ptr = offset;
break;
case SEEK_CUR:
- if(offset < 0 && ((uint32)-offset) > fh[fd].ptr) {
+ if(offset < 0 && ((uint32_t)-offset) > fd->ptr) {
errno = EINVAL;
return -1;
}
- fh[fd].ptr += offset;
+ fd->ptr += offset;
break;
case SEEK_END:
- if(offset < 0 && ((uint32)-offset) > fh[fd].size) {
+ if(offset < 0 && ((uint32_t)-offset) > fd->size) {
errno = EINVAL;
return -1;
}
- fh[fd].ptr = fh[fd].size + offset;
+ fd->ptr = fd->size + offset;
break;
default:
@@ -354,80 +352,80 @@ static off_t romdisk_seek(void * h, off_t offset, int whence) {
}
/* Check bounds */
- if(fh[fd].ptr > fh[fd].size) fh[fd].ptr = fh[fd].size;
+ if(fd->ptr > fd->size) fd->ptr = fd->size;
- return fh[fd].ptr;
+ return fd->ptr;
}
/* Tell where in the file we are */
-static off_t romdisk_tell(void * h) {
- file_t fd = (file_t)h;
+static off_t romdisk_tell(void *h) {
+ rd_fd_t *fd = (rd_fd_t *)h;
- if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) {
+ if(romdisk_fd_invalid(fd) || fd->dir) {
errno = EINVAL;
return -1;
}
- return fh[fd].ptr;
+ return fd->ptr;
}
/* Tell how big the file is */
-static size_t romdisk_total(void * h) {
- file_t fd = (file_t)h;
+static size_t romdisk_total(void *h) {
+ rd_fd_t *fd = (rd_fd_t *)h;
- if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) {
+ if(romdisk_fd_invalid(fd) || fd->dir) {
errno = EINVAL;
return -1;
}
- return fh[fd].size;
+ return fd->size;
}
/* Read a directory entry */
-static dirent_t *romdisk_readdir(void * h) {
+static dirent_t *romdisk_readdir(void *h) {
romdisk_file_t *fhdr;
int type;
- file_t fd = (file_t)h;
+ rd_fd_t *fd = (rd_fd_t *)h;
- if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || !fh[fd].dir) {
+ if(romdisk_fd_invalid(fd) || !fd->dir) {
errno = EBADF;
return NULL;
}
/* This happens if we hit the end of the directory on advancing the pointer
last time through. */
- if(fh[fd].ptr == (uint32)-1)
+ if(fd->ptr == (uint32_t)-1)
return NULL;
/* Get the current file header */
- fhdr = (romdisk_file_t *)(fh[fd].mnt->image + fh[fd].index + fh[fd].ptr);
+ fhdr = (romdisk_file_t *)(fd->mnt->image + fd->index + fd->ptr);
/* Update the pointer */
- fh[fd].ptr = ntohl_32(&fhdr->next_header);
- type = fh[fd].ptr & 0x0f;
- fh[fd].ptr = fh[fd].ptr & 0xfffffff0;
+ fd->ptr = ntohl_32(&fhdr->next_header);
+ type = fd->ptr & 0x0f;
+ fd->ptr = fd->ptr & 0xfffffff0;
- if(fh[fd].ptr != 0)
- fh[fd].ptr = fh[fd].ptr - fh[fd].index;
+ if(fd->ptr != 0)
+ fd->ptr = fd->ptr - fd->index;
else
- fh[fd].ptr = (uint32)-1;
+ fd->ptr = (uint32_t)-1;
/* Copy out the requested data */
- strcpy(fh[fd].dirent.name, fhdr->filename);
- fh[fd].dirent.time = 0;
+ strcpy(fd->dirent.name, fhdr->filename);
+ fd->dirent.time = 0;
if((type & ROMFH_MASK) == ROMFH_DIR ||
- strcmp(fh[fd].dirent.name, ".") == 0 ||
- strcmp(fh[fd].dirent.name, "..") == 0) {
- fh[fd].dirent.attr = O_DIR;
- fh[fd].dirent.size = -1;
+ strcmp(fd->dirent.name, ".") == 0 ||
+ strcmp(fd->dirent.name, "..") == 0) {
+ fd->dirent.attr = O_DIR;
+ fd->dirent.size = -1;
}
else {
- fh[fd].dirent.attr = 0;
- fh[fd].dirent.size = ntohl_32(&fhdr->size);
+ fd->dirent.attr = 0;
+ fd->dirent.size = ntohl_32(&fhdr->size);
}
- return &fh[fd].dirent;
+ return &fd->dirent;
}
/* Just to get the errno that might be better recognized upstream. */
@@ -439,16 +437,16 @@ static int romdisk_unlink(vfs_handler_t *vfs, const char *fn) {
return -1;
}
-static void *romdisk_mmap(void * h) {
- file_t fd = (file_t)h;
+static void *romdisk_mmap(void *h) {
+ rd_fd_t *fd = (rd_fd_t *)h;
- if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE) {
+ if(romdisk_fd_invalid(fd)) {
errno = EINVAL;
return NULL;
}
/* Can't really help the loss of "const" here */
- return (void *)(fh[fd].mnt->image + fh[fd].index);
+ return (void *)(fd->mnt->image + fd->index);
}
static int romdisk_stat(vfs_handler_t *vfs, const char *path, struct stat *st,
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-07-29 15:16:52
|
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 c62573617e4718d48f0ac3fe0cb02d60b78bed32 (commit)
from abbef9219b1fc6ba8721cb059a6e969d4a946c9b (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 c62573617e4718d48f0ac3fe0cb02d60b78bed32
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jul 10 00:36:06 2025 +0200
timer: Fine-tune timer rate
The seconds counter has been reported to drift quite significantly vs. a
wall clock. This is most likely because until now we considered that the
peripheral clock was a perfect 50.0 MHz, while in practice it is closer
to 49.9 MHz.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/kernel/timer.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c
index fe5e7853..58a7b067 100644
--- a/kernel/arch/dreamcast/kernel/timer.c
+++ b/kernel/arch/dreamcast/kernel/timer.c
@@ -65,8 +65,11 @@ typedef enum PCK_DIV {
#define TIMER_TPSC PCK_DIV_4
/* Timer IRQ priority levels (0-15) */
#define TIMER_PRIO 15
-/* Peripheral clock rate (50Mhz) */
-#define TIMER_PCK 50000000
+
+/* Peripheral clock rate (~49.9 Mhz).
+ * The main clock is not exactly 200 MHz, and has been measured at
+ * 199499520 Hz. The peripheral clock is a quarter of that. */
+#define TIMER_PCK (199499520 / 4)
/* Timer registers, indexed by Timer ID. */
static const unsigned tcors[] = { TCOR0, TCOR1, TCOR2 };
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-07-29 13:13:40
|
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 abbef9219b1fc6ba8721cb059a6e969d4a946c9b (commit)
via 9a10d5659364850b6c59a492e4c72823f66a78eb (commit)
via a07874e2abbd960be7c189b5951322e8e8221ef9 (commit)
via 6698e8cf3486da3d3c022a7646413702ece7bc1e (commit)
from 23c46e9ff097e8ffea3a295a5a315ce829e00d6c (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 abbef9219b1fc6ba8721cb059a6e969d4a946c9b
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 19:16:28 2025 -0400
pvr: Replace arch/types usage in pvr_texture.
Additionally replace an alignment rounding with
the `__align_up` macro.
commit 9a10d5659364850b6c59a492e4c72823f66a78eb
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 19:10:32 2025 -0400
pvr: Add example for using 32-pixel strided textures
Originally authored by Andress Barajas for #836.
Demonstrates the generation of a 640 width texture
and the rendering of it using the global strided textures
setting.
commit a07874e2abbd960be7c189b5951322e8e8221ef9
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 18:35:01 2025 -0400
pvr: Add getter/setter for strided texture value.
Provide a friendly API to get/set the currently configured
texture stride value. That value is used to set the stride
width for any texture using the `PVR_TXRFMT_X32_STRIDE` flag.
These were originally authored by Andress Barajas for #836.
Additionally update the `fb_tex` example, to use this API
rather than directly modifying the register.
commit 6698e8cf3486da3d3c022a7646413702ece7bc1e
Author: QuzarDC <qu...@co...>
Date: Sun Jul 27 15:46:23 2025 -0400
pvr: Correct bits for strided texture format.
This has been incorrect since added. Bit 21 of the
texture format apparently has no effect, and bit 25
is what sets whether or not the texture u size is
read as a power of 2 or 32x the value in the lower bits
of the PVR_TEXTURE_MODULO register.
This striding does not apply for YUV textures and so
the use was simply removed in those examples.
-----------------------------------------------------------------------
Summary of changes:
.../dreamcast/kgl/basic/elements/pvr-texture.c | 2 +-
examples/dreamcast/kgl/basic/gl/pvr-texture.c | 2 +-
examples/dreamcast/kgl/basic/scissor/pvr-texture.c | 2 +-
examples/dreamcast/kgl/basic/txrenv/pvr-texture.c | 2 +-
.../dreamcast/kgl/basic/zclip_arrays/pvr-texture.c | 2 +-
examples/dreamcast/kgl/demos/blur/pvr-texture.c | 2 +-
examples/dreamcast/kgl/demos/mipmap/pvr-texture.c | 2 +-
.../kgl/demos/multitexture-arrays/pvr-texture.c | 2 +-
.../kgl/demos/multitexture-elements/pvr-texture.c | 2 +-
.../dreamcast/kgl/demos/specular/pvr-texture.c | 2 +-
examples/dreamcast/kgl/demos/specular/texture.c | 2 +-
examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c | 2 +-
examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c | 2 +-
examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c | 2 +-
examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c | 2 +-
examples/dreamcast/pvr/fb_tex/fb_tex.c | 11 +-
.../pty => pvr/strided_texture}/Makefile | 12 +-
.../pvr/strided_texture/strided_texture.c | 221 +++++++++++++++++++++
.../dreamcast/pvr/yuv_converter/YUV420/yuv420.c | 2 -
.../dreamcast/pvr/yuv_converter/YUV422/yuv422.c | 2 -
kernel/arch/dreamcast/hardware/pvr/pvr_texture.c | 66 +++---
kernel/arch/dreamcast/include/dc/pvr.h | 8 +-
kernel/arch/dreamcast/include/dc/pvr/pvr_regs.h | 7 +
kernel/arch/dreamcast/include/dc/pvr/pvr_txr.h | 46 ++++-
24 files changed, 345 insertions(+), 60 deletions(-)
copy examples/dreamcast/{filesystem/pty => pvr/strided_texture}/Makefile (74%)
create mode 100644 examples/dreamcast/pvr/strided_texture/strided_texture.c
diff --git a/examples/dreamcast/kgl/basic/elements/pvr-texture.c b/examples/dreamcast/kgl/basic/elements/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/basic/elements/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/elements/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/basic/gl/pvr-texture.c b/examples/dreamcast/kgl/basic/gl/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/basic/gl/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/gl/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/basic/scissor/pvr-texture.c b/examples/dreamcast/kgl/basic/scissor/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/basic/scissor/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/scissor/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c b/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/txrenv/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c b/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c
+++ b/examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/demos/blur/pvr-texture.c b/examples/dreamcast/kgl/demos/blur/pvr-texture.c
index 5056df13..15ee4529 100644
--- a/examples/dreamcast/kgl/demos/blur/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/blur/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c b/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c
index 5056df13..15ee4529 100644
--- a/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/mipmap/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c b/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c
index 5056df13..15ee4529 100644
--- a/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c b/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c
index 5056df13..15ee4529 100644
--- a/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/multitexture-elements/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/demos/specular/pvr-texture.c b/examples/dreamcast/kgl/demos/specular/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/demos/specular/pvr-texture.c
+++ b/examples/dreamcast/kgl/demos/specular/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/demos/specular/texture.c b/examples/dreamcast/kgl/demos/specular/texture.c
index aa56847c..e28621ad 100644
--- a/examples/dreamcast/kgl/demos/specular/texture.c
+++ b/examples/dreamcast/kgl/demos/specular/texture.c
@@ -82,7 +82,7 @@ GLuint glTextureLoadPVR(char *fname, unsigned char UseMipMap) {
break;//RECTANGLE
case 0x0B:
- texFormat = PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED;
+ texFormat = PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED;
break;//RECTANGULAR STRIDE
case 0x0D:
diff --git a/examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c b/examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c
+++ b/examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c b/examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c
+++ b/examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c b/examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c
+++ b/examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c b/examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c
index 0e03198f..d73433f3 100644
--- a/examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c
+++ b/examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c
@@ -134,7 +134,7 @@ static GLuint PVR_TextureFormat(unsigned char *HDR) {
return PVR_TXRFMT_NONTWIDDLED; //RECTANGLE
case 0x0B:
- return PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
+ return PVR_TXRFMT_X32_STRIDE | PVR_TXRFMT_NONTWIDDLED; //RECTANGULAR STRIDE
case 0x0D:
return PVR_TXRFMT_TWIDDLED; //RECTANGULAR TWIDDLED
diff --git a/examples/dreamcast/pvr/fb_tex/fb_tex.c b/examples/dreamcast/pvr/fb_tex/fb_tex.c
index db457e02..2eb896e5 100644
--- a/examples/dreamcast/pvr/fb_tex/fb_tex.c
+++ b/examples/dreamcast/pvr/fb_tex/fb_tex.c
@@ -7,10 +7,6 @@
#include <stdio.h>
#include <stdbool.h>
-/* XXX: KallistiOS has the wrong value for the stride bit. */
-#undef PVR_TXRFMT_STRIDE
-#define PVR_TXRFMT_STRIDE BIT(25)
-
#define SQUARE_SIZE 64
struct square_fcoords {
@@ -157,7 +153,7 @@ static void render_back_buffer_step2(pvr_ptr_t frontbuf, bool hi_chip) {
float uoffset;
pvr_poly_cxt_txr(&cxt, PVR_LIST_TR_POLY,
- PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED | PVR_TXRFMT_STRIDE,
+ PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED | PVR_TXRFMT_X32_STRIDE,
1024, 1024, frontbuf, PVR_FILTER_NEAREST);
if(fbuf_color == 0xffffffff) {
@@ -204,9 +200,8 @@ int main(int argc, char **argv) {
pvr_init_defaults();
- /* Set the stride length for strided textures.
- * Unit is a set of 32 pixels, hence the /32. */
- PVR_SET(PVR_TEXTURE_MODULO, 640 / 32);
+ /* Set the stride length for strided textures. */
+ pvr_txr_set_stride(640);
fake_tex = pvr_mem_malloc(sizeof(fake_tex_data));
pvr_txr_load(fake_tex_data, fake_tex, sizeof(fake_tex_data));
diff --git a/examples/dreamcast/filesystem/pty/Makefile b/examples/dreamcast/pvr/strided_texture/Makefile
similarity index 74%
copy from examples/dreamcast/filesystem/pty/Makefile
copy to examples/dreamcast/pvr/strided_texture/Makefile
index 4b6182d5..ed4fcca0 100644
--- a/examples/dreamcast/filesystem/pty/Makefile
+++ b/examples/dreamcast/pvr/strided_texture/Makefile
@@ -1,12 +1,10 @@
#
-# fs_pty test program
-#
+# strided_texture
# Copyright (C) 2024 Andress Barajas
-#
-
-TARGET = pty.elf
+#
-OBJS = pty.o
+TARGET = strided_texture.elf
+OBJS = strided_texture.o
all: rm-elf $(TARGET)
@@ -26,4 +24,4 @@ run: $(TARGET)
dist: $(TARGET)
-rm -f $(OBJS)
- $(KOS_STRIP) $(TARGET)
+ $(KOS_STRIP) $(TARGET)
\ No newline at end of file
diff --git a/examples/dreamcast/pvr/strided_texture/strided_texture.c b/examples/dreamcast/pvr/strided_texture/strided_texture.c
new file mode 100644
index 00000000..8115a2f4
--- /dev/null
+++ b/examples/dreamcast/pvr/strided_texture/strided_texture.c
@@ -0,0 +1,221 @@
+/* KallistiOS ##version##
+ strided_texture.c
+ Copyright (C) 2024 Andress Barajas
+*/
+
+/*
+ This example demonstrates rendering a black-and-white chessboard pattern
+ using a 640x480 texture with 16bpp color depth. In this example, the texture
+ width and stride are both set to 640. However, because 640 is not a power
+ of two, we need to use the `PVR_TXRFMT_X32_STRIDE` flag. This flag informs the
+ PVR that the texture's width (or "stride") is a multiple of 32 rather than
+ a power of two.
+ Steps to configure and render a texture with a 32-pixel multiple width:
+
+ 1. Configure the Polygon Header for Textures:
+
+ - Use `pvr_poly_cxt_txr()` to set up the polygon context for the texture.
+ - Specify `PVR_TXRFMT_NONTWIDDLED | PVR_TXRFMT_X32_STRIDE` in the format
+ flags.
+ - Provide dimensions in powers of two, which should be larger than the
+ actual texture. For example, if your texture is 640x480, set width and
+ height to `1024` and `512`, respectively.
+ Example:
+ ```c
+ pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY,
+ PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED |
+ PVR_TXRFMT_X32_STRIDE, 1024, 512,
+ texture_pointer, PVR_FILTER_NONE);
+ ```
+ 2. Set the Global Texture Stride Register:
+ - Use `pvr_txr_set_stride(texture_width);` to define a custom texture
+ stride width in increments of 32 pixels.
+ - The `texture_width` parameter should be the full width of the texture
+ in pixels.
+ - This setting instructs the hardware on how to interpret each row's
+ width in VRAM for non-power-of-two textures. For a 640-pixel wide
+ texture, you would call:
+
+ ```c
+ pvr_txr_set_stride(640);
+ ```
+ Important Notes:
+ - Texture widths that are multiples of 32 (but not powers of two) require
+ the `PVR_TXRFMT_X32_STRIDE` flag.
+ - Palette-based textures are incompatible with the `PVR_TXRFMT_X32_STRIDE`
+ flag, as are mipmaps as both require the texture format to be twiddled.
+ - `pvr_txr_set_stride()` sets a global PVR register. All textures using
+ the `PVR_TXRFMT_X32_STRIDE` flag in the same frame must share the same
+ stride. Changing `pvr_txr_set_stride()` affects all such textures
+ rendered afterward.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+
+#include <dc/pvr.h>
+#include <dc/maple.h>
+#include <dc/maple/controller.h>
+
+/* The width of the texture in pixels (must be a multiple of 32) */
+#define TEXTURE_WIDTH 640
+
+/* The height of the texture in pixels */
+#define TEXTURE_HEIGHT 480
+
+/*
+ Macro to calculate the next power of two for a given integer `x`.
+
+ Example:
+ NEXT_POWER_OF_TWO(640) -> 1024
+*/
+#define NEXT_POWER_OF_TWO(x) (1 << (32 - __builtin_clz((x) - 1)))
+
+/*
+ The power-of-two width to be passed to texture setup functions.
+ Based on TEXTURE_WIDTH, this should be equal to or greater than
+ TEXTURE_WIDTH, and will match the hardware requirement for
+ power-of-two texture dimensions.
+*/
+#define TEXTURE_PADDED_WIDTH NEXT_POWER_OF_TWO(TEXTURE_WIDTH)
+
+/*
+ The power-of-two height to be passed to texture setup functions.
+ Based on TEXTURE_HEIGHT, this should be equal to or greater than
+ TEXTURE_HEIGHT, following the power-of-two requirement.
+*/
+#define TEXTURE_PADDED_HEIGHT NEXT_POWER_OF_TWO(TEXTURE_HEIGHT)
+
+/* RGB565 colors for chessboard pattern */
+#define COLOR_BLACK 0x0000
+#define COLOR_WHITE 0xFFFF
+
+static pvr_poly_hdr_t hdr;
+static pvr_vertex_t verts[4];
+
+static pvr_ptr_t board_texture;
+
+static void draw_frame(void) {
+ pvr_wait_ready();
+ pvr_scene_begin();
+
+ pvr_list_begin(PVR_LIST_OP_POLY);
+
+ pvr_prim(&hdr, sizeof(hdr));
+
+ pvr_prim(&verts[0], sizeof(pvr_vertex_t));
+ pvr_prim(&verts[1], sizeof(pvr_vertex_t));
+ pvr_prim(&verts[2], sizeof(pvr_vertex_t));
+ pvr_prim(&verts[3], sizeof(pvr_vertex_t));
+
+ pvr_list_finish();
+ pvr_scene_finish();
+}
+
+static void load_texture(void) {
+ pvr_poly_cxt_t cxt;
+ uint16_t *grid_texture;
+
+ /* Allocate memory for the texture with 32-byte alignment */
+ grid_texture = (uint16_t *)aligned_alloc(32, TEXTURE_WIDTH * TEXTURE_HEIGHT * 2);
+
+ /* Generate a chessboard pattern */
+ for(int y = 0; y < TEXTURE_HEIGHT; y++) {
+ for(int x = 0; x < TEXTURE_WIDTH; x++) {
+ /* Determine if we are in an even or odd square. */
+ int square_x = x / 32;
+ int square_y = y / 32;
+ int is_white_square = (square_x + square_y) % 2;
+
+ grid_texture[y * TEXTURE_WIDTH + x] = is_white_square
+ ? COLOR_WHITE : COLOR_BLACK;
+ }
+ }
+
+ /* Allocate space in VRAM for the texture */
+ board_texture = pvr_mem_malloc(TEXTURE_WIDTH * TEXTURE_HEIGHT * 2);
+
+ /* Load the chessboard pattern into VRAM */
+ pvr_txr_load(grid_texture, board_texture,
+ TEXTURE_WIDTH * TEXTURE_HEIGHT * 2);
+
+ /* Set texture context format for nontwiddled, strided texture */
+ pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY,
+ PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED
+ | PVR_TXRFMT_X32_STRIDE, TEXTURE_PADDED_WIDTH,
+ TEXTURE_PADDED_HEIGHT, board_texture, PVR_FILTER_NONE);
+ pvr_poly_compile(&hdr, &cxt);
+
+ /* Set the global non-power-of-two stride register */
+ pvr_txr_set_stride(TEXTURE_WIDTH);
+
+ free(grid_texture);
+}
+
+/*
+ When setting up the vertices, the texture width (stride) is divided by
+ the padded texture width (and similarly for the height) to ensure that
+ the non-power-of-two dimensions are mapped correctly to the power-of-two
+ padded dimensions used in VRAM. This allows textures with non-standard
+ widths (e.g., multiples of 32) to render accurately on the Dreamcast's
+ PVR hardware.
+*/
+static void setup_vertices(void) {
+ int color = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
+
+ verts[0].x = 0.0f;
+ verts[0].y = 0.0f;
+ verts[0].z = 1.0f;
+ verts[0].u = 0.0f;
+ verts[0].v = 0.0f;
+ verts[0].argb = color;
+ verts[0].oargb = 0;
+ verts[0].flags = PVR_CMD_VERTEX;
+
+ verts[1].x = 640.0f;
+ verts[1].y = 0.0f;
+ verts[1].z = 1.0f;
+ verts[1].u = (float)TEXTURE_WIDTH / (float)TEXTURE_PADDED_WIDTH;
+ verts[1].v = 0.0f;
+ verts[1].argb = color;
+ verts[1].oargb = 0;
+ verts[1].flags = PVR_CMD_VERTEX;
+
+ verts[2].x = 0.0f;
+ verts[2].y = 480.0f;
+ verts[2].z = 1.0f;
+ verts[2].u = 0.0f;
+ verts[2].v = (float)TEXTURE_HEIGHT / (float)TEXTURE_PADDED_HEIGHT;
+ verts[2].argb = color;
+ verts[2].oargb = 0;
+ verts[2].flags = PVR_CMD_VERTEX;
+
+ verts[3].x = 640.0f;
+ verts[3].y = 480.0f;
+ verts[3].z = 1.0f;
+ verts[3].u = (float)TEXTURE_WIDTH / (float)TEXTURE_PADDED_WIDTH;
+ verts[3].v = (float)TEXTURE_HEIGHT / (float)TEXTURE_PADDED_HEIGHT;
+ verts[3].argb = color;
+ verts[3].oargb = 0;
+ verts[3].flags = PVR_CMD_VERTEX_EOL;
+}
+
+int main(int argc, char **argv) {
+
+ pvr_init_defaults();
+
+ /* If the user hits start, bail */
+ cont_btn_callback(0, CONT_START, (cont_btn_callback_t)exit);
+
+ load_texture();
+
+ setup_vertices();
+
+ draw_frame();
+
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|