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
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: ljsebald <ljs...@us...> - 2023-12-04 12:34:57
|
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 8d98948f2b6dfc9aedd8a1edd6fb209f300403ff (commit) via 036af84aa28358763ab2e4ee123755ba4b2cd902 (commit) via a96afcc11ecf820293475df23968e6c181a4de6d (commit) from b9b86efd2f32900f3c1725304c53d1ad462ec079 (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 8d98948f2b6dfc9aedd8a1edd6fb209f300403ff Author: Falco Girgis <gyr...@gm...> Date: Mon Dec 4 06:34:31 2023 -0600 RTC Date/Time Fix for Negative Unix Timestamps (#394) * First attempt at making RTC driver robust - Fixing time_t over/underflow for RTC API - Moved a bunch of private stuff that was polluting the global API into the .c file - Fixed up documentation in a few places, added more info on error conditions * Fixed all issues with date/time negatives/overflow - Had a precision issue with getting the current unix seconds where a subtraction that should've been done on an int64_t was done on a uint32_t, freaking out upon negatives - Had a precision issue with setting the current unix seconds where the updated boot time did a similar subtraction which got truncated as a uint32_t rather than an int64_t commit 036af84aa28358763ab2e4ee123755ba4b2cd902 Author: Falco Girgis <gyr...@gm...> Date: Sun Dec 3 23:22:10 2023 -0600 Doxygen GitHub link (#404) * Doxygen Layout Path Fix - Still wasn't the correct $(KOS_BASE) relative path. commit a96afcc11ecf820293475df23968e6c181a4de6d Author: Falco Girgis <gyr...@gm...> Date: Sun Dec 3 23:16:15 2023 -0600 Changed Doxygen to use $(KOS_BASE) for Navigator Layout Path (#403) * Changed Doxygen layout file to use KOS ENV path - Was previously using a relative path which would screw up depending on where Doxygen was run. ----------------------------------------------------------------------- Summary of changes: doc/Doxyfile | 2 +- kernel/arch/dreamcast/include/arch/rtc.h | 49 +++----------------- kernel/arch/dreamcast/kernel/rtc.c | 77 +++++++++++++++++++++++++++----- 3 files changed, 73 insertions(+), 55 deletions(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index 2f7c77a..290d332 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -786,7 +786,7 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = pages/DoxygenLayout.xml +LAYOUT_FILE = $(KOS_BASE)/doc/pages/DoxygenLayout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib diff --git a/kernel/arch/dreamcast/include/arch/rtc.h b/kernel/arch/dreamcast/include/arch/rtc.h index a68f7cf..9951cf4 100644 --- a/kernel/arch/dreamcast/include/arch/rtc.h +++ b/kernel/arch/dreamcast/include/arch/rtc.h @@ -59,48 +59,6 @@ __BEGIN_DECLS \sa wdt */ -/** \defgroup rtc_regs Registers - \brief RTC registers - \ingroup rtc - - All registers are located on the G2 BUS and must be read and - written to as full 32-byte values. -@{*/ - -/** \brief High 16-bit timestamp value - - 32-bit register containing the upper 16-bits of - the 32-bit timestamp in seconds. Only the lower 16-bits - are valid. - - \note Writing to this register will lock the timestamp registers. - */ -#define RTC_TIMESTAMP_HIGH_ADDR 0xa0710000 - -/** \brief Low 16-bit timestamp value - - 32-bit register containing the lower 16-bits of - the 32-bit timestamp in seconds. Only the lower 16-bits - are valid. - */ -#define RTC_TIMESTAMP_LOW_ADDR 0xa0710004 - -/** \brief Timestamp control register - - All fields are reserved except for #RTC_CTRL_WRITE_EN, - which is write-only. - */ -#define RTC_CTRL_ADDR 0xa0710008 -/** -@} */ - -/** \brief Timestamp write enable - - #RTC_CTRL_ADDR value to be written in order to unlock - writing to the timestamp registers. -*/ -#define RTC_CTRL_WRITE_EN (1 << 0) - /** \brief Get the current date/time. \ingroup rtc @@ -114,13 +72,18 @@ __BEGIN_DECLS */ time_t rtc_unix_secs(void); -/** \brief Get the current date/time. +/** \brief Set the current date/time. \ingroup rtc This function sets the current RTC value as a standard UNIX timestamp (with an epoch of January 1, 1970 00:00). This is assumed to be in the timezone of the user (as the RTC does not support timezones). + \warning + This function may fail! Since `time_t` is typically 64-bit while the RTC + uses a 32-bit timestamp (which also has a different epoch), not all + `time_t` values can be represented within the RTC! + \param time Unix timestamp to set the current time to \return 0 for success or -1 for failure diff --git a/kernel/arch/dreamcast/kernel/rtc.c b/kernel/arch/dreamcast/kernel/rtc.c index 53564b6..db83694 100644 --- a/kernel/arch/dreamcast/kernel/rtc.c +++ b/kernel/arch/dreamcast/kernel/rtc.c @@ -7,7 +7,8 @@ Copyright (C) 2023 Megavolt85 */ -/* Real-Time Clock (RTC) support +/* + Real-Time Clock (RTC) Support The functions in here return various info about the real-world time and date stored in the machine. The general process here is to retrieve @@ -28,16 +29,64 @@ #include <arch/timer.h> #include <dc/g2bus.h> #include <stdint.h> +#include <assert.h> -#define RTC_UNIX_EPOCH_DELTA 631152000 /* Twenty years in seconds */ -#define RTC_RETRY_COUNT 3 /* # of times to repeat on bad access */ +/* + High 16-bit Timestamp Value + + 32-bit register containing the upper 16-bits of + the 32-bit timestamp in seconds. Only the lower 16-bits + are valid. + + Writing to this register will lock the timestamp registers. +*/ +#define RTC_TIMESTAMP_HIGH_ADDR 0xa0710000 + +/* + Low 16-bit Timestamp Value + + 32-bit register containing the lower 16-bits of + the 32-bit timestamp in seconds. Only the lower 16-bits + are valid. +*/ +#define RTC_TIMESTAMP_LOW_ADDR 0xa0710004 + +/* + Timestamp Control Register + + All fields are reserved except for RTC_CTRL_WRITE_EN, + which is write-only. +*/ +#define RTC_CTRL_ADDR 0xa0710008 + +/* + Timestamp Write Enable + + RTC_CTRL_ADDR field to be written in order to unlock + writing to the timestamp registers. +*/ +#define RTC_CTRL_WRITE_EN (1 << 0) + +/* + Second Delta between Sega and Unix Epochs + + Twenty years in seconds. +*/ +#define RTC_UNIX_EPOCH_DELTA 631152000 + +/* + # of Read/Write Retry Attempts + + To ensure a coherent, race-free read/write operation. +*/ +#define RTC_RETRY_COUNT 3 /* The boot time; we'll save this in rtc_init() */ static time_t boot_time = 0; /* Returns the date/time value as a UNIX epoch time stamp */ time_t rtc_unix_secs(void) { - uint32 rtcold, rtcnew; + uint32_t rtcold, rtcnew; int i; /* Try several times to make sure we don't read one value, then the @@ -60,10 +109,7 @@ time_t rtc_unix_secs(void) { break; } - /* Subtract out 20 years */ - rtcnew = rtcnew - RTC_UNIX_EPOCH_DELTA; - - return rtcnew; + return rtcnew - RTC_UNIX_EPOCH_DELTA; } /* Sets the date/time value from a UNIX epoch time stamp, @@ -72,9 +118,16 @@ int rtc_set_unix_secs(time_t secs) { int result = 0; uint32_t rtcnew; int i; + uint32_t s, ms; /* Adjust by 20 years to get to the expected RTC time. */ - const uint32_t adjusted = secs + RTC_UNIX_EPOCH_DELTA; + const time_t adjusted_time = secs + RTC_UNIX_EPOCH_DELTA; + const uint32_t adjusted = (const uint32_t)adjusted_time; + + /* Protect against underflowing or overflowing our 32-bit timestamp. */ + if(adjusted_time < 0 || adjusted_time > UINT32_MAX) + return -1; + /* Enable writing by setting LSB of control */ g2_write_32(RTC_CTRL_ADDR, RTC_CTRL_WRITE_EN); @@ -94,6 +147,9 @@ int rtc_set_unix_secs(time_t secs) { break; } + /* Disable further writing by clearing LSB of control */ + g2_write_32(RTC_CTRL_ADDR, 0); + /* Signify failure if the fetched time never matched the time we attempted to set. */ if(i == RTC_RETRY_COUNT) @@ -102,9 +158,8 @@ int rtc_set_unix_secs(time_t secs) { /* We have to update the boot time now as well, subtracting the amount of time that has elapsed since boot from the new time we've just set. */ - uint32 s, ms; timer_ms_gettime(&s, &ms); - boot_time = rtcnew - RTC_UNIX_EPOCH_DELTA - s; + boot_time = ((time_t)rtcnew - RTC_UNIX_EPOCH_DELTA) - s; return result; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-12-04 04:21:04
|
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 b9b86efd2f32900f3c1725304c53d1ad462ec079 (commit) from 15ade8d666d0c167fd5a5d53fefbc7569ac05ae4 (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 b9b86efd2f32900f3c1725304c53d1ad462ec079 Author: Andy Barajas <and...@gm...> Date: Sun Dec 3 20:20:43 2023 -0800 Comment out line that was cause no video on non vga setups (#402) ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c index ebc59ad..72f8e9c 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c @@ -188,7 +188,7 @@ int pvr_init(pvr_init_params_t *params) { PVR_SET(PVR_TEXTURE_MODULO, 0x00000000); /* stride width */ PVR_SET(PVR_FOG_DENSITY, 0x0000ff07); /* fog density */ PVR_SET(PVR_HPOS_IRQ, PVR_GET(PVR_BORDER_X) << 16); /* HBLANK settings (fire on line 0 at the start of the line) */ - PVR_SET(PVR_VPOS_IRQ, PVR_GET(PVR_BORDER_Y)); /* VBLANK settings (VBLANK begin at start, VBLANK end at end) */ + //PVR_SET(PVR_VPOS_IRQ, PVR_GET(PVR_BORDER_Y)); /* VBLANK settings (VBLANK begin at start, VBLANK end at end) */ PVR_SET(PVR_UNK_0118, 0x00008040); /* M */ /* Initialize PVR DMA */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-12-04 04:01:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 15ade8d666d0c167fd5a5d53fefbc7569ac05ae4 (commit) via 5f74069609be239f356be7b38dfff54d493ada07 (commit) from a644e345e6f3ff226afec097296f5f7b79698fc2 (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 15ade8d666d0c167fd5a5d53fefbc7569ac05ae4 Author: Falco Girgis <gyr...@gm...> Date: Sun Dec 3 21:52:34 2023 -0600 Added link to Source Code to Doxygen Navigator Bar (#395) * Added link to Source Code to Doxygen Navigator Bar - Required redoing the heading levels in the main README.md to bump everything up by 1 - Added pages/DoxygenLayout.xml with a link to the GitHub commit 5f74069609be239f356be7b38dfff54d493ada07 Author: Falco Girgis <gyr...@gm...> Date: Sun Dec 3 21:47:00 2023 -0600 Revert "Thread Switch copy speed up" (#398) * Revert "Thread Switch copy speed up" * Update thread.h Removed redundant <stdint.h> include. ----------------------------------------------------------------------- Summary of changes: README.md | 22 +- doc/Doxyfile | 2 +- doc/pages/DoxygenLayout.xml | 241 +++++++++++++ kernel/arch/dreamcast/include/arch/irq.h | 34 +- kernel/arch/dreamcast/kernel/entry.s | 581 ++++++++++++++++--------------- kernel/arch/dreamcast/kernel/irq.c | 18 +- kernel/arch/dreamcast/kernel/thdswitch.s | 169 ++++----- 7 files changed, 672 insertions(+), 395 deletions(-) create mode 100644 doc/pages/DoxygenLayout.xml diff --git a/README.md b/README.md index 64d7106..2eeac26 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ <!-- PROJECT LOGO --> <br /> <div align="center"> - <h1 align="center">KallistiOS</h1> + <h1 align="center"><strong>KallistiOS</strong></h1> <p align="center"> Independent SDK for the Sega Dreamcast @@ -11,7 +11,7 @@ </p> </div> -## Overview +# Overview KOS is an unofficial development kit for the SEGA Dreamcast game console with some support for the NAOMI and NAOMI 2 arcade boards. @@ -19,15 +19,15 @@ KOS was developed from scratch over the internet by a group of free software dev Despite the console's age, KOS offers an extremely modern, programmer-friendly development environment. Using the latest GCC toolchain, it supports the entirety of C17 and C++20 including their standard libraries, along with support for portions of C23, C++23, Objective-C, and various POSIX APIs. Additionally, KOS-ports offers a rich set of add-on libraries such as SDL, OpenGL, OpenAL, and Lua for the platform. -## Features -### Core Functionality +# Features +## Core Functionality * Concurrency with Kernel Threads, C11 Threads, C++11 `std::thread`, POSIX threads * Virtual Filesystem Abstraction * IPv4/IPv6 Network Stack * Dynamically Loaded Libraries and Modules * GDB Debugger Support -### Dreamcast Hardware Support +## Dreamcast Hardware Support * GD-ROM Optical Drive * Low-level 3D PowerVR Graphics * SH4 ASM-Optimized Math Routines @@ -41,7 +41,7 @@ Despite the console's age, KOS offers an extremely modern, programmer-friendly d * MMU Management * BIOS Font Rendering -### Peripherals and Accessory Support +## Peripherals and Accessory Support * Controller, ASCII Pad * Arcade Stick, Twin Stick, Mission Stick * Keyboard @@ -61,15 +61,15 @@ Despite the console's age, KOS offers an extremely modern, programmer-friendly d * VGA Adapter * SD Card Reader -### Hardware Modification Support +## Hardware Modification Support * IDE Hard Drive * 32MB RAM Upgrade * Custom BIOS Flashroms -## Getting Started +# Getting Started A beginner's guide to development for the Sega Dreamcast along with detailed instructions for installing KOS and the required toolchains can be found on the [Dreamcast Wiki](https://dreamcast.wiki/Getting_Started_with_Dreamcast_development). Additional documentation can be found in the docs folder. -## Examples +# Examples Once you've set up the environment and are ready to begin developing, a good place to start learning is the examples directory, which provides demos for the various KOS APIs and for interacting with the Dreamcast's hardware. Examples include: - Hello World - Console Input/Output @@ -95,9 +95,9 @@ Once you've set up the environment and are ready to begin developing, a good pla - Testing 32MB RAM hardware mod - Interactive Lua interpreter terminal -## Resources -[DCEmulation Forums](http://dcemulation.org/phpBB/viewforum.php?f=29): Goldmine of Dreamcast development information and history +# Resources [Dreamcast Wiki](http://dreamcast.wiki): Large collection of tutorials and articles for beginners [Simulant Discord Chat](https://discord.gg/bpDZHT78PA): Home to the official Discord channel of KOS +[DCEmulation Forums](http://dcemulation.org/phpBB/viewforum.php?f=29): Goldmine of Dreamcast development information and history IRC Channel: irc.libera.chat `#dreamcastdev` diff --git a/doc/Doxyfile b/doc/Doxyfile index 21baf29..2f7c77a 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -786,7 +786,7 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = pages/DoxygenLayout.xml # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib diff --git a/doc/pages/DoxygenLayout.xml b/doc/pages/DoxygenLayout.xml new file mode 100644 index 0000000..5421b63 --- /dev/null +++ b/doc/pages/DoxygenLayout.xml @@ -0,0 +1,241 @@ +<doxygenlayout version="1.0"> + <!-- Generated by doxygen 1.9.7 --> + <!-- Navigation index tabs for HTML output --> + <navindex> + <tab type="mainpage" visible="yes" title=""/> + <tab type="user" url="https://github.com/KallistiOS/KallistiOS" title="Source Code"/> + <tab type="pages" visible="yes" title="" intro=""/> + <tab type="modules" visible="yes" title="Topics" intro=""/> + <tab type="namespaces" visible="yes" title=""> + <tab type="namespacelist" visible="yes" title="" intro=""/> + <tab type="namespacemembers" visible="yes" title="" intro=""/> + </tab> + <tab type="concepts" visible="yes" title=""> + </tab> + <tab type="interfaces" visible="yes" title=""> + <tab type="interfacelist" visible="yes" title="" intro=""/> + <tab type="interfaceindex" visible="$ALPHABETICAL_INDEX" title=""/> + <tab type="interfacehierarchy" visible="yes" title="" intro=""/> + </tab> + <tab type="classes" visible="yes" title=""> + <tab type="classlist" visible="yes" title="" intro=""/> + <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> + <tab type="hierarchy" visible="yes" title="" intro=""/> + <tab type="classmembers" visible="yes" title="" intro=""/> + </tab> + <tab type="structs" visible="yes" title=""> + <tab type="structlist" visible="yes" title="" intro=""/> + <tab type="structindex" visible="$ALPHABETICAL_INDEX" title=""/> + </tab> + <tab type="exceptions" visible="yes" title=""> + <tab type="exceptionlist" visible="yes" title="" intro=""/> + <tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/> + <tab type="exceptionhierarchy" visible="yes" title="" intro=""/> + </tab> + <tab type="files" visible="yes" title=""> + <tab type="filelist" visible="yes" title="" intro=""/> + <tab type="globals" visible="yes" title="" intro=""/> + </tab> + <tab type="examples" visible="yes" title="" intro=""/> + </navindex> + + <!-- Layout definition for a class page --> + <class> + <briefdescription visible="yes"/> + <includes visible="$SHOW_HEADERFILE"/> + <inheritancegraph visible="$CLASS_GRAPH"/> + <collaborationgraph visible="$COLLABORATION_GRAPH"/> + <memberdecl> + <nestedclasses visible="yes" title=""/> + <publictypes title=""/> + <services title=""/> + <interfaces title=""/> + <publicslots title=""/> + <signals title=""/> + <publicmethods title=""/> + <publicstaticmethods title=""/> + <publicattributes title=""/> + <publicstaticattributes title=""/> + <protectedtypes title=""/> + <protectedslots title=""/> + <protectedmethods title=""/> + <protectedstaticmethods title=""/> + <protectedattributes title=""/> + <protectedstaticattributes title=""/> + <packagetypes title=""/> + <packagemethods title=""/> + <packagestaticmethods title=""/> + <packageattributes title=""/> + <packagestaticattributes title=""/> + <properties title=""/> + <events title=""/> + <privatetypes title=""/> + <privateslots title=""/> + <privatemethods title=""/> + <privatestaticmethods title=""/> + <privateattributes title=""/> + <privatestaticattributes title=""/> + <friends title=""/> + <related title="" subtitle=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <inlineclasses title=""/> + <typedefs title=""/> + <enums title=""/> + <services title=""/> + <interfaces title=""/> + <constructors title=""/> + <functions title=""/> + <related title=""/> + <variables title=""/> + <properties title=""/> + <events title=""/> + </memberdef> + <allmemberslink visible="yes"/> + <usedfiles visible="$SHOW_USED_FILES"/> + <authorsection visible="yes"/> + </class> + + <!-- Layout definition for a namespace page --> + <namespace> + <briefdescription visible="yes"/> + <memberdecl> + <nestednamespaces visible="yes" title=""/> + <constantgroups visible="yes" title=""/> + <interfaces visible="yes" title=""/> + <classes visible="yes" title=""/> + <concepts visible="yes" title=""/> + <structs visible="yes" title=""/> + <exceptions visible="yes" title=""/> + <typedefs title=""/> + <sequences title=""/> + <dictionaries title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <inlineclasses title=""/> + <typedefs title=""/> + <sequences title=""/> + <dictionaries title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + </memberdef> + <authorsection visible="yes"/> + </namespace> + + <!-- Layout definition for a concept page --> + <concept> + <briefdescription visible="yes"/> + <includes visible="$SHOW_HEADERFILE"/> + <definition visible="yes" title=""/> + <detaileddescription title=""/> + <authorsection visible="yes"/> + </concept> + + <!-- Layout definition for a file page --> + <file> + <briefdescription visible="yes"/> + <includes visible="$SHOW_INCLUDE_FILES"/> + <includegraph visible="$INCLUDE_GRAPH"/> + <includedbygraph visible="$INCLUDED_BY_GRAPH"/> + <sourcelink visible="yes"/> + <memberdecl> + <interfaces visible="yes" title=""/> + <classes visible="yes" title=""/> + <structs visible="yes" title=""/> + <exceptions visible="yes" title=""/> + <namespaces visible="yes" title=""/> + <concepts visible="yes" title=""/> + <constantgroups visible="yes" title=""/> + <defines title=""/> + <typedefs title=""/> + <sequences title=""/> + <dictionaries title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <inlineclasses title=""/> + <defines title=""/> + <typedefs title=""/> + <sequences title=""/> + <dictionaries title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + </memberdef> + <authorsection/> + </file> + + <!-- Layout definition for a group page --> + <group> + <briefdescription visible="yes"/> + <groupgraph visible="$GROUP_GRAPHS"/> + <memberdecl> + <nestedgroups visible="yes" title=""/> + <dirs visible="yes" title=""/> + <files visible="yes" title=""/> + <namespaces visible="yes" title=""/> + <concepts visible="yes" title=""/> + <classes visible="yes" title=""/> + <defines title=""/> + <typedefs title=""/> + <sequences title=""/> + <dictionaries title=""/> + <enums title=""/> + <enumvalues title=""/> + <functions title=""/> + <variables title=""/> + <signals title=""/> + <publicslots title=""/> + <protectedslots title=""/> + <privateslots title=""/> + <events title=""/> + <properties title=""/> + <friends title=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <pagedocs/> + <inlineclasses title=""/> + <defines title=""/> + <typedefs title=""/> + <sequences title=""/> + <dictionaries title=""/> + <enums title=""/> + <enumvalues title=""/> + <functions title=""/> + <variables title=""/> + <signals title=""/> + <publicslots title=""/> + <protectedslots title=""/> + <privateslots title=""/> + <events title=""/> + <properties title=""/> + <friends title=""/> + </memberdef> + <authorsection visible="yes"/> + </group> + + <!-- Layout definition for a directory page --> + <directory> + <briefdescription visible="yes"/> + <directorygraph visible="yes"/> + <memberdecl> + <dirs visible="yes"/> + <files visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + </directory> +</doxygenlayout> diff --git a/kernel/arch/dreamcast/include/arch/irq.h b/kernel/arch/dreamcast/include/arch/irq.h index 2f782ee..de70c60 100644 --- a/kernel/arch/dreamcast/include/arch/irq.h +++ b/kernel/arch/dreamcast/include/arch/irq.h @@ -20,7 +20,6 @@ #ifndef __ARCH_IRQ_H #define __ARCH_IRQ_H -#include <stdint.h> #include <sys/cdefs.h> __BEGIN_DECLS @@ -45,20 +44,19 @@ __BEGIN_DECLS \headerfile arch/irq.h */ typedef struct irq_context { - uint32_t r[16]; /**< \brief 16 general purpose (integer) registers */ - uint32_t pc; /**< \brief Program counter */ - uint32_t pr; /**< \brief Procedure register (aka return address) */ - uint32_t gbr; /**< \brief Global base register */ - uint32_t vbr; /**< \brief Vector base register */ - uint32_t mach; /**< \brief Multiply-and-accumulate register (high) */ - uint32_t macl; /**< \brief Multiply-and-accumulate register (low) */ - uint32_t sr; /**< \brief Status register */ - uint32_t fpul; /**< \brief Floating-point communication register */ - uint32_t frbank[16]; /**< \brief Secondary floating poing registers */ - uint32_t fr[16]; /**< \brief Primary floating point registers */ - uint32_t fpscr; /**< \brief Floating-point status/control register */ - uint8_t padding[28]; /**< \brief Padding to make the struct size 256 bytes */ -} irq_context_t __attribute((aligned(32))); + uint32 r[16]; /**< \brief 16 general purpose (integer) registers */ + uint32 pc; /**< \brief Program counter */ + uint32 pr; /**< \brief Procedure register (aka return address) */ + uint32 gbr; /**< \brief Global base register */ + uint32 vbr; /**< \brief Vector base register */ + uint32 mach; /**< \brief Multiply-and-accumulate register (high) */ + uint32 macl; /**< \brief Multiply-and-accumulate register (low) */ + uint32 sr; /**< \brief Status register */ + uint32 frbank[16]; /**< \brief Secondary floating poing registers */ + uint32 fr[16]; /**< \brief Primary floating point registers */ + uint32 fpscr; /**< \brief Floating-point status/control register */ + uint32 fpul; /**< \brief Floatint-point communication register */ +} irq_context_t; /* A couple of architecture independent access macros */ /** \brief Fetch the program counter from an irq_context_t. @@ -234,7 +232,7 @@ typedef struct irq_context { #define TIMER_IRQ EXC_TMU0_TUNI0 /** \brief The type of an interrupt identifier */ -typedef uint32_t irq_t; +typedef uint32 irq_t; /** \brief The type of an IRQ handler \param source The IRQ that caused the handler to be called. @@ -332,8 +330,8 @@ irq_context_t *irq_get_context(void); to the architecture maximum. \param usermode 1 to run the routine in user mode, 0 for supervisor. */ -void irq_create_context(irq_context_t *context, uint32_t stack_pointer, - uint32_t routine, uint32_t *args, int usermode); +void irq_create_context(irq_context_t *context, uint32 stack_pointer, + uint32 routine, uint32 *args, int usermode); /* Enable/Disable interrupts */ /** \brief Disable interrupts. diff --git a/kernel/arch/dreamcast/kernel/entry.s b/kernel/arch/dreamcast/kernel/entry.s index ddf330b..5624fb6 100644 --- a/kernel/arch/dreamcast/kernel/entry.s +++ b/kernel/arch/dreamcast/kernel/entry.s @@ -1,8 +1,7 @@ ! KallistiOS ##version## ! ! arch/dreamcast/kernel/entry.s -! Copyright (C) 2003 Megan Potter -! Copyright (C) 2023 Colton Pawielski +! (c)2000-2001 Megan Potter ! ! Assembler code for entry and exit to/from the kernel via exceptions ! @@ -15,12 +14,12 @@ ! for a context switcher (or especially a timer! =) but it can ! be optimized later. - .text - .align 2 - .globl _irq_srt_addr - .globl _irq_handle_exception - .globl _irq_save_regs - .globl _irq_force_return + .text + .align 2 + .globl _irq_srt_addr + .globl _irq_handle_exception + .globl _irq_save_regs + .globl _irq_force_return ! Static kernel-mode stack; we can get away with this because in our ! tiny microkernel, only one thread will ever actually be sitting inside @@ -30,170 +29,200 @@ ! mis-mapped user-mode stack pointers, etc. It also opens the door for ! hard real-time interrupts and exceptions that interrupt the kernel ! itself. - .space 4096 ! One page + .space 4096 ! One page krn_stack: ! All exception vectors lead to Rome (i.e., this label). - .align 2 _irq_save_regs: ! On the SH4, an exception triggers a toggle of RB in SR. So all ! the R0-R7 registers were convienently saved for us. - mov.l _irq_srt_addr, r0 ! Grab the location of the reg store - add #0x20, r0 ! Start at the top of the BANK regs - stc.l r7_bank, @-r0 ! Save R7 - stc.l r6_bank, @-r0 ! Save R6 - stc.l r5_bank, @-r0 ! Save R5 - stc.l r4_bank, @-r0 ! Save R4 - stc.l r3_bank, @-r0 ! Save R3 - stc.l r2_bank, @-r0 ! Save R2 - stc.l r1_bank, @-r0 ! Save R1 - stc.l r0_bank, @-r0 ! Save R0 - - mov.l r8,@(0x20,r0) ! save R8 - mov.l r9,@(0x24,r0) ! save R9 - mov.l r10,@(0x28,r0) ! save R10 - mov.l r11,@(0x2c,r0) ! save R11 - mov.l r12,@(0x30,r0) ! save R12 - mov.l r13,@(0x34,r0) ! save R13 - mov.l r14,@(0x38,r0) ! save R14 - mov.l r15,@(0x3c,r0) ! save R15 (SP) - add #0x5c, r0 ! readjust register pointer - stc.l ssr, @-r0 ! save SSR 0x58 - sts.l macl, @-r0 ! save MACL 0x54 - sts.l mach, @-r0 ! save MACH 0x50 - stc.l vbr, @-r0 ! save VBR 0x4c - stc.l gbr, @-r0 ! save GBR 0x48 - sts.l pr, @-r0 ! save PR 0x44 - stc.l spc, @-r0 ! save PC 0x40 - - add #0xA4, r0 ! readjust register pointer - sts.l fpscr, @-r0 ! save FPSCR 0xdc - mov #0, r2 ! Set known FP flags - lds r2, fpscr - fschg ! Switch to pair FP moves - fmov.d dr14, @-r0 ! save FR14 & FR15 - fmov.d dr12, @-r0 ! save FR12 & FR13 - fmov.d dr10, @-r0 ! save FR10 & FR11 - fmov.d dr8, @-r0 ! save FR8 & FR9 - fmov.d dr6, @-r0 ! save FR6 & FR7 - fmov.d dr4, @-r0 ! save FR4 & FR5 - fmov.d dr2, @-r0 ! save FR2 & FR3 - fmov.d dr0, @-r0 ! save FR0 & FR1 - frchg ! Second FP bank - fmov.d dr14, @-r0 ! save FR14 & FR15 - fmov.d dr12, @-r0 ! save FR12 & FR13 - fmov.d dr10, @-r0 ! save FR10 & FR11 - fmov.d dr8, @-r0 ! save FR8 & FR9 - fmov.d dr6, @-r0 ! save FR6 & FR7 - fmov.d dr4, @-r0 ! save FR4 & FR5 - fmov.d dr2, @-r0 ! save FR2 & FR3 ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-12-04 03:18: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 a644e345e6f3ff226afec097296f5f7b79698fc2 (commit) from 70337bb739622aa55556972848cd84af3e7de28a (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 a644e345e6f3ff226afec097296f5f7b79698fc2 Author: darcagn <da...@pr...> Date: Sun Dec 3 21:17:57 2023 -0600 Update dc-chain configs to build new GDB 14.1 (#400) ----------------------------------------------------------------------- Summary of changes: utils/dc-chain/config/config.mk.10.5.0.sample | 2 +- utils/dc-chain/config/config.mk.11.4.0.sample | 2 +- utils/dc-chain/config/config.mk.12.3.0.sample | 2 +- utils/dc-chain/config/config.mk.devel.sample | 2 +- utils/dc-chain/config/config.mk.stable.sample | 2 +- utils/dc-chain/config/config.mk.winxp-latest.sample | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/dc-chain/config/config.mk.10.5.0.sample b/utils/dc-chain/config/config.mk.10.5.0.sample index 3ceb19c..d7a7d92 100644 --- a/utils/dc-chain/config/config.mk.10.5.0.sample +++ b/utils/dc-chain/config/config.mk.10.5.0.sample @@ -9,7 +9,7 @@ sh_binutils_ver=2.41 sh_gcc_ver=10.5.0 newlib_ver=4.3.0.20230120 -gdb_ver=13.2 +gdb_ver=14.1 # Tarball extensions to download for SH sh_binutils_download_type=xz diff --git a/utils/dc-chain/config/config.mk.11.4.0.sample b/utils/dc-chain/config/config.mk.11.4.0.sample index d4458e6..0356da1 100644 --- a/utils/dc-chain/config/config.mk.11.4.0.sample +++ b/utils/dc-chain/config/config.mk.11.4.0.sample @@ -9,7 +9,7 @@ sh_binutils_ver=2.41 sh_gcc_ver=11.4.0 newlib_ver=4.3.0.20230120 -gdb_ver=13.2 +gdb_ver=14.1 # Tarball extensions to download for SH sh_binutils_download_type=xz diff --git a/utils/dc-chain/config/config.mk.12.3.0.sample b/utils/dc-chain/config/config.mk.12.3.0.sample index 2840d3b..77bd92f 100644 --- a/utils/dc-chain/config/config.mk.12.3.0.sample +++ b/utils/dc-chain/config/config.mk.12.3.0.sample @@ -9,7 +9,7 @@ sh_binutils_ver=2.41 sh_gcc_ver=12.3.0 newlib_ver=4.3.0.20230120 -gdb_ver=13.2 +gdb_ver=14.1 # Tarball extensions to download for SH sh_binutils_download_type=xz diff --git a/utils/dc-chain/config/config.mk.devel.sample b/utils/dc-chain/config/config.mk.devel.sample index 7400930..1693c87 100644 --- a/utils/dc-chain/config/config.mk.devel.sample +++ b/utils/dc-chain/config/config.mk.devel.sample @@ -16,7 +16,7 @@ sh_binutils_ver=2.41 sh_gcc_ver=devel newlib_ver=4.3.0.20230120 -gdb_ver=13.2 +gdb_ver=14.1 # Tarball extensions to download for SH sh_binutils_download_type=xz diff --git a/utils/dc-chain/config/config.mk.stable.sample b/utils/dc-chain/config/config.mk.stable.sample index 2541df1..28a5ec2 100644 --- a/utils/dc-chain/config/config.mk.stable.sample +++ b/utils/dc-chain/config/config.mk.stable.sample @@ -9,7 +9,7 @@ sh_binutils_ver=2.41 sh_gcc_ver=13.2.0 newlib_ver=4.3.0.20230120 -gdb_ver=13.2 +gdb_ver=14.1 # Tarball extensions to download for SH sh_binutils_download_type=xz diff --git a/utils/dc-chain/config/config.mk.winxp-latest.sample b/utils/dc-chain/config/config.mk.winxp-latest.sample index 5d0d6cc..8f4f603 100644 --- a/utils/dc-chain/config/config.mk.winxp-latest.sample +++ b/utils/dc-chain/config/config.mk.winxp-latest.sample @@ -9,7 +9,7 @@ sh_binutils_ver=2.34 sh_gcc_ver=9.5.0 newlib_ver=4.3.0.20230120 -gdb_ver=13.2 +gdb_ver=14.1 # Tarball extensions to download for SH sh_binutils_download_type=xz hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-12-01 20:17:37
|
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 70337bb739622aa55556972848cd84af3e7de28a (commit) via 364b9c880c4b65627de9b5cba7b2cf12ca9e3e6d (commit) via ab08bdd386250c3a7f53705bd8b27a8cb9ebc0e7 (commit) via 760c20121cdfcb7dcded3d6012323792b12fba85 (commit) via 5a04eaf7a9260ba8a955ddf8b4116aa5281e73e5 (commit) via b430a7017c3b05197363dfaa11b1ed1ee9fd5cf2 (commit) via 43b9712f7c067466a003d2353c5188569271c1f3 (commit) via d9aaa493630a61f80d6f7041806c0b7b1874a1f0 (commit) via 0dad23dad59142ca4bf90e96f207171bdee2957d (commit) via ad4cedb0960b625f16002b1217b1f2aabb91da51 (commit) from 25be1fb3ae7ae6267106bac673c2297c659c8930 (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 70337bb739622aa55556972848cd84af3e7de28a Merge: 25be1fb 364b9c8 Author: Lawrence Sebald <ljs...@us...> Date: Fri Dec 1 15:14:27 2023 -0500 Merge pull request #374 from Dreamcast-Projects/thdswitch_speed * Use pair single precision data transfer * Removed unused global * Fixed bug in thdswitch. Added commented out sections * Fixed spacing and address feedback * Removed extra add * Fix spacing * Fix copyright commit 364b9c880c4b65627de9b5cba7b2cf12ca9e3e6d Author: Andress Barajas <and...@gm...> Date: Thu Nov 30 23:54:37 2023 -0800 Fix copyright commit ab08bdd386250c3a7f53705bd8b27a8cb9ebc0e7 Author: Andress Barajas <and...@gm...> Date: Thu Nov 30 23:53:52 2023 -0800 Fix spacing commit 760c20121cdfcb7dcded3d6012323792b12fba85 Author: Andress Barajas <and...@gm...> Date: Thu Nov 30 23:51:03 2023 -0800 Removed extra add commit 5a04eaf7a9260ba8a955ddf8b4116aa5281e73e5 Author: Andress Barajas <and...@gm...> Date: Thu Nov 30 23:48:56 2023 -0800 Fixed spacing and address feedback commit b430a7017c3b05197363dfaa11b1ed1ee9fd5cf2 Merge: 43b9712 6ffd6a1 Author: Andy Barajas <and...@gm...> Date: Sun Nov 26 15:08:47 2023 -0800 Merge branch 'KallistiOS:master' into thdswitch_speed commit 43b9712f7c067466a003d2353c5188569271c1f3 Merge: d9aaa49 8b11983 Author: Andy Barajas <and...@gm...> Date: Sun Nov 26 09:04:28 2023 -0800 Merge branch 'KallistiOS:master' into thdswitch_speed commit d9aaa493630a61f80d6f7041806c0b7b1874a1f0 Author: Andress Barajas <and...@gm...> Date: Wed Nov 22 14:13:51 2023 -0800 Fixed bug in thdswitch. Added commented out sections commit 0dad23dad59142ca4bf90e96f207171bdee2957d Author: Andress Barajas <and...@gm...> Date: Wed Nov 22 10:10:07 2023 -0800 Removed unused global commit ad4cedb0960b625f16002b1217b1f2aabb91da51 Author: Andress Barajas <and...@gm...> Date: Wed Nov 22 10:01:13 2023 -0800 Use pair single precision data transfer ----------------------------------------------------------------------- Summary of changes: include/kos/thread.h | 2 - kernel/arch/dreamcast/include/arch/irq.h | 34 +- kernel/arch/dreamcast/kernel/entry.s | 581 +++++++++++++++---------------- kernel/arch/dreamcast/kernel/irq.c | 18 +- kernel/arch/dreamcast/kernel/thdswitch.s | 169 +++++---- 5 files changed, 383 insertions(+), 421 deletions(-) diff --git a/include/kos/thread.h b/include/kos/thread.h index c00b4ab..cf353e2 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -19,8 +19,6 @@ __BEGIN_DECLS #include <sys/reent.h> #include <stdint.h> -#include <stdint.h> - /** \file kos/thread.h \brief Threading support. \ingroup kthreads diff --git a/kernel/arch/dreamcast/include/arch/irq.h b/kernel/arch/dreamcast/include/arch/irq.h index de70c60..2f782ee 100644 --- a/kernel/arch/dreamcast/include/arch/irq.h +++ b/kernel/arch/dreamcast/include/arch/irq.h @@ -20,6 +20,7 @@ #ifndef __ARCH_IRQ_H #define __ARCH_IRQ_H +#include <stdint.h> #include <sys/cdefs.h> __BEGIN_DECLS @@ -44,19 +45,20 @@ __BEGIN_DECLS \headerfile arch/irq.h */ typedef struct irq_context { - uint32 r[16]; /**< \brief 16 general purpose (integer) registers */ - uint32 pc; /**< \brief Program counter */ - uint32 pr; /**< \brief Procedure register (aka return address) */ - uint32 gbr; /**< \brief Global base register */ - uint32 vbr; /**< \brief Vector base register */ - uint32 mach; /**< \brief Multiply-and-accumulate register (high) */ - uint32 macl; /**< \brief Multiply-and-accumulate register (low) */ - uint32 sr; /**< \brief Status register */ - uint32 frbank[16]; /**< \brief Secondary floating poing registers */ - uint32 fr[16]; /**< \brief Primary floating point registers */ - uint32 fpscr; /**< \brief Floating-point status/control register */ - uint32 fpul; /**< \brief Floatint-point communication register */ -} irq_context_t; + uint32_t r[16]; /**< \brief 16 general purpose (integer) registers */ + uint32_t pc; /**< \brief Program counter */ + uint32_t pr; /**< \brief Procedure register (aka return address) */ + uint32_t gbr; /**< \brief Global base register */ + uint32_t vbr; /**< \brief Vector base register */ + uint32_t mach; /**< \brief Multiply-and-accumulate register (high) */ + uint32_t macl; /**< \brief Multiply-and-accumulate register (low) */ + uint32_t sr; /**< \brief Status register */ + uint32_t fpul; /**< \brief Floating-point communication register */ + uint32_t frbank[16]; /**< \brief Secondary floating poing registers */ + uint32_t fr[16]; /**< \brief Primary floating point registers */ + uint32_t fpscr; /**< \brief Floating-point status/control register */ + uint8_t padding[28]; /**< \brief Padding to make the struct size 256 bytes */ +} irq_context_t __attribute((aligned(32))); /* A couple of architecture independent access macros */ /** \brief Fetch the program counter from an irq_context_t. @@ -232,7 +234,7 @@ typedef struct irq_context { #define TIMER_IRQ EXC_TMU0_TUNI0 /** \brief The type of an interrupt identifier */ -typedef uint32 irq_t; +typedef uint32_t irq_t; /** \brief The type of an IRQ handler \param source The IRQ that caused the handler to be called. @@ -330,8 +332,8 @@ irq_context_t *irq_get_context(void); to the architecture maximum. \param usermode 1 to run the routine in user mode, 0 for supervisor. */ -void irq_create_context(irq_context_t *context, uint32 stack_pointer, - uint32 routine, uint32 *args, int usermode); +void irq_create_context(irq_context_t *context, uint32_t stack_pointer, + uint32_t routine, uint32_t *args, int usermode); /* Enable/Disable interrupts */ /** \brief Disable interrupts. diff --git a/kernel/arch/dreamcast/kernel/entry.s b/kernel/arch/dreamcast/kernel/entry.s index 5624fb6..ddf330b 100644 --- a/kernel/arch/dreamcast/kernel/entry.s +++ b/kernel/arch/dreamcast/kernel/entry.s @@ -1,7 +1,8 @@ ! KallistiOS ##version## ! ! arch/dreamcast/kernel/entry.s -! (c)2000-2001 Megan Potter +! Copyright (C) 2003 Megan Potter +! Copyright (C) 2023 Colton Pawielski ! ! Assembler code for entry and exit to/from the kernel via exceptions ! @@ -14,12 +15,12 @@ ! for a context switcher (or especially a timer! =) but it can ! be optimized later. - .text - .align 2 - .globl _irq_srt_addr - .globl _irq_handle_exception - .globl _irq_save_regs - .globl _irq_force_return + .text + .align 2 + .globl _irq_srt_addr + .globl _irq_handle_exception + .globl _irq_save_regs + .globl _irq_force_return ! Static kernel-mode stack; we can get away with this because in our ! tiny microkernel, only one thread will ever actually be sitting inside @@ -29,200 +30,170 @@ ! mis-mapped user-mode stack pointers, etc. It also opens the door for ! hard real-time interrupts and exceptions that interrupt the kernel ! itself. - .space 4096 ! One page + .space 4096 ! One page krn_stack: ! All exception vectors lead to Rome (i.e., this label). + .align 2 _irq_save_regs: ! On the SH4, an exception triggers a toggle of RB in SR. So all ! the R0-R7 registers were convienently saved for us. - mov.l _irq_srt_addr,r0 ! Grab the location of the reg store - add #0x20,r0 ! Start at the top of the BANK regs - stc.l r7_bank,@-r0 ! Save R7 - stc.l r6_bank,@-r0 ! Save R6 - stc.l r5_bank,@-r0 ! Save R5 - stc.l r4_bank,@-r0 ! Save R4 - stc.l r3_bank,@-r0 ! Save R3 - stc.l r2_bank,@-r0 ! Save R2 - stc.l r1_bank,@-r0 ! Save R1 - stc.l r0_bank,@-r0 ! Save R0 - - mov.l r8,@(0x20,r0) ! save R8 - mov.l r9,@(0x24,r0) ! save R9 - mov.l r10,@(0x28,r0) ! save R10 - mov.l r11,@(0x2c,r0) ! save R11 - mov.l r12,@(0x30,r0) ! save R12 - mov.l r13,@(0x34,r0) ! save R13 - mov.l r14,@(0x38,r0) ! save R14 - mov.l r15,@(0x3c,r0) ! save R15 (SP) - add #0x5c,r0 ! readjust register pointer - stc.l ssr,@-r0 ! save SSR 0x58 - sts.l macl,@-r0 ! save MACL 0x54 - sts.l mach,@-r0 ! save MACH 0x50 - stc.l vbr,@-r0 ! save VBR 0x4c - stc.l gbr,@-r0 ! save GBR 0x48 - sts.l pr,@-r0 ! save PR 0x44 - stc.l spc,@-r0 ! save PC 0x40 - - add #0x60,r0 ! readjust register pointer - add #0x44,r0 - sts.l fpul,@-r0 ! save FPUL 0xe0 - sts.l fpscr,@-r0 ! save FPSCR 0xdc - mov #0,r2 ! Set known FP flags - lds r2,fpscr - fmov.s fr15,@-r0 ! save FR15 0xd8 - fmov.s fr14,@-r0 ! save FR14 - fmov.s fr13,@-r0 ! save FR13 - fmov.s fr12,@-r0 ! save FR12 - fmov.s fr11,@-r0 ! save FR11 - fmov.s fr10,@-r0 ! save FR10 - fmov.s fr9,@-r0 ! save FR9 - fmov.s fr8,@-r0 ! save FR8 - fmov.s fr7,@-r0 ! save FR7 - fmov.s fr6,@-r0 ! save FR6 - fmov.s fr5,@-r0 ! save FR5 - fmov.s fr4,@-r0 ! save FR4 - fmov.s fr3,@-r0 ! save FR3 - fmov.s fr2,@-r0 ! save FR2 - fmov.s fr1,@-r0 ! save FR1 - fmov.s fr0,@-r0 ! save FR0 0x9c - frchg ! Second FP bank - fmov.s fr15,@-r0 ! save FR15 0x98 - fmov.s fr14,@-r0 ! save FR14 - fmov.s fr13,@-r0 ! save FR13 - fmov.s fr12,@-r0 ! save FR12 - fmov.s fr11,@-r0 ! save FR11 - fmov.s fr10,@-r0 ! save FR10 - fmov.s fr9,@-r0 ! save FR9 - fmov.s fr8,@-r0 ! save FR8 - fmov.s fr7,@-r0 ! save FR7 - fmov.s fr6,@-r0 ! save FR6 - fmov.s fr5,@-r0 ! save FR5 - fmov.s fr4,@-r0 ! save FR4 - fmov.s fr3,@-r0 ! save FR3 - fmov.s fr2,@-r0 ! save FR2 - fmov.s fr1,@-r0 ! save FR1 - fmov.s fr0,@-r0 ! save FR0 0x5c - frchg ! First FP bank again - - ! Setup our kernel-mode stack - mov.l stkaddr,r15 - - ! 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 - - ! R4 still contains the exception code - mov.l hdl_except,r2 ! Call handle_exception - jsr @r2 - nop - bra _save_regs_finish - nop + mov.l _irq_srt_addr, r0 ! Grab the location of the reg store + add #0x20, r0 ! Start at the top of the BANK regs + stc.l r7_bank, @-r0 ! Save R7 + stc.l r6_bank, @-r0 ! Save R6 + stc.l r5_bank, @-r0 ! Save R5 + stc.l r4_bank, @-r0 ! Save R4 + stc.l r3_bank, @-r0 ! Save R3 + stc.l r2_bank, @-r0 ! Save R2 + stc.l r1_bank, @-r0 ! Save R1 + stc.l r0_bank, @-r0 ! Save R0 + + mov.l r8,@(0x20,r0) ! save R8 + mov.l r9,@(0x24,r0) ! save R9 + mov.l r10,@(0x28,r0) ! save R10 + mov.l r11,@(0x2c,r0) ! save R11 + mov.l r12,@(0x30,r0) ! save R12 + mov.l r13,@(0x34,r0) ! save R13 + mov.l r14,@(0x38,r0) ! save R14 + mov.l r15,@(0x3c,r0) ! save R15 (SP) + add #0x5c, r0 ! readjust register pointer + stc.l ssr, @-r0 ! save SSR 0x58 + sts.l macl, @-r0 ! save MACL 0x54 + sts.l mach, @-r0 ! save MACH 0x50 + stc.l vbr, @-r0 ! save VBR 0x4c + stc.l gbr, @-r0 ! save GBR 0x48 + sts.l pr, @-r0 ! save PR 0x44 + stc.l spc, @-r0 ! save PC 0x40 + + add #0xA4, r0 ! readjust register pointer + sts.l fpscr, @-r0 ! save FPSCR 0xdc + mov #0, r2 ! Set known FP flags + lds r2, fpscr + fschg ! Switch to pair FP moves + fmov.d dr14, @-r0 ! save FR14 & FR15 + fmov.d dr12, @-r0 ! save FR12 & FR13 + fmov.d dr10, @-r0 ! save FR10 & FR11 + fmov.d dr8, @-r0 ! save FR8 & FR9 + fmov.d dr6, @-r0 ! save FR6 & FR7 + fmov.d dr4, @-r0 ! save FR4 & FR5 + fmov.d dr2, @-r0 ! save FR2 & FR3 + fmov.d dr0, @-r0 ! save FR0 & FR1 + frchg ! Second FP bank + fmov.d dr14, @-r0 ! save FR14 & FR15 + fmov.d dr12, @-r0 ! save FR12 & FR13 + fmov.d dr10, @-r0 ! save FR10 & FR11 + fmov.d dr8, @-r0 ! save FR8 & FR9 + fmov.d dr6, @-r0 ! save FR6 & FR7 + fmov.d dr4, @-r0 ! save FR4 & FR5 + fmov.d dr2, @-r0 ! save FR2 & FR3 + fmov.d dr0, @-r0 ! save FR0 & FR1 + fschg ! Switch to single FP moves + frchg ! First FP bank again + sts.l fpul, @-r0 ! save FPUL + + ! Setup our kernel-mode stack + mov.l stkaddr, r15 + + ! 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 + + ! R4 still contains the exception code + mov.l hdl_except, r2 ! Call handle_exception + jsr @r2 + nop + bra _save_regs_finish + nop ! irq_force_return() jumps here; make sure we're in register ! bank 1 (as opposed to 0) + .align 2 _irq_force_return: - mov.l _irqfr_or,r1 - stc sr,r0 - or r1,r0 - ldc r0,sr - bra _save_regs_finish - nop - - .align 2 + mov.l _irqfr_or, r1 + stc sr, r0 + or r1, r0 + ldc r0, sr + bra _save_regs_finish + nop + + .align 2 _irqfr_or: - .long 0x20000000 + .long 0x20000000 stkaddr: - .long krn_stack + .long krn_stack ! Now restore all the registers and jump back to the thread + .align 2 _save_regs_finish: - mov.l _irq_srt_addr, r1 ! Get register store address - ldc.l @r1+,r0_bank ! restore R0 (r1 is now _irq_srt_addr+0) - ldc.l @r1+,r1_bank ! restore R1 - ldc.l @r1+,r2_bank ! restore R2 - ldc.l @r1+,r3_bank ! restore R3 - ldc.l @r1+,r4_bank ! restore R4 - ldc.l @r1+,r5_bank ! restore R5 - ldc.l @r1+,r6_bank ! restore R6 - ldc.l @r1+,r7_bank ! restore R7 - add #-32,r1 ! Go back to the front - mov.l @(0x20,r1), r8 ! restore R8 (r1 is now ...+0) - mov.l @(0x24,r1), r9 ! restore R9 - mov.l @(0x28,r1), r10 ! restore R10 - mov.l @(0x2c,r1), r11 ! restore R11 - mov.l @(0x30,r1), r12 ! restore R12 - mov.l @(0x34,r1), r13 ! restore R13 - mov.l @(0x38,r1), r14 ! restore R14 - mov.l @(0x3c,r1), r15 ! restore program's stack - - add #0x40,r1 ! jump up to status words - ldc.l @r1+,spc ! restore SPC 0x40 (r1 is now +0x40) - lds.l @r1+,pr ! restore PR 0x44 (+0x44) - ldc.l @r1+,gbr ! restore GBR 0x48 (+0x48) -! ldc.l @r1+,vbr ! restore VBR (don't play with VBR) - add #4,r1 ! (+0x4c) - lds.l @r1+,mach ! restore MACH 0x50 (+0x50) - lds.l @r1+,macl ! restore MACL 0x54 (+0x54) - ldc.l @r1+,ssr ! restore SSR 0x58 (+0x58) - - mov #0,r2 ! Set known FP flags (+0x5c) - lds r2,fpscr - frchg ! Second FP bank - fmov.s @r1+,fr0 ! restore FR0 0x5c - fmov.s @r1+,fr1 ! restore FR1 - fmov.s @r1+,fr2 ! restore FR2 - fmov.s @r1+,fr3 ! restore FR3 - fmov.s @r1+,fr4 ! restore FR4 - fmov.s @r1+,fr5 ! restore FR5 - fmov.s @r1+,fr6 ! restore FR6 - fmov.s @r1+,fr7 ! restore FR7 - fmov.s @r1+,fr8 ! restore FR8 - fmov.s @r1+,fr9 ! restore FR9 - fmov.s @r1+,fr10 ! restore FR10 - fmov.s @r1+,fr11 ! restore FR11 - fmov.s @r1+,fr12 ! restore FR12 - fmov.s @r1+,fr13 ! restore FR13 - fmov.s @r1+,fr14 ! restore FR14 - fmov.s @r1+,fr15 ! restore FR15 0x98 - frchg ! First FP bank - fmov.s @r1+,fr0 ! restore FR0 0x9c - fmov.s @r1+,fr1 ! restore FR1 - fmov.s @r1+,fr2 ! restore FR2 - fmov.s @r1+,fr3 ! restore FR3 - fmov.s @r1+,fr4 ! restore FR4 - fmov.s @r1+,fr5 ! restore FR5 - fmov.s @r1+,fr6 ! restore FR6 - fmov.s @r1+,fr7 ! restore FR7 - fmov.s @r1+,fr8 ! restore FR8 - fmov.s @r1+,fr9 ! restore FR9 - fmov.s @r1+,fr10 ! restore FR10 - fmov.s @r1+,fr11 ! restore FR11 - fmov.s @r1+,fr12 ! restore FR12 - fmov.s @r1+,fr13 ! restore FR13 - fmov.s @r1+,fr14 ! restore FR14 - fmov.s @r1+,fr15 ! restore FR15 0xd8 - lds.l @r1+,fpscr ! restore FPSCR 0xdc - lds.l @r1+,fpul ! restore FPUL 0xe0 - -! add #-0x70,r1 ! jump back to registers -! add #-0x34,r1 -! mov.l @(0,r1),r0 ! restore R0 -! mov.l @(4,r1),r1 ! restore R1 - mov #2,r0 - - rte ! return - nop - - .align 2 + mov.l _irq_srt_addr, r1 ! Get register store address + ldc.l @r1+, r0_bank ! restore R0 (r1 is now _irq_srt_addr+0) + ldc.l @r1+, r1_bank ! restore R1 + ldc.l @r1+, r2_bank ! restore R2 + ldc.l @r1+, r3_bank ! restore R3 + ldc.l @r1+, r4_bank ! restore R4 + ldc.l @r1+, r5_bank ! restore R5 + ldc.l @r1+, r6_bank ! restore R6 + ldc.l @r1+, r7_bank ! restore R7 + add #-32, r1 ! Go back to the front + mov.l @(0x20,r1), r8 ! restore R8 (r1 is now ...+0) + mov.l @(0x24,r1), r9 ! restore R9 + mov.l @(0x28,r1), r10 ! restore R10 + mov.l @(0x2c,r1), r11 ! restore R11 + mov.l @(0x30,r1), r12 ! restore R12 + mov.l @(0x34,r1), r13 ! restore R13 + mov.l @(0x38,r1), r14 ! restore R14 + mov.l @(0x3c,r1), r15 ! restore program's stack + + add #0x40, r1 ! jump up to status words + ldc.l @r1+, spc ! restore SPC 0x40 (r1 is now +0x40) + lds.l @r1+, pr ! restore PR 0x44 (+0x44) + ldc.l @r1+, gbr ! restore GBR 0x48 (+0x48) +! ldc.l @r1+, vbr ! restore VBR (don't play with VBR) + add #4, r1 ! (+0x4c) + lds.l @r1+, mach ! restore MACH 0x50 (+0x50) + lds.l @r1+, macl ! restore MACL 0x54 (+0x54) + ldc.l @r1+, ssr ! restore SSR 0x58 (+0x58) + + lds.l @r1+, fpul ! restore FPUL + mov #0, r2 ! Set known FP flags (+0x5c) + lds r2, fpscr + frchg ! Second FP bank + fschg ! Switch to pair FP moves + fmov.d @r1+, dr0 ! restore FR0 & FR1 + fmov.d @r1+, dr2 ! restore FR2 & FR3 + fmov.d @r1+, dr4 ! restore FR4 & FR5 + fmov.d @r1+, dr6 ! restore FR6 & FR7 + fmov.d @r1+, dr8 ! restore FR8 & FR9 + fmov.d @r1+, dr10 ! restore FR10 & FR11 + fmov.d @r1+, dr12 ! restore FR12 & FR13 + fmov.d @r1+, dr14 ! restore FR14 & FR15 + frchg ! First FP bank + fmov.d @r1+, dr0 ! restore FR0 & FR1 + fmov.d @r1+, dr2 ! restore FR2 & FR3 + fmov.d @r1+, dr4 ! restore FR4 & FR5 + fmov.d @r1+, dr6 ! restore FR6 & FR7 + fmov.d @r1+, dr8 ! restore FR8 & FR9 + fmov.d @r1+, dr8 ! restore FR8 & FR9 + fmov.d @r1+, dr10 ! restore FR10 & FR11 + fmov.d @r1+, dr12 ! restore FR12 & FR13 + fmov.d @r1+, dr14 ! restore FR14 & FR15 + lds.l @r1+, fpscr ! restore FPSCR 0xdc + + mov #2, r0 + + rte ! return + nop + + .align 2 _irq_srt_addr: - .long 0 ! Save Regs Table -- this is an indirection - ! so we can easily swap out pointers during a - ! context switch. + .long 0 ! Save Regs Table -- this is an indirection + ! so we can easily swap out pointers during a + ! context switch. hdl_except: - .long _irq_handle_exception + .long _irq_handle_exception ! Special case handler for TLB miss exceptions. There are two reasons @@ -238,80 +209,80 @@ hdl_except: ! !!NOTE!! This is highly dependent on the structure of the MMU tables ! in mmu.h and the MMU code in mmu.c. If either of those change, this will ! likely need to change as well. - .text - .align 2 + .text + .align 2 tlb_miss_hnd: - ! Get the exception event code; we want to handle only - ! 0x0040 (ITLB_MISS/DTLB_MISS_READ) or 0x0060 (DTLB_MISS_WRITE) - mov #-1,r3 ! 0xff000024 (EXPEVT) -> r3 - shll16 r3 - shll8 r3 - add #0x24,r3 - mov.l @r3,r0 ! Get EXPEVT + ! Get the exception event code; we want to handle only + ! 0x0040 (ITLB_MISS/DTLB_MISS_READ) or 0x0060 (DTLB_MISS_WRITE) + mov #-1, r3 ! 0xff000024 (EXPEVT) -> r3 + shll16 r3 + shll8 r3 + add #0x24, r3 + mov.l @r3, r0 ! Get EXPEVT - mov #0x40,r1 ! 0x0040 -> r1 + mov #0x40, r1 ! 0x0040 -> r1 - cmp/eq r0,r1 - bt.s tmh_doit - mov #0x60,r1 + cmp/eq r0, r1 + bt.s tmh_doit + mov #0x60, r1 - cmp/eq r0,r1 - bt tmh_doit + cmp/eq r0, r1 + bt tmh_doit - ! It's not one of the MISS codes, just send it on to the normal - ! irq processing. - bra _irq_save_regs - mov #2,r4 + ! It's not one of the MISS codes, just send it on to the normal + ! irq processing. + bra _irq_save_regs ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-30 20:03:32
|
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 25be1fb3ae7ae6267106bac673c2297c659c8930 (commit) via 594915b3dcefe438b70a3ce5688f070522381db7 (commit) via bc5d28aa769e44dcced5e0d27a7e8391d8f74e60 (commit) via 5c5a00eeaa1c26bc9d9d773ae0c380484c6899e5 (commit) from e1e1bb214155a01edafbda8e43bde747787955b0 (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 25be1fb3ae7ae6267106bac673c2297c659c8930 Merge: e1e1bb2 594915b Author: Lawrence Sebald <ljs...@us...> Date: Thu Nov 30 15:03:02 2023 -0500 Merge pull request #392 from KallistiOS/ntp_example Add network example for setting system clock via NTP commit 594915b3dcefe438b70a3ce5688f070522381db7 Author: Lawrence Sebald <ljs...@us...> Date: Thu Nov 30 15:02:05 2023 -0500 Update examples/dreamcast/network/ntp/ntp.c Fix spacing. commit bc5d28aa769e44dcced5e0d27a7e8391d8f74e60 Author: darcagn <da...@pr...> Date: Thu Nov 30 13:59:18 2023 -0600 Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> commit 5c5a00eeaa1c26bc9d9d773ae0c380484c6899e5 Author: darc <da...@pr...> Date: Wed Nov 29 14:57:18 2023 -0600 Add network example for setting system clock via NTP ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/network/Makefile | 3 + .../dreamcast/network/{udpecho6 => ntp}/Makefile | 12 +-- examples/dreamcast/network/ntp/ntp.c | 119 +++++++++++++++++++++ 3 files changed, 128 insertions(+), 6 deletions(-) copy examples/dreamcast/network/{udpecho6 => ntp}/Makefile (74%) create mode 100644 examples/dreamcast/network/ntp/ntp.c diff --git a/examples/dreamcast/network/Makefile b/examples/dreamcast/network/Makefile index ddd39b1..b9627dc 100644 --- a/examples/dreamcast/network/Makefile +++ b/examples/dreamcast/network/Makefile @@ -12,6 +12,7 @@ all: $(KOS_MAKE) -C dns-client $(KOS_MAKE) -C httpd $(KOS_MAKE) -C isp-settings + $(KOS_MAKE) -C ntp clean: $(KOS_MAKE) -C basic clean @@ -21,6 +22,7 @@ clean: $(KOS_MAKE) -C dns-client clean $(KOS_MAKE) -C httpd clean $(KOS_MAKE) -C isp-settings clean + $(KOS_MAKE) -C ntp clean dist: $(KOS_MAKE) -C basic dist @@ -30,3 +32,4 @@ dist: $(KOS_MAKE) -C dns-client dist $(KOS_MAKE) -C httpd dist $(KOS_MAKE) -C isp-settings dist + $(KOS_MAKE) -C ntp dist diff --git a/examples/dreamcast/network/udpecho6/Makefile b/examples/dreamcast/network/ntp/Makefile similarity index 74% copy from examples/dreamcast/network/udpecho6/Makefile copy to examples/dreamcast/network/ntp/Makefile index 4aa9fc6..07741d8 100644 --- a/examples/dreamcast/network/udpecho6/Makefile +++ b/examples/dreamcast/network/ntp/Makefile @@ -1,13 +1,14 @@ +# KallistiOS ##version## +# +# examples/dreamcast/network/ntp/Makefile +# Copyright (C) 2023 Eric Fradella # -# Basic KallistiOS skeleton / test program -# (c)2001 Megan Potter -# # Put the filename of the output binary here -TARGET = echo.elf +TARGET = ntp.elf # List all of your C files here, but change the extension to ".o" -OBJS = echo.o +OBJS = ntp.o all: rm-elf $(TARGET) @@ -28,4 +29,3 @@ run: $(TARGET) dist: $(TARGET) -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) - diff --git a/examples/dreamcast/network/ntp/ntp.c b/examples/dreamcast/network/ntp/ntp.c new file mode 100644 index 0000000..a706928 --- /dev/null +++ b/examples/dreamcast/network/ntp/ntp.c @@ -0,0 +1,119 @@ +/* KallistiOS ##version## + * + * ntp.c + * Copyright (C) 2023 Eric Fradella + * + * This example demonstrates how to set the Dreamcast's + * real-time clock to current UTC time via an NTP server. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <netdb.h> + +#include <arch/arch.h> +#include <arch/rtc.h> +#include <kos/dbgio.h> +#include <kos/net.h> + +#define NTP_PORT "123" +#define NTP_SERVER "us.pool.ntp.org" +#define NTP_DELTA 2208988800ULL + +#define ERR_EXIT() { thd_sleep(2000); exit(EXIT_FAILURE); } + +KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET); + +/* Structure for 48-byte NTP packet */ +typedef struct ntp_packet { + uint8_t leap_ver_mode; /* First 2 bits are leap indicator, next + three bits NTP version, last 3 bits mode */ + uint8_t stratum; + uint8_t poll_interval; + uint8_t precision; + uint32_t root_delay; + uint32_t root_dispersion; + uint32_t ref_id; + uint32_t ref_time_s; + uint32_t ref_time_f; + uint32_t orig_time_s; + uint32_t orig_time_f; + uint32_t rcv_time_s; + uint32_t rcv_time_f; + uint32_t trns_time_s; + uint32_t trns_time_f; +} ntp_packet_t; + +int main(int argc, char **argv) { + ntp_packet_t packet; + int sockfd; + struct addrinfo *ai; + time_t ntp_time, dc_time; + + /* Set the framebuffer as the output device for dbgio. */ + dbgio_dev_select("fb"); + + /* Create NTP packet and clear it */ + memset(&packet, 0, sizeof(ntp_packet_t)); + + /* Leave leap indicator blank, set version number to 4,and + set client mode to 3. 0x23 = 00 100 011 = 0, 4, 3 */ + packet.leap_ver_mode = 0x23; + + /* Create a new UDP socket */ + if((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + printf("Error opening socket!\n"); + ERR_EXIT(); + } + + /* Retrieve IP address for our specified hostname */ + if(getaddrinfo(NTP_SERVER, NTP_PORT, NULL, &ai)) { + printf("Error resolving host!\n"); + ERR_EXIT(); + } + + if(connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) { + printf("Error connecting to server!\n"); + ERR_EXIT(); + } + + freeaddrinfo(ai); + + /* Send the NTP packet we constructed */ + if(write(sockfd, &packet, sizeof(ntp_packet_t)) < 0) { + printf("Error writing to socket!\n"); + ERR_EXIT(); + } + + /* Receive the packet back from the server, + now filled out with the current time */ + if(read(sockfd, &packet, sizeof(ntp_packet_t)) < 0) { + printf("Error reading response from socket!\n"); + ERR_EXIT(); + } + + /* Grab time from the structure, and subtract 70 years to convert + from NTP's 1900 epoch to Unix time's 1970 epoch */ + ntp_time = (ntohl(packet.trns_time_s) - NTP_DELTA); + printf("The current NTP time is...\n %s\n", ctime(&ntp_time)); + + /* Print the current system time */ + dc_time = rtc_unix_secs(); + printf("Dreamcast system time is...\n %s\n", ctime(&dc_time)); + + /* Set the system time to the NTP time and read it back */ + printf("Setting Dreamcast clock's time to NTP time...\n\n"); + rtc_set_unix_secs(ntp_time); + dc_time = rtc_unix_secs(); + printf("Dreamcast system time is now...\n %s\n", ctime(&dc_time)); + + /* Wait 10 seconds for the user to see what's on the screen before we clear + it during the exit back to the loader */ + thd_sleep(10 * 1000); + + return 0; +} + hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-29 02:01: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 e1e1bb214155a01edafbda8e43bde747787955b0 (commit) via 2a1df86d7761232fb132416c52ce0fa124248b64 (commit) via 573e7ee8acd82fc99f0b9335e847cc8e4ede0635 (commit) via e844c3afc86948e6a79accc06d47c72421231f4b (commit) via b514025474dfd4914d03ec8d202f65a3f21babab (commit) from 6ffd6a1772643b0a645ee9d0a4c956eb09b133d6 (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 e1e1bb214155a01edafbda8e43bde747787955b0 Merge: 2a1df86 b514025 Author: Lawrence Sebald <ljs...@us...> Date: Tue Nov 28 20:59:25 2023 -0500 Merge pull request #383 from KallistiOS/wdt_doxygen_update Watchdog Timer Documentation Improvements commit 2a1df86d7761232fb132416c52ce0fa124248b64 Merge: 6ffd6a1 573e7ee Author: Lawrence Sebald <ljs...@us...> Date: Tue Nov 28 20:58:23 2023 -0500 Merge pull request #387 from sizious/utils-update Utils: Updating `bin2o` and `elf2bin` commit 573e7ee8acd82fc99f0b9335e847cc8e4ede0635 Author: SiZiOUS <si...@gm...> Date: Fri Nov 24 23:45:52 2023 +0100 `bin2o`: removing temporary folder after processing commit e844c3afc86948e6a79accc06d47c72421231f4b Author: SiZiOUS <si...@gm...> Date: Fri Nov 24 20:37:07 2023 +0100 `elf2bin`: updating comment inside script commit b514025474dfd4914d03ec8d202f65a3f21babab Author: Falco Girgis <gyr...@gm...> Date: Thu Nov 23 01:02:38 2023 -0600 Updated and improved Doxygen docs for WDT. - Watchdog timer documentation had a few errors within it - Watchdog timer documentation lacked a proper top-level group defined to put it in the main module index - Added a reference to the WDT from the RTC ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/arch/rtc.h | 4 ++ kernel/arch/dreamcast/include/arch/wdt.h | 104 ++++++++++++++++++++----------- utils/bin2o/bin2o | 44 +++++++++---- utils/elf2bin/elf2bin | 2 +- 4 files changed, 103 insertions(+), 51 deletions(-) diff --git a/kernel/arch/dreamcast/include/arch/rtc.h b/kernel/arch/dreamcast/include/arch/rtc.h index bb8c4ed..a68f7cf 100644 --- a/kernel/arch/dreamcast/include/arch/rtc.h +++ b/kernel/arch/dreamcast/include/arch/rtc.h @@ -15,6 +15,8 @@ standard C functions, like time(), rather than these when simply needing to fetch the current system time. + \sa arch/wdt.h + \author Megan Potter \author Falco Girgis */ @@ -53,6 +55,8 @@ __BEGIN_DECLS with an epoch of January 1, 1950 00:00. Because of this, the Dreamcast's Y2K and the last timestamp it can represent before rolling over is February 06 2086 06:28:15. + + \sa wdt */ /** \defgroup rtc_regs Registers diff --git a/kernel/arch/dreamcast/include/arch/wdt.h b/kernel/arch/dreamcast/include/arch/wdt.h index 9233305..c5d6700 100644 --- a/kernel/arch/dreamcast/include/arch/wdt.h +++ b/kernel/arch/dreamcast/include/arch/wdt.h @@ -1,14 +1,41 @@ /* KallistiOS ##version## arch/dreamcast/include/wdt.h - Copyright (c) 2023 Falco Girgis + Copyright (C) 2023 Falco Girgis */ -/** \file arch/wdt.h - \brief Watchdog Timer API +/** \file arch/wdt.h + \brief Watchdog Timer API + \ingroup wdt + + This file provides an API for configuring and utilizing the SH4's watchdog + timer as either a reset or an interval timer. + + \sa timer.h, rtc.h + + \author Falco Girgis +*/ + +#ifndef __ARCH_WDT_H +#define __ARCH_WDT_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +#include <stdint.h> + +/** \defgroup wdt Watchdog Timer + \brief Driver for using the WDT as a reset or interval timer + + The watchdog timer (WDT) is a special-purpose timer peripheral integrated + within the Dreamcast's SH4 CPU. + + \warning + At this time, there are no known emulators which are emulating the WDT, + as it was never used in commercial games; however, it works perfectly fine + on real hardware. - This file provides an API built around utilizing the SH4's watchdog timer. There are two different modes of operation which are supported: - watchdog mode: counter overflow causes a reset interrupt - interval timer mode: counter overflow invokes a callback function @@ -16,7 +43,7 @@ To start the WDT in watchdog mode, use wdt_enable_watchdog(). To use the WDT as a general-purpose interval timer, use wdt_enable_timer(). - The timer can be stopped in either mode by calling wdt_disable_timer(). + The timer can be stopped in either mode by calling wdt_disable(). \warning Once the WDT has been enabled, special care must be taken to disable it @@ -25,49 +52,46 @@ an unhandled exception (depending on which mode was used), preventing you from gracefully returning to a DC-Load session when testing. - \sa timer.h, rtc.h - - \author Falco Girgis + \sa rtc */ -#ifndef __ARCH_WDT_H -#define __ARCH_WDT_H - -#include <sys/cdefs.h> -__BEGIN_DECLS - -#include <stdint.h> - -/** \brief Clock divider settings +/** \brief Clock divider settings + \ingroup wdt Denominators used to set the frequency divider for the input clock to the WDT. */ typedef enum WDT_CLK_DIV { - WDT_CLK_DIV_32, /** \brief Period: 41us */ - WDT_CLK_DIV_64, /** \brief Period: 82us */ - WDT_CLK_DIV_128, /** \brief Period: 164us */ - WDT_CLK_DIV_256, /** \brief Period: 328us */ - WDT_CLK_DIV_512, /** \brief Period: 656us */ - WDT_CLK_DIV_1024, /** \brief Period: 1.31ms */ - WDT_CLK_DIV_2048, /** \brief Period: 2.62ms */ - WDT_CLK_DIV_4096 /** \brief Period: 5.25ms */ + WDT_CLK_DIV_32, /**< \brief Period: 41us */ + WDT_CLK_DIV_64, /**< \brief Period: 82us */ + WDT_CLK_DIV_128, /**< \brief Period: 164us */ + WDT_CLK_DIV_256, /**< \brief Period: 328us */ + WDT_CLK_DIV_512, /**< \brief Period: 656us */ + WDT_CLK_DIV_1024, /**< \brief Period: 1.31ms */ + WDT_CLK_DIV_2048, /**< \brief Period: 2.62ms */ + WDT_CLK_DIV_4096 /**< \brief Period: 5.25ms */ } WDT_CLK_DIV; -/** \brief Reset signal type - +/** \brief Reset signal type + \ingroup wdt + Specifies the kind of reset to be performed when the WDT overflows in watchdog mode. */ typedef enum WDT_RST { - WDT_RST_POWER_ON, /** \brief Power-On Reset */ - WDT_RST_MANUAL /** \brief Manual Reset */ + WDT_RST_POWER_ON, /**< \brief Power-On Reset */ + WDT_RST_MANUAL /**< \brief Manual Reset */ } WDT_RST; -/* \brief WDT interval timer callback function type */ +/* \brief WDT interval timer callback function type + \ingroup wdt + + Type of the callback function to be passed to wdt_enable_timer(). +*/ typedef void (*wdt_callback)(void *user_data); -/** \brief Enables the WDT as an interval timer +/** \brief Enables the WDT as an interval timer + \ingroup wdt Stops the WDT if it was previously running and reconfigures it to be used as a generic interval timer, calling the given callback @@ -100,7 +124,8 @@ void wdt_enable_timer(uint8_t initial_count, wdt_callback callback, void *user_data); -/** \brief Enables the WDT in watchdog mode +/** \brief Enables the WDT in watchdog mode + \ingroup wdt Stops the WDT if it was previously running and reconfigures it to be used as a typical watchdog timer, generating a resest @@ -121,7 +146,8 @@ void wdt_enable_watchdog(uint8_t initial_count, WDT_CLK_DIV clk_config, WDT_RST reset_select); -/** \brief Fetches the counter value +/** \brief Fetches the counter value + \ingroup wdt Returns the current 8-bit value of the WDT counter. @@ -131,7 +157,8 @@ void wdt_enable_watchdog(uint8_t initial_count, */ uint8_t wdt_get_counter(void); -/** \brief Sets the counter value +/** \brief Sets the counter value + \ingroup wdt Sets the current 8-bit value of the WDT counter. @@ -141,7 +168,8 @@ uint8_t wdt_get_counter(void); */ void wdt_set_counter(uint8_t value); -/** \brief Resets the counter value +/** \brief Resets the counter value + \ingroup wdt "Petting" or "kicking" the WDT is the same thing as resetting its counter value to 0. @@ -150,7 +178,8 @@ void wdt_set_counter(uint8_t value); */ void wdt_pet(void); -/** \brief Disables the WDT +/** \brief Disables the WDT + \ingroup wdt Disables the WDT if it was previously enabled, otherwise does nothing. @@ -159,7 +188,8 @@ void wdt_pet(void); */ void wdt_disable(void); -/** \brief Returns whether the WDT is enabled +/** \brief Returns whether the WDT is enabled + \ingroup wdt Checks to see whether the WDT has been enabled. diff --git a/utils/bin2o/bin2o b/utils/bin2o/bin2o index c0eadf8..ac43f86 100755 --- a/utils/bin2o/bin2o +++ b/utils/bin2o/bin2o @@ -9,12 +9,21 @@ set -o pipefail set -o nounset set -o errexit +me=`basename "$0"` + error() { - echo "bin2o:" "$@" 1>&2 + echo "$me: error:" "$@" 1>&2 +} + +# Remove the temporary directory +cleanup() { + if [ -d "$WORKDIR" ]; then + rm -r "$WORKDIR" + fi } if [ $# != 3 ]; then - echo "usage: $0 \<input file\> \<symbol\> \<output file\>" + echo "usage: $me <input.bin> <symbol> <output.o>" exit 0 fi @@ -38,29 +47,38 @@ TMPFILE3="$WORKDIR/objb$$.o" # Gotta do a different binary target here depending on the target. case $KOS_ARCH in dreamcast) - # shellcheck disable=SC2086 + # shellcheck disable=SC2086 echo ".section .rodata; .align 2; " | "$KOS_AS" $KOS_AFLAGS -o "$TMPFILE3" - # shellcheck disable=SC2181 - if [ $? -ne 0 ]; then exit 1; fi + # shellcheck disable=SC2181 + if [ $? -ne 0 ]; then + cleanup + exit 1 + fi echo "SECTIONS { .rodata : { _$2 = .; *(.data); _$2_end = .; } }" > "$TMPFILE1" "$KOS_LD" --no-warn-mismatch --format binary --oformat elf32-shl "$1" --format elf32-shl "$TMPFILE3" -o "$TMPFILE2" -r -EL -T "$TMPFILE1" - # shellcheck disable=SC2181 - if [ $? -ne 0 ]; then exit 1; fi + # shellcheck disable=SC2181 + if [ $? -ne 0 ]; then + cleanup + exit 1 + fi "$KOS_OBJCOPY" --set-section-flags .rodata=alloc,load,data,readonly "$TMPFILE2" "$3" - ;; + ;; gba) echo "SECTIONS { .rodata : { $2 = .; *(.data); $2_end = .; } }" > "$WORKDIR/script.ld" "$KOS_LD" --no-warn-mismatch --format binary --oformat elf32-littlearm "$1" -o "$3" -r -EL -T "$WORKDIR/script.ld" - ;; + ;; ps2) echo "OUTPUT_ARCH(mips:5900) SECTIONS { .rodata : { _$2 = .; *(.data); _$2_end = .; } }" > "$WORKDIR/script.ld" "$KOS_LD" --no-warn-mismatch --format binary --oformat elf64-littlemips -mips3 "$1" -o "$3" -r -EL -T "$WORKDIR/script.ld" - ;; + ;; *) - error "unsupported architecture \"$KOS_ARCH\"" - exit 1 - ;; + error "unsupported architecture \"$KOS_ARCH\"" + cleanup + exit 1 + ;; esac + +cleanup diff --git a/utils/elf2bin/elf2bin b/utils/elf2bin/elf2bin index b4ffbfa..2d6f7a5 100644 --- a/utils/elf2bin/elf2bin +++ b/utils/elf2bin/elf2bin @@ -3,7 +3,7 @@ # elf2bin # script to convert an elf program to a bin(ary) program # then you can use 'scramble' to generate a '1ST_READ.BIN' file -# this script is basically using 'strip' and 'objcopy'. +# this script is basically a simplified 'kos-objcopy'. me=`basename "$0"` hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-11-26 22:07:35
|
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 6ffd6a1772643b0a645ee9d0a4c956eb09b133d6 (commit) from 1f39538d02d39a084c457b0cac5e2f98bf5e200e (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 6ffd6a1772643b0a645ee9d0a4c956eb09b133d6 Author: Shirobon <126...@us...> Date: Mon Nov 27 07:05:58 2023 +0900 Fix GCC 13.2.0 Toolchain Compilation on Cygwin (#388) Toolchain fails to build sh.cc with undeclared fputs_unlocked errors, so if __CYGWIN__ is defined, undef these macros for this file. * Add x64 Cygwin specific patch for gcc 13.2.0 ----------------------------------------------------------------------- Summary of changes: .../dc-chain/patches/x86_64-pc-cygwin/gcc-13.2.0.diff | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 utils/dc-chain/patches/x86_64-pc-cygwin/gcc-13.2.0.diff diff --git a/utils/dc-chain/patches/x86_64-pc-cygwin/gcc-13.2.0.diff b/utils/dc-chain/patches/x86_64-pc-cygwin/gcc-13.2.0.diff new file mode 100644 index 0000000..41bd23b --- /dev/null +++ b/utils/dc-chain/patches/x86_64-pc-cygwin/gcc-13.2.0.diff @@ -0,0 +1,18 @@ +diff --color -ruN gcc-13.2.0/gcc/config/sh/sh.cc gcc-13.2.0-kos/gcc/config/sh/sh.cc +--- gcc-13.2.0/gcc/config/sh/sh.cc 2023-11-26 08:34:56.426962700 +0900 ++++ gcc-13.2.0-kos/gcc/config/sh/sh.cc 2023-11-26 08:40:20.067698600 +0900 +@@ -71,6 +71,14 @@ + /* This file should be included last. */ + #include "target-def.h" + ++/* fputs() and related are redefined in system.h to their unlocked version. */ ++/* On Cygwin, compilation errors with 'fputs_unlocked() was not declared' */ ++/* Therefore, on Cygwin, undefine these problematic symbols. */ ++#ifdef __CYGWIN__ ++#undef fputs ++#undef fprintf ++#endif ++ + int code_for_indirect_jump_scratch = CODE_FOR_indirect_jump_scratch; + + #define CONST_OK_FOR_ADD(size) CONST_OK_FOR_I08 (size) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-11-26 18:10: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 1f39538d02d39a084c457b0cac5e2f98bf5e200e (commit) via 9dd08a9dca7356b3896b526eaaabade571a5ce6e (commit) from 8b119832fcbbaf0b967582e9d90bf581ee210018 (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 1f39538d02d39a084c457b0cac5e2f98bf5e200e Merge: 8b11983 9dd08a9 Author: darcagn <da...@pr...> Date: Sun Nov 26 12:09:13 2023 -0600 Merge pull request #391 from Dreamcast-Projects/fix_cd_warning Fix unused variable warning. commit 9dd08a9dca7356b3896b526eaaabade571a5ce6e Author: Andress Barajas <and...@gm...> Date: Sun Nov 26 09:57:04 2023 -0800 Fix unused variable warning. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index 2d2f697..4942c61 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -471,7 +471,6 @@ int cdrom_spin_down(void) { /* Initialize: assume no threading issues */ int cdrom_init(void) { - int status, disc_type; uint32_t p; volatile uint32_t *react = (uint32_t *)(0x005f74e4 | MEM_AREA_P2_BASE); volatile uint32_t *bios = (uint32_t *)MEM_AREA_P2_BASE; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-11-26 07:26:06
|
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 8b119832fcbbaf0b967582e9d90bf581ee210018 (commit) via 5eb1d2484c8d51aa73cfc38b56442a920e93e700 (commit) via 1afd2ae53e12afc6b2cff0e9305e5afbff899423 (commit) via 90fdd6751e67f261c537bc88df462f4f8f3c7f6f (commit) from 73d97a809a2b1cc6319460864272a703e6d84654 (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 8b119832fcbbaf0b967582e9d90bf581ee210018 Merge: 1afd2ae 5eb1d24 Author: darcagn <da...@pr...> Date: Sun Nov 26 01:25:13 2023 -0600 Merge pull request #390 from DC-SWAT/gd_init_fix Removed GD drive status checks at startup. commit 5eb1d2484c8d51aa73cfc38b56442a920e93e700 Author: DC-SWAT <sw...@21...> Date: Sun Nov 26 14:20:00 2023 +0700 Removed GD drive status checks at startup. commit 1afd2ae53e12afc6b2cff0e9305e5afbff899423 Merge: 73d97a8 90fdd67 Author: darcagn <da...@pr...> Date: Sat Nov 25 23:47:12 2023 -0600 Merge pull request #389 from DC-SWAT/gd_init_fix Added check disc change status for cdrom_reinit_ex() commit 90fdd6751e67f261c537bc88df462f4f8f3c7f6f Author: DC-SWAT <sw...@21...> Date: Sun Nov 26 12:40:30 2023 +0700 Added check disc change status for cdrom_reinit_ex ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index d287503..2d2f697 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -316,7 +316,10 @@ int cdrom_reinit(void) { /* Enhanced cdrom_reinit, takes the place of the old 'sector_size' function */ int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { int r; - r = cdrom_exec_cmd_timed(CMD_INIT, NULL, 10000); + + do { + r = cdrom_exec_cmd_timed(CMD_INIT, NULL, 10000); + } while(r == ERR_DISC_CHG); if(r == ERR_NO_DISC || r == ERR_SYS || r == ERR_TIMEOUT) { return r; @@ -498,16 +501,7 @@ int cdrom_init(void) { gdc_init_system(); mutex_unlock(&_g1_ata_mutex); - cdrom_get_status(&status, &disc_type); - - if(status < CD_STATUS_OPEN && disc_type > CD_CDDA && disc_type < CD_FAIL) { - /* Do an initial initialization */ - cdrom_reinit(); - } else { - dbglog(DBG_INFO, "cdrom_init: No disc inserted\n"); - } - - return 0; + return cdrom_reinit(); } void cdrom_shutdown(void) { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-11-24 00: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 73d97a809a2b1cc6319460864272a703e6d84654 (commit) via 9559394c1f0a3b47c537a5ec81d84f99fc9e8534 (commit) from e0f17b4778bfa4b45e457fc2bde1efc7a792d27e (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 73d97a809a2b1cc6319460864272a703e6d84654 Merge: e0f17b4 9559394 Author: darcagn <da...@pr...> Date: Thu Nov 23 18:42:29 2023 -0600 Merge pull request #384 from KallistiOS/doxygen_warning_fix Fixed Thread-Related Doxygen Warnings commit 9559394c1f0a3b47c537a5ec81d84f99fc9e8534 Author: Falco Girgis <gyr...@gm...> Date: Thu Nov 23 01:10:20 2023 -0600 Fixed two thread-related Doxygen warnings - 1 in kthreads: kos/thread.h - 1 in C11 threads: threads.h ----------------------------------------------------------------------- Summary of changes: include/kos/thread.h | 2 +- include/threads.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/kos/thread.h b/include/kos/thread.h index 6b8be23..c00b4ab 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -573,7 +573,7 @@ struct _reent *thd_get_reent(kthread_t *thd); \deprecated This is now deprecated. - \param mode One of the \ref thd_modes values. + \param mode One of the THD_MODE values. \return The old mode of the threading system. \sa thd_get_mode diff --git a/include/threads.h b/include/threads.h index c133b17..bc49cc4 100644 --- a/include/threads.h +++ b/include/threads.h @@ -114,8 +114,7 @@ extern void mtx_destroy(mtx_t *mtx); protect critical sections of code. \param mtx The mutex to initialize. - \param type The type of mutex desired (see - \ref c11_mutex_types). + \param type The type of mutex desired \retval thrd_success On success. \retval thrd_error If the request could not be honored. */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-11-23 20:38:32
|
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 e0f17b4778bfa4b45e457fc2bde1efc7a792d27e (commit) from b6d26daa07a7e1b0342be19a5a8787d978e9b62b (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 e0f17b4778bfa4b45e457fc2bde1efc7a792d27e Author: Aaron Glazer <Aar...@us...> Date: Wed Nov 22 20:47:41 2023 -0800 Add basic micropython example. (#382) * Add basic micropython example. * respond to comments * add micropython to examples/dreamcast/Makefile and wrap whole demo w/ exception catcher * use EXIT_SUCCESS and print to stderr * update CHANGELOG * update copyright ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + examples/dreamcast/Makefile | 4 +- examples/dreamcast/micropython/Makefile | 37 ++++++++++ examples/dreamcast/micropython/example.c | 91 ++++++++++++++++++++++++ examples/dreamcast/micropython/romdisk/script.py | 26 +++++++ 5 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 examples/dreamcast/micropython/Makefile create mode 100644 examples/dreamcast/micropython/example.c create mode 100644 examples/dreamcast/micropython/romdisk/script.py diff --git a/doc/CHANGELOG b/doc/CHANGELOG index f8c8c7b..d3961eb 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -209,6 +209,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- content from <netinet/in.h> [LS] - *** Added __weak, __used, likely() and unlikely() [FG] - DC Added Maple-specific KOS_INIT_FLAGS() which allow for GC-ing unused drivers [FG] +- DC Added basic example for micropython KOS port [Aaron Glazer == AG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile index 68e59e4..dc867de 100644 --- a/examples/dreamcast/Makefile +++ b/examples/dreamcast/Makefile @@ -5,7 +5,9 @@ # DIRS = 2ndmix basic libdream kgl hello sound png network vmu conio pvr video \ - lua parallax modem dreameye sd g1ata lightgun keyboard sdl random rumble + lua parallax modem dreameye sd g1ata lightgun keyboard sdl random rumble \ + micropython + ifdef KOS_CCPLUS DIRS += cpp tsunami endif diff --git a/examples/dreamcast/micropython/Makefile b/examples/dreamcast/micropython/Makefile new file mode 100644 index 0000000..f00af49 --- /dev/null +++ b/examples/dreamcast/micropython/Makefile @@ -0,0 +1,37 @@ +# KallistiOS ##version## +# +# examples/dreamcast/micropython/Makefile +# Copyright (C) 2023 Aaron Glazer +# + +TARGET = micropython.elf + +CFLAGS += -std=c99 +CFLAGS += -I. +CFLAGS += -Wall -Og + +SRCS += example.c +OBJS += example.o romdisk.o +KOS_ROMDISK_DIR = romdisk + +# The rm-elf step is to remove the target before building, to force the +# re-creation of the rom disk. +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: rm-elf + -rm -f $(OBJS) + +rm-elf: + -rm -f $(TARGET) romdisk.* + +$(TARGET): $(OBJS) + kos-cc -o $(TARGET) $(OBJS) -lmicropython + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: $(TARGET) + -rm -f $(OBJS) romdisk.img + $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/micropython/example.c b/examples/dreamcast/micropython/example.c new file mode 100644 index 0000000..ae50bbd --- /dev/null +++ b/examples/dreamcast/micropython/example.c @@ -0,0 +1,91 @@ +/* KallistiOS ##version## + + example.c + Copyright (C) 2023 Aaron Glazer + + This example demonstrates basic usage of KOS's port + of micropython via its C API. +*/ + +#include <stdio.h> +#include <stdlib.h> + +#include <kos.h> + +#include <micropython/py/parse.h> +#include <micropython/py/lexer.h> +#include <micropython/py/gc.h> +#include <micropython/py/nlr.h> +#include <micropython/py/compile.h> +#include <micropython/py/runtime.h> +#include <micropython/py/stackctrl.h> +#include <micropython/py/qstr.h> +#include <micropython/py/obj.h> + +static char mp_heap[8 * 1024]; + +static void load_module(void) { + mp_lexer_t *lex = mp_lexer_new_from_file(qstr_from_str("/rd/script.py")); + mp_parse_tree_t parse_tree = mp_parse(lex, MP_PARSE_FILE_INPUT); + mp_obj_t mod = mp_compile(&parse_tree, lex->source_name, false); + mp_call_function_0(mod); +} + +static void demo(void) { + printf("(entering script)\n"); + load_module(); + printf("(exited script)\n"); + + mp_obj_t fn; + mp_obj_t res; + mp_obj_t five = mp_obj_new_int(5); + + fn = mp_load_name(qstr_from_str("f")); + res = mp_call_function_1(fn, five); + printf("f(5): "); + mp_obj_print(res, PRINT_REPR); + printf("\n"); + + fn = mp_load_name(qstr_from_str("g")); + res = mp_call_function_1(fn, five); + printf("g(5): "); + mp_obj_print(res, PRINT_REPR); + printf("\n"); + + mp_obj_t sum_obj = mp_load_name(qstr_from_str("sum")); + mp_int_t sum = mp_obj_int_get_checked(sum_obj); + printf("sum: %d\n", sum); + + printf("globals:\n"); + mp_obj_dict_t* globals = mp_globals_get(); + mp_map_t* map = &globals->map; + for (size_t i = 0; i < map->alloc; i++) { + printf(" "); + if (map->table[i].key != MP_OBJ_NULL) { + mp_obj_print(map->table[i].key, PRINT_REPR); + } else { + printf("(nil)"); + } + printf(": %p\n", map->table[i].value); + } +} + +int main(int argc, const char* argv[]) { + mp_stack_ctrl_init(); + gc_init(mp_heap, mp_heap + sizeof(mp_heap)); + mp_init(); + + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { + demo(); + nlr_pop(); + } else { + fprintf(stderr, "demo ran into an uncaught exception!\n"); + mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); + exit(EXIT_FAILURE); + } + + mp_deinit(); + + return EXIT_SUCCESS; +} diff --git a/examples/dreamcast/micropython/romdisk/script.py b/examples/dreamcast/micropython/romdisk/script.py new file mode 100644 index 0000000..3ee19fc --- /dev/null +++ b/examples/dreamcast/micropython/romdisk/script.py @@ -0,0 +1,26 @@ +# KallistiOS ##version## +# +# script.py +# Copyright (C) 2023 Aaron Glazer +# + +def f(n): + return n * n +def g(n): + return n ** n + +sum = 0 +for i in range(10): + print('iter {:08}'.format(i)) + sum += i + +try: + 1//0 +except Exception as er: + print('caught exception', repr(er)) + +import gc +print('run GC collect') +gc.collect() + +print('finish') hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-23 03:45:06
|
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 b6d26daa07a7e1b0342be19a5a8787d978e9b62b (commit) via 1d6c9fd74b0f199c9609ebe57e7920cdaa0b629d (commit) from 8aa26e9089de3928faca950a9ad73ad3a392e9d2 (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 b6d26daa07a7e1b0342be19a5a8787d978e9b62b Merge: 8aa26e9 1d6c9fd Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 22 22:15:35 2023 -0500 Merge pull request #381 from pcercuei/kos_init_flags_cpp init.h: Support KOS_INIT_FLAGS() in C++ code commit 1d6c9fd74b0f199c9609ebe57e7920cdaa0b629d Author: Paul Cercueil <pa...@cr...> Date: Wed Nov 22 22:56:49 2023 +0100 init.h: Support KOS_INIT_FLAGS() in C++ code Automatically add extern "C" brackets around the exported variables when the KOS_INIT_FLAGS() macro is used inside C++ code. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: include/kos/init.h | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/include/kos/init.h b/include/kos/init.h index 341e04d..4becbeb 100644 --- a/include/kos/init.h +++ b/include/kos/init.h @@ -28,6 +28,10 @@ #ifndef __KOS_INIT_H #define __KOS_INIT_H +#ifdef __cplusplus +extern "C" { +#endif + #include <kos/cdefs.h> __BEGIN_DECLS @@ -35,19 +39,14 @@ __BEGIN_DECLS #include <kos/init_base.h> #include <stdint.h> -/** \brief Exports and initializes the given KOS subsystems. - - KOS_INIT_FLAGS() provides a mechanism through which various components - of KOS can be enabled and initialized depending on whether their flag - has been included within the list. - - \note - When no KOS_INIT_FLAGS() have been explicitly provided, the default - flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT). +/** \cond */ +#ifdef __cplusplus +#define __kos_cplusplus 1 +#else +#define __kos_cplusplus 0 +#endif - \param flags Parts of KOS to init. - */ - #define KOS_INIT_FLAGS(flags) \ + #define __KOS_INIT_FLAGS_0(flags) \ const uint32_t __kos_init_flags = (flags); \ KOS_INIT_FLAG(flags, INIT_NET, arch_init_net); \ KOS_INIT_FLAG(flags, INIT_NET, net_shutdown); \ @@ -58,10 +57,35 @@ __BEGIN_DECLS KOS_INIT_FLAG(flags, INIT_EXPORT, export_init); \ KOS_INIT_FLAGS_ARCH(flags) -/** \cond */ +#define __KOS_INIT_FLAGS_1(flags) \ + extern "C" { \ + __KOS_INIT_FLAGS_0(flags); \ + } + +#define __KOS_INIT_FLAGS(flags, cp) \ + __KOS_INIT_FLAGS_##cp(flags) + +#define _KOS_INIT_FLAGS(flags, cp) \ + __KOS_INIT_FLAGS(flags, cp) + extern const uint32_t __kos_init_flags; /** \endcond */ +/** \brief Exports and initializes the given KOS subsystems. + + KOS_INIT_FLAGS() provides a mechanism through which various components + of KOS can be enabled and initialized depending on whether their flag + has been included within the list. + + \note + When no KOS_INIT_FLAGS() have been explicitly provided, the default + flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT). + + \param flags Parts of KOS to init. + */ +#define KOS_INIT_FLAGS(flags) \ + _KOS_INIT_FLAGS(flags, __kos_cplusplus) + /** \brief Deprecated and not useful anymore. */ #define KOS_INIT_ROMDISK(rd) \ void *__kos_romdisk = (rd); \ @@ -108,4 +132,8 @@ extern void * __kos_romdisk; __END_DECLS +#ifdef __cplusplus +}; +#endif + #endif /* !__KOS_INIT_H */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-22 14:34:39
|
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 8aa26e9089de3928faca950a9ad73ad3a392e9d2 (commit) via 9142f596220cf284cb926fc50f5eeec506a63f4a (commit) via 71540de622403aad56876323e6c3c67171eef26a (commit) from c37b8e2ac30db217eb1c217f6b1f314d19dcd3e2 (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 8aa26e9089de3928faca950a9ad73ad3a392e9d2 Merge: 9142f59 71540de Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 22 09:32:32 2023 -0500 Merge pull request #380 from KallistiOS/readme_update Updated main repo and documentation README commit 9142f596220cf284cb926fc50f5eeec506a63f4a Author: Paul Cercueil <pa...@cr...> Date: Wed Nov 22 15:31:09 2023 +0100 Modularizing KOS, my take (#360) * cdefs.h: Add and use __weak, __used, likely() and unlikely() Add __weak and __used tokens, and use them in the places were the corresponding GCC attributes were used. Add likely() and unlikely() macros, which are yet to be used anywhere. Signed-off-by: Paul Cercueil <pa...@cr...> * fs_romdisk: Make init/shutdown functions void-typed They would always return 0, and the calling code would never check the error code anyway. So they might just as well not return any value. Signed-off-by: Paul Cercueil <pa...@cr...> * exports: Make export_init() and nmmgr_init() void-typed Their potential errors (which in practice will never happen) were ignored by the init code. Therefore it's just simpler to make these functions void-typed. Signed-off-by: Paul Cercueil <pa...@cr...> * maple: Make init functions void-typed The calling code would never check the error code, so they might just as well not return any value. Signed-off-by: Paul Cercueil <pa...@cr...> * fs_romdisk: Make builtin romdisk mount function void-typed The potential error codes is ignored by the init code anyway, so it can be converted to void-typed. Signed-off-by: Paul Cercueil <pa...@cr...> * Make '__kos_init_flags' const It does not need to be mutable and the user shouldn't update it at runtime. Use this occasion to also update from using the deprecated uint32 type to uint32_t. Signed-off-by: Paul Cercueil <pa...@cr...> * Add and use new macros for init/shutdown functions The KOS_INIT_FLAG_EXPORT() is supposed to be used within KOS_INIT_FLAGS(). It will override the weak symbol associated with the function with a strong one, that points to this function if the flag is set, or is NULL if the flag is cleared. The KOS_INIT_FLAG_WEAK() should be used to declare the weak symbol for the init/shutdown function. Finally, the init/shutdown function can be called with KOS_INIT_FLAG_CALL(). If the flag has not been set, the function will not be called, and will be automatically garbage-collected by the compiler. Signed-off-by: Paul Cercueil <pa...@cr...> * Add support for arch-specific init flags This will later allow programs to pick which parts of the hardware should be initialized by KallistiOS. Signed-off-by: Paul Cercueil <pa...@cr...> * Add init flags for all Maple drivers Add init flags for all Maple drivers, so that a program can configure which peripherals should be supported by KallistiOS (the default being all of them). The compiler will then garbage-collect the init/shutdown functions (and all related code) of the disabled Maple drivers. Signed-off-by: Paul Cercueil <pa...@cr...> * Add weak init/shutdown of the whole Maple bus If none of the Maple drivers have been enabled, we can skip initialization/shutdown of the whole Maple bus, allowing the compiler to garbage-collect more code. Signed-off-by: Paul Cercueil <pa...@cr...> * Enable VMU FS according to init flags Use weak init/shutdown functions for the VMU FS. This allows the VMU FS code to be automatically garbage-collected if the INIT_VMU init flag has not been set (it is set by default). Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> commit 71540de622403aad56876323e6c3c67171eef26a Author: Falco Girgis <gyr...@gm...> Date: Wed Nov 22 02:14:10 2023 -0600 Updated main repo and documentation README - Added a header with a link to the up-to-date Doxygen, to make it easier for people to find - Expounded upon language and API support more in the Overview - Reworded a lot of things - Added mention of a few peripherals and drivers ----------------------------------------------------------------------- Summary of changes: README.md | 48 ++++++++---- doc/CHANGELOG | 2 + include/kos/cdefs.h | 43 ++++++++++- include/kos/exports.h | 7 +- include/kos/fs_romdisk.h | 4 +- include/kos/init.h | 87 ++++++++++++---------- include/kos/init_base.h | 67 +++++++++++++++++ include/kos/nmmgr.h | 2 +- kernel/arch/dreamcast/hardware/hardware.c | 20 +++-- kernel/arch/dreamcast/hardware/maple/controller.c | 5 +- kernel/arch/dreamcast/hardware/maple/dreameye.c | 5 +- kernel/arch/dreamcast/hardware/maple/keyboard.c | 5 +- kernel/arch/dreamcast/hardware/maple/lightgun.c | 5 +- .../dreamcast/hardware/maple/maple_init_shutdown.c | 62 +++++++++------ kernel/arch/dreamcast/hardware/maple/mouse.c | 5 +- kernel/arch/dreamcast/hardware/maple/purupuru.c | 5 +- kernel/arch/dreamcast/hardware/maple/sip.c | 5 +- kernel/arch/dreamcast/hardware/maple/vmu.c | 5 +- kernel/arch/dreamcast/include/arch/init_flags.h | 65 +++++++++++++++- kernel/arch/dreamcast/include/dc/maple.h | 6 +- .../arch/dreamcast/include/dc/maple/controller.h | 2 +- kernel/arch/dreamcast/include/dc/maple/dreameye.h | 2 +- kernel/arch/dreamcast/include/dc/maple/keyboard.h | 2 +- kernel/arch/dreamcast/include/dc/maple/lightgun.h | 2 +- kernel/arch/dreamcast/include/dc/maple/mouse.h | 2 +- kernel/arch/dreamcast/include/dc/maple/purupuru.h | 2 +- kernel/arch/dreamcast/include/dc/maple/sip.h | 2 +- kernel/arch/dreamcast/include/dc/maple/vmu.h | 2 +- kernel/arch/dreamcast/kernel/init.c | 68 +++++++++-------- kernel/exports/exports.c | 11 +-- kernel/exports/nmmgr.c | 13 ++-- kernel/fs/fs_romdisk.c | 12 +-- kernel/libc/koslib/abort.c | 2 +- kernel/romdisk/romdiskbase.c | 4 +- 34 files changed, 388 insertions(+), 191 deletions(-) create mode 100644 include/kos/init_base.h diff --git a/README.md b/README.md index 2a2ac24..64d7106 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,60 @@ -# KallistiOS -KOS is an unofficial development environment for the SEGA Dreamcast game console with some support for the NAOMI and NAOMI 2 arcade boards. +<!-- PROJECT LOGO --> +<br /> +<div align="center"> + <h1 align="center">KallistiOS</h1> + + <p align="center"> + Independent SDK for the Sega Dreamcast + <br /> + <a href="https://kos-docs.dreamcast.wiki"><strong>Explore the docs »</strong></a> + </p> +</div> + +## Overview + +KOS is an unofficial development kit for the SEGA Dreamcast game console with some support for the NAOMI and NAOMI 2 arcade boards. KOS was developed from scratch over the internet by a group of free software developers and has no relation to the official Sega Katana or Microsoft Windows CE Dreamcast development kits. This has allowed it to fuel a thriving Dreamcast homebrew scene, powering many commercial releases for the platform over the years. It supports a signficiant portion of the Dreamcast's hardware capabilities and a wide variety of peripherals, accessories, and add-ons for the console, including custom hardware modifications that have been created by the scene. -Despite the console's age, KOS offers an extremely modern, programmer-friendly development environment, supporting portions of C23 and C++23, with the majority of their standard libraries fully supported and additional support for many POSIX APIs. Additionally, KOS-ports offers a rich set of add-on libraries such as SDL, OpenGL, and Lua for the platform. +Despite the console's age, KOS offers an extremely modern, programmer-friendly development environment. Using the latest GCC toolchain, it supports the entirety of C17 and C++20 including their standard libraries, along with support for portions of C23, C++23, Objective-C, and various POSIX APIs. Additionally, KOS-ports offers a rich set of add-on libraries such as SDL, OpenGL, OpenAL, and Lua for the platform. ## Features ### Core Functionality -* Concurrency with Kernel Threads, C11 Threads, C++11 `std::thread`, Pthreads -* Virtual filesystem abstraction -* IPv4/IPv6 Network stack -* Dynamically loading libraries/modules -* GDB Debug stubs +* Concurrency with Kernel Threads, C11 Threads, C++11 `std::thread`, POSIX threads +* Virtual Filesystem Abstraction +* IPv4/IPv6 Network Stack +* Dynamically Loaded Libraries and Modules +* GDB Debugger Support ### Dreamcast Hardware Support -* GD-Rom driver +* GD-ROM Optical Drive * Low-level 3D PowerVR Graphics * SH4 ASM-Optimized Math Routines * SH4 SCIF Serial I/O * DMA Controller -* Flashrom Access +* Flashrom Filesystem * AICA SPU Sound Processor Driver * Cache and Store Queue Management -* Timer Peripherals, Real-Time Clock, Performance Counters -* MMU Management API +* Timer Peripherals, Real-Time Clock, Watchdog Timer +* Performance Counters +* MMU Management * BIOS Font Rendering ### Peripherals and Accessory Support +* Controller, ASCII Pad +* Arcade Stick, Twin Stick, Mission Stick +* Keyboard +* Mouse * Visual Memory Unit * Puru Puru Vibration Pack * Seaman Microphone * Dreameye Webcam * Lightgun -* Keyboard -* Mouse +* Racing Wheel +* Fishing Rod +* Samba De Amigo Maracas +* Dance Mat * Dial-up Modem * Broadband Adapter * LAN Adapter diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 26be8ae..f8c8c7b 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -207,6 +207,8 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added <netinet/tcp.h> header file and required option [LS] - *** Added <netinet/udp.h> and <netinet/udplite.h> headers and move the related content from <netinet/in.h> [LS] +- *** Added __weak, __used, likely() and unlikely() [FG] +- DC Added Maple-specific KOS_INIT_FLAGS() which allow for GC-ing unused drivers [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h index a2f222d..439ba1c 100644 --- a/include/kos/cdefs.h +++ b/include/kos/cdefs.h @@ -3,18 +3,21 @@ kos/cdefs.h Copyright (C) 2002, 2004 Megan Potter Copyright (C) 2020, 2023 Lawrence Sebald + Copyright (C) 2023 Falco Girgis Based loosely around some stuff in BSD's sys/cdefs.h */ /** \file kos/cdefs.h - \brief Potentially useful definitions for C Programs. + \brief Definitions for builtin attributes and compiler directives This file contains definitions of various __attribute__ directives in - shorter forms for use in programs (to aid in optimization, mainly). + shorter forms for use in programs. These typically aid in optimizations + or provide the compiler with extra information about a symbol. \author Megan Potter \author Lawrence Sebald + \author Falco Girgis */ #ifndef __KOS_CDEFS_H @@ -45,6 +48,16 @@ #define __unused __attribute__((__unused__)) #endif +#ifndef __used +/** \brief Prevent a symbol from being removed from the binary. */ +#define __used __attribute__((used)) +#endif + +#ifndef __weak +/** \brief Identify a function or variable that may be overriden by another symbol. */ +#define __weak __attribute__((weak)) +#endif + #ifndef __dead2 /** \brief Alias for \ref __noreturn. For BSD compatibility. */ #define __dead2 __noreturn /* BSD compat */ @@ -55,6 +68,32 @@ #define __pure2 __pure /* ditto */ #endif +#ifndef likely +/** \brief Directive to inform the compiler the condition is in the likely path. + + This can be used around conditionals or loops to help inform the + compiler which path to optimize for as the common-case. + + \param exp Boolean expression which expected to be true. + + \sa unlikely() +*/ +#define likely(exp) __builtin_expect(!!(exp), 1) +#endif + +#ifndef unlikely +/** \brief Directive to inform the compiler the condition is in the unlikely path. + + This can be used around conditionals or loops to help inform the + compiler which path to optimize against as the infrequent-case. + + \param exp Boolean expression which is expected to be false. + + \sa likely() +*/ +#define unlikely(exp) __builtin_expect(!!(exp), 0) +#endif + #ifndef __deprecated /** \brief Mark something as deprecated. This should be used to warn users that a function/type/etc will be removed diff --git a/include/kos/exports.h b/include/kos/exports.h index f5f816a..d7d9a76 100644 --- a/include/kos/exports.h +++ b/include/kos/exports.h @@ -55,11 +55,8 @@ typedef struct symtab_handler { } symtab_handler_t; #endif -/** \brief Setup initial kernel exports. - \retval 0 On success - \retval -1 On error -*/ -int export_init(void); +/** \brief Setup initial kernel exports. */ +void export_init(void); /** \brief Look up a symbol by name. \param name The symbol to look up diff --git a/include/kos/fs_romdisk.h b/include/kos/fs_romdisk.h index a4a45ff..35a3763 100644 --- a/include/kos/fs_romdisk.h +++ b/include/kos/fs_romdisk.h @@ -32,10 +32,10 @@ __BEGIN_DECLS /** \cond */ /* Initialize the file system */ -int fs_romdisk_init(void); +void fs_romdisk_init(void); /* De-init the file system; also unmounts any mounted images. */ -int fs_romdisk_shutdown(void); +void fs_romdisk_shutdown(void); /** \endcond */ /* NOTE: the mount/unmount are _not_ thread safe as regards doing multiple diff --git a/include/kos/init.h b/include/kos/init.h index 4b563fe..341e04d 100644 --- a/include/kos/init.h +++ b/include/kos/init.h @@ -3,6 +3,8 @@ include/kos/init.h Copyright (C) 2001 Megan Potter Copyright (C) 2023 Lawrence Sebald + Copyright (C) 2023 Paul Cercueil + Copyright (C) 2023 Falco Girgis */ @@ -14,9 +16,13 @@ architecture-independent are specified here, however this file also includes the architecture-specific file to bring in those flags as well. - \author Lawrence Sebald + \sa arch/init_flags.h + \sa kos/init_base.h + \author Megan Potter - \see arch/init_flags.h + \author Lawrence Sebald + \author Paul Cercueil + \author Falco Girgis */ #ifndef __KOS_INIT_H @@ -25,44 +31,43 @@ #include <kos/cdefs.h> __BEGIN_DECLS -#include <arch/types.h> #include <arch/init_flags.h> +#include <kos/init_base.h> +#include <stdint.h> + +/** \brief Exports and initializes the given KOS subsystems. -/** \brief Use this macro to determine the level of initialization you'd like - in your program by default. + KOS_INIT_FLAGS() provides a mechanism through which various components + of KOS can be enabled and initialized depending on whether their flag + has been included within the list. - The defaults will be fine for most things, and will be used if you do not - specify any init flags yourself. + \note + When no KOS_INIT_FLAGS() have been explicitly provided, the default + flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT). \param flags Parts of KOS to init. - \see kos_initflags - \see dreamcast_initflags -*/ -#define KOS_INIT_FLAGS(flags) \ - uint32 __kos_init_flags = (flags); \ - extern void arch_init_net(void); \ - void (*init_net_weak)(void) = ((flags) & INIT_NET) ? arch_init_net : NULL; \ - extern void net_shutdown(void); \ - void (*net_shutdown_weak)(void) = ((flags) & INIT_NET) ? net_shutdown : NULL; \ - extern void bba_la_init(void); \ - void (*bba_la_init_weak)(void) = ((flags) & INIT_NET) ? bba_la_init : NULL; \ - extern void bba_la_shutdown(void); \ - void (*bba_la_shutdown_weak)(void) = ((flags) & INIT_NET) ? bba_la_shutdown : NULL; \ - extern int fs_romdisk_init(void); \ - int (*fs_romdisk_init_weak)(void) = ((flags) & INIT_FS_ROMDISK) ? fs_romdisk_init : NULL; \ - extern int fs_romdisk_shutdown(void); \ - int (*fs_romdisk_shutdown_weak)(void) = ((flags) & INIT_FS_ROMDISK) ? fs_romdisk_shutdown : NULL; \ - extern int export_init(void); \ - int (*export_init_weak)(void) = ((flags) & INIT_EXPORT) ? export_init : NULL - -/** \brief The init flags. Do not modify this directly! */ -extern uint32 __kos_init_flags; + */ + #define KOS_INIT_FLAGS(flags) \ + const uint32_t __kos_init_flags = (flags); \ + KOS_INIT_FLAG(flags, INIT_NET, arch_init_net); \ + KOS_INIT_FLAG(flags, INIT_NET, net_shutdown); \ + KOS_INIT_FLAG(flags, INIT_NET, bba_la_init); \ + KOS_INIT_FLAG(flags, INIT_NET, bba_la_shutdown); \ + KOS_INIT_FLAG(flags, INIT_FS_ROMDISK, fs_romdisk_init); \ + KOS_INIT_FLAG(flags, INIT_FS_ROMDISK, fs_romdisk_shutdown); \ + KOS_INIT_FLAG(flags, INIT_EXPORT, export_init); \ + KOS_INIT_FLAGS_ARCH(flags) + +/** \cond */ +extern const uint32_t __kos_init_flags; +/** \endcond */ /** \brief Deprecated and not useful anymore. */ #define KOS_INIT_ROMDISK(rd) \ void *__kos_romdisk = (rd); \ - extern int fs_romdisk_mount_builtin(void); \ - int (*fs_romdisk_mount_builtin_weak_legacy)(void) = fs_romdisk_mount_builtin + extern void fs_romdisk_mount_builtin_legacy(void); \ + void (*fs_romdisk_mount_builtin_legacy_weak)(void) = fs_romdisk_mount_builtin_legacy + /** \brief Built-in romdisk. Do not modify this directly! */ extern void * __kos_romdisk; @@ -87,18 +92,18 @@ extern void * __kos_romdisk; @{ */ /** \brief Default init flags (IRQs on, preemption enabled, romdisks). */ -#define INIT_DEFAULT \ - (INIT_IRQ | INIT_THD_PREEMPT | INIT_FS_ROMDISK) +#define INIT_DEFAULT (INIT_IRQ | INIT_THD_PREEMPT | INIT_FS_ROMDISK | \ + INIT_DEFAULT_ARCH) -#define INIT_NONE 0x0000 /**< \brief Don't init optional things */ -#define INIT_IRQ 0x0001 /**< \brief Enable IRQs at startup */ +#define INIT_NONE 0x00000000 /**< \brief Don't init optional things */ +#define INIT_IRQ 0x00000001 /**< \brief Enable IRQs at startup */ /* Preemptive mode is the only mode now. Keeping define for compatability. */ -#define INIT_THD_PREEMPT 0x0002 /**< \brief Enable thread preemption */ -#define INIT_NET 0x0004 /**< \brief Enable built-in networking */ -#define INIT_MALLOCSTATS 0x0008 /**< \brief Enable malloc statistics */ -#define INIT_QUIET 0x0010 /**< \brief Disable dbgio */ -#define INIT_EXPORT 0x0020 /**< \brief Export kernel symbols */ -#define INIT_FS_ROMDISK 0x0040 /**< \brief Enable support for romdisks */ +#define INIT_THD_PREEMPT 0x00000002 /**< \deprecated Already default mode */ +#define INIT_NET 0x00000004 /**< \brief Enable built-in networking */ +#define INIT_MALLOCSTATS 0x00000008 /**< \brief Enable malloc statistics */ +#define INIT_QUIET 0x00000010 /**< \brief Disable dbgio */ +#define INIT_EXPORT 0x00000020 /**< \brief Export kernel symbols */ +#define INIT_FS_ROMDISK 0x00000040 /**< \brief Enable support for romdisks */ /** @} */ __END_DECLS diff --git a/include/kos/init_base.h b/include/kos/init_base.h new file mode 100644 index 0000000..8fe7034 --- /dev/null +++ b/include/kos/init_base.h @@ -0,0 +1,67 @@ +/* KallistiOS ##version## + + include/kos/init_base.h + Copyright (C) 2023 Falco Girgis + +*/ + +/** \file kos/init_base.h + \brief Shared initialization macros and utilities + + This file contains common utilities which can be included within + architecture-specific `init_flags.h` files, providing a base + layer of infrastructure for managing initialization flags. + + \sa kos/init.h + \sa arch/init_flags.h + + \author Falco Girgis +*/ + +#ifndef __KOS_INIT_BASE_H +#define __KOS_INIT_BASE_H + +#include <kos/cdefs.h> +__BEGIN_DECLS + +/** \cond */ + +/* Declares a weak function pointer which can be optionally + overridden and given a value later. */ +#define KOS_INIT_FLAG_WEAK(func, dft_on) \ + void (*func##_weak)(void) __weak = (dft_on) ? func : NULL + +/* Invokes the given function if its weak function pointer + has been overridden to point to a valid function. */ +#define KOS_INIT_FLAG_CALL(func) ({ \ + int ret = 0; \ + if(func##_weak) { \ + (*func##_weak)(); \ + ret = 1; \ + } \ + ret; \ +}) + +/* Export the given function pointer by assigning it to the weak function + * pointer if the given flags value contains all the flags set in the mask. */ +#define KOS_INIT_FLAG_ALL(flags, mask, func) \ + extern void func(void); \ + void (*func##_weak)(void) = ((flags) & (mask)) == (mask) ? func : NULL + +/* Export the given function by assigning it to the weak function pointer if the + given flags value contains none of the flags set in the mask. */ +#define KOS_INIT_FLAG_NONE(flags, mask, func) \ + extern void func(void); \ + void (*func##_weak)(void) = ((flags) & (mask)) ? NULL : func + +/* Export the given function by assigning it to the weak function pointer if the + given flags value contains the selected flag */ +#define KOS_INIT_FLAG(flags, mask, func) \ + extern void func(void); \ + void (*func##_weak)(void) = ((flags) & (mask)) ? func : NULL + +/** \endcond */ + +__END_DECLS + +#endif /* !__ARCH_INIT_BASE_H */ diff --git a/include/kos/nmmgr.h b/include/kos/nmmgr.h index ad48284..e80d058 100644 --- a/include/kos/nmmgr.h +++ b/include/kos/nmmgr.h @@ -127,7 +127,7 @@ int nmmgr_handler_remove(nmmgr_handler_t *hnd); /** \cond */ /* Name manager init */ -int nmmgr_init(void); +void nmmgr_init(void); void nmmgr_shutdown(void); /** \endcond */ diff --git a/kernel/arch/dreamcast/hardware/hardware.c b/kernel/arch/dreamcast/hardware/hardware.c index 7f15b50..c37066c 100644 --- a/kernel/arch/dreamcast/hardware/hardware.c +++ b/kernel/arch/dreamcast/hardware/hardware.c @@ -5,7 +5,9 @@ Copyright (C) 2013 Lawrence Sebald */ +#include <stdbool.h> #include <arch/arch.h> +#include <kos/init.h> #include <dc/spu.h> #include <dc/video.h> #include <dc/cdrom.h> @@ -40,8 +42,6 @@ int hardware_sys_init(void) { return 0; } -void (*bba_la_init_weak)(void) __attribute__((weak)); -void (*bba_la_shutdown_weak)(void) __attribute__((weak)); void bba_la_init(void) { /* Setup network (this won't do anything unless we enable netcore) */ @@ -54,6 +54,10 @@ void bba_la_shutdown(void) { bba_shutdown(); } +KOS_INIT_FLAG_WEAK(bba_la_init, false); +KOS_INIT_FLAG_WEAK(bba_la_shutdown, false); +KOS_INIT_FLAG_WEAK(maple_init, true); + int hardware_periph_init(void) { /* Init sound */ spu_init(); @@ -65,14 +69,13 @@ int hardware_periph_init(void) { #endif /* Setup maple bus */ - maple_init(); + KOS_INIT_FLAG_CALL(maple_init); /* Init video */ vid_init(DEFAULT_VID_MODE, DEFAULT_PIXEL_MODE); #ifndef _arch_sub_naomi - if(bba_la_init_weak) - (*bba_la_init_weak)(); + KOS_INIT_FLAG_CALL(bba_la_init); #endif initted = 2; @@ -80,14 +83,15 @@ int hardware_periph_init(void) { return 0; ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-22 05:00:57
|
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 c37b8e2ac30db217eb1c217f6b1f314d19dcd3e2 (commit) via 88a3a8e06481fe22ffc4653845001e73fd7092f3 (commit) via 6d706e1d5e54a2cc092c0d64b2dd4f842715ae89 (commit) via a246cbfe5f2756e526da17f3d67c2910a4765cf7 (commit) via e228fd47a82d7ff2dbed7c04607069562a40cce6 (commit) from 92a76c016c9d0c89e5f8613189ca6ba7bff1616e (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 c37b8e2ac30db217eb1c217f6b1f314d19dcd3e2 Merge: 88a3a8e a246cbf Author: Lawrence Sebald <ljs...@us...> Date: Wed Nov 22 00:00:21 2023 -0500 Merge pull request #377 from DC-SWAT/gd_init Fixed GD-ROM init for BIOS mod without CD inserted. commit 88a3a8e06481fe22ffc4653845001e73fd7092f3 Merge: 92a76c0 6d706e1 Author: Lawrence Sebald <ljs...@us...> Date: Tue Nov 21 22:26:18 2023 -0500 Merge pull request #376 from sizious/elf2bin `elf2bin`: adding script to the `utils` directory commit 6d706e1d5e54a2cc092c0d64b2dd4f842715ae89 Author: SiZiOUS <si...@gm...> Date: Tue Nov 21 21:51:51 2023 +0100 `elf2bin`: Removing unnecessary `strip` step commit a246cbfe5f2756e526da17f3d67c2910a4765cf7 Author: DC-SWAT <sw...@21...> Date: Mon Nov 20 12:57:39 2023 +0700 Fixed GD-ROM init for BIOS mod without CD inserted. Also added cdrom_exec_cmd_timed, fixed cdrom_get_status and some cleanup. commit e228fd47a82d7ff2dbed7c04607069562a40cce6 Author: SiZiOUS <si...@gm...> Date: Sun Nov 19 18:43:41 2023 +0100 `elf2bin`: adding script to the `utils` directory This is basically a simple script using `strip` and `kos-objcopy`; basically this makes the conversion "explicit". ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 129 ++++++++++++++++++------------- kernel/arch/dreamcast/include/dc/cdrom.h | 20 ++++- utils/elf2bin/elf2bin | 57 ++++++++++++++ 3 files changed, 149 insertions(+), 57 deletions(-) create mode 100644 utils/elf2bin/elf2bin diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index 870c5fe..d287503 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -10,11 +10,15 @@ */ #include <assert.h> +#include <arch/timer.h> +#include <arch/memory.h> + #include <dc/cdrom.h> #include <dc/g1ata.h> #include <kos/thread.h> #include <kos/mutex.h> +#include <kos/dbglog.h> /* @@ -49,23 +53,25 @@ hiccups (by severely reducing the number of gd commands being sent). which syscall we want. */ #define MAKE_SYSCALL(rs, p1, p2, idx) \ - uint32 *syscall_bc = (uint32*)0x8c0000bc; \ + uint32_t *syscall_bc = (uint32_t *)(0x0c0000bc | MEM_AREA_P1_BASE); \ int (*syscall)() = (int (*)())(*syscall_bc); \ rs syscall((p1), (p2), 0, (idx)); +typedef int gdc_cmd_hnd_t; + /* Reset system functions */ static void gdc_init_system(void) { MAKE_SYSCALL(/**/, 0, 0, 3); } /* Submit a command to the system */ -static int gdc_req_cmd(int cmd, void *param) { +static gdc_cmd_hnd_t gdc_req_cmd(int cmd, void *param) { MAKE_SYSCALL(return, cmd, param, 0); } /* Check status on an executed command */ -static int gdc_get_cmd_stat(int f, void *status) { - MAKE_SYSCALL(return, f, status, 1); +static int gdc_get_cmd_stat(gdc_cmd_hnd_t hnd, void *status) { + MAKE_SYSCALL(return, hnd, status, 1); } /* Execute submitted commands */ @@ -84,28 +90,28 @@ static int gdc_change_data_type(void *param) { } /* Abort the current command */ -static void gdc_abort_cmd(int cmd) { - MAKE_SYSCALL(/**/, cmd, 0, 8); +static void gdc_abort_cmd(gdc_cmd_hnd_t hnd) { + MAKE_SYSCALL(/**/, hnd, 0, 8); } -#if 0 /* Not used yet */ + /* Reset the GD-ROM syscalls */ static void gdc_reset(void) { MAKE_SYSCALL(/**/, 0, 0, 9); } - +#if 0 /* Not used yet */ /* DMA end interrupt handler */ static void gdc_dma_end(uintptr_t callback, void *param) { MAKE_SYSCALL(/**/, callback, param, 5); } /* Request DMA transfer for DMAREAD_STREAM commands */ -static int gdc_req_dma_transfer(int f, int *params) { - MAKE_SYSCALL(return, f, params, 6); +static int gdc_req_dma_transfer(gdc_cmd_hnd_t hnd, int *params) { + MAKE_SYSCALL(return, hnd, params, 6); } /* Check DMA transfer for DMAREAD_STREAM commands */ -static int gdc_check_dma_transfer(int f, int *size) { - MAKE_SYSCALL(return, f, size, 7); +static int gdc_check_dma_transfer(gdc_cmd_hnd_t hnd, int *size) { + MAKE_SYSCALL(return, hnd, size, 7); } /* Setup PIO transfer end callback for PIOREAD_STREAM commands */ @@ -114,13 +120,13 @@ static void gdc_set_pio_callback(uintptr_t callback, void *param) { } /* Request PIO transfer for PIOREAD_STREAM commands */ -static int gdc_req_pio_transfer(int f, int *params) { - MAKE_SYSCALL(return, f, params, 12); +static int gdc_req_pio_transfer(gdc_cmd_hnd_t hnd, int *params) { + MAKE_SYSCALL(return, hnd, params, 12); } /* Check PIO transfer for PIOREAD_STREAM commands */ -static int gdc_check_pio_transfer(int f, int *size) { - MAKE_SYSCALL(return, f, size, 13); +static int gdc_check_pio_transfer(gdc_cmd_hnd_t hnd, int *size) { + MAKE_SYSCALL(return, hnd, size, 13); } #endif @@ -133,48 +139,67 @@ int cdrom_set_sector_size(int size) { } /* Command execution sequence */ -/* XXX: It might make sense to have a version of this that takes a timeout. */ int cdrom_exec_cmd(int cmd, void *param) { + return cdrom_exec_cmd_timed(cmd, param, 0); +} + +int cdrom_exec_cmd_timed(int cmd, void *param, int timeout) { int status[4] = { 0, /* Error code 1 */ 0, /* Error code 2 */ 0, /* Transfered size */ 0 /* ATA status waiting */ }; - int f, n; + gdc_cmd_hnd_t hnd; + int n, rv = ERR_OK; + uint64_t begin; assert(cmd > 0 && cmd < CMD_MAX); mutex_lock(&_g1_ata_mutex); /* Submit the command */ for(n = 0; n < 10; ++n) { - f = gdc_req_cmd(cmd, param); - if (f > 0) { + hnd = gdc_req_cmd(cmd, param); + if (hnd != 0) { break; } gdc_exec_server(); thd_pass(); } - if(f <= 0) { + if(hnd <= 0) { mutex_unlock(&_g1_ata_mutex); return ERR_SYS; } /* Wait command to finish */ + if(timeout) { + begin = timer_ms_gettime64(); + } do { gdc_exec_server(); - n = gdc_get_cmd_stat(f, status); + n = gdc_get_cmd_stat(hnd, status); if(n != PROCESSING && n != BUSY) { break; } + if(timeout) { + if((timer_ms_gettime64() - begin) >= (unsigned)timeout) { + gdc_abort_cmd(hnd); + gdc_exec_server(); + rv = ERR_TIMEOUT; + dbglog(DBG_ERROR, "cdrom_exec_cmd_timed: Timeout exceeded\n"); + break; + } + } thd_pass(); } while(1); mutex_unlock(&_g1_ata_mutex); - if(n == COMPLETED || n == STREAMING) + if(rv != ERR_OK) + return rv; + else if(n == COMPLETED || n == STREAMING) return ERR_OK; else if(n == NO_ACTIVE) return ERR_NO_ACTIVE; @@ -209,7 +234,15 @@ int cdrom_get_status(int *status, int *disc_type) { mutex_lock(&_g1_ata_mutex); } - rv = gdc_get_drv_stat(params); + do { + rv = gdc_get_drv_stat(params); + + if(rv != BUSY) { + break; + } + thd_pass(); + } while(1); + mutex_unlock(&_g1_ata_mutex); if(rv >= 0) { @@ -282,32 +315,10 @@ int cdrom_reinit(void) { /* Enhanced cdrom_reinit, takes the place of the old 'sector_size' function */ int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { - int r = -1; - int timeout; - - /* Try a few times; it might be busy. If it's still busy - after this loop then it's probably really dead. */ - timeout = 10 * 1000 / 20; /* 10 second timeout */ - - while(timeout > 0) { - r = cdrom_exec_cmd(CMD_INIT, NULL); - - if(r == 0) break; - - if(r == ERR_NO_DISC || r == ERR_SYS) { - return r; - } + int r; + r = cdrom_exec_cmd_timed(CMD_INIT, NULL, 10000); - /* Still trying.. sleep a bit and check again */ - thd_sleep(20); - timeout--; - } - - if(timeout <= 0) { - mutex_lock(&_g1_ata_mutex); - /* Send an abort since we're giving up waiting for the init */ - gdc_abort_cmd(CMD_INIT); - mutex_unlock(&_g1_ata_mutex); + if(r == ERR_NO_DISC || r == ERR_SYS || r == ERR_TIMEOUT) { return r; } @@ -457,9 +468,10 @@ int cdrom_spin_down(void) { /* Initialize: assume no threading issues */ int cdrom_init(void) { - uint32 p; - volatile uint32 *react = (uint32 *)0xa05f74e4, - *bios = (uint32 *)0xa0000000; + int status, disc_type; + uint32_t p; + volatile uint32_t *react = (uint32_t *)(0x005f74e4 | MEM_AREA_P2_BASE); + volatile uint32_t *bios = (uint32_t *)MEM_AREA_P2_BASE; mutex_lock(&_g1_ata_mutex); @@ -469,7 +481,7 @@ int cdrom_init(void) { hardware is fitted with custom BIOS using magic bootstrap which can and must pass controller verification with only the first 1024 bytes */ - if((*(uint16 *)0xa0000000) == 0xe6ff) { + if((*(uint16_t *)MEM_AREA_P2_BASE) == 0xe6ff) { *react = 0x3ff; for(p = 0; p < 0x400 / sizeof(bios[0]); p++) { (void)bios[p]; @@ -482,11 +494,18 @@ int cdrom_init(void) { } /* Reset system functions */ + gdc_reset(); gdc_init_system(); mutex_unlock(&_g1_ata_mutex); - /* Do an initial initialization */ - cdrom_reinit(); + cdrom_get_status(&status, &disc_type); + + if(status < CD_STATUS_OPEN && disc_type > CD_CDDA && disc_type < CD_FAIL) { + /* Do an initial initialization */ + cdrom_reinit(); + } else { + dbglog(DBG_INFO, "cdrom_init: No disc inserted\n"); + } return 0; } diff --git a/kernel/arch/dreamcast/include/dc/cdrom.h b/kernel/arch/dreamcast/include/dc/cdrom.h index 8bf16b4..b50d1ce 100644 --- a/kernel/arch/dreamcast/include/dc/cdrom.h +++ b/kernel/arch/dreamcast/include/dc/cdrom.h @@ -83,6 +83,7 @@ __BEGIN_DECLS #define ERR_SYS 3 /**< \brief System error */ #define ERR_ABORTED 4 /**< \brief Command aborted */ #define ERR_NO_ACTIVE 5 /**< \brief System inactive? */ +#define ERR_TIMEOUT 6 /**< \brief Aborted due to timeout */ /** @} */ /** \defgroup cd_cmd_status CD-ROM Command Status responses @@ -182,6 +183,7 @@ __BEGIN_DECLS #define CD_STATUS_NO_DISC 7 /**< \brief No disc inserted */ #define CD_STATUS_RETRY 8 /**< \brief Retry is needed */ #define CD_STATUS_ERROR 9 /**< \brief System error */ +#define CD_STATUS_FATAL 12 /**< \brief Need reset syscalls */ /** @} */ /** \defgroup cd_disc_types CD-ROM drive disc types @@ -190,11 +192,12 @@ __BEGIN_DECLS the cdrom_get_status() function. @{ */ -#define CD_CDDA 0 /**< \brief Audio CD (Red book) */ +#define CD_CDDA 0x00 /**< \brief Audio CD (Red book) or no disc */ #define CD_CDROM 0x10 /**< \brief CD-ROM or CD-R (Yellow book) */ #define CD_CDROM_XA 0x20 /**< \brief CD-ROM XA (Yellow book extension) */ #define CD_CDI 0x30 /**< \brief CD-i (Green book) */ #define CD_GDROM 0x80 /**< \brief GD-ROM */ +#define CD_FAIL 0xf0 /**< \brief Need reset syscalls */ /** @} */ /** \brief TOC structure returned by the BIOS. @@ -255,7 +258,7 @@ int cdrom_set_sector_size(int size); /** \brief Execute a CD-ROM command. This function executes the specified command using the BIOS syscall for - executing GD-ROM commands. This is now thread-safe to be called by users. + executing GD-ROM commands. \param cmd The command number to execute. \param param Data to pass to the syscall. @@ -264,6 +267,19 @@ int cdrom_set_sector_size(int size); */ int cdrom_exec_cmd(int cmd, void *param); +/** \brief Execute a CD-ROM command with timeout. + + This function executes the specified command using the BIOS syscall for + executing GD-ROM commands with timeout. + + \param cmd The command number to execute. + \param param Data to pass to the syscall. + \param timeout Timeout in milliseconds. + + \return \ref cd_cmd_response +*/ +int cdrom_exec_cmd_timed(int cmd, void *param, int timeout); + /** \brief Get the status of the GD-ROM drive. \param status Space to return the drive's status. diff --git a/utils/elf2bin/elf2bin b/utils/elf2bin/elf2bin new file mode 100644 index 0000000..b4ffbfa --- /dev/null +++ b/utils/elf2bin/elf2bin @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# elf2bin +# script to convert an elf program to a bin(ary) program +# then you can use 'scramble' to generate a '1ST_READ.BIN' file +# this script is basically using 'strip' and 'objcopy'. + +me=`basename "$0"` + +# Retrieve args +source=$1 +destination=$2 + +# Check if we want to overwrite (force) the destination file +force_switch=$3 +if [ "$destination" = "-f" ] || [ "$force_switch" = "-f" ]; then + force_switch=1 + unset destination +else + force_switch=0 +fi + +# Check for args +if [ -z "$source" ]; then + echo "usage: $me <binary.elf> [binary.bin] [-f]"; + exit 1 +fi + +# Check for source file existence +if [ ! -f "$source" ]; then + echo "$me: error: file not found: $source"; + exit 2 +fi + +# Compute destination file if destination arg is not passed +if [ -z "$destination" ]; then + destination="${source%.*}.bin" +fi + +# Check if destination file exists (or ignore if requested) +if [ -f "$destination" ] && [ "$force_switch" = "0" ]; then + echo "$me: error: file already exists: $destination"; + exit 3 +fi + +# Compute a temporary filename used to work on the elf file +workdir=$(mktemp -d) +tmpfile="$workdir/$(basename $0).$$.tmp" + +# Do the conversion +cp "$source" "$tmpfile" +kos-objcopy -O binary "$tmpfile" "$destination" + +# Remove the temporary directory +if [ -d "$workdir" ]; then + rm -r "$workdir" +fi hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-20 01:01: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 92a76c016c9d0c89e5f8613189ca6ba7bff1616e (commit) via b575f6f941b3b7b0be12e14b4b32673506954888 (commit) from f8644374d6beaf41365e30d185cb455f340c7014 (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 92a76c016c9d0c89e5f8613189ca6ba7bff1616e Merge: f864437 b575f6f Author: Lawrence Sebald <ljs...@us...> Date: Sun Nov 19 19:59:02 2023 -0500 Merge pull request #375 from DC-SWAT/g1_ata_select Fixed ATA device selection and mutex. commit b575f6f941b3b7b0be12e14b4b32673506954888 Author: DC-SWAT <sw...@21...> Date: Sun Nov 19 17:18:17 2023 +0700 Fixed ATA device selection and mutex. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 69 +++++++--------------------------- kernel/arch/dreamcast/hardware/g1ata.c | 5 +++ 2 files changed, 18 insertions(+), 56 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index c0ad6a9..870c5fe 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -125,7 +125,7 @@ static int gdc_check_pio_transfer(int f, int *size) { #endif /* The G1 ATA access mutex */ -mutex_t _g1_ata_mutex = RECURSIVE_MUTEX_INITIALIZER; +mutex_t _g1_ata_mutex = MUTEX_INITIALIZER; /* Shortcut to cdrom_reinit_ex. Typically this is the only thing changed. */ int cdrom_set_sector_size(int size) { @@ -146,9 +146,6 @@ int cdrom_exec_cmd(int cmd, void *param) { assert(cmd > 0 && cmd < CMD_MAX); mutex_lock(&_g1_ata_mutex); - /* Make sure to select the GD-ROM drive. */ - g1_ata_select_device(G1_ATA_MASTER); - /* Submit the command */ for(n = 0; n < 10; ++n) { f = gdc_req_cmd(cmd, param); @@ -197,8 +194,8 @@ int cdrom_exec_cmd(int cmd, void *param) { /* Return the status of the drive as two integers (see constants) */ int cdrom_get_status(int *status, int *disc_type) { - int rv = ERR_OK; - uint32 params[2]; + int rv = ERR_OK; + uint32_t params[2]; /* We might be called in an interrupt to check for ISO cache flushing, so make sure we're not interrupting something @@ -212,9 +209,6 @@ int cdrom_get_status(int *status, int *disc_type) { mutex_lock(&_g1_ata_mutex); } - /* Make sure to select the GD-ROM drive. */ - g1_ata_select_device(G1_ATA_MASTER); - rv = gdc_get_drv_stat(params); mutex_unlock(&_g1_ata_mutex); @@ -244,10 +238,9 @@ int cdrom_change_dataype(int sector_part, int cdxa, int sector_size) { /* Wrapper for the change datatype syscall */ int cdrom_change_datatype(int sector_part, int cdxa, int sector_size) { int rv = ERR_OK; - uint32 params[4]; + uint32_t params[4]; mutex_lock(&_g1_ata_mutex); - g1_ata_select_device(G1_ATA_MASTER); /* Check if we are using default params */ if(sector_size == 2352) { @@ -292,26 +285,16 @@ int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { int r = -1; int timeout; - mutex_lock(&_g1_ata_mutex); - /* Try a few times; it might be busy. If it's still busy after this loop then it's probably really dead. */ timeout = 10 * 1000 / 20; /* 10 second timeout */ - /* Make sure to select the GD-ROM drive. */ - g1_ata_select_device(G1_ATA_MASTER); - while(timeout > 0) { r = cdrom_exec_cmd(CMD_INIT, NULL); if(r == 0) break; - if(r == ERR_NO_DISC) { - mutex_unlock(&_g1_ata_mutex); - return r; - } - else if(r == ERR_SYS) { - mutex_unlock(&_g1_ata_mutex); + if(r == ERR_NO_DISC || r == ERR_SYS) { return r; } @@ -321,6 +304,7 @@ int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { } if(timeout <= 0) { + mutex_lock(&_g1_ata_mutex); /* Send an abort since we're giving up waiting for the init */ gdc_abort_cmd(CMD_INIT); mutex_unlock(&_g1_ata_mutex); @@ -328,7 +312,6 @@ int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { } r = cdrom_change_datatype(sector_part, cdxa, sector_size); - mutex_unlock(&_g1_ata_mutex); return r; } @@ -337,17 +320,14 @@ int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { int cdrom_read_toc(CDROM_TOC *toc_buffer, int session) { struct { int session; - void *buffer; + void *buffer; } params; int rv; params.session = session; params.buffer = toc_buffer; - mutex_lock(&_g1_ata_mutex); - rv = cdrom_exec_cmd(CMD_GETTOC2, ¶ms); - mutex_unlock(&_g1_ata_mutex); return rv; } @@ -356,17 +336,15 @@ int cdrom_read_toc(CDROM_TOC *toc_buffer, int session) { int cdrom_read_sectors_ex(void *buffer, int sector, int cnt, int mode) { struct { int sec, num; - void *buffer; - int dunno; + void *buffer; + int is_test; } params; int rv = ERR_OK; params.sec = sector; /* Starting sector */ params.num = cnt; /* Number of sectors */ params.buffer = buffer; /* Output buffer */ - params.dunno = 0; /* ? */ - - mutex_lock(&_g1_ata_mutex); + params.is_test = 0; /* Enable test mode */ /* The DMA mode blocks the thread it is called in by the way we execute gd syscalls. It does however allow for other threads to run. */ @@ -378,7 +356,6 @@ int cdrom_read_sectors_ex(void *buffer, int sector, int cnt, int mode) { else if(mode == CDROM_READ_PIO) rv = cdrom_exec_cmd(CMD_PIOREAD, ¶ms); - mutex_unlock(&_g1_ata_mutex); return rv; } @@ -397,16 +374,14 @@ int cdrom_get_subcode(void *buffer, int buflen, int which) { struct { int which; int buflen; - void *buffer; + void *buffer; } params; int rv; params.which = which; params.buflen = buflen; params.buffer = buffer; - mutex_lock(&_g1_ata_mutex); rv = cdrom_exec_cmd(CMD_GETSCD, ¶ms); - mutex_unlock(&_g1_ata_mutex); return rv; } @@ -451,48 +426,32 @@ int cdrom_cdda_play(uint32 start, uint32 end, uint32 repeat, int mode) { params.end = end; params.repeat = repeat; - mutex_lock(&_g1_ata_mutex); - if(mode == CDDA_TRACKS) rv = cdrom_exec_cmd(CMD_PLAY, ¶ms); else if(mode == CDDA_SECTORS) rv = cdrom_exec_cmd(CMD_PLAY2, ¶ms); - mutex_unlock(&_g1_ata_mutex); - return rv; } /* Pause CDDA audio playback */ int cdrom_cdda_pause(void) { int rv; - - mutex_lock(&_g1_ata_mutex); rv = cdrom_exec_cmd(CMD_PAUSE, NULL); - mutex_unlock(&_g1_ata_mutex); - return rv; } /* Resume CDDA audio playback */ int cdrom_cdda_resume(void) { int rv; - - mutex_lock(&_g1_ata_mutex); rv = cdrom_exec_cmd(CMD_RELEASE, NULL); - mutex_unlock(&_g1_ata_mutex); - return rv; } /* Spin down the CD */ int cdrom_spin_down(void) { int rv; - - mutex_lock(&_g1_ata_mutex); rv = cdrom_exec_cmd(CMD_STOP, NULL); - mutex_unlock(&_g1_ata_mutex); - return rv; } @@ -502,6 +461,8 @@ int cdrom_init(void) { volatile uint32 *react = (uint32 *)0xa05f74e4, *bios = (uint32 *)0xa0000000; + mutex_lock(&_g1_ata_mutex); + /* Reactivate drive: send the BIOS size and then read each word across the bus so the controller can verify it. If first bytes are 0xe6ff instead of usual 0xe3ff, then @@ -520,10 +481,6 @@ int cdrom_init(void) { } } - mutex_lock(&_g1_ata_mutex); - /* Make sure to select the GD-ROM drive. */ - g1_ata_select_device(G1_ATA_MASTER); - /* Reset system functions */ gdc_init_system(); mutex_unlock(&_g1_ata_mutex); diff --git a/kernel/arch/dreamcast/hardware/g1ata.c b/kernel/arch/dreamcast/hardware/g1ata.c index f2d1567..a4d227d 100644 --- a/kernel/arch/dreamcast/hardware/g1ata.c +++ b/kernel/arch/dreamcast/hardware/g1ata.c @@ -206,6 +206,8 @@ inline int g1_ata_mutex_lock(void) { } inline int g1_ata_mutex_unlock(void) { + /* Make sure to select the GD-ROM drive back. */ + g1_ata_select_device(G1_ATA_MASTER); return mutex_unlock(&_g1_ata_mutex); } @@ -222,6 +224,9 @@ static void g1_dma_irq_hnd(uint32 code) { } dma_in_progress = 0; + + /* Make sure to select the GD-ROM drive back. */ + g1_ata_select_device(G1_ATA_MASTER); mutex_unlock_as_thread(&_g1_ata_mutex, dma_thd); } } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-11-18 19:41:43
|
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 f8644374d6beaf41365e30d185cb455f340c7014 (commit) via 7837ad40d53f11e078cbfa668594c98be2fd75b5 (commit) from ed6c8f946d1ff8f59de05f02e8772b81298cae59 (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 f8644374d6beaf41365e30d185cb455f340c7014 Merge: ed6c8f9 7837ad4 Author: Falco Girgis <gyr...@gm...> Date: Sat Nov 18 13:41:16 2023 -0600 Merge pull request #373 from KallistiOS/netinet-udp-h Add <netinet/udp.h> and <netinet/udplite.h> headers commit 7837ad40d53f11e078cbfa668594c98be2fd75b5 Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 18 14:28:25 2023 -0500 Add <netinet/udp.h> and <netinet/udplite.h> headers. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 2 ++ include/netinet/in.h | 35 +++------------------------------- include/netinet/udp.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++ include/netinet/udplite.h | 48 +++++++++++++++++++++++++++++++++++++++++++++++ kernel/net/net_udp.c | 2 ++ 5 files changed, 102 insertions(+), 32 deletions(-) create mode 100644 include/netinet/udp.h create mode 100644 include/netinet/udplite.h diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 6cfd0bb..26be8ae 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -205,6 +205,8 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Refactored sfx and streaming to add SQ fast path [RR] - DC Added 4/8-bit wav support to sfx and streaming [RR] - *** Added <netinet/tcp.h> header file and required option [LS] +- *** Added <netinet/udp.h> and <netinet/udplite.h> headers and move the related + content from <netinet/in.h> [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/netinet/in.h b/include/netinet/in.h index 1ddd45b..765967b 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -201,7 +201,9 @@ extern const struct in6_addr in6addr_loopback; @{ */ + #define IP_TTL 24 /**< \brief TTL for unicast (get/set) */ + /** @} */ /** \defgroup ipv6_opts IPv6 protocol level options @@ -220,6 +222,7 @@ extern const struct in6_addr in6addr_loopback; @{ */ + #define IPV6_JOIN_GROUP 17 /**< \brief Join a multicast group (set) */ #define IPV6_LEAVE_GROUP 18 /**< \brief Leave a multicast group (set) */ #define IPV6_MULTICAST_HOPS 19 /**< \brief Hop limit for multicast (get/set) */ @@ -227,39 +230,7 @@ extern const struct in6_addr in6addr_loopback; #define IPV6_MULTICAST_LOOP 21 /**< \brief Multicasts loopback (get/set) */ #define IPV6_UNICAST_HOPS 22 /**< \brief Hop limit for unicast (get/set) */ #define IPV6_V6ONLY 23 /**< \brief IPv6 only -- no IPv4 (get/set) */ -/** @} */ - -/** \defgroup udp_opts UDP protocol level options - - These are the various socket-level options that can be accessed with the - setsockopt() and getsockopt() functions for the IPPROTO_UDP level value. - - \see so_opts - \see ipv4_opts - \see ipv6_opts - \see udplite_opts - \see tcp_opts - - @{ -*/ -#define UDP_NOCHECKSUM 25 /**< \brief Don't calculate UDP checksums */ -/** @} */ - -/** \defgroup udplite_opts UDP-Lite protocol level options - - These are the various socket-level options that can be accessed with the - setsockopt() and getsockopt() functions for the IPPROTO_UDPLITE level value. - - \see so_opts - \see ipv4_opts - \see ipv6_opts - \see udp_opts - \see tcp_opts - @{ -*/ -#define UDPLITE_SEND_CSCOV 26 /**< \brief Sending checksum coverage. */ -#define UDPLITE_RECV_CSCOV 27 /**< \brief Receiving checksum coverage. */ /** @} */ /** \brief Test if an IPv6 Address is unspecified. diff --git a/include/netinet/udp.h b/include/netinet/udp.h new file mode 100644 index 0000000..93e2099 --- /dev/null +++ b/include/netinet/udp.h @@ -0,0 +1,47 @@ +/* KallistiOS ##version## + + netinet/udp.h + Copyright (C) 2014, 2023 Lawrence Sebald + +*/ + +/** \file netinet/udp.h + \brief Definitions for the User Datagram Protocol. + + This file contains definitions related to the User Datagram Protocol (UDP). + UDP is a connectionless datagram delivery protocol, which provides optional + datagram integrity validation. + + UDP is described in RFC 768. + + \author Lawrence Sebald +*/ + +#ifndef __NETINET_UDP_H +#define __NETINET_UDP_H + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +/** \defgroup udp_opts UDP protocol level options + + These are the various socket-level options that can be accessed with the + setsockopt() and getsockopt() functions for the IPPROTO_UDP level value. + + \see so_opts + \see ipv4_opts + \see ipv6_opts + \see udplite_opts + \see tcp_opts + + @{ +*/ + +#define UDP_NOCHECKSUM 25 /**< \brief Don't calculate UDP checksums */ + +/** @} */ + +__END_DECLS + +#endif /* !__NETINET_UDP_H */ diff --git a/include/netinet/udplite.h b/include/netinet/udplite.h new file mode 100644 index 0000000..b1f4daa --- /dev/null +++ b/include/netinet/udplite.h @@ -0,0 +1,48 @@ +/* KallistiOS ##version## + + netinet/udplite.h + Copyright (C) 2014, 2023 Lawrence Sebald + +*/ + +/** \file netinet/udplite.h + \brief Definitions for UDP-Lite. + + This file contains definitions related to UDP-Lite, a version of UDP that + allows for partial checksum coverage (rather than requiring that either all + or none of the packet is covered as does UDP). + + UDP-Lite is described in RFC 3828. + + \author Lawrence Sebald +*/ + +#ifndef __NETINET_UDPLITE_H +#define __NETINET_UDPLITE_H + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +/** \defgroup udplite_opts UDP-Lite protocol level options + + These are the various socket-level options that can be accessed with the + setsockopt() and getsockopt() functions for the IPPROTO_UDPLITE level value. + + \see so_opts + \see ipv4_opts + \see ipv6_opts + \see udp_opts + \see tcp_opts + + @{ +*/ + +#define UDPLITE_SEND_CSCOV 26 /**< \brief Sending checksum coverage. */ +#define UDPLITE_RECV_CSCOV 27 /**< \brief Receiving checksum coverage. */ + +/** @} */ + +__END_DECLS + +#endif /* !__NETINET_UDPLITE_H */ diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index af5403f..dcfe97e 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -19,6 +19,8 @@ #include <kos/fs_socket.h> #include <arch/irq.h> #include <sys/socket.h> +#include <netinet/udp.h> +#include <netinet/udplite.h> #include "net_ipv4.h" #include "net_ipv6.h" hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-11-18 16:13:57
|
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 ed6c8f946d1ff8f59de05f02e8772b81298cae59 (commit) via 1f7aa3f098a59d730c2efaf521d6bc0bbfd6ff36 (commit) via 659799bf6e56a0c00da7fe2a0fadd774014a6842 (commit) via 55f0e708b11ca73e55fa251df621f0cb1470f24e (commit) from f75efb895335970db3a4019f08457b196c985ae1 (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 ed6c8f946d1ff8f59de05f02e8772b81298cae59 Merge: f75efb8 1f7aa3f Author: Falco Girgis <gyr...@gm...> Date: Sat Nov 18 10:13:23 2023 -0600 Merge pull request #372 from KallistiOS/netinet-tcp-h Add <netinet/tcp.h> header commit 1f7aa3f098a59d730c2efaf521d6bc0bbfd6ff36 Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 18 11:12:13 2023 -0500 Update CHANGELOG commit 659799bf6e56a0c00da7fe2a0fadd774014a6842 Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 18 11:02:59 2023 -0500 Add TCP_NODELAY into setsockopt/getsockopt. Note that the option is effectively ignored as we do not implement Nagle's algorithm. commit 55f0e708b11ca73e55fa251df621f0cb1470f24e Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 18 11:02:29 2023 -0500 Add netinet/tcp.h file and update documentation to reflect it. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 4 +++- include/netinet/in.h | 4 ++++ include/netinet/tcp.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/net/net_tcp.c | 36 ++++++++++++++++++++++++++++-------- 4 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 include/netinet/tcp.h diff --git a/doc/CHANGELOG b/doc/CHANGELOG index c90e2ba..6cfd0bb 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -192,7 +192,8 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added toolchain and KOS support for C/C++ compiler-level TLS [CP && FG] - DC Added vmu functions to check/enable/disable the extra 41 blocks [AB] - *** Added driver for the SH4's Watchdog Timer peripheral [FG] -- DC Added Moop powered fast path to sq_cpy, added TapamN pvr related sq functions [AB] +- DC Added Moop powered fast path to sq_cpy, added TapamN pvr related sq + functions [AB] - DC Garbage-collect network stack [PC] - DC Rework romdisks [PC] - DC Refactored g2bus API, converted magic values to macros, added @@ -203,6 +204,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Optimized separating stereo PCM [RR] - DC Refactored sfx and streaming to add SQ fast path [RR] - DC Added 4/8-bit wav support to sfx and streaming [RR] +- *** Added <netinet/tcp.h> header file and required option [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/netinet/in.h b/include/netinet/in.h index f7d12e4..1ddd45b 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -197,6 +197,7 @@ extern const struct in6_addr in6addr_loopback; \see ipv6_opts \see udp_opts \see udplite_opts + \see tcp_opts @{ */ @@ -215,6 +216,7 @@ extern const struct in6_addr in6addr_loopback; \see ipv4_opts \see udp_opts \see udplite_opts + \see tcp_opts @{ */ @@ -236,6 +238,7 @@ extern const struct in6_addr in6addr_loopback; \see ipv4_opts \see ipv6_opts \see udplite_opts + \see tcp_opts @{ */ @@ -251,6 +254,7 @@ extern const struct in6_addr in6addr_loopback; \see ipv4_opts \see ipv6_opts \see udp_opts + \see tcp_opts @{ */ diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h new file mode 100644 index 0000000..7c74be2 --- /dev/null +++ b/include/netinet/tcp.h @@ -0,0 +1,51 @@ +/* KallistiOS ##version## + + netinet/tcp.h + Copyright (C) 2023 Lawrence Sebald + +*/ + +/** \file netinet/tcp.h + \brief Definitions for the Transmission Control Protocol. + + This file contains the standard definitions (as directed by the Open Group + Base Specifications Issue 7, 2018 Edition aka POSIX 2017) for functionality + of the Transmission Control Protocol. + This does is not guaranteed to have everything that one might have in a + fully-standard compliant implementation of the POSIX standard. + + \author Lawrence Sebald +*/ + +#ifndef __NETINET_TCP_H +#define __NETINET_TCP_H + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +/** \defgroup tcp_opts TCP protocol level options + + These are the various socket-level optoins that can be accessed with the + setsockopt() and getsockopt() fnctions for the IPPROTO_TCP level value. + + All options listed here are at least guaranteed to be accepted by + setsockopt() and getsockopt() for IPPROTO_TCP, however they are not + guaranteed to be implemented in any meaningful way. + + \see so_opts + \see ipv4_opts + \see ipv6_opts + \see udp_opts + \see udplite_opts + + @{ +*/ + +#define TCP_NODELAY 1 /**< \brief Don't delay to coalesce. */ + +/** @} */ + +__END_DECLS + +#endif /* !__NETINET_TCP_H */ diff --git a/kernel/net/net_tcp.c b/kernel/net/net_tcp.c index 4250b2d..6991a6e 100644 --- a/kernel/net/net_tcp.c +++ b/kernel/net/net_tcp.c @@ -11,6 +11,7 @@ #include <stdint.h> #include <poll.h> #include <sys/socket.h> +#include <netinet/tcp.h> #include <kos/fs.h> #include <kos/net.h> @@ -1708,7 +1709,6 @@ static int net_tcp_getsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IP: - if(sock->domain != AF_INET) goto ret_inval; @@ -1721,7 +1721,6 @@ static int net_tcp_getsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IPV6: - if(sock->domain != AF_INET6) goto ret_inval; @@ -1734,6 +1733,17 @@ static int net_tcp_getsockopt(net_socket_t *hnd, int level, int option_name, tmp = !!(sock->flags & FS_SOCKET_V6ONLY); goto copy_int; } + + break; + + case IPPROTO_TCP: + switch(option_name) { + case TCP_NODELAY: + tmp = 1; + goto copy_int; + } + + break; } /* If it wasn't handled, return that error. */ @@ -1803,7 +1813,6 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, switch(level) { case SOL_SOCKET: - switch(option_name) { case SO_ACCEPTCONN: case SO_ERROR: @@ -1853,13 +1862,11 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IP: - if(sock->domain != AF_INET) goto ret_inval; switch(option_name) { case IP_TTL: - if(option_len != sizeof(int)) goto ret_inval; @@ -1878,13 +1885,11 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, break; case IPPROTO_IPV6: - if(sock->domain != AF_INET6) goto ret_inval; switch(option_name) { case IPV6_UNICAST_HOPS: - if(option_len != sizeof(int)) goto ret_inval; @@ -1900,7 +1905,6 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, goto ret_success; case IPV6_V6ONLY: - if(option_len != sizeof(int)) goto ret_inval; @@ -1914,6 +1918,22 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, goto ret_success; } + break; + + case IPPROTO_TCP: + switch(option_name) { + case TCP_NODELAY: + if(option_len != sizeof(int)) + goto ret_inval; + + tmp = *((int *)option_value); + + if(tmp == 0) + goto ret_inval; + + goto ret_success; + } + break; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-18 15:21: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 f75efb895335970db3a4019f08457b196c985ae1 (commit) via 02b916e8094ed7e09309ea85f7f045fb3dd266c8 (commit) via 5fb12dea49ee7b9db9e27785b52ca56e2fa8b76f (commit) via 4e833ec168513ad709c093adc2ec32a585a2c1a3 (commit) from 932513b05e6f234ddde655a628addb01e9e75753 (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 f75efb895335970db3a4019f08457b196c985ae1 Author: Falco Girgis <gyr...@gm...> Date: Sat Nov 18 09:20:17 2023 -0600 C++20 Concurrency Test/Example (#315) Add C++ 20 concurrency test/example. commit 02b916e8094ed7e09309ea85f7f045fb3dd266c8 Author: ross.codes <ros...@go...> Date: Sat Nov 18 15:18:17 2023 +0000 PVR: Add option to specify additional OPBs for TA overflow (#333) * Add option to specify additional OPBs for TA overflow * Fix default OPB allocation when OPB overflow is set to 0 commit 5fb12dea49ee7b9db9e27785b52ca56e2fa8b76f Merge: 932513b 4e833ec Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 18 10:16:41 2023 -0500 Merge pull request #364 from DC-SWAT/snd_thread_safe Thread-safe audio fixes commit 4e833ec168513ad709c093adc2ec32a585a2c1a3 Author: DC-SWAT <sw...@21...> Date: Thu Nov 16 16:57:06 2023 +0700 Thread-safe audio fixes ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/cpp/Makefile | 5 +- examples/dreamcast/cpp/concurrency/Makefile | 29 + examples/dreamcast/cpp/concurrency/concurrency.cpp | 743 +++++++++++++++++++++ include/kos/opts.h | 3 + kernel/arch/dreamcast/hardware/pvr/pvr_buffers.c | 16 +- .../dreamcast/hardware/pvr/pvr_init_shutdown.c | 31 +- kernel/arch/dreamcast/hardware/pvr/pvr_internal.h | 4 + kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 39 +- kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 20 +- kernel/arch/dreamcast/hardware/vblank.c | 8 +- kernel/arch/dreamcast/include/dc/asic.h | 36 +- kernel/arch/dreamcast/include/dc/pvr.h | 13 +- kernel/arch/dreamcast/sound/snd_mem.c | 69 +- kernel/arch/dreamcast/sound/snd_stream.c | 19 +- 14 files changed, 988 insertions(+), 47 deletions(-) create mode 100644 examples/dreamcast/cpp/concurrency/Makefile create mode 100644 examples/dreamcast/cpp/concurrency/concurrency.cpp diff --git a/examples/dreamcast/cpp/Makefile b/examples/dreamcast/cpp/Makefile index d50bbcc..135a427 100644 --- a/examples/dreamcast/cpp/Makefile +++ b/examples/dreamcast/cpp/Makefile @@ -1,7 +1,7 @@ # KallistiOS ##version## # # examples/dreamcast/cpp/Makefile -# (c)2001-2002 Megan Potter +# Copyright (C) 2001-2002 Megan Potter # all: @@ -10,6 +10,7 @@ all: $(KOS_MAKE) -C clock $(KOS_MAKE) -C modplug_test $(KOS_MAKE) -C out_of_memory + $(KOS_MAKE) -C concurrency clean: $(KOS_MAKE) -C gltest clean @@ -17,6 +18,7 @@ clean: $(KOS_MAKE) -C clock clean $(KOS_MAKE) -C modplug_test clean $(KOS_MAKE) -C out_of_memory clean + $(KOS_MAKE) -C concurrency clean dist: $(KOS_MAKE) -C gltest dist @@ -24,5 +26,6 @@ dist: $(KOS_MAKE) -C clock dist $(KOS_MAKE) -C modplug_test dist $(KOS_MAKE) -C out_of_memory dist + $(KOS_MAKE) -C concurrency dist diff --git a/examples/dreamcast/cpp/concurrency/Makefile b/examples/dreamcast/cpp/concurrency/Makefile new file mode 100644 index 0000000..65c7765 --- /dev/null +++ b/examples/dreamcast/cpp/concurrency/Makefile @@ -0,0 +1,29 @@ +# +# C++ Concurrency Test/Example +# (c) 2023 Falco Girgis +# + +TARGET = concurrency.elf +OBJS = concurrency.o +KOS_CPPFLAGS += -std=c++20 + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: + -rm -f $(TARGET) $(OBJS) + +rm-elf: + -rm -f $(TARGET) + +$(TARGET): $(OBJS) + kos-c++ -o $(TARGET) $(OBJS) -lm + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: + rm -f $(OBJS) + $(KOS_STRIP) $(TARGET) + diff --git a/examples/dreamcast/cpp/concurrency/concurrency.cpp b/examples/dreamcast/cpp/concurrency/concurrency.cpp new file mode 100644 index 0000000..e4892ae --- /dev/null +++ b/examples/dreamcast/cpp/concurrency/concurrency.cpp @@ -0,0 +1,743 @@ +/* KallistiOS ##version## + + examples/dreamcast/cpp/concurrency/concurrency.cpp + + Copyright (C) 2023 Falco Girgis + +*/ + +/* + This file serves as both an example of using and as validation test suite + for all of standard C++ concurrency, through C++20. It is composed of 8 + standalone test cases, which have been either created from scratch or have + been adopted from examples on cppreference.com. These test cases aim to + flex the various synchronization primitives and threading constructs, + demonstrating their usage and ensuring that KOS, the toolchain, and + libstdc++ are behaving properly. After the tests run, a final result + message will be displayed, indicating whether the test suite passed or + failed. + + The following constructs are tested: + - atomic + - thread_local + - async + - thread/jthread + - mutex + - shared_mutex + - unique_lock + - lock_guard + - future + - promise + - semaphore + - latch + - shared_lock + - condition_variable + - scoped_lock + - barrier + - stop_source + - stop_token + - coroutine + - syncstream +*/ + +#include <iostream> +#include <atomic> +#include <array> +#include <future> +#include <chrono> +#include <functional> +#include <coroutine> +#include <semaphore> +#include <thread> +#include <barrier> +#include <cstdlib> +#include <latch> +#include <syncstream> +#include <shared_mutex> +#include <condition_variable> +#include <stop_token> +#include <span> +#include <random> +#include <exception> +#include <string> + +#include <arch/wdt.h> + +// 20 seconds in us +inline constexpr unsigned WATCHDOG_TIMEOUT = (20 * 1000 * 1000); +// Number of threads to spawn -- each of which runs the entire test suite +inline constexpr int THREAD_COUNT = 10; + +using namespace std::chrono_literals; + +// Exception type for test-case errors +class TestCaseException: public std::exception { + std::string what_; + public: + TestCaseException(std::string str) noexcept: + what_(std::move(str)) {} + + TestCaseException& + operator=(const TestCaseException& other) noexcept = default; + + const char* what() const noexcept override { + return what_.c_str(); + } +}; + +/* ===== TEST CASE 1: std::binary_semaphore ===== + Simply spawns a worker thread and ping-pongs acquiring + and releasing two binary_semaphores between the worker and + parent thread. +*/ +static void run_semaphore(std::binary_semaphore &sem_main_to_thread, + std::binary_semaphore &sem_thread_to_main) { + // wait for a signal from the main proc + // by attempting to decrement the semaphore + sem_main_to_thread.acquire(); + + // this call blocks until the semaphore's count + // is increased from the main proc + + std::cout << "[BINARY_SEMAPHORE] thread: Got the signal" << std::endl; + + // wait for 3 seconds to imitate some work + // being done by the thread + std::this_thread::sleep_for(1ms); + + std::cout << "[BINARY_SEMAPHORE] thread: Send the signal" << std::endl; + + // signal the main proc back + sem_thread_to_main.release(); +} + +static void test_semaphore() { + std::binary_semaphore sem_main_to_thread{0}, sem_thread_to_main{0}; + std::cout << "[BINARY_SEMAPHORE] Starting test." << std::endl; + + // create some worker thread + std::thread thrWorker(run_semaphore, + std::ref(sem_main_to_thread), + std::ref(sem_thread_to_main)); + + std::cout << "[BINARY_SEMAPHORE] main: Send the signal" << std::endl; + + // signal the worker thread to start working + // by increasing the semaphore's count + sem_main_to_thread.release(); + + // wait until the worker thread is done doing the work + // by attempting to decrement the semaphore's count + sem_thread_to_main.acquire(); + + std::cout << "[BINARY_SEMAPHORE] main: Got the signal" << std::endl; + thrWorker.join(); + + std::cout << "[BINARY_SEMAPHORE] Finished test." << std::endl; +} + +/* ===== TEST CASE 2: std::latch ===== + Creates 3 "Job" objects, each of which gets + managed by its own thread. First, the main thread + waits until all job threads have hit a synchronization + point (creating work). Then the workers wait until + the main thread hits a synchronization point to begin + cleaning their work. +*/ +struct LatchJob { + const std::string name; + std::string product{"not worked"}; + std::thread action; +}; + +static void test_latch() { + LatchJob jobs[]{{"Sonic"}, {"Knuckles"}, {"Tails"}}; + + std::cout << "[LATCH] Starting test." << std::endl; + + std::latch work_done{std::size(jobs)}; + std::latch start_clean_up{1}; + + auto work = [&](LatchJob &my_job) { + my_job.product = my_job.name + " worked"; + work_done.count_down(); + start_clean_up.wait(); + my_job.product = my_job.name + " cleaned"; + }; + + std::cout << "[LATCH] Work is starting... " << std::endl; + for (auto &job : jobs) + job.action = std::thread{work, std::ref(job)}; + + work_done.wait(); + std::cout << "[LATCH] done." << std::endl; + for (auto const &job : jobs) + std::cout << "[LATCH] " << job.product << '\n'; + + std::cout << "[LATCH] Workers are cleaning up... "; + start_clean_up.count_down(); + for (auto &job : jobs) + job.action.join(); + + std::cout << "[LATCH] done." << std::endl; + for (auto const& job : jobs) { + if(job.product == "not worked") { + throw TestCaseException("[LATCH] Job failed to produce!"); + } + std::cout << "[LATCH] " << job.product << std::endl; + } + + std::cout << "[LATCH] Finished test." << std::endl; +} + +/* ===== TEST CASE 3: std::shared_lock ===== + Creates a SharedLockCounter in the parent thread, which then + gets passed to two child threads, both of which attempt to + increment its value 3 times and print it. Write operations + are protected via std::unique_locks, while the read operation, + get(), is protected by a std::shared_lock. This models a + traditional "ReadWrite" lock. +*/ + +class SharedLockCounter { +public: + SharedLockCounter() = default; + + // Multiple threads/readers can read the counter's value at the same time. + unsigned int get() const { + std::shared_lock lock(mutex_); + return value_; + } + + // Only one thread/writer can increment/write the counter's value. + void increment() { + std::unique_lock lock(mutex_); + ++value_; + } + + // Only one thread/writer can reset/write the counter's value. + void reset() { + std::unique_lock lock(mutex_); + value_ = 0; + } + +private: + mutable std::shared_mutex mutex_; + unsigned int value_{}; +}; + +static void test_shared_lock() { + SharedLockCounter counter; + + std::cout << "[SHARED_LOCK] Starting test." << std::endl; + + auto increment_and_print = [&counter] { + for(int i{}; i != 3; ++i) { + counter.increment(); + std::osyncstream(std::cout) + << "[SHARED_LOCK] " + << std::this_thread::get_id() << ' ' + << counter.get() << std::endl; + } + }; + + std::thread thread1(increment_and_print); + std::thread thread2(increment_and_print); + + thread1.join(); + thread2.join(); + + if(counter.get() != 6) + throw TestCaseException("[SHARED_LOCK]: Unexpected counter value!"); + + std::cout << "[SHARED_LOCK] Finished test." << std::endl; +} + +/* ===== TEST CASE 4: std::condition_variable ===== + Spawns a worker thread, passing it a state object with both a + mutex and a condition_variable. The parent thread populates the + data field within the state object then uses the condition_variable + to signal to one thread (the child) that its data is ready to process. + The parent thread then waits on the condition_variable, which the + child thread signals back when it is done processing its work data. + + Basically the parent and child threads swap between signalling to + each other to proceed execution via the condition_variable. +*/ +struct CondVarState { + std::mutex m; + std::condition_variable cv; + std::string data; + bool ready = false; + bool processed = false; +}; + +static void run_condition_variable(CondVarState &cond_variable_state) { + // Wait until main() sends data + std::unique_lock lk(cond_variable_state.m); + cond_variable_state.cv.wait(lk, [&]{ return cond_variable_state.ready; }); + + // after the wait, we own the lock. + std::cout << "[COND_VARIABLE]: Worker thread is processing data" << std::endl; + cond_variable_state.data += " after processing"; + + // Send data back to main() + cond_variable_state.processed = true; + std::cout << "[COND_VARIABLE]: Worker thread signals data " + "processing completed" << std::endl; + + // Manual unlocking is done before notifying, to avoid waking up + // the waiting thread only to block again (see notify_one for details) + lk.unlock(); + cond_variable_state.cv.notify_one(); +} + +static void test_condition_variable() { + CondVarState cond_variable_state; + + std::cout << "[COND_VARIABLE] Starting test." << std::endl; + + std::thread worker(run_condition_variable, std::ref(cond_variable_state)); + + cond_variable_state.data = "Example data"; + // send data to the worker thread + { + std::lock_guard lk(cond_variable_state.m); + cond_variable_state.ready = true; + std::cout << "[COND_VARIABLE] main() signals data ready " + "for processing" << std::endl; + } + cond_variable_state.cv.notify_one(); + + // wait for the worker + { + std::unique_lock lk(cond_variable_state.m); + cond_variable_state.cv.wait(lk, [&]{ return cond_variable_state.processed; }); + } + std::cout << "[COND_VARIABLE] Back in main(), data = " + << cond_variable_state.data << std::endl; + + if(cond_variable_state.data != "Example data after processing") + throw TestCaseException("[COND_VARIABLE]: Unexpected value for data!"); + + worker.join(); + + std::cout << "[COND_VARIABLE] Finished test." << std::endl; +} + +/* ===== TEST CASE 5: std::scoped_lock ===== + The parent thread creates 4 different employees, + each of which has a list of lunch_partners as well as a + mutex to control access to them. The main thread then + creates 4 child threads, passing each a different pair + of employees. Each child thread uses a std::scoped_lock + to acquire the two employee locks simultaneously, before + adding them to each other's lunch partner lists. Finally, + the resulting lunch partner lists are printed. +*/ +struct Employee { + std::vector<std::string> lunch_partners; + std::string id; + std::mutex m; + Employee(std::string id) : id(id) {} + std::string partners() const + { + std::string ret = "Employee " + id + " has lunch partners: "; + for (const auto& partner : lunch_partners) + ret += partner + " "; + return ret; + } +}; + +static void send_mail(Employee &, Employee &) { + // simulate a time-consuming messaging operation + std::this_thread::yield(); +} + +static void assign_lunch_partner(Employee &e1, Employee &e2) { + static thread_local std::mutex io_mutex; + { + std::lock_guard<std::mutex> lk(io_mutex); + std::cout << "[SCOPED_LOCK] " << e1.id << " and " << e2.id + << " are waiting for locks" << std::endl; + } + + { + // use std::scoped_lock to acquire two locks without worrying about + // other calls to assign_lunch_partner deadlocking us + // and it also provides a convenient RAII-style mechanism + + std::scoped_lock lock(e1.m, e2.m); + + // Equivalent code 1 (using std::lock and std::lock_guard) + // std::lock(e1.m, e2.m); + // std::lock_guard<std::mutex> lk1(e1.m, std::adopt_lock); + // std::lock_guard<std::mutex> lk2(e2.m, std::adopt_lock); + + // Equivalent code 2 (if unique_locks are needed, e.g. for condition variables) + // std::unique_lock<std::mutex> lk1(e1.m, std::defer_lock); + // std::unique_lock<std::mutex> lk2(e2.m, std::defer_lock); + // std::lock(lk1, lk2); + { + std::lock_guard<std::mutex> lk(io_mutex); + std::cout << "[SCOPED_LOCK] " << e1.id << " and " << e2.id + << " got locks" << std::endl; + } + e1.lunch_partners.push_back(e2.id); + e2.lunch_partners.push_back(e1.id); + } + + send_mail(e1, e2); + send_mail(e2, e1); +} + +static void test_scoped_lock() { + Employee ryo("RyoHazuki"), amigo("SambaDeAmigo"), + eggman("Dr.Eggman"), ulala("Ulala"); + + // assign in parallel threads because mailing users about lunch assignments + // takes a long time + std::vector<std::thread> threads; + threads.emplace_back(assign_lunch_partner, std::ref(ryo), std::ref(amigo)); + threads.emplace_back(assign_lunch_partner, std::ref(eggman), std::ref(amigo)); + threads.emplace_back(assign_lunch_partner, std::ref(eggman), std::ref(ryo)); + threads.emplace_back(assign_lunch_partner, std::ref(ulala), std::ref(amigo)); + + for (auto &thread : threads) + thread.join(); + + std::cout << "[SCOPED_LOCK] " << ryo.partners() << '\n' + << "[SCOPED_LOCK] " << amigo.partners() << '\n' + << "[SCOPED_LOCK] " << eggman.partners() << '\n' + << "[SCOPED_LOCK] " << ulala.partners() << std::endl; +} + +/* ===== TEST CASE 6: std::barrier ===== + The parent thread creates a list of 4 workers and a std::sync_point + of the same size with a completion callback. It then spawns a child ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-18 15:12:44
|
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 932513b05e6f234ddde655a628addb01e9e75753 (commit) via 068101701152c072348b93af13f8803fae065a3d (commit) from e8653ec03223ab890cb6682ed819e3c1da5c35f4 (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 932513b05e6f234ddde655a628addb01e9e75753 Merge: e8653ec 0681017 Author: Lawrence Sebald <ljs...@us...> Date: Sat Nov 18 10:12:06 2023 -0500 Merge pull request #371 from KallistiOS/setsockopt Implement SO_RCVBUF and SO_SNDBUF for setsockopt() commit 068101701152c072348b93af13f8803fae065a3d Author: darc <da...@pr...> Date: Sat Nov 18 00:59:03 2023 -0600 Implement SO_RCVBUF and SO_SNDBUF for setsockopt() ----------------------------------------------------------------------- Summary of changes: kernel/net/net_tcp.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/kernel/net/net_tcp.c b/kernel/net/net_tcp.c index 5a82daa..4250b2d 100644 --- a/kernel/net/net_tcp.c +++ b/kernel/net/net_tcp.c @@ -1767,6 +1767,7 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, const void *option_value, socklen_t option_len) { struct tcp_sock *sock; int tmp; + uint8_t *new_ptr; if(!option_value || !option_len) { errno = EFAULT; @@ -1808,6 +1809,45 @@ static int net_tcp_setsockopt(net_socket_t *hnd, int level, int option_name, case SO_ERROR: case SO_TYPE: goto ret_inval; + + case SO_RCVBUF: + if(option_len != sizeof(uint32_t)) + goto ret_inval; + + tmp = *(uint32_t *)option_value; + /* Receive buffer size must be in the range 256 - 65535 */ + if(tmp < 256) + tmp = 256; + else if(tmp > 65535) + tmp = 65535; + + new_ptr = realloc(sock->data.rcvbuf, tmp); + if(!new_ptr) + goto ret_nomem; + + sock->data.rcvbuf = new_ptr; + sock->rcvbuf_sz = tmp; + goto ret_success; + + case SO_SNDBUF: + if(option_len != sizeof(uint32_t)) + goto ret_inval; + + tmp = *(uint32_t *)option_value; + /* Send buffer size must be in the range 2048 - 65535 */ + if(tmp < 2048) + tmp = 2048; + else if(tmp > 65535) + tmp = 65535; + + new_ptr = realloc(sock->data.sndbuf, tmp); + if(!new_ptr) { + goto ret_nomem; + } + + sock->data.sndbuf = new_ptr; + sock->sndbuf_sz = tmp; + goto ret_success; } break; @@ -1889,6 +1929,12 @@ ret_inval: errno = EINVAL; return -1; +ret_nomem: + mutex_unlock(&sock->mutex); + rwsem_read_unlock(&tcp_sem); + errno = ENOMEM; + return -1; + ret_success: mutex_unlock(&sock->mutex); rwsem_read_unlock(&tcp_sem); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-11-18 06:43: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 e8653ec03223ab890cb6682ed819e3c1da5c35f4 (commit) via 8cae634c1ac7c7eab24f2ccafc08934a665fce05 (commit) from c27fb0a93183016b5b68eb7e42958f48808b8097 (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 e8653ec03223ab890cb6682ed819e3c1da5c35f4 Merge: c27fb0a 8cae634 Author: Falco Girgis <gyr...@gm...> Date: Sat Nov 18 00:42:47 2023 -0600 Merge pull request #370 from cepawiel/cmake_naomi_fix Fix Typo in CMake Toolchain for NAOMI commit 8cae634c1ac7c7eab24f2ccafc08934a665fce05 Author: Colton Pawielski <cep...@mt...> Date: Sat Nov 18 00:36:13 2023 -0600 Fix CMake Toolchain Typo ----------------------------------------------------------------------- Summary of changes: utils/cmake/dreamcast.toolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/cmake/dreamcast.toolchain.cmake b/utils/cmake/dreamcast.toolchain.cmake index f0a44f0..08fbb0c 100644 --- a/utils/cmake/dreamcast.toolchain.cmake +++ b/utils/cmake/dreamcast.toolchain.cmake @@ -74,7 +74,7 @@ ADD_DEFINITIONS( ) if(${KOS_SUBARCH} MATCHES naomi) - ADD_DEFINITONS( + ADD_DEFINITIONS( -D__NAOMI__ -D_arch_sub_naomi ) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-11-18 05:12:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c27fb0a93183016b5b68eb7e42958f48808b8097 (commit) via dd72b80ef83078d266503e181ab8c1d762ebb02c (commit) via 9cdc816f98dd777e61fa7331b452b894d65cba1e (commit) from 9462865fd8e91ea45d2241c3bead0722c55a020d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c27fb0a93183016b5b68eb7e42958f48808b8097 Merge: dd72b80 9cdc816 Author: darcagn <da...@pr...> Date: Fri Nov 17 23:11:07 2023 -0600 Merge pull request #369 from KallistiOS/c99_formatters_default Enable C99 printf() Formatters in Toolchain Config Samples commit dd72b80ef83078d266503e181ab8c1d762ebb02c Author: Ruslan Rostovtsev <sw...@21...> Date: Sat Nov 18 11:53:35 2023 +0700 Complete description of BIOS syscalls for GD-ROM. (#366) commit 9cdc816f98dd777e61fa7331b452b894d65cba1e Author: Falco Girgis <gyr...@gm...> Date: Fri Nov 17 21:31:53 2023 -0600 Dc-chain configs enable c99 formatters by default - Modified all of the sample configuration files in dc-chain to enable the C99 printf formatter option by default. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 84 +++++++++++++++++----- kernel/arch/dreamcast/include/dc/cdrom.h | 79 +++++++++++++++----- utils/dc-chain/config/config.mk.10.5.0.sample | 2 +- utils/dc-chain/config/config.mk.11.4.0.sample | 2 +- utils/dc-chain/config/config.mk.12.3.0.sample | 2 +- utils/dc-chain/config/config.mk.9.3.0.sample | 2 +- utils/dc-chain/config/config.mk.devel.sample | 2 +- utils/dc-chain/config/config.mk.legacy.sample | 2 +- utils/dc-chain/config/config.mk.stable.sample | 2 +- .../dc-chain/config/config.mk.winxp-latest.sample | 2 +- 10 files changed, 136 insertions(+), 43 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index 3beec3c..c0ad6a9 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -5,8 +5,10 @@ Copyright (C) 2000 Megan Potter Copyright (C) 2014 Lawrence Sebald Copyright (C) 2014 Donald Haase + Copyright (C) 2023 Ruslan Rostovtsev */ +#include <assert.h> #include <dc/cdrom.h> #include <dc/g1ata.h> @@ -81,18 +83,47 @@ static int gdc_change_data_type(void *param) { MAKE_SYSCALL(return, param, 0, 10); } -/* Reset the GD-ROM */ -/* Stop gcc from complaining that we don't use it */ -static void gdc_reset(void) __attribute__((unused)); +/* Abort the current command */ +static void gdc_abort_cmd(int cmd) { + MAKE_SYSCALL(/**/, cmd, 0, 8); +} +#if 0 /* Not used yet */ +/* Reset the GD-ROM syscalls */ static void gdc_reset(void) { MAKE_SYSCALL(/**/, 0, 0, 9); } -/* Abort the current command */ -static void gdc_abort_cmd(int cmd) { - MAKE_SYSCALL(/**/, cmd, 0, 8); +/* DMA end interrupt handler */ +static void gdc_dma_end(uintptr_t callback, void *param) { + MAKE_SYSCALL(/**/, callback, param, 5); +} + +/* Request DMA transfer for DMAREAD_STREAM commands */ +static int gdc_req_dma_transfer(int f, int *params) { + MAKE_SYSCALL(return, f, params, 6); +} + +/* Check DMA transfer for DMAREAD_STREAM commands */ +static int gdc_check_dma_transfer(int f, int *size) { + MAKE_SYSCALL(return, f, size, 7); +} + +/* Setup PIO transfer end callback for PIOREAD_STREAM commands */ +static void gdc_set_pio_callback(uintptr_t callback, void *param) { + MAKE_SYSCALL(/**/, callback, param, 11); } +/* Request PIO transfer for PIOREAD_STREAM commands */ +static int gdc_req_pio_transfer(int f, int *params) { + MAKE_SYSCALL(return, f, params, 12); +} + +/* Check PIO transfer for PIOREAD_STREAM commands */ +static int gdc_check_pio_transfer(int f, int *size) { + MAKE_SYSCALL(return, f, size, 13); +} +#endif + /* The G1 ATA access mutex */ mutex_t _g1_ata_mutex = RECURSIVE_MUTEX_INITIALIZER; @@ -104,33 +135,50 @@ int cdrom_set_sector_size(int size) { /* Command execution sequence */ /* XXX: It might make sense to have a version of this that takes a timeout. */ int cdrom_exec_cmd(int cmd, void *param) { - int status[4] = {0}; + int status[4] = { + 0, /* Error code 1 */ + 0, /* Error code 2 */ + 0, /* Transfered size */ + 0 /* ATA status waiting */ + }; int f, n; + assert(cmd > 0 && cmd < CMD_MAX); mutex_lock(&_g1_ata_mutex); /* Make sure to select the GD-ROM drive. */ g1_ata_select_device(G1_ATA_MASTER); - /* Submit the command and wait for it to finish */ - f = gdc_req_cmd(cmd, param); + /* Submit the command */ + for(n = 0; n < 10; ++n) { + f = gdc_req_cmd(cmd, param); + if (f > 0) { + break; + } + gdc_exec_server(); + thd_pass(); + } + + if(f <= 0) { + mutex_unlock(&_g1_ata_mutex); + return ERR_SYS; + } + /* Wait command to finish */ do { gdc_exec_server(); n = gdc_get_cmd_stat(f, status); - if(n == PROCESSING) - thd_pass(); - } - while(n == PROCESSING) - ; + if(n != PROCESSING && n != BUSY) { + break; + } + thd_pass(); + } while(1); mutex_unlock(&_g1_ata_mutex); - if(n == COMPLETED) + if(n == COMPLETED || n == STREAMING) return ERR_OK; - else if(n == ABORTED) - return ERR_ABORTED; else if(n == NO_ACTIVE) return ERR_NO_ACTIVE; else { @@ -142,6 +190,8 @@ int cdrom_exec_cmd(int cmd, void *param) { default: return ERR_SYS; } + if(status[1] != 0) + return ERR_SYS; } } diff --git a/kernel/arch/dreamcast/include/dc/cdrom.h b/kernel/arch/dreamcast/include/dc/cdrom.h index c50c63e..8bf16b4 100644 --- a/kernel/arch/dreamcast/include/dc/cdrom.h +++ b/kernel/arch/dreamcast/include/dc/cdrom.h @@ -3,6 +3,7 @@ dc/cdrom.h Copyright (C) 2000-2001 Megan Potter Copyright (C) 2014 Donald Haase + Copyright (C) 2023 Ruslan Rostovtsev */ #ifndef __DC_CDROM_H @@ -29,6 +30,7 @@ __BEGIN_DECLS normal file reading, consult with the stuff for the fs and for fs_iso9660. \author Megan Potter + \author Ruslan Rostovtsev \see kos/fs.h \see dc/fs_iso9660.h */ @@ -40,20 +42,34 @@ __BEGIN_DECLS @{ */ -#define CMD_PIOREAD 16 /**< \brief Read via PIO */ -#define CMD_DMAREAD 17 /**< \brief Read via DMA */ -#define CMD_GETTOC 18 /**< \brief Read TOC */ -#define CMD_GETTOC2 19 /**< \brief Read TOC */ -#define CMD_PLAY 20 /**< \brief Play track */ -#define CMD_PLAY2 21 /**< \brief Play sectors */ -#define CMD_PAUSE 22 /**< \brief Pause playback */ -#define CMD_RELEASE 23 /**< \brief Resume from pause */ -#define CMD_INIT 24 /**< \brief Initialize the drive */ -#define CMD_SEEK 27 /**< \brief Seek to a new position */ -#define CMD_READ 28 /**< \brief Read raw sectors */ -#define CMD_STOP 33 /**< \brief Stop the disc from spinning */ -#define CMD_GETSCD 34 /**< \brief Get subcode data */ -#define CMD_GETSES 35 /**< \brief Get session */ +#define CMD_CHECK_LICENSE 2 /**< \brief Check license */ +#define CMD_REQ_SPI_CMD 4 /**< \brief Request to Sega Packet Interface */ +#define CMD_PIOREAD 16 /**< \brief Read via PIO */ +#define CMD_DMAREAD 17 /**< \brief Read via DMA */ +#define CMD_GETTOC 18 /**< \brief Read TOC */ +#define CMD_GETTOC2 19 /**< \brief Read TOC */ +#define CMD_PLAY 20 /**< \brief Play track */ +#define CMD_PLAY2 21 /**< \brief Play sectors */ +#define CMD_PAUSE 22 /**< \brief Pause playback */ +#define CMD_RELEASE 23 /**< \brief Resume from pause */ +#define CMD_INIT 24 /**< \brief Initialize the drive */ +#define CMD_DMA_ABORT 25 /**< \brief Abort DMA transfer */ +#define CMD_OPEN_TRAY 26 /**< \brief Open CD tray (on DevBox?) */ +#define CMD_SEEK 27 /**< \brief Seek to a new position */ +#define CMD_DMAREAD_STREAM 28 /**< \brief Stream DMA until end/abort */ +#define CMD_NOP 29 /**< \brief No operation */ +#define CMD_REQ_MODE 30 /**< \brief Request mode */ +#define CMD_SET_MODE 31 /**< \brief Setup mode */ +#define CMD_SCAN_CD 32 /**< \brief Scan CD */ +#define CMD_STOP 33 /**< \brief Stop the disc from spinning */ +#define CMD_GETSCD 34 /**< \brief Get subcode data */ +#define CMD_GETSES 35 /**< \brief Get session */ +#define CMD_REQ_STAT 36 /**< \brief Request stat */ +#define CMD_PIOREAD_STREAM 37 /**< \brief Stream PIO until end/abort */ +#define CMD_DMAREAD_STREAM_EX 38 /**< \brief Stream DMA transfer */ +#define CMD_PIOREAD_STREAM_EX 39 /**< \brief Stream PIO transfer */ +#define CMD_GET_VERS 40 /**< \brief Get syscall driver version */ +#define CMD_MAX 47 /**< \brief Max of GD syscall commands */ /** @} */ /** \defgroup cd_cmd_response CD-ROM command responses @@ -78,7 +94,18 @@ __BEGIN_DECLS #define NO_ACTIVE 0 /**< \brief System inactive? */ #define PROCESSING 1 /**< \brief Processing command */ #define COMPLETED 2 /**< \brief Command completed successfully */ -#define ABORTED 3 /**< \brief Command aborted before completion */ +#define STREAMING 3 /**< \brief Stream type command is in progress */ +#define BUSY 4 /**< \brief GD syscalls is busy */ +/** @} */ + +/** \defgroup cd_cmd_ata_status CD-ROM ATA status + @{ +*/ +#define ATA_STAT_INTERNAL 0x00 +#define ATA_STAT_IRQ 0x01 +#define ATA_STAT_DRQ_0 0x02 +#define ATA_STAT_DRQ_1 0x03 +#define ATA_STAT_BUSY 0x04 /** @} */ /** \defgroup cdda_read_modes CDDA read modes @@ -107,12 +134,25 @@ __BEGIN_DECLS possible values for the first parameter sent to the GETSCD syscall. @{ */ -#define CD_SUB_Q_CHANNEL 0 /**< \brief Read Q Channel Subcode Data */ -#define CD_SUB_CURRENT_POSITION 1 /**< \brief Read all Subcode Data for - most recent sector */ +#define CD_SUB_Q_ALL 0 /**< \brief Read all Subcode Data */ +#define CD_SUB_Q_CHANNEL 1 /**< \brief Read Q Channel Subcode Data */ #define CD_SUB_MEDIA_CATALOG 2 /**< \brief Read the Media Catalog Subcode Data */ #define CD_SUB_TRACK_ISRC 3 /**< \brief Read the ISRC Subcode Data */ +#define CD_SUB_RESERVED 4 /**< \brief Reserved */ +/** @} */ + +/** \defgroup cd_subcode_audio CD-ROM Subcode audio status + + Information about CDDA playback from GETSCD syscall. + @{ +*/ +#define CD_SUB_AUDIO_STATUS_INVALID 0x00 +#define CD_SUB_AUDIO_STATUS_PLAYING 0x11 +#define CD_SUB_AUDIO_STATUS_PAUSED 0x12 +#define CD_SUB_AUDIO_STATUS_ENDED 0x13 +#define CD_SUB_AUDIO_STATUS_ERROR 0x14 +#define CD_SUB_AUDIO_STATUS_NO_INFO 0x15 /** @} */ /** \defgroup cd_read_sector_mode CD-ROM Read Sector Mode @@ -131,6 +171,7 @@ __BEGIN_DECLS cdrom_get_status() function. @{ */ +#define CD_STATUS_READ_FAIL -1 /**< \brief Can't read status */ #define CD_STATUS_BUSY 0 /**< \brief Drive is busy */ #define CD_STATUS_PAUSED 1 /**< \brief Disc is paused */ #define CD_STATUS_STANDBY 2 /**< \brief Drive is in standby */ @@ -139,6 +180,8 @@ __BEGIN_DECLS #define CD_STATUS_SCANNING 5 /**< \brief Drive is scanning */ #define CD_STATUS_OPEN 6 /**< \brief Disc tray is open */ #define CD_STATUS_NO_DISC 7 /**< \brief No disc inserted */ +#define CD_STATUS_RETRY 8 /**< \brief Retry is needed */ +#define CD_STATUS_ERROR 9 /**< \brief System error */ /** @} */ /** \defgroup cd_disc_types CD-ROM drive disc types diff --git a/utils/dc-chain/config/config.mk.10.5.0.sample b/utils/dc-chain/config/config.mk.10.5.0.sample index da52ff1..3ceb19c 100644 --- a/utils/dc-chain/config/config.mk.10.5.0.sample +++ b/utils/dc-chain/config/config.mk.10.5.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.11.4.0.sample b/utils/dc-chain/config/config.mk.11.4.0.sample index 0132602..d4458e6 100644 --- a/utils/dc-chain/config/config.mk.11.4.0.sample +++ b/utils/dc-chain/config/config.mk.11.4.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.12.3.0.sample b/utils/dc-chain/config/config.mk.12.3.0.sample index 64d6924..2840d3b 100644 --- a/utils/dc-chain/config/config.mk.12.3.0.sample +++ b/utils/dc-chain/config/config.mk.12.3.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.9.3.0.sample b/utils/dc-chain/config/config.mk.9.3.0.sample index 4b2866c..61c25fd 100644 --- a/utils/dc-chain/config/config.mk.9.3.0.sample +++ b/utils/dc-chain/config/config.mk.9.3.0.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.devel.sample b/utils/dc-chain/config/config.mk.devel.sample index b000f59..7400930 100644 --- a/utils/dc-chain/config/config.mk.devel.sample +++ b/utils/dc-chain/config/config.mk.devel.sample @@ -146,7 +146,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.legacy.sample b/utils/dc-chain/config/config.mk.legacy.sample index 8a2349e..47a6c14 100644 --- a/utils/dc-chain/config/config.mk.legacy.sample +++ b/utils/dc-chain/config/config.mk.legacy.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.stable.sample b/utils/dc-chain/config/config.mk.stable.sample index 1223da6..2541df1 100644 --- a/utils/dc-chain/config/config.mk.stable.sample +++ b/utils/dc-chain/config/config.mk.stable.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will diff --git a/utils/dc-chain/config/config.mk.winxp-latest.sample b/utils/dc-chain/config/config.mk.winxp-latest.sample index 50a638b..5d0d6cc 100644 --- a/utils/dc-chain/config/config.mk.winxp-latest.sample +++ b/utils/dc-chain/config/config.mk.winxp-latest.sample @@ -136,7 +136,7 @@ thread_model=kos # Define this to build SH4 Newlib with additional support for the C99 format # specifiers, used by printf and friends. These include support for size_t, # ptrdiff_t, intmax_t, and sized integral types. -#newlib_c99_formats=1 +newlib_c99_formats=1 # Optimize Newlib for Space (1|0) # Define this to enable optimizing for space when building Newlib. This will hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-16 15:51:20
|
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 9462865fd8e91ea45d2241c3bead0722c55a020d (commit) via de9a02b5d7e9914a5e63ceaf70db3e7103ce3a5e (commit) from a8c46d4bf635a113b6895873389ed8aeee793017 (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 9462865fd8e91ea45d2241c3bead0722c55a020d Merge: a8c46d4 de9a02b Author: Lawrence Sebald <ljs...@us...> Date: Thu Nov 16 10:45:32 2023 -0500 Merge pull request #365 from KallistiOS/thread_mode_warning Removed INIT_THD_PREEMPT startup warning commit de9a02b5d7e9914a5e63ceaf70db3e7103ce3a5e Author: Falco Girgis <gyr...@gm...> Date: Thu Nov 16 08:47:20 2023 -0600 Removed INIT_THD_PREEMPT startup warning - Removed warning from init.c that gets printed when the INIT_THD_PREEMPT flag gets used * this flag is always used by default, so the warning is just clutter and is confusing when the flag wasn't explicitly added - Hid extern variable for current thread pointer from the Doxygen in thread.h ----------------------------------------------------------------------- Summary of changes: include/kos/thread.h | 11 +++-------- kernel/arch/dreamcast/kernel/init.c | 5 ----- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/include/kos/thread.h b/include/kos/thread.h index c57004f..6b8be23 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -271,18 +271,13 @@ typedef struct kthread_attr { @{ */ #define THD_MODE_NONE -1 /**< \brief Threads not running */ -#define THD_MODE_COOP 0 /**< \brief Cooperative mode (deprecated) */ +#define THD_MODE_COOP 0 /**< \brief Cooperative mode \deprecated */ #define THD_MODE_PREEMPT 1 /**< \brief Preemptive threading mode */ /** @} */ -/** \brief The currently executing thread. - - \warning - Do not manipulate this variable directly! - - \sa thd_get_current -*/ +/** \cond The currently executing thread -- Do not manipulate directly! */ extern kthread_t *thd_current; +/** \endcond */ /** \brief Block the current thread. diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index ee2d6d5..9c7ae7e 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -139,11 +139,6 @@ int __attribute__((weak)) arch_auto_init(void) { timer_ms_enable(); rtc_init(); - /* Threads */ - if(!(__kos_init_flags & INIT_THD_PREEMPT)) - dbglog(DBG_WARNING, "Cooperative threading mode is deprecated. KOS is \ - always in pre-emptive threading mode. \n"); - thd_init(); nmmgr_init(); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-11-14 06:27:58
|
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 a8c46d4bf635a113b6895873389ed8aeee793017 (commit) via f04ed208e0d6d122258d5ba25c234a903c1d559e (commit) from 75cf3932042a8321f40b325948665cadd61ed51e (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 a8c46d4bf635a113b6895873389ed8aeee793017 Merge: 75cf393 f04ed20 Author: darcagn <da...@pr...> Date: Mon Nov 13 23:42:46 2023 -0600 Merge pull request #363 from Dreamcast-Projects/fix_ports commit f04ed208e0d6d122258d5ba25c234a903c1d559e Author: Andress Barajas <and...@gm...> Date: Mon Nov 13 21:40:17 2023 -0800 Fix kos-ports compile error ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/sound/sfxmgr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h b/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h index ee8f69e..bfe4e0c 100644 --- a/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h +++ b/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h @@ -26,6 +26,7 @@ __BEGIN_DECLS #include <arch/types.h> +#include <stdint.h> /** \brief Sound effect handle type. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-11-14 03:46: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 75cf3932042a8321f40b325948665cadd61ed51e (commit) via 12ef9deb02475981481c43b83fa4720c2ded687f (commit) from 5e0d59d084fe4ecd7a244956dbab36033e77ea83 (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 75cf3932042a8321f40b325948665cadd61ed51e Merge: 5e0d59d 12ef9de Author: Lawrence Sebald <ljs...@us...> Date: Mon Nov 13 17:33:24 2023 -0500 Merge pull request #362 from Dreamcast-Projects/fix_compile Fix KOS compile error and warning commit 12ef9deb02475981481c43b83fa4720c2ded687f Author: Andress Barajas <and...@gm...> Date: Mon Nov 13 14:11:42 2023 -0800 Fix KOS compile error and warning ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/sound/snd_stream.c | 2 +- kernel/libc/koslib/getaddrinfo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/arch/dreamcast/sound/snd_stream.c b/kernel/arch/dreamcast/sound/snd_stream.c index b379f6f..cea5219 100644 --- a/kernel/arch/dreamcast/sound/snd_stream.c +++ b/kernel/arch/dreamcast/sound/snd_stream.c @@ -328,7 +328,7 @@ int snd_stream_init(void) { } snd_stream_hnd_t snd_stream_alloc(snd_stream_callback_t cb, int bufsize) { - int i, old; + int i; snd_stream_hnd_t hnd; mutex_lock(&stream_mutex); diff --git a/kernel/libc/koslib/getaddrinfo.c b/kernel/libc/koslib/getaddrinfo.c index 4950c9c..f3ea1db 100644 --- a/kernel/libc/koslib/getaddrinfo.c +++ b/kernel/libc/koslib/getaddrinfo.c @@ -707,7 +707,7 @@ int getaddrinfo(const char *nodename, const char *servname, } /* Try to handle input as an IPv4 address */ - if(ihints.ai_family == AI_INET || ihints.ai_family == AF_UNSPEC) { + if(ihints.ai_family == AF_INET || ihints.ai_family == AF_UNSPEC) { uint32_t ip4_addr; if(inet_pton(AF_INET, nodename, &ip4_addr) > 0) { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |