You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
(26) |
Aug
(27) |
Sep
|
Oct
|
Nov
|
Dec
|
From: ljsebald <ljs...@us...> - 2023-04-01 01:14:11
|
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 da8bbb1c6990fe0c5b57968e6c5c25ee03f0bbb7 (commit) from b65b96f95855f2b018552ce9ea5f2aacfca5fdb7 (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 da8bbb1c6990fe0c5b57968e6c5c25ee03f0bbb7 Author: Falco Girgis <gyr...@gm...> Date: Fri Mar 31 21:13:37 2023 -0400 Authors update (#142) * Updated AUTHORS. ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index e601e26..0cfdc34 100644 --- a/AUTHORS +++ b/AUTHORS @@ -46,6 +46,7 @@ Eric Fradella: 2023 Falco Girgis: 2023 Ruslan Rostovtsev: 2014, 2016, 2023 Colton Pawielski: 2023 +Andy Barajas: 2023 Files with Specific licenses: ----------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-04-01 01:08:42
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b65b96f95855f2b018552ce9ea5f2aacfca5fdb7 (commit) via 809e2e1ebfa89eb14d3defd9efd4420a6b7fada9 (commit) via 16a44ff18ca0b02ce1ec0f9f0ada23f99001197d (commit) via 53df25d6fc9ad34e5f8e5adb26934dc80eb1171e (commit) via c7d13b603d96ab3219d63375a347c26130efb7d4 (commit) via d3af812e59b65f4e0eaee335aa72800cc680487f (commit) via 248b93928dbe934daea47edc60c089c851d7e644 (commit) via 2141d3e92afac0daf78278461da2af2c1e3931db (commit) from 8017df8cd9e88c7ed80e5bd095cd874b9ac6a21a (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 b65b96f95855f2b018552ce9ea5f2aacfca5fdb7 Merge: 809e2e1 16a44ff Author: Lawrence Sebald <ljs...@us...> Date: Fri Mar 31 21:04:24 2023 -0400 Merge pull request #140 from Dreamcast-Projects/master Make sure clearing a counter stops it first. Updated read me to incl⦠commit 809e2e1ebfa89eb14d3defd9efd4420a6b7fada9 Merge: 8017df8 c7d13b6 Author: Lawrence Sebald <ljs...@us...> Date: Fri Mar 31 21:03:15 2023 -0400 Merge pull request #141 from KallistiOS/cpp_time Update kos/time.h header for C++ support commit 16a44ff18ca0b02ce1ec0f9f0ada23f99001197d Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 16:35:07 2023 -0700 Added better doxygen documentation for performance counters commit 53df25d6fc9ad34e5f8e5adb26934dc80eb1171e Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 16:15:38 2023 -0700 Added documentation inside the comments commit 2141d3e92afac0daf78278461da2af2c1e3931db Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 13:25:12 2023 -0700 Make sure clearing a counter stops it first. Updated read me to include performance counters. Fixed a comment ----------------------------------------------------------------------- Summary of changes: README.md | 2 +- doc/CHANGELOG | 1 + include/kos/time.h | 6 +- kernel/arch/dreamcast/include/arch/timer.h | 106 ++++++++++++++++++----------- kernel/arch/dreamcast/kernel/timer.c | 5 +- 5 files changed, 73 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 90f69cf..c03f033 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Despite the console's age, KOS offers an extremely modern, programmer-friendly d * Flashrom Access * AICA SPU Sound Processor Driver * Cache and Store Queue Management -* Timer Peripherals and Real-Time Clock +* Timer Peripherals, Real-Time Clock, Performance Counters * MMU Management API * BIOS Font Rendering diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 8de8b48..46929d8 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -158,6 +158,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Removed (completely unsupported) support for GCC 3.x and older [LS] - *** Add timespec_get C11 function to koslib's libc [LS] - DC Added timer_ns_gettime64() and performance counters [AB] +- *** Added check to allow strict C++17+ to use timespec_get [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/include/kos/time.h b/include/kos/time.h index 78279b5..d32da92 100644 --- a/include/kos/time.h +++ b/include/kos/time.h @@ -14,7 +14,7 @@ #ifndef __KOS_TIME_H #define __KOS_TIME_H -#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) +#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) #include <kos/cdefs.h> @@ -29,5 +29,5 @@ extern int timespec_get(struct timespec *ts, int base); __END_DECLS -#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) */ -#endif /* !__KOS_C11TIME_H */ +#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) */ +#endif /* !__KOS_TIME_H */ diff --git a/kernel/arch/dreamcast/include/arch/timer.h b/kernel/arch/dreamcast/include/arch/timer.h index 4286cf1..ffbb74a 100644 --- a/kernel/arch/dreamcast/include/arch/timer.h +++ b/kernel/arch/dreamcast/include/arch/timer.h @@ -225,72 +225,91 @@ int timer_init(); void timer_shutdown(); /* \endcond */ +/** \defgroup perf_counters Performance Counters + The performance counter API exposes the SH4's hardware profiling registers, + which consist of two different sets of independently operable 64-bit + counters. +*/ + /** \brief SH4 Performance Counter. + \ingroup perf_counters This counter is used by the ns_gettime function in this header. */ #define PRFC0 0 /** \brief SH4 Performance Counter. + \ingroup perf_counters A counter that is not used by KOS. */ #define PRFC1 1 -/** \brief CPU Cycles Count Type +/** \brief CPU Cycles Count Type. + \ingroup perf_counters Count cycles. At 5 ns increments, a 48-bit cycle counter can run continuously for 16.33 days. */ #define PMCR_COUNT_CPU_CYCLES 0 -/** \brief Ratio Cycles Count Type +/** \brief Ratio Cycles Count Type. + \ingroup perf_counters CPU/bus ratio mode where cycles (where T = C x B / 24 and T is time, C is count, and B is time of one bus cycle). */ #define PMCR_COUNT_RATIO_CYCLES 1 +/** \defgroup perf_counters_modes Performance Counter Modes + This is the list of modes that are allowed to be passed into the perf_cntr_start() + function, representing different things you want to count. + \ingroup perf_counters + @{ +*/ /* MODE DEFINITION VALUE MEASURMENT TYPE & NOTES */ -#define PMCR_INIT_NO_MODE 0x00 /* None; Just here to be complete */ -#define PMCR_OPERAND_READ_ACCESS_MODE 0x01 /* Quantity; With cache */ -#define PMCR_OPERAND_WRITE_ACCESS_MODE 0x02 /* Quantity; With cache */ -#define PMCR_UTLB_MISS_MODE 0x03 /* Quantity */ -#define PMCR_OPERAND_CACHE_READ_MISS_MODE 0x04 /* Quantity */ -#define PMCR_OPERAND_CACHE_WRITE_MISS_MODE 0x05 /* Quantity */ -#define PMCR_INSTRUCTION_FETCH_MODE 0x06 /* Quantity; With cache */ -#define PMCR_INSTRUCTION_TLB_MISS_MODE 0x07 /* Quantity */ -#define PMCR_INSTRUCTION_CACHE_MISS_MODE 0x08 /* Quantity */ -#define PMCR_ALL_OPERAND_ACCESS_MODE 0x09 /* Quantity */ -#define PMCR_ALL_INSTRUCTION_FETCH_MODE 0x0a /* Quantity */ -#define PMCR_ON_CHIP_RAM_OPERAND_ACCESS_MODE 0x0b /* Quantity */ +#define PMCR_INIT_NO_MODE 0x00 /**< \brief None; Just here to be complete */ +#define PMCR_OPERAND_READ_ACCESS_MODE 0x01 /**< \brief Quantity; With cache */ +#define PMCR_OPERAND_WRITE_ACCESS_MODE 0x02 /**< \brief Quantity; With cache */ +#define PMCR_UTLB_MISS_MODE 0x03 /**< \brief Quantity */ +#define PMCR_OPERAND_CACHE_READ_MISS_MODE 0x04 /**< \brief Quantity */ +#define PMCR_OPERAND_CACHE_WRITE_MISS_MODE 0x05 /**< \brief Quantity */ +#define PMCR_INSTRUCTION_FETCH_MODE 0x06 /**< \brief Quantity; With cache */ +#define PMCR_INSTRUCTION_TLB_MISS_MODE 0x07 /**< \brief Quantity */ +#define PMCR_INSTRUCTION_CACHE_MISS_MODE 0x08 /**< \brief Quantity */ +#define PMCR_ALL_OPERAND_ACCESS_MODE 0x09 /**< \brief Quantity */ +#define PMCR_ALL_INSTRUCTION_FETCH_MODE 0x0a /**< \brief Quantity */ +#define PMCR_ON_CHIP_RAM_OPERAND_ACCESS_MODE 0x0b /**< \brief Quantity */ /* No 0x0c */ -#define PMCR_ON_CHIP_IO_ACCESS_MODE 0x0d /* Quantity */ -#define PMCR_OPERAND_ACCESS_MODE 0x0e /* Quantity; With cache, counts both reads and writes */ -#define PMCR_OPERAND_CACHE_MISS_MODE 0x0f /* Quantity */ -#define PMCR_BRANCH_ISSUED_MODE 0x10 /* Quantity; Not the same as branch taken! */ -#define PMCR_BRANCH_TAKEN_MODE 0x11 /* Quantity */ -#define PMCR_SUBROUTINE_ISSUED_MODE 0x12 /* Quantity; Issued a BSR, BSRF, JSR, JSR/N */ -#define PMCR_INSTRUCTION_ISSUED_MODE 0x13 /* Quantity */ -#define PMCR_PARALLEL_INSTRUCTION_ISSUED_MODE 0x14 /* Quantity */ -#define PMCR_FPU_INSTRUCTION_ISSUED_MODE 0x15 /* Quantity */ -#define PMCR_INTERRUPT_COUNTER_MODE 0x16 /* Quantity */ -#define PMCR_NMI_COUNTER_MODE 0x17 /* Quantity */ -#define PMCR_TRAPA_INSTRUCTION_COUNTER_MODE 0x18 /* Quantity */ -#define PMCR_UBC_A_MATCH_MODE 0x19 /* Quantity */ -#define PMCR_UBC_B_MATCH_MODE 0x1a /* Quantity */ +#define PMCR_ON_CHIP_IO_ACCESS_MODE 0x0d /**< \brief Quantity */ +#define PMCR_OPERAND_ACCESS_MODE 0x0e /**< \brief Quantity; With cache, counts both reads and writes */ +#define PMCR_OPERAND_CACHE_MISS_MODE 0x0f /**< \brief Quantity */ +#define PMCR_BRANCH_ISSUED_MODE 0x10 /**< \brief Quantity; Not the same as branch taken! */ +#define PMCR_BRANCH_TAKEN_MODE 0x11 /**< \brief Quantity */ +#define PMCR_SUBROUTINE_ISSUED_MODE 0x12 /**< \brief Quantity; Issued a BSR, BSRF, JSR, JSR/N */ +#define PMCR_INSTRUCTION_ISSUED_MODE 0x13 /**< \brief Quantity */ +#define PMCR_PARALLEL_INSTRUCTION_ISSUED_MODE 0x14 /**< \brief Quantity */ +#define PMCR_FPU_INSTRUCTION_ISSUED_MODE 0x15 /**< \brief Quantity */ +#define PMCR_INTERRUPT_COUNTER_MODE 0x16 /**< \brief Quantity */ +#define PMCR_NMI_COUNTER_MODE 0x17 /**< \brief Quantity */ +#define PMCR_TRAPA_INSTRUCTION_COUNTER_MODE 0x18 /**< \brief Quantity */ +#define PMCR_UBC_A_MATCH_MODE 0x19 /**< \brief Quantity */ +#define PMCR_UBC_B_MATCH_MODE 0x1a /**< \brief Quantity */ /* No 0x1b-0x20 */ -#define PMCR_INSTRUCTION_CACHE_FILL_MODE 0x21 /* Cycles */ -#define PMCR_OPERAND_CACHE_FILL_MODE 0x22 /* Cycles */ -#define PMCR_ELAPSED_TIME_MODE 0x23 /* Cycles; For 200MHz CPU: 5ns per count in 1 cycle = 1 count mode, or around 417.715ps per count (increments by 12) in CPU/bus ratio mode */ -#define PMCR_PIPELINE_FREEZE_BY_ICACHE_MISS_MODE 0x24 /* Cycles */ -#define PMCR_PIPELINE_FREEZE_BY_DCACHE_MISS_MODE 0x25 /* Cycles */ +#define PMCR_INSTRUCTION_CACHE_FILL_MODE 0x21 /**< \brief Cycles */ +#define PMCR_OPERAND_CACHE_FILL_MODE 0x22 /**< \brief Cycles */ +#define PMCR_ELAPSED_TIME_MODE 0x23 /**< \brief Cycles; For 200MHz CPU: 5ns per count in 1 cycle = 1 count mode, or around 417.715ps per count (increments by 12) in CPU/bus ratio mode */ +#define PMCR_PIPELINE_FREEZE_BY_ICACHE_MISS_MODE 0x24 /**< \brief Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_DCACHE_MISS_MODE 0x25 /**< \brief Cycles */ /* No 0x26 */ -#define PMCR_PIPELINE_FREEZE_BY_BRANCH_MODE 0x27 /* Cycles */ -#define PMCR_PIPELINE_FREEZE_BY_CPU_REGISTER_MODE 0x28 /* Cycles */ -#define PMCR_PIPELINE_FREEZE_BY_FPU_MODE 0x29 /* Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_BRANCH_MODE 0x27 /**< \brief Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_CPU_REGISTER_MODE 0x28 /**< \brief Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_FPU_MODE 0x29 /**< \brief Cycles */ +/** @} */ + /** \brief Get a performance counter's settings. + \ingroup perf_counters This function returns a performance counter's settings. @@ -300,6 +319,7 @@ void timer_shutdown(); uint16 perf_cntr_get_config(int which); /** \brief Start a performance counter. + \ingroup perf_counters This function starts a performance counter @@ -311,6 +331,7 @@ uint16 perf_cntr_get_config(int which); int perf_cntr_start(int which, int mode, int count_type); /** \brief Stop a performance counter. + \ingroup perf_counters This function stops a performance counter that was started with perf_cntr_start(). Stopping a counter retains its count. To clear the count use perf_cntr_clear(). @@ -320,11 +341,12 @@ int perf_cntr_start(int which, int mode, int count_type); */ int perf_cntr_stop(int which); -/** \brief Clear a performance counter +/** \brief Clear a performance counter. + \ingroup perf_counters - This function clears a performance counter. It resets its value to zero. - You cannot clear a running counter. This function stops the counter before - clearing it because you cant clear a running counter. + This function clears a performance counter. It resets its count to zero. + This function stops the counter before clearing it because you cant clear + a running counter. \param which The counter to clear (i.e, \ref PRFC0 or PRFC1). \retval 0 On success. @@ -332,6 +354,7 @@ int perf_cntr_stop(int which); int perf_cntr_clear(int which); /** \brief Obtain the count of a performance counter. + \ingroup perf_counters This function simply returns the count of the counter. @@ -341,6 +364,7 @@ int perf_cntr_clear(int which); uint64 perf_cntr_count(int which); /** \brief Enable the nanosecond timer. + \ingroup perf_counters This function enables the performance counter used for the timer_ns_gettime64() function. This is on by default. The function uses \ref PRFC0 to do the work. @@ -348,6 +372,7 @@ uint64 perf_cntr_count(int which); void timer_ns_enable(); /** \brief Disable the nanosecond timer. + \ingroup perf_counters This function disables the performance counter used for the timer_ns_gettime64() function. Generally, you will not want to do this, unless you have some need to use @@ -356,6 +381,7 @@ void timer_ns_enable(); void timer_ns_disable(); /** \brief Get the current uptime of the system (in nanoseconds). + \ingroup perf_counters This function retrieves the number of nanoseconds since KOS was started. diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c index 3829781..ecc7a34 100644 --- a/kernel/arch/dreamcast/kernel/timer.c +++ b/kernel/arch/dreamcast/kernel/timer.c @@ -337,7 +337,6 @@ uint16 perf_cntr_get_config(int which) { /* Start a performance counter */ int perf_cntr_start(int which, int mode, int count_type) { - perf_cntr_stop(which); perf_cntr_clear(which); PMCR_CTRL(which) = PMCR_RUN | mode | (count_type << PMCR_CLOCK_TYPE_SHIFT); @@ -351,8 +350,9 @@ int perf_cntr_stop(int which) { return 0; } -/* Clears a performance counter */ +/* Clears a performance counter. Has to stop it first. */ int perf_cntr_clear(int which) { + perf_cntr_stop(which); PMCR_CTRL(which) |= PMCR_CLR; return 0; @@ -372,7 +372,6 @@ void timer_ns_disable() { /* If timer is running, disable it */ if((config & PMCR_ELAPSED_TIME_MODE)) { - perf_cntr_stop(PRFC0); perf_cntr_clear(PRFC0); } } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-04-01 00:52:42
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, ignore_stream has been created at e5f18bf58eab10db34ec53af2dd4b3d37009d16d (commit) - Log ----------------------------------------------------------------- commit e5f18bf58eab10db34ec53af2dd4b3d37009d16d Author: falco <gyr...@gm...> Date: Fri Mar 31 20:51:00 2023 -0400 Added ARM driver stream.drv to .gitignore ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-31 23:33:08
|
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, authors_update has been created at 71f314048e35084382e7bc04dffb055d129d775f (commit) - Log ----------------------------------------------------------------- commit 71f314048e35084382e7bc04dffb055d129d775f Author: falco <gyr...@gm...> Date: Fri Mar 31 19:30:38 2023 -0400 Updated AUTHORS. commit c7d13b603d96ab3219d63375a347c26130efb7d4 Merge: d3af812 8017df8 Author: Falco Girgis <gyr...@gm...> Date: Fri Mar 31 18:34:53 2023 -0400 Merge branch 'master' into cpp_time ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-31 22:33: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, cpp_time has been updated via d3af812e59b65f4e0eaee335aa72800cc680487f (commit) from 248b93928dbe934daea47edc60c089c851d7e644 (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 d3af812e59b65f4e0eaee335aa72800cc680487f Author: falco <gyr...@gm...> Date: Fri Mar 31 18:33:28 2023 -0400 Updated CHANGELOG, fixed closing #endif comments ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/time.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index cb6ed7f..07be87c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -157,6 +157,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Removed "navi" subarch, moved code to addons/libnavi [LS] - *** Removed (completely unsupported) support for GCC 3.x and older [LS] - *** Add timespec_get C11 function to koslib's libc [LS] +- *** Added check to allow strict C++17+ to use timespec_get [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/include/kos/time.h b/include/kos/time.h index 2272642..d32da92 100644 --- a/include/kos/time.h +++ b/include/kos/time.h @@ -29,5 +29,5 @@ extern int timespec_get(struct timespec *ts, int base); __END_DECLS -#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) */ -#endif /* !__KOS_C11TIME_H */ +#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) */ +#endif /* !__KOS_TIME_H */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-31 22:09: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, cpp_time has been created at 248b93928dbe934daea47edc60c089c851d7e644 (commit) - Log ----------------------------------------------------------------- commit 248b93928dbe934daea47edc60c089c851d7e644 Author: falco <gyr...@gm...> Date: Fri Mar 31 18:08:55 2023 -0400 Update kos/time.h header for C++ support - Notice the timespec stuff was only made available in C++17 - C++ is being built with __STRICT_ANSI__ apparently which made the code conditionally #ifdef'd out ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-31 19:45:42
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 8017df8cd9e88c7ed80e5bd095cd874b9ac6a21a (commit) via 99dd5dbf44fd8237a8edbf262572ba26e5011f6f (commit) via d500f410b742bd359fa59894074cd765df5ac68b (commit) via 0fd372b473a767041f13af7f5276b453debd10fb (commit) via 58f0b86eeb7364669aaf8ba883cafa97ec7d319e (commit) via 94d79b8c0b1c9401647d4e93701e9790fda3a3b4 (commit) via 941774c45f6f28a8bf87b4135efcfbcb176b60d7 (commit) via 0a8727d99d37f55f9b18f196e0d5d75b55f9b071 (commit) via 5a407b67225d2427dcbc95e556daf6592551eebd (commit) via c83711685a5c0dcca7a366e4401d25ba8047faba (commit) from 4c7ef784f214b83ef5503fe2a56145e68f93bb75 (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 8017df8cd9e88c7ed80e5bd095cd874b9ac6a21a Merge: 4c7ef78 99dd5db Author: Lawrence Sebald <ljs...@us...> Date: Fri Mar 31 15:44:40 2023 -0400 Merge pull request #91 from gyrovorbis/cmake Added CMake Toolchain file + environment variable commit 99dd5dbf44fd8237a8edbf262572ba26e5011f6f Author: Colton Pawielski <cep...@mt...> Date: Tue Mar 14 21:19:15 2023 -0500 Fix errors in CMake ENV Var Checks commit d500f410b742bd359fa59894074cd765df5ac68b Author: Colton Pawielski <cep...@mt...> Date: Tue Mar 14 21:17:01 2023 -0500 Make spacing uniform across CMake files commit 0fd372b473a767041f13af7f5276b453debd10fb Author: Colton Pawielski <cep...@mt...> Date: Thu Mar 9 17:39:38 2023 -0600 Add CMake helper functions generate_romdisk() will create a romdisk from the folder passed and add it to the target enable_sh4_math() will add flags for math optimization (when available) commit 58f0b86eeb7364669aaf8ba883cafa97ec7d319e Author: falco <gyr...@gm...> Date: Thu Mar 9 18:10:23 2023 -0500 Addressed most of the code review commentary 1) fast math flags have been removed - there's no way to detect compiler-version within the toolchain's execution context, and the fast math flags aren't in "legacy" 4.7 2) KOS environment flags are now configurable flags which default to being populated via environment variables - allows for the user to override programmatically - allows for other logic to access these variables 3) Debug/Release flags now use generator expressions and are deduplicated across configurations 4) Duplicate linker libraries have been removed commit 94d79b8c0b1c9401647d4e93701e9790fda3a3b4 Author: falco <gyr...@gm...> Date: Wed Feb 1 23:13:44 2023 -0500 Removed redundant arch def, added default configs - removed redundante define for __arch_dreamcast - removed -g0 for disabling debug information from release (CMake handles this for targets, including RelWithDebInfo) - added SH4 instruction flags to all configurations because none of them are enabled without -ffast-math, and all should be available - added default configurations for RelWithDebInfo and RelMinSize commit 941774c45f6f28a8bf87b4135efcfbcb176b60d7 Author: falco <gyr...@gm...> Date: Wed Feb 1 16:18:45 2023 -0500 Reordered Naomi platform definitions to match DC's commit 0a8727d99d37f55f9b18f196e0d5d75b55f9b071 Author: falco <gyr...@gm...> Date: Wed Feb 1 16:10:40 2023 -0500 Made SH4 math instructions optional - Removed -ffast-math from both C and CXX configurations so that it must be provided by the user's CMakeLists.txt for the target in order to activate -mfsrra and -mfsca. - Added description of how to do this. commit 5a407b67225d2427dcbc95e556daf6592551eebd Author: falco <gyr...@gm...> Date: Wed Feb 1 06:17:14 2023 -0500 Added define for Naomi to Cmake Toolchain commit c83711685a5c0dcca7a366e4401d25ba8047faba Author: falco <gyr...@gm...> Date: Wed Feb 1 06:03:04 2023 -0500 Added CMake Toolchain file + environment variable - Added utils/cmake/dreamcast.toolchain.cmake, a toolchain file configured for setting up KOS and cross-compiling for DC with CMake - added environment variable to doc/environ.sh.sample for being able to conveniently reference the toolchain when passing it to CMake from the command-line ----------------------------------------------------------------------- Summary of changes: doc/environ.sh.sample | 3 + utils/cmake/dreamcast.cmake | 63 +++++++++++++++++ utils/cmake/dreamcast.toolchain.cmake | 127 ++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 utils/cmake/dreamcast.cmake create mode 100644 utils/cmake/dreamcast.toolchain.cmake diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample index f5516fb..28e93a5 100644 --- a/doc/environ.sh.sample +++ b/doc/environ.sh.sample @@ -31,6 +31,9 @@ export KOS_PORTS="${KOS_BASE}/../kos-ports" export KOS_MAKE="make" #export KOS_MAKE="gmake" +# CMake toolchain +export KOS_CMAKE_TOOLCHAIN="${KOS_BASE}/utils/cmake/dreamcast.toolchain.cmake" + # Load utility export KOS_LOADER="dc-tool -x" # dcload, preconfigured # export KOS_LOADER="dc-tool-ser -t /dev/ttyS0 -x" # dcload-serial diff --git a/utils/cmake/dreamcast.cmake b/utils/cmake/dreamcast.cmake new file mode 100644 index 0000000..a6254e5 --- /dev/null +++ b/utils/cmake/dreamcast.cmake @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.23) + +### Helper Function for Generating Romdisk ### +function(generate_romdisk target romdiskName romdiskPath) + set(obj ${CMAKE_CURRENT_BINARY_DIR}/${romdiskName}.o) + set(img ${CMAKE_CURRENT_BINARY_DIR}/${romdiskName}.img) + + # Variable holding all files in the romdiskPath folder + # CONFIGURE_DEPENDS causes the folder to always be rechecked + # at build time not only when CMake is re-run + file(GLOB romdiskFiles CONFIGURE_DEPENDS + "${romdiskPath}/*" + ) + + # Custom Command to generate romdisk image from folder + # Only run when folder contents have changed by depending on + # the romdiskFiles variable + add_custom_command( + OUTPUT ${img} + COMMAND $ENV{KOS_GENROMFS} -f ${img} -d ${romdiskPath} -v + DEPENDS ${romdiskFiles} +) + + # Custom Command to generate romdisk object file from image +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${romdiskName}.o + COMMAND $ENV{KOS_BASE}/utils/bin2o/bin2o ${img} ${romdiskName} ${obj} + DEPENDS ${img} + ) + + # Append romdisk object to target + target_sources(${target} PRIVATE ${obj}) +endfunction() + +### Function to Enable SH4 Math Optimizations ### +function(enable_sh4_math) + if(NOT ${PLATFORM_DREAMCAST}) + message(WARN " PLATFORM_DREAMCAST not set, skipping SH4 Math flags") + return() + endif() + + message(INFO " Enabling SH4 Math Optimizations") + add_compile_options(-ffast-math) + + # Check if -mfsrra and -mfsca are supported by the compiler + # They were added for GCC 4.8, so the Legacy GCC4.7 toolchain + # will complain if they are added. + include(CheckCCompilerFlag) + check_c_compiler_flag("-mfsrra" COMPILER_HAS_FSRRA) + check_c_compiler_flag("-mfsca" COMPILER_HAS_FSCA) + if(COMPILER_HAS_FSRRA) + add_compile_options(-mfsrra) + else() + message(WARN " Must have GCC4.8 or later for -mfsrra to be enabled") + endif() + + if(COMPILER_HAS_FSCA) + add_compile_options(-mfsca) + else() + message(WARN " Must have GCC4.8 or later for -mfsca to be enabled") + endif() + +endfunction() \ No newline at end of file diff --git a/utils/cmake/dreamcast.toolchain.cmake b/utils/cmake/dreamcast.toolchain.cmake new file mode 100644 index 0000000..8377404 --- /dev/null +++ b/utils/cmake/dreamcast.toolchain.cmake @@ -0,0 +1,127 @@ +# CMake Toolchain file for targeting the Dreamcast or NAOMI with CMake. +# (c)2023 Falco Girgis, Luke Benstead +# +# This file is to be passed to CMake when compiling a regular CMake project +# to cross-compile for the Dreamcast, using the KOS environment and settings. +# +# cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=${KOS_BASE}/kos/utils/cmake/dreamcast.toolchain.cmake +# +# or alternatively: +# +# cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=${KOS_CMAKE_TOOLCHAIN} +# +# Frame pointers are enabled in debug builds as these are required for +# stack traces and GDB. They are disabled in release. +# +# The original toolchain file was created by Kazade for the Simulant +# engine who has graciously allowed the rest of the scene to warez it. + +cmake_minimum_required(VERSION 3.23) + +#### Set Configuration Variables From Environment #### +if(NOT DEFINED KOS_BASE) + if(NOT DEFINED ENV{KOS_BASE}) + message(FATAL_ERROR "Variable KOS_BASE not set and was not found in the environment") + endif() + set(KOS_BASE $ENV{KOS_BASE}) + message("KOS_BASE: ${KOS_BASE}") +endif() + +if(NOT DEFINED KOS_CC_BASE) + if(NOT DEFINED ENV{KOS_CC_BASE}) + message(FATAL_ERROR "Variable KOS_CC_BASE not set and was not found in the environment") + endif() + set(KOS_CC_BASE $ENV{KOS_CC_BASE}) + message("KOS_CC_BASE: ${KOS_CC_BASE}") +endif() + +if(NOT DEFINED KOS_SUBARCH) + if(NOT DEFINED ENV{KOS_SUBARCH}) + message(FATAL_ERROR "Variable KOS_SUBARCH not set and was not found in the environment") + endif() + set(KOS_SUBARCH $ENV{KOS_SUBARCH}) + message("KOS_SUBARCH: ${KOS_SUBARCH}") +endif() + +if(NOT DEFINED KOS_PORTS) + if(NOT DEFINED ENV{KOS_PORTS}) + message(FATAL_ERROR "Variable KOS_PORTS not set and was not found in the environment") + endif() + set(KOS_PORTS $ENV{KOS_PORTS}) + message("KOS_PORTS: ${KOS_PORTS}") +endif() + +##### Configure CMake System ##### +set(CMAKE_SYSTEM_NAME Generic-ELF) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR SH4) +set(PLATFORM_DREAMCAST TRUE) + +##### Configure Cross-Compiler ##### +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_C_COMPILER ${KOS_CC_BASE}/bin/sh-elf-gcc) +set(CMAKE_CXX_COMPILER ${KOS_CC_BASE}/bin/sh-elf-g++) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + +# Never use the CMAKE_FIND_ROOT_PATH to find programs with find_program() +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +##### Add Platform-Specific #defines ##### +ADD_DEFINITIONS( + -D__DREAMCAST__ + -D_arch_dreamcast +) + +if(${KOS_SUBARCH} MATCHES naomi) + ADD_DEFINITONS( + -D__NAOMI__ + -D_arch_sub_naomi + ) +else() + ADD_DEFINITIONS(-D_arch_sub_pristine) +endif() + +##### Configure Build Flags ##### +add_compile_options(-ml -m4-single-only -ffunction-sections -fdata-sections) + +set(ENABLE_DEBUG_FLAGS $<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>) +set(ENABLE_RELEASE_FLAGS $<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>) + +add_compile_options( + "$<${ENABLE_DEBUG_FLAGS}:-DFRAME_POINTERS;-fno-omit-frame-pointer>" + "$<${ENABLE_RELEASE_FLAGS}:-fomit-frame-pointer>" + ) + +set(CMAKE_ASM_FLAGS "") +set(CMAKE_ASM_FLAGS_RELEASE "") + +##### Configure Include Directories ##### +set(CMAKE_SYSTEM_INCLUDE_PATH "${CMAKE_SYSTEM_INCLUDE_PATH} ${KOS_BASE}/include ${KOS_BASE}/kernel/arch/dreamcast/include ${KOS_BASE}/addons/include ${KOS_PORTS}/include") + +INCLUDE_DIRECTORIES( + $ENV{KOS_BASE}/include + $ENV{KOS_BASE}/kernel/arch/dreamcast/include + $ENV{KOS_BASE}/addons/include + $ENV{KOS_PORTS}/include +) + +##### Configure Libraries ##### +set(CMAKE_SYSTEM_LIBRARY_PATH "${CMAKE_SYSTEM_LIBRARY_PATH} ${KOS_BASE}/addons/lib/dreamcast ${KOS_PORTS}/lib") + +if(${KOS_SUBARCH} MATCHES naomi) + add_link_options(-Wl,-Ttext=0x8c020000 -T${KOS_BASE}/utils/ldscripts/shlelf-naomi.xc) +else() + add_link_options(-Wl,-Ttext=0x8c010000 -T${KOS_BASE}/utils/ldscripts/shlelf.xc) +endif() + +add_link_options(-ml -m4-single-only -Wl,--gc-sections -nodefaultlibs) + +LINK_DIRECTORIES( + ${KOS_BASE}/lib/dreamcast + ${KOS_BASE}/addons/lib/dreamcast + ${KOS_PORTS}/lib +) + +add_link_options(-L${KOS_BASE}/lib/dreamcast -L${KOS_BASE}/addons/lib/dreamcast -L${KOS_PORTS}/lib) +LINK_LIBRARIES(-Wl,--start-group -lstdc++ -lkallisti -lc -lgcc -Wl,--end-group m) \ No newline at end of file hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-31 19:37: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 4c7ef784f214b83ef5503fe2a56145e68f93bb75 (commit) via b69def42a7a046e43d4b5d85bf3a8770d67de87f (commit) via f58eaa82c102eae29d64aa1d6ceb296ca948cae9 (commit) via 667764379bd03078847481edc7328955cba65391 (commit) via 6f5ff8997e907aa5a68dedccb02ffbc8e621df12 (commit) via 5b8865f9ab8518366c19eb1ccac2596ef6a6306f (commit) via 810ac57d3c2bfdc05bea12abdb0ec0e12d4fafe6 (commit) from 35364a74b969f71c422a98f214fbf3599a4a914f (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 4c7ef784f214b83ef5503fe2a56145e68f93bb75 Merge: 35364a7 b69def4 Author: Lawrence Sebald <ljs...@us...> Date: Fri Mar 31 15:37:07 2023 -0400 Merge pull request #139 from Dreamcast-Projects/master Added timer_ns_gettime64() and performance counters commit b69def42a7a046e43d4b5d85bf3a8770d67de87f Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 08:37:23 2023 -0700 Updated entry position in Changelog. Return a value using micro seconds timer to generate a nanoseconds value instead of returning 0 commit f58eaa82c102eae29d64aa1d6ceb296ca948cae9 Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 01:21:01 2023 -0700 Added inline to speed things up commit 667764379bd03078847481edc7328955cba65391 Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 00:50:38 2023 -0700 Updated Changelog commit 6f5ff8997e907aa5a68dedccb02ffbc8e621df12 Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 00:46:21 2023 -0700 Fix comment typo commit 5b8865f9ab8518366c19eb1ccac2596ef6a6306f Merge: 810ac57 35364a7 Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 00:42:35 2023 -0700 Merge branch 'KallistiOS:master' into master commit 810ac57d3c2bfdc05bea12abdb0ec0e12d4fafe6 Author: Andress Barajas <and...@gm...> Date: Fri Mar 31 00:41:13 2023 -0700 Added timer_ns_gettime64() ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/include/arch/timer.h | 140 ++++++++++++++++++++++++++++- kernel/arch/dreamcast/kernel/init.c | 1 + kernel/arch/dreamcast/kernel/timer.c | 77 +++++++++++++++- 4 files changed, 216 insertions(+), 3 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index cb6ed7f..8de8b48 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -157,6 +157,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Removed "navi" subarch, moved code to addons/libnavi [LS] - *** Removed (completely unsupported) support for GCC 3.x and older [LS] - *** Add timespec_get C11 function to koslib's libc [LS] +- DC Added timer_ns_gettime64() and performance counters [AB] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/kernel/arch/dreamcast/include/arch/timer.h b/kernel/arch/dreamcast/include/arch/timer.h index 82fa661..4286cf1 100644 --- a/kernel/arch/dreamcast/include/arch/timer.h +++ b/kernel/arch/dreamcast/include/arch/timer.h @@ -51,7 +51,7 @@ __BEGIN_DECLS KallistiOS does not currently support using this timer. */ -#define WDT 3 +#define WDT 3 /** \brief Which timer does the thread system use? */ #define TIMER_ID TMU0 @@ -225,6 +225,144 @@ int timer_init(); void timer_shutdown(); /* \endcond */ +/** \brief SH4 Performance Counter. + + This counter is used by the ns_gettime function in this header. +*/ +#define PRFC0 0 + +/** \brief SH4 Performance Counter. + + A counter that is not used by KOS. +*/ +#define PRFC1 1 + +/** \brief CPU Cycles Count Type + + Count cycles. At 5 ns increments, a 48-bit cycle counter can + run continuously for 16.33 days. +*/ +#define PMCR_COUNT_CPU_CYCLES 0 + +/** \brief Ratio Cycles Count Type + + CPU/bus ratio mode where cycles (where T = C x B / 24 and T is time, + C is count, and B is time of one bus cycle). +*/ +#define PMCR_COUNT_RATIO_CYCLES 1 + +/* MODE DEFINITION VALUE MEASURMENT TYPE & NOTES */ +#define PMCR_INIT_NO_MODE 0x00 /* None; Just here to be complete */ +#define PMCR_OPERAND_READ_ACCESS_MODE 0x01 /* Quantity; With cache */ +#define PMCR_OPERAND_WRITE_ACCESS_MODE 0x02 /* Quantity; With cache */ +#define PMCR_UTLB_MISS_MODE 0x03 /* Quantity */ +#define PMCR_OPERAND_CACHE_READ_MISS_MODE 0x04 /* Quantity */ +#define PMCR_OPERAND_CACHE_WRITE_MISS_MODE 0x05 /* Quantity */ +#define PMCR_INSTRUCTION_FETCH_MODE 0x06 /* Quantity; With cache */ +#define PMCR_INSTRUCTION_TLB_MISS_MODE 0x07 /* Quantity */ +#define PMCR_INSTRUCTION_CACHE_MISS_MODE 0x08 /* Quantity */ +#define PMCR_ALL_OPERAND_ACCESS_MODE 0x09 /* Quantity */ +#define PMCR_ALL_INSTRUCTION_FETCH_MODE 0x0a /* Quantity */ +#define PMCR_ON_CHIP_RAM_OPERAND_ACCESS_MODE 0x0b /* Quantity */ +/* No 0x0c */ +#define PMCR_ON_CHIP_IO_ACCESS_MODE 0x0d /* Quantity */ +#define PMCR_OPERAND_ACCESS_MODE 0x0e /* Quantity; With cache, counts both reads and writes */ +#define PMCR_OPERAND_CACHE_MISS_MODE 0x0f /* Quantity */ +#define PMCR_BRANCH_ISSUED_MODE 0x10 /* Quantity; Not the same as branch taken! */ +#define PMCR_BRANCH_TAKEN_MODE 0x11 /* Quantity */ +#define PMCR_SUBROUTINE_ISSUED_MODE 0x12 /* Quantity; Issued a BSR, BSRF, JSR, JSR/N */ +#define PMCR_INSTRUCTION_ISSUED_MODE 0x13 /* Quantity */ +#define PMCR_PARALLEL_INSTRUCTION_ISSUED_MODE 0x14 /* Quantity */ +#define PMCR_FPU_INSTRUCTION_ISSUED_MODE 0x15 /* Quantity */ +#define PMCR_INTERRUPT_COUNTER_MODE 0x16 /* Quantity */ +#define PMCR_NMI_COUNTER_MODE 0x17 /* Quantity */ +#define PMCR_TRAPA_INSTRUCTION_COUNTER_MODE 0x18 /* Quantity */ +#define PMCR_UBC_A_MATCH_MODE 0x19 /* Quantity */ +#define PMCR_UBC_B_MATCH_MODE 0x1a /* Quantity */ +/* No 0x1b-0x20 */ +#define PMCR_INSTRUCTION_CACHE_FILL_MODE 0x21 /* Cycles */ +#define PMCR_OPERAND_CACHE_FILL_MODE 0x22 /* Cycles */ +#define PMCR_ELAPSED_TIME_MODE 0x23 /* Cycles; For 200MHz CPU: 5ns per count in 1 cycle = 1 count mode, or around 417.715ps per count (increments by 12) in CPU/bus ratio mode */ +#define PMCR_PIPELINE_FREEZE_BY_ICACHE_MISS_MODE 0x24 /* Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_DCACHE_MISS_MODE 0x25 /* Cycles */ +/* No 0x26 */ +#define PMCR_PIPELINE_FREEZE_BY_BRANCH_MODE 0x27 /* Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_CPU_REGISTER_MODE 0x28 /* Cycles */ +#define PMCR_PIPELINE_FREEZE_BY_FPU_MODE 0x29 /* Cycles */ + +/** \brief Get a performance counter's settings. + + This function returns a performance counter's settings. + + \param which The performance counter (i.e, \ref PRFC0 or PRFC1). + \retval 0 On success. +*/ +uint16 perf_cntr_get_config(int which); + +/** \brief Start a performance counter. + + This function starts a performance counter + + \param which The counter to start (i.e, \ref PRFC0 or PRFC1). + \param mode Use one of the 33 modes listed above. + \param count_type PMCR_COUNT_CPU_CYCLES or PMCR_COUNT_RATIO_CYCLES. + \retval 0 On success. +*/ +int perf_cntr_start(int which, int mode, int count_type); + +/** \brief Stop a performance counter. + + This function stops a performance counter that was started with perf_cntr_start(). + Stopping a counter retains its count. To clear the count use perf_cntr_clear(). + + \param which The counter to stop (i.e, \ref PRFC0 or PRFC1). + \retval 0 On success. +*/ +int perf_cntr_stop(int which); + +/** \brief Clear a performance counter + + This function clears a performance counter. It resets its value to zero. + You cannot clear a running counter. This function stops the counter before + clearing it because you cant clear a running counter. + + \param which The counter to clear (i.e, \ref PRFC0 or PRFC1). + \retval 0 On success. +*/ +int perf_cntr_clear(int which); + +/** \brief Obtain the count of a performance counter. + + This function simply returns the count of the counter. + + \param which The counter to read (i.e, \ref PRFC0 or PRFC1). + \return The counter's count. +*/ +uint64 perf_cntr_count(int which); + +/** \brief Enable the nanosecond timer. + + This function enables the performance counter used for the timer_ns_gettime64() + function. This is on by default. The function uses \ref PRFC0 to do the work. +*/ +void timer_ns_enable(); + +/** \brief Disable the nanosecond timer. + + This function disables the performance counter used for the timer_ns_gettime64() + function. Generally, you will not want to do this, unless you have some need to use + the counter \ref PRFC0 for something else. +*/ +void timer_ns_disable(); + +/** \brief Get the current uptime of the system (in nanoseconds). + + This function retrieves the number of nanoseconds since KOS was started. + + \return The number of nanoseconds since KOS started. +*/ +uint64 timer_ns_gettime64(); + __END_DECLS #endif /* __ARCH_TIMER_H */ diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index bb51d60..2b6ab91 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -101,6 +101,7 @@ int __attribute__((weak)) arch_auto_init() { hardware_sys_init(); /* DC low-level hardware init */ /* Initialize our timer */ + timer_ns_enable(); timer_ms_enable(); rtc_init(); diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c index bfa52ad..3829781 100644 --- a/kernel/arch/dreamcast/kernel/timer.c +++ b/kernel/arch/dreamcast/kernel/timer.c @@ -120,8 +120,6 @@ void timer_spin_sleep(int ms) { timer_stop(TMU1); } - - /* Enable timer interrupts (high priority); needs to move to irq.c sometime. */ void timer_enable_ints(int which) { @@ -316,5 +314,80 @@ void timer_shutdown() { timer_disable_ints(TMU2); } +/* Quick access macros */ +#define PMCR_CTRL(o) ( *((volatile uint16*)(0xff000084) + (o << 1)) ) +#define PMCTR_HIGH(o) ( *((volatile uint32*)(0xff100004) + (o << 1)) ) +#define PMCTR_LOW(o) ( *((volatile uint32*)(0xff100008) + (o << 1)) ) + +#define PMCR_CLR 0x2000 +#define PMCR_PMST 0x4000 +#define PMCR_PMENABLE 0x8000 +#define PMCR_RUN 0xc000 +#define PMCR_PMM_MASK 0x003f + +#define PMCR_CLOCK_TYPE_SHIFT 8 + +/* 5ns per count in 1 cycle = 1 count mode(PMCR_COUNT_CPU_CYCLES) */ +#define NS_PER_CYCLE 5 + +/* Get a counter's current configuration */ +uint16 perf_cntr_get_config(int which) { + return PMCR_CTRL(which); +} + +/* Start a performance counter */ +int perf_cntr_start(int which, int mode, int count_type) { + perf_cntr_stop(which); + perf_cntr_clear(which); + PMCR_CTRL(which) = PMCR_RUN | mode | (count_type << PMCR_CLOCK_TYPE_SHIFT); + + return 0; +} + +/* Stop a performance counter */ +int perf_cntr_stop(int which) { + PMCR_CTRL(which) &= ~(PMCR_PMM_MASK | PMCR_PMENABLE); + + return 0; +} + +/* Clears a performance counter */ +int perf_cntr_clear(int which) { + PMCR_CTRL(which) |= PMCR_CLR; + return 0; +} + +/* Returns the count value of a counter */ +inline uint64 perf_cntr_count(int which) { + return (uint64)(PMCTR_HIGH(which) & 0xffff) << 32 | PMCTR_LOW(which); +} + +void timer_ns_enable() { + perf_cntr_start(PRFC0, PMCR_ELAPSED_TIME_MODE, PMCR_COUNT_CPU_CYCLES); +} + +void timer_ns_disable() { + uint16 config = PMCR_CTRL(PRFC0); + + /* If timer is running, disable it */ + if((config & PMCR_ELAPSED_TIME_MODE)) { + perf_cntr_stop(PRFC0); + perf_cntr_clear(PRFC0); + } +} + +inline uint64 timer_ns_gettime64() { + uint16 config = PMCR_CTRL(PRFC0); + + /* If timer is running */ + if((config & PMCR_ELAPSED_TIME_MODE)) { + uint64 cycles = perf_cntr_count(PRFC0); + return cycles * NS_PER_CYCLE; + } + else { + uint64 micro_secs = timer_us_gettime64(); + return micro_secs * 1000; + } +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-30 19:10: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 35364a74b969f71c422a98f214fbf3599a4a914f (commit) from 8982377032426e3a5820d94cd580cf14f85001c5 (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 35364a74b969f71c422a98f214fbf3599a4a914f Author: Lawrence Sebald <ljs...@us...> Date: Thu Mar 30 15:10:06 2023 -0400 Move <kos/time.h> include to ensure it always can be accessed from <time.h> ----------------------------------------------------------------------- Summary of changes: include/sys/_types.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sys/_types.h b/include/sys/_types.h index 547f828..664907a 100644 --- a/include/sys/_types.h +++ b/include/sys/_types.h @@ -203,11 +203,6 @@ typedef _CLOCK_T_ __clock_t; /* Include stuff to make pthreads work as well. */ #include <sys/_pthread.h> -/* Grab our C11 time stuff if we got here from <time.h>. */ -#ifdef _TIME_H_ -#include <kos/time.h> -#endif - #ifndef __RESTRICT #if (__STDC_VERSION__ >= 199901L) #define __RESTRICT restrict @@ -227,3 +222,8 @@ typedef char * __va_list; __END_DECLS #endif /* _SYS__TYPES_H */ + +/* Grab our C11 time stuff if we got here from <time.h>. */ +#ifdef _TIME_H_ +#include <kos/time.h> +#endif hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-29 19:02:51
|
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 8982377032426e3a5820d94cd580cf14f85001c5 (commit) from 7237ac56f9141d130c3dac749ccb4becabcd1df5 (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 8982377032426e3a5820d94cd580cf14f85001c5 Author: Lawrence Sebald <ljs...@us...> Date: Wed Mar 29 15:02:27 2023 -0400 timespec_get: add back in missing return. ----------------------------------------------------------------------- Summary of changes: kernel/libc/c11/timespec_get.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/libc/c11/timespec_get.c b/kernel/libc/c11/timespec_get.c index a1f05dc..5a9a850 100644 --- a/kernel/libc/c11/timespec_get.c +++ b/kernel/libc/c11/timespec_get.c @@ -15,6 +15,8 @@ int timespec_get(struct timespec *ts, int base) { timer_ms_gettime(&s, &ms); ts->tv_sec = rtc_boot_time() + s; ts->tv_nsec = ms * 1000 * 1000; + + return base; } return 0; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-29 02:59: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 7237ac56f9141d130c3dac749ccb4becabcd1df5 (commit) from 11cd2c47cf3c025273784d61da08d56fb38495ee (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 7237ac56f9141d130c3dac749ccb4becabcd1df5 Author: Lawrence Sebald <ljs...@us...> Date: Tue Mar 28 22:58:59 2023 -0400 Add timespec_get to libc/c11. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/time.h | 33 +++++++++++++++++++++++++++++++++ include/sys/_types.h | 9 +++++++-- kernel/libc/c11/Makefile | 4 ++-- kernel/libc/c11/timespec_get.c | 21 +++++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 include/kos/time.h create mode 100644 kernel/libc/c11/timespec_get.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 2dbec9a..cb6ed7f 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -156,6 +156,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Fixed wildly out of range start for pvrmark benchmark [Falco Girgis == FG] - DC Removed "navi" subarch, moved code to addons/libnavi [LS] - *** Removed (completely unsupported) support for GCC 3.x and older [LS] +- *** Add timespec_get C11 function to koslib's libc [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/include/kos/time.h b/include/kos/time.h new file mode 100644 index 0000000..78279b5 --- /dev/null +++ b/include/kos/time.h @@ -0,0 +1,33 @@ +/* KallistiOS ##version## + + kos/time.h + Copyright (C) 2023 Lawrence Sebald +*/ + +/* This will probably go away at some point in the future, if/when Newlib gets + an implementation of this function. But for now, it's here. */ + +#ifndef _TIME_H_ +#error "Do not include this file directly. Use <time.h> instead." +#endif /* !_TIME_H_ */ + +#ifndef __KOS_TIME_H +#define __KOS_TIME_H + +#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) + +#include <kos/cdefs.h> + +__BEGIN_DECLS + +/* Forward declaration. */ +struct timespec; + +#define TIME_UTC 1 + +extern int timespec_get(struct timespec *ts, int base); + +__END_DECLS + +#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) */ +#endif /* !__KOS_C11TIME_H */ diff --git a/include/sys/_types.h b/include/sys/_types.h index 6a95a24..547f828 100644 --- a/include/sys/_types.h +++ b/include/sys/_types.h @@ -197,12 +197,17 @@ typedef _CLOCK_T_ __clock_t; #define IOV_MAX 1024 #endif -// And this is for old KOS source compatability. +/* This is for old KOS source compatability. */ #include <arch/types.h> -// Include stuff to make pthreads work as well. +/* Include stuff to make pthreads work as well. */ #include <sys/_pthread.h> +/* Grab our C11 time stuff if we got here from <time.h>. */ +#ifdef _TIME_H_ +#include <kos/time.h> +#endif + #ifndef __RESTRICT #if (__STDC_VERSION__ >= 199901L) #define __RESTRICT restrict diff --git a/kernel/libc/c11/Makefile b/kernel/libc/c11/Makefile index df0b67f..4328d16 100644 --- a/kernel/libc/c11/Makefile +++ b/kernel/libc/c11/Makefile @@ -1,7 +1,7 @@ # KallistiOS ##version## # # kernel/libc/c11/Makefile -# Copyright (C) 2014, 2015 Lawrence Sebald +# Copyright (C) 2014, 2015, 2023 Lawrence Sebald # KOS_CFLAGS += -std=c11 @@ -11,6 +11,6 @@ OBJS = call_once.o cnd_broadcast.o cnd_destroy.o cnd_init.o cnd_signal.o \ mtx_timedlock.o mtx_trylock.o mtx_unlock.o thrd_create.o thrd_current.o \ thrd_detach.o thrd_equal.o thrd_exit.o thrd_join.o thrd_sleep.o \ thrd_yield.o tss_create.o tss_delete.o tss_get.o tss_set.o \ - aligned_alloc.o + aligned_alloc.o timespec_get.o include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/libc/c11/timespec_get.c b/kernel/libc/c11/timespec_get.c new file mode 100644 index 0000000..a1f05dc --- /dev/null +++ b/kernel/libc/c11/timespec_get.c @@ -0,0 +1,21 @@ +/* KallistiOS ##version## + + timespec_get.c + Copyright (C) 2023 Lawrence Sebald +*/ + +#include <time.h> +#include <arch/timer.h> +#include <arch/rtc.h> + +int timespec_get(struct timespec *ts, int base) { + if(base == TIME_UTC && ts) { + uint32 s, ms; + + timer_ms_gettime(&s, &ms); + ts->tv_sec = rtc_boot_time() + s; + ts->tv_nsec = ms * 1000 * 1000; + } + + return 0; +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-27 14:53:49
|
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 11cd2c47cf3c025273784d61da08d56fb38495ee (commit) via 6b006f17192bc27e49ac607fb90d96f456ecbce4 (commit) from 6ab415e46b610a38b3b46d06c450a8d024a9cd66 (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 11cd2c47cf3c025273784d61da08d56fb38495ee Merge: 6ab415e 6b006f1 Author: Lawrence Sebald <ljs...@us...> Date: Mon Mar 27 10:53:15 2023 -0400 Merge pull request #138 from KallistiOS/authors-change Add Colton Pawielski to AUTHORS commit 6b006f17192bc27e49ac607fb90d96f456ecbce4 Author: darcagn <da...@pr...> Date: Sun Mar 26 22:23:58 2023 -0500 Add Colton Pawielski to AUTHORS ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 326a61d..e601e26 100644 --- a/AUTHORS +++ b/AUTHORS @@ -45,6 +45,7 @@ Luke Benstead: 2020, 2021 Eric Fradella: 2023 Falco Girgis: 2023 Ruslan Rostovtsev: 2014, 2016, 2023 +Colton Pawielski: 2023 Files with Specific licenses: ----------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-27 03:20:27
|
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 6ab415e46b610a38b3b46d06c450a8d024a9cd66 (commit) via 4d9d2116d52484b70177902618f3828e8660bb8b (commit) from 50501862f2535d496fed4fd00adbd3769af2adbe (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 6ab415e46b610a38b3b46d06c450a8d024a9cd66 Merge: 5050186 4d9d211 Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 26 23:18:24 2023 -0400 Merge pull request #137 from cepawiel/dcchain-disable-patching Add use_kos_patches option to dc-chain config commit 4d9d2116d52484b70177902618f3828e8660bb8b Author: Colton Pawielski <cep...@mt...> Date: Thu Mar 23 19:59:37 2023 -0500 Add use_kos_patches option to dc-chain config Adds the ability to build fully raw toolchains without applying any KOS patches. As it was the patchs would still be applied causing modifications to the sh-elf target's compile options. ----------------------------------------------------------------------- Summary of changes: utils/dc-chain/Makefile | 2 +- utils/dc-chain/README.md | 14 ++++++++++++-- utils/dc-chain/config.mk.legacy.sample | 10 +++++++--- utils/dc-chain/config.mk.stable.sample | 5 +++++ utils/dc-chain/config.mk.testing.sample | 5 +++++ utils/dc-chain/scripts/init.mk | 18 ++++++++++++++++-- utils/dc-chain/scripts/patch.mk | 13 +++++++++++++ 7 files changed, 59 insertions(+), 8 deletions(-) diff --git a/utils/dc-chain/Makefile b/utils/dc-chain/Makefile index 75e8c0d..6b216b0 100644 --- a/utils/dc-chain/Makefile +++ b/utils/dc-chain/Makefile @@ -29,7 +29,7 @@ include scripts/init.mk # Makefile variables include scripts/variables.mk -all: patch build +all: build # ---- patch {{{ diff --git a/utils/dc-chain/README.md b/utils/dc-chain/README.md index c46e508..7327626 100644 --- a/utils/dc-chain/README.md +++ b/utils/dc-chain/README.md @@ -237,13 +237,23 @@ This flag is here mainly for producing [DreamSDK](https://dreamsdk.org). ### Automatic fixup SH-4 Newlib (use with care) Set `auto_fixup_sh4_newlib` to `0` if you want to disable the automatic fixup -SH-4 Newlib needed by KallistiOS. This will keep the generated toolchain -completely raw. +SH-4 Newlib needed by KallistiOS. Setting this option along with +`use_kos_patches=0` will keep the generated toolchain completely raw. **Note:** If you disable this flag, the KallistiOS threading model (`kos`) will be unavailable. Also, this may be a problem if you still apply the KallistiOS patches. **Use this flag with care**. +### Automatic KOS Patching (use with care) +Set `use_kos_patches` to `0` if you want to skip applying the KOS patches +to the downloaded sources before building. Setting this option along with +`auto_fixup_sh4_newlib=0` will keep the generated toolchain completely raw. + +**Note:** If you disable this flag, the KallistiOS threading model (`kos`) will +be unavailable. Also, this may be a problem if you still apply the KallistiOS +patches. **Use this flag with care**. + + ## Usage After installing all the prerequisites and tweaking the configuration with the diff --git a/utils/dc-chain/config.mk.legacy.sample b/utils/dc-chain/config.mk.legacy.sample index f3f3e43..42202b9 100644 --- a/utils/dc-chain/config.mk.legacy.sample +++ b/utils/dc-chain/config.mk.legacy.sample @@ -141,11 +141,15 @@ install_mode=install-strip # Automatic fixup SH-4 Newlib (1|0) # Uncomment this if you want to disable the automatic fixup sh4 newlib needed by -# KallistiOS. This will keep the generated toolchain completely raw. This will -# also disable the 'kos' thread model. Don't mess with that flag unless you know -# exactly what you are doing. +# KallistiOS. This will also disable the 'kos' thread model. Don't mess with that +# flag unless you know exactly what you are doing. #auto_fixup_sh4_newlib=0 +# Automatic patching for KOS (1|0) +# Uncomment this if you want to disable applying KOS patches to the toolchain +# source files before building. This will disable usage of the 'kos' thread model. +#use_kos_patches=0 + # Force installation of BFD for SH (1|0) # Uncomment this if you want to force the installation of 'libbfd' for the SH # toolchain. This is required for MinGW/MSYS and can't be disabled in this diff --git a/utils/dc-chain/config.mk.stable.sample b/utils/dc-chain/config.mk.stable.sample index c06b9b9..99533a1 100644 --- a/utils/dc-chain/config.mk.stable.sample +++ b/utils/dc-chain/config.mk.stable.sample @@ -146,6 +146,11 @@ install_mode=install-strip # exactly what you are doing. #auto_fixup_sh4_newlib=0 +# Automatic patching for KOS (1|0) +# Uncomment this if you want to disable applying KOS patches to the toolchain +# source files before building. This will disable usage of the 'kos' thread model. +#use_kos_patches=0 + # Force installation of BFD for SH (1|0) # Uncomment this if you want to force the installation of 'libbfd' for the SH # toolchain. This is required for MinGW/MSYS and can't be disabled in this diff --git a/utils/dc-chain/config.mk.testing.sample b/utils/dc-chain/config.mk.testing.sample index 1823548..a1f5db5 100644 --- a/utils/dc-chain/config.mk.testing.sample +++ b/utils/dc-chain/config.mk.testing.sample @@ -146,6 +146,11 @@ install_mode=install-strip # exactly what you are doing. #auto_fixup_sh4_newlib=0 +# Automatic patching for KOS (1|0) +# Uncomment this if you want to disable applying KOS patches to the toolchain +# source files before building. This will disable usage of the 'kos' thread model. +#use_kos_patches=0 + # Force installation of BFD for SH (1|0) # Uncomment this if you want to force the installation of 'libbfd' for the SH # toolchain. This is required for MinGW/MSYS and can't be disabled in this diff --git a/utils/dc-chain/scripts/init.mk b/utils/dc-chain/scripts/init.mk index 8063bf9..b90e61a 100644 --- a/utils/dc-chain/scripts/init.mk +++ b/utils/dc-chain/scripts/init.mk @@ -114,12 +114,26 @@ curl_cmd=curl -C - -O do_auto_fixup_sh4_newlib := 1 ifdef auto_fixup_sh4_newlib ifeq (0,$(auto_fixup_sh4_newlib)) + $(warning 'Disabling Newlib Auto Fixup) do_auto_fixup_sh4_newlib := 0 endif endif -ifeq (0,$(do_auto_fixup_sh4_newlib)) - ifeq (kos,$(thread_model)) +# Determine if we want to apply KOS patches to GCC/Newlib/Binutils +do_kos_patching := 1 +ifdef use_kos_patches + ifeq (0,$(use_kos_patches)) + $(warning 'Disabling KOS Patches) + do_kos_patching := 0 + endif +endif + +# Report an error if KOS threading is enabled when patching or fixup is disabled +ifeq (kos,$(thread_model)) + ifeq (0,$(do_auto_fixup_sh4_newlib)) $(error kos thread model is unsupported when Newlib fixup is disabled) endif + ifeq (0,$(do_kos_patching)) + $(error kos thread model is unsupported when KOS patches are disabled) + endif endif diff --git a/utils/dc-chain/scripts/patch.mk b/utils/dc-chain/scripts/patch.mk index bb64f16..6901a25 100644 --- a/utils/dc-chain/scripts/patch.mk +++ b/utils/dc-chain/scripts/patch.mk @@ -32,6 +32,19 @@ patch_gcc = patch-sh4-gcc patch-arm-gcc patch_newlib = patch-sh4-newlib patch_kos = patch-kos +# Patch +# Apply sh4 newlib fixups (default is yes and this should be always the case!) +ifeq (1,$(do_kos_patching)) +# Add Build Pre-Requisites for SH4 Steps + build-sh4-binutils: patch-sh4-binutils + build-sh4-gcc-pass1 build-sh4-gcc-pass2: patch-sh4-gcc + build-sh4-newlib-only: patch-sh4-newlib + +# Add Build Pre-Requisites for ARM Steps + build-arm-binutils: patch-arm-binutils + build-arm-gcc-pass1: patch-arm-gcc +endif + uname_p := $(shell uname -p) uname_s := $(shell uname -s) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-26 21:24: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 50501862f2535d496fed4fd00adbd3769af2adbe (commit) from 547d44653ef7cb5a5d3e7c6615284c3ea0e0a3aa (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 50501862f2535d496fed4fd00adbd3769af2adbe Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 26 17:23:40 2023 -0400 Call fs_dev_shutdown() and make sure no linker errors come up later. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/init.c | 3 +++ kernel/fs/fs_dev.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index 88bd685..bb51d60 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -201,6 +201,9 @@ void __attribute__((weak)) arch_auto_shutdown() { vmufs_shutdown(); #ifndef _arch_sub_naomi fs_iso9660_shutdown(); +#endif +#if defined(__NEWLIB__) && !(__NEWLIB__ < 2 && __NEWLIB_MINOR__ < 4) + fs_dev_shutdown(); #endif fs_ramdisk_shutdown(); fs_romdisk_shutdown(); diff --git a/kernel/fs/fs_dev.c b/kernel/fs/fs_dev.c index dcd00d5..5ba5d76 100644 --- a/kernel/fs/fs_dev.c +++ b/kernel/fs/fs_dev.c @@ -20,7 +20,17 @@ /* This function is declared in <stdlib.h> but behind an if __BSD_VISIBLE Declaring as extern here to avoid implicit declaration */ -void arc4random_buf (void *, size_t); +extern void arc4random_buf(void *, size_t); + +#if !defined(__NEWLIB__) || (__NEWLIB__ < 2 && __NEWLIB_MINOR__ < 4) +/* Ensure the function is defined on versions of Newlib where it doesn't exist, + even though this isn't functional at all. This makes sure we don't get any + linker errors when -ffunction-sections isn't used, for instance. */ +void arc4random_buf(void *a, size_t b) { + (void)a; + (void)b; +} +#endif /* File handles */ typedef struct dev_fh_str { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-26 21:13: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 547d44653ef7cb5a5d3e7c6615284c3ea0e0a3aa (commit) via 3bd35d6d3ee3b886b60af8e24243a57d9c580973 (commit) via 035030b245c59f0ea374dcd0527a43aa42d1a3a4 (commit) via cbffea67a4ab28d7af3bd2ebac5f356c799efee9 (commit) via a22531bbee760d3e9ce4db56724cf34e05f7a8e5 (commit) from c84b74b52c9240cd02fe52d5f92d4d256d85ce69 (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 547d44653ef7cb5a5d3e7c6615284c3ea0e0a3aa Merge: c84b74b 3bd35d6 Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 26 17:11:59 2023 -0400 Merge pull request #136 from cepawiel/random-gcc4 Disable opening/reading random device when using GCC4 Toolchain commit 3bd35d6d3ee3b886b60af8e24243a57d9c580973 Author: Colton Pawielski <cep...@us...> Date: Wed Mar 15 16:40:37 2023 -0500 Change warning text to clarify limitation with newlib Co-authored-by: Lawrence Sebald <ljs...@us...> commit 035030b245c59f0ea374dcd0527a43aa42d1a3a4 Author: Colton Pawielski <cep...@us...> Date: Wed Mar 15 16:39:54 2023 -0500 Change CFLAGS to KOS_CFLAGS in random example Co-authored-by: Lawrence Sebald <ljs...@us...> commit cbffea67a4ab28d7af3bd2ebac5f356c799efee9 Author: Colton Pawielski <cep...@mt...> Date: Tue Mar 14 21:55:27 2023 -0500 Disable dev filesystem when newlib < 2.4.0 commit a22531bbee760d3e9ce4db56724cf34e05f7a8e5 Author: Colton Pawielski <cep...@mt...> Date: Tue Mar 14 17:20:17 2023 -0500 Add C99 flag to Random Example ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/random/Makefile | 2 ++ kernel/arch/dreamcast/kernel/init.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/examples/dreamcast/random/Makefile b/examples/dreamcast/random/Makefile index 7ac05a3..d294e73 100644 --- a/examples/dreamcast/random/Makefile +++ b/examples/dreamcast/random/Makefile @@ -14,6 +14,8 @@ OBJS = random.o romdisk.o # from the named dir. KOS_ROMDISK_DIR = romdisk +KOS_CFLAGS += -std=c99 + # The rm-elf step is to remove the target before building, to force the # re-creation of the rom disk. all: rm-elf $(TARGET) diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index 02efd4b..88bd685 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -116,7 +116,14 @@ int __attribute__((weak)) arch_auto_init() { fs_pty_init(); /* Pty */ fs_ramdisk_init(); /* Ramdisk */ fs_romdisk_init(); /* Romdisk */ + +/* The arc4random_buf() function used for random & urandom is only + available in newlib starting with version 2.4.0 */ +#if defined(__NEWLIB__) && !(__NEWLIB__ < 2 && __NEWLIB_MINOR__ < 4) fs_dev_init(); /* /dev/urandom etc. */ +#else +#warning "/dev filesystem is not supported with Newlib < 2.4.0" +#endif hardware_periph_init(); /* DC peripheral init */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-03-17 22:42:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c84b74b52c9240cd02fe52d5f92d4d256d85ce69 (commit) via 635da4bd1a43a04e374ed7360b275dae603d1421 (commit) via f29c981de99135692e2a9aa26f069cd07ead1d30 (commit) from 9f42456895517fc2a70dfb6f3a363ba38e684d7b (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 c84b74b52c9240cd02fe52d5f92d4d256d85ce69 Merge: 9f42456 635da4b Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 12 13:47:08 2023 -0400 Merge pull request #128 from cepawiel/seperate-build-folders Separate Pass 1 and Pass 2 GCC build directories. commit 635da4bd1a43a04e374ed7360b275dae603d1421 Author: Colton Pawielski <cep...@mt...> Date: Sat Mar 11 18:06:07 2023 -0600 Seperate build variable assign for build_gcc_pass1 Which will drop the "-pass1" name from the ARM toolchain build folder and log file As such the build folders will be named: build-gcc-sh-elf-<version>-pass1 build-gcc-sh-elf-<version>-pass2 build-gcc-arm-eabi-<version> Along with matching logs: build-gcc-sh-elf-<version>-pass1.log build-gcc-sh-elf-<version>-pass2.log build-gcc-arm-eabi-<version>.log commit f29c981de99135692e2a9aa26f069cd07ead1d30 Author: Colton Pawielski <cep...@mt...> Date: Sat Mar 11 10:58:33 2023 -0600 Seperate Pass 1 and Pass 2 GCC folders Using the same build folder for both was causing an issue in Pass 2 where our gthr-kos.h file was failing to replace the gthr-default.h file. This was causing issues with libstdc++ feature detection failing to figure out our threading support and thus things like std::thread and std::mutex wouldn't work properly on the GCC9 & GCC12 toolchains. ----------------------------------------------------------------------- Summary of changes: utils/dc-chain/scripts/clean.mk | 3 ++- utils/dc-chain/scripts/gcc-pass1.mk | 5 +++-- utils/dc-chain/scripts/gcc-pass2.mk | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/dc-chain/scripts/clean.mk b/utils/dc-chain/scripts/clean.mk index f869b82..5b73b95 100644 --- a/utils/dc-chain/scripts/clean.mk +++ b/utils/dc-chain/scripts/clean.mk @@ -21,7 +21,8 @@ clean_patches_stamp: clean: clean_patches_stamp -rm -rf build-newlib-$(sh_target)-$(newlib_ver) -rm -rf build-newlib-$(arm_target)-$(newlib_ver) - -rm -rf build-gcc-$(sh_target)-$(sh_gcc_ver) + -rm -rf build-gcc-$(sh_target)-$(sh_gcc_ver)-pass1 + -rm -rf build-gcc-$(sh_target)-$(sh_gcc_ver)-pass2 -rm -rf build-gcc-$(arm_target)-$(arm_gcc_ver) -rm -rf build-binutils-$(sh_target)-$(sh_binutils_ver) -rm -rf build-binutils-$(arm_target)-$(arm_binutils_ver) diff --git a/utils/dc-chain/scripts/gcc-pass1.mk b/utils/dc-chain/scripts/gcc-pass1.mk index b00cbeb..4150a2e 100644 --- a/utils/dc-chain/scripts/gcc-pass1.mk +++ b/utils/dc-chain/scripts/gcc-pass1.mk @@ -5,9 +5,10 @@ # Initially adapted from Stalin's build script version 0.3. # -$(build_gcc_pass1) $(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver) +build-sh4-gcc-pass1: build = build-gcc-$(target)-$(gcc_ver)-pass1 +build-arm-gcc-pass1: build = build-gcc-$(target)-$(gcc_ver) $(build_gcc_pass1) $(build_gcc_pass2): src_dir = gcc-$(gcc_ver) -$(build_gcc_pass1): log = $(logdir)/$(build)-pass1.log +$(build_gcc_pass1) $(build_gcc_pass2): log = $(logdir)/$(build).log $(build_gcc_pass1): logdir @echo "+++ Building $(src_dir) to $(build) (pass 1)..." -mkdir -p $(build) diff --git a/utils/dc-chain/scripts/gcc-pass2.mk b/utils/dc-chain/scripts/gcc-pass2.mk index 01419fc..accd4b8 100644 --- a/utils/dc-chain/scripts/gcc-pass2.mk +++ b/utils/dc-chain/scripts/gcc-pass2.mk @@ -5,7 +5,7 @@ # Initially adapted from Stalin's build script version 0.3. # -$(build_gcc_pass2): log = $(logdir)/$(build)-pass2.log +$(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver)-pass2 $(build_gcc_pass2): logdir @echo "+++ Building $(src_dir) to $(build) (pass 2)..." -mkdir -p $(build) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-13 04:03: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, warnings_fixes has been updated via c9c5b6cf4fb7d82951c63d03c54d763bec04296e (commit) via 0c66c5671d810a841a8357d7b2528ef6bb31f60f (commit) from ab924cb0e850aecf2eb46a758025504201def49f (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 c9c5b6cf4fb7d82951c63d03c54d763bec04296e Author: falco <gyr...@gm...> Date: Mon Mar 13 00:02:33 2023 -0400 Bumped down pragma for pack version check to GCC9 commit 0c66c5671d810a841a8357d7b2528ef6bb31f60f Author: falco <gyr...@gm...> Date: Sun Mar 12 23:59:57 2023 -0400 Updated changelog ----------------------------------------------------------------------- Summary of changes: addons/libkosfat/directory.c | 4 ++-- doc/CHANGELOG | 1 + kernel/net/net_icmp6.c | 4 ++-- kernel/net/net_ipv6.c | 4 ++-- kernel/net/net_udp.c | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/libkosfat/directory.c b/addons/libkosfat/directory.c index 66ee61c..0c45e09 100644 --- a/addons/libkosfat/directory.c +++ b/addons/libkosfat/directory.c @@ -18,7 +18,7 @@ #include "directory.h" #include "fatinternal.h" -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" #endif @@ -1397,6 +1397,6 @@ void fat_dentry_print(const fat_dentry_t *ent) { } #endif -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic pop #endif \ No newline at end of file diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 2dbec9a..47bae20 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -156,6 +156,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Fixed wildly out of range start for pvrmark benchmark [Falco Girgis == FG] - DC Removed "navi" subarch, moved code to addons/libnavi [LS] - *** Removed (completely unsupported) support for GCC 3.x and older [LS] +- *** Cleaned up all compiler warnings for all toolchains for KOS [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/kernel/net/net_icmp6.c b/kernel/net/net_icmp6.c index 30d9cd7..20e8850 100644 --- a/kernel/net/net_icmp6.c +++ b/kernel/net/net_icmp6.c @@ -16,7 +16,7 @@ #include "net_ipv6.h" #include "net_ipv4.h" /* For net_ipv4_checksum() */ -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" #endif @@ -808,6 +808,6 @@ int net_icmp6_send_param_prob(netif_t *net, uint8 code, uint32 ptr, mc_allow); } -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic pop #endif \ No newline at end of file diff --git a/kernel/net/net_ipv6.c b/kernel/net/net_ipv6.c index b0260b5..58b92c0 100644 --- a/kernel/net/net_ipv6.c +++ b/kernel/net/net_ipv6.c @@ -15,7 +15,7 @@ #include "net_icmp6.h" #include "net_ipv4.h" -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" #endif @@ -308,6 +308,6 @@ void net_ipv6_shutdown(void) { net_multicast_del(mac); } -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic pop #endif \ No newline at end of file diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index 5d68e37..1e05caf 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -23,7 +23,7 @@ #include "net_ipv4.h" #include "net_ipv6.h" -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" #endif @@ -1548,6 +1548,6 @@ void net_udp_shutdown(void) { fs_socket_proto_remove(&proto_lite); } -#if __GNUC__ >= 12 +#if __GNUC__ >= 9 #pragma GCC diagnostic pop #endif \ No newline at end of file hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-13 03:52:15
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, warnings_fixes has been updated via ab924cb0e850aecf2eb46a758025504201def49f (commit) from a79f74634c51efe9329f76e9b8b804d436e32cc5 (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 ab924cb0e850aecf2eb46a758025504201def49f Author: falco <gyr...@gm...> Date: Sun Mar 12 23:51:26 2023 -0400 Conditionally compiled out pack pragmas for <GCC12 - the warnings weren't even around on the testing and legacy toolchains. ----------------------------------------------------------------------- Summary of changes: addons/libkosfat/directory.c | 6 +++++- kernel/net/net_icmp6.c | 6 +++++- kernel/net/net_ipv6.c | 6 +++++- kernel/net/net_udp.c | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/addons/libkosfat/directory.c b/addons/libkosfat/directory.c index ad3c17e..66ee61c 100644 --- a/addons/libkosfat/directory.c +++ b/addons/libkosfat/directory.c @@ -18,8 +18,10 @@ #include "directory.h" #include "fatinternal.h" +#if __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif #ifdef __STRICT_ANSI__ /* These don't necessarily get prototyped in string.h in standard-compliant mode @@ -1395,4 +1397,6 @@ void fat_dentry_print(const fat_dentry_t *ent) { } #endif -#pragma GCC diagnostic pop \ No newline at end of file +#if __GNUC__ >= 12 +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/kernel/net/net_icmp6.c b/kernel/net/net_icmp6.c index 12879eb..30d9cd7 100644 --- a/kernel/net/net_icmp6.c +++ b/kernel/net/net_icmp6.c @@ -16,8 +16,10 @@ #include "net_ipv6.h" #include "net_ipv4.h" /* For net_ipv4_checksum() */ +#if __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif /* This file implements RFC 4443, the Internet Control Message Protocol for IPv6. @@ -806,4 +808,6 @@ int net_icmp6_send_param_prob(netif_t *net, uint8 code, uint32 ptr, mc_allow); } -#pragma GCC diagnostic pop \ No newline at end of file +#if __GNUC__ >= 12 +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/kernel/net/net_ipv6.c b/kernel/net/net_ipv6.c index c730a0e..b0260b5 100644 --- a/kernel/net/net_ipv6.c +++ b/kernel/net/net_ipv6.c @@ -15,8 +15,10 @@ #include "net_icmp6.h" #include "net_ipv4.h" +#if __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif static net_ipv6_stats_t ipv6_stats = { 0 }; const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; @@ -306,4 +308,6 @@ void net_ipv6_shutdown(void) { net_multicast_del(mac); } -#pragma GCC diagnostic pop \ No newline at end of file +#if __GNUC__ >= 12 +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index 39c5c74..5d68e37 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -23,8 +23,10 @@ #include "net_ipv4.h" #include "net_ipv6.h" +#if __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif /* Default hop limit (or ttl for IPv4) for new sockets */ #define UDP_DEFAULT_HOPS 64 @@ -1546,4 +1548,6 @@ void net_udp_shutdown(void) { fs_socket_proto_remove(&proto_lite); } -#pragma GCC diagnostic pop \ No newline at end of file +#if __GNUC__ >= 12 +#pragma GCC diagnostic pop +#endif \ No newline at end of file hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-13 03:44:08
|
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, warnings_fixes has been updated via a79f74634c51efe9329f76e9b8b804d436e32cc5 (commit) from 6b831840851c0d8c5a60f6c1e8134cc5fbc6d44b (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 a79f74634c51efe9329f76e9b8b804d436e32cc5 Author: falco <gyr...@gm...> Date: Sun Mar 12 23:43:41 2023 -0400 Fixed an uninitialized variable warning in GCC4.7 ----------------------------------------------------------------------- Summary of changes: addons/libnavi/navi_ide.c | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/libnavi/navi_ide.c b/addons/libnavi/navi_ide.c index 6fcd2ad..f5bf6ec 100644 --- a/addons/libnavi/navi_ide.c +++ b/addons/libnavi/navi_ide.c @@ -33,6 +33,7 @@ static void ide_outp(int port, uint16 value, int size) { break; default: assert(0); + return; } //printf("ide_outp %02x -> %04x(%08x)\n", value, port, addr); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-13 03:08: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, warnings_fixes has been updated via 6b831840851c0d8c5a60f6c1e8134cc5fbc6d44b (commit) from d0ced5dd50ced1da229a6adb9029d5a1cfdd38e6 (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 6b831840851c0d8c5a60f6c1e8134cc5fbc6d44b Author: falco <gyr...@gm...> Date: Sun Mar 12 23:07:05 2023 -0400 All warnings are now gone with GCC12! - removed warnings for taking pointers to members of packed structs by adding a pragma to ignore the warning for the scope of each file ----------------------------------------------------------------------- Summary of changes: addons/libkosfat/directory.c | 5 +++++ addons/libkosfat/directory.h | 2 ++ kernel/net/net_icmp6.c | 5 +++++ kernel/net/net_ipv6.c | 5 +++++ kernel/net/net_udp.c | 5 +++++ 5 files changed, 22 insertions(+) diff --git a/addons/libkosfat/directory.c b/addons/libkosfat/directory.c index 7625f06..ad3c17e 100644 --- a/addons/libkosfat/directory.c +++ b/addons/libkosfat/directory.c @@ -18,6 +18,9 @@ #include "directory.h" #include "fatinternal.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" + #ifdef __STRICT_ANSI__ /* These don't necessarily get prototyped in string.h in standard-compliant mode as they are extensions to the standard. Declaring them this way shouldn't @@ -1391,3 +1394,5 @@ void fat_dentry_print(const fat_dentry_t *ent) { dbglog(DBG_KDEBUG, "Size: %" PRIu32 "\n", ent->size); } #endif + +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/addons/libkosfat/directory.h b/addons/libkosfat/directory.h index f04be5f..3557f06 100644 --- a/addons/libkosfat/directory.h +++ b/addons/libkosfat/directory.h @@ -14,6 +14,8 @@ __BEGIN_DECLS #include "fatfs.h" +#define PACKED __attribute__((packed)) + typedef struct fat_dentry { uint8_t name[11]; uint8_t attr; diff --git a/kernel/net/net_icmp6.c b/kernel/net/net_icmp6.c index 2a913b1..12879eb 100644 --- a/kernel/net/net_icmp6.c +++ b/kernel/net/net_icmp6.c @@ -16,6 +16,9 @@ #include "net_ipv6.h" #include "net_ipv4.h" /* For net_ipv4_checksum() */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" + /* This file implements RFC 4443, the Internet Control Message Protocol for IPv6. All messages mentioned below are from that RFC, unless otherwise specified. @@ -802,3 +805,5 @@ int net_icmp6_send_param_prob(netif_t *net, uint8 code, uint32 ptr, return send_err_pkt(net, buf, sizeof(icmp6_param_problem_t), ppkt, psz, mc_allow); } + +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/kernel/net/net_ipv6.c b/kernel/net/net_ipv6.c index 266ff0d..c730a0e 100644 --- a/kernel/net/net_ipv6.c +++ b/kernel/net/net_ipv6.c @@ -15,6 +15,9 @@ #include "net_icmp6.h" #include "net_ipv4.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" + static net_ipv6_stats_t ipv6_stats = { 0 }; const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; @@ -302,3 +305,5 @@ void net_ipv6_shutdown(void) { mac[5] = net_default_dev->ip6_lladdr.s6_addr[15]; net_multicast_del(mac); } + +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/kernel/net/net_udp.c b/kernel/net/net_udp.c index 633e4ff..39c5c74 100644 --- a/kernel/net/net_udp.c +++ b/kernel/net/net_udp.c @@ -23,6 +23,9 @@ #include "net_ipv4.h" #include "net_ipv6.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" + /* Default hop limit (or ttl for IPv4) for new sockets */ #define UDP_DEFAULT_HOPS 64 @@ -1542,3 +1545,5 @@ void net_udp_shutdown(void) { fs_socket_proto_remove(&proto); fs_socket_proto_remove(&proto_lite); } + +#pragma GCC diagnostic pop \ No newline at end of file hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-13 02:35: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, warnings_fixes has been created at d0ced5dd50ced1da229a6adb9029d5a1cfdd38e6 (commit) - Log ----------------------------------------------------------------- commit d0ced5dd50ced1da229a6adb9029d5a1cfdd38e6 Author: falco <gyr...@gm...> Date: Sun Mar 12 22:33:14 2023 -0400 Initial warning removal work. - Warnings were removed for all of KOS in all files WITH THE EXCEPTION of "taking address of packed member" warnings in 2 files. - All work has been done on GCC12 which seems to be the angriest, but will verify on others. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-12 17:34:11
|
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 9f42456895517fc2a70dfb6f3a363ba38e684d7b (commit) via 2880e69e279e09f502522d3087c73f473650e66f (commit) via aa18885d396a3fdfd536d9966c5ca65232578113 (commit) via a2a758ec3761aaa4dc8315fd9983e24c597d1c83 (commit) via ae1a2b3243308302149fda046cbf4f822c9548c4 (commit) from bc1c46ecc373d834770633e41b18a94b9b1873d7 (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 9f42456895517fc2a70dfb6f3a363ba38e684d7b Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 12 13:33:48 2023 -0400 Add <stdint.h> to newlib_getentropy.c. commit 2880e69e279e09f502522d3087c73f473650e66f Merge: aa18885 a2a758e Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 12 09:49:17 2023 -0400 Merge pull request #132 from KallistiOS/modem_inline_static Fixed Undefined symbols for modem with -Os builds commit aa18885d396a3fdfd536d9966c5ca65232578113 Merge: bc1c46e ae1a2b3 Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 12 09:48:23 2023 -0400 Merge pull request #131 from KallistiOS/cpp_enable_rtti_exceptions Removed CXX flags: -fno-rtti and -fno-exceptions commit ae1a2b3243308302149fda046cbf4f822c9548c4 Author: falco <gyr...@gm...> Date: Sun Mar 12 00:25:29 2023 -0500 Removed CXX flags: -fno-rtti and -fno-exceptions - RTTI will now be enabled by default for C++ - Exceptions will now be enabled by default for C++ - This is how any regular, modern C++ setup would work - There are no problems using either with our toolchains ----------------------------------------------------------------------- Summary of changes: environ_base.sh | 2 +- kernel/arch/dreamcast/hardware/modem/modem.c | 6 +++--- kernel/libc/newlib/newlib_getentropy.c | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/environ_base.sh b/environ_base.sh index d8580be..619a458 100644 --- a/environ_base.sh +++ b/environ_base.sh @@ -34,7 +34,7 @@ export KOS_LD="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-ld" export KOS_RANLIB="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-ranlib" export KOS_STRIP="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-strip" export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_INC_PATHS} -D_arch_${KOS_ARCH} -D_arch_sub_${KOS_SUBARCH} -Wall -g -fno-builtin" -export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP} -fno-operator-names -fno-rtti -fno-exceptions" +export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP} -fno-operator-names" # Which standards modes we want to compile for # Note that this only covers KOS itself, not necessarily anything else compiled diff --git a/kernel/arch/dreamcast/hardware/modem/modem.c b/kernel/arch/dreamcast/hardware/modem/modem.c index fd93f1b..6c00599 100644 --- a/kernel/arch/dreamcast/hardware/modem/modem.c +++ b/kernel/arch/dreamcast/hardware/modem/modem.c @@ -96,7 +96,7 @@ const unsigned short modemBPSConstants[31] = { }; /* Converts a MODEM_SPEED_* constant into a value in bits per second */ -__inline unsigned short speedCodeToBPS(unsigned char speed) { +__inline static unsigned short speedCodeToBPS(unsigned char speed) { if(speed == MODEM_SPEED_1200) return 1200; @@ -267,7 +267,7 @@ void modemTimeoutIncCallback(void) { /* Verifys if the controller data returned as a result of a reset is valid or not. Returns zero if the results are invalid other a non zero number is returned. */ -__inline int verifyControllerData(unsigned short *ctrlInfo) { +__inline static int verifyControllerData(unsigned short *ctrlInfo) { /* RAM1 and RAM2 Checksums */ if((ctrlInfo[0] == 0xEA3C || ctrlInfo[0] == 0x451) && (ctrlInfo[1] == 0x5536 || ctrlInfo[1] == 0x49A5)) { @@ -289,7 +289,7 @@ __inline int verifyControllerData(unsigned short *ctrlInfo) { /* Does the same thing as verifyControllerData but checks to see if the DSP values from the DSP self test are valid. */ -__inline int verifyDSPData(unsigned short *dspInfo) { +__inline static int verifyDSPData(unsigned short *dspInfo) { /* EC Checksum */ if(dspInfo[0] == 0xF083 || dspInfo[0] == 0xA577) { /* Multiplier Checksum */ diff --git a/kernel/libc/newlib/newlib_getentropy.c b/kernel/libc/newlib/newlib_getentropy.c index 26652f5..dfdc2a2 100644 --- a/kernel/libc/newlib/newlib_getentropy.c +++ b/kernel/libc/newlib/newlib_getentropy.c @@ -6,6 +6,7 @@ */ #include <errno.h> +#include <stdint.h> #include <unistd.h> #include <sys/time.h> hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-03-12 05:44: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, modem_inline_static has been created at a2a758ec3761aaa4dc8315fd9983e24c597d1c83 (commit) - Log ----------------------------------------------------------------- commit a2a758ec3761aaa4dc8315fd9983e24c597d1c83 Author: falco <gyr...@gm...> Date: Sun Mar 12 00:41:12 2023 -0500 Fixed Undefined symbls for modem with -Os builds - When building KOS with -Os with GCC12, the modem basic demo failes to link with a few unresolved symbol errors - It looks as though several functions were marked inline within the driver; however, when building for -Os, the compiler decided not to actually inline them to favor code size, so no inline means no symbols - The fix was to also add static to the declarations so that a symbol with internal linkage will still be emitted within the translation unit should the compiler decide not to inline. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-03-12 04:32:31
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via bc1c46ecc373d834770633e41b18a94b9b1873d7 (commit) via 55f142357f1a6ceaa9f0b0a997bd7c4097b4ae83 (commit) via 3c642bf921459112fe559484ab176f73721ab67b (commit) via 3f97576228a1335245ec1cda4dc44c111fac576b (commit) via b04bf154a2cfc64b8ed182353cc939170763a13e (commit) via e26d0dbdc11326dcf832cd3b831954a0361f23a2 (commit) via 83f2053711c8720a11b1f5938537d9878b876470 (commit) via 325972fdb3d7c4bc82b0325045972e6c445fa933 (commit) from b7799950e6f7672881fdaf2779ae0607e6499c73 (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 bc1c46ecc373d834770633e41b18a94b9b1873d7 Merge: b779995 55f1423 Author: Lawrence Sebald <ljs...@us...> Date: Sat Mar 11 23:31:46 2023 -0500 Merge pull request #109 from KallistiOS/implement-dev-urandom Implement a new FS driver for /dev/random and /dev/urandom commit 55f142357f1a6ceaa9f0b0a997bd7c4097b4ae83 Author: Luke Benstead <ka...@gm...> Date: Wed Mar 1 11:01:52 2023 +0000 Move fs_random to fs_dev commit 3c642bf921459112fe559484ab176f73721ab67b Author: Luke Benstead <ka...@gm...> Date: Wed Mar 1 09:18:33 2023 +0000 Update kernel/libc/newlib/newlib_getentropy.c Co-authored-by: Lawrence Sebald <ljs...@us...> commit 3f97576228a1335245ec1cda4dc44c111fac576b Author: Luke Benstead <ka...@gm...> Date: Wed Mar 1 09:17:52 2023 +0000 Update kernel/arch/dreamcast/kernel/init.c Co-authored-by: Lawrence Sebald <ljs...@us...> commit b04bf154a2cfc64b8ed182353cc939170763a13e Author: Luke Benstead <ka...@gm...> Date: Tue Feb 21 20:29:20 2023 +0000 Make sure we remove both handlers commit e26d0dbdc11326dcf832cd3b831954a0361f23a2 Author: Luke Benstead <ka...@gm...> Date: Tue Feb 21 20:25:20 2023 +0000 Move things out of arch/dreamcast commit 83f2053711c8720a11b1f5938537d9878b876470 Author: Colton Pawielski <cep...@mt...> Date: Tue Feb 21 11:09:39 2023 -0600 Use newlib arc4random_buf for random fs device commit 325972fdb3d7c4bc82b0325045972e6c445fa933 Author: Luke Benstead <ka...@gm...> Date: Mon Feb 20 20:29:56 2023 +0000 Implement a new FS driver for /dev/random and /dev/urandom This helps with portability of libraries which expect it to be there. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/Makefile | 2 +- examples/dreamcast/{hello => random}/Makefile | 6 +- examples/dreamcast/random/random.c | 37 +++ .../dreamcast/random/romdisk}/.keepme | 0 include/kos.h | 1 + include/kos/fs_dev.h | 41 +++ kernel/arch/dreamcast/fs/Makefile | 2 +- kernel/arch/dreamcast/kernel/init.c | 1 + kernel/arch/dreamcast/kernel/initall_hdrs.h | 1 + kernel/fs/Makefile | 4 +- kernel/fs/fs_dev.c | 327 +++++++++++++++++++++ kernel/libc/newlib/Makefile | 4 +- kernel/libc/newlib/newlib_getentropy.c | 38 +++ 13 files changed, 455 insertions(+), 9 deletions(-) copy examples/dreamcast/{hello => random}/Makefile (93%) create mode 100644 examples/dreamcast/random/random.c copy {addons/lib => examples/dreamcast/random/romdisk}/.keepme (100%) create mode 100644 include/kos/fs_dev.h create mode 100644 kernel/fs/fs_dev.c create mode 100644 kernel/libc/newlib/newlib_getentropy.c diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile index 7ff5a70..f5cc332 100644 --- a/examples/dreamcast/Makefile +++ b/examples/dreamcast/Makefile @@ -5,7 +5,7 @@ # DIRS = 2ndmix basic libdream kgl hello sound png network vmu conio pvr video \ - lua parallax modem dreameye sd g1ata lightgun keyboard sdl + lua parallax modem dreameye sd g1ata lightgun keyboard sdl random ifdef KOS_CCPLUS DIRS += cpp tsunami endif diff --git a/examples/dreamcast/hello/Makefile b/examples/dreamcast/random/Makefile similarity index 93% copy from examples/dreamcast/hello/Makefile copy to examples/dreamcast/random/Makefile index d2ba544..7ac05a3 100644 --- a/examples/dreamcast/hello/Makefile +++ b/examples/dreamcast/random/Makefile @@ -1,14 +1,14 @@ # # Basic KallistiOS skeleton / test program # Copyright (C)2001-2004 Dan Potter -# +# # Put the filename of the output binary here -TARGET = hello.elf +TARGET = random.elf # List all of your C files here, but change the extension to ".o" # Include "romdisk.o" if you want a rom disk. -OBJS = hello.o romdisk.o +OBJS = random.o romdisk.o # If you define this, the Makefile.rules will create a romdisk.o for you # from the named dir. diff --git a/examples/dreamcast/random/random.c b/examples/dreamcast/random/random.c new file mode 100644 index 0000000..0d5adec --- /dev/null +++ b/examples/dreamcast/random/random.c @@ -0,0 +1,37 @@ +/* KallistiOS ##version## + + random.c + Copyright (C) 2023 Luke Benstead +*/ + +#include <kos.h> +#include <stdint.h> + +KOS_INIT_FLAGS(INIT_DEFAULT); + +int main(int argc, char **argv) { + const int buffer_size = 256; + uint8_t buffer[buffer_size]; + + FILE* urandom = fopen("/dev/urandom", "r"); + if(!urandom) { + fprintf(stderr, "Unable to open /dev/urandom for reading\n"); + return 1; + } + + size_t bytes = fread(buffer, 1, buffer_size, urandom); + fclose(urandom); + + if(bytes != buffer_size) { + fprintf(stderr, "Failed to read the correct number of bytes\n"); + return 2; + } + + printf("Generated the following random bytes:\n\n"); + for(int i = 0; i < buffer_size; ++i) { + printf("0x%02X ", (int) buffer[i]); + } + printf("\n\n"); + + return 0; +} diff --git a/addons/lib/.keepme b/examples/dreamcast/random/romdisk/.keepme similarity index 100% copy from addons/lib/.keepme copy to examples/dreamcast/random/romdisk/.keepme diff --git a/include/kos.h b/include/kos.h index 55c7b1c..019d0e9 100644 --- a/include/kos.h +++ b/include/kos.h @@ -35,6 +35,7 @@ __BEGIN_DECLS #include <kos/fs.h> #include <kos/fs_romdisk.h> #include <kos/fs_ramdisk.h> +#include <kos/fs_dev.h> #include <kos/fs_pty.h> #include <kos/limits.h> #include <kos/thread.h> diff --git a/include/kos/fs_dev.h b/include/kos/fs_dev.h new file mode 100644 index 0000000..2c94e3e --- /dev/null +++ b/include/kos/fs_dev.h @@ -0,0 +1,41 @@ +/* KallistiOS ##version## + + dc/fs_dev.h + (c)2023 - Luke Benstead + +*/ + +/** \file dc/fs_dev.h + \brief Driver for /dev/random and /dev/urandom. + + This filesystem driver provides implementations of /dev/random + and /dev/urandom for portability. It seeds randomness from + uninitialized memory, and the clock. Obviously we + are limited in how we can provide sufficient entropy on an + embedded platform like the Dreamcast so the randomness from + this driver will not win any awards but it should be sufficiently + good for most purposes. + + /dev/random is an alias to /dev/urandom for now. + + \author Luke Benstead +*/ + +#ifndef __DC_FS_DEV_H +#define __DC_FS_DEV_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +#include <kos/fs.h> + +/* \cond */ +/* Initialization */ +int fs_dev_init(); +int fs_dev_shutdown(); +/* \endcond */ + +__END_DECLS + +#endif /* __DC_FS_DEV_H */ + diff --git a/kernel/arch/dreamcast/fs/Makefile b/kernel/arch/dreamcast/fs/Makefile index 03a2c5d..a4bad92 100644 --- a/kernel/arch/dreamcast/fs/Makefile +++ b/kernel/arch/dreamcast/fs/Makefile @@ -8,6 +8,6 @@ OBJS = fs_iso9660.o fs_vmu.o fs_dcload.o dcload-syscall.o vmufs.o \ fs_dclsocket.o -SUBDIRS = +SUBDIRS = include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index 04e8cfe..02efd4b 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -116,6 +116,7 @@ int __attribute__((weak)) arch_auto_init() { fs_pty_init(); /* Pty */ fs_ramdisk_init(); /* Ramdisk */ fs_romdisk_init(); /* Romdisk */ + fs_dev_init(); /* /dev/urandom etc. */ hardware_periph_init(); /* DC peripheral init */ diff --git a/kernel/arch/dreamcast/kernel/initall_hdrs.h b/kernel/arch/dreamcast/kernel/initall_hdrs.h index c3da587..f505df3 100644 --- a/kernel/arch/dreamcast/kernel/initall_hdrs.h +++ b/kernel/arch/dreamcast/kernel/initall_hdrs.h @@ -3,6 +3,7 @@ #include <kos/fs.h> #include <kos/thread.h> #include <kos/fs_pty.h> +#include <kos/fs_dev.h> #include <kos/fs_romdisk.h> #include <kos/fs_ramdisk.h> #include <kos/library.h> diff --git a/kernel/fs/Makefile b/kernel/fs/Makefile index 03d71bb..3e979db 100644 --- a/kernel/fs/Makefile +++ b/kernel/fs/Makefile @@ -4,9 +4,9 @@ # (c)2000-2001 Dan Potter # -OBJS = fs.o fs_romdisk.o fs_ramdisk.o fs_pty.o +OBJS = fs.o fs_dev.o fs_romdisk.o fs_ramdisk.o fs_pty.o OBJS += fs_utils.o elf.o fs_socket.o -SUBDIRS = +SUBDIRS = include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/fs/fs_dev.c b/kernel/fs/fs_dev.c new file mode 100644 index 0000000..dcd00d5 --- /dev/null +++ b/kernel/fs/fs_dev.c @@ -0,0 +1,327 @@ +/* KallistiOS ##version## + + fs_dev.c + Copyright (C) 2023 Luke Benstead +*/ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdint.h> +#include <malloc.h> +#include <errno.h> +#include <time.h> +#include <arch/types.h> +#include <kos/mutex.h> +#include <kos/fs_dev.h> +#include <sys/queue.h> +#include <errno.h> +#include <sys/time.h> + +/* This function is declared in <stdlib.h> but behind an if __BSD_VISIBLE + Declaring as extern here to avoid implicit declaration */ +void arc4random_buf (void *, size_t); + +/* File handles */ +typedef struct dev_fh_str { + int mode; /* mode the file was opened with */ + + TAILQ_ENTRY(dev_fh_str) listent; /* list entry */ +} dev_fh_t; + +/* Linked list of open files (controlled by "mutex") */ +TAILQ_HEAD(dev_fh_list, dev_fh_str) dev_fh; + +/* Thread mutex for dev_fh access */ +static mutex_t fh_mutex; + + +/* openfile function */ +static dev_fh_t *dev_open_file(vfs_handler_t * vfs, const char *fn, int mode) { + (void) vfs; + + if(strcmp(fn, "/urandom") != 0 && strcmp(fn, "/random") != 0) { + return NULL; + } + + dev_fh_t * fd; /* file descriptor */ + int realmode; + + /* Malloc a new fh struct */ + fd = malloc(sizeof(dev_fh_t)); + + /* Fill in the filehandle struct */ + fd->mode = mode; + + realmode = mode & O_MODE_MASK; + + /* We only allow reading, not writing */ + if(realmode != O_RDONLY) { + free(fd); + return NULL; + } + + return fd; +} + +/* open function */ +static void * dev_open(vfs_handler_t * vfs, const char *path, int mode) { + dev_fh_t *fh = dev_open_file(vfs, path, mode); + if(!fh) { + return NULL; + } + + /* link the fh onto the top of the list */ + mutex_lock(&fh_mutex); + TAILQ_INSERT_TAIL(&dev_fh, fh, listent); + mutex_unlock(&fh_mutex); + + return (void *)fh; +} + +/* Verify that a given hnd is actually in the list */ +static int dev_verify_hnd(void * hnd) { + dev_fh_t *cur; + int rv; + + rv = 0; + + mutex_lock(&fh_mutex); + TAILQ_FOREACH(cur, &dev_fh, listent) { + if((void *)cur == hnd) { + rv = 1; + break; + } + } + mutex_unlock(&fh_mutex); + + if(rv) + return 1; + else + return 0; +} + +/* close a file */ +static int dev_close(void * hnd) { + dev_fh_t *fh; + int retval = 0; + + /* Check the handle */ + if(!dev_verify_hnd(hnd)) { + errno = EBADF; + return -1; + } + + fh = (dev_fh_t *)hnd; + + /* Look for the one to get rid of */ + mutex_lock(&fh_mutex); + TAILQ_REMOVE(&dev_fh, fh, listent); + mutex_unlock(&fh_mutex); + + free(fh); + return retval; +} + +/* read function */ +static ssize_t dev_read(void * hnd, void *buffer, size_t cnt) { + dev_fh_t *fh; + uint8_t* buf = buffer; + + /* Check the handle */ + if(!dev_verify_hnd(hnd)) + return -1; + + fh = (dev_fh_t *)hnd; + + /* make sure we're opened for reading */ + if((fh->mode & O_MODE_MASK) != O_RDONLY && (fh->mode & O_MODE_MASK) != O_RDWR) + return 0; + + arc4random_buf(buf, cnt); + + return cnt; +} + +/* write function */ +static ssize_t dev_write(void * hnd, const void *buffer, size_t cnt) { + (void) buffer; + (void) cnt; + + dev_fh_t *fh; + + /* Check the handle we were given */ + if(!dev_verify_hnd(hnd)) + return -1; + + fh = (dev_fh_t *)hnd; + + /* Make sure we're opened for writing */ + if((fh->mode & O_MODE_MASK) != O_WRONLY && (fh->mode & O_MODE_MASK) != O_RDWR) + return -1; + + dbglog(DBG_ERROR, "RANDOMFS: writing entropy is not supported\n"); + return -1; +} + + +/* Seek elsewhere in a file */ +static off_t dev_seek(void * hnd, off_t offset, int whence) { + (void) offset; + (void) whence; + + /* Check the handle */ + if(!dev_verify_hnd(hnd)) + return -1; + + return 0; +} + +/* tell the current position in the file */ +static off_t dev_tell(void * hnd) { + /* Check the handle */ + if(!dev_verify_hnd(hnd)) + return -1; + + return 0; +} + +/* return the filesize */ +static size_t dev_total(void * fd) { + /* Check the handle */ + if(!dev_verify_hnd(fd)) + return -1; + + /* The size of /dev/urandom always returns 0 */ + return 0; +} + + +/* Delete a file */ +static int dev_unlink(vfs_handler_t * vfs, const char *path) { + (void) vfs; + (void) path; + + dbglog(DBG_ERROR, "RANDOMFS: Attempted to delete system file\n"); + return -1; +} + +static int dev_stat(vfs_handler_t *vfs, const char *fn, struct stat *rv, + int flag) { + (void)vfs; + (void)fn; + (void)flag; + + memset(rv, 0, sizeof(struct stat)); + rv->st_mode = S_IRUSR; + rv->st_nlink = 1; + + return 0; +} + +static int dev_fcntl(void *fd, int cmd, va_list ap) { + int rv = -1; + + (void)ap; + + /* Check the handle */ + if(!dev_verify_hnd(fd)) { + errno = EBADF; + return -1; + } + + switch(cmd) { + case F_GETFL: + rv = O_RDONLY; + break; + + case F_SETFL: + case F_GETFD: + case F_SETFD: + rv = 0; + break; + + default: + errno = EINVAL; + } + + return rv; +} + +static int dev_fstat(void *fd, struct stat *st) { + + /* Check the handle */ + if(!dev_verify_hnd(fd)) { + errno = EBADF; + return -1; + } + + memset(st, 0, sizeof(struct stat)); + st->st_mode = S_IFREG | S_IRUSR; + st->st_nlink = 1; + + return 0; +} + +/* handler interface */ +static vfs_handler_t vh = { + /* Name handler */ + { + "/dev", /* name */ + 0, /* tbfi */ + 0x00010000, /* Version 1.0 */ + 0, /* flags */ + NMMGR_TYPE_VFS, /* VFS handler */ + NMMGR_LIST_INIT + }, + 0, NULL, /* In-kernel, privdata */ + + dev_open, + dev_close, + dev_read, + dev_write, + dev_seek, + dev_tell, + dev_total, + NULL, + NULL, /* ioctl */ + NULL, /* rename/move */ + dev_unlink, ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-03-11 21:41:08
|
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 b7799950e6f7672881fdaf2779ae0607e6499c73 (commit) via 50d2cf79af631d0761a1a4f7df128aa6a32ed85a (commit) from c9fa4c5069ee526714c941b9470fbc2b15c23888 (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 b7799950e6f7672881fdaf2779ae0607e6499c73 Merge: c9fa4c5 50d2cf7 Author: darcagn <da...@pr...> Date: Sat Mar 11 15:40:18 2023 -0600 Merge pull request #129 from KallistiOS/macos-chain Change arm-Darwin patches to run in addition to standard patches commit 50d2cf79af631d0761a1a4f7df128aa6a32ed85a Author: darc <da...@pr...> Date: Sat Mar 11 15:33:23 2023 -0600 Change arm-Darwin patches to run in addition to standard patches instead of exclusively, bringing behavior in line with SiZiOUS's MinGW-w64 patches and eliminating duplication of labor. ----------------------------------------------------------------------- Summary of changes: .../patches/arm-Darwin/gcc-12.2.0-kos.diff | 1587 +------------------- .../dc-chain/patches/arm-Darwin/gcc-8.4.0-kos.diff | 44 +- .../dc-chain/patches/arm-Darwin/gcc-9.3.0-kos.diff | 1555 +------------------ utils/dc-chain/scripts/patch.mk | 2 +- 4 files changed, 35 insertions(+), 3153 deletions(-) diff --git a/utils/dc-chain/patches/arm-Darwin/gcc-12.2.0-kos.diff b/utils/dc-chain/patches/arm-Darwin/gcc-12.2.0-kos.diff index 9e6cf03..9d235b2 100644 --- a/utils/dc-chain/patches/arm-Darwin/gcc-12.2.0-kos.diff +++ b/utils/dc-chain/patches/arm-Darwin/gcc-12.2.0-kos.diff @@ -1,1597 +1,28 @@ diff --color -ruN gcc-12.2.0/gcc/config/host-darwin.cc gcc-12.2.0-kos/gcc/config/host-darwin.cc ---- gcc-12.2.0/gcc/config/host-darwin.cc 2023-02-03 23:24:26 -+++ gcc-12.2.0-kos/gcc/config/host-darwin.cc 2023-02-03 23:27:40 -@@ -24,6 +24,8 @@ +--- gcc-12.2.0/gcc/config/host-darwin.cc 2023-03-11 14:18:10 ++++ gcc-12.2.0-kos/gcc/config/host-darwin.cc 2023-03-11 14:22:40 +@@ -24,6 +24,10 @@ #include "diagnostic-core.h" #include "config/host-darwin.h" #include <errno.h> +#include "hosthooks.h" +#include "hosthooks-def.h" - - /* For Darwin (macOS only) platforms, without ASLR (PIE) enabled on the - binaries, the following VM addresses are expected to be available. -@@ -181,3 +183,5 @@ - - return 1; - } + +const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; -diff --color -ruN gcc-12.2.0/gcc/config/sh/sh-c.cc gcc-12.2.0-kos/gcc/config/sh/sh-c.cc ---- gcc-12.2.0/gcc/config/sh/sh-c.cc 2023-02-03 23:24:26 -+++ gcc-12.2.0-kos/gcc/config/sh/sh-c.cc 2023-02-03 23:25:16 -@@ -141,4 +141,11 @@ - - cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__", - selected_atomic_model ().cdef_name); -+ -+ /* Custom built-in defines for KallistiOS */ -+ builtin_define ("__KOS_GCC_PATCHED__"); -+ cpp_define_formatted (pfile, "__KOS_GCC_PATCHLEVEL__=%d", -+ 2023010200); -+ /* Toolchain supports setting up stack for 32MB */ -+ builtin_define ("__KOS_GCC_32MB__"); - } -diff --color -ruN gcc-12.2.0/gcc/config/sh/sh_treg_combine.cc gcc-12.2.0-kos/gcc/config/sh/sh_treg_combine.cc ---- gcc-12.2.0/gcc/config/sh/sh_treg_combine.cc 2023-02-03 23:24:26 -+++ gcc-12.2.0-kos/gcc/config/sh/sh_treg_combine.cc 2023-02-03 23:25:16 -@@ -37,6 +37,7 @@ - #include "cfgrtl.h" - #include "tree-pass.h" - #include "expr.h" -+#include "tm-preds.h" - - /* - This pass tries to optimize for example this: -@@ -425,10 +426,6 @@ - rtx p = PATTERN (i); - return GET_CODE (p) == SET && GET_CODE (XEXP (p, 1)) == IF_THEN_ELSE; - } -- --// FIXME: Remove dependency on SH predicate function somehow. --extern int t_reg_operand (rtx, machine_mode); --extern int negt_reg_operand (rtx, machine_mode); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RTL pass class + /* For Darwin (macOS only) platforms, without ASLR (PIE) enabled on the + binaries, the following VM addresses are expected to be available. diff --color -ruN gcc-12.2.0/gcc/config.host gcc-12.2.0-kos/gcc/config.host ---- gcc-12.2.0/gcc/config.host 2023-02-03 23:24:42 -+++ gcc-12.2.0-kos/gcc/config.host 2023-02-03 23:28:17 +--- gcc-12.2.0/gcc/config.host 2023-03-11 14:18:26 ++++ gcc-12.2.0-kos/gcc/config.host 2023-03-11 14:23:01 @@ -93,8 +93,8 @@ case ${host} in *-darwin*) # Generic darwin host support. - out_host_hook_obj=host-darwin.o - host_xmake_file="${host_xmake_file} x-darwin" -+ #out_host_hook_obj=host-darwin.o -+ #host_xmake_file="${host_xmake_file} x-darwin" ++ # out_host_hook_obj=host-darwin.o ++ # host_xmake_file="${host_xmake_file} x-darwin" ;; esac -diff --color -ruN gcc-12.2.0/gcc/configure gcc-12.2.0-kos/gcc/configure ---- gcc-12.2.0/gcc/configure 2023-02-03 23:24:25 -+++ gcc-12.2.0-kos/gcc/configure 2023-02-03 23:25:16 -@@ -12885,7 +12885,7 @@ - target_thread_file='single' - ;; - aix | dce | lynx | mipssde | posix | rtems | \ -- single | tpf | vxworks | win32) -+ single | tpf | vxworks | win32 | kos) - target_thread_file=${enable_threads} - ;; - *) -diff --color -ruN gcc-12.2.0/libgcc/config/sh/crt1.S gcc-12.2.0-kos/libgcc/config/sh/crt1.S ---- gcc-12.2.0/libgcc/config/sh/crt1.S 2023-02-03 23:24:24 -+++ gcc-12.2.0-kos/libgcc/config/sh/crt1.S 2023-02-03 23:25:16 -@@ -1,724 +1,225 @@ --/* Copyright (C) 2000-2022 Free Software Foundation, Inc. -- This file was pretty much copied from newlib. -+! KallistiOS ##version## -+! -+! startup.s -+! (c)2000-2001 Dan Potter -+! -+! This file must appear FIRST in your linking order, or your program won't -+! work correctly as a raw binary. -+! -+! This is very loosely based on Marcus' crt0.s/startup.s -+! - --This file is part of GCC. -+.globl start -+.globl _start -+.globl _arch_real_exit -+.globl __arch_old_sr -+.globl __arch_old_vbr -+.globl __arch_old_stack -+.globl __arch_old_fpscr -+.globl __arch_mem_top - --GCC is free software; you can redistribute it and/or modify it --under the terms of the GNU General Public License as published by the --Free Software Foundation; either version 3, or (at your option) any --later version. -- --GCC is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --General Public License for more details. -- --Under Section 7 of GPL version 3, you are granted additional --permissions described in the GCC Runtime Library Exception, version --3.1, as published by the Free Software Foundation. -- --You should have received a copy of the GNU General Public License and --a copy of the GCC Runtime Library Exception along with this program; --see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --<http://www.gnu.org/licenses/>. */ -- --#include "crt.h" -- --#ifdef MMU_SUPPORT -- /* Section used for exception/timer interrupt stack area */ -- .section .data.vbr.stack,"aw" -- .align 4 -- .global __ST_VBR --__ST_VBR: -- .zero 1024 * 2 /* ; 2k for VBR handlers */ --/* Label at the highest stack address where the stack grows from */ --__timer_stack: --#endif /* MMU_SUPPORT */ -- -- /* ;---------------------------------------- -- Normal newlib crt1.S */ -- -- ! make a place to keep any previous value of the vbr register -- ! this will only have a value if it has been set by redboot (for example) -- .section .bss --old_vbr: -- .long 0 --#ifdef PROFILE --profiling_enabled: -- .long 0 --#endif -- -- -- .section .text -- .global start -- .import ___rtos_profiler_start_timer -- .weak ___rtos_profiler_start_timer -+_start: - start: -- mov.l stack_k,r15 -+ ! Disable interrupts (if they're enabled) -+ mov.l old_sr_addr,r0 -+ stc sr,r1 -+ mov.l r1,@r0 -+ mov.l init_sr,r0 -+ ldc r0,sr - --#if defined (__SH3__) || (defined (__SH_FPU_ANY__) && ! defined (__SH2E__) && ! defined (__SH2A__)) || defined (__SH4_NOFPU__) --#define VBR_SETUP -- ! before zeroing the bss ... -- ! if the vbr is already set to vbr_start then the program has been restarted -- ! (i.e. it is not the first time the program has been run since reset) -- ! reset the vbr to its old value before old_vbr (in bss) is wiped -- ! this ensures that the later code does not create a circular vbr chain -- stc vbr, r1 -- mov.l vbr_start_k, r2 -- cmp/eq r1, r2 -- bf 0f -- ! reset the old vbr value -- mov.l old_vbr_k, r1 -- mov.l @r1, r2 -- ldc r2, vbr --0: --#endif /* VBR_SETUP */ -- -- ! zero out bss -- mov.l edata_k,r0 -- mov.l end_k,r1 -- mov #0,r2 --start_l: -- mov.l r2,@r0 -- add #4,r0 -- cmp/ge r0,r1 -- bt start_l -+ ! Run in the P2 area -+ mov.l setup_cache_addr,r0 -+ mov.l p2_mask,r1 -+ or r1,r0 -+ jmp @r0 -+ nop - --#if defined (__SH_FPU_ANY__) -- mov.l set_fpscr_k, r1 -- mov #4,r4 -- jsr @r1 -- shll16 r4 ! Set DN bit (flush denormal inputs to zero) -- lds r3,fpscr ! Switch to default precision --#endif /* defined (__SH_FPU_ANY__) */ -+setup_cache: -+ ! Now that we are in P2, it's safe to enable the cache -+ ! Check to see if we should enable OCRAM. -+ mov.l kos_init_flags_addr, r0 -+ add #2, r0 -+ mov.w @r0, r0 -+ tst #1, r0 -+ bf .L_setup_cache_L0 -+ mov.w ccr_data,r1 -+ bra .L_setup_cache_L1 -+ nop -+.L_setup_cache_L0: -+ mov.w ccr_data_ocram,r1 -+.L_setup_cache_L1: -+ mov.l ccr_addr,r0 -+ mov.l r1,@r0 - --#ifdef VBR_SETUP -- ! save the existing contents of the vbr -- ! there will only be a prior value when using something like redboot -- ! otherwise it will be zero -- stc vbr, r1 -- mov.l old_vbr_k, r2 -- mov.l r1, @r2 -- ! setup vbr -- mov.l vbr_start_k, r1 -- ldc r1,vbr --#endif /* VBR_SETUP */ -+ ! After changing CCR, eight instructions must be executed before -+ ! it's safe to enter a cached area such as P1 -+ nop ! 1 -+ nop ! 2 -+ nop ! 3 -+ nop ! 4 -+ nop ! 5 (d-cache now safe) -+ nop ! 6 -+ mov.l init_addr,r0 ! 7 -+ mov #0,r1 ! 8 -+ jmp @r0 ! go -+ mov r1,r0 -+ nop - -- ! if an rtos is exporting a timer start fn, -- ! then pick up an SR which does not enable ints -- ! (the rtos will take care of this) -- mov.l rtos_start_fn, r0 -- mov.l sr_initial_bare, r1 -- tst r0, r0 -- bt set_sr -+init: -+ ! Save old PR on old stack so we can get to it later -+ sts.l pr,@-r15 - -- mov.l sr_initial_rtos, r1 -+ ! Save the current stack, and set a new stack (higher up in RAM) -+ mov.l old_stack_addr,r0 -+ mov.l r15,@r0 -+ mov.l new_stack_16m,r15 - --set_sr: -- ! Set status register (sr) -- ldc r1, sr -+ ! Check if 0xadffffff is a mirror of 0xacffffff, or if unique -+ ! If unique, then memory is 32MB instead of 16MB, and we must -+ ! set up new stack even higher -+ mov.l p2_mask,r0 -+ mov r0,r2 -+ or r15,r2 -+ mov #0xba,r1 -+ mov.b r1,@-r2 ! Store 0xba to 0xacffffff -+ mov.l new_stack_32m,r1 -+ or r0,r1 -+ mov #0xab,r0 -+ mov.b r0,@-r1 ! Store 0xab in 0xadffffff -+ mov.b @r1,r0 -+ mov.b @r2,r1 ! Reloaded values -+ cmp/eq r0,r1 ! Check if values match -+ bt memchk_done ! If so, mirror - we're done, move on -+ mov.l new_stack_32m,r15 ! If not, unique - set higher stack -+memchk_done: -+ mov.l mem_top_addr,r0 -+ mov.l r15,@r0 ! Save address of top of memory - -- ! arrange for exit to call fini -- mov.l atexit_k,r0 -- mov.l fini_k,r4 -- jsr @r0 -- nop -+ ! Save VBR -+ mov.l old_vbr_addr,r0 -+ stc vbr,r1 -+ mov.l r1,@r0 - --#ifdef PROFILE -- ! arrange for exit to call _mcleanup (via stop_profiling) -- mova stop_profiling,r0 -- mov.l atexit_k,r1 -- jsr @r1 -- mov r0, r4 -+ ! Save FPSCR -+ mov.l old_fpscr_addr,r0 -+ sts fpscr,r1 -+ mov.l r1,@r0 - -- ! Call profiler startup code -- mov.l monstartup_k, r0 -- mov.l start_k, r4 -- mov.l etext_k, r5 -- jsr @r0 -- nop -- -- ! enable profiling trap -- ! until now any trap 33s will have been ignored -- ! This means that all library functions called before this point -- ! (directly or indirectly) may have the profiling trap at the start. -- ! Therefore, only mcount itself may not have the extra header. -- mov.l profiling_enabled_k2, r0 -- mov #1, r1 -- mov.l r1, @r0 --#endif /* PROFILE */ -- -- ! call init -- mov.l init_k,r0 -+ ! Reset FPSCR -+ mov #4,r4 ! Use 00040000 (DN=1) -+ mov.l fpscr_addr,r0 - jsr @r0 -- nop -+ shll16 r4 - -- ! call the mainline -- mov.l main_k,r0 -- jsr @r0 -- nop -+ ! Setup a sentinel value for frame pointer in case we're using -+ ! FRAME_POINTERS for stack tracing. -+ mov #-1,r14 - -- ! call exit -- mov r0,r4 -- mov.l exit_k,r0 -+ ! Jump to the kernel main -+ mov.l main_addr,r0 - jsr @r0 - nop -- -- .balign 4 --#ifdef PROFILE --stop_profiling: -- # stop mcount counting -- mov.l profiling_enabled_k2, r0 -- mov #0, r1 -- mov.l r1, @r0 - -- # call mcleanup -- mov.l mcleanup_k, r0 -- jmp @r0 -- nop -- -- .balign 4 --mcleanup_k: -- .long __mcleanup --monstartup_k: -- .long ___monstartup --profiling_enabled_k2: -- .long profiling_enabled --start_k: -- .long _start --etext_k: -- .long __etext --#endif /* PROFILE */ -+ ! Program can return here (not likely) or jump here directly -+ ! from anywhere in it to go straight back to the monitor -+_arch_real_exit: -+ ! Reset SR -+ mov.l old_sr,r0 -+ ldc r0,sr - -- .align 2 --#if defined (__SH_FPU_ANY__) --set_fpscr_k: -- .long ___set_fpscr --#endif /* defined (__SH_FPU_ANY__) */ -+ ! Disable MMU, invalidate TLB -+ mov #4,r0 -+ mov.l mmu_addr,r1 -+ mov.l r0,@r1 - --stack_k: -- .long _stack --edata_k: -- .long _edata --end_k: -- .long _end --main_k: -- .long ___setup_argv_and_call_main --exit_k: -- .long _exit --atexit_k: -- .long _atexit --init_k: -- .long GLOBAL(_init) --fini_k: -- .long GLOBAL(_fini) --#ifdef VBR_SETUP --old_vbr_k: -- .long old_vbr --vbr_start_k: -- .long vbr_start --#endif /* VBR_SETUP */ -- --sr_initial_rtos: -- ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. -- ! Whether profiling or not, keep interrupts masked, -- ! the RTOS will enable these if required. -- .long 0x600000f1 -+ ! Wait (just in case) -+ nop ! 1 -+ nop ! 2 -+ nop ! 3 -+ nop ! 4 -+ nop ! 5 -+ nop ! 6 -+ nop ! 7 -+ nop ! 8 - --rtos_start_fn: -- .long ___rtos_profiler_start_timer -- --#ifdef PROFILE --sr_initial_bare: -- ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. -- ! For bare machine, we need to enable interrupts to get profiling working -- .long 0x60000001 --#else -+ ! Restore VBR -+ mov.l old_vbr,r0 -+ ldc r0,vbr - --sr_initial_bare: -- ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. -- ! Keep interrupts disabled - the application will enable as required. -- .long 0x600000f1 --#endif -+ ! If we're working under dcload, call its EXIT syscall -+ mov.l dcload_magic_addr,r0 -+ mov.l @r0,r0 -+ mov.l dcload_magic_value,r1 -+ cmp/eq r0,r1 -+ bf normal_exit - -- ! supplied for backward compatibility only, in case of linking -- ! code whose main() was compiled with an older version of GCC. -- .global ___main --___main: -+ mov.l dcload_syscall,r0 -+ mov.l @r0,r0 -+ jsr @r0 -+ mov #15,r4 -+ -+ ! Set back the stack and return (presumably to a serial debug) -+normal_exit: -+ mov.l old_stack,r15 -+ lds.l @r15+,pr - rts - nop --#ifdef VBR_SETUP --! Exception handlers -- .section .text.vbr, "ax" --vbr_start: - -- .org 0x100 --vbr_100: --#ifdef PROFILE -- ! Note on register usage. -- ! we use r0..r3 as scratch in this code. If we are here due to a trapa for profiling -- ! then this is OK as we are just before executing any function code. -- ! The other r4..r7 we save explicityl on the stack -- ! Remaining registers are saved by normal ABI conventions and we assert we do not -- ! use floating point registers. -- mov.l expevt_k1, r1 -- mov.l @r1, r1 -- mov.l event_mask, r0 ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |