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
(25) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: ljsebald <ljs...@us...> - 2023-06-04 01:49:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, vmu has been deleted was 3880532748bdaebd8f720d2861d6d4d742975f98 ----------------------------------------------------------------------- 3880532748bdaebd8f720d2861d6d4d742975f98 Merge branch 'vmu' of github.com:gyrovorbis/KallistiOS into vmu ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-04 01:49: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, authors_update has been deleted was 71f314048e35084382e7bc04dffb055d129d775f ----------------------------------------------------------------------- 71f314048e35084382e7bc04dffb055d129d775f Updated AUTHORS. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-04 01:48:50
|
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, init-flags-header has been deleted was b720f3891036040cf7081c01255d7c7fe236eb9d ----------------------------------------------------------------------- b720f3891036040cf7081c01255d7c7fe236eb9d Fix examples that fail to compile due to missing headers. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-04 01:46:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via dfbcd7ee95a047f82db4db8cb29e843cd3c822b9 (commit) via bf957b2491993542c59e49cb1fd615a792d4d288 (commit) via 760131840dfa2e06c59a082b3393e069049a9d7d (commit) via b720f3891036040cf7081c01255d7c7fe236eb9d (commit) via 868673af42808f56ec0192ee32f7db9faf7157c8 (commit) via dadeb40746488aa74bc7745cd2803393607e1180 (commit) via 644c7faea83165c634ee683fed64ee9c6093b636 (commit) from b0a75b33759c57b9399aa8bf9f69806977a952bd (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 dfbcd7ee95a047f82db4db8cb29e843cd3c822b9 Author: darcagn <da...@pr...> Date: Sat Jun 3 20:45:29 2023 -0500 Convert all files using CRLF line endings to LF (#236) commit bf957b2491993542c59e49cb1fd615a792d4d288 Merge: b0a75b3 7601318 Author: Donald Haase <qu...@ya...> Date: Sat Jun 3 21:42:20 2023 -0400 Merge pull request #235 from KallistiOS/init-flags-header Separate out initialization flags from <arch/arch.h> commit 760131840dfa2e06c59a082b3393e069049a9d7d Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 21:37:52 2023 -0400 Take two with more missing headers. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + examples/dreamcast/basic/memtest32/main.c | 5 +- examples/dreamcast/basic/memtest32/memtest.c | 442 ++-- examples/dreamcast/basic/memtest32/memtest.h | 84 +- examples/dreamcast/cpp/gltest/gltest.cpp | 828 +++---- examples/dreamcast/cpp/out_of_memory/Makefile | 9 +- .../dreamcast/cpp/out_of_memory/out_of_memory.cc | 22 +- examples/dreamcast/keyboard/keytest/keytest.c | 178 +- examples/dreamcast/kgl/basic/elements/Makefile | 68 +- .../dreamcast/kgl/basic/elements/gl-elements.c | 219 +- .../dreamcast/kgl/basic/elements/pvr-texture.c | 312 +-- examples/dreamcast/kgl/basic/gl/gltest.c | 494 ++-- examples/dreamcast/kgl/basic/gl/pvr-texture.c | 312 +-- examples/dreamcast/kgl/basic/scissor/pvr-texture.c | 312 +-- examples/dreamcast/kgl/basic/scissor/scissor.c | 656 +++--- examples/dreamcast/kgl/basic/txrenv/gltest.c | 304 +-- examples/dreamcast/kgl/basic/txrenv/pvr-texture.c | 312 +-- examples/dreamcast/kgl/basic/vq/Makefile | 62 +- examples/dreamcast/kgl/basic/vq/vq-example.c | 398 ++-- examples/dreamcast/kgl/basic/zclip_arrays/Makefile | 68 +- .../dreamcast/kgl/basic/zclip_arrays/gl-arrays.c | 233 +- .../dreamcast/kgl/basic/zclip_arrays/pvr-texture.c | 312 +-- .../dreamcast/kgl/benchmarks/quadmark/Makefile | 60 +- .../dreamcast/kgl/benchmarks/quadmark/quadmark.c | 366 +-- examples/dreamcast/kgl/benchmarks/trimark/Makefile | 58 +- .../dreamcast/kgl/benchmarks/trimark/trimark.c | 360 +-- .../dreamcast/kgl/benchmarks/tristripmark/Makefile | 60 +- .../kgl/benchmarks/tristripmark/tristripmark.c | 370 +-- examples/dreamcast/kgl/demos/blur/Makefile | 68 +- examples/dreamcast/kgl/demos/blur/pvr-texture.c | 312 +-- examples/dreamcast/kgl/demos/blur/radial_blur.c | 770 +++---- examples/dreamcast/kgl/demos/mipmap/Makefile | 68 +- examples/dreamcast/kgl/demos/mipmap/gl-mipmap.c | 292 +-- examples/dreamcast/kgl/demos/mipmap/pvr-texture.c | 312 +-- .../kgl/demos/multitexture-arrays/Makefile | 68 +- .../demos/multitexture-arrays/gl-multitex-arrays.c | 240 +- .../kgl/demos/multitexture-arrays/pvr-texture.c | 312 +-- .../multitexture-elements/gl-multitex-elements.c | 246 +- .../kgl/demos/multitexture-elements/pvr-texture.c | 312 +-- examples/dreamcast/kgl/demos/specular/font.c | 158 +- examples/dreamcast/kgl/demos/specular/font.h | 70 +- examples/dreamcast/kgl/demos/specular/input.c | 128 +- examples/dreamcast/kgl/demos/specular/input.h | 60 +- .../dreamcast/kgl/demos/specular/pvr-texture.c | 312 +-- examples/dreamcast/kgl/demos/specular/specular.c | 2368 ++++++++++---------- examples/dreamcast/kgl/demos/specular/texture.c | 216 +- examples/dreamcast/kgl/demos/specular/texture.h | 30 +- examples/dreamcast/kgl/demos/specular/timer.c | 40 +- examples/dreamcast/kgl/demos/specular/timer.h | 36 +- examples/dreamcast/kgl/demos/specular/vector.c | 56 +- examples/dreamcast/kgl/demos/specular/vector.h | 46 +- examples/dreamcast/kgl/nehe/nehe02/Makefile | 58 +- examples/dreamcast/kgl/nehe/nehe02/nehe02.c | 166 +- examples/dreamcast/kgl/nehe/nehe05/Makefile | 58 +- examples/dreamcast/kgl/nehe/nehe05/nehe05.c | 286 +-- examples/dreamcast/kgl/nehe/nehe06/nehe06.c | 308 +-- examples/dreamcast/kgl/nehe/nehe06/pvr-texture.c | 312 +-- examples/dreamcast/kgl/nehe/nehe08/nehe08.c | 452 ++-- examples/dreamcast/kgl/nehe/nehe08/pvr-texture.c | 312 +-- examples/dreamcast/kgl/nehe/nehe09/nehe09.c | 348 +-- examples/dreamcast/kgl/nehe/nehe09/pvr-texture.c | 312 +-- examples/dreamcast/kgl/nehe/nehe16/nehe16.c | 474 ++-- examples/dreamcast/kgl/nehe/nehe16/pvr-texture.c | 312 +-- examples/dreamcast/kgl/nehe/nehe26/Makefile | 70 +- examples/dreamcast/kgl/nehe/nehe26/data/sphere.txt | 974 ++++---- examples/dreamcast/kgl/nehe/nehe26/data/torus.txt | 974 ++++---- examples/dreamcast/kgl/nehe/nehe26/data/tube.txt | 974 ++++---- examples/dreamcast/kgl/nehe/nehe26/nehe26.c | 770 +++---- examples/dreamcast/network/httpd/simhost.c | 2 +- examples/dreamcast/pvr/bumpmap/bump.c | 2 +- .../dreamcast/pvr/modifier_volume_tex/modifier.c | 2 +- examples/dreamcast/rumble/rumble.c | 17 +- examples/dreamcast/sd/speedtest/sd-speedtest.c | 2 +- examples/dreamcast/sound/hello-opus/opustest.c | 2 +- examples/dreamcast/vmu/vmu_beep/Makefile | 72 +- examples/dreamcast/vmu/vmu_beep/beep.c | 13 +- examples/dreamcast/vmu/vmu_lcd/Makefile | 58 +- examples/dreamcast/vmu/vmu_lcd/lcd.c | 20 +- include/kos.h | 1 + include/kos/init.h | 88 + kernel/arch/dreamcast/include/arch/arch.h | 55 +- kernel/arch/dreamcast/include/arch/init_flags.h | 41 + 82 files changed, 10526 insertions(+), 10434 deletions(-) create mode 100644 include/kos/init.h create mode 100644 kernel/arch/dreamcast/include/arch/init_flags.h diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 6c7f1e3..20bd0bd 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -177,6 +177,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Update bfont example for Dreamcast-specific characters [DH] - DC Add example for VMU speaker use [DH && FG] - DC Add example for rumble accessory use [DH] +- *** Split init flags from <arch/arch.h> into <kos/init.h> [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/basic/memtest32/main.c b/examples/dreamcast/basic/memtest32/main.c index 291ba8b..1acd8e5 100644 --- a/examples/dreamcast/basic/memtest32/main.c +++ b/examples/dreamcast/basic/memtest32/main.c @@ -27,6 +27,7 @@ #include <stdio.h> #include <stdint.h> +#include <kos/init.h> #include <arch/arch.h> #include "memtest.h" @@ -40,8 +41,8 @@ #define BASE_ADDRESS (volatile datum *) (0x8c000000 + SAFE_AREA) /* Define the number of bytes to be tested. KallistiOS provides the - * macros HW_MEM_16 and HW_MEM_32 in <arch/arch.h> which describe - * the number of bytes available in standard supported console + * macros HW_MEM_16 and HW_MEM_32 in <arch/arch.h> which describe + * the number of bytes available in standard supported console * configurations (16777216 and 33554432, respectively). */ #define NUM_BYTES_32 (HW_MEM_32 - SAFE_AREA - STACK_SIZE) #define NUM_BYTES_16 (HW_MEM_16 - SAFE_AREA - STACK_SIZE) diff --git a/examples/dreamcast/basic/memtest32/memtest.c b/examples/dreamcast/basic/memtest32/memtest.c index 5321600..a9807df 100644 --- a/examples/dreamcast/basic/memtest32/memtest.c +++ b/examples/dreamcast/basic/memtest32/memtest.c @@ -1,221 +1,221 @@ -/********************************************************************** - * - * Filename: memtest.c - * - * Description: General-purpose memory testing functions. - * - * Notes: This software can be easily ported to systems with - * different data bus widths by redefining 'datum'. - * - * - * Copyright (c) 1998 by Michael Barr. This software is placed into - * the public domain and may be used for any purpose. However, this - * notice must not be changed or removed and no warranty is either - * expressed or implied by its publication or distribution. - **********************************************************************/ - - -#include "memtest.h" - - -/********************************************************************** - * - * Function: memTestDataBus() - * - * Description: Test the data bus wiring in a memory region by - * performing a walking 1's test at a fixed address - * within that region. The address (and hence the - * memory region) is selected by the caller. - * - * Notes: - * - * Returns: 0 if the test succeeds. - * A non-zero result is the first pattern that failed. - * - **********************************************************************/ -datum -memTestDataBus(volatile datum * address) -{ - datum pattern; - - - /* - * Perform a walking 1's test at the given address. - */ - for (pattern = 1; pattern != 0; pattern <<= 1) - { - /* - * Write the test pattern. - */ - *address = pattern; - - /* - * Read it back (immediately is okay for this test). - */ - if (*address != pattern) - { - return (pattern); - } - } - - return (0); - -} /* memTestDataBus() */ - - -/********************************************************************** - * - * Function: memTestAddressBus() - * - * Description: Test the address bus wiring in a memory region by - * performing a walking 1's test on the relevant bits - * of the address and checking for aliasing. This test - * will find single-bit address failures such as stuck - * -high, stuck-low, and shorted pins. The base address - * and size of the region are selected by the caller. - * - * Notes: For best results, the selected base address should - * have enough LSB 0's to guarantee single address bit - * changes. For example, to test a 64-Kbyte region, - * select a base address on a 64-Kbyte boundary. Also, - * select the region size as a power-of-two--if at all - * possible. - * - * Returns: NULL if the test succeeds. - * A non-zero result is the first address at which an - * aliasing problem was uncovered. By examining the - * contents of memory, it may be possible to gather - * additional information about the problem. - * - **********************************************************************/ -datum * -memTestAddressBus(volatile datum * baseAddress, unsigned long nBytes) -{ - unsigned long addressMask = (nBytes/sizeof(datum) - 1); - unsigned long offset; - unsigned long testOffset; - - datum pattern = (datum) 0xAAAAAAAA; - datum antipattern = (datum) 0x55555555; - - - /* - * Write the default pattern at each of the power-of-two offsets. - */ - for (offset = 1; (offset & addressMask) != 0; offset <<= 1) - { - baseAddress[offset] = pattern; - } - - /* - * Check for address bits stuck high. - */ - testOffset = 0; - baseAddress[testOffset] = antipattern; - - for (offset = 1; (offset & addressMask) != 0; offset <<= 1) - { - if (baseAddress[offset] != pattern) - { - return ((datum *) &baseAddress[offset]); - } - } - - baseAddress[testOffset] = pattern; - - /* - * Check for address bits stuck low or shorted. - */ - for (testOffset = 1; (testOffset & addressMask) != 0; testOffset <<= 1) - { - baseAddress[testOffset] = antipattern; - - if (baseAddress[0] != pattern) - { - return ((datum *) &baseAddress[testOffset]); - } - - for (offset = 1; (offset & addressMask) != 0; offset <<= 1) - { - if ((baseAddress[offset] != pattern) && (offset != testOffset)) - { - return ((datum *) &baseAddress[testOffset]); - } - } - - baseAddress[testOffset] = pattern; - } - - return (NULL); - -} /* memTestAddressBus() */ - - -/********************************************************************** - * - * Function: memTestDevice() - * - * Description: Test the integrity of a physical memory device by - * performing an increment/decrement test over the - * entire region. In the process every storage bit - * in the device is tested as a zero and a one. The - * base address and the size of the region are - * selected by the caller. - * - * Notes: - * - * Returns: NULL if the test succeeds. - * - * A non-zero result is the first address at which an - * incorrect value was read back. By examining the - * contents of memory, it may be possible to gather - * additional information about the problem. - * - **********************************************************************/ -datum * -memTestDevice(volatile datum * baseAddress, unsigned long nBytes) -{ - unsigned long offset; - unsigned long nWords = nBytes / sizeof(datum); - - datum pattern; - datum antipattern; - - - /* - * Fill memory with a known pattern. - */ - for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++) - { - baseAddress[offset] = pattern; - } - - /* - * Check each location and invert it for the second pass. - */ - for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++) - { - if (baseAddress[offset] != pattern) - { - return ((datum *) &baseAddress[offset]); - } - - antipattern = ~pattern; - baseAddress[offset] = antipattern; - } - - /* - * Check each location for the inverted pattern and zero it. - */ - for (pattern = 1, offset = 0; offset < nWords; pattern++, offset++) - { - antipattern = ~pattern; - if (baseAddress[offset] != antipattern) - { - return ((datum *) &baseAddress[offset]); - } - } - - return (NULL); - -} /* memTestDevice() */ +/********************************************************************** + * + * Filename: memtest.c + * + * Description: General-purpose memory testing functions. + * + * Notes: This software can be easily ported to systems with + * different data bus widths by redefining 'datum'. + * + * + * Copyright (c) 1998 by Michael Barr. This software is placed into + * the public domain and may be used for any purpose. However, this + * notice must not be changed or removed and no warranty is either + * expressed or implied by its publication or distribution. + **********************************************************************/ + + +#include "memtest.h" + + +/********************************************************************** + * + * Function: memTestDataBus() + * + * Description: Test the data bus wiring in a memory region by + * performing a walking 1's test at a fixed address + * within that region. The address (and hence the + * memory region) is selected by the caller. + * + * Notes: + * + * Returns: 0 if the test succeeds. + * A non-zero result is the first pattern that failed. + * + **********************************************************************/ +datum +memTestDataBus(volatile datum * address) +{ + datum pattern; + + + /* + * Perform a walking 1's test at the given address. + */ + for (pattern = 1; pattern != 0; pattern <<= 1) + { + /* + * Write the test pattern. + */ + *address = pattern; + + /* + * Read it back (immediately is okay for this test). + */ + if (*address != pattern) + { + return (pattern); + } + } + + return (0); + +} /* memTestDataBus() */ + + +/********************************************************************** + * + * Function: memTestAddressBus() + * + * Description: Test the address bus wiring in a memory region by + * performing a walking 1's test on the relevant bits + * of the address and checking for aliasing. This test + * will find single-bit address failures such as stuck + * -high, stuck-low, and shorted pins. The base address + * and size of the region are selected by the caller. + * + * Notes: For best results, the selected base address should + * have enough LSB 0's to guarantee single address bit + * changes. For example, to test a 64-Kbyte region, + * select a base address on a 64-Kbyte boundary. Also, + * select the region size as a power-of-two--if at all + * possible. + * + * Returns: NULL if the test succeeds. + * A non-zero result is the first address at which an + * aliasing problem was uncovered. By examining the + * contents of memory, it may be possible to gather + * additional information about the problem. + * + **********************************************************************/ +datum * +memTestAddressBus(volatile datum * baseAddress, unsigned long nBytes) +{ + unsigned long addressMask = (nBytes/sizeof(datum) - 1); + unsigned long offset; + unsigned long testOffset; + + datum pattern = (datum) 0xAAAAAAAA; + datum antipattern = (datum) 0x55555555; + + + /* + * Write the default pattern at each of the power-of-two offsets. + */ + for (offset = 1; (offset & addressMask) != 0; offset <<= 1) + { + baseAddress[offset] = pattern; + } + + /* + * Check for address bits stuck high. + */ + testOffset = 0; + baseAddress[testOffset] = antipattern; + + for (offset = 1; (offset & addressMask) != 0; offset <<= 1) + { + if (baseAddress[offset] != pattern) + { + return ((datum *) &baseAddress[offset]); + } + } + + baseAddress[testOffset] = pattern; + + /* + * Check for address bits stuck low or shorted. + */ + for (testOffset = 1; (testOffset & addressMask) != 0; testOffset <<= 1) + { + baseAddress[testOffset] = antipattern; + + if (baseAddress[0] != pattern) + { + return ((datum *) &baseAddress[testOffset]); + } + + for (offset = 1; (offset & addressMask) != 0; offset <<= 1) + { + if ((baseAddress[offset] != pattern) && (offset != testOffset)) + { + return ((datum *) &baseAddress[testOffset]); + } + } + + baseAddress[testOffset] = pattern; + } + + return (NULL); + +} /* memTestAddressBus() */ + + +/********************************************************************** + * + * Function: memTestDevice() + * + * Description: Test the integrity of a physical memory device by + * performing an increment/decrement test over the + * entire region. In the process every storage bit + * in the device is tested as a zero and a one. The + * base address and the size of the region are + * selected by the caller. + * + * Notes: ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-04 01:33:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, init-flags-header has been created at b720f3891036040cf7081c01255d7c7fe236eb9d (commit) - Log ----------------------------------------------------------------- commit b720f3891036040cf7081c01255d7c7fe236eb9d Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 21:33:30 2023 -0400 Fix examples that fail to compile due to missing headers. commit 868673af42808f56ec0192ee32f7db9faf7157c8 Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 17:42:06 2023 -0400 Update changelog for init flags header change commit dadeb40746488aa74bc7745cd2803393607e1180 Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 17:34:42 2023 -0400 Update examples to account for <kos/init.h> header. commit 644c7faea83165c634ee683fed64ee9c6093b636 Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 17:29:48 2023 -0400 Add new init flags headers. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-03 21:38: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 b0a75b33759c57b9399aa8bf9f69806977a952bd (commit) from 3ba1a8e7c28117a77019b98b194fd64283517283 (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 b0a75b33759c57b9399aa8bf9f69806977a952bd Author: darcagn <da...@pr...> Date: Sat Jun 3 16:38:03 2023 -0500 Help prevent duplicate paths and flags upon multiple sourcing of environ.sh (#234) * Help prevent duplicate paths and flags upon multiple sourcing of environ.sh ----------------------------------------------------------------------- Summary of changes: doc/environ.sh.sample | 8 ++++++-- environ_base.sh | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample index a6dbcfb..9ed3aae 100644 --- a/doc/environ.sh.sample +++ b/doc/environ.sh.sample @@ -57,15 +57,19 @@ export KOS_CC_PREFIX="sh-elf" export DC_ARM_BASE="/opt/toolchains/dc/arm-eabi" export DC_ARM_PREFIX="arm-eabi" -# Expand PATH (comment out if you don't want this done here) -export PATH="${PATH}:${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin" +# Expand PATH if not already set (comment out if you don't want this done here) +if [[ ":$PATH:" != *":${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin"* ]]; then + export PATH="${PATH}:${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin" +fi # reset some options because there's no reason for them to persist across # multiple sourcing of this +export KOS_INC_PATHS="" export KOS_CFLAGS="" export KOS_CPPFLAGS="" export KOS_LDFLAGS="" export KOS_AFLAGS="" +export DC_ARM_LDFLAGS="" # Setup some default CFLAGS for compilation. The things that will go here # are user specifyable, like optimization level and whether you want stack diff --git a/environ_base.sh b/environ_base.sh index ade36db..4fe5414 100644 --- a/environ_base.sh +++ b/environ_base.sh @@ -12,8 +12,10 @@ export KOS_ARCH_DIR="${KOS_BASE}/kernel/arch/${KOS_ARCH}" # Pull in the arch environ file . ${KOS_BASE}/environ_${KOS_ARCH}.sh -# Add the gnu wrappers dir to the path -export PATH="${PATH}:${KOS_BASE}/utils/gnu_wrappers" +# Add the gnu wrappers dir to the path if it is not already +if [[ ":$PATH:" != *":${KOS_BASE}/utils/gnu_wrappers"* ]]; then + export PATH="${PATH}:${KOS_BASE}/utils/gnu_wrappers" +fi # Our includes export KOS_INC_PATHS="${KOS_INC_PATHS} -I${KOS_BASE}/include \ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-03 21:02:45
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 3ba1a8e7c28117a77019b98b194fd64283517283 (commit) via 0f0bfa1f53afd3eae64a5819f75f5dad87d206c8 (commit) via 7a24987acdb249e90257b8ba60db3a07ce494004 (commit) via 260b1b4dcb9563ebfa995b623544361c31f1e8f2 (commit) from f9f02709c946f6b3b00e39e3dec6d394d4b39f6e (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 3ba1a8e7c28117a77019b98b194fd64283517283 Merge: f9f0270 0f0bfa1 Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 17:02:17 2023 -0400 Merge pull request #233 from cepawiel/dc-chain-download DC-Chain: Move fetch/unpack/cleanup functionality from Bash Scripts to Makefile commit 0f0bfa1f53afd3eae64a5819f75f5dad87d206c8 Author: Colton Pawielski <cep...@mt...> Date: Sat Jun 3 14:39:39 2023 -0500 Update dc-chain docs commit 7a24987acdb249e90257b8ba60db3a07ce494004 Author: Colton Pawielski <cep...@mt...> Date: Sat Jun 3 14:39:19 2023 -0500 Remove dc-chain bash scripts commit 260b1b4dcb9563ebfa995b623544361c31f1e8f2 Author: Colton Pawielski <cep...@mt...> Date: Sat Jun 3 13:54:33 2023 -0500 Implement dc-chain download and unpack in Makefiles ----------------------------------------------------------------------- Summary of changes: utils/dc-chain/README.md | 29 ++++--- utils/dc-chain/cleanup.sh | 133 -------------------------------- utils/dc-chain/doc/CONTRIBUTORS.md | 1 + utils/dc-chain/doc/bsd/README.md | 12 +-- utils/dc-chain/doc/cygwin/README.md | 12 +-- utils/dc-chain/doc/linux/alpine.md | 10 +-- utils/dc-chain/doc/linux/debian.md | 12 +-- utils/dc-chain/doc/macos/README.md | 10 +-- utils/dc-chain/doc/mingw/mingw-w64.md | 12 +-- utils/dc-chain/doc/mingw/mingw.md | 12 +-- utils/dc-chain/download.sh | 111 --------------------------- utils/dc-chain/scripts/build.mk | 30 ++++++-- utils/dc-chain/scripts/clean.mk | 40 +++++++++- utils/dc-chain/scripts/common.sh | 138 ---------------------------------- utils/dc-chain/scripts/download.mk | 67 ++++++++++++++++- utils/dc-chain/scripts/newlib.mk | 8 +- utils/dc-chain/scripts/patch.mk | 9 +++ utils/dc-chain/scripts/phony.mk | 5 +- utils/dc-chain/unpack.sh | 87 --------------------- 19 files changed, 172 insertions(+), 566 deletions(-) delete mode 100755 utils/dc-chain/cleanup.sh delete mode 100755 utils/dc-chain/download.sh delete mode 100755 utils/dc-chain/scripts/common.sh delete mode 100755 utils/dc-chain/unpack.sh diff --git a/utils/dc-chain/README.md b/utils/dc-chain/README.md index 8a41dd3..9a9c0ba 100644 --- a/utils/dc-chain/README.md +++ b/utils/dc-chain/README.md @@ -59,9 +59,7 @@ for your computer installed. Indeed, to build the cross-compilers you'll need a working compilation environment on your computer. In addition, you must have `bash` installed on your host system. Other shells -*may* work, but are not tested and not guaranteed to work. The `download.sh` and -`unpack.sh` scripts should be able to find your system's installed `bash` so -long as it is installed in a standard location. +*may* work, but are not tested and not guaranteed to work. If you need help on this step, everything is described in the `./doc` directory. @@ -146,8 +144,9 @@ the use of `git_repo` and `git_branch` variables to specify the repository and branch respectively. If `git_branch` is omitted, the default for the repository will be used. -**Note:** All download URL are computed in the `scripts/common.sh` file, but -you shouldn't update/change this. +**Note:** All download URL are computed in the `scripts/download.mk` file, but +you shouldn't update/change this as it can be overriden with the `gnu_mirror` +config option detailed below. ### Toolchains base @@ -273,16 +272,14 @@ After installing all the prerequisites and tweaking the configuration with the Below you will find some generic instructions; you may find some specific instructions in the `./doc` directory for your environment. -1. Execute the following for preparing the sources (if you have any syntax - errors running the scripts, try running with `bash` explicitly): - - ./download.sh - ./unpack.sh - -2. Finally, input (for **BSD**, please use `gmake` instead): +In the dc-chain directory, run (for **BSD**, please use `gmake` instead): make +This will build the ARM & SH4 toolchains. If you wish to only build the SH4 +toolchain and just use the prebuilt KOS sound driver run: + make build-sh4 + Depending of your environment, this can take a bunch of hours. So please be patient! @@ -302,10 +299,9 @@ documentation to learn more on this point. ### Removing all useless files -After the toolchain compilation, you can cleanup everything by entering (if -you had to use `bash` explicitly above, you will need to do so again here): +After the toolchain compilation, you can cleanup everything by entering: - ./cleanup.sh + make clean This will save a lot of space by removing all unnecessary files. @@ -317,7 +313,8 @@ of the problematic step only rather than running the whole process again. Interesting targets (you can `make` any of these): -- `all`: `patch` `build` (patch and build everything, excluding `gdb`) +- `all`: `fetch` `patch` `build` (fetch, patch and build everything, excluding `gdb`) +- `fetch`: `fetch-sh4` `fetch-arm` `fetch-gdb` - `patch`: `patch-gcc` `patch-newlib` `patch-kos` (should be executed once) - `build`: `build-sh4` `build-arm` (build everything, excluding `gdb`) - `build-sh4`: `build-sh4-binutils` `build-sh4-gcc` (build only `sh-elf` toolchain, excluding `gdb`) diff --git a/utils/dc-chain/cleanup.sh b/utils/dc-chain/cleanup.sh deleted file mode 100755 index f009094..0000000 --- a/utils/dc-chain/cleanup.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env bash - -# Getting configuration from Makefile -source ./scripts/common.sh - -print_banner "Cleaner" - -while [ "$1" != "" ]; do - PARAM=`echo $1 | awk -F= '{print $1}'` - case $PARAM in - --including-logs) - DELETE_LOGS=1 - ;; - --keep-downloads) - KEEP_DOWNLOADS=1 - ;; - *) - echo "error: unknown parameter \"$PARAM\"" - exit 1 - ;; - esac - shift -done - -function cleanup_dependency() -{ - local type="$1" - local dep_name="$2" - local dep_ver=$3_VER - local dep_type=$3_TARBALL_TYPE - - local dep="${dep_name}-${!dep_ver}" - - if [ -n "${!dep_ver}" ]; then - if [ "$type" == "package" ]; then - rm -f "${dep}.tar.${!dep_type}" - else - rm -rf "${dep}" - fi - fi -} - -function cleanup_dependencies() -{ - local type=$2 - - if [ "$USE_CUSTOM_DEPENDENCIES" == "1" ]; then - cleanup_dependency "$type" "GMP" "$1_GMP" - cleanup_dependency "$type" "MPFR" "$1_MPFR" - cleanup_dependency "$type" "MPC" "$1_MPC" - cleanup_dependency "$type" "ISL" "$1_ISL" - fi -} - -if [ -z $KEEP_DOWNLOADS ]; then - # Clean up downloaded tarballs... - echo "Deleting downloaded packages..." - - rm -f binutils-$SH_BINUTILS_VER.tar.$SH_BINUTILS_TARBALL_TYPE \ - binutils-$ARM_BINUTILS_VER.tar.$ARM_BINUTILS_TARBALL_TYPE \ - gcc-$SH_GCC_VER.tar.$SH_GCC_TARBALL_TYPE \ - gcc-$ARM_GCC_VER.tar.$ARM_GCC_TARBALL_TYPE \ - newlib-$NEWLIB_VER.tar.$NEWLIB_TARBALL_TYPE - - if [ "$USE_CUSTOM_DEPENDENCIES" == "1" ]; then - cleanup_dependencies "SH" "package" - cleanup_dependencies "ARM" "package" - fi - - if [ -f "gdb-$GDB_VER.tar.$GDB_TARBALL_TYPE" ]; then - rm -f gdb-$GDB_VER.tar.$GDB_TARBALL_TYPE - fi - - echo "Done!" - echo "---------------------------------------" -fi - -# Clean up unpacked sources... -echo "Deleting unpacked package sources..." -rm -rf binutils-$SH_BINUTILS_VER binutils-$ARM_BINUTILS_VER \ - gcc-$SH_GCC_VER gcc-$ARM_GCC_VER \ - newlib-$NEWLIB_VER \ - *.stamp - -if [ "$USE_CUSTOM_DEPENDENCIES" == "1" ]; then - cleanup_dependencies "SH" "dir" - cleanup_dependencies "ARM" "dir" -fi - -if [ -d "gdb-$GDB_VER" ]; then - rm -rf gdb-$GDB_VER -fi - -echo "Done!" -echo "---------------------------------------" - -# Clean up any stale build directories. -echo "Cleaning up build directories..." - -make="make" -if ! [ -z "$(command -v gmake)" ]; then - make="gmake" -fi - -# Cleaning up build directories. -${make} clean > /dev/null 2>&1 - -echo "Done!" -echo "---------------------------------------" - -# Clean up the logs -if [ "$DELETE_LOGS" == "1" ]; then - echo "Cleaning up build logs..." - - if [ -d "logs/" ]; then - rm -f logs/*.log - rmdir logs/ - fi - - echo "Done!" - echo "---------------------------------------" -fi - -if [ -z $KEEP_DOWNLOADS ]; then - # Clean up config.guess - echo "Cleaning up ${CONFIG_GUESS}..." - - if [ -f ${CONFIG_GUESS} ]; then - rm -f "${CONFIG_GUESS}" - fi - - echo "Done!" -fi diff --git a/utils/dc-chain/doc/CONTRIBUTORS.md b/utils/dc-chain/doc/CONTRIBUTORS.md index c3fbb3a..d7c3325 100644 --- a/utils/dc-chain/doc/CONTRIBUTORS.md +++ b/utils/dc-chain/doc/CONTRIBUTORS.md @@ -17,3 +17,4 @@ * 2019 [Ellen Marie Dash](https://gitlab.com/duckinator) * 2020 [Ben Baron](https://github.com/einsteinx2) * 2020 [Jon Daniel](https://github.com/jopadan) +* 2023 [Colton Pawielski](https://github.com/cepawiel) diff --git a/utils/dc-chain/doc/bsd/README.md b/utils/dc-chain/doc/bsd/README.md index 877e717..a471f97 100644 --- a/utils/dc-chain/doc/bsd/README.md +++ b/utils/dc-chain/doc/bsd/README.md @@ -93,15 +93,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -3. Enter the following to download all source packages for all components: - - ./download.sh - -4. Enter the following to unpack all source packages. - - ./unpack.sh - -5. Enter the following to launch the process: +3. Enter the following to start downloading and building toolchain: gmake @@ -121,7 +113,7 @@ This will install `sh-elf-gdb` and can be used to debug programs through After everything is done, you can cleanup all temporary files by entering: - ./cleanup.sh + gmake clean ## Next steps ## diff --git a/utils/dc-chain/doc/cygwin/README.md b/utils/dc-chain/doc/cygwin/README.md index 082ce54..00c6900 100644 --- a/utils/dc-chain/doc/cygwin/README.md +++ b/utils/dc-chain/doc/cygwin/README.md @@ -108,15 +108,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -3. Enter the following to download all source packages for all components: - - ./download.sh - -4. Enter the following to unpack all source packages. - - ./unpack.sh - -5. Enter the following to launch the process: +3. Enter the following to start downloading and building toolchain: make @@ -136,7 +128,7 @@ This will install `sh-elf-gdb` and can be used to debug programs through After everything is done, you can cleanup all temporary files by entering: - ./cleanup.sh + make clean ## Next steps ## diff --git a/utils/dc-chain/doc/linux/alpine.md b/utils/dc-chain/doc/linux/alpine.md index 003e200..1d1bddb 100644 --- a/utils/dc-chain/doc/linux/alpine.md +++ b/utils/dc-chain/doc/linux/alpine.md @@ -79,15 +79,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -2. Enter the following to download all source packages for all components: - - ./download.sh - -3. Enter the following to unpack all source packages. - - ./unpack.sh - -4. Enter the following to launch the process: +2. Enter the following to start downloading and building toolchain: make diff --git a/utils/dc-chain/doc/linux/debian.md b/utils/dc-chain/doc/linux/debian.md index b341609..0e3762f 100644 --- a/utils/dc-chain/doc/linux/debian.md +++ b/utils/dc-chain/doc/linux/debian.md @@ -79,15 +79,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -2. Enter the following to download all source packages for all components: - - ./download.sh - -3. Enter the following to unpack all source packages. - - ./unpack.sh - -4. Enter the following to launch the process: +2. Enter the following to start downloading and building toolchain: make @@ -107,7 +99,7 @@ This will install `sh-elf-gdb` and can be used to debug programs through After everything is done, you can cleanup all temporary files by entering: - ./cleanup.sh + make clean ## Next steps ## diff --git a/utils/dc-chain/doc/macos/README.md b/utils/dc-chain/doc/macos/README.md index 5783923..35f86b7 100644 --- a/utils/dc-chain/doc/macos/README.md +++ b/utils/dc-chain/doc/macos/README.md @@ -107,15 +107,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -2. Enter the following to download all source packages for all components: - - ./download.sh - -3. Enter the following to unpack all source packages. - - ./unpack.sh - -4. Enter the following to launch the process: +2. Enter the following to start downloading and building toolchain: make diff --git a/utils/dc-chain/doc/mingw/mingw-w64.md b/utils/dc-chain/doc/mingw/mingw-w64.md index d7deeb0..acd1045 100644 --- a/utils/dc-chain/doc/mingw/mingw-w64.md +++ b/utils/dc-chain/doc/mingw/mingw-w64.md @@ -118,15 +118,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -3. Enter the following to download all source packages for all components: - - ./download.sh - -4. Enter the following to unpack all source packages. - - ./unpack.sh - -5. Enter the following to launch the process: +3. Enter the following to start downloading and building toolchain: make @@ -146,7 +138,7 @@ This will install `sh-elf-gdb` and can be used to debug programs through After everything is done, you can cleanup all temporary files by entering: - ./cleanup.sh + make clean ## Fixing up Newlib for SH-4 ## diff --git a/utils/dc-chain/doc/mingw/mingw.md b/utils/dc-chain/doc/mingw/mingw.md index 7dd0882..6f9de28 100644 --- a/utils/dc-chain/doc/mingw/mingw.md +++ b/utils/dc-chain/doc/mingw/mingw.md @@ -183,15 +183,7 @@ To make the toolchains, do the following: cd /opt/toolchains/dc/kos/utils/dc-chain/ -3. Enter the following to download all source packages for all components: - - ./download.sh - -4. Enter the following to unpack all source packages. - - ./unpack.sh - -5. Enter the following to launch the process: +3. Enter the following to start downloading and building toolchain: make @@ -211,7 +203,7 @@ This will install `sh-elf-gdb` and can be used to debug programs through After everything is done, you can cleanup all temporary files by entering: - ./cleanup.sh + make clean ## Removing the MSYS heap patch ## diff --git a/utils/dc-chain/download.sh b/utils/dc-chain/download.sh deleted file mode 100755 index 12edf2b..0000000 --- a/utils/dc-chain/download.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash - -# Getting configuration from Makefile -source ./scripts/common.sh || exit 1 - -print_banner "Downloader" - -while [ "$1" != "" ]; do - PARAM=`echo $1 | awk -F= '{print $1}'` - case $PARAM in - --config-guess-only) - CONFIG_GUESS_ONLY=1 - ;; - *) - echo "error: unknown parameter \"$PARAM\"" - exit 1 - ;; - esac - shift -done - -function download() -{ - local name=$1 - local prefix=$2 - - local ver="$2_VER" - local download_type="$2_DOWNLOAD_TYPE" - - # if version is not empty - if [ ! -n "${!ver}" ]; then - echo "ERROR: ${name} version must not be empty" - exit 1 - fi - - # source tarball - if [[ "${!download_type}" == "tarball" ]]; then - local url=$2_TARBALL_URL - local filename=$(basename "${!url}") - if [ -f $filename ]; then - echo "${name} ${!ver} was already downloaded" - else - echo "Downloading ${name} ${!ver} from ${!url}" - ${WEB_DOWNLOADER} "${DOWNLOAD_PROTOCOL}${!url}" || exit 1 - fi - # source tarball - elif [[ "${!download_type}" == "git" ]]; then - local filename=$(tolower $name)-${!ver} - local repo=$2_GIT_REPO - local branch=$2_GIT_BRANCH - if [ -d $filename ]; then - echo "${name} \"${filename}\" already exists" - else - if [ -z ${!branch} ]; then - echo "Downloading ${name} from ${!repo}" - ${GIT_CLONE} ${!repo} ${filename} || exit 1 - else - echo "Downloading ${name} from ${!repo}:${!branch}" - ${GIT_CLONE} ${!repo} -b ${!branch} ${filename} || exit 1 - fi - fi - - # invalid type (shouldn't get here) - else - printf "Invalid Download Type ${!download_type}\n" - exit 1 - fi -} - ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-03 19:18: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 f9f02709c946f6b3b00e39e3dec6d394d4b39f6e (commit) via 9dc74f235b78893a29cb64e3a0853d9f78ddfe22 (commit) via 2d7796621b2c43a4745bdbb0de8f3a449424b340 (commit) via 51d454f736cadd5a17327f0eac5da51dada024ec (commit) via ca4ed1de159b809f7abf31b1f37a5b4f1814abed (commit) via 92271718c6150c92f1f5374260373932cb34697d (commit) via 55450c0c13fb9148a51031732998e7b6eb2fc210 (commit) via 15823fd84ac07aa1036f5339bf9a494ff50037ae (commit) via b20807dc5c1caa8de536d250b876970117fb2905 (commit) via a97469ce5a5da81e6f4f299f0cd520409a5eecbe (commit) via b24dacacfd643209ab5375f6d173cd3e36e294df (commit) via 0a69bf0ee955ede00f267a6089cfd03da4dd5536 (commit) via f047f20a2e49e041fc72396ece695fbb19379cc2 (commit) via 13e9c5412ead86534ecc421171780bf3e30bbdb2 (commit) from ee67ff9a35bcfc4b4628da99b8f771137c2ea572 (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 f9f02709c946f6b3b00e39e3dec6d394d4b39f6e Merge: ee67ff9 9dc74f2 Author: Lawrence Sebald <ljs...@us...> Date: Sat Jun 3 15:15:16 2023 -0400 Merge pull request #217 from KallistiOS/safe_arches Clean up arch-related stuff in case of future arches other than Dreamcast. commit 9dc74f235b78893a29cb64e3a0853d9f78ddfe22 Author: Quzar <qu...@co...> Date: Sat May 27 00:01:29 2023 -0400 Adjust the previous comments I'd made to reflect how the file is handled. commit 2d7796621b2c43a4745bdbb0de8f3a449424b340 Author: Quzar <qu...@co...> Date: Fri May 26 23:24:43 2023 -0400 Send newlib flag to disable syscalls instead of patching them out. Copy lock.h instead of patching it in. Stop copying the dc include folder as it isn't needed. commit 51d454f736cadd5a17327f0eac5da51dada024ec Author: Quzar <qu...@co...> Date: Fri May 26 23:22:33 2023 -0400 Reducing the scope of chained includes in <kos/thread.h> and <arch/arch.h>. This makes way for removing newlib's dependence on the dc include folder, which was only there to get <arch/irq.h> roundabout into <kos/thread.h>. Unfortunately this required adjusting some examples to be sure they could see <arch/arch.h> for KOS_INIT stuff. commit ca4ed1de159b809f7abf31b1f37a5b4f1814abed Author: Quzar <qu...@co...> Date: Fri May 26 07:50:21 2023 -0400 Revert "Remove lock.h from the newlib patch, and remove the note about it from the header." I really can't tell if this worked right. I'm going to make a separate issue for it. This reverts commit 92271718c6150c92f1f5374260373932cb34697d. commit 92271718c6150c92f1f5374260373932cb34697d Author: Quzar <qu...@co...> Date: Thu May 25 22:31:11 2023 -0400 Remove lock.h from the newlib patch, and remove the note about it from the header. commit 55450c0c13fb9148a51031732998e7b6eb2fc210 Author: Quzar <qu...@co...> Date: Thu May 25 15:44:39 2023 -0400 Readding this file out of the dc-newlib patches with a note that changes should be reflected there and it may generally be needed for other archs commit 15823fd84ac07aa1036f5339bf9a494ff50037ae Author: Quzar <qu...@co...> Date: Thu May 25 14:03:44 2023 -0400 Explicitly add the kos headers that have the typedef for kthread_t and kos' mutex functions/defines commit b20807dc5c1caa8de536d250b876970117fb2905 Author: Quzar <qu...@co...> Date: Thu May 25 13:31:51 2023 -0400 Update uint8 to uint8_t as this doesn't have any ties to arch/types commit a97469ce5a5da81e6f4f299f0cd520409a5eecbe Author: Quzar <qu...@co...> Date: Thu May 25 13:31:04 2023 -0400 Update uint8 to uint8_t as this doesn't have any ties to arch/types commit b24dacacfd643209ab5375f6d173cd3e36e294df Author: Quzar <qu...@co...> Date: Thu May 25 13:19:32 2023 -0400 Remove references to <kos/limits.h> where it is not used commit 0a69bf0ee955ede00f267a6089cfd03da4dd5536 Author: Quzar <qu...@co...> Date: Thu May 25 13:01:22 2023 -0400 Adjust <kos/limits.h> to use standard define names and protect them from redefining over <limits.h> commit f047f20a2e49e041fc72396ece695fbb19379cc2 Author: Quzar <qu...@co...> Date: Thu May 25 10:31:26 2023 -0400 rtc functions rtc_unix_secs and rtc_boot_time are being exported for all archs, so shouldn't be gated to arch_dreamcast. commit 13e9c5412ead86534ecc421171780bf3e30bbdb2 Author: Quzar <qu...@co...> Date: Thu May 25 10:26:50 2023 -0400 Since this relies on _arch_mem_top, it should be including arch/arch.h to be sure to find it. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/basic/memtest32/main.c | 8 +- .../dreamcast/cpp/out_of_memory/out_of_memory.cc | 2 + .../dreamcast/kgl/basic/elements/gl-elements.c | 2 + .../dreamcast/kgl/basic/zclip_arrays/gl-arrays.c | 2 + examples/dreamcast/network/httpd/simhost.c | 1 + examples/dreamcast/pvr/bumpmap/bump.c | 2 + .../dreamcast/pvr/modifier_volume_tex/modifier.c | 2 + examples/dreamcast/sd/speedtest/sd-speedtest.c | 6 +- examples/dreamcast/sound/hello-opus/opustest.c | 2 + include/kos.h | 2 +- include/kos/fs.h | 2 +- include/kos/fs_pty.h | 1 - include/kos/fs_ramdisk.h | 1 - include/kos/fs_romdisk.h | 1 - include/kos/fs_socket.h | 1 - include/kos/limits.h | 12 +- include/kos/nmmgr.h | 2 +- include/kos/thread.h | 3 +- include/sys/lock.h | 55 +++ kernel/arch/dreamcast/fs/fs_dcload.c | 1 + kernel/arch/dreamcast/fs/fs_iso9660.c | 2 +- kernel/arch/dreamcast/include/arch/arch.h | 2 +- kernel/arch/dreamcast/include/dc/fs_dcload.h | 1 - kernel/fs/elf.c | 1 + kernel/libc/koslib/inet_ntoa.c | 2 +- kernel/libc/koslib/inet_ntop.c | 2 +- kernel/libc/newlib/newlib_getentropy.c | 2 + kernel/libc/pthreads/pthread_mutex.c | 2 + kernel/libc/pthreads/pthread_thd.c | 2 + kernel/thread/cond.c | 1 - kernel/thread/sem.c | 1 - .../patches/newlib-4.3.0.20230120-kos.diff | 367 +-------------------- utils/dc-chain/scripts/newlib.mk | 7 +- 33 files changed, 107 insertions(+), 393 deletions(-) create mode 100644 include/sys/lock.h diff --git a/examples/dreamcast/basic/memtest32/main.c b/examples/dreamcast/basic/memtest32/main.c index bf32d5f..291ba8b 100644 --- a/examples/dreamcast/basic/memtest32/main.c +++ b/examples/dreamcast/basic/memtest32/main.c @@ -27,6 +27,8 @@ #include <stdio.h> #include <stdint.h> +#include <arch/arch.h> + #include "memtest.h" /* Leave space at the beginning and end of memory for this program and for the @@ -38,9 +40,9 @@ #define BASE_ADDRESS (volatile datum *) (0x8c000000 + SAFE_AREA) /* Define the number of bytes to be tested. KallistiOS provides the - * macros HW_MEM_16 and HW_MEM_32 which describe the number of bytes - * available in standard supported console configurations (16777216 - * and 33554432, respectively). */ + * macros HW_MEM_16 and HW_MEM_32 in <arch/arch.h> which describe + * the number of bytes available in standard supported console + * configurations (16777216 and 33554432, respectively). */ #define NUM_BYTES_32 (HW_MEM_32 - SAFE_AREA - STACK_SIZE) #define NUM_BYTES_16 (HW_MEM_16 - SAFE_AREA - STACK_SIZE) diff --git a/examples/dreamcast/cpp/out_of_memory/out_of_memory.cc b/examples/dreamcast/cpp/out_of_memory/out_of_memory.cc index 7a4064f..10d5c53 100644 --- a/examples/dreamcast/cpp/out_of_memory/out_of_memory.cc +++ b/examples/dreamcast/cpp/out_of_memory/out_of_memory.cc @@ -3,6 +3,8 @@ #include <cstdint> #include <malloc.h> +#include <arch/arch.h> + KOS_INIT_FLAGS(INIT_MALLOCSTATS); void new_handler_cb() { diff --git a/examples/dreamcast/kgl/basic/elements/gl-elements.c b/examples/dreamcast/kgl/basic/elements/gl-elements.c index c03d5b2..c10c906 100644 --- a/examples/dreamcast/kgl/basic/elements/gl-elements.c +++ b/examples/dreamcast/kgl/basic/elements/gl-elements.c @@ -15,6 +15,8 @@ #include <GL/glu.h> #include <GL/glut.h> +#include <arch/arch.h> + /* Load a PVR texture - located in pvr-texture.c */ extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap); diff --git a/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c b/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c index d32bed5..a960373 100644 --- a/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c +++ b/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c @@ -15,6 +15,8 @@ #include <GL/glu.h> #include <GL/glut.h> +#include <arch/arch.h> + /* Load a PVR texture - located in pvr-texture.c */ extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap); diff --git a/examples/dreamcast/network/httpd/simhost.c b/examples/dreamcast/network/httpd/simhost.c index 2ae5a58..cf46aeb 100644 --- a/examples/dreamcast/network/httpd/simhost.c +++ b/examples/dreamcast/network/httpd/simhost.c @@ -3,6 +3,7 @@ #include <dc/biosfont.h> #include <dc/maple.h> #include <dc/maple/controller.h> +#include <arch/arch.h> extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); diff --git a/examples/dreamcast/pvr/bumpmap/bump.c b/examples/dreamcast/pvr/bumpmap/bump.c index 86af312..2d08154 100644 --- a/examples/dreamcast/pvr/bumpmap/bump.c +++ b/examples/dreamcast/pvr/bumpmap/bump.c @@ -17,6 +17,8 @@ #include <dc/fmath.h> #include <dc/maple/controller.h> +#include <arch/arch.h> + #include <kmg/kmg.h> static pvr_sprite_txr_t sprites[2]; diff --git a/examples/dreamcast/pvr/modifier_volume_tex/modifier.c b/examples/dreamcast/pvr/modifier_volume_tex/modifier.c index 1de10dd..7346556 100644 --- a/examples/dreamcast/pvr/modifier_volume_tex/modifier.c +++ b/examples/dreamcast/pvr/modifier_volume_tex/modifier.c @@ -14,6 +14,8 @@ #include <dc/maple.h> #include <dc/maple/controller.h> +#include <arch/arch.h> + #include <pcx/pcx.h> #include <kmg/kmg.h> diff --git a/examples/dreamcast/sd/speedtest/sd-speedtest.c b/examples/dreamcast/sd/speedtest/sd-speedtest.c index 593acac..fcfbded 100644 --- a/examples/dreamcast/sd/speedtest/sd-speedtest.c +++ b/examples/dreamcast/sd/speedtest/sd-speedtest.c @@ -19,7 +19,7 @@ #include <dc/maple/controller.h> #include <arch/timer.h> -#include <arch/types.h> +#include <arch/arch.h> #include <kos/dbgio.h> #include <kos/blockdev.h> @@ -50,8 +50,8 @@ static void __attribute__((__noreturn__)) wait_exit() { int main(int argc, char *argv[]) { kos_blockdev_t sd_dev; - uint64 begin, end, timer, average; - uint64 sum = 0; + uint64_t begin, end, timer, average; + uint64_t sum = 0; uint8_t pt; int i; diff --git a/examples/dreamcast/sound/hello-opus/opustest.c b/examples/dreamcast/sound/hello-opus/opustest.c index 0c743db..a97d5f3 100644 --- a/examples/dreamcast/sound/hello-opus/opustest.c +++ b/examples/dreamcast/sound/hello-opus/opustest.c @@ -14,6 +14,8 @@ #include <dc/maple/controller.h> #include <dc/sound/stream.h> +#include <arch/arch.h> + #include <opusplay/opusplay.h> extern uint8 romdisk[]; diff --git a/include/kos.h b/include/kos.h index ed853dd..d7f528c 100644 --- a/include/kos.h +++ b/include/kos.h @@ -66,11 +66,11 @@ __BEGIN_DECLS #include <arch/exec.h> #include <arch/stack.h> #include <arch/byteorder.h> +#include <arch/rtc.h> #ifdef _arch_dreamcast # include <arch/gdb.h> # include <arch/mmu.h> -# include <arch/rtc.h> # include <dc/asic.h> # include <dc/biosfont.h> diff --git a/include/kos/fs.h b/include/kos/fs.h index b8700fd..1d1ab05 100644 --- a/include/kos/fs.h +++ b/include/kos/fs.h @@ -43,7 +43,7 @@ __BEGIN_DECLS */ typedef struct kos_dirent { int size; /**< \brief Size of the file in bytes. */ - char name[MAX_FN_LEN]; /**< \brief Name of the file. */ + char name[NAME_MAX]; /**< \brief Name of the file. */ time_t time; /**< \brief Last access/mod/change time (depends on VFS) */ uint32 attr; /**< \brief Attributes of the file. */ } dirent_t; diff --git a/include/kos/fs_pty.h b/include/kos/fs_pty.h index e826e60..ddc9ad8 100644 --- a/include/kos/fs_pty.h +++ b/include/kos/fs_pty.h @@ -26,7 +26,6 @@ __BEGIN_DECLS #include <arch/types.h> -#include <kos/limits.h> #include <kos/fs.h> /** \brief Create a new pseudo-terminal. diff --git a/include/kos/fs_ramdisk.h b/include/kos/fs_ramdisk.h index cd68699..bc72a7c 100644 --- a/include/kos/fs_ramdisk.h +++ b/include/kos/fs_ramdisk.h @@ -26,7 +26,6 @@ __BEGIN_DECLS #include <arch/types.h> -#include <kos/limits.h> #include <kos/fs.h> /** \cond */ diff --git a/include/kos/fs_romdisk.h b/include/kos/fs_romdisk.h index f504045..a4a45ff 100644 --- a/include/kos/fs_romdisk.h +++ b/include/kos/fs_romdisk.h @@ -28,7 +28,6 @@ __BEGIN_DECLS #include <arch/types.h> -#include <kos/limits.h> #include <kos/fs.h> /** \cond */ diff --git a/include/kos/fs_socket.h b/include/kos/fs_socket.h index 03e7448..b06c2e5 100644 --- a/include/kos/fs_socket.h +++ b/include/kos/fs_socket.h @@ -29,7 +29,6 @@ __BEGIN_DECLS #include <arch/types.h> -#include <kos/limits.h> #include <kos/fs.h> #include <kos/net.h> #include <sys/queue.h> diff --git a/include/kos/limits.h b/include/kos/limits.h index e7d57d6..b8466ed 100644 --- a/include/kos/limits.h +++ b/include/kos/limits.h @@ -16,8 +16,16 @@ #ifndef __KOS_LIMITS_H #define __KOS_LIMITS_H -#define MAX_FN_LEN 256 /**< \brief Max filename length */ -#define PATH_MAX 4095 /**< \brief Max path length */ +#ifndef NAME_MAX +#define NAME_MAX 256 /**< \brief Max filename length */ +#endif + +#ifndef PATH_MAX +#define PATH_MAX 4096 /**< \brief Max path length */ +#endif + +#ifndef SYMLOOP_MAX #define SYMLOOP_MAX 16 /**< \brief Max number of symlinks resolved */ +#endif #endif /* __KOS_LIMITS_H */ diff --git a/include/kos/nmmgr.h b/include/kos/nmmgr.h index 25d33ae..ad48284 100644 --- a/include/kos/nmmgr.h +++ b/include/kos/nmmgr.h @@ -50,7 +50,7 @@ typedef LIST_HEAD(nmmgr_list, nmmgr_handler) nmmgr_list_t; \headerfile kos/nmmgr.h */ typedef struct nmmgr_handler { - char pathname[MAX_FN_LEN]; /* Path name */ + char pathname[NAME_MAX]; /* Path name */ int pid; /* Process table ID for handler (0 == static) */ uint32 version; /* Version code */ uint32 flags; /* Bitmask of flags */ diff --git a/include/kos/thread.h b/include/kos/thread.h index 0e43377..197c941 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -12,10 +12,9 @@ #include <sys/cdefs.h> __BEGIN_DECLS +#include <kos/cdefs.h> #include <kos/tls.h> -#include <arch/types.h> #include <arch/irq.h> -#include <arch/arch.h> #include <sys/queue.h> #include <sys/reent.h> diff --git a/include/sys/lock.h b/include/sys/lock.h new file mode 100644 index 0000000..ad45790 --- /dev/null +++ b/include/sys/lock.h @@ -0,0 +1,55 @@ +/* KallistiOS ##version## + + lock_common.h + Copyright (C)2004 Megan Potter + + This file is patched into the dc-chain newlib's <sys/lock.h>, by newlib.mk + in \utils\dc-chain\scripts. +*/ + +#ifndef __SYS_LOCK_H__ +#define __SYS_LOCK_H__ + +typedef struct { + void* owner; + int nest; + volatile int lock; +} __newlib_recursive_lock_t; + +#define __NEWLIB_RECURSIVE_LOCK_INIT { (void *)0, 0, 0 } + +typedef volatile int __newlib_lock_t; +#define __NEWLIB_LOCK_INIT 0 + +typedef unsigned long int _COND_T; +typedef __newlib_lock_t _LOCK_T; +typedef __newlib_recursive_lock_t _LOCK_RECURSIVE_T; + +#define __LOCK_INIT(class,lock) class _LOCK_T lock = __NEWLIB_LOCK_INIT; +#define __LOCK_INIT_RECURSIVE(class,lock) class _LOCK_RECURSIVE_T lock = __NEWLIB_RECURSIVE_LOCK_INIT; +#define __lock_init(lock) __newlib_lock_init(&(lock)) +#define __lock_init_recursive(lock) __newlib_lock_init_recursive(&(lock)) +#define __lock_close(lock) __newlib_lock_close(&(lock)) +#define __lock_close_recursive(lock) __newlib_lock_close_recursive(&(lock)) +#define __lock_acquire(lock) __newlib_lock_acquire(&(lock)) +#define __lock_acquire_recursive(lock) __newlib_lock_acquire_recursive(&(lock)) +#define __lock_try_acquire(lock) __newlib_lock_try_acquire(&(lock)) +#define __lock_try_acquire_recursive(lock) __newlib_lock_try_acquire_recursive(&(lock)) +#define __lock_release(lock) __newlib_lock_release(&(lock)) +#define __lock_release_recursive(lock) __newlib_lock_release_recursive(&(lock)) + +void __newlib_lock_init(__newlib_lock_t*); +void __newlib_lock_close(__newlib_lock_t*); +void __newlib_lock_acquire(__newlib_lock_t*); +void __newlib_lock_try_acquire(__newlib_lock_t*); +void __newlib_lock_release(__newlib_lock_t*); + +void __newlib_lock_init_recursive(__newlib_recursive_lock_t*); +void __newlib_lock_close_recursive(__newlib_recursive_lock_t*); +void __newlib_lock_acquire_recursive(__newlib_recursive_lock_t*); +void __newlib_lock_try_acquire_recursive(__newlib_recursive_lock_t*); +void __newlib_lock_release_recursive(__newlib_recursive_lock_t*); + + +#endif // __NEWLIB_LOCK_COMMON_H + diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index b8fe5c0..46f0030 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -20,6 +20,7 @@ printf goes to the dc-tool console #include <dc/fs_dcload.h> #include <kos/thread.h> #include <arch/spinlock.h> +#include <arch/arch.h> #include <kos/dbgio.h> #include <kos/fs.h> diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index 30659fc..4ea7a30 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -430,7 +430,7 @@ static iso_dirent_t *find_object(const char *fn, int dir, /* RockRidge */ int len; uint8 *pnt; - char rrname[MAX_FN_LEN]; + char rrname[NAME_MAX]; int rrnamelen; int size_left; diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h index dd2744c..abae8b1 100644 --- a/kernel/arch/dreamcast/include/arch/arch.h +++ b/kernel/arch/dreamcast/include/arch/arch.h @@ -21,7 +21,7 @@ #include <kos/cdefs.h> __BEGIN_DECLS -#include <dc/video.h> +#include <arch/types.h> /** \brief Top of memory available, depending on memory size. */ #ifdef __KOS_GCC_32MB__ diff --git a/kernel/arch/dreamcast/include/dc/fs_dcload.h b/kernel/arch/dreamcast/include/dc/fs_dcload.h index 900f7ae..1a8892f 100644 --- a/kernel/arch/dreamcast/include/dc/fs_dcload.h +++ b/kernel/arch/dreamcast/include/dc/fs_dcload.h @@ -25,7 +25,6 @@ __BEGIN_DECLS #include <arch/types.h> -#include <kos/limits.h> #include <kos/fs.h> #include <kos/dbgio.h> diff --git a/kernel/fs/elf.c b/kernel/fs/elf.c index 5a43bc2..2d98a5b 100644 --- a/kernel/fs/elf.c +++ b/kernel/fs/elf.c @@ -8,6 +8,7 @@ #include <string.h> #include <stdio.h> #include <arch/cache.h> +#include <arch/arch.h> #include <kos/fs.h> #include <kos/elf.h> #include <kos/exports.h> diff --git a/kernel/libc/koslib/inet_ntoa.c b/kernel/libc/koslib/inet_ntoa.c index ace3288..c199c9e 100644 --- a/kernel/libc/koslib/inet_ntoa.c +++ b/kernel/libc/koslib/inet_ntoa.c @@ -20,7 +20,7 @@ char *inet_ntoa(struct in_addr addr) { values. This works, regardless of the endianness of the host system because the specs require the address passed in here to be in network byte order (big endian). */ - part = ((uint8 *) &addr.s_addr)[i]; + part = ((uint8_t *) &addr.s_addr)[i]; do { *ch++ = '0' + (char)(part % 10); diff --git a/kernel/libc/koslib/inet_ntop.c b/kernel/libc/koslib/inet_ntop.c index 657595e..48d10bf 100644 --- a/kernel/libc/koslib/inet_ntop.c +++ b/kernel/libc/koslib/inet_ntop.c @@ -22,7 +22,7 @@ static const char *inet_ntop4(const void *src, char *dst, socklen_t size) { values. This works regardless of the endianness of the host system because the specs require the address passed in here to be in network byte order (big endian). */ - part = ((uint8 *) &addr->s_addr)[i]; + part = ((uint8_t *) &addr->s_addr)[i]; do { *ch++ = '0' + (char)(part % 10); diff --git a/kernel/libc/newlib/newlib_getentropy.c b/kernel/libc/newlib/newlib_getentropy.c index dfdc2a2..5345182 100644 --- a/kernel/libc/newlib/newlib_getentropy.c +++ b/kernel/libc/newlib/newlib_getentropy.c @@ -10,6 +10,8 @@ #include <unistd.h> #include <sys/time.h> +#include <arch/arch.h> + int getentropy(void *ptr, size_t len) { const int block_size = 128; struct timeval tv; diff --git a/kernel/libc/pthreads/pthread_mutex.c b/kernel/libc/pthreads/pthread_mutex.c index a4084bb..ae4d89e 100644 --- a/kernel/libc/pthreads/pthread_mutex.c +++ b/kernel/libc/pthreads/pthread_mutex.c @@ -6,6 +6,8 @@ #include <errno.h> #include <assert.h> +#include <kos/mutex.h> + // XXX Recursive mutexes are not supported ... this could cause deadlocks // in code expecting it. Where do you set that!? diff --git a/kernel/libc/pthreads/pthread_thd.c b/kernel/libc/pthreads/pthread_thd.c index 443734b..ff65ecb 100644 --- a/kernel/libc/pthreads/pthread_thd.c +++ b/kernel/libc/pthreads/pthread_thd.c @@ -2,6 +2,8 @@ #include <errno.h> #include <assert.h> +#include <kos/thread.h> + /* Thread Creation, P1003.1c/Draft 10, p. 144 */ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, diff --git a/kernel/thread/cond.c b/kernel/thread/cond.c index 827854e..89600fa 100644 --- a/kernel/thread/cond.c +++ b/kernel/thread/cond.c @@ -14,7 +14,6 @@ #include <errno.h> #include <kos/thread.h> -#include <kos/limits.h> #include <kos/cond.h> #include <kos/genwait.h> diff --git a/kernel/thread/sem.c b/kernel/thread/sem.c index 78cae46..0329a72 100644 --- a/kernel/thread/sem.c +++ b/kernel/thread/sem.c @@ -16,7 +16,6 @@ #include <errno.h> ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-03 02:36: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 ee67ff9a35bcfc4b4628da99b8f771137c2ea572 (commit) from b0be55caed3a7b965920824fb156f7cb21323588 (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 ee67ff9a35bcfc4b4628da99b8f771137c2ea572 Author: Donald Haase <qu...@ya...> Date: Fri Jun 2 22:35:44 2023 -0400 Various corrections from static analysis (#204) * Correct TCP Close-Wait never being able to provide flags. * Fix possible memory leak * Error before possible NULL deferences * Give the default assert handler the attribute hint that it doesn't return. * Prevent possible NULL deref in thd_set_prio, provide error returns. * Prevent memory leaks in error paths. * Better error handling, errno setting, and less memory leakage. * Clean up memory leaks and null derefs in VMU stuff * Correct null deref and update doxy a little. * Correct null derefs and mem leak in romdisk. Update error return documentation * Fix null derefs, some that should be common * Avoid null deref via calloc rather than 0-initing each element * Whitespace * More cleanups * Fix spacing, remove errno if not already being used * alloc inside the if checks and newline for if-returns * Apply suggestions from code review ----------------------------------------------------------------------- Summary of changes: addons/libkosext2fs/fs_ext2.c | 8 +++- include/assert.h | 1 + include/kos/fs_romdisk.h | 4 +- include/kos/net.h | 4 +- include/kos/thread.h | 2 + kernel/arch/dreamcast/fs/fs_vmu.c | 27 +++++++++---- kernel/arch/dreamcast/fs/vmufs.c | 8 +++- kernel/arch/dreamcast/include/arch/mmu.h | 5 ++- kernel/arch/dreamcast/kernel/mmu.c | 4 ++ kernel/arch/dreamcast/sound/snd_sfxmgr.c | 22 +++++++++++ kernel/fs/fs.c | 8 +--- kernel/fs/fs_pty.c | 67 ++++++++++++++++++-------------- kernel/fs/fs_ramdisk.c | 35 +++++++++++++++-- kernel/fs/fs_romdisk.c | 13 ++++++- kernel/libc/koslib/assert.c | 4 +- kernel/net/net_arp.c | 8 ++++ kernel/net/net_tcp.c | 2 +- kernel/net/net_udp.c | 1 + kernel/thread/thread.c | 6 +++ 19 files changed, 171 insertions(+), 58 deletions(-) diff --git a/addons/libkosext2fs/fs_ext2.c b/addons/libkosext2fs/fs_ext2.c index fe68e28..d2365bc 100644 --- a/addons/libkosext2fs/fs_ext2.c +++ b/addons/libkosext2fs/fs_ext2.c @@ -740,6 +740,7 @@ static int int_rename(fs_ext2_fs_t *fs, const char *fn1, const char *fn2, if(dinode) ext2_inode_put(dinode); + free(cp); return -EINVAL; } @@ -754,6 +755,7 @@ static int int_rename(fs_ext2_fs_t *fs, const char *fn1, const char *fn2, if(dinode) ext2_inode_put(dinode); + free(cp); return -EINVAL; } @@ -771,6 +773,7 @@ static int int_rename(fs_ext2_fs_t *fs, const char *fn1, const char *fn2, if(dinode) ext2_inode_put(dinode); + free(cp); return irv; } } @@ -823,8 +826,10 @@ static int int_rename(fs_ext2_fs_t *fs, const char *fn1, const char *fn2, /* If the thing we moved was a directory, we need to fix its '..' entry and update the reference counts of the inodes involved. */ if(!isfile) { - if((ext2_dir_redir_entry(fs->fs, finode, "..", dpinode_num, NULL))) + if((ext2_dir_redir_entry(fs->fs, finode, "..", dpinode_num, NULL))) { + free(cp); return -EIO; + } --pinode->i_links_count; ++dpinode->i_links_count; @@ -911,6 +916,7 @@ static int fs_ext2_rename(vfs_handler_t *vfs, const char *fn1, /* Find the inode of the entry we want to move. */ if(!(inode = ext2_inode_get(fs->fs, dent->inode, &irv))) { mutex_unlock(&ext2_mutex); + free(cp); errno = EIO; return -1; } diff --git a/include/assert.h b/include/assert.h index 6dda814..a1c9dff 100644 --- a/include/assert.h +++ b/include/assert.h @@ -96,6 +96,7 @@ typedef void (*assert_handler_t)(const char * file, int line, const char * expr, /** \brief Set an assertion handler to call on a failed assertion. The default assertion handler simply will print a message and call abort(). + NULL is a valid value and will cause nothing to happen on an assert. \return The old assertion handler so it may be restored later if appropriate. diff --git a/include/kos/fs_romdisk.h b/include/kos/fs_romdisk.h index fd586e2..f504045 100644 --- a/include/kos/fs_romdisk.h +++ b/include/kos/fs_romdisk.h @@ -54,7 +54,9 @@ int fs_romdisk_shutdown(void); free it if appropriate. If non-zero, img will be freed when it is unmounted \retval 0 On success - \retval -1 On error + \retval -1 If fs_romdisk_init not called + \retval -2 If img is invalid + \retval -3 If a malloc fails */ int fs_romdisk_mount(const char * mountpoint, const uint8 *img, int own_buffer); diff --git a/include/kos/net.h b/include/kos/net.h index c0c820d..f9f4f90 100644 --- a/include/kos/net.h +++ b/include/kos/net.h @@ -259,7 +259,8 @@ void net_arp_shutdown(void); \param timestamp The entry's timestamp. Set to 0 for a permanent entry, otherwise set to the current number of milliseconds since boot (i.e, timer_ms_gettime64()). - \retval 0 On success (no error conditions defined). + \retval 0 On success. + \retval -1 Error allocating memory. */ int net_arp_insert(netif_t *nif, const uint8 mac[6], const uint8 ip[4], uint64 timestamp); @@ -280,6 +281,7 @@ int net_arp_insert(netif_t *nif, const uint8 mac[6], const uint8 ip[4], \retval 0 On success. \retval -1 A query is outstanding for that address. \retval -2 Address not found, query generated. + \retval -3 Error allocating memory. */ int net_arp_lookup(netif_t *nif, const uint8 ip_in[4], uint8 mac_out[6], const ip_hdr_t *pkt, const uint8 *data, int data_size); diff --git a/include/kos/thread.h b/include/kos/thread.h index 8a5b866..0e43377 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -482,6 +482,8 @@ void thd_sleep(int ms); \param prio The priority value to assign to the thread. \retval 0 On success. + \retval -1 thd is NULL. + \retval -2 prio requested was out of range. */ int thd_set_prio(kthread_t *thd, prio_t prio); diff --git a/kernel/arch/dreamcast/fs/fs_vmu.c b/kernel/arch/dreamcast/fs/fs_vmu.c index 476eb79..decb159 100644 --- a/kernel/arch/dreamcast/fs/fs_vmu.c +++ b/kernel/arch/dreamcast/fs/fs_vmu.c @@ -128,7 +128,8 @@ static vmu_fh_t *vmu_open_vmu_dir(void) { dbglog(DBG_KDEBUG, "# of memcards found: %d\n", num); #endif - dh = malloc(sizeof(vmu_dh_t)); + if(!(dh = malloc(sizeof(vmu_dh_t)))) + return NULL; memset(dh, 0, sizeof(vmu_dh_t)); dh->strtype = VMU_DIR; dh->dirblocks = malloc(num * sizeof(vmu_dir_t)); @@ -164,7 +165,8 @@ static vmu_fh_t *vmu_open_dir(maple_device_t * dev) { return NULL; /* Allocate a handle for the dir blocks */ - dh = malloc(sizeof(vmu_dh_t)); + if(!(dh = malloc(sizeof(vmu_dh_t)))) + return NULL; dh->strtype = VMU_DIR; dh->dirblocks = dirents; dh->rootdir = 0; @@ -183,7 +185,8 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) int datasize; /* Malloc a new fh struct */ - fd = malloc(sizeof(vmu_fh_t)); + if(!(fd = malloc(sizeof(vmu_fh_t)))) + return NULL; /* Fill in the filehandle struct */ fd->strtype = VMU_FILE; @@ -203,10 +206,8 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) if(rv < 0) { if(realmode == O_RDWR || realmode == O_WRONLY) { - /* In some modes failure is ok -- just setup a blank first block. */ - data = malloc(512); - datasize = 512; - memset(data, 0, 512); + /* In some modes failure is ok -- flag to setup a blank first block. */ + datasize = -1; } else { free(fd); @@ -215,8 +216,17 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) } } else { - /* We're writing with truncate... just setup a blank first block. */ + /* We're writing with truncate... flag to setup a blank first block. */ + datasize = -1; + } + + /* We were flagged to set up a blank first block */ + if(datasize == -1) { data = malloc(512); + if(data == NULL) { + free(fd); + return NULL; + } datasize = 512; memset(data, 0, 512); } @@ -226,6 +236,7 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) if(fd->filesize == 0) { dbglog(DBG_WARNING, "VMUFS: can't open zero-length file %s\n", path); + free(fd->data); free(fd); return NULL; } diff --git a/kernel/arch/dreamcast/fs/vmufs.c b/kernel/arch/dreamcast/fs/vmufs.c index 3264b29..bafaafe 100644 --- a/kernel/arch/dreamcast/fs/vmufs.c +++ b/kernel/arch/dreamcast/fs/vmufs.c @@ -543,12 +543,18 @@ static int vmufs_setup(maple_device_t * dev, vmu_root_t * root, vmu_dir_t ** dir if(!*fat) { dbglog(DBG_ERROR, "vmufs_setup: can't alloc %d bytes for FAT on device %c%c\n", *fatsize, dev->port + 'A', dev->unit + '0'); + if(dir) + free(*dir); goto dead; } /* Read it */ - if(vmufs_fat_read(dev, root, *fat) < 0) + if(vmufs_fat_read(dev, root, *fat) < 0) { + free(*fat); + if(dir) + free(*dir); goto dead; + } } /* Ok, everything's cool */ diff --git a/kernel/arch/dreamcast/include/arch/mmu.h b/kernel/arch/dreamcast/include/arch/mmu.h index 8dac0bc..5cbd26c 100644 --- a/kernel/arch/dreamcast/include/arch/mmu.h +++ b/kernel/arch/dreamcast/include/arch/mmu.h @@ -201,7 +201,7 @@ void mmu_use_table(mmucontext_t *context); own, that means you will only ever have one of these, if any. \param asid The address space ID of this process. - \return The newly created context. + \return The newly created context or NULL on fail. */ mmucontext_t *mmu_context_create(int asid); @@ -271,7 +271,7 @@ void mmu_page_map(mmucontext_t *context, int virtpage, int physpage, \param srcaddr Source, in the mapped memory space. \param srccnt The number of bytes to copy. \param buffer The kernel buffer to copy into (should be in P1). - \return The number of bytes copied. + \return The number of bytes copied (failure causes arch_panic). */ int mmu_copyin(mmucontext_t *context, uint32 srcaddr, uint32 srccnt, void *buffer); @@ -285,6 +285,7 @@ int mmu_copyin(mmucontext_t *context, uint32 srcaddr, uint32 srccnt, \param context2 The destination's context. \param iov2 The scatter/gather array to copy to. \param iovcnt2 The number of entries in iov2. + \return The number of bytes copied (failure causes arch_panic). */ int mmu_copyv(mmucontext_t *context1, struct iovec *iov1, int iovcnt1, mmucontext_t *context2, struct iovec *iov2, int iovcnt2); diff --git a/kernel/arch/dreamcast/kernel/mmu.c b/kernel/arch/dreamcast/kernel/mmu.c index ece0503..81506de 100644 --- a/kernel/arch/dreamcast/kernel/mmu.c +++ b/kernel/arch/dreamcast/kernel/mmu.c @@ -138,6 +138,10 @@ mmucontext_t *mmu_context_create(int asid) { int i; cont = (mmucontext_t*)malloc(sizeof(mmucontext_t)); + + if(cont == NULL) + return NULL; + cont->asid = asid; for(i = 0; i < MMU_PAGES; i++) diff --git a/kernel/arch/dreamcast/sound/snd_sfxmgr.c b/kernel/arch/dreamcast/sound/snd_sfxmgr.c index ec7468b..9d0fade 100644 --- a/kernel/arch/dreamcast/sound/snd_sfxmgr.c +++ b/kernel/arch/dreamcast/sound/snd_sfxmgr.c @@ -143,6 +143,12 @@ sfxhnd_t snd_sfx_load(const char *fn) { if(!tmp) { tmp = malloc(len); + + if(tmp == NULL) { + fs_close(fd); + return SFXHND_INVALID; + } + fs_read(fd, tmp, len); ownmem = 1; } @@ -153,6 +159,14 @@ sfxhnd_t snd_sfx_load(const char *fn) { fs_close(fd); t = malloc(sizeof(snd_effect_t)); + + if(t == NULL) { + if(ownmem) + free(tmp); + + return SFXHND_INVALID; + } + memset(t, 0, sizeof(snd_effect_t)); /* Common characteristics not impacted by stream type */ @@ -185,6 +199,14 @@ sfxhnd_t snd_sfx_load(const char *fn) { sepbuf = malloc(len / 2); + if(sepbuf == NULL) { + free(t); + if(ownmem) + free(tmp); + + return SFXHND_INVALID; + } + for(i = 0; i < len / 2; i += 2) { sepbuf[i / 2] = tmp[i + 1]; } diff --git a/kernel/fs/fs.c b/kernel/fs/fs.c index cecff7a..e027af1 100644 --- a/kernel/fs/fs.c +++ b/kernel/fs/fs.c @@ -57,13 +57,7 @@ extern char *realpath(const char *, char[PATH_MAX]); /* Internal file commands for root dir reading */ static fs_hnd_t * fs_root_opendir(void) { - fs_hnd_t *hnd; - - hnd = malloc(sizeof(fs_hnd_t)); - hnd->handler = NULL; - hnd->hnd = 0; - hnd->refcnt = 0; - return hnd; + return calloc(1, sizeof(fs_hnd_t)); } /* Not thread-safe right now */ diff --git a/kernel/fs/fs_pty.c b/kernel/fs/fs_pty.c index 462753a..b521df8 100644 --- a/kernel/fs/fs_pty.c +++ b/kernel/fs/fs_pty.c @@ -185,7 +185,7 @@ int fs_pty_create(char * buffer, int maxbuflen, file_t * master_out, file_t * sl } /* Autoclean totally unreferenced PTYs (zero refcnt). */ -/* XXX This is a kinda nasty piece of code... two goto's!! */ +/* XXX This is a kinda nasty piece of code... goto!! */ static void pty_destroy_unused(void) { ptyhalf_t * c, * n; int old; @@ -206,40 +206,35 @@ again: n = LIST_NEXT(c, list); /* Don't mess with the kernel console or locked items */ - if(c->id == 0 || mutex_is_locked(&c->mutex)) - goto next; + if((c->id != 0) && (!mutex_is_locked(&c->mutex))) { - /* Not in use? */ - if(c->refcnt <= 0) { - /* Check to see if the other end is also free */ - if(c->other->refcnt > 0) - goto next; + /* Make sure neither is in use */ + if((c->refcnt <= 0) && (c->other->refcnt <= 0)) { - /* Free all our structs */ - cond_destroy(&c->ready_read); - cond_destroy(&c->ready_write); - mutex_destroy(&c->mutex); + /* Free all our structs */ + cond_destroy(&c->ready_read); + cond_destroy(&c->ready_write); + mutex_destroy(&c->mutex); - /* Remove us from the list */ - LIST_REMOVE(c, list); + /* Remove us from the list */ + LIST_REMOVE(c, list); - /* Now to deal with our partner... */ - cond_destroy(&c->other->ready_read); - cond_destroy(&c->other->ready_write); - mutex_destroy(&c->other->mutex); + /* Now to deal with our partner... */ + cond_destroy(&c->other->ready_read); + cond_destroy(&c->other->ready_write); + mutex_destroy(&c->other->mutex); - /* Remove it from the list */ - LIST_REMOVE(c->other, list); + /* Remove it from the list */ + LIST_REMOVE(c->other, list); - /* Free the structs */ - free(c->other); - free(c); + /* Free the structs */ + free(c->other); + free(c); - /* Need to restart */ - goto again; + /* Need to restart */ + goto again; + } } - - next: c = n; } @@ -298,6 +293,14 @@ static void * pty_open_dir(const char * fn, int mode) { /* Now return that as our handle item */ fdobj = malloc(sizeof(pipefd_t)); + + if(fdobj == NULL) { + free(dl->items); + free(dl); + errno = ENOMEM; + goto done; /* return */ + } + memset(fdobj, 0, sizeof(pipefd_t)); fdobj->d.d = dl; fdobj->type = PF_DIR; @@ -358,13 +361,19 @@ static void * pty_open_file(const char * fn, int mode) { ph = ph->other; } + fdobj = malloc(sizeof(pipefd_t)); + + if(fdobj == NULL) { + errno = ENOMEM; + return NULL; + } + memset(fdobj, 0, sizeof(pipefd_t)); + /* Now add a refcnt and return it */ mutex_lock(&ph->mutex); ph->refcnt++; mutex_unlock(&ph->mutex); - fdobj = malloc(sizeof(pipefd_t)); - memset(fdobj, 0, sizeof(pipefd_t)); fdobj->d.p = ph; fdobj->type = PF_PTY; fdobj->mode = mode; diff --git a/kernel/fs/fs_ramdisk.c b/kernel/fs/fs_ramdisk.c index e135a15..f23a3ef 100644 --- a/kernel/fs/fs_ramdisk.c +++ b/kernel/fs/fs_ramdisk.c @@ -148,7 +148,7 @@ static rd_file_t * ramdisk_find_path(rd_dir_t * parent, const char * fn, int dir if(fn[0] != 0) { f = ramdisk_find(parent, fn, strlen(fn)); - if((!dir && f->type == STAT_TYPE_DIR) || (dir && f->type != STAT_TYPE_DIR)) + if((f == NULL) || (!dir && f->type == STAT_TYPE_DIR) || (dir && f->type != STAT_TYPE_DIR)) return NULL; } else { @@ -203,8 +203,15 @@ static rd_file_t * ramdisk_create_file(rd_dir_t * parent, const char * fn, int d return NULL; /* Now add a file to the parent */ - f = (rd_file_t *)malloc(sizeof(rd_file_t)); + if(!(f = (rd_file_t *)malloc(sizeof(rd_file_t)))) + return NULL; + f->name = strdup(p); + if(f->name == NULL) { + free(f); + return NULL; + } + f->size = 0; f->type = dir ? STAT_TYPE_DIR : STAT_TYPE_FILE; f->openfor = OPENFOR_NOTHING; @@ -219,6 +226,12 @@ static rd_file_t * ramdisk_create_file(rd_dir_t * parent, const char * fn, int d f->datasize = 0; } + if(f->data == NULL) { + free(f->name); + free(f); + return NULL; + } + LIST_INSERT_HEAD(pdir, f, dirlist); return f; @@ -834,10 +847,22 @@ int fs_ramdisk_detach(const char * fn, void ** obj, size_t * size) { /* Initialize the file system */ int fs_ramdisk_init(void) { /* Create an empty root dir */ - rootdir = (rd_dir_t *)malloc(sizeof(rd_dir_t)); - LIST_INIT(rootdir); + if(!(rootdir = (rd_dir_t *)malloc(sizeof(rd_dir_t)))) + return -1; + root = (rd_file_t *)malloc(sizeof(rd_file_t)); + if(root == NULL) { + free(rootdir); + return -1; + } + root->name = strdup("/"); + if(root->name == NULL) { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-03 02:06:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b0be55caed3a7b965920824fb156f7cb21323588 (commit) from 25d98d1de6e46420c366ccbc0660ad029778f34a (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 b0be55caed3a7b965920824fb156f7cb21323588 Author: Donald Haase <qu...@ya...> Date: Fri Jun 2 22:06:10 2023 -0400 Add Rumble Example (#227) * Add rumble example, dedupe driver * Rearrange and add comments * Since we're already checking controllers, don't bother using the callback * Add recent example updates * Correct conflict * Update doc/CHANGELOG ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 3 + examples/dreamcast/Makefile | 2 +- examples/dreamcast/rumble/Makefile | 29 +++ .../{parallax/font => rumble}/romdisk/axaxax.txf | Bin examples/dreamcast/rumble/rumble.c | 198 +++++++++++++++++++++ kernel/arch/dreamcast/hardware/maple/purupuru.c | 34 +--- 6 files changed, 234 insertions(+), 32 deletions(-) create mode 100644 examples/dreamcast/rumble/Makefile copy examples/dreamcast/{parallax/font => rumble}/romdisk/axaxax.txf (100%) create mode 100644 examples/dreamcast/rumble/rumble.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index de7839d..6c7f1e3 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -174,6 +174,9 @@ KallistiOS version 2.1.0 ----------------------------------------------- runtime aspects of the language [Andrew Apperley == AA] - DC Improve fipr() and fipr_magnitude_sqr() functions [PC] - DC Add optimized bit-reverse function && vmu_draw_lcd_rotated() [PC] +- DC Update bfont example for Dreamcast-specific characters [DH] +- DC Add example for VMU speaker use [DH && FG] +- DC Add example for rumble accessory use [DH] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile index bd83770..68e59e4 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 random + lua parallax modem dreameye sd g1ata lightgun keyboard sdl random rumble ifdef KOS_CCPLUS DIRS += cpp tsunami endif diff --git a/examples/dreamcast/rumble/Makefile b/examples/dreamcast/rumble/Makefile new file mode 100644 index 0000000..a1c79df --- /dev/null +++ b/examples/dreamcast/rumble/Makefile @@ -0,0 +1,29 @@ +# +# Rumble Test Redux +# Copyright (C) 2023 Donald Haase + +# + +KOS_ROMDISK_DIR = romdisk +TARGET = rumble.elf +OBJS = rumble.o romdisk.o + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: rm-elf + rm -f $(OBJS) + +rm-elf: + rm -f $(TARGET) romdisk.* + +$(TARGET): $(OBJS) + kos-cc -o $(TARGET) $(OBJS) -lparallax -lz -lm + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: $(TARGET) + rm -f $(OBJS) romdisk.img + $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/parallax/font/romdisk/axaxax.txf b/examples/dreamcast/rumble/romdisk/axaxax.txf similarity index 100% copy from examples/dreamcast/parallax/font/romdisk/axaxax.txf copy to examples/dreamcast/rumble/romdisk/axaxax.txf diff --git a/examples/dreamcast/rumble/rumble.c b/examples/dreamcast/rumble/rumble.c new file mode 100644 index 0000000..100891a --- /dev/null +++ b/examples/dreamcast/rumble/rumble.c @@ -0,0 +1,198 @@ +/* KallistiOS ##version## + + rumble.c + Copyright (C) 2004 SinisterTengu + Copyright (C) 2008, 2023 Donald Haase + +*/ + +/* + This example allows you to send raw commands to the rumble accessory (aka purupuru). + + This is a recreation of an original posted by SinisterTengu in 2004 here: + https://dcemulation.org/phpBB/viewtopic.php?p=490067#p490067 . Unfortunately, + that one is lost, but I had based my vmu_beep testing on it, and the principle is + the same. In each, a single 32-bit value is sent to the device which defines the + features of the rumbling. + + TODO: This should be updated at some point to display and work from the macros in + dc/maple/purupuru.h that define the characteristics of the raw 32-bit value. + + */ + +#include <stdio.h> +#include <stdint.h> + +#include <dc/maple.h> +#include <dc/maple/controller.h> +#include <dc/maple/purupuru.h> +#include <plx/font.h> + +extern uint8_t romdisk[]; +KOS_INIT_FLAGS(INIT_DEFAULT); +KOS_INIT_ROMDISK(romdisk); + +plx_fcxt_t *cxt; + +/* This blocks waiting for a specified device to be present and valid */ +void wait_for_dev_attach(maple_device_t **dev_ptr, unsigned int func) { + maple_device_t *dev = *dev_ptr; + point_t w = {40.0f, 200.0f, 10.0f, 0.0f}; + + /* If we already have it, and it's still valid, leave */ + /* dev->valid is set to 0 by the driver if the device + is detatched, but dev will stay not-null */ + if((dev != NULL) && (dev->valid != 0)) return; + + /* Draw up a screen */ + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(PVR_LIST_OP_POLY); + pvr_list_begin(PVR_LIST_TR_POLY); + + plx_fcxt_begin(cxt); + plx_fcxt_setpos_pnt(cxt, &w); + if(func == MAPLE_FUNC_CONTROLLER) + plx_fcxt_draw(cxt, "Please attach a controller!"); + else if(func == MAPLE_FUNC_PURUPURU) + plx_fcxt_draw(cxt, "Please attach a rumbler!"); + plx_fcxt_end(cxt); + + pvr_scene_finish(); + + /* Repeatedly check until we find one and it's valid */ + while((dev == NULL) || (dev->valid == 0)) { + *dev_ptr = maple_enum_type(0, func); + dev = *dev_ptr; + usleep(50); + } +} + +int main(int argc, char *argv[]) { + + cont_state_t *state; + maple_device_t *contdev = NULL, *purudev = NULL; + + plx_font_t *fnt; + point_t w; + int i = 0, count = 0; + uint16_t old_buttons = 0, rel_buttons = 0; + uint32_t effect = 0; + uint8_t n[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; //nibbles + char s[8][2] = { "", "", "", "", "", "", "", "" }; + + pvr_init_defaults(); + + fnt = plx_font_load("/rd/axaxax.txf"); + cxt = plx_fcxt_create(fnt, PVR_LIST_TR_POLY); + + pvr_set_bg_color(0.0f, 0.0f, 0.0f); + + /* Loop until Start is pressed */ + while(!(rel_buttons & CONT_START)) { + + /* Before drawing the screen, trap into these functions to be + sure that there's at least one controller and one rumbler */ + wait_for_dev_attach(&contdev, MAPLE_FUNC_CONTROLLER); + wait_for_dev_attach(&purudev, MAPLE_FUNC_PURUPURU); + + /* Start drawing and draw the header */ + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(PVR_LIST_OP_POLY); + pvr_list_begin(PVR_LIST_TR_POLY); + plx_fcxt_begin(cxt); + + w.x = 70.0f; w.y = 70.0f; w.z = 10.0f; + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Rumble Test by Quzar"); + + /* Start drawing the changable section of the screen */ + w.x += 130; w.y += 120.0f; + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_setsize(cxt, 30.0f); + plx_fcxt_draw(cxt, "0x"); + + w.x += 48.0f; + plx_fcxt_setpos_pnt(cxt, &w); + + for(count = 0; count <= 7; count++, w.x += 25.0f) { + if(i == count) + plx_fcxt_setcolor4f(cxt, 1.0f, 0.9f, 0.9f, 0.0f); + else + plx_fcxt_setcolor4f(cxt, 1.0f, 1.0f, 1.0f, 1.0f); + + sprintf(s[count], "%x", n[count]); + + plx_fcxt_draw(cxt, s[count]); + } + + /* Store current button states + buttons which have been released. */ + state = (cont_state_t *)maple_dev_status(contdev); + rel_buttons = (old_buttons ^ state->buttons); + + if((state->buttons & CONT_DPAD_LEFT) && (rel_buttons & CONT_DPAD_LEFT)) { + if(i > 0) i--; + } + + if((state->buttons & CONT_DPAD_RIGHT) && (rel_buttons & CONT_DPAD_RIGHT)) { + if(i < 7) i++; + } + + if((state->buttons & CONT_DPAD_UP) && (rel_buttons & CONT_DPAD_UP)) { + if(n[i] < 15) n[i]++; + } + + if((state->buttons & CONT_DPAD_DOWN) && (rel_buttons & CONT_DPAD_DOWN)) { + if(n[i] > 0) n[i]--; + } + + if((state->buttons & CONT_A) && (rel_buttons & CONT_A)) { + effect = (n[0] << 28) + (n[1] << 24) + (n[2] << 20) + (n[3] << 16) + + (n[4] << 12) + (n[5] << 8) + (n[6] << 4) + (n[7] << 0); + + purupuru_rumble_raw(purudev, effect); + /* We print these out to make it easier to track the options chosen */ + printf("Rumble: 0x%lx!\n", effect); + } + + if((state->buttons & CONT_B) && (rel_buttons & CONT_B)) { + purupuru_rumble_raw(purudev, 0x00000000); + printf("Rumble Stopped!\n"); + } + + old_buttons = state->buttons ; + + /* Draw the bottom half of the screen and finish it up. */ + plx_fcxt_setsize(cxt, 24.0f); + plx_fcxt_setcolor4f(cxt, 1.0f, 1.0f, 1.0f, 1.0f); + w.x = 65.0f; w.y += 50.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press left/right to switch digits."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press up/down to change values."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press A to start rumblin."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press B to stop rumblin."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press Start to quit."); + + plx_fcxt_end(cxt); + pvr_scene_finish(); + } + + /* Stop rumbling before exiting, if it still exists. */ + if((purudev != NULL) && (purudev->valid != 0)) + purupuru_rumble_raw(purudev, 0x00000000); + return 0; +} diff --git a/kernel/arch/dreamcast/hardware/maple/purupuru.c b/kernel/arch/dreamcast/hardware/maple/purupuru.c index 4725fb9..c168754 100644 --- a/kernel/arch/dreamcast/hardware/maple/purupuru.c +++ b/kernel/arch/dreamcast/hardware/maple/purupuru.c @@ -45,11 +45,11 @@ int purupuru_rumble_raw(maple_device_t *dev, uint32 effect) { maple_queue_frame(&dev->frame); /* Wait for the purupuru to accept it */ - if(genwait_wait(&dev->frame, "purupuru_rumble_raw", 500, NULL) < 0) { + if(genwait_wait(&dev->frame, "purupuru_rumble", 500, NULL) < 0) { if(dev->frame.state != MAPLE_FRAME_VACANT) { /* Something went wrong.... */ dev->frame.state = MAPLE_FRAME_VACANT; - dbglog(DBG_ERROR, "purupuru_rumble_raw: timeout to unit %c%c\n", + dbglog(DBG_ERROR, "purupuru_rumble: timeout to unit %c%c\n", dev->port + 'A', dev->unit + '0'); return MAPLE_ETIMEOUT; } @@ -68,35 +68,7 @@ int purupuru_rumble(maple_device_t *dev, purupuru_effect_t *effect) { comp_effect = (effect->duration << 24) | (effect->effect2 << 16) | (effect->effect1 << 8) | (effect->special); - /* Lock the frame */ - if(maple_frame_lock(&dev->frame) < 0) - return MAPLE_EAGAIN; - - /* Reset the frame */ - maple_frame_init(&dev->frame); - send_buf = (uint32 *)dev->frame.recv_buf; - send_buf[0] = MAPLE_FUNC_PURUPURU; - send_buf[1] = comp_effect; - dev->frame.cmd = MAPLE_COMMAND_SETCOND; - dev->frame.dst_port = dev->port; - dev->frame.dst_unit = dev->unit; - dev->frame.length = 2; - dev->frame.callback = purupuru_rumble_cb; - dev->frame.send_buf = send_buf; - maple_queue_frame(&dev->frame); - - /* Wait for the purupuru to accept it */ - if(genwait_wait(&dev->frame, "purupuru_rumble", 500, NULL) < 0) { - if(dev->frame.state != MAPLE_FRAME_VACANT) { - /* Something went wrong.... */ - dev->frame.state = MAPLE_FRAME_VACANT; - dbglog(DBG_ERROR, "purupuru_rumble: timeout to unit %c%c\n", - dev->port + 'A', dev->unit + '0'); - return MAPLE_ETIMEOUT; - } - } - - return MAPLE_EOK; + return purupuru_rumble_raw(dev, comp_effect); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-03 01:41:17
|
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 25d98d1de6e46420c366ccbc0660ad029778f34a (commit) via f6c9e57e2b59d8355dd96b0e5ad59368afefb1c2 (commit) from 9dc411b35a2c5f42bdeb227be98efe1a2b622dcb (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 25d98d1de6e46420c366ccbc0660ad029778f34a Merge: 9dc411b f6c9e57 Author: Lawrence Sebald <ljs...@us...> Date: Fri Jun 2 21:35:38 2023 -0400 Merge pull request #231 from KallistiOS/Draw_Button Add DC-specific character drawing to bfont demo commit f6c9e57e2b59d8355dd96b0e5ad59368afefb1c2 Author: Quzar <qu...@co...> Date: Fri Jun 2 11:47:27 2023 -0400 Add drawing Dreamcast-specific characters to demo. Minor cleanups. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/video/bfont/bfont.c | 50 +++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/examples/dreamcast/video/bfont/bfont.c b/examples/dreamcast/video/bfont/bfont.c index 9679459..effea99 100644 --- a/examples/dreamcast/video/bfont/bfont.c +++ b/examples/dreamcast/video/bfont/bfont.c @@ -1,6 +1,12 @@ /* Very simple test for bfont (and its various encodings) */ -#include <kos.h> +#include <dc/biosfont.h> +#include <dc/video.h> +#include <dc/maple/controller.h> + +#include <arch/arch.h> + +#include <unistd.h> int main(int argc, char **argv) { int x, y, o; @@ -13,35 +19,53 @@ int main(int argc, char **argv) { | ((c >> 3) << 0); } - o = 20 * 640 + 20; + /* Set our starting offset to one letter height away from the + top of the screen and two widths from the left */ + o = (640 * BFONT_HEIGHT) + (BFONT_THIN_WIDTH * 2); /* Test with ISO8859-1 encoding */ bfont_set_encoding(BFONT_CODE_ISO8859_1); - bfont_draw_str(vram_s + o, 640, 1, "Test of basic ASCII"); - o += 640 * 24; + bfont_draw_str(vram_s + o, 640, 1, "Test of basic ASCII"); + /* After each string, we'll increment the offset down by one row */ + o += 640 * BFONT_HEIGHT; bfont_draw_str(vram_s + o, 640, 1, "Parlez-vous fran�ais?"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; + + /* Do a second set drawn transparently */ bfont_draw_str(vram_s + o, 640, 0, "Test of basic ASCII"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; bfont_draw_str(vram_s + o, 640, 0, "Parlez-vous fran�ais?"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; /* Test with EUC encoding */ bfont_set_encoding(BFONT_CODE_EUC); bfont_draw_str(vram_s + o, 640, 1, "�����ˤ�� EUC!"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; bfont_draw_str(vram_s + o, 640, 0, "�����ˤ�� EUC!"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; /* Test with Shift-JIS encoding */ bfont_set_encoding(BFONT_CODE_SJIS); bfont_draw_str(vram_s + o, 640, 1, "�A�h���X�Ï� SJIS"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; bfont_draw_str(vram_s + o, 640, 0, "�A�h���X�Ï� SJIS"); - o += 640 * 24; + o += 640 * BFONT_HEIGHT; + + /* Drawing the special symbols is a bit convoluted. First we'll draw some + standard text as above. */ + bfont_set_encoding(BFONT_CODE_ISO8859_1); + bfont_draw_str(vram_s + o, 640, 1, "To exit, press "); + + /* Then we set the mode to raw to draw the special character. */ + bfont_set_encoding(BFONT_CODE_RAW); + /* Adjust the writing to start after "To exit, press " and draw the one char */ + bfont_draw_wide(vram_s + o + (BFONT_THIN_WIDTH * 15), 640, 1, BFONT_STARTBUTTON); + + /* If Start is pressed, exit the app */ + cont_btn_callback(0, CONT_START, (cont_btn_callback_t)arch_exit); - /* Pause to see the results */ - usleep(5 * 1000 * 1000); + /* Just trap here waiting for the button press */ + for(;;) { usleep(50); } return 0; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-01 23:40:40
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 9dc411b35a2c5f42bdeb227be98efe1a2b622dcb (commit) from 3e9f13a6c8a50fb95c5173c18141256bf4c53573 (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 9dc411b35a2c5f42bdeb227be98efe1a2b622dcb Author: Andress Barajas <and...@gm...> Date: Thu Jun 1 16:39:59 2023 -0700 Fix some warnings (#225) Fix warnings that were uncovered when removing -fno-builtin from the compile flags. ----------------------------------------------------------------------- Summary of changes: addons/libkosext2fs/fs_ext2.c | 3 +- addons/libkosutils/netcfg.c | 53 +++++++++-------- kernel/arch/dreamcast/fs/vmufs.c | 11 +++- kernel/arch/dreamcast/hardware/flashrom.c | 98 +++++++++++++++---------------- kernel/exports.txt | 1 + kernel/fs/fs_utils.c | 18 ++++-- kernel/libc/koslib/readdir.c | 2 +- utils/genexports/genexportstubs.sh | 1 + 8 files changed, 104 insertions(+), 83 deletions(-) diff --git a/addons/libkosext2fs/fs_ext2.c b/addons/libkosext2fs/fs_ext2.c index 478ab00..fe68e28 100644 --- a/addons/libkosext2fs/fs_ext2.c +++ b/addons/libkosext2fs/fs_ext2.c @@ -1583,7 +1583,8 @@ static int fs_ext2_symlink(vfs_handler_t *vfs, const char *path1, /* Will the link fit in the inode? */ if(len < 60) { /* We can make a fast symlink. */ - strncpy((char *)inode->i_block, path1, 60); + strncpy((char *)inode->i_block, path1, 59); + ((char *)inode->i_block)[59] = '\0'; inode->i_size = (uint32_t)len; } else { diff --git a/addons/libkosutils/netcfg.c b/addons/libkosutils/netcfg.c index b5ccc99..6ed801e 100644 --- a/addons/libkosutils/netcfg.c +++ b/addons/libkosutils/netcfg.c @@ -30,10 +30,13 @@ void netcfg_vmuify(const char *filename_in, const char *filename_out) { dbgp("Opening source file\n"); fd = fs_open(filename_in, O_RDONLY); buf = (uint8 *) malloc(fs_total(fd)); + if(buf == NULL) + return; + fs_read(fd, buf, fs_total(fd)); dbgp("Read %i bytes\n", fs_total(fd)); - strcpy(pkg.desc_short, "KallistiOS 1.3"); + strcpy(pkg.desc_short, "KallistiOS 2.1.0"); strcpy(pkg.desc_long, "KOS Network Settings"); strcpy(pkg.app_id, "KOS"); pkg.icon_cnt = 1; @@ -71,17 +74,17 @@ int netcfg_load_from(const char * fn, netcfg_t * out) { assert(out); - // Open the file + /* Open the file */ f = fopen(fn, "rb"); if(!f) return -1; - // If we're reading from a VMU, seek past the header - // In the future, we could read this and use data_len to - // know how big the file really is + /* If we're reading from a VMU, seek past the header + In the future, we could read this and use data_len to + know how big the file really is */ if(fn[0] == '/' && fn[1] == 'v' && fn[2] == 'm' && fn[3] == 'u') { - // Make sure there's a VMU header to skip. If so, skip it. + /* Make sure there's a VMU header to skip. If so, skip it. */ fread(buf, 4, 1, f); buf[4] = 0; @@ -89,13 +92,13 @@ int netcfg_load_from(const char * fn, netcfg_t * out) { fseek(f, 128 + 512, SEEK_SET); } - // Read each line... + /* Read each line... */ while(fgets(buf, 64, f)) { - // Skip comments and blank lines + /* Skip comments and blank lines */ if(buf[0] == 0 || buf[0] == '#') continue; - // Strip newlines + /* Strip newlines */ l = strlen(buf); if(buf[l - 1] == '\n') { @@ -108,7 +111,7 @@ int netcfg_load_from(const char * fn, netcfg_t * out) { l--; } - // Look for an equals + /* Look for an equals */ b = strchr(buf, '='); if(!b) @@ -117,7 +120,7 @@ int netcfg_load_from(const char * fn, netcfg_t * out) { *b = 0; b++; - // What was the line type? + /* What was the line type? */ if(!strcmp(buf, "driver")) { strcpy(out->driver, b); } @@ -190,7 +193,7 @@ int netcfg_load_flash(netcfg_t * out) { if(flashrom_get_ispcfg(&cfg) < 0) return -1; - // Start out with a clean config + /* Start out with a clean config */ memset(out, 0, sizeof(netcfg_t)); #define READIP(dst, src) \ @@ -256,7 +259,7 @@ int netcfg_load(netcfg_t * out) { dirent_t * d; char buf[64]; - // Scan for VMUs + /* Scan for VMUs */ f = fs_open("/vmu", O_RDONLY | O_DIR); if(f >= 0) { @@ -268,7 +271,8 @@ int netcfg_load(netcfg_t * out) { break; } - sprintf(buf, "/vmu/%s/net.cfg", d->name); + /* Valid names are a1, a2, b1, etc */ + sprintf(buf, "/vmu/%.*s/net.cfg", 2, d->name); if(netcfg_load_from(buf, out) >= 0) { out->src = NETCFG_SRC_VMU; @@ -278,20 +282,19 @@ int netcfg_load(netcfg_t * out) { } } - // Couldn't find anything. Try reading the config - // from flash. + /* Couldn't find anything. Try reading the config from flash */ if(netcfg_load_flash(out) >= 0) { out->src = NETCFG_SRC_FLASH; return 0; } - // Didn't work out->. try the current dir. + /* Didn't work out->. try the current dir. */ if(netcfg_load_from("net.cfg", out) >= 0) { out->src = NETCFG_SRC_CWD; return 0; } - // Finally, try the CD + /* Finally, try the CD */ if(netcfg_load_from("/cd/net.cfg", out) >= 0) { out->src = NETCFG_SRC_CDROOT; return 0; @@ -302,13 +305,13 @@ int netcfg_load(netcfg_t * out) { int netcfg_save_to(const char * fn, const netcfg_t * cfg) { FILE * f; - char buf[64]; + char buf[256]; assert(cfg); dbgp("Saving: %s\n", fn); - // Open the output file + /* Open the output file */ if(fn[0] == '/' && fn[1] == 'v' && fn[2] == 'm' && fn[3] == 'u') { dbgp("Saving to VMU\n"); f = fopen("/ram/netcfg.tmp", "wb"); @@ -320,7 +323,7 @@ int netcfg_save_to(const char * fn, const netcfg_t * cfg) { if(!f) return -1; - // Write out each line... + /* Write out each line... */ sprintf(buf, "# KOS Network Config written by netcfg_save_to\n"); if(fwrite(buf, strlen(buf), 1, f) != 1) @@ -365,7 +368,7 @@ int netcfg_save_to(const char * fn, const netcfg_t * cfg) { fclose(f); - //If we're saving to a VMU, tack on the header and send it out + /* If we're saving to a VMU, tack on the header and send it out */ if(fn[0] == '/' && fn[1] == 'v' && fn[2] == 'm' && fn[3] == 'u') { netcfg_vmuify("/ram/netcfg.tmp", fn); unlink("/ram/netcfg.tmp"); @@ -383,7 +386,7 @@ int netcfg_save(const netcfg_t * cfg) { dirent_t * d; char buf[64]; - // Scan for a VMU + /* Scan for a VMU */ f = fs_open("/vmu", O_RDONLY | O_DIR); if(f < 0) @@ -396,8 +399,10 @@ int netcfg_save(const netcfg_t * cfg) { return -1; } - sprintf(buf, "/vmu/%s/net.cfg", d->name); + /* Valid names are a1, a2, b1, etc */ + sprintf(buf, "/vmu/%.*s/net.cfg", 2, d->name); fs_close(f); return netcfg_save_to(buf, cfg); } + diff --git a/kernel/arch/dreamcast/fs/vmufs.c b/kernel/arch/dreamcast/fs/vmufs.c index 79127e3..3264b29 100644 --- a/kernel/arch/dreamcast/fs/vmufs.c +++ b/kernel/arch/dreamcast/fs/vmufs.c @@ -702,7 +702,7 @@ int vmufs_write(maple_device_t * dev, const char * fn, void * inbuf, int insize, vmu_root_t root; vmu_dir_t * dir = NULL, nd; uint16 * fat = NULL; - int oldinsize, fatsize, dirsize, idx, rv = 0, st; + int oldinsize, fatsize, dirsize, idx, rv = 0, st, fnlength; /* Round up the size if necessary */ oldinsize = insize; @@ -744,7 +744,14 @@ int vmufs_write(maple_device_t * dev, const char * fn, void * inbuf, int insize, nd.filetype = (flags & VMUFS_VMUGAME) ? 0xcc : 0x33; nd.copyprotect = (flags & VMUFS_NOCOPY) ? 0xff : 0x00; nd.firstblk = 0; - strncpy(nd.filename, fn, 12); + + fnlength = strlen(fn); + fnlength = fnlength > 12 ? 12 : fnlength; + memcpy(nd.filename, fn, fnlength); + if (fnlength < 12) { + memset(nd.filename + fnlength, '\0', 12 - fnlength); + } + vmufs_dir_fill_time(&nd); nd.filesize = insize / 512; nd.hdroff = (flags & VMUFS_VMUGAME) ? 1 : 0; diff --git a/kernel/arch/dreamcast/hardware/flashrom.c b/kernel/arch/dreamcast/hardware/flashrom.c index 00aef18..3acd338 100644 --- a/kernel/arch/dreamcast/hardware/flashrom.c +++ b/kernel/arch/dreamcast/hardware/flashrom.c @@ -19,6 +19,26 @@ #include <dc/flashrom.h> #include <arch/irq.h> +static void strcpy_no_term(char *dest, const char *src, size_t destsize) { + size_t srclength; + + srclength = strlen(src); + srclength = srclength > destsize ? destsize : srclength; + memcpy(dest, src, srclength); + if (srclength < destsize) { + memset(dest + srclength, '\0', destsize - srclength); + } +} + +static void strcpy_with_term(char *dest, const char *src, size_t destsize) { + size_t srclength; + + srclength = strlen(src); + srclength = srclength > destsize ? destsize : srclength; + memcpy(dest, src, srclength); + dest[srclength] = '\0'; +} + /* First, implementation of the syscall wrappers. */ typedef int (*flashrom_sc)(int, void *, int, int); @@ -69,8 +89,6 @@ int flashrom_delete(int offset) { return rv; } - - /* Higher level stuff follows */ /* Internal function calculates the checksum of a flashrom block. Thanks @@ -92,7 +110,6 @@ static int flashrom_calc_crc(uint8 * buffer) { return (~n) & 0xffff; } - int flashrom_get_block(int partid, int blockid, uint8 * buffer_out) { int start, size; int bmcnt; @@ -383,9 +400,9 @@ typedef struct { } isp_settings_t; int flashrom_get_ispcfg(flashrom_ispcfg_t * out) { - uint8 buffer[sizeof(isp_settings_t)]; - isp_settings_t * isp = (isp_settings_t *)buffer; - int found = 0; + uint8 buffer[sizeof(isp_settings_t)]; + isp_settings_t * isp = (isp_settings_t *)buffer; + int found = 0; /* Clean out the output config buffer. */ memset(out, 0, sizeof(flashrom_ispcfg_t)); @@ -497,8 +514,8 @@ int flashrom_get_ispcfg(flashrom_ispcfg_t * out) { if(!(out->valid_fields & FLASHROM_ISP_PHONE1)) { /* The full number is 27 digits in C6-C8, so we truncate it to fit the phone1 field */ - strncpy(out->phone1, isp->c6.phone1_pt1, 12); - strncpy(out->phone1 + 12, isp->c7.phone1_pt2, 25 - 12); + strcpy_no_term(out->phone1, isp->c6.phone1_pt1, 12); + strcpy_no_term(out->phone1 + 12, isp->c7.phone1_pt2, 25 - 12); out->phone1[25] = '\0'; out->valid_fields |= FLASHROM_ISP_PHONE1; } @@ -675,19 +692,17 @@ int flashrom_get_pw_ispcfg(flashrom_ispcfg_t *out) { } /* Copy out the outside dial prefix. */ - strncpy(out->out_prefix, isp->b80.out_prefix, 8); - out->out_prefix[8] = '\0'; + strcpy_with_term(out->out_prefix, isp->b80.out_prefix, 8); out->valid_fields |= FLASHROM_ISP_OUT_PREFIX; /* Copy out the call waiting prefix. */ - strncpy(out->cw_prefix, isp->b80.cw_prefix, 8); - out->cw_prefix[8] = '\0'; + strcpy_with_term(out->cw_prefix, isp->b80.cw_prefix, 8); out->valid_fields |= FLASHROM_ISP_CW_PREFIX; /* Copy the second part of the email address (if it exists). We don't set the email as valid here, since that really depends on the first part being found (PW 1.0 doesn't store anything in this place). */ - strncpy(out->email + 32, isp->b80.email_pt2, 16); + strcpy_no_term(out->email + 32, isp->b80.email_pt2, 16); } else { /* If we couldn't find the PWBrowser block, punt, the PlanetWeb settings @@ -700,11 +715,10 @@ int flashrom_get_pw_ispcfg(flashrom_ispcfg_t *out) { /* Copy the third part of the email address to the appropriate place. Note that PlanetWeb 1.0 doesn't store anything here, thus we'll just copy a null terminator. */ - strncpy(out->email + 32 + 16, isp->b81.email_pt3, 14); + strcpy_no_term(out->email + 32 + 16, isp->b81.email_pt3, 14); /* Copy out the "Real Name" field. */ - strncpy(out->real_name, isp->b81.real_name, 30); - out->real_name[30] = '\0'; + strcpy_with_term(out->real_name, isp->b81.real_name, 30); out->valid_fields |= FLASHROM_ISP_REAL_NAME; } @@ -712,25 +726,22 @@ int flashrom_get_pw_ispcfg(flashrom_ispcfg_t *out) { if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_SETTINGS_3, buffer) >= 0) { /* The only thing in this block is the modem init string, go ahead and copy it to our destination. */ - strncpy(out->modem_init, isp->b82.modem_str, 30); - out->modem_init[30] = '\0'; + strcpy_with_term(out->modem_init, isp->b82.modem_str, 30); out->valid_fields |= FLASHROM_ISP_MODEM_INIT; } /* Grab block 0x83 */ if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_SETTINGS_4, buffer) >= 0) { /* The modem init string continues at the start of this block. */ - strncpy(out->modem_init + 30, (char *)isp->b83.modem_str2, 2); + strcpy_no_term(out->modem_init + 30, (char *)isp->b83.modem_str2, 2); out->modem_init[32] = '\0'; /* Copy out the area code next. */ - strncpy(out->area_code, isp->b83.area_code, 3); - out->area_code[3] = '\0'; + strcpy_with_term(out->area_code, isp->b83.area_code, 3); out->valid_fields |= FLASHROM_ISP_AREA_CODE; /* Copy the long-distance dial prefix */ - strncpy(out->ld_prefix, isp->b83.ld_prefix, 20); - out->ld_prefix[20] = '\0'; + strcpy_with_term(out->ld_prefix, isp->b83.ld_prefix, 20); out->valid_fields |= FLASHROM_ISP_LD_PREFIX; } @@ -761,38 +772,32 @@ int flashrom_get_pw_ispcfg(flashrom_ispcfg_t *out) { } /* Grab the PPP Username. */ - strncpy(out->ppp_login, isp->c0.ppp_login, 28); - out->ppp_login[28] = '\0'; + strcpy_with_term(out->ppp_login, isp->c0.ppp_login, 28); out->valid_fields |= FLASHROM_ISP_PPP_USER; /* Grab the PPP Password. */ - strncpy(out->ppp_passwd, isp->c0.ppp_passwd, 16); - out->ppp_passwd[16] = '\0'; + strcpy_with_term(out->ppp_passwd, isp->c0.ppp_passwd, 16); out->valid_fields |= FLASHROM_ISP_PPP_PASS; /* Grab the area code for phone 1, stripping away the parenthesis. */ - strncpy(out->p1_areacode, isp->c0.ac1 + 1, 3); - out->p1_areacode[3] = '\0'; + strcpy_with_term(out->p1_areacode, isp->c0.ac1 + 1, 3); /* Grab the start of phone number 1. */ - strncpy(out->phone1, isp->c0.phone1_pt1, 3); - out->phone1[3] = '\0'; + strcpy_with_term(out->phone1, isp->c0.phone1_pt1, 3); } /* Grab block 0xC1 */ if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_PPP2, buffer) >= 0) { /* Grab the rest of phone number 1. */ - strncpy(out->phone1 + 3, isp->c1.phone1_pt2, 22); + strcpy_no_term(out->phone1 + 3, isp->c1.phone1_pt2, 22); out->phone1[25] = '\0'; out->valid_fields |= FLASHROM_ISP_PHONE1; /* Grab the area code for phone 2, stripping away the parenthesis. */ - strncpy(out->p2_areacode, isp->c1.ac2 + 1, 3); - out->p2_areacode[3] = '\0'; + strcpy_with_term(out->p2_areacode, isp->c1.ac2 + 1, 3); /* Grab the start of phone number 2. */ - strncpy(out->phone2, isp->c1.phone2_pt1, 23); - out->phone2[23] = '\0'; + strcpy_with_term(out->phone2, isp->c1.phone2_pt1, 23); } /* Grab block 0xC2 */ @@ -812,46 +817,41 @@ int flashrom_get_pw_ispcfg(flashrom_ispcfg_t *out) { /* Grab block 0xC3 */ if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_EMAIL1, buffer) >= 0) { /* Grab the beginning of the email address (or all of it in PW 1.0). */ - strncpy(out->email, isp->c3.email_p1, 32); + strcpy_no_term(out->email, isp->c3.email_p1, 32); out->valid_fields |= FLASHROM_ISP_EMAIL; /* Grab the beginning of the SMTP server. */ - strncpy(out->smtp, isp->c3.out_srv_p1, 12); - out->smtp[12] = '\0'; + strcpy_with_term(out->smtp, isp->c3.out_srv_p1, 12); } /* Grab block 0xC4 */ if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_EMAIL2, buffer) >= 0) { /* Grab the end of the SMTP server. */ - strncpy(out->smtp + 12, isp->c4.out_srv_p2, 18); + strcpy_no_term(out->smtp + 12, isp->c4.out_srv_p2, 18); out->smtp[30] = '\0'; out->valid_fields |= FLASHROM_ISP_SMTP; /* Grab the POP3 server. */ - strncpy(out->pop3, isp->c4.in_srv, 30); - out->pop3[30] = '\0'; + strcpy_with_term(out->pop3, isp->c4.in_srv, 30); out->valid_fields |= FLASHROM_ISP_POP3; /* Grab the beginning of the POP3 login. */ - strncpy(out->pop3_login, isp->c4.em_login_p1, 8); - out->pop3_login[8] = '\0'; + strcpy_with_term(out->pop3_login, isp->c4.em_login_p1, 8); } /* Grab block 0xC5 */ if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_EMAIL_PROXY, buffer) >= 0) { /* Grab the end of the POP3 login. */ - strncpy(out->pop3_login + 8, isp->c5.em_login_p2, 8); + strcpy_no_term(out->pop3_login + 8, isp->c5.em_login_p2, 8); out->pop3_login[16] = '\0'; out->valid_fields |= FLASHROM_ISP_POP3_USER; /* Grab the POP3 password. */ - strncpy(out->pop3_passwd, isp->c5.em_passwd, 16); - out->pop3_passwd[16] = '\0'; + strcpy_with_term(out->pop3_passwd, isp->c5.em_passwd, 16); out->valid_fields |= FLASHROM_ISP_POP3_PASS; /* Grab the proxy server. */ - strncpy(out->proxy_host, isp->c5.proxy_srv, 30); - out->proxy_host[30] = '\0'; + strcpy_with_term(out->proxy_host, isp->c5.proxy_srv, 30); out->valid_fields |= FLASHROM_ISP_PROXY_HOST; /* Grab the proxy port. */ diff --git a/kernel/exports.txt b/kernel/exports.txt index 2dc3a47..3052c20 100644 --- a/kernel/exports.txt +++ b/kernel/exports.txt @@ -242,5 +242,6 @@ arch_stk_trace_at timer_spin_sleep timer_ms_gettime timer_ms_gettime64 +timer_us_gettime64 timer_primary_set_callback timer_primary_wakeup diff --git a/kernel/fs/fs_utils.c b/kernel/fs/fs_utils.c index 2f5de79..9ec83de 100644 --- a/kernel/fs/fs_utils.c +++ b/kernel/fs/fs_utils.c @@ -78,6 +78,7 @@ ssize_t fs_copy(const char * src, const char * dst) { ssize_t fs_load(const char * src, void ** out_ptr) { file_t f; void * data; + void * new_data; uint8 * out; ssize_t total, left, r; @@ -94,6 +95,11 @@ ssize_t fs_load(const char * src, void ** out_ptr) { left = fs_total(f); total = 0; data = malloc(left); + if(data == NULL) { + fs_close(f); + return -1; + } + out = (uint8 *)data; /* Load the data */ ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-01 23:36:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 3e9f13a6c8a50fb95c5173c18141256bf4c53573 (commit) from e8f73e30fa8c4be3bf6c685a9b08d313d5c13a4d (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 3e9f13a6c8a50fb95c5173c18141256bf4c53573 Author: Falco Girgis <gyr...@gm...> Date: Thu Jun 1 18:35:22 2023 -0500 Made vmu_fb_present() honor connector_direction (#230) * Made vmu_fb_present() honor connector_direction - Had to compare the VMU's connector direction against its controller's connector direction and flip the image if they both face the same direction ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/util/vmu_fb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c index 977d251..353a44b 100644 --- a/kernel/arch/dreamcast/util/vmu_fb.c +++ b/kernel/arch/dreamcast/util/vmu_fb.c @@ -98,10 +98,19 @@ void vmufb_clear_area(vmufb_t *fb, } void vmufb_present(const vmufb_t *fb, maple_device_t *dev) { - if (dev->info.connector_direction == 0) /* 0: UP - rotated like most controllers */ - vmu_draw_lcd_rotated(dev, fb->data); - else /* 1: DOWN - not rotated, like lightgun */ + /* Check for controller containing VMU (should always be same port, unit 0) */ + maple_device_t *cont = maple_enum_dev(dev->port, 0); + + /* If the VMU connector and controller connector face opposite directions, + no flipping necessary (example: VMU in a lightgun). */ + if(cont && (cont->info.functions & MAPLE_FUNC_CONTROLLER) && + (cont->info.connector_direction != dev->info.connector_direction)) vmu_draw_lcd(dev, fb->data); + + /* If we somehow found no corresponding controller, or connectors face the same direction, + we rotate the image 180 degreees (example: VMU in a standard controller). */ + else + vmu_draw_lcd_rotated(dev, fb->data); } void vmufb_print_string_into(vmufb_t *fb, hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-01 20:36:59
|
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 e8f73e30fa8c4be3bf6c685a9b08d313d5c13a4d (commit) from 191d653fb75570a38130c0fa69c27dd181d45094 (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 e8f73e30fa8c4be3bf6c685a9b08d313d5c13a4d Author: Falco Girgis <gyr...@gm...> Date: Thu Jun 1 15:36:29 2023 -0500 Added VMU LCD example using virtual framebuffer (#228) * Turned zcrc's VMU LCD demo into a KOS example. - Took his example from GitHub and turned it into a KOS example - Fixed a missing include for stdint.h in vmu_fb.h ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/vmu/Makefile | 4 +- .../{g1ata/atatest => vmu/vmu_lcd}/Makefile | 56 +++--- examples/dreamcast/vmu/vmu_lcd/lcd.c | 188 +++++++++++++++++++++ kernel/arch/dreamcast/include/dc/vmu_fb.h | 1 + kernel/arch/dreamcast/util/vmu_fb.c | 1 - 5 files changed, 221 insertions(+), 29 deletions(-) copy examples/dreamcast/{g1ata/atatest => vmu/vmu_lcd}/Makefile (61%) create mode 100644 examples/dreamcast/vmu/vmu_lcd/lcd.c diff --git a/examples/dreamcast/vmu/Makefile b/examples/dreamcast/vmu/Makefile index c5ac508..52b0bd8 100644 --- a/examples/dreamcast/vmu/Makefile +++ b/examples/dreamcast/vmu/Makefile @@ -8,14 +8,16 @@ all: $(KOS_MAKE) -C vmu_pkg $(KOS_MAKE) -C vmu_game $(KOS_MAKE) -C vmu_beep + $(KOS_MAKE) -C vmu_lcd clean: $(KOS_MAKE) -C vmu_pkg clean $(KOS_MAKE) -C vmu_game clean $(KOS_MAKE) -C vmu_beep clean + $(KOS_MAKE) -C vmu_lcd clean dist: $(KOS_MAKE) -C vmu_pkg dist $(KOS_MAKE) -C vmu_game dist $(KOS_MAKE) -C vmu_beep dist - + $(KOS_MAKE) -C vmu_lcd dist diff --git a/examples/dreamcast/g1ata/atatest/Makefile b/examples/dreamcast/vmu/vmu_lcd/Makefile similarity index 61% copy from examples/dreamcast/g1ata/atatest/Makefile copy to examples/dreamcast/vmu/vmu_lcd/Makefile index 92f594f..ab659d0 100644 --- a/examples/dreamcast/g1ata/atatest/Makefile +++ b/examples/dreamcast/vmu/vmu_lcd/Makefile @@ -1,27 +1,29 @@ -# KallistiOS ##version## -# -# examples/dreamcast/g1ata/atatest/Makefile -# - -TARGET = atatest.elf -OBJS = atatest.o - -all: rm-elf $(TARGET) - -include $(KOS_BASE)/Makefile.rules - -clean: rm-elf - -rm -f $(OBJS) - -rm-elf: - -rm -f $(TARGET) - -$(TARGET): $(OBJS) - kos-cc -o $(TARGET) $(OBJS) - -run: $(TARGET) - $(KOS_LOADER) $(TARGET) - -dist: $(TARGET) - -rm -f $(OBJS) - $(KOS_STRIP) $(TARGET) +# +# VMU LCD Example +# Copyright (C) 2023 Paul Cercueil +# + +TARGET = lcd.elf +OBJS = lcd.o + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: rm-elf + -rm -f $(OBJS) + +rm-elf: + -rm -f $(TARGET) + +$(TARGET): $(OBJS) + kos-cc -o $(TARGET) $(OBJS) -lm + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: $(TARGET) + -rm -f $(OBJS) + $(KOS_STRIP) $(TARGET) + + diff --git a/examples/dreamcast/vmu/vmu_lcd/lcd.c b/examples/dreamcast/vmu/vmu_lcd/lcd.c new file mode 100644 index 0000000..1b92685 --- /dev/null +++ b/examples/dreamcast/vmu/vmu_lcd/lcd.c @@ -0,0 +1,188 @@ +/* KallistiOS ##version## + + lcd.c + Copyright (C) 2023 Paul Cercueil + +*/ + +/* + This example demonstrates drawing dynamic contents to the + VMU's LCD display. It does so by rendering to a virtual + framebuffer and then presenting it, which sends the updated + framebuffer to the VMU over the maple protocol which displays + it. + + This demo also shows off rendering dynamic text using an + embedded font. + */ + +#include <dc/maple.h> +#include <dc/maple/controller.h> +#include <dc/maple/vmu.h> +#include <dc/vmu_fb.h> + +#include <stdio.h> +#include <math.h> +#include <stdint.h> + +/* 4x6 font from the Linux kernel: + https://github.com/torvalds/linux/blob/master/lib/fonts/font_mini_4x6.c + + Modified locally to pack the data better. + + Created by Kenneth Albanowski. + No rights reserved, released to the public domain. + */ +static const char fontdata_4x6[] = { + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, + 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, + 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, + 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, + 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, + 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, + 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, + 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, + 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, + 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, + 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, + 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, + 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, + 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, + 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, + 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, + 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, + 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, + 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, + 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, + 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, + 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, + 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, + 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, + 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, + 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, + 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, + 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, + 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, + 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, + 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, + 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, + 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, + 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0x06, 0xc6, 0x00, 0x0c, 0x6c, 0x00, + 0x82, 0x82, 0x82, 0xa5, 0xa5, 0xa5, 0xdb, 0xdb, + 0xdb, 0x44, 0x44, 0x44, 0x44, 0xc4, 0x44, 0x44, + 0xcc, 0x44, 0x66, 0xe6, 0x66, 0x00, 0xe6, 0x66, + 0x00, 0xcc, 0x44, 0x66, 0xee, 0x66, 0x66, 0x66, + 0x66, 0x00, 0xee, 0x66, 0x66, 0xee, 0x00, 0x66, + 0xe0, 0x00, 0x44, 0xcc, 0x00, 0x00, 0xc4, 0x44, + 0x44, 0x70, 0x00, 0x44, 0xf0, 0x00, 0x00, 0xf4, + 0x44, 0x44, 0x74, 0x44, 0x00, 0xf0, 0x00, 0x44, + 0xf4, 0x44, 0x44, 0x77, 0x44, 0x66, 0x76, 0x66, + 0x66, 0x77, 0x00, 0x00, 0x77, 0x66, 0x66, 0xff, + 0x00, 0x00, 0xff, 0x66, 0x66, 0x77, 0x66, 0x00, + 0xff, 0x00, 0x66, 0xff, 0x66, 0x44, 0xff, 0x00, + 0x66, 0xf0, 0x00, 0x00, 0xff, 0x44, 0x00, 0xf6, + 0x66, 0x66, 0x70, 0x00, 0x44, 0x77, 0x00, 0x00, + 0x77, 0x44, 0x00, 0x76, 0x66, 0x66, 0xf6, 0x66, + 0x44, 0xff, 0x44, 0x44, 0xc0, 0x00, 0x00, 0x74, + 0x44, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xcc, + 0xcc, 0xcc, 0x33, 0x33, 0x33, 0xff, 0xf0, 0x00, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0, +}; + +static const vmufb_font_t vmufb_font4x6 = { + .w = 4, + .h = 6, + .stride = 3, + .fontdata = fontdata_4x6, +}; + +static const char smiley[] = { + 0b00111100, + 0b01000010, + 0b10100101, + 0b10000001, + 0b10100101, + 0b10011001, + 0b01000010, + 0b00111100, +}; + +static vmufb_t vmufb; +static const char message[] = " Hello World! "; + +KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS); + +/* Your program's main entry point */ +int main(int argc, char **argv) { + unsigned int x, y, i, vmu; + maple_device_t *dev; + float val; + + /* If start is pressed, exit the app. */ + cont_btn_callback(0, CONT_START, + (cont_btn_callback_t)arch_exit); + + for(i = 0; ; i++) { + vmufb_clear(&vmufb); + + val = (float)i * M_PI / 360.0f; + x = 20 + (int)(20.0f * cosf(val)); + y = 12 + (int)(12.0f * sinf(val)); + + vmufb_paint_area(&vmufb, x, y, 8, 8, smiley); + + vmufb_print_string_into(&vmufb, &vmufb_font4x6, + 12, 12, 24, 6, 0, + &message[(i / 16) % sizeof(message)]); + + + for(vmu = 0; !!(dev = maple_enum_type(vmu, MAPLE_FUNC_LCD)); vmu++) { + vmufb_present(&vmufb, dev); + } + } + + return 0; +} diff --git a/kernel/arch/dreamcast/include/dc/vmu_fb.h b/kernel/arch/dreamcast/include/dc/vmu_fb.h index d9f5a4b..ef96ba7 100644 --- a/kernel/arch/dreamcast/include/dc/vmu_fb.h +++ b/kernel/arch/dreamcast/include/dc/vmu_fb.h @@ -13,6 +13,7 @@ */ #include <dc/maple.h> +#include <stdint.h> /** \brief VMU framebuffer. diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c index 37b9f8d..977d251 100644 --- a/kernel/arch/dreamcast/util/vmu_fb.c +++ b/kernel/arch/dreamcast/util/vmu_fb.c @@ -6,7 +6,6 @@ */ #include <stdbool.h> -#include <stdint.h> #include <string.h> #include <dc/maple/vmu.h> hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-06-01 02:17:36
|
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 191d653fb75570a38130c0fa69c27dd181d45094 (commit) via 188fa4b508fc6353d659afc0ad3a5941f847e559 (commit) from 8c8b2ad3773a566d54471ac0dba6da71f803de3b (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 191d653fb75570a38130c0fa69c27dd181d45094 Merge: 8c8b2ad 188fa4b Author: Lawrence Sebald <ljs...@us...> Date: Wed May 31 22:16:21 2023 -0400 Merge pull request #226 from pcercuei/vmufb vmu: Add VMU framebuffer API commit 188fa4b508fc6353d659afc0ad3a5941f847e559 Author: Paul Cercueil <pa...@cr...> Date: Mon May 29 19:51:19 2023 +0200 vmu: Add VMU framebuffer API This API can be used to render and present dynamic images to the VMUs connected to the system. It also supports rendering text using a user-provided font. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/vmu_fb.h | 132 +++++++++++++++++++++++++++ kernel/arch/dreamcast/util/Makefile | 2 +- kernel/arch/dreamcast/util/vmu_fb.c | 142 ++++++++++++++++++++++++++++++ 3 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 kernel/arch/dreamcast/include/dc/vmu_fb.h create mode 100644 kernel/arch/dreamcast/util/vmu_fb.c diff --git a/kernel/arch/dreamcast/include/dc/vmu_fb.h b/kernel/arch/dreamcast/include/dc/vmu_fb.h new file mode 100644 index 0000000..d9f5a4b --- /dev/null +++ b/kernel/arch/dreamcast/include/dc/vmu_fb.h @@ -0,0 +1,132 @@ +/* KallistiOS ##version## + + dc/vmu_fb.h + Copyright (C) 2023 Paul Cercueil + +*/ + +/** \file dc/vmu_fb.h + \brief VMU framebuffer. + + This file provides an API that can be used to compose a 48x32 image that can + then be displayed on the VMUs connected to the system. +*/ + +#include <dc/maple.h> + +/** \brief VMU framebuffer. + + This object contains a 48x32 monochrome framebuffer. It can be painted to, + or displayed one the VMUs connected to the system, using the API below. + + \headerfile dc/vmu_fb.h + */ +typedef struct { + uint32_t data[48]; +} vmufb_t; + +/** \brief VMU framebuffer font meta-data. + + \headerfile dc/vmu_fb.h + */ +typedef struct { + unsigned int w; /**< \brief Character width in pixels */ + unsigned int h; /**< \brief Character height in pixels */ + unsigned int stride; /**< \brief Size of one character in bytes */ + const char *fontdata; /**< \brief Pointer to the font data */ +} vmufb_font_t; + +/** \brief Render into the VMU framebuffer + + This function will paint the provided pixel data into the VMU framebuffer, + into the rectangle provided by the x, y, w and h values. + + \param fb A pointer to the vmufb_t to paint to. + \param x The horizontal position of the top-left corner of + the drawing area, in pixels + \param y The vertical position of the top-left corner of the + drawing area, in pixels + \param w The width of the drawing area, in pixels + \param h The height of the drawing area, in pixels + \param data A pointer to the pixel data that will be painted + into the drawing area. + */ +void vmufb_paint_area(vmufb_t *fb, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h, + const char *data); + +/** \brief Clear a specific area of the VMU framebuffer + + This function clears the area of the VMU framebuffer designated by the + x, y, w and h values. + + \param fb A pointer to the vmufb_t to paint to. + \param x The horizontal position of the top-left corner of + the drawing area, in pixels + \param y The vertical position of the top-left corner of the + drawing area, in pixels + \param w The width of the drawing area, in pixels + \param h The height of the drawing area, in pixels + */ +void vmufb_clear_area(vmufb_t *fb, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h); + +/** \brief Clear the VMU framebuffer + + This function clears the whole VMU framebuffer. + + \param fb A pointer to the vmufb_t to paint to. + */ +void vmufb_clear(vmufb_t *fb); + +/** \brief Present the VMU framebuffer to a VMU + + This function presents the previously rendered VMU framebuffer to the + VMU identified by the dev argument. + + \param fb A pointer to the vmufb_t to paint to. + \param dev The maple device of the VMU to present to + */ +void vmufb_present(const vmufb_t *fb, maple_device_t *dev); + +/** \brief Render a string into the VMU framebuffer + + This function uses the provided font to render text into the VMU + framebuffer. + + \param fb A pointer to the vmufb_t to paint to. + \param font A pointer to the vmufb_font_t that will be used for + painting the text + \param x The horizontal position of the top-left corner of + the drawing area, in pixels + \param y The vertical position of the top-left corner of the + drawing area, in pixels + \param w The width of the drawing area, in pixels + \param h The height of the drawing area, in pixels + \param line_spacing Specify the number of empty lines that should + separate two lines of text + \param str The text to render + */ +void vmufb_print_string_into(vmufb_t *fb, + const vmufb_font_t *font, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h, + unsigned int line_spacing, + const char *str); + +/** \brief Render a string into the VMU framebuffer + + Simplified version of vmufb_print_string_into(). This is the same as calling + vmufb_print_string_into with x=0, y=0, w=48, h=32, line_spacing=0. + + \param fb A pointer to the vmufb_t to paint to. + \param font A pointer to the vmufb_font_t that will be used for + painting the text + \param str The text to render + */ +static __inline__ void +vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) { + vmufb_print_string_into(fb, font, 0, 0, 48, 32, 0, str); +} diff --git a/kernel/arch/dreamcast/util/Makefile b/kernel/arch/dreamcast/util/Makefile index 1d9a31a..3bcc711 100644 --- a/kernel/arch/dreamcast/util/Makefile +++ b/kernel/arch/dreamcast/util/Makefile @@ -4,7 +4,7 @@ # Copyright (C) 2001 Megan Potter # -OBJS = vmu_pkg.o screenshot.o minifont.o +OBJS = vmu_fb.o vmu_pkg.o screenshot.o minifont.o SUBDIRS = ifneq ($(KOS_SUBARCH), naomi) diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c new file mode 100644 index 0000000..37b9f8d --- /dev/null +++ b/kernel/arch/dreamcast/util/vmu_fb.c @@ -0,0 +1,142 @@ +/* KallistiOS ##version## + + util/vmu_fb.c + Copyright (C) 2023 Paul Cercueil + +*/ + +#include <stdbool.h> +#include <stdint.h> +#include <string.h> + +#include <dc/maple/vmu.h> +#include <dc/vmu_fb.h> + +#define GENMASK(h, l) \ + (((unsigned int)-1 << (l)) & ((unsigned int)-1 >> (31 - (h)))) + +static uint64_t extract_bits(const uint8_t *data, + unsigned int offt, unsigned int w) { + uint32_t tmp, lsb, nb_bits; + uint64_t bits = 0; + + /* This algorithm will extract "w" bits starting from bit "offt", and + place them right-adjusted in "bits". + + Since we manipulate 8 bits at a time, and neither "w" nor "offt" are + required to be byte-aligned, we need to compute a mask of valid bits + for each byte that is processed. */ + while (w) { + tmp = data[offt / 8]; + + if (8 - (offt & 0x7) > w) + lsb = 8 - (offt & 0x7) - w; + else + lsb = 0; + + nb_bits = 8 - (offt & 0x7) - lsb; + bits <<= nb_bits; + + tmp &= GENMASK(7 - (offt & 0x7), lsb); + + bits |= tmp >> lsb; + + offt += nb_bits; + w -= nb_bits; + } + + return bits; +} + +static void insert_bits(uint8_t *data, + unsigned int offt, unsigned int w, uint64_t bits) { + uint32_t tmp, lsb, nb_bits, mask; + + while (w) { + tmp = data[offt / 8]; + + if (8 - (offt & 0x7) > w) + lsb = 8 - (offt & 0x7) - w; + else + lsb = 0; + + nb_bits = 8 - (offt & 0x7) - lsb; + mask = GENMASK(7 - (offt & 0x7), lsb); + tmp &= ~mask; + + tmp |= ((bits >> (w - nb_bits)) << lsb) & mask; + + data[offt / 8] = tmp; + + offt += nb_bits; + w -= nb_bits; + } +} + +void vmufb_paint_area(vmufb_t *fb, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h, + const char *data) { + unsigned int i; + uint64_t bits; + + for (i = 0; i < h; i++) { + bits = extract_bits((const uint8_t *)data, i * w, w); + insert_bits((uint8_t *)fb->data, (y + i) * 48 + x, w, bits); + } +} + +void vmufb_clear(vmufb_t *fb) { + memset(fb->data, 0, sizeof(fb->data)); +} + +void vmufb_clear_area(vmufb_t *fb, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h) { + uint32_t tmp[48] = {}; + + vmufb_paint_area(fb, x, y, w, h, (const char *) tmp); +} + +void vmufb_present(const vmufb_t *fb, maple_device_t *dev) { + if (dev->info.connector_direction == 0) /* 0: UP - rotated like most controllers */ + vmu_draw_lcd_rotated(dev, fb->data); + else /* 1: DOWN - not rotated, like lightgun */ + vmu_draw_lcd(dev, fb->data); +} + +void vmufb_print_string_into(vmufb_t *fb, + const vmufb_font_t *font, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h, + unsigned int line_spacing, + const char *str) { + unsigned int xorig = x, yorig = y; + + for (; *str; str++) { + switch (*str) { + case '\n': + x = xorig; + y += line_spacing + font->h; + continue; + default: + break; + } + + if (x > xorig + w - font->w) { + /* We run out of horizontal space - put character on new line */ + x = xorig; + y += line_spacing + font->h; + } + + if (y > yorig + h - font->h) { + /* We ran out of space */ + break; + } + + vmufb_paint_area(fb, x, y, font->w, font->h, + &font->fontdata[*str * font->stride]); + + x += font->w; + } +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-30 03:41:00
|
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 8c8b2ad3773a566d54471ac0dba6da71f803de3b (commit) via 9dea5adaa8b6e1dd6225cb62c761af502b40da34 (commit) via 81e7045fc97c0fb824dd1dbd710a62200d77b22b (commit) via 5ba215d72dd9e31923aba3d5b482729e1d1f106c (commit) from 0153c5ac5d88e44b08d66d3629ddc80e2681d7f8 (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 8c8b2ad3773a566d54471ac0dba6da71f803de3b Merge: 0153c5a 9dea5ad Author: Lawrence Sebald <ljs...@us...> Date: Mon May 29 23:39:39 2023 -0400 Merge pull request #223 from pcercuei/vmu-draw-lcd-rotated vmu: Add function vmu_draw_lcd_rotated() commit 9dea5adaa8b6e1dd6225cb62c761af502b40da34 Author: Paul Cercueil <pa...@cr...> Date: Sun May 28 01:45:32 2023 +0200 vmu: Add function vmu_draw_lcd_rotated() This function is equivalent to vmu_draw_lcd, but the image is rotated 180° so that the first byte of the bitmap corresponds to the top-left corner, instead of the bottom-right one. Signed-off-by: Paul Cercueil <pa...@cr...> commit 81e7045fc97c0fb824dd1dbd710a62200d77b22b Author: Paul Cercueil <pa...@cr...> Date: Sun May 28 15:18:07 2023 +0200 vmu: constify bitmap argument to vmu_draw_lcd() The data pointed by the bitmap argument is never modified by the function. Therefore, it should be marked const. Signed-off-by: Paul Cercueil <pa...@cr...> commit 5ba215d72dd9e31923aba3d5b482729e1d1f106c Author: Paul Cercueil <pa...@cr...> Date: Sun May 28 01:42:36 2023 +0200 Add optimized ASM bit-reverse function This function can be used to bit-reverse a 32-bit value (where the MSB becomes the LSB and vice-versa). Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/hardware/maple/vmu.c | 14 +++++++++++++- kernel/arch/dreamcast/include/dc/maple/vmu.h | 21 ++++++++++++++++++++- kernel/arch/dreamcast/include/dc/math.h | 27 +++++++++++++++++++++++++++ kernel/arch/dreamcast/math/Makefile | 2 +- kernel/arch/dreamcast/math/math.s | 18 ++++++++++++++++++ 6 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 kernel/arch/dreamcast/include/dc/math.h create mode 100644 kernel/arch/dreamcast/math/math.s diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 2e05268..de7839d 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -173,6 +173,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Updated Objective-C examples to include more thorough testing of the runtime aspects of the language [Andrew Apperley == AA] - DC Improve fipr() and fipr_magnitude_sqr() functions [PC] +- DC Add optimized bit-reverse function && vmu_draw_lcd_rotated() [PC] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c index 302b431..3267479 100644 --- a/kernel/arch/dreamcast/hardware/maple/vmu.c +++ b/kernel/arch/dreamcast/hardware/maple/vmu.c @@ -12,6 +12,7 @@ #include <kos/genwait.h> #include <dc/maple.h> #include <dc/maple/vmu.h> +#include <dc/math.h> #include <dc/biosfont.h> #include <dc/vmufs.h> #include <arch/timer.h> @@ -169,7 +170,7 @@ int vmu_beep_raw(maple_device_t * dev, uint32 beep) { /* Draw a 1-bit bitmap on the LCD screen (48x32). return a -1 if an error occurs */ -int vmu_draw_lcd(maple_device_t * dev, void *bitmap) { +int vmu_draw_lcd(maple_device_t * dev, const void *bitmap) { uint32 * send_buf; assert(dev != NULL); @@ -206,6 +207,17 @@ int vmu_draw_lcd(maple_device_t * dev, void *bitmap) { return MAPLE_EOK; } +int vmu_draw_lcd_rotated(maple_device_t *dev, const void *bitmap) { + uint32 bitmap_inverted[48]; + unsigned int i; + + for (i = 0; i < 48; i++) { + bitmap_inverted[i] = bit_reverse(((uint32 *)bitmap)[47 - i]); + } + + return vmu_draw_lcd(dev, bitmap_inverted); +} + /* This function converts a xbm image to a 1-bit bitmap that can be displayed on LCD screen of VMU */ static void vmu_xbm_to_bitmap(uint8 *bitmap, const char *vmu_icon) { diff --git a/kernel/arch/dreamcast/include/dc/maple/vmu.h b/kernel/arch/dreamcast/include/dc/maple/vmu.h index 01fb82d..eb9d952 100644 --- a/kernel/arch/dreamcast/include/dc/maple/vmu.h +++ b/kernel/arch/dreamcast/include/dc/maple/vmu.h @@ -97,7 +97,26 @@ int vmu_beep_raw(maple_device_t * dev, uint32 beep); \retval MAPLE_EAGAIN If the command couldn't be sent. Try again later. \retval MAPLE_ETIMEOUT If the command timed out while blocking. */ -int vmu_draw_lcd(maple_device_t * dev, void *bitmap); +int vmu_draw_lcd(maple_device_t * dev, const void *bitmap); + +/** \brief Display a 1bpp bitmap on a VMU screen. + + This function sends a raw bitmap to a VMU to display on its screen. This + bitmap is 1bpp, and is 48x32 in size. This function is equivalent to + vmu_draw_lcd, but the image is rotated 180° so that the first byte of the + bitmap corresponds to the top-left corner, instead of the bottom-right one. + + \param dev The device to draw to. + \param bitmap The bitmap to show. + \retval MAPLE_EOK On success. + \retval MAPLE_EAGAIN If the command couldn't be sent. Try again later. + \retval MAPLE_ETIMEOUT If the command timed out while blocking. + + \warning This function is optimized by an assembly routine which operates + on 32 bits at a time. As such, the given bitmap must be 4-byte + aligned. +*/ +int vmu_draw_lcd_rotated(maple_device_t * dev, const void *bitmap); /** \brief Display a Xwindows XBM image on a VMU screen. diff --git a/kernel/arch/dreamcast/include/dc/math.h b/kernel/arch/dreamcast/include/dc/math.h new file mode 100644 index 0000000..83e52cd --- /dev/null +++ b/kernel/arch/dreamcast/include/dc/math.h @@ -0,0 +1,27 @@ +/* KallistiOS ##version## + + dc/math.h + Copyright (C) 2023 Paul Cercueil + +*/ + +#ifndef __DC_MATH_H +#define __DC_MATH_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +/** + \file dc/math.h + \brief Prototypes for optimized math functions written in ASM + \author Paul Cercueil +*/ + +/** + \brief Returns the bit-reverse value of the argument (where MSB + becomes LSB and vice-versa). + \return the bit-reverse value of the argument. +*/ +unsigned int bit_reverse(unsigned int value); + +#endif /* __DC_MATH_H */ diff --git a/kernel/arch/dreamcast/math/Makefile b/kernel/arch/dreamcast/math/Makefile index 43a7f59..dc4081a 100644 --- a/kernel/arch/dreamcast/math/Makefile +++ b/kernel/arch/dreamcast/math/Makefile @@ -6,7 +6,7 @@ # Dreamcast-specific math functions -OBJS = fmath.o matrix.o matrix3d.o +OBJS = fmath.o math.o matrix.o matrix3d.o SUBDIRS = include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/arch/dreamcast/math/math.s b/kernel/arch/dreamcast/math/math.s new file mode 100644 index 0000000..ae84be9 --- /dev/null +++ b/kernel/arch/dreamcast/math/math.s @@ -0,0 +1,18 @@ +! KallistiOS ##version## +! +! dc/math.s +! Copyright (C) 2023 Paul Cercueil + +! Return the bit-reverse value of the first argument. +.globl _bit_reverse +_bit_reverse: + mov r4,r0 + sett +_1: + rotcr r0 + rotcl r1 + cmp/eq #1,r0 + bf _1 + + rts + mov r1,r0 hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-29 01:08:44
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 0153c5ac5d88e44b08d66d3629ddc80e2681d7f8 (commit) via 1dd5d4ec67d9f7759088f13445c891aaf5392bce (commit) via dcc9071ac8c5d3e669194697b5899abc15df21f7 (commit) via 1c39d4dbd4a389f0361a587b62cef11944812e94 (commit) via 8153a425273e565bb425231976a6ae9f7b1226b6 (commit) via 4125c9a5b0da71994ec60dc627d9eb1dd7acf4b9 (commit) from ebf8d528cd8d1909150f60bef98e1a68318cbb95 (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 0153c5ac5d88e44b08d66d3629ddc80e2681d7f8 Merge: 1dd5d4e 8153a42 Author: Lawrence Sebald <ljs...@us...> Date: Sun May 28 21:06:36 2023 -0400 Merge pull request #222 from KallistiOS/fast_math_flags Added fast math flags and -fno-builtin options to environ.sh.sample commit 1dd5d4ec67d9f7759088f13445c891aaf5392bce Author: Falco Girgis <gyr...@gm...> Date: Sun May 28 20:04:20 2023 -0500 Update AUTHORS (#221) Add Paul Cercueil, aka "zcrc" to AUTHORS. commit dcc9071ac8c5d3e669194697b5899abc15df21f7 Author: James Peach <jp...@ap...> Date: Mon May 29 10:50:05 2023 +1000 Move vector.h from addons to core. (#218) * Move vector.h from addons to core. The core matrix API depends on the typedefs in vector.h, which currently lives in the addons tree. This change moves these typed back to the core kernel tree so that we don't have a dependency from addons back to the kernel. Signed-off-by: James Peach <jp...@ap...> * Update Doxygen comments for dc/vector.h. Signed-off-by: James Peach <jp...@ap...> --------- Signed-off-by: James Peach <jp...@ap...> commit 1c39d4dbd4a389f0361a587b62cef11944812e94 Author: Andress Barajas <and...@gm...> Date: Sun May 28 17:48:27 2023 -0700 Clean up Makefiles (#220) Clean up Makefiles for examples. commit 8153a425273e565bb425231976a6ae9f7b1226b6 Author: Falco Girgis <gyr...@gm...> Date: Sat May 27 04:23:59 2023 -0500 Added -fno-builtin to environ.sh.sample - Removed -fno-builtin from environ_base.sh - Added it back to environ.sh.sample with a comment on how to disable it and an explanation of the implications of doing so commit 4125c9a5b0da71994ec60dc627d9eb1dd7acf4b9 Author: Falco Girgis <gyr...@gm...> Date: Fri May 26 21:48:46 2023 -0500 Added fast math CFlags to environ.sh.sample - Added fasth math KOS_CFLAGS to environ.sh.sample, defaulting to commented out, with a description of when and why you'd want to enable them - Removed -fno-builtin from the environ_base.sh script ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + addons/include/kos/bspline.h | 2 +- addons/include/kos/vector.h | 38 +++------------------ doc/environ.sh.sample | 14 ++++++++ environ_base.sh | 2 +- examples/dreamcast/2ndmix/Makefile | 6 ++-- examples/dreamcast/basic/asserthnd/Makefile | 2 +- examples/dreamcast/basic/exec/Makefile | 2 +- examples/dreamcast/basic/fpu/exc/Makefile | 2 +- examples/dreamcast/basic/memtest32/Makefile | 2 +- examples/dreamcast/basic/mmu/nullptr/Makefile | 2 +- examples/dreamcast/basic/mmu/pvrmap/Makefile | 2 +- examples/dreamcast/basic/stackprotector/Makefile | 2 +- examples/dreamcast/basic/stacktrace/Makefile | 2 +- examples/dreamcast/basic/threading/once/Makefile | 2 +- .../basic/threading/recursive_lock/Makefile | 2 +- examples/dreamcast/basic/threading/rwsem/Makefile | 2 +- examples/dreamcast/basic/threading/tls/Makefile | 4 +-- examples/dreamcast/cpp/clock/Makefile | 2 +- examples/dreamcast/cpp/dcplib/Makefile | 2 +- examples/dreamcast/cpp/gltest/Makefile | 2 +- examples/dreamcast/cpp/modplug_test/Makefile | 2 +- examples/dreamcast/cpp/out_of_memory/Makefile | 2 +- examples/dreamcast/dreameye/basic/Makefile | 2 +- examples/dreamcast/dreameye/sd/Makefile | 2 +- examples/dreamcast/g1ata/atatest/Makefile | 2 +- examples/dreamcast/hello/Makefile | 2 +- examples/dreamcast/keyboard/keytest/Makefile | 2 +- examples/dreamcast/kgl/basic/elements/Makefile | 2 +- examples/dreamcast/kgl/basic/gl/Makefile | 2 +- examples/dreamcast/kgl/basic/scissor/Makefile | 2 +- examples/dreamcast/kgl/basic/txrenv/Makefile | 2 +- examples/dreamcast/kgl/basic/vq/Makefile | 2 +- examples/dreamcast/kgl/basic/zclip_arrays/Makefile | 2 +- .../dreamcast/kgl/benchmarks/quadmark/Makefile | 2 +- examples/dreamcast/kgl/benchmarks/trimark/Makefile | 2 +- .../dreamcast/kgl/benchmarks/tristripmark/Makefile | 2 +- examples/dreamcast/kgl/demos/blur/Makefile | 2 +- examples/dreamcast/kgl/demos/mipmap/Makefile | 2 +- .../kgl/demos/multitexture-arrays/Makefile | 2 +- .../kgl/demos/multitexture-elements/Makefile | 2 +- examples/dreamcast/kgl/demos/specular/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe02/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe05/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe06/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe08/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe09/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe16/Makefile | 2 +- examples/dreamcast/kgl/nehe/nehe26/Makefile | 2 +- examples/dreamcast/libdream/Makefile.prefab | 12 +++---- examples/dreamcast/modem/basic/Makefile | 2 +- examples/dreamcast/modem/ppp/Makefile | 2 +- examples/dreamcast/network/basic/Makefile | 2 +- examples/dreamcast/network/dns-client/Makefile | 2 +- examples/dreamcast/network/httpd/Makefile | 8 ++--- examples/dreamcast/network/isp-settings/Makefile | 2 +- examples/dreamcast/network/ping/Makefile | 2 +- examples/dreamcast/network/ping6/Makefile | 2 +- examples/dreamcast/network/udpecho6/Makefile | 2 +- examples/dreamcast/objc/runtime/Makefile | 2 +- examples/dreamcast/parallax/bubbles/Makefile | 2 +- examples/dreamcast/parallax/delay_cube/Makefile | 2 +- examples/dreamcast/parallax/font/Makefile | 2 +- examples/dreamcast/parallax/raster_melt/Makefile | 2 +- examples/dreamcast/parallax/rotocube/Makefile | 2 +- examples/dreamcast/parallax/serpent_dma/Makefile | 2 +- examples/dreamcast/parallax/sinus/Makefile | 2 +- examples/dreamcast/png/Makefile | 14 ++++---- examples/dreamcast/png/example.c | 4 +-- .../png/{romdisk_boot => romdisk}/background.png | Bin .../png/{romdisk_boot => romdisk}/text.gz | Bin examples/dreamcast/pvr/bumpmap/Makefile | 2 +- examples/dreamcast/pvr/cheap_shadow/Makefile | 2 +- examples/dreamcast/pvr/modifier_volume/Makefile | 2 +- .../dreamcast/pvr/modifier_volume_tex/Makefile | 2 +- examples/dreamcast/pvr/plasma/Makefile | 2 +- examples/dreamcast/pvr/pvrmark/Makefile | 2 +- examples/dreamcast/pvr/pvrmark_strips/Makefile | 2 +- .../dreamcast/pvr/pvrmark_strips_direct/Makefile | 2 +- examples/dreamcast/pvr/texture_render/Makefile | 2 +- examples/dreamcast/random/Makefile | 2 +- examples/dreamcast/sd/ext2fs/Makefile | 2 +- examples/dreamcast/sd/mke2fs/Makefile | 4 +-- examples/dreamcast/sd/speedtest/Makefile | 2 +- examples/dreamcast/sdl/sound/Makefile | 2 +- examples/dreamcast/sound/cdda/basic_cdda/Makefile | 2 +- .../dreamcast/sound/ghettoplay-vorbis/Makefile | 2 +- examples/dreamcast/sound/hello-mp3/Makefile | 2 +- examples/dreamcast/sound/hello-ogg/Makefile | 2 +- examples/dreamcast/sound/hello-opus/Makefile | 2 +- examples/dreamcast/tsunami/banner/Makefile | 2 +- examples/dreamcast/tsunami/font/Makefile | 2 +- examples/dreamcast/tsunami/genmenu/Makefile | 2 +- examples/dreamcast/video/minifont/Makefile | 2 +- examples/dreamcast/video/palmenu/Makefile | 2 +- examples/dreamcast/vmu/vmu_beep/Makefile | 2 +- examples/dreamcast/vmu/vmu_game/Makefile | 2 +- examples/dreamcast/vmu/vmu_pkg/Makefile | 2 +- kernel/arch/dreamcast/include/dc/matrix.h | 2 +- .../arch/dreamcast/include/dc}/vector.h | 21 +++++------- 100 files changed, 140 insertions(+), 160 deletions(-) rename examples/dreamcast/png/{romdisk_boot => romdisk}/background.png (100%) rename examples/dreamcast/png/{romdisk_boot => romdisk}/text.gz (100%) copy {addons/include/kos => kernel/arch/dreamcast/include/dc}/vector.h (61%) diff --git a/AUTHORS b/AUTHORS index a6d4096..d4fc8fc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -47,6 +47,7 @@ Falco Girgis: 2023 Ruslan Rostovtsev: 2014, 2016, 2023 Colton Pawielski: 2023 Andy Barajas: 2023 +Paul Cercueil: 2023 Files with Specific licenses: ----------------------------- diff --git a/addons/include/kos/bspline.h b/addons/include/kos/bspline.h index 4a9b55a..d029293 100644 --- a/addons/include/kos/bspline.h +++ b/addons/include/kos/bspline.h @@ -24,7 +24,7 @@ #include <sys/cdefs.h> __BEGIN_DECLS -#include <kos/vector.h> +#include <dc/vector.h> /** \brief Calculate and set b-spline coefficients. diff --git a/addons/include/kos/vector.h b/addons/include/kos/vector.h index a69038e..c4d9b85 100644 --- a/addons/include/kos/vector.h +++ b/addons/include/kos/vector.h @@ -5,42 +5,12 @@ */ -#ifndef __KOS_VECTOR_H -#define __KOS_VECTOR_H - /** \file kos/vector.h - \brief Primitive matrix, vector, and point types. - - This file provides a few primivite data types that are useful for 3D - graphics. These are used by the code in kos/bspline.h and can be useful - elsewhere, as well. - - \author Megan Potter -*/ - -#include <sys/cdefs.h> -__BEGIN_DECLS - -#include <arch/types.h> + \brief Deprecated alias for <dc/vector.h>. -/** \brief Basic 4x4 matrix type. - \headerfile kos/vector.h + This file is provided for backwards compatibility. New code should include + <dc/vector.h> directly. */ -typedef float matrix_t[4][4]; - -/** \brief 4-part vector type. - \headerfile kos/vector.h -*/ -typedef struct vectorstr { - float x, y, z, w; -} vector_t; - -/** \brief 4-part point type (alias to the vector_t type). - \headerfile kos/vector.h -*/ -typedef vector_t point_t; - -__END_DECLS -#endif /* __KOS_VECTOR_H */ +#include <dc/vector.h> diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample index 16e74c9..a6dbcfb 100644 --- a/doc/environ.sh.sample +++ b/doc/environ.sh.sample @@ -79,6 +79,20 @@ export KOS_AFLAGS="" export KOS_CFLAGS="-O2 -fomit-frame-pointer" # export KOS_CFLAGS="-O2 -DFRAME_POINTERS -fno-omit-frame-pointer" +# Comment out this line to enable GCC to use its own builtin implementations of +# certain standard library functions. Under certain conditions, this can allow +# compiler-optimized implementations to replace standard function invocations. +# The downside of this is that it COULD interfere with Newlib or KOS implementations +# of these functions, and it has not been tested thoroughly to ensure compatibility. +export KOS_CFLAGS="${KOS_CFLAGS} -fno-builtin" + +# Uncomment this line to enable the optimized fast-math instructions (FSSRA, +# FSCA, and FSQRT) for calculating sin/cos, inverse square root, and square roots. +# These can result in substantial performance gains for these kinds of operations; +# however, they do so at the price of accuracy and are not IEEE compliant. +# NOTE: This also requires -fno-builtin be removed from KOS_CFLAGS to take effect! +# export KOS_CFLAGS="${KOS_CFLAGS} -ffast-math -ffp-contract=fast -mfsrra -mfsca" + # Everything else is pretty much shared. If you want to configure compiler # options or other such things, look at this file. . ${KOS_BASE}/environ_base.sh diff --git a/environ_base.sh b/environ_base.sh index 3d6bec8..ade36db 100644 --- a/environ_base.sh +++ b/environ_base.sh @@ -33,7 +33,7 @@ export KOS_OBJCOPY="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-objcopy" export KOS_LD="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-ld" export KOS_RANLIB="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-gcc-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_CFLAGS="${KOS_CFLAGS} ${KOS_INC_PATHS} -D_arch_${KOS_ARCH} -D_arch_sub_${KOS_SUBARCH} -Wall -g" export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP} -fno-operator-names" # Which standards modes we want to compile for diff --git a/examples/dreamcast/2ndmix/Makefile b/examples/dreamcast/2ndmix/Makefile index 3a2be9a..1bfb159 100644 --- a/examples/dreamcast/2ndmix/Makefile +++ b/examples/dreamcast/2ndmix/Makefile @@ -13,10 +13,10 @@ KOS_ROMDISK_DIR = romdisk_boot include $(KOS_BASE)/Makefile.rules clean: rm-elf - rm -f $(OBJS) + -rm -f $(OBJS) rm-elf: - rm -f $(TARGET) romdisk.* + -rm -f $(TARGET) romdisk.* $(TARGET): $(OBJS) kos-cc -o $(TARGET) $(OBJS) @@ -25,6 +25,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) romdisk.img + -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/asserthnd/Makefile b/examples/dreamcast/basic/asserthnd/Makefile index 9caf7fa..a4182ae 100644 --- a/examples/dreamcast/basic/asserthnd/Makefile +++ b/examples/dreamcast/basic/asserthnd/Makefile @@ -23,6 +23,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/exec/Makefile b/examples/dreamcast/basic/exec/Makefile index 407c658..928599d 100644 --- a/examples/dreamcast/basic/exec/Makefile +++ b/examples/dreamcast/basic/exec/Makefile @@ -37,6 +37,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) sub.elf sub.o romdisk/sub.bin romdisk.img + -rm -f $(OBJS) sub.elf sub.o romdisk/sub.bin romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/fpu/exc/Makefile b/examples/dreamcast/basic/fpu/exc/Makefile index 6120b6e..c8d46ad 100644 --- a/examples/dreamcast/basic/fpu/exc/Makefile +++ b/examples/dreamcast/basic/fpu/exc/Makefile @@ -23,6 +23,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/memtest32/Makefile b/examples/dreamcast/basic/memtest32/Makefile index b8cb5bc..4a696cb 100644 --- a/examples/dreamcast/basic/memtest32/Makefile +++ b/examples/dreamcast/basic/memtest32/Makefile @@ -18,5 +18,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/mmu/nullptr/Makefile b/examples/dreamcast/basic/mmu/nullptr/Makefile index b3c41bc..772f36d 100644 --- a/examples/dreamcast/basic/mmu/nullptr/Makefile +++ b/examples/dreamcast/basic/mmu/nullptr/Makefile @@ -23,6 +23,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/mmu/pvrmap/Makefile b/examples/dreamcast/basic/mmu/pvrmap/Makefile index 10315f5..f10a050 100644 --- a/examples/dreamcast/basic/mmu/pvrmap/Makefile +++ b/examples/dreamcast/basic/mmu/pvrmap/Makefile @@ -23,6 +23,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/stackprotector/Makefile b/examples/dreamcast/basic/stackprotector/Makefile index f4056dc..6e4ec0e 100644 --- a/examples/dreamcast/basic/stackprotector/Makefile +++ b/examples/dreamcast/basic/stackprotector/Makefile @@ -28,7 +28,7 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/stacktrace/Makefile b/examples/dreamcast/basic/stacktrace/Makefile index 649b6a4..0efd755 100644 --- a/examples/dreamcast/basic/stacktrace/Makefile +++ b/examples/dreamcast/basic/stacktrace/Makefile @@ -23,6 +23,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/threading/once/Makefile b/examples/dreamcast/basic/threading/once/Makefile index d80f042..52d83b3 100644 --- a/examples/dreamcast/basic/threading/once/Makefile +++ b/examples/dreamcast/basic/threading/once/Makefile @@ -24,6 +24,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/threading/recursive_lock/Makefile b/examples/dreamcast/basic/threading/recursive_lock/Makefile index 12c4080..b7fa065 100644 --- a/examples/dreamcast/basic/threading/recursive_lock/Makefile +++ b/examples/dreamcast/basic/threading/recursive_lock/Makefile @@ -24,5 +24,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/threading/rwsem/Makefile b/examples/dreamcast/basic/threading/rwsem/Makefile index 2fadfb7..0f541bf 100644 --- a/examples/dreamcast/basic/threading/rwsem/Makefile +++ b/examples/dreamcast/basic/threading/rwsem/Makefile @@ -24,5 +24,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/threading/tls/Makefile b/examples/dreamcast/basic/threading/tls/Makefile index 46d9564..2854ddd 100644 --- a/examples/dreamcast/basic/threading/tls/Makefile +++ b/examples/dreamcast/basic/threading/tls/Makefile @@ -17,13 +17,13 @@ clean: rm-elf rm-elf: -rm -f $(TARGET) -tls_test.elf: $(OBJS) +$(TARGET): $(OBJS) kos-cc -o $(TARGET) $(OBJS) run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/cpp/clock/Makefile b/examples/dreamcast/cpp/clock/Makefile index 79d6900..061ca3f 100644 --- a/examples/dreamcast/cpp/clock/Makefile +++ b/examples/dreamcast/cpp/clock/Makefile @@ -30,6 +30,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) romdisk.img + -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/cpp/dcplib/Makefile b/examples/dreamcast/cpp/dcplib/Makefile index 86d74f3..badf892 100644 --- a/examples/dreamcast/cpp/dcplib/Makefile +++ b/examples/dreamcast/cpp/dcplib/Makefile @@ -31,6 +31,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) romdisk.img + -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/cpp/gltest/Makefile b/examples/dreamcast/cpp/gltest/Makefile index d35679a..f18a277 100644 --- a/examples/dreamcast/cpp/gltest/Makefile +++ b/examples/dreamcast/cpp/gltest/Makefile @@ -29,6 +29,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) romdisk.img + -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/cpp/modplug_test/Makefile b/examples/dreamcast/cpp/modplug_test/Makefile index 073cb0f..0a9af3e 100644 --- a/examples/dreamcast/cpp/modplug_test/Makefile +++ b/examples/dreamcast/cpp/modplug_test/Makefile @@ -24,5 +24,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) romdisk.img + -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/cpp/out_of_memory/Makefile b/examples/dreamcast/cpp/out_of_memory/Makefile index d594330..24bf5df 100644 --- a/examples/dreamcast/cpp/out_of_memory/Makefile +++ b/examples/dreamcast/cpp/out_of_memory/Makefile @@ -25,6 +25,6 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/dreameye/basic/Makefile b/examples/dreamcast/dreameye/basic/Makefile index 221558c..5a004a6 100644 --- a/examples/dreamcast/dreameye/basic/Makefile +++ b/examples/dreamcast/dreameye/basic/Makefile @@ -24,5 +24,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/dreameye/sd/Makefile b/examples/dreamcast/dreameye/sd/Makefile index 607ce6e..af7fa1a 100644 --- a/examples/dreamcast/dreameye/sd/Makefile +++ b/examples/dreamcast/dreameye/sd/Makefile @@ -26,5 +26,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/g1ata/atatest/Makefile b/examples/dreamcast/g1ata/atatest/Makefile index 6c38732..92f594f 100644 --- a/examples/dreamcast/g1ata/atatest/Makefile +++ b/examples/dreamcast/g1ata/atatest/Makefile @@ -23,5 +23,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/hello/Makefile b/examples/dreamcast/hello/Makefile index 580b4aa..a33d108 100644 --- a/examples/dreamcast/hello/Makefile +++ b/examples/dreamcast/hello/Makefile @@ -33,5 +33,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) romdisk.img + -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/keyboard/keytest/Makefile b/examples/dreamcast/keyboard/keytest/Makefile index 6ce0094..3806fa6 100644 --- a/examples/dreamcast/keyboard/keytest/Makefile +++ b/examples/dreamcast/keyboard/keytest/Makefile @@ -23,5 +23,5 @@ run: $(TARGET) $(KOS_LOADER) $(TARGET) dist: $(TARGET) - rm -f $(OBJS) + -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/kgl/basic/elements/Makefile b/examples/dreamcast/kgl/basic/elements/Makefile index e5fb06b..8fb9660 100644 --- a/examples/dreamcast/kgl/basic/elements/Makefile +++ b/examples/dreamcast/kgl/basic/elements/Makefile ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-27 03:28: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 ebf8d528cd8d1909150f60bef98e1a68318cbb95 (commit) via 227a3cd67643609b6152cc7625f79b61fab0dfdd (commit) from 1cefd646c73b9115ca4457b24fc2db103fb4e15d (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 ebf8d528cd8d1909150f60bef98e1a68318cbb95 Merge: 1cefd64 227a3cd Author: Lawrence Sebald <ljs...@us...> Date: Fri May 26 23:21:02 2023 -0400 Merge pull request #219 from pcercuei/better-fipr Improve fipr() function commit 227a3cd67643609b6152cc7625f79b61fab0dfdd Author: Paul Cercueil <pa...@cr...> Date: Fri May 26 15:15:18 2023 +0200 Improve fipr() and fipr_magnitude_sqr() functions Update the __fipr() and __fipr_magnitude_sq() macros to use better registers. With this change, the inner body of these functions pass from being 11 and 9 opcodes long respectively, to being just 3 opcodes long. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/include/dc/fmath_base.h | 34 +++++++++++++-------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 9920b4f..2e05268 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -172,6 +172,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added Objective-C example testing/demonstrating C Runtime [FG] - *** Updated Objective-C examples to include more thorough testing of the runtime aspects of the language [Andrew Apperley == AA] +- DC Improve fipr() and fipr_magnitude_sqr() functions [PC] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/kernel/arch/dreamcast/include/dc/fmath_base.h b/kernel/arch/dreamcast/include/dc/fmath_base.h index 830c721..f56cb0b 100644 --- a/kernel/arch/dreamcast/include/dc/fmath_base.h +++ b/kernel/arch/dreamcast/include/dc/fmath_base.h @@ -125,34 +125,34 @@ __BEGIN_DECLS /* Floating point inner product (dot product) */ #define __fipr(x, y, z, w, a, b, c, d) ({ \ - register float __x __asm__("fr0") = (x); \ - register float __y __asm__("fr1") = (y); \ - register float __z __asm__("fr2") = (z); \ - register float __w __asm__("fr3") = (w); \ - register float __a __asm__("fr4") = (a); \ - register float __b __asm__("fr5") = (b); \ - register float __c __asm__("fr6") = (c); \ - register float __d __asm__("fr7") = (d); \ + register float __x __asm__("fr5") = (x); \ + register float __y __asm__("fr4") = (y); \ + register float __z __asm__("fr7") = (z); \ + register float __w __asm__("fr6") = (w); \ + register float __a __asm__("fr9") = (a); \ + register float __b __asm__("fr8") = (b); \ + register float __c __asm__("fr11") = (c); \ + register float __d __asm__("fr10") = (d); \ __asm__ __volatile__( \ - "fipr fv4,fv0" \ - : "+f" (__w) \ + "fipr fv8,fv4" \ + : "+f" (__z) \ : "f" (__x), "f" (__y), "f" (__z), "f" (__w), \ "f" (__a), "f" (__b), "f" (__c), "f" (__d) \ ); \ - __w; }) + __z; }) /* Floating point inner product w/self (square of vector magnitude) */ #define __fipr_magnitude_sqr(x, y, z, w) ({ \ - register float __x __asm__("fr4") = (x); \ - register float __y __asm__("fr5") = (y); \ - register float __z __asm__("fr6") = (z); \ - register float __w __asm__("fr7") = (w); \ + register float __x __asm__("fr5") = (x); \ + register float __y __asm__("fr4") = (y); \ + register float __z __asm__("fr7") = (z); \ + register float __w __asm__("fr6") = (w); \ __asm__ __volatile__( \ "fipr fv4,fv4" \ - : "+f" (__w) \ + : "+f" (__z) \ : "f" (__x), "f" (__y), "f" (__z), "f" (__w) \ ); \ - __w; }) + __z; }) /** \endcond */ __END_DECLS hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-26 02:15:17
|
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 1cefd646c73b9115ca4457b24fc2db103fb4e15d (commit) from 3d31498741c7ae5788711d8f8da37b086d63ddd2 (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 1cefd646c73b9115ca4457b24fc2db103fb4e15d Author: Falco Girgis <gyr...@gm...> Date: Thu May 25 21:14:35 2023 -0500 Added Quzar's VMUBeep as an Example (#214) * Added Quzar's VMUBeep example, withcleanups Quzar's VMUBeep is an incredibly useful tool that allows you to easily send raw maple buzzer commands to a VMU. Co-authored-by: Lawrence Sebald <ljs...@us...> ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/vmu/Makefile | 4 +- .../{cpp/gltest => vmu/vmu_beep}/Makefile | 70 ++++---- examples/dreamcast/vmu/vmu_beep/beep.c | 195 +++++++++++++++++++++ .../font => vmu/vmu_beep}/romdisk/axaxax.txf | Bin 4 files changed, 234 insertions(+), 35 deletions(-) copy examples/dreamcast/{cpp/gltest => vmu/vmu_beep}/Makefile (69%) create mode 100644 examples/dreamcast/vmu/vmu_beep/beep.c copy examples/dreamcast/{parallax/font => vmu/vmu_beep}/romdisk/axaxax.txf (100%) diff --git a/examples/dreamcast/vmu/Makefile b/examples/dreamcast/vmu/Makefile index f711b57..c5ac508 100644 --- a/examples/dreamcast/vmu/Makefile +++ b/examples/dreamcast/vmu/Makefile @@ -7,13 +7,15 @@ all: $(KOS_MAKE) -C vmu_pkg $(KOS_MAKE) -C vmu_game + $(KOS_MAKE) -C vmu_beep clean: $(KOS_MAKE) -C vmu_pkg clean $(KOS_MAKE) -C vmu_game clean + $(KOS_MAKE) -C vmu_beep clean dist: $(KOS_MAKE) -C vmu_pkg dist $(KOS_MAKE) -C vmu_game dist - + $(KOS_MAKE) -C vmu_beep dist diff --git a/examples/dreamcast/cpp/gltest/Makefile b/examples/dreamcast/vmu/vmu_beep/Makefile similarity index 69% copy from examples/dreamcast/cpp/gltest/Makefile copy to examples/dreamcast/vmu/vmu_beep/Makefile index d35679a..56e318b 100644 --- a/examples/dreamcast/cpp/gltest/Makefile +++ b/examples/dreamcast/vmu/vmu_beep/Makefile @@ -1,34 +1,36 @@ -# -# KallistiGL test program in C++ -# (c)2001 Megan Potter -# - -TARGET = gltest.elf -OBJS = gltest.o romdisk.o - -all: rm-elf $(TARGET) - -include $(KOS_BASE)/Makefile.rules - -clean: rm-elf - -rm -f $(OBJS) - -rm-elf: - -rm -f $(TARGET) romdisk.* - -$(TARGET): $(OBJS) - kos-c++ -o $(TARGET) $(OBJS) -lGL -lkosutils - -romdisk.img: - $(KOS_GENROMFS) -f romdisk.img -d romdisk -v - -romdisk.o: romdisk.img - $(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o - -run: $(TARGET) - $(KOS_LOADER) $(TARGET) - -dist: $(TARGET) - rm -f $(OBJS) romdisk.img - $(KOS_STRIP) $(TARGET) - +# +# VMUBeep Test 2 +# Copyright (C) 2008 Donald Haase + +# + +TARGET = beep.elf +OBJS = beep.o romdisk.o + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: rm-elf + -rm -f $(OBJS) + +rm-elf: + -rm -f $(TARGET) romdisk.* + +$(TARGET): $(OBJS) + kos-cc -o $(TARGET) $(OBJS) -lparallax -lz -lm + +romdisk.img: + $(KOS_GENROMFS) -f romdisk.img -d romdisk -v + +romdisk.o: romdisk.img + $(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: $(TARGET) + rm -f $(OBJS) romdisk.img + $(KOS_STRIP) $(TARGET) + + diff --git a/examples/dreamcast/vmu/vmu_beep/beep.c b/examples/dreamcast/vmu/vmu_beep/beep.c new file mode 100644 index 0000000..0bd1d42 --- /dev/null +++ b/examples/dreamcast/vmu/vmu_beep/beep.c @@ -0,0 +1,195 @@ +/* KallistiOS ##version## + + beep.c + Copyright (C) 2004 SinisterTengu + Copyright (C) 2008 Donald Haase + +*/ + +/* + This example allows you to send raw commands to the VMU's buzzer, using the CLOCK + function implemented by the VMU. + + On a typical VMU, which only has a single channel, only the low 2 bytes are used to + create a single waveform, with the lowest byte being the period of the waveform, and + the next byte being the duty cycle. Duty cyle should always be less than the period + and is recommended to stay around 50%. + + All of the interface code for this was stolen from SinisterTengu's Puru Puru Demo from '04 + (when Kamjin first RE'd the puru). The rest was based off the puru driver as well as other bits + of maple driver and lots of guesswork (and messed up vmu). + + Try out this value: 0x000065F0 + + Enjoy, and let me know about some interesting sounds. + */ + +#include <dc/maple.h> +#include <dc/maple/controller.h> +#include <dc/maple/vmu.h> +#include <plx/font.h> + +#include <stdio.h> +#include <stdint.h> + +extern uint8_t romdisk[]; +KOS_INIT_FLAGS(INIT_DEFAULT); +KOS_INIT_ROMDISK(romdisk); + +int main(int argc, char *argv[]) { + maple_device_t *dev, *vmudev; + cont_state_t *state; + plx_font_t *fnt; + plx_fcxt_t *cxt; + point_t w; + int i = 0, count = 0; + uint16_t old_buttons = 0, rel_buttons = 0; + uint32_t effect = 0; + uint8_t n[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; //nibbles + char s[8][2] = { "", "", "", "", "", "", "", "" }; + + /* If the face buttons are all pressed, exit the app */ + cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, + (cont_btn_callback_t)arch_exit); + + pvr_init_defaults(); + + fnt = plx_font_load("/rd/axaxax.txf"); + cxt = plx_fcxt_create(fnt, PVR_LIST_TR_POLY); + + pvr_set_bg_color(0.0f, 0.0f, 0.0f); + + for(;;) { + dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + vmudev = maple_enum_type(0, MAPLE_FUNC_CLOCK); + + while(!dev) { + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(PVR_LIST_OP_POLY); + pvr_list_begin(PVR_LIST_TR_POLY); + + plx_fcxt_begin(cxt); + w.x = 40.0f; w.y = 200.0f; w.z = 10.0f; + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Please attach a controller!"); + plx_fcxt_end(cxt); + + pvr_scene_finish(); + + dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + } + + while(!vmudev) { + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(PVR_LIST_OP_POLY); + pvr_list_begin(PVR_LIST_TR_POLY); + + plx_fcxt_begin(cxt); + w.x = 40.0f; w.y = 200.0f; w.z = 10.0f; + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Please attach a vmu!"); + plx_fcxt_end(cxt); + + pvr_scene_finish(); + + vmudev = maple_enum_type(0, MAPLE_FUNC_CLOCK); + } + + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(PVR_LIST_OP_POLY); + pvr_list_begin(PVR_LIST_TR_POLY); + plx_fcxt_begin(cxt); + + w.x = 70.0f; w.y = 70.0f; w.z = 10.0f; + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "VMUBeep Test by Quzar"); + + w.x += 130; w.y += 120.0f; + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_setsize(cxt, 30.0f); + plx_fcxt_draw(cxt, "0x"); + + w.x += 48.0f; + plx_fcxt_setpos_pnt(cxt, &w); + + count = 0; + while(count <= 7) { + if(i == count) + plx_fcxt_setcolor4f(cxt, 1.0f, 0.9f, 0.9f, 0.0f); + else + plx_fcxt_setcolor4f(cxt, 1.0f, 1.0f, 1.0f, 1.0f); + + sprintf(s[count], "%x", n[count]); + plx_fcxt_draw(cxt, s[count]); + + count++; + w.x += 25.0f; + } + + plx_fcxt_setsize(cxt, 24.0f); + plx_fcxt_setcolor4f(cxt, 1.0f, 1.0f, 1.0f, 1.0f); + w.x = 65.0f; w.y += 50.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press left/right to switch digits."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press up/down to change values."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press A to start vmu beep."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press B to stop vmu beep."); + w.y += 25.0f; + + plx_fcxt_setpos_pnt(cxt, &w); + plx_fcxt_draw(cxt, "Press ABXYS to quit."); + + plx_fcxt_end(cxt); + pvr_scene_finish(); + + /* Store current button states + buttons which have been released. */ + state = (cont_state_t *)maple_dev_status(dev); + rel_buttons = (old_buttons ^ state->buttons); + + if((state->buttons & CONT_DPAD_LEFT) && (rel_buttons & CONT_DPAD_LEFT)) { + if(i > 0) i--; + } + + if((state->buttons & CONT_DPAD_RIGHT) && (rel_buttons & CONT_DPAD_RIGHT)) { + if(i < 7) i++; + } + + if((state->buttons & CONT_DPAD_UP) && (rel_buttons & CONT_DPAD_UP)) { + if(n[i] < 15) n[i]++; + } + + if((state->buttons & CONT_DPAD_DOWN) && (rel_buttons & CONT_DPAD_DOWN)) { + if(n[i] > 0) n[i]--; + } + + if((state->buttons & CONT_A) && (rel_buttons & CONT_A)) { + effect = (n[0] << 28) + (n[1] << 24) + (n[2] << 20) + (n[3] << 16) + + (n[4] << 12) + (n[5] << 8) + (n[6] << 4) + (n[7] << 0); + + vmu_beep_raw(vmudev, effect); + printf("VMU Beep: 0x%lx!\n", effect); + } + + if((state->buttons & CONT_B) && (rel_buttons & CONT_B)) { + vmu_beep_raw(vmudev, 0x00000000); + printf("Beep Stopped!\n"); + } + + old_buttons = state->buttons ; + } + + return 0; +} diff --git a/examples/dreamcast/parallax/font/romdisk/axaxax.txf b/examples/dreamcast/vmu/vmu_beep/romdisk/axaxax.txf similarity index 100% copy from examples/dreamcast/parallax/font/romdisk/axaxax.txf copy to examples/dreamcast/vmu/vmu_beep/romdisk/axaxax.txf hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-24 01:34:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 3d31498741c7ae5788711d8f8da37b086d63ddd2 (commit) from 660a7f724bc0ce9da0d262ef33282160983954ba (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 3d31498741c7ae5788711d8f8da37b086d63ddd2 Author: Lawrence Sebald <ljs...@us...> Date: Tue May 23 21:33:37 2023 -0400 Update copyright years in banner.c ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/banner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/arch/dreamcast/kernel/banner.c b/kernel/arch/dreamcast/kernel/banner.c index ddd7481..3567c47 100644 --- a/kernel/arch/dreamcast/kernel/banner.c +++ b/kernel/arch/dreamcast/kernel/banner.c @@ -8,7 +8,7 @@ #include "authors.h" static const char license[] = -"Copyright (C) 1997-2022 KallistiOS Contributors. All rights reserved.\n" +"Copyright (C) 1997-2023 KallistiOS Contributors. All rights reserved.\n" "\n" "Redistribution and use in source and binary forms, with or without\n" "modification, are permitted provided that the following conditions\n" hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-24 00:02:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 660a7f724bc0ce9da0d262ef33282160983954ba (commit) via 90dade51f42d5d2a9b5ae8f56eb8ed08cafd7d3a (commit) from 37fcad35a2a1fce7a1098cbde039f4fd520be9cc (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 660a7f724bc0ce9da0d262ef33282160983954ba Merge: 37fcad3 90dade5 Author: Lawrence Sebald <ljs...@us...> Date: Tue May 23 20:02:01 2023 -0400 Merge pull request #211 from jpeach/bin2o-robust Make bin2o a little more robust. commit 90dade51f42d5d2a9b5ae8f56eb8ed08cafd7d3a Author: James Peach <jp...@ap...> Date: Tue May 23 16:39:48 2023 +1000 Make bin2o a little more robust. - use a private directory for temporary files - set shell error checking flags - error on unsupported $KOS_ARCH settings Signed-off-by: James Peach <jp...@ap...> ----------------------------------------------------------------------- Summary of changes: utils/bin2o/bin2o | 57 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/utils/bin2o/bin2o b/utils/bin2o/bin2o index 86a7119..c0eadf8 100755 --- a/utils/bin2o/bin2o +++ b/utils/bin2o/bin2o @@ -1,47 +1,66 @@ -#!/bin/sh +#! /usr/bin/env bash # bin2o (heh) # script to convert a binary data to an elf object file # (c)2000 Megan Potter +# Unfortunately pipefail is not POSIX, see https://github.com/koalaman/shellcheck/issues/2555. +set -o pipefail +set -o nounset +set -o errexit + +error() { + echo "bin2o:" "$@" 1>&2 +} + if [ $# != 3 ]; then echo "usage: $0 \<input file\> \<symbol\> \<output file\>" exit 0 fi -for i in KOS_ARCH KOS_AS KOS_AFLAGS KOS_LD; do +for i in KOS_ARCH KOS_AS KOS_AFLAGS KOS_LD ; do if [ -z "$(eval "echo \"\$$i\"")" ]; then - echo "Environment variable $i is undefined." + error "environment variable $i is undefined" error=1 fi done -if [ -n "$error" ]; then +if [ -n "${error:-}" ]; then exit 1 fi -TMPFILE1=/tmp/script$$.ld -TMPFILE2=/tmp/obja$$.o -TMPFILE3=/tmp/objb$$.o +WORKDIR=$(mktemp -d) + +TMPFILE1="$WORKDIR/script$$.ld" +TMPFILE2="$WORKDIR/obja$$.o" +TMPFILE3="$WORKDIR/objb$$.o" -# Gotta do a different binary target here depending on the target -if [ "$KOS_ARCH" = dreamcast ]; then +# Gotta do a different binary target here depending on the target. +case $KOS_ARCH in +dreamcast) + # shellcheck disable=SC2086 echo ".section .rodata; .align 2; " | "$KOS_AS" $KOS_AFLAGS -o "$TMPFILE3" + # shellcheck disable=SC2181 if [ $? -ne 0 ]; then exit 1; fi echo "SECTIONS { .rodata : { _$2 = .; *(.data); _$2_end = .; } }" > "$TMPFILE1" "$KOS_LD" --no-warn-mismatch --format binary --oformat elf32-shl "$1" --format elf32-shl "$TMPFILE3" -o "$TMPFILE2" -r -EL -T "$TMPFILE1" + # shellcheck disable=SC2181 if [ $? -ne 0 ]; then exit 1; fi "$KOS_OBJCOPY" --set-section-flags .rodata=alloc,load,data,readonly "$TMPFILE2" "$3" - if [ $? -ne 0 ]; then exit 1; fi - rm -f "$TMPFILE1" "$TMPFILE2" "$TMPFILE3" + ;; -elif [ "$KOS_ARCH" = gba ]; then - echo "SECTIONS { .rodata : { $2 = .; *(.data); $2_end = .; } }" > /tmp/script.ld - "$KOS_LD" --no-warn-mismatch --format binary --oformat elf32-littlearm "$1" -o "$3" -r -EL -T /tmp/script.ld +gba) + echo "SECTIONS { .rodata : { $2 = .; *(.data); $2_end = .; } }" > "$WORKDIR/script.ld" + "$KOS_LD" --no-warn-mismatch --format binary --oformat elf32-littlearm "$1" -o "$3" -r -EL -T "$WORKDIR/script.ld" + ;; -elif [ "$KOS_ARCH" = ps2 ]; then - echo "OUTPUT_ARCH(mips:5900) SECTIONS { .rodata : { _$2 = .; *(.data); _$2_end = .; } }" > /tmp/script.ld - "$KOS_LD" --no-warn-mismatch --format binary --oformat elf64-littlemips -mips3 "$1" -o "$3" -r -EL -T /tmp/script.ld -fi +ps2) + echo "OUTPUT_ARCH(mips:5900) SECTIONS { .rodata : { _$2 = .; *(.data); _$2_end = .; } }" > "$WORKDIR/script.ld" + "$KOS_LD" --no-warn-mismatch --format binary --oformat elf64-littlemips -mips3 "$1" -o "$3" -r -EL -T "$WORKDIR/script.ld" + ;; -rm -f /tmp/script.ld +*) + error "unsupported architecture \"$KOS_ARCH\"" + exit 1 + ;; +esac hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-23 02:50:46
|
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 37fcad35a2a1fce7a1098cbde039f4fd520be9cc (commit) via cfbddf7a2131e3363f7ce1885adadc831e7e00fe (commit) from dad5b531aeb3ccb8d55b17ef14bb703d771b6dfb (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 37fcad35a2a1fce7a1098cbde039f4fd520be9cc Merge: dad5b53 cfbddf7 Author: Lawrence Sebald <ljs...@us...> Date: Mon May 22 22:50:12 2023 -0400 Merge pull request #210 from KallistiOS/petty-locks Avoid mutex_lock in an interrupt in fs_pty commit cfbddf7a2131e3363f7ce1885adadc831e7e00fe Author: Quzar <qu...@co...> Date: Mon May 22 21:51:16 2023 -0400 Properly trylock if in an int and trying to clean up ----------------------------------------------------------------------- Summary of changes: kernel/fs/fs_pty.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/fs/fs_pty.c b/kernel/fs/fs_pty.c index a4e6aad..462753a 100644 --- a/kernel/fs/fs_pty.c +++ b/kernel/fs/fs_pty.c @@ -192,7 +192,11 @@ static void pty_destroy_unused(void) { /* Make sure no one else is messing with the list and then disable everything for a bit */ - mutex_lock(&list_mutex); + if(irq_inside_int()) + mutex_trylock(&list_mutex); + else + mutex_lock(&list_mutex); + old = irq_disable(); again: @@ -401,7 +405,11 @@ static int pty_close(void * h) { if(fdobj->type == PF_PTY) { /* De-ref this end of it */ - mutex_lock(&fdobj->d.p->mutex); + if(irq_inside_int()) + mutex_trylock(&fdobj->d.p->mutex); + else + mutex_lock(&fdobj->d.p->mutex); + fdobj->d.p->refcnt--; if(fdobj->d.p->refcnt <= 0) { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-23 01:04:54
|
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 dad5b531aeb3ccb8d55b17ef14bb703d771b6dfb (commit) via 7ce6d3ff434e56b4f95e1209aba94a40b746d3e5 (commit) via be8d16ab6a2cde052d60cfa43cb06a058e68c3fd (commit) from a9ac6f8a5b1cacf8a1ffb98682795853ba16286b (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 dad5b531aeb3ccb8d55b17ef14bb703d771b6dfb Author: Falco Girgis <gyr...@gm...> Date: Mon May 22 20:01:16 2023 -0500 Fixed Objective-C + added C runtime example (#202) * Fixed Objective-C + added C runtime example - Added ObjC + ObjC++ Makefile rules - Modified GCC13 patch to also include a fix for a bug where libobjc was never being properly installed for stripped targets - added an example that dynamically creates a class and calls a method using only the Objective-C runtime API (libobjc) * ...oops.. * libobjc patches applied to GCC4+9, example update - Updated patches for gcc-4.7.4 and gcc-9.3.0 to include the libobjc Makefile fix, so that the library and headers are properly installed with GCC - Added top-level Makefile to examples/objc directory * Added a newline character to end of Makefile * Updated objc runtime example and added myself to changelog * ...removed tab from end of Makefile... * Update runtime.m Add a newline at end of file * Clean-up, more testing, and more validation - refactored a bit - got rid of all warnings - uniform exit with error return code - validating every operation with C runtime - testing copying an instance - errors are written to stderr * Removed accidental addition of merge marker * Added more comments, made util function static * Final pass testing + cleaning up example * Wrapped CHANGELOG entry to next line --------- Co-authored-by: Andrew Apperley <ma...@an...> Co-authored-by: darcagn <da...@pr...> commit 7ce6d3ff434e56b4f95e1209aba94a40b746d3e5 Merge: a9ac6f8 be8d16a Author: Lawrence Sebald <ljs...@us...> Date: Mon May 22 20:55:29 2023 -0400 Merge pull request #206 from KallistiOS/threads_doxygen Updated Doxygen for Threading API commit be8d16ab6a2cde052d60cfa43cb06a058e68c3fd Author: Falco Girgis <gyr...@gm...> Date: Sun May 21 03:38:05 2023 -0500 Updated Doxygen for Threading API - added top-level thread module - added "related functions" for kthread_t type - swapped uints to uint_t stdint types - added #define for threads' label and pwd sizes ----------------------------------------------------------------------- Summary of changes: Makefile.rules | 12 + doc/CHANGELOG | 3 + doc/Doxyfile | 2 +- examples/dreamcast/objc/Makefile | 14 ++ .../{cpp/out_of_memory => objc/runtime}/Makefile | 13 +- examples/dreamcast/objc/runtime/runtime.m | 214 +++++++++++++++++ include/kos/thread.h | 259 ++++++++++++++++----- kernel/thread/thread.c | 30 +-- utils/dc-chain/patches/gcc-13.1.0-kos.diff | 89 ++++--- utils/dc-chain/patches/gcc-4.7.4-kos.diff | 89 ++++--- utils/dc-chain/patches/gcc-9.3.0-kos.diff | 83 +++++-- 11 files changed, 640 insertions(+), 168 deletions(-) create mode 100644 examples/dreamcast/objc/Makefile copy examples/dreamcast/{cpp/out_of_memory => objc/runtime}/Makefile (57%) create mode 100644 examples/dreamcast/objc/runtime/runtime.m diff --git a/Makefile.rules b/Makefile.rules index 05280aa..78d3fb2 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -18,6 +18,12 @@ ifndef KOS_DEPDIR %.o: %.cpp kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ +%.o: %.m + kos-cc $(CFLAGS) -c $< -o $@ + +%.o: %.mm + kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ + else %.o: %.c @@ -29,6 +35,12 @@ else %.o: %.cpp kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) +%.o: %.m + kos-cc $(CFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.m,%.md,$(subst /,__,$(subst ..,,$<))) + +%.o: %.mm + kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.mm,%.md,$(subst /,__,$(subst ..,,$<))) + -include $(wildcard $(KOS_DEPDIR)/*.md) endif diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 5f8ff95..9920b4f 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -169,6 +169,9 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Cleaned up asic functions and corrected potential bugs [DH] - DC Removed cooperative threading mode -- threading is always preemptive [DH] - DC Added early user init function [PC] +- *** Added Objective-C example testing/demonstrating C Runtime [FG] +- *** Updated Objective-C examples to include more thorough testing of the + runtime aspects of the language [Andrew Apperley == AA] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/doc/Doxyfile b/doc/Doxyfile index 0193040..7df6ccd 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -449,7 +449,7 @@ INLINE_SIMPLE_STRUCTS = NO # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. -TYPEDEF_HIDES_STRUCT = NO +TYPEDEF_HIDES_STRUCT = YES # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be diff --git a/examples/dreamcast/objc/Makefile b/examples/dreamcast/objc/Makefile new file mode 100644 index 0000000..5004c50 --- /dev/null +++ b/examples/dreamcast/objc/Makefile @@ -0,0 +1,14 @@ +# KallistiOS ##version## +# +# examples/dreamcast/objc/Makefile +# (c) 2023 Falco Girgis +# + +all: + $(KOS_MAKE) -C runtime + +clean: + $(KOS_MAKE) -C runtime + +dist: + $(KOS_MAKE) -C runtime diff --git a/examples/dreamcast/cpp/out_of_memory/Makefile b/examples/dreamcast/objc/runtime/Makefile similarity index 57% copy from examples/dreamcast/cpp/out_of_memory/Makefile copy to examples/dreamcast/objc/runtime/Makefile index d594330..050d8f8 100644 --- a/examples/dreamcast/cpp/out_of_memory/Makefile +++ b/examples/dreamcast/objc/runtime/Makefile @@ -1,12 +1,11 @@ # -# C++ out-of-memory demonstration -# (c)2023 Falco Girgis +# Objective-C Runtime Example +# (c) 2023 Falco Girgis # -TARGET = out_of_memory.elf -OBJS = out_of_memory.o - -KOS_CPPFLAGS += -fexceptions -std=c++11 +TARGET = runtime.elf +OBJS = runtime.o +CFLAGS = -std=c11 all: rm-elf $(TARGET) @@ -19,7 +18,7 @@ rm-elf: -rm -f $(TARGET) $(TARGET): $(OBJS) - kos-c++ -o $(TARGET) $(OBJS) -lm + kos-cc -o $(TARGET) $(OBJS) -lobjc run: $(TARGET) $(KOS_LOADER) $(TARGET) diff --git a/examples/dreamcast/objc/runtime/runtime.m b/examples/dreamcast/objc/runtime/runtime.m new file mode 100644 index 0000000..6c4af0b --- /dev/null +++ b/examples/dreamcast/objc/runtime/runtime.m @@ -0,0 +1,214 @@ +/* KallistiOS ##version## + + runtime.m + Copyright (C) 2023 Falco Girgis, Andrew Apperley + + This example serves two purposes: to demonstrate the basic + usage of the Objective-C language runtime C API as well as + to serve as a toolchain and sanity check to validate it. +*/ + +#import <objc/objc.h> +#import <objc/Object.h> +#import <objc/runtime.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +/* +Relatively simple Objective-C class flexing: + - inheritance + - instance variables + - properties + - message handlers +*/ +@interface Person: Object +{ + const char *_name; + int _age; + float _height; + Person *_bestFriend; + BOOL _dead; +} +- (void)addName:(const char *)name age:(int)age height:(float)height; +- (void)setBestFriend:(Person *)bestFriend; +@property(nonatomic, assign)Person *bestFriend; +@property(nonatomic)BOOL dead; +@end + +@implementation Person + +@synthesize bestFriend = _bestFriend, dead = _dead; + +- (void)addName:(const char *)name age:(int)age height:(float)height { + _name = name; + _age = age; + _height = height; +} + +- (void)setDead:(BOOL)dead { + if (_dead == YES) { return; } + _dead = dead; +} + +- (BOOL)dead { + return _dead; +} + +- (void)setBestFriend:(Person *)bestFriend { + _bestFriend = bestFriend; +} + +- (Person *)bestFriend { + return _bestFriend; +} +@end + +/* + Utility function for reflecting over a Person, printing its + instance variables. +*/ +static BOOL printIVarsForPerson(const Person *person) { + BOOL success = YES; + unsigned int outCount = 0; + + // Retrieve a list of all instance variables + Ivar *iVarList = class_copyIvarList(objc_getClass("Person"), &outCount); + printf("Discovered %u instance variables:\n", outCount); + + // Ensure we found all 5 of them + if(outCount != 5) { + fprintf(stderr, "\tUnexpected count!\n"); + success = NO; + } + else { + // Iterate over them, printing name + property + for(unsigned i = 0; i < outCount; i++) { + Ivar iVar = iVarList[i]; + const char* type = ivar_getTypeEncoding(iVar); + + printf("\t[%u] %s: ", i, ivar_getName(iVar)); + + // Use the encoded type to tell us how to print the queried value + if(strcmp(type, "f") == 0) { + ptrdiff_t offset = ivar_getOffset(iVar); + printf("%f\n", *(float*)(((uint8_t*)person) + offset)); + } + else { + id value = object_getIvar(person, iVar); + + const char* format; + if (strcmp(type, "i") == 0) { + format = "%d"; + } + else if(strcmp(type, "r*") == 0) { + format = "%s"; + } + else if(strcmp(type, "C") == 0) { + format = "%u"; + } + else if(strcmp(type, "@\"Person\"") == 0) { + format = "%x"; + } + else { + fprintf(stderr, "Unexpected Type [%s]\n", type); + success = NO; + break; + } + + printf(format, value); + printf("\n"); + } + } + } + + free(iVarList); + return success; +} + +int main(int argc, char *argv[]) { + int result = EXIT_SUCCESS; + Person *person1 = NULL; + Person *person2 = NULL; + + // Create a new instance of person, using the runtime + person1 = class_createInstance(objc_getClass("Person"), 0); + + // Verify the runtime succeeded + if(!person1) { + fprintf(stderr, "Failed to create Person instance!\n"); + result = EXIT_FAILURE; + goto exit; + } + else printf("Created Person instance.\n"); + + // Call message handler for "addName," setting instance variables + [person1 addName: "Joe" age: 20 height: 6.1f]; + + // Dynamically query values of instance variables by string names + const char* name = NULL; + int age = 0; + float height = 0.0f; + object_getInstanceVariable(person1, "_name", (void**)&name); + object_getInstanceVariable(person1, "_age", (void**)&age); + object_getInstanceVariable(person1, "_height", (void**)&height); + + // Verify values were properly set and retrieved + if(strcmp(name, "Joe") != 0 || age != 20 || height != 6.1f) { + fprintf(stderr, "Failed to set and retrieve instance variables!\n"); + result = EXIT_FAILURE; + goto exit; + } + else printf("Set and retrieved instance variables.\n"); + + // Use runtime to dynamically reflect over all properties + if(!printIVarsForPerson(person1)) { + result = EXIT_FAILURE; + goto exit; + } + + // Check if instance of Person responds to getBestFriend + if(!class_respondsToSelector(objc_getClass("Person"), @selector(bestFriend))) { + fprintf(stderr, "Does not respond to getBestFriend message!\n"); + result = EXIT_FAILURE; + goto exit; + } + else printf("Checked for responding to message handler.\n"); + + // Use runtime to copy construct another Person instance + person2 = object_copy(person1, 0); + + if(!person2) { + fprintf(stderr, "Failed to copy Person instance!\n"); + result = EXIT_FAILURE; + goto exit; + } + else printf("Copied Person instance.\n"); + + // Initialize instance variables + [person2 addName: "Jim" age: 30 height: 5.2]; + + // Test out setting and retrieving properties + person2.dead = YES; + object_setInstanceVariable(person1, "_bestFriend", person2); + + if(!person2.dead || person1.bestFriend != person2) { + fprintf(stderr, "Failed to set and retrieve properties!\n"); + result = EXIT_FAILURE; + } else printf("Set and retrieved properties!\n"); + +exit: + + // Clean up after ourselves + object_dispose(person1); + object_dispose(person2); + + if(result == EXIT_FAILURE) + fprintf(stderr, "**** FAILURE! ****\n"); + else + printf("**** SUCCESS! ****\n"); + + return result; +} diff --git a/include/kos/thread.h b/include/kos/thread.h index bde3058..8a5b866 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -19,12 +19,31 @@ __BEGIN_DECLS #include <sys/queue.h> #include <sys/reent.h> -/** \file kos/thread.h - \brief Threading support. +#include <stdint.h> + +/** \file kos/thread.h + \brief Threading support. + \ingroup threads This file contains the interface to the threading system of KOS. Timer interrupts are used to reschedule threads within the system. + \author Megan Potter + \author Lawrence Sebald + + \see arch/timer.h + \see kos/genwait.h + \see kos/mutex.h + \see kos/once.h + \see kos/recursive_lock.h + \see kos/rwsem.h + \see kos/sem.h + \see kos/tls.h +*/ + +/** \defgroup threads Threads + \brief Threading API + The thread scheduler itself is a relatively simplistic priority scheduler. There is no provision for priorities to erode over time, so keep that in mind. That practically means that if you have 2 high priority threads that @@ -45,29 +64,40 @@ __BEGIN_DECLS thd_detach()). The old KOS threading system only had what would be considered detached threads. - \author Megan Potter - \author Lawrence Sebald - \see arch/timer.h - \see kos/genwait.h - \see kos/mutex.h - \see kos/once.h - \see kos/recursive_lock.h - \see kos/rwsem.h - \see kos/sem.h - \see kos/tls.h + \sa semaphore_t, mutex_t, kthread_once_t, kthread_key_t */ -/** \brief Maximal thread priority. +/** \brief Maximal thread priority. + \ingroup threads + This macro defines the maximum value for a thread's priority. Note that the larger this number, the lower the priority of the thread. */ #define PRIO_MAX 4096 -/** \brief Default thread priority. +/** \brief Default thread priority. + \ingroup threads + Threads are created by default with the priority specified. */ #define PRIO_DEFAULT 10 +/** \brief Size of a kthread's label + \ingroup threads + + Maximum number of characters in a thread's label or name + (including NULL terminator). +*/ +#define KTHREAD_LABEL_SIZE 256 + +/** \brief Size of a kthread's current directory + \ingroup threads + + Maximum number of characters in a thread's current working + directory (including NULL terminator). +*/ +#define KTHREAD_PWD_SIZE 256 + /* Pre-define list/queue types */ struct kthread; @@ -76,9 +106,10 @@ TAILQ_HEAD(ktqueue, kthread); LIST_HEAD(ktlist, kthread); /* \endcond */ -/** \brief Structure describing one running thread. +/** \brief Structure describing one running thread. + \ingroup threads - Each thread has one of this structure assigned to it, which hold all the + Each thread has one of these structures assigned to it, which holds all the data associated with the thread. There are various functions to manipulate the data in here, so you shouldn't generally do so manually. @@ -102,7 +133,7 @@ typedef struct kthread { /** \brief Thread flags. \see thd_flags */ - uint32 flags; + uint32_t flags; /** \brief Process state. \see thd_states */ @@ -129,24 +160,24 @@ typedef struct kthread { This value is used for sleep and timed block operations. This value is in milliseconds since the start of timer_ms_gettime(). This should be enough for something like 2 million years of wait time. ;) */ - uint64 wait_timeout; + uint64_t wait_timeout; /** \brief Thread label. This value is used when printing out a user-readable process listing. */ - char label[256]; + char label[KTHREAD_LABEL_SIZE]; /** \brief Current file system path. */ - char pwd[256]; + char pwd[KTHREAD_PWD_SIZE]; /** \brief Register store -- used to save thread context. */ irq_context_t context; /** \brief Thread private stack. This should be a pointer to the base of a stack page. */ - uint32 *stack; + uint32_t *stack; /** \brief Size of the thread's stack, in bytes. */ - uint32 stack_size; + uint32_t stack_size; /** \brief Thread errno variable. */ int thd_errno; @@ -164,6 +195,7 @@ typedef struct kthread { } kthread_t; /** \defgroup thd_flags Thread flag values + \ingroup threads These are possible values for the flags field on the kthread_t structure. These can be ORed together. @@ -177,6 +209,7 @@ typedef struct kthread { /** @} */ /** \defgroup thd_states Thread states + \ingroup threads Each thread in the system is in exactly one of this set of states. @@ -189,7 +222,8 @@ typedef struct kthread { #define STATE_FINISHED 0x0004 /**< \brief Finished execution */ /** @} */ -/** \brief Thread creation attributes. +/** \brief Thread creation attributes. ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-05-21 02:16:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a9ac6f8a5b1cacf8a1ffb98682795853ba16286b (commit) via d5e2f3e9abc1e63d2ed2689906d44c142eef4c70 (commit) via b39fa012c6c39261cb6cf9ff5f2ffee9209ca7e4 (commit) via d48c3b8b88c08340dace32c3e598ee0ee931f14f (commit) from 308a1bbc2f95c0f9aa44982f4f9bf7334ddef207 (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 a9ac6f8a5b1cacf8a1ffb98682795853ba16286b Author: Colton Pawielski <cep...@us...> Date: Sat May 20 21:15:55 2023 -0500 Update GDB to use _download_type config (#193) * Update GDB to use _download_type config This change allows specifying a git repo to pull sources from, matching the behavior of Binutils, GCC, & Newlib. * Add GNU source mirror override * Remove extra whitespace * Fix whitespace and typos commit d5e2f3e9abc1e63d2ed2689906d44c142eef4c70 Merge: 308a1bb b39fa01 Author: Lawrence Sebald <ljs...@us...> Date: Sat May 20 22:14:00 2023 -0400 Merge pull request #203 from KallistiOS/filling_GAPS Updates to GAPS and BBA init sequences commit b39fa012c6c39261cb6cf9ff5f2ffee9209ca7e4 Author: quzar <qu...@co...> Date: Fri May 19 11:13:12 2023 -0400 Updating more register names and definitions commit d48c3b8b88c08340dace32c3e598ee0ee931f14f Author: quzar <qu...@co...> Date: Mon May 15 12:07:22 2023 -0400 Update GAPS and BBA init routines to match updated dcload. Reduce magic numbers via RTL datasheet. ----------------------------------------------------------------------- Summary of changes: .../dreamcast/hardware/network/broadband_adapter.c | 246 ++++++++++++++------- .../dreamcast/include/dc/net/broadband_adapter.h | 137 +++++++++--- utils/dc-chain/Makefile | 12 +- utils/dc-chain/README.md | 3 + utils/dc-chain/config.mk.legacy.sample | 8 +- utils/dc-chain/config.mk.stable.sample | 8 +- utils/dc-chain/config.mk.testing.sample | 8 +- utils/dc-chain/scripts/clean.mk | 2 +- utils/dc-chain/scripts/common.sh | 4 +- utils/dc-chain/scripts/download.mk | 95 ++++++++ utils/dc-chain/scripts/gdb.mk | 30 +-- utils/dc-chain/scripts/host-detect.mk | 9 +- utils/dc-chain/scripts/init.mk | 53 ++++- utils/dc-chain/scripts/phony.mk | 3 +- utils/dc-chain/scripts/variables.mk | 24 -- 15 files changed, 470 insertions(+), 172 deletions(-) create mode 100644 utils/dc-chain/scripts/download.mk diff --git a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c index 41f40f4..0347231 100644 --- a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c +++ b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c @@ -47,10 +47,7 @@ #define TX_BUFFER_LEN (0x800) #define TX_NB_BUFFERS 4 -/* original value */ -//#define BBA_ASIC_IRQ ASIC_IRQB - -/* testing */ +/* This was originally set as ASIC_IRQB */ #define BBA_ASIC_IRQ ASIC_IRQ_DEFAULT /* Use a customized g2_read_block function */ @@ -97,7 +94,14 @@ static int gaps_detect(void) { g2_read_block_8((uint8 *)str, GAPS_BASE + 0x1400, 16); if(!strncmp(str, "GAPSPCI_BRIDGE_2", 16)) + { + /* Set this to 0 first thing */ + g2_write_32(GAPS_BASE + 0x1414, 0x00000000); + /* Turn GAPS off */ + g2_write_32(GAPS_BASE + 0x1418, 0x5a14a501); + return 0; + } else return -1; } @@ -122,7 +126,7 @@ static int gaps_init(void) { if(!(g2_read_32(GAPS_BASE + 0x1418) & 1)) { dbglog(DBG_ERROR, "bba: GAPS PCI controller not responding; giving up!\n"); - return -1; + return -2; } g2_write_32(GAPS_BASE + 0x1420, 0x01000000); @@ -137,16 +141,69 @@ static int gaps_init(void) { ridiculous for accessing a single card that will probably never change. Considering that the DC is now out of production officially, there is a VERY good chance it will never change. */ - g2_write_16(GAPS_BASE + 0x1606, 0xf900); - g2_write_32(GAPS_BASE + 0x1630, 0x00000000); - g2_write_8(GAPS_BASE + 0x163c, 0x00); - g2_write_8(GAPS_BASE + 0x160d, 0xf0); - g2_read_16(GAPS_BASE + 0x0004); - g2_write_16(GAPS_BASE + 0x1604, 0x0006); - g2_write_32(GAPS_BASE + 0x1614, 0x01000000); - g2_read_8(GAPS_BASE + 0x1650); - return 0; + /* VEN:DEV is 11db:1234 (vendor code is "Sega Enterprises, LTD") + The GAPS bridge is really just an MMU with a memory buffer that maps + the RTL8139C to the Dreamcast's memory space, so these are actually + the PCI configuration registers for the RTL8139, not GAPS (those are + just the 0x1400 regs). + + It has a custom ven:dev ID, but the class ID in 0x1608 indicates a + network controller (byte 0x160b = 0x02 = network controller, + 0x160a = 0x00 = Ethernet controller) + + See PCI Local Bus Specification 2.2 (2.3 has all the 2.2 stuff in + it and the RTL8139C uses 2.2). This is also documented in the + RTL8139C's datasheet, under "PCI Configuration Space Registers" + */ + + g2_write_16(GAPS_BASE + 0x1606, 0xf900); /* PCI Status Register */ + g2_write_32(GAPS_BASE + 0x1630, 0x00000000); /* PCI BMAR */ + g2_write_8(GAPS_BASE + 0x163c, 0x00); /* Interrupt Line */ + g2_write_8(GAPS_BASE + 0x160d, 0xf0); /* Primary Latency Timer */ + + /* PCI Command Register (Fast Back-to-Back is read-only 0 on this bridge) + 0x1610 (BAR0, I/O BAR) reads back as 0x00000001, which is I/O Space Indicator + */ + g2_write_16(GAPS_BASE + 0x1604, g2_read_16(GAPS_BASE + 0x1604) | 0x6); + + g2_write_32(GAPS_BASE + 0x1614, 0x01000000); /* BAR1 (Memory BAR) */ + + /* There are two extra regs here that are GAPS-specific (0x1650 and 0x1654). */ + if(g2_read_8(GAPS_BASE + 0x1650) & 0x1) + { + g2_write_16(GAPS_BASE + 0x1654, (g2_read_16(GAPS_BASE + 0x1654) & 0xfffc) | 0x8000); + } + + /* Apparently we do this again */ + g2_write_32(GAPS_BASE + 0x1414, 0x00000001); /* Interrupt enable */ + + /* Clear GAPS mem */ + g2_memset_8(RTL_MEM, 0, (RX_BUFFER_LEN + (TX_BUFFER_LEN * TX_NB_BUFFERS))); + //Apparently the Cache should be invalidated also. Don't want to import that. + + /* Another magic number sequence, possibly checking previous init. */ + /* ASCII for 'SEGA' in little-endian */ + if(g2_read_32(GAPS_BASE + 0x141c) == 0x41474553) { + g2_write_32(GAPS_BASE + 0x141c, 0x55aaff00); + + if(g2_read_32(GAPS_BASE + 0x141c) == 0x55aaff00) { + g2_write_32(GAPS_BASE + 0x141c, 0xaa5500ff); + + if(g2_read_32(GAPS_BASE + 0x141c) == 0xaa5500ff) { + g2_write_32(GAPS_BASE + 0x141c, 0x41474553); + /* I think GAPS automatically pulls RSTB low for 120ns, which + causes the EEPROM to autoload all the registers initially. + So we don't need to worry about it. + */ + return 0; + } + } + } + + dbglog(DBG_ERROR, "bba: GAPS PCI controller init failed!\n"); + + return -3; } /****************************************************************************/ @@ -160,7 +217,7 @@ struct { } rtl; /* 8, 16, and 32 bit access to the PCI I/O space (configured by GAPS) */ -#define NIC(ADDR) (0xa1001700 + (ADDR)) +#define NIC(ADDR) (GAPS_BASE + 0x1700 + (ADDR)) /* 8 and 32 bit access to the PCI MEMMAP space (configured by GAPS) */ static uint32 const rtl_mem = 0xa0000000 + RTL_MEM; @@ -192,63 +249,39 @@ void bba_set_rx_callback(eth_rx_callback_t cb) { eth_rx_callback = cb; } -/* - Initializes the BBA - - Returns 0 for success or -1 for failure. - */ -static int bba_hw_init(void) { - int i; - uint32 tmp; - - link_stable = 0; - link_initial = 0; - - /* Initialize GAPS */ - if(gaps_init() < 0) - return -1; +static int rtl_reset(void) { + int i = 100; /* Soft-reset the chip */ g2_write_8(NIC(RT_CHIPCMD), RT_CMD_RESET); /* Wait for it to come back */ - i = 100; - while((g2_read_8(NIC(RT_CHIPCMD)) & RT_CMD_RESET) && i > 0) { i--; thd_sleep(10); } if(g2_read_8(NIC(RT_CHIPCMD)) & RT_CMD_RESET) { - dbglog(DBG_ERROR, "bba: timed out on reset #1\n"); + dbglog(DBG_ERROR, "bba: timed out on reset\n"); return -1; } - /* Reset CONFIG1 */ - g2_write_8(NIC(RT_CONFIG1), 0); - - /* Enable auto-negotiation and restart that process */ - /* NIC16(RT_MII_BMCR) = 0x1200; */ - g2_write_16(NIC(RT_MII_BMCR), 0x9200); - - /* Do another reset */ - g2_write_8(NIC(RT_CHIPCMD), RT_CMD_RESET); + return 0; +} +/* + Initializes the BBA - /* Wait for it to come back */ - i = 100; + Returns 0 for success or -1 for failure. + */ +static int bba_hw_init(void) { + uint32 tmp; - while((g2_read_8(NIC(RT_CHIPCMD)) & RT_CMD_RESET) && i > 0) { - i--; - thd_sleep(10); - } + link_stable = 0; + link_initial = 0; - if(g2_read_8(NIC(RT_CHIPCMD)) & RT_CMD_RESET) { - dbglog(DBG_ERROR, "bba: timed out on reset #2\n"); + /* Initialize GAPS */ + if(gaps_init() < 0) return -1; - } - - /* Enable writing to the config registers */ - g2_write_8(NIC(RT_CFG9346), 0xc0); /* Read MAC address */ tmp = g2_read_32(NIC(RT_IDR0)); @@ -263,7 +296,50 @@ static int bba_hw_init(void) { rtl.mac[0], rtl.mac[1], rtl.mac[2], rtl.mac[3], rtl.mac[4], rtl.mac[5]); - /* Enable receive and transmit functions */ + /* Reset the chip and wait for it to come back */ + if(rtl_reset() < 0) + return -2; + + /* Setup RX buffer */ + g2_write_32(NIC(RT_RXBUF), RTL_MEM); + + /* Setup TX buffers */ + for(tmp=0; tmp<TX_NB_BUFFERS; tmp++) + g2_write_32(NIC(RT_TXADDR0 + (tmp*4)), RTL_MEM + (tmp* TX_BUFFER_LEN) + TX_BUFFER_OFFSET); + + /* Magic reset */ + if(rtl_reset() < 0) + return -3; + + /* Perform some magic enable/disable dance */ + g2_write_8(NIC(RT_CHIPCMD), RT_CMD_RX_ENABLE); + + if(g2_read_8(NIC(RT_CHIPCMD)) == RT_CMD_RX_ENABLE) { + g2_write_8(NIC(RT_CHIPCMD), RT_CMD_TX_ENABLE); + + if(g2_read_8(NIC(RT_CHIPCMD)) == RT_CMD_TX_ENABLE) { + /* Disable RX and TX */ + g2_write_8(NIC(RT_CHIPCMD), 0); + } + } + + /* Now a dance with the Multicast Register before Enabling */ + g2_write_32(NIC(RT_MAR0), 0x55aaff00); + g2_write_32(NIC(RT_MAR4), 0xaa5500ff); + + if((g2_read_32(NIC(RT_MAR0)) == 0x55aaff00) && + (g2_read_32(NIC(RT_MAR4)) == 0xaa5500ff)) { + /* Enable receive and transmit functions */ + g2_write_8(NIC(RT_CHIPCMD), RT_CMD_RX_ENABLE | RT_CMD_TX_ENABLE); + + g2_write_32(NIC(RT_MAR0), 0xffffffff); + g2_write_32(NIC(RT_MAR4), 0xffffffff); + } + + /* Disable all interrupts */ + g2_write_16(NIC(RT_INTRMASK), 0); + + /* Enable receive and transmit functions ... again*/ g2_write_8(NIC(RT_CHIPCMD), RT_CMD_RX_ENABLE | RT_CMD_TX_ENABLE); /* Set Rx FIFO threashold to 1K, Rx size to 16k+16, 1024 byte DMA burst */ @@ -272,31 +348,25 @@ static int bba_hw_init(void) { /* Set Tx 1024 byte DMA burst */ g2_write_32(NIC(RT_TXCONFIG), TX_CONFIG); - /* Turn off lan-wake and set the driver-loaded bit */ - g2_write_8(NIC(RT_CONFIG1), (g2_read_8(NIC(RT_CONFIG1)) & ~0x30) | 0x20); + /* Enable writing to the config registers */ + g2_write_8(NIC(RT_CFG9346), 0xc0); + + /* Old style would turn of LWACT and on DVRLOAD. New also disables LED0 and enables LED1 */ + g2_write_8(NIC(RT_CONFIG1), (g2_read_8(NIC(RT_CONFIG1)) & + ~(RT_CONFIG1_LWACT | RT_CONFIG1_LED0)) | RT_CONFIG1_DVRLOAD | RT_CONFIG1_LED1); /* Enable FIFO auto-clear */ - g2_write_8(NIC(RT_CONFIG4), g2_read_8(NIC(RT_CONFIG4)) | 0x80); + g2_write_8(NIC(RT_CONFIG4), g2_read_8(NIC(RT_CONFIG4)) | RT_CONFIG4_RxFIFIOAC); + + /* Disable Link-Down Power Saver */ + g2_write_8(NIC(RT_CONFIG5), g2_read_8(NIC(RT_CONFIG5)) | RT_CONFIG5_LDPS); /* Switch back to normal operation mode */ g2_write_8(NIC(RT_CFG9346), 0); - /* Setup RX buffer */ - g2_write_32(NIC(RT_RXBUF), RTL_MEM); - - /* Setup TX buffers */ - for(i=0; i<TX_NB_BUFFERS; i++) - g2_write_32(NIC(RT_TXADDR0 + (i*4)), RTL_MEM + (i* TX_BUFFER_LEN) + TX_BUFFER_OFFSET); - - /* Reset RXMISSED counter */ - g2_write_32(NIC(RT_RXMISSED), 0); - - /* Enable receiving broadcast and physical match packets */ - g2_write_32(NIC(RT_RXCONFIG), g2_read_32(NIC(RT_RXCONFIG)) | 0x0000000a); - /* Filter out all multicast packets */ - g2_write_32(NIC(RT_MAR0 + 0), 0); - g2_write_32(NIC(RT_MAR0 + 4), 0); + g2_write_32(NIC(RT_MAR0), 0); + g2_write_32(NIC(RT_MAR4), 0); /* Disable all multi-interrupts */ g2_write_16(NIC(RT_MULTIINTR), 0); @@ -318,13 +388,22 @@ static int bba_hw_init(void) { RT_INT_RX_ERR | RT_INT_RX_OK); + /* Reset RXMISSED counter */ + g2_write_32(NIC(RT_RXMISSED), 0); + /* Enable RX/TX once more */ g2_write_8(NIC(RT_CHIPCMD), RT_CMD_RX_ENABLE | RT_CMD_TX_ENABLE); + /* Reset, Enable, and start auto-negotiation */ + g2_write_16(NIC(RT_MII_BMCR), RT_MII_RESET | RT_MII_AN_ENABLE | RT_MII_AN_START); + /* Initialize status vars */ rtl.cur_tx = 0; rtl.cur_rx = 0; + /* Enable receiving broadcast and physical match packets */ + g2_write_32(NIC(RT_RXCONFIG), g2_read_32(NIC(RT_RXCONFIG)) | 0x0000000a); + return 0; } @@ -635,10 +714,15 @@ static int bba_tx(const uint8 * pkt, int len, int wait) #endif { /* - int i; + int i; - printf("Transmitting packet:\r\n"); for(i=0; i<len; i++) { printf("%02x ", pkt[i]); if(i - && !(i % 16)) printf("\r\n"); } printf("\r\n"); + dbglog(DBG_KDEBUG,"Transmitting packet:\r\n"); + for(i=0; i<len; i++) { + dbglog(DBG_KDEBUG,"%02x ", pkt[i]); + if(i && !(i % 16)) + printf("\r\n"); + } + dbglog(DBG_KDEBUG,"\r\n"); */ //wait = BBA_TX_WAIT; @@ -779,7 +863,7 @@ static void bba_rx(void) { pkt_size = rx_size - 4; if(rx_size == 0xfff0) { - //dbglog(DBG_KDEBUG, "bba: early receive triggered\n"); + dbglog(DBG_KDEBUG, "bba: early receive triggered\n"); break; } @@ -1079,8 +1163,8 @@ static int bba_if_set_mc(netif_t *self, const uint8 *list, int count) { if(count == 0) { /* Clear the multicast address filter */ - g2_write_32(NIC(RT_MAR0 + 0), 0); - g2_write_32(NIC(RT_MAR0 + 4), 0); + g2_write_32(NIC(RT_MAR0), 0); + g2_write_32(NIC(RT_MAR4), 0); /* Disable multicast reception */ old = g2_read_32(NIC(RT_RXCONFIG)); @@ -1098,8 +1182,8 @@ static int bba_if_set_mc(netif_t *self, const uint8 *list, int count) { } /* Set the multicast address filter */ - g2_write_32(NIC(RT_MAR0 + 0), mar[0]); - g2_write_32(NIC(RT_MAR0 + 4), mar[1]); + g2_write_32(NIC(RT_MAR0), mar[0]); + g2_write_32(NIC(RT_MAR4), mar[1]); /* Enable multicast reception */ old = g2_read_32(NIC(RT_RXCONFIG)); diff --git a/kernel/arch/dreamcast/include/dc/net/broadband_adapter.h b/kernel/arch/dreamcast/include/dc/net/broadband_adapter.h index f1f1bd4..7054b73 100644 --- a/kernel/arch/dreamcast/include/dc/net/broadband_adapter.h +++ b/kernel/arch/dreamcast/include/dc/net/broadband_adapter.h @@ -22,46 +22,83 @@ __BEGIN_DECLS /** \defgroup bba_regs RTL8139C Register Definitions + + The default assumption is that these are all RW at any aligned size unless + otherwise noted. ex (RW 32bit, RO 16/8) indicates read/write at 32bit and + read-only at 16 or 8bits. + @{ */ -#define RT_IDR0 0x00 /**< \brief MAC address */ -#define RT_MAR0 0x08 /**< \brief Multicast filter */ -#define RT_TXSTATUS0 0x10 /**< \brief Transmit status (4 32bit regs) */ -#define RT_TXADDR0 0x20 /**< \brief Tx descriptors (also 4 32bit) */ -#define RT_RXBUF 0x30 /**< \brief Receive buffer start address */ -#define RT_RXEARLYCNT 0x34 /**< \brief Early Rx byte count */ -#define RT_RXEARLYSTATUS 0x36 /**< \brief Early Rx status */ +#define RT_IDR0 0x00 /**< \brief MAC address 0 (RW 32bit, RO 16/8) */ +#define RT_IDR1 0x01 /**< \brief MAC address 1 (Read-only) */ +#define RT_IDR2 0x02 /**< \brief MAC address 2 (Read-only) */ +#define RT_IDR3 0x03 /**< \brief MAC address 3 (Read-only) */ +#define RT_IDR4 0x04 /**< \brief MAC address 4 (RW 32bit, RO 16/8) */ +#define RT_IDR5 0x05 /**< \brief MAC address 5 (Read-only) */ +#define RT_RES06 0x06 /**< \brief Reserved */ +#define RT_RES07 0x07 /**< \brief Reserved */ +#define RT_MAR0 0x08 /**< \brief Multicast filter 0 (RW 32bit, RO 16/8) */ +#define RT_MAR1 0x09 /**< \brief Multicast filter 1 (Read-only) */ +#define RT_MAR2 0x0A /**< \brief Multicast filter 2 (Read-only) */ +#define RT_MAR3 0x0B /**< \brief Multicast filter 3 (Read-only) */ +#define RT_MAR4 0x0C /**< \brief Multicast filter 4 (RW 32bit, RO 16/8) */ +#define RT_MAR5 0x0D /**< \brief Multicast filter 5 (Read-only) */ +#define RT_MAR6 0x0E /**< \brief Multicast filter 6 (Read-only) */ +#define RT_MAR7 0x0F /**< \brief Multicast filter 7 (Read-only) */ +#define RT_TXSTATUS0 0x10 /**< \brief Transmit status 0 (32bit only) */ +#define RT_TXSTATUS1 0x14 /**< \brief Transmit status 1 (32bit only) */ +#define RT_TXSTATUS2 0x18 /**< \brief Transmit status 2 (32bit only) */ +#define RT_TXSTATUS3 0x1C /**< \brief Transmit status 3 (32bit only) */ +#define RT_TXADDR0 0x20 /**< \brief Tx descriptor 0 (32bit only) */ +#define RT_TXADDR1 0x24 /**< \brief Tx descriptor 1 (32bit only) */ +#define RT_TXADDR2 0x28 /**< \brief Tx descriptor 2 (32bit only) */ +#define RT_TXADDR3 0x2C /**< \brief Tx descriptor 3 (32bit only) */ +#define RT_RXBUF 0x30 /**< \brief Receive buffer start address (32bit only) */ +#define RT_RXEARLYCNT 0x34 /**< \brief Early Rx byte count (RO 16bit) */ +#define RT_RXEARLYSTATUS 0x36 /**< \brief Early Rx status (RO) */ #define RT_CHIPCMD 0x37 /**< \brief Command register */ -#define RT_RXBUFTAIL 0x38 /**< \brief Current address of packet read (queue tail) */ -#define RT_RXBUFHEAD 0x3A /**< \brief Current buffer address (queue head) */ -#define RT_INTRMASK 0x3C /**< \brief Interrupt mask */ -#define RT_INTRSTATUS 0x3E /**< \brief Interrupt status */ -#define RT_TXCONFIG 0x40 /**< \brief Tx config */ -#define RT_RXCONFIG 0x44 /**< \brief Rx config */ -#define RT_TIMER 0x48 /**< \brief A general purpose counter */ -#define RT_RXMISSED 0x4C /**< \brief 24 bits valid, write clears */ +#define RT_RXBUFTAIL 0x38 /**< \brief Current address of packet read (queue tail) (16bit only) */ +#define RT_RXBUFHEAD 0x3A /**< \brief Current buffer address (queue head) (RO 16bit) */ +#define RT_INTRMASK 0x3C /**< \brief Interrupt mask (16bit only) */ +#define RT_INTRSTATUS 0x3E /**< \brief Interrupt status (16bit only) */ +#define RT_TXCONFIG 0x40 /**< \brief Tx config (32bit only) */ +#define RT_RXCONFIG 0x44 /**< \brief Rx config (32bit only) */ +#define RT_TIMER 0x48 /**< \brief A general purpose counter, any write clears (32bit only) */ +#define RT_RXMISSED 0x4C /**< \brief 24 bits valid, write clears (32bit only) */ #define RT_CFG9346 0x50 /**< \brief 93C46 command register */ #define RT_CONFIG0 0x51 /**< \brief Configuration reg 0 */ #define RT_CONFIG1 0x52 /**< \brief Configuration reg 1 */ -#define RT_TIMERINT 0x54 /**< \brief Timer interrupt register (32 bits) */ +#define RT_RES53 0x53 /**< \brief Reserved */ +#define RT_TIMERINT 0x54 /**< \brief Timer interrupt register (32bit only) */ #define RT_MEDIASTATUS 0x58 /**< \brief Media status register */ #define RT_CONFIG3 0x59 /**< \brief Config register 3 */ #define RT_CONFIG4 0x5A /**< \brief Config register 4 */ -#define RT_MULTIINTR 0x5C /**< \brief Multiple interrupt select */ -#define RT_MII_TSAD 0x60 /**< \brief Transmit status of all descriptors (16 bits) */ -#define RT_MII_BMCR 0x62 /**< \brief Basic Mode Control Register (16 bits) */ -#define RT_MII_BMSR 0x64 /**< \brief Basic Mode Status Register (16 bits) */ -#define RT_AS_ADVERT 0x66 /**< \brief Auto-negotiation advertisement reg (16 bits) */ -#define RT_AS_LPAR 0x68 /**< \brief Auto-negotiation link partner reg (16 bits) */ -#define RT_AS_EXPANSION 0x6A /**< \brief Auto-negotiation expansion reg (16 bits) */ +#define RT_RES5B 0x5B /**< \brief Reserved */ +#define RT_MULTIINTR 0x5C /**< \brief Multiple interrupt select (32bit only) */ +#define RT_RERID 0x5E /**< \brief PCI Revision ID (10h) (Read-only) */ +#define RT_RES5F 0x5F /**< \brief Reserved */ +#define RT_MII_TSAD 0x60 /**< \brief Transmit status of all descriptors (RO 16bit) */ +#define RT_MII_BMCR 0x62 /**< \brief Basic Mode Control Register (16bit only) */ +#define RT_MII_BMSR 0x64 /**< \brief Basic Mode Status Register (RO 16bit) */ +#define RT_AS_ADVERT 0x66 /**< \brief Auto-negotiation advertisement reg (16bit only) */ +#define RT_AS_LPAR 0x68 /**< \brief Auto-negotiation link partner reg (RO 16bit) */ +#define RT_AS_EXPANSION 0x6A /**< \brief Auto-negotiation expansion reg (RO 16bit) */ + +#define RT_CONFIG5 0xD8 /**< \brief Config register 5 */ /** @} */ /** \defgroup bba_miicb RTL8139C MII (media independent interface) control bits @{ */ -#define RT_MII_AN_START 0x0200 /**< \brief Start auto-negotiation */ -#define RT_MII_AN_ENABLE 0x1000 /**< \brief Enable auto-negotiation */ -#define RT_MII_RESET 0x8000 /**< \brief Reset the MII chip */ +#define RT_MII_RESET 0x8000 /**< \brief Reset the MII chip */ +#define RT_MII_RES4000 0x4000 /**< \brief Reserved */ +#define RT_MII_SPD_SET 0x2000 /**< \brief 1 for 100 0 for 10. Ignored if AN enabled. */ +#define RT_MII_AN_ENABLE 0x1000 /**< \brief Enable auto-negotiation */ +#define RT_MII_RES0800 0x0800 /**< \brief Reserved */ +#define RT_MII_RES0400 0x0400 /**< \brief Reserved */ +#define RT_MII_AN_START 0x0200 /**< \brief Start auto-negotiation */ +#define RT_MII_DUPLEX 0x0100 /**< \brief 1 for full 0 for half. Ignored if AN enabled. */ + /** @} */ /** \defgroup bba_miisb RTL8139C MII (media independent interface) status bits @@ -133,6 +170,54 @@ __BEGIN_DECLS #define RT_RX_STATUS_OK 0x00000001 /**< \brief Status ok: a good packet was received */ /** @} */ ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-05-19 03:24:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 308a1bbc2f95c0f9aa44982f4f9bf7334ddef207 (commit) via f3213427722638d277a845888885976166ae4e15 (commit) from a9ae48e55b87757d5c657ed8d7f510e6fe36c9dd (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 308a1bbc2f95c0f9aa44982f4f9bf7334ddef207 Merge: a9ae48e f321342 Author: darcagn <da...@pr...> Date: Thu May 18 22:23:59 2023 -0500 Merge pull request #201 from KallistiOS/Doxygen_MainPage Set Doxygen main page to updated README.md commit f3213427722638d277a845888885976166ae4e15 Author: Falco Girgis <gyr...@gm...> Date: Wed May 17 17:34:53 2023 -0500 Set Doxygen main page to updated README.md - Doxygen's main page is now generated from the main README.md file for the GitHub index page - Also updated the page a tiny bit ----------------------------------------------------------------------- Summary of changes: README.md | 8 ++++---- doc/Doxyfile | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c03f033..cebaf0c 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ KOS is an unofficial development environment for the SEGA Dreamcast game console KOS was developed from scratch over the internet by a group of free software developers and has no relation to the official Sega Katana or Microsoft Windows CE Dreamcast development kits. This has allowed it to fuel a thriving Dreamcast homebrew scene, powering many commercial releases for the platform over the years. It supports a signficiant portion of the Dreamcast's hardware capabilities and a wide variety of peripherals, accessories, and add-ons for the console, including custom hardware modifications that have been created by the scene. -Despite the console's age, KOS offers an extremely modern, programmer-friendly development environment, supporting C17 and C++20, with the majority of their standard libraries fully supported and additional support for many POSIX APIs. Additionally, KOS-ports offers a rich set of add-on libraries such as SDL, OpenGL, and Lua for the platform. +Despite the console's age, KOS offers an extremely modern, programmer-friendly development environment, supporting portions of C23 and C++23, with the majority of their standard libraries fully supported and additional support for many POSIX APIs. Additionally, KOS-ports offers a rich set of add-on libraries such as SDL, OpenGL, and Lua for the platform. ## Features ##### Core Functionality -* Concurrency with Kernel Threads, C11 Threads, pthreads +* Concurrency with Kernel Threads, C11 Threads, C++11 `std::thread`, Pthreads * Virtual filesystem abstraction * IPv4/IPv6 Network stack * Dynamically loading libraries/modules @@ -47,7 +47,7 @@ Despite the console's age, KOS offers an extremely modern, programmer-friendly d * Custom BIOS Flashroms ## Getting Started -A beginner's guide to development for the Sega Dreamcast along with detailed instructions for installing KOS and the required toolchains can be found on the [Dreamcast Wiki](https://dreamcast.wiki/Getting_Started_with_Dreamcast_development). Additional documentation can be found in the docs folder. +A beginner's guide to development for the Sega Dreamcast along with detailed instructions for installing KOS and the required toolchains can be found on the [Dreamcast Wiki](https://dreamcast.wiki/Getting_Started_with_Dreamcast_development). Additional documentation can be found in the docs folder. ## Examples Once you've set up the environment and are ready to begin developing, a good place to start learning is the examples directory, which provides demos for the various KOS APIs and for interacting with the Dreamcast's hardware. Examples include: @@ -79,5 +79,5 @@ Once you've set up the environment and are ready to begin developing, a good pla [DCEmulation Forums](http://dcemulation.org/phpBB/viewforum.php?f=29): Goldmine of Dreamcast development information and history [Dreamcast Wiki](http://dreamcast.wiki): Large collection of tutorials and articles for beginners [Simulant Discord Chat](https://discord.gg/bpDZHT78PA): Home to the official Discord channel of KOS -IRC Channel: irc.libera.chat #dreamcastdev +IRC Channel: irc.libera.chat `#dreamcastdev` diff --git a/doc/Doxyfile b/doc/Doxyfile index 726ac5c..0193040 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -54,7 +54,7 @@ PROJECT_NUMBER = "##version##" # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = +PROJECT_BRIEF = Independent SDK for the Sega Dreamcast # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -909,7 +909,8 @@ WARN_LOGFILE = INPUT = $(KOS_BASE)/include \ $(KOS_BASE)/kernel/arch/$(KOS_ARCH)/include \ - $(KOS_BASE)/addons/include + $(KOS_BASE)/addons/include \ + $(KOS_BASE)/README.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -1078,7 +1079,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +USE_MDFILE_AS_MAINPAGE = $(KOS_BASE)/README.md # The Fortran standard specifies that for fixed formatted Fortran code all # characters from position 72 are to be considered as comment. A common @@ -1600,7 +1601,7 @@ DISABLE_INDEX = NO # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = YES # When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the # FULL_SIDEBAR option determines if the side bar is limited to only the treeview @@ -1612,7 +1613,7 @@ GENERATE_TREEVIEW = NO # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -FULL_SIDEBAR = NO +FULL_SIDEBAR = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |