From: quzar <qu...@us...> - 2025-04-10 20:03:51
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e120412ac981ce36e51c941d03e0db2608651992 (commit) via 6822d9db85a739b1b19146b0373e81677cb11338 (commit) via d9e4ac836288aeaf6a514bc5177243db8e71b133 (commit) via 95f8f2d48c95bf8ac970191ce9d3a1d3a30ff377 (commit) via 6b54707a5f3045c357b337942349530a3eb50265 (commit) via 08385c8de32bbb2af6dcb48ce427581061f3ed68 (commit) via ee5d32fff3411afd6385423b640b87ca7714a199 (commit) via 91e60459f01b4838c8c7af718e280d1b7ab03b01 (commit) via 205aaeb6922032afa6ba9361e7278ab14bfc2320 (commit) via bcc9b7506ad5ab39700793cb38cd2879fdf0c4d3 (commit) via 2802ae7a595f0a9a075bed2efc203bb8732fc3b4 (commit) via e1e2503f1be90216ef5ff577ff68532f6377e2bf (commit) via 1b5429bf39092df76565c9f22aaca45ad56d736b (commit) via 129d18af3a4af0336f74bce374bb5ad163a249c6 (commit) via edf52edd38e99921f644e60ba0a0f1f5e9cda7a8 (commit) via 3e4d1bb12cca8fb90b42f5f9405c199aca8a31e9 (commit) via 5573c8eed2e1ecb2e82c6a984691dd9917227b5d (commit) via 0c4a7d8d41f7d28513cdea12985752f47ee424ef (commit) via 996b01f05386ff12bc4906f08d37dba386f71d33 (commit) via 5d33e5ac74b59804d78305a355532e663164b8f3 (commit) via 0b56ee924d97f9f5e1d6e1ae1b34da95f63faffd (commit) via 33101bdfa56550c68d7d6e055b514d387d06df0c (commit) via b7df027e03cd329bf2341d48cec65d9931287c80 (commit) via 43b0f9a01973c063c513f5efbc7b2ed7f0df4d67 (commit) via ef8308b1e5ecf26f8b24502eb1b2e04cfde321b4 (commit) via aa5bbb791e7b37e0ee1dfaf53e8a16d15f4f6726 (commit) via 3b354a4b4246ae154c3fc1c70846a6b04e1a5de7 (commit) via 80308bc44e30f0c92a05f7e8a4ac82c6e1a072b9 (commit) via d286105ed5403ae0079043956a21e9c8dd643763 (commit) via d665cdae34a4ae6bb2ef5ccd02c450e4077fb5f2 (commit) via 5ac08737d0d026e43254c3028e0d5829e0f14d4a (commit) via dca7f6d86be234b6488bd9d7e05aef0fa10f8d96 (commit) via fcae791265eee3fa3644316b3bbdb70563b4b290 (commit) via 4934bfbae4cfeb45c7ed57a41f5feadf5d2a2c51 (commit) via 78ec0f239d4d1cf7bb5eb6c3d7fde91d9aec05ea (commit) via 5685e822b02e49e80b1d3e46541686c8ce133b49 (commit) via 3a7cff13340b98ceeb153878147a5653fba82cdf (commit) via 20279fc53ad8e17f458fbb05c0c1cdd42fe0ab81 (commit) via 0771070cc741ff513d09ecefb92cf23a9c21e34c (commit) via 08a94a5cead642470d0185b6ec4eefb5a7695514 (commit) via 9da83b9007c3d4e0de1df08cd6d35984d4cababb (commit) via 73b0c14a9f64f1937f4ed207746dd89101897f89 (commit) via 2e18edca61a8357c5c149f14ddfa984b06b2817a (commit) via b1453c5fbd68c68a3e5bb0a3af9dc6b543a47182 (commit) via 58e06b91648b0dca27c6ae603aeffe5b2cb42ce8 (commit) from f94e9a5b4bb8cfc281fa00884bb04e3da510eb96 (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 e120412ac981ce36e51c941d03e0db2608651992 Author: QuzarDC <qu...@co...> Date: Fri Mar 21 21:53:25 2025 -0400 Reduce duplicated thread scheduling code. Slight refactor that deduplicates a sequence that was used 3 times in thread.c . This has the side effect of introducing stack overrun testing during manual thread rescheduling via `thd_schedule_next`. commit 6822d9db85a739b1b19146b0373e81677cb11338 Author: QuzarDC <qu...@co...> Date: Fri Mar 21 21:39:32 2025 -0400 Add arch/tls_static Move arch-dependent static TLS functionality out of kos/thread. Previously the SH-specific implementation details were hardcoded into otherwise platform-independent code. commit d9e4ac836288aeaf6a514bc5177243db8e71b133 Author: QuzarDC <qu...@co...> Date: Thu Mar 20 22:49:06 2025 -0400 Clean up thd_create_tls_data First, adjust it to signal failure for simple memory allocation, as out of memory is normally recoverable. Second, move the setting of the gbr register into the tls data creation. This will facilitate moving the function out of thread.c into an arch-specific file by having all the SH-specific code together. Now, you pass the kthread that you want tls data created for and the function does the rest of the related work. commit 95f8f2d48c95bf8ac970191ce9d3a1d3a30ff377 Author: Paul Cercueil <pa...@cr...> Date: Thu Apr 3 11:19:31 2025 +0200 pvr: Rename 'ta_ready' variable It was looking a bit strange in the pvr_start_ta_rendering() function to have the following: ta_ready = 1; ta_busy = 1; Rename the 'ta_ready' variable to 'ta_checked_ready', since the information it really contains is whether or not we already checked that the TA was ready in the current scene, and not if it is ready at this exact moment. Signed-off-by: Paul Cercueil <pa...@cr...> commit 6b54707a5f3045c357b337942349530a3eb50265 Author: Paul Cercueil <pa...@cr...> Date: Thu Apr 3 02:21:49 2025 +0200 pvr: Fix race between driver and TA The driver was calling pvr_start_ta_rendering() at two different spots: when a non-DMA list was opened, or in the pvr_scene_finish() function before uploading DMA lists. This function would wait for the TA to be ready (if not previously done), then mark it as "busy" again. However, in the specific case where the DMA feature was enabled but no lists were actually configured for DMA transfers, and for a simple enough scene, it was possible for the TA to complete before the second call of pvr_start_ta_rendering(), causing it to reset the "busy" flag once again, which would then never be cleared by the IRQ handler. This caused any following call to pvr_wait_ready() to timeout, dropping the framerate to 5 fps or lower. Fix this race by only setting the "busy" flag once, as we only need to set it in the first call (whichever it is) of pvr_start_ta_rendering(). Signed-off-by: Paul Cercueil <pa...@cr...> commit 08385c8de32bbb2af6dcb48ce427581061f3ed68 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 18:17:11 2025 -0400 Clean up doxygen structure. Remove duplicated insertions of documentation to the top level kbd group. Add a predefined exception for the `__depr` (deprecation with a message) macro. commit ee5d32fff3411afd6385423b640b87ca7714a199 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 16:26:53 2025 -0400 Add new public function kbd_key_to_ascii This makes public the translation functionality from kbd_queue_pop. It required moving the definition of the region type, but no changes to it. commit 91e60459f01b4838c8c7af718e280d1b7ab03b01 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 15:50:42 2025 -0400 Deprecate public kbd_keymap_t Move to a private version. Leaving a deprecated stub as this was never noted as being internal (it just didn't make much sense to use it externally, perhaps as a way to support keyboard layouts we don't). commit 205aaeb6922032afa6ba9361e7278ab14bfc2320 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 12:45:02 2025 -0400 Use new kbd_mods, kbd_leds, and kbd_key types. Shift over internal data structures and functions to use these new types. Introduces new internal type for queued keypresses (`kbd_q_key_t`) that wraps the three new types that used to be just bitpacked into an int. In `kbd_enqueue` no longer pass 'mods' as the same is already available via the keyboard state. Additionally use the defined keycode rather than literal 1 for ERROR, and the compile time static sizeof keymap rather than the hardcoded size of it. In `kbd_queue_pop` access the mods/led data from the `kbd_q_key` type rather than the bitpacking, and use the correct led define for caps lock. The old kbd_state `shift_keys` int is incompatible with these new usages so it has been replaced by a new `last_modifiers` kbd_mods_t. It has been set up to allow friendly deprecation. Changes in `kbd_check_poll` follow the change of `shift keys` as well as the params change of `kbd_enqueue`. commit bcc9b7506ad5ab39700793cb38cd2879fdf0c4d3 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 09:52:03 2025 -0400 Remove extraneous error check. The region parameter is only set during attach, and it is guaranteed to be valid based on that. Thus this error condition can never be triggered. commit 2802ae7a595f0a9a075bed2efc203bb8732fc3b4 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 03:15:29 2025 -0400 Move private data members out of public kbd_state_t. These values had been marked as being internal when first introduced, just due to lack of the mechanism being used here. The private struct size will be the status size in the driver definition. With this new mechanism, it's also possible to simplify the initialization of the private struct data rather than individually setting each to 0. Additionally, some minor whitespace, define, and typing fixes. commit e1e2503f1be90216ef5ff577ff68532f6377e2bf Author: QuzarDC <qu...@co...> Date: Mon Apr 7 02:41:55 2025 -0400 Clean up keyboard example. Add clarifying comments and defines. Use escape characters rather than hex. Update kbd_queue_pop usage. commit 1b5429bf39092df76565c9f22aaca45ad56d736b Author: QuzarDC <qu...@co...> Date: Mon Apr 7 02:14:40 2025 -0400 Update keyboard example to not require controller. Previously if no controller was found, the example would just quit, despite the controller just being for optional exiting via START. commit 129d18af3a4af0336f74bce374bb5ad163a249c6 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 01:59:10 2025 -0400 Change kbd_queue_pop param to bool. Additionally adjust documentation to match and to remove some unclear language. commit edf52edd38e99921f644e60ba0a0f1f5e9cda7a8 Author: QuzarDC <qu...@co...> Date: Tue Apr 8 02:31:51 2025 -0400 Add kbd_set_repeat_timing, clean up repeating internals. The two loose static vars have been updated into a struct, and an accessor added to set the values. Additionally a small change was made so that if the repeat timing is set to 0 the timing is not pulled or tested at all. Previously, each poll would unnecessarily check the timer and store/test times. commit 3e4d1bb12cca8fb90b42f5f9405c199aca8a31e9 Author: QuzarDC <qu...@co...> Date: Mon Apr 7 01:00:02 2025 -0400 Add kbd_mods type, and update documentation for keyboard state. commit 5573c8eed2e1ecb2e82c6a984691dd9917227b5d Author: QuzarDC <qu...@co...> Date: Mon Apr 7 00:29:33 2025 -0400 Create define KBD_QUEUE_END. Replaces magic -1 for marking that there are no keys left in queue for kbd_queue_pop. commit 0c4a7d8d41f7d28513cdea12985752f47ee424ef Author: QuzarDC <qu...@co...> Date: Mon Apr 7 00:11:05 2025 -0400 Move kbd_key defines into enum from list of defines. The enum needs to be 'packed' so that its still just a byte in order to match the hardware data. commit 996b01f05386ff12bc4906f08d37dba386f71d33 Author: QuzarDC <qu...@co...> Date: Sun Apr 6 23:55:08 2025 -0400 Add kbd_input doxygen group. Enumerates and explains the two available methods for accessing keyboard data. commit 5d33e5ac74b59804d78305a355532e663164b8f3 Author: QuzarDC <qu...@co...> Date: Sun Apr 6 21:46:07 2025 -0400 Better handle unknown keyboard regions. Test against region = 0 which is also undefined, add debug output to note it, and clean up some spacing. commit 0b56ee924d97f9f5e1d6e1ae1b34da95f63faffd Author: QuzarDC <qu...@co...> Date: Sun Apr 6 21:16:44 2025 -0400 Add accessor for keyboard state. Useful for safely working with a kbd_state_t, no need to blindly cast from the generic maple state. Additionally add doxygen commentary for the usage of directly polling the kbd state. commit 33101bdfa56550c68d7d6e055b514d387d06df0c Author: QuzarDC <qu...@co...> Date: Sun Apr 6 20:34:38 2025 -0400 Move deprecated functions to end of header. commit b7df027e03cd329bf2341d48cec65d9931287c80 Author: QuzarDC <qu...@co...> Date: Sun Apr 6 14:35:50 2025 -0400 Update to stdint types. commit 43b0f9a01973c063c513f5efbc7b2ed7f0df4d67 Author: QuzarDC <qu...@co...> Date: Sun Apr 6 14:28:28 2025 -0400 Update kbd_leds defines and add a type. Clean up kbd_led defines with dox and macros. Add new type to access the data. Fill in all previously undefined bits. commit ef8308b1e5ecf26f8b24502eb1b2e04cfde321b4 Author: QuzarDC <qu...@co...> Date: Sun Apr 6 10:50:21 2025 -0400 Create enum type for keyboard regions. This transparently replaces the existing defines. commit aa5bbb791e7b37e0ee1dfaf53e8a16d15f4f6726 Author: QuzarDC <qu...@co...> Date: Sun Apr 6 09:54:14 2025 -0400 Rename MAX_KBD_KEYS define to KBD_MAX_KEYS. This is more in-line with our naming conventions to start with the system name. A compatibility const was added to help with updating. commit 3b354a4b4246ae154c3fc1c70846a6b04e1a5de7 Author: Paul Cercueil <pa...@cr...> Date: Sun Apr 6 11:38:00 2025 +0200 fs_vmu: Fix seeking in files with headers My recent change with VMU headers worked as long as applications did not try to use fs_seek(). The problem was then that the beginning of the file was set relative to the actual beginning, before the header, and not after the header. The fix is to consider that the cursor position is always relative to the start of the file, and the start of the file being the address after the file header, if there is one. Signed-off-by: Paul Cercueil <pa...@cr...> commit 80308bc44e30f0c92a05f7e8a4ac82c6e1a072b9 Author: Paul Cercueil <pa...@cr...> Date: Tue Dec 31 20:18:05 2024 +0100 examples: vmu_pkg: Set file header using new function Instead of writing the header to the file itself, use fs_vmu_set_header() to assignate the header to the file. Signed-off-by: Paul Cercueil <pa...@cr...> commit d286105ed5403ae0079043956a21e9c8dd643763 Author: Paul Cercueil <pa...@cr...> Date: Wed Jan 1 14:33:54 2025 +0100 fs_vmu: Allow opening raw file with O_META flag When the O_META flag is passed to fs_open(), the VMU file header will not be kept internally, and will be able to be read as regular data. Signed-off-by: Paul Cercueil <pa...@cr...> commit d665cdae34a4ae6bb2ef5ccd02c450e4077fb5f2 Author: Paul Cercueil <pa...@cr...> Date: Tue Dec 31 20:05:04 2024 +0100 fs_vmu: Improve handling of VMU file headers - Add function fs_vmu_set_header(). This function can be used to set a specific header (which contains the metadata, icons...) to an opened VMU file, replacing the one it previously had (if any). - Add function fs_vmu_set_default_header(). This function will set a default header, that will be used for new files which were not assignated their own header. The header is now skipped when opening a VMU file (that has a header), which is a breaking change from the previous behaviour of KallistiOS. It is however kept internally, which means that a file opened read-write will reuse its header (unless overwritten by fs_vmu_set_header()). The point of this change is to hide the header from the application completely, which can now read/write the VMU files with a proper header as if they were PC files. It is then much easier for PC ports to read/write savestates that look good. Signed-off-by: Paul Cercueil <pa...@cr...> commit 5ac08737d0d026e43254c3028e0d5829e0f14d4a Author: Paul Cercueil <pa...@cr...> Date: Tue Dec 31 19:09:50 2024 +0100 vmu_pkg: Add "data_size" param to vmu_pkg_parse() This allows vmu_pkg_parse() to work (aka. not crash) with buffers that do not contain a VMU header. Signed-off-by: Paul Cercueil <pa...@cr...> commit dca7f6d86be234b6488bd9d7e05aef0fa10f8d96 Author: Paul Cercueil <pa...@cr...> Date: Wed Apr 2 14:08:02 2025 +0200 pvr: Fix render-to-texture Render-to-texture was broken since the recent changes that decoupled the Tile Accelerator with the PVR rendering. This was because the code checked the "render to texture" flag on the back buffer, which made sense back then, but now the back and front buffers can be flipped in the middle of a scene draw. This did not show in KOS' example for RTT (examples/dreamcast/pvr/texture_render/), for the reason that the code there was rendering fast enough to reach 60 fps and be throttled by VSYNC. Address this issue by keeping track of RTT for the next frame (the one for which we're preparing a new scene), and the current frame (being processed by the TA or being rendered by the PVR CORE), without taking the "view target" into account. Signed-off-by: Paul Cercueil <pa...@cr...> commit fcae791265eee3fa3644316b3bbdb70563b4b290 Author: Paul Cercueil <pa...@cr...> Date: Sat Mar 29 19:25:22 2025 +0100 vmufb: Add function vmufb_screen_shot() This function can be used to save a screenshot of a VMU framebuffer into a PBM image. Signed-off-by: Paul Cercueil <pa...@cr...> commit 4934bfbae4cfeb45c7ed57a41f5feadf5d2a2c51 Author: Paul Cercueil <pa...@cr...> Date: Thu Mar 27 18:06:47 2025 +0100 math: Add mat_multiply() This function is similar to mat_apply(), except that it does not write the result matrix back to the internal matrix, but to a destination pointer in memory. Signed-off-by: Paul Cercueil <pa...@cr...> commit 78ec0f239d4d1cf7bb5eb6c3d7fde91d9aec05ea Author: Tchan0 <617...@us...> Date: Sun Mar 23 10:10:06 2025 +0100 pvr_list_prim(): avoid buffer overflow In pvr_list_prim(), the assert to check for buffer overflow is done too late, after a potential memory corruption commit 5685e822b02e49e80b1d3e46541686c8ce133b49 Author: Ross Kilgariff <ros...@gm...> Date: Sun Mar 23 15:51:07 2025 +0000 Remove GDROM reset syscall as it causes an issue with GDEMU clones where the subsequent CMD_INIT is ignored because it's sent while the drive is in the BUSY status commit 3a7cff13340b98ceeb153878147a5653fba82cdf Merge: 20279fc5 73b0c14a Author: Lawrence Sebald <ljs...@us...> Date: Tue Mar 18 00:08:10 2025 -0400 Merge pull request #952 from KallistiOS/arch_perf Remove non-arch perf counter use / fix `thd_pslist` times commit 20279fc53ad8e17f458fbb05c0c1cdd42fe0ab81 Merge: b1453c5f 0771070c Author: Lawrence Sebald <ljs...@us...> Date: Tue Mar 18 00:07:05 2025 -0400 Merge pull request #953 from KallistiOS/arch_include_fixes A set of small changes around better arch separation. commit 0771070cc741ff513d09ecefb92cf23a9c21e34c Author: QuzarDC <qu...@co...> Date: Sat Mar 8 02:08:52 2025 -0500 Add `kos/init_base.h` include to newlib_exit. It needs init_base for the init flag macros. Currently it gets them from <arch/arch.h> but the inclusion of `kos/init.h` there is marked as for compat only so other archs shouldn't need to. Also remove extraneous stdbool. commit 08a94a5cead642470d0185b6ec4eefb5a7695514 Author: QuzarDC <qu...@co...> Date: Sat Mar 8 02:14:51 2025 -0500 Reduce scope of <arch/wdt.h>. As we dont require it in the kernel, moving <arch/wdt.h> to be gated by `dreamcast`. This should likely be moved to be a <dc/wdt.h> driver that the <arch/timer.h> api can tap intom, rather than an arch-level interface requirement. commit 9da83b9007c3d4e0de1df08cd6d35984d4cababb Author: QuzarDC <qu...@co...> Date: Sat Mar 8 02:18:09 2025 -0500 Don't hardcode the arch of the cmake toolchain files. Open up the structure to easily allow other archs to be added. commit 73b0c14a9f64f1937f4ed207746dd89101897f89 Author: QuzarDC <qu...@co...> Date: Thu Mar 6 21:25:11 2025 -0500 Ensure precision and consistency of the thread list printout. A number of changes were made in order to ensure the total timing of the thread list cpu_times would always reach 100%. First, IRQs are disabled before taking the first time measurements. This is important as, without doing so we could context switch away and skew the percentages. This was happening randomly in the general threading test. Second, we get the total time `ns_time` only once at the start of the listing. Otherwise when checking it repeatedly it will naturally skew as it grows duing the process of printing. To match with this, we update the current thread's time just before reading it. The small amount of time between those two operations ends up factoring into the new [system] line item. Third, adding a new line item [system]. This tracks the difference between the total `cpu_time` recorded for each thread and the clock. This not only helps account for the small chunk of time mentioned before but all the time taken between the updating of one thread's time and the new schedule time of the next thread that starts. With basic operation should should mostly track just context switching time, but can be significant when we're doing something like genwaiting on multiple objects as we'll be repeatedly jumping out of the idle thread to update them. With these changes the total percentages should always add up to exactly 100% (permitting possible rounding error) while before they would vary wildly in situations with lots of waits and idle time. commit 2e18edca61a8357c5c149f14ddfa984b06b2817a Author: QuzarDC <qu...@co...> Date: Wed Mar 5 18:06:36 2025 -0500 Remove perfcounter usage from time tracking functions. There were a number of issues with the usage of perf counters here. The biggest was that it violates the arch interface into KOS by directly digging into a dreamcast-specific driver from the outer threading/libc support. The second is that it simply unnecessary. I don't see anything in the descriptions of the usage to indicate that this has merits over the standard ns timer used elsewhere, and the mere usage of a separate timer with different qualities means that it's more likely to have discrepancies with our general ns timer-backed things. The third is that it's not accurate. Due to not counting sleep time the performance counters horribly undercount the amount of time spent in the idle thread, so the total time percentage of a `thd_pslist` would rarely add up to 100%. The last is that doing so allows us to move forward with a better way to streamline a perfcounter based timer into the API. commit b1453c5fbd68c68a3e5bb0a3af9dc6b543a47182 Merge: f94e9a5b 58e06b91 Author: Lawrence Sebald <ljs...@us...> Date: Sun Mar 2 00:43:44 2025 -0500 Merge pull request #949 from darcagn/chainmakefile Update profiles listed in Makefile.default.cfg commit 58e06b91648b0dca27c6ae603aeffe5b2cb42ce8 Author: darc <da...@pr...> Date: Sat Mar 1 19:49:47 2025 -0600 Update profiles listed in Makefile.default.cfg ----------------------------------------------------------------------- Summary of changes: doc/Doxyfile | 3 +- examples/dreamcast/libdream/keyboard/keyboard.c | 65 ++- examples/dreamcast/vmu/vmu_pkg/vmu.c | 5 +- include/kos.h | 2 +- include/kos/cdefs.h | 5 + include/kos/thread.h | 41 +- kernel/arch/dreamcast/fs/fs_vmu.c | 148 ++++- kernel/arch/dreamcast/hardware/cdrom.c | 2 - kernel/arch/dreamcast/hardware/maple/keyboard.c | 217 ++++--- kernel/arch/dreamcast/hardware/pvr/pvr_internal.h | 26 +- kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 17 +- kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 10 +- kernel/arch/dreamcast/hardware/pvr/pvr_scene.c | 34 +- kernel/arch/dreamcast/include/arch/tls_static.h | 65 +++ kernel/arch/dreamcast/include/dc/fs_vmu.h | 59 ++ kernel/arch/dreamcast/include/dc/maple/keyboard.h | 664 +++++++++++++++------- kernel/arch/dreamcast/include/dc/matrix.h | 16 + kernel/arch/dreamcast/include/dc/vmu_fb.h | 11 + kernel/arch/dreamcast/include/dc/vmu_pkg.h | 5 +- kernel/arch/dreamcast/kernel/Makefile | 2 +- kernel/arch/dreamcast/kernel/tls_static.c | 131 +++++ kernel/arch/dreamcast/math/matrix.s | 72 +++ kernel/arch/dreamcast/util/vmu_fb.c | 24 + kernel/arch/dreamcast/util/vmu_pkg.c | 7 +- kernel/libc/newlib/newlib_exit.c | 2 +- kernel/libc/newlib/newlib_times.c | 8 +- kernel/libc/posix/clock_gettime.c | 21 +- kernel/thread/thread.c | 211 +++---- utils/build_wrappers/kos-ccmake | 2 +- utils/build_wrappers/kos-cmake | 2 +- utils/dc-chain/Makefile.default.cfg | 19 +- 31 files changed, 1306 insertions(+), 590 deletions(-) create mode 100644 kernel/arch/dreamcast/include/arch/tls_static.h create mode 100644 kernel/arch/dreamcast/kernel/tls_static.c diff --git a/doc/Doxyfile b/doc/Doxyfile index 74abf0bf..a6b8c9c1 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -2268,7 +2268,8 @@ PREDEFINED = _arch_$(KOS_ARCH)=1 \ __END_DECLS= \ __extension__= \ __packed__= \ - __attribute__(x)= + __attribute__(x)= \ + __depr # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/examples/dreamcast/libdream/keyboard/keyboard.c b/examples/dreamcast/libdream/keyboard/keyboard.c index c020b432..2ff10b44 100644 --- a/examples/dreamcast/libdream/keyboard/keyboard.c +++ b/examples/dreamcast/libdream/keyboard/keyboard.c @@ -1,33 +1,34 @@ #include <kos.h> +#include <stdlib.h> + +/* Display constants */ +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 void kb_test(void) { maple_device_t *cont, *kbd; cont_state_t *state; - int k, x = 20, y = 20 + 24; + int k, x = 20, y = 20 + BFONT_HEIGHT; printf("Now doing keyboard test\n"); - while(1) { - cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + while(true) { + /* Query for the first detected controller */ + if((cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER))) { + /* Fetch controller button state structure. */ + state = maple_dev_status(cont); - if(!cont) continue; + /* Quit if start is pressed on the controller. */ + if(state->start) { + printf("Pressed start!\n"); + return; + } + } kbd = maple_enum_type(0, MAPLE_FUNC_KEYBOARD); if(!kbd) continue; - /* Check for start on the controller */ - state = (cont_state_t *)maple_dev_status(cont); - - if(!state) { - return; - } - - if(state->buttons & CONT_START) { - printf("Pressed start\n"); - return; - } - thd_sleep(10); /* Check for keyboard input */ @@ -36,23 +37,29 @@ void kb_test(void) { return; } */ - /* Get queued keys */ - while((k = kbd_queue_pop(kbd, 1)) != -1) { - if(k == 27) { + /* Keep popping keys while there are more enqueued. */ + while((k = kbd_queue_pop(kbd, true)) != KBD_QUEUE_END) { + /* Quit if ESC key is pressed. */ + if(k == '\e') { printf("ESC pressed\n"); return; } + /* Log when special keys are pressed. */ if(k > 0xff) printf("Special key %04x\n", k); - if(k != 13) { - bfont_draw(vram_s + y * 640 + x, 640, 0, k); - x += 12; + /* Handle every key that isn't the RETURN key. */ + if(k != '\r') { + /* Draw the key we just pressed. */ + bfont_draw(vram_s + y * SCREEN_WIDTH + x, SCREEN_WIDTH, 0, k); + + /* Advance the cursor horizontally. */ + x += BFONT_THIN_WIDTH; } else { x = 20; - y += 24; + y += BFONT_HEIGHT; } } @@ -63,15 +70,15 @@ void kb_test(void) { int main(int argc, char **argv) { int x, y; - for(y = 0; y < 480; y++) - for(x = 0; x < 640; x++) { + for(y = 0; y < SCREEN_HEIGHT; y++) + for(x = 0; x < SCREEN_WIDTH; x++) { int c = (x ^ y) & 255; - vram_s[y * 640 + x] = ((c >> 3) << 12) - | ((c >> 2) << 5) - | ((c >> 3) << 0); + vram_s[y * SCREEN_WIDTH + x] = ((c >> 3) << 12) + | ((c >> 2) << 5) + | ((c >> 3) << 0); } kb_test(); - return 0; + return EXIT_SUCCESS; } diff --git a/examples/dreamcast/vmu/vmu_pkg/vmu.c b/examples/dreamcast/vmu/vmu_pkg/vmu.c index 553ef9aa..2baa7979 100644 --- a/examples/dreamcast/vmu/vmu_pkg/vmu.c +++ b/examples/dreamcast/vmu/vmu_pkg/vmu.c @@ -98,8 +98,6 @@ void write_entry(void) { pkg.icon_data = vmu_icon; pkg.icon_anim_speed = 8; pkg.eyecatch_type = VMUPKG_EC_NONE; - pkg.data_len = 4096; - pkg.data = data; for(i = 0; i < 4096; i++) data[i] = i & 255; @@ -115,7 +113,8 @@ void write_entry(void) { return; } - fs_write(f, pkg_out, pkg_size); + fs_write(f, data, sizeof(data)); + fs_vmu_set_header(f, &pkg); fs_close(f); } diff --git a/include/kos.h b/include/kos.h index f2d48638..fbc7f41f 100644 --- a/include/kos.h +++ b/include/kos.h @@ -66,7 +66,6 @@ __BEGIN_DECLS #include <arch/irq.h> #include <arch/spinlock.h> #include <arch/timer.h> -#include <arch/wdt.h> #include <arch/types.h> #include <arch/exec.h> #include <arch/stack.h> @@ -77,6 +76,7 @@ __BEGIN_DECLS # include <arch/gdb.h> # include <arch/mmu.h> # include <arch/memory.h> +# include <arch/wdt.h> # include <dc/asic.h> # include <dc/biosfont.h> diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h index 0aa77349..f042b524 100644 --- a/include/kos/cdefs.h +++ b/include/kos/cdefs.h @@ -66,6 +66,11 @@ #define __weak __attribute__((weak)) #endif +#ifndef __packed +/** \brief Force a structure, enum, or other type to be packed as small as possible. */ +#define __packed __attribute__((packed)) +#endif + #ifndef __dead2 /** \brief Alias for \ref __noreturn. For BSD compatibility. */ #define __dead2 __noreturn /* BSD compat */ diff --git a/include/kos/thread.h b/include/kos/thread.h index f78d5b81..bccc836f 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -149,16 +149,7 @@ typedef enum kthread_state { STATE_FINISHED = 0x0004 /**< \brief Finished execution */ } kthread_state_t; -/** \brief Thread Control Block Header - Header preceding the static TLS data segments as defined by - the SH-ELF TLS ABI (version 1). This is what the thread pointer - (GBR) points to for compiler access to thread-local data. -*/ -typedef struct tcbhead { - void *dtv; /**< \brief Dynamic TLS vector (unused) */ - uintptr_t pointer_guard; /**< \brief Pointer guard (unused) */ -} tcbhead_t; /** \brief Structure describing one running thread. @@ -260,7 +251,7 @@ typedef __attribute__((aligned(32))) struct kthread { struct kthread_tls_kv_list tls_list; /** \brief Compiler-level thread-local storage. */ - tcbhead_t* tcbhead; + void *tls_hnd; /** \brief Return value of the thread function. @@ -608,26 +599,28 @@ int *thd_get_errno(kthread_t *thd); */ struct _reent *thd_get_reent(kthread_t *thd); - /** \brief Retrieves the thread's elapsed CPU time \relatesalso kthread_t Returns the amount of active CPU time the thread has consumed in nanoseconds. - \warning - The implementation uses perf_cntr_timer_ns() internally when maintaining - this CPU time, so disabling or clearing the nanosecond timer will - interfere with this time keeping. - - \param thd The thead to retrieve the CPU time for + \param thd The thead to retrieve the CPU time for. - \retval Total utilized CPU time in nanoseconds OR - 0 if the nanosecond timer of the performance - counters has been disturbed. + \retval Total utilized CPU time in nanoseconds. */ uint64_t thd_get_cpu_time(kthread_t *thd); +/** \brief Retrieves all thread's elapsed CPU time + \relatesalso kthread_t + + Returns the amount of active CPU time all threads have consumed in + nanoseconds. + + \retval Total utilized CPU time in nanoseconds. +*/ +uint64_t thd_get_total_cpu_time(void); + /** \brief Change threading modes. This function changes the current threading mode of the system. @@ -729,6 +722,14 @@ int thd_each(int (*cb)(kthread_t *thd, void *user_data), void *data); /** \brief Print a list of all threads using the given print function. + Each thread is printed with its address, tid, priority level, flags, + it's wait timeout (if sleeping) the amount of cpu time usage in ns + (this includes time in IRQs), state, and name. + + In addition a '[system]' item is provided that represents time since + initialization not spent in a thread (context switching, updating + wait timeouts, etc). + \param pf The printf-like function to print with. \retval 0 On success. diff --git a/kernel/arch/dreamcast/fs/fs_vmu.c b/kernel/arch/dreamcast/fs/fs_vmu.c index ab45f449..e28eb49b 100644 --- a/kernel/arch/dreamcast/fs/fs_vmu.c +++ b/kernel/arch/dreamcast/fs/fs_vmu.c @@ -18,6 +18,7 @@ #include <dc/vmufs.h> #include <dc/maple.h> #include <dc/maple/vmu.h> +#include <dc/vmu_pkg.h> #include <sys/queue.h> /* @@ -56,10 +57,13 @@ typedef struct vmu_fh_str { int mode; /* mode the file was opened with */ char path[17]; /* full path of the file */ char name[13]; /* name of the file */ - off_t loc; /* current position in the file (bytes) */ + off_t loc; /* current position from the start in the file (bytes) */ + off_t start; /* start of the data in the file (bytes) */ maple_device_t *dev; /* maple address of the vmu to use */ uint32 filesize; /* file length from dirent (in 512-byte blks) */ uint8 *data; /* copy of the whole file */ + vmu_pkg_t *header; /* VMU file header */ + bool raw; /* file opened as raw */ } vmu_fh_t; /* Directory handles */ @@ -81,6 +85,50 @@ TAILQ_HEAD(vmu_fh_list, vmu_fh_str) vmu_fh; /* Thread mutex for vmu_fh access */ static mutex_t fh_mutex; +static vmu_pkg_t *dft_header; + +static vmu_pkg_t * vmu_pkg_dup(const vmu_pkg_t *old_hdr) { + size_t ec_size, icon_size; + vmu_pkg_t *hdr; + + hdr = malloc(sizeof(*hdr)); + if(!hdr) + return NULL; + + memcpy(hdr, old_hdr, sizeof(*hdr)); + + if(old_hdr->eyecatch_type && old_hdr->eyecatch_data) { + ec_size = (72 * 56 / 2) << (3 - old_hdr->eyecatch_type); + + hdr->eyecatch_data = malloc(ec_size); + if(!hdr->eyecatch_data) + goto err_free_hdr; + + memcpy(hdr->eyecatch_data, old_hdr->eyecatch_data, ec_size); + } else { + hdr->eyecatch_data = NULL; + } + + if(old_hdr->icon_cnt) { + icon_size = 512 * old_hdr->icon_cnt; + + hdr->icon_data = malloc(icon_size); + if(!hdr->icon_data) + goto err_free_ec_data; + + memcpy(hdr->icon_data, old_hdr->icon_data, icon_size); + } else { + hdr->icon_data = NULL; + } + + return hdr; + +err_free_ec_data: + free(hdr->eyecatch_data); +err_free_hdr: + free(hdr); + return NULL; +} /* Take a VMUFS path and return the requested address */ static maple_device_t * vmu_path_to_addr(const char *p) { @@ -182,6 +230,7 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) int realmode, rv; void * data; int datasize; + vmu_pkg_t vmu_pkg; /* Malloc a new fh struct */ if(!(fd = malloc(sizeof(vmu_fh_t)))) @@ -193,7 +242,10 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) strncpy(fd->path, path, 16); strncpy(fd->name, path + 4, 12); fd->loc = 0; + fd->start = 0; fd->dev = dev; + fd->header = NULL; + fd->raw = mode & O_META; /* What mode are we opening in? If we're reading or writing without O_TRUNC then we need to read the old file if there is one. */ @@ -228,6 +280,9 @@ static vmu_fh_t *vmu_open_file(maple_device_t * dev, const char *path, int mode) } datasize = 512; memset(data, 0, 512); + } else if(!fd->raw && !vmu_pkg_parse(data, datasize, &vmu_pkg)) { + fd->header = vmu_pkg_dup(&vmu_pkg); + fd->start = (unsigned int)vmu_pkg.data - (unsigned int)data; } fd->data = (uint8 *)data; @@ -308,10 +363,30 @@ static int vmu_verify_hnd(void * hnd, int type) { /* write a file out before closing it: we aren't perfect on error handling here */ static int vmu_write_close(void * hnd) { - vmu_fh_t *fh; + vmu_fh_t *fh = (vmu_fh_t*)hnd; + uint8_t *data = fh->data + fh->start; + int ret, data_len = fh->filesize * 512; + vmu_pkg_t *hdr = fh->header ?: dft_header; + + if(!fh->raw) { + if(!hdr) { + dbglog(DBG_WARNING, "VMUFS: file written without header\n"); + } else { + hdr->data_len = data_len; + hdr->data = data; + + ret = vmu_pkg_build(hdr, &data, &data_len); + if(ret < 0) + return ret; + } + } + + ret = vmufs_write(fh->dev, fh->name, data, data_len, VMUFS_OVERWRITE); + + if(hdr) + free(data); - fh = (vmu_fh_t*)hnd; - return vmufs_write(fh->dev, fh->name, fh->data, fh->filesize * 512, VMUFS_OVERWRITE); + return ret; } /* close a file */ @@ -349,6 +424,11 @@ static int vmu_close(void * hnd) { } } + if(fh->header) { + free(fh->header->eyecatch_data); + free(fh->header->icon_data); + free(fh->header); + } free(fh->data); break; @@ -386,7 +466,7 @@ static ssize_t vmu_read(void * hnd, void *buffer, size_t cnt) { return 0; /* Copy out the data */ - memcpy(buffer, fh->data + fh->loc, cnt); + memcpy(buffer, fh->data + fh->loc + fh->start, cnt); fh->loc += cnt; return cnt; @@ -409,9 +489,9 @@ static ssize_t vmu_write(void * hnd, const void *buffer, size_t cnt) { return -1; /* Check to make sure we have enough room in data */ - if(fh->loc + cnt > fh->filesize * 512) { + if(fh->loc + fh->start + cnt > fh->filesize * 512) { /* Figure out the new block count */ - n = ((fh->loc + cnt) - (fh->filesize * 512)); + n = ((fh->loc + fh->start + cnt) - (fh->filesize * 512)); if(n & 511) n = (n + 512) & ~511; @@ -441,7 +521,7 @@ static ssize_t vmu_write(void * hnd, const void *buffer, size_t cnt) { dbglog(DBG_KDEBUG, "VMUFS: adding %d bytes of data at loc %d (%d avail)\n", cnt, fh->loc, fh->filesize * 512); #endif - memcpy(fh->data + fh->loc, buffer, cnt); + memcpy(fh->data + fh->loc + fh->start, buffer, cnt); fh->loc += cnt; return cnt; @@ -458,7 +538,7 @@ static void *vmu_mmap(void * hnd) { fh = (vmu_fh_t *)hnd; - return fh->data; + return fh->data + fh->start; } /* Seek elsewhere in a file */ @@ -486,7 +566,8 @@ static off_t vmu_seek(void * hnd, off_t offset, int whence) { } /* Check bounds; allow seek past EOF. */ - if(offset < 0) offset = 0; + if(offset < 0) + offset = 0; fh->loc = offset; @@ -555,6 +636,45 @@ static dirent_t *vmu_readdir(void * fd) { return &dh->dirent; } ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |