Commit Graph

79 Commits

Author SHA1 Message Date
Sergi (セルジ) 63aaa5051e kernel: two-phase thread shutdown
Replace `exit_delete_all_threads_and_wait()` with two separate operations:
- `process_exit()` blocks until all guest threads have exited (host-only)
- `request_process_exit()` fires the registered callback and returns immediately, safe to call from guest threads.

Threads are now SDL_DetachThread'd at creation. `thread_deleted_cond` on `KernelState` is used for join semantics in `process_exit()`.

Remove `shutting_down` from sync primitives; `exit_delete()` wakes blocked threads via `update_status(run)`, which all `status_cond` predicates already check.

`process_exit_callback` carries an `optional<AppLaunchRequest>` so `LoadExec` relaunches flow through the same path as normal exits. `AppLaunchRequest`/`AppLaunchReason` extracted to `emuenv/app_launch_request.h` so kernel can include it without a circular dependency.

After this, further simplification to `ThreadStatus` will be done in https://github.com/Vita3K/Vita3K/pull/3922.
2026-05-18 09:56:39 -04:00
KorewaWatchful 91f533f86f emu: complete gui overhaul 2026-05-13 17:58:56 -04:00
bookmist 345d807488 Tick Tick Tick, thats the sound of 2025 flying by 2026-01-18 01:58:45 +03:00
bookmist 5aa398be89 vita3k: code cleanup and minor bugfixes
Fix bugs
* gui/disassembly_dialog: fix bug. Can't enter addresses >= 0x80000000
* utils/vc_runtime_checker: fix almost impossible AV in vc_runtime_checker
* util/net_utils: fix warning and error in parseHeaders function
* patch: fix almost impossible bug, also drop unused var
* modules/SceAvPlayer: fix error (wrong mutex)
* kernel: more correct value of export variable __sce_libcparam (NID:0xDF084DFA)
* interface.cpp/get_contents_path (Looks like mistype in duplicate search)

Needs recheck of refactoring. I found something strange, but I'm not sure if it's intended or not.
* renderer::vulkan/VKContext::VKContext (Looks like mistype in variable name)
* spirv_recompiler/create_fragment_inputs (Variable anonimous is always false here. It's not static and reinit every loop iteration)
* renderer/transfer: fix strange (and maybe never run) code if pixel format is unknown
* renderer/vulkan/replacement: fix some type to type converson

Refactoring and enhancements
* codec/atrac9: better error logs
* util/fs_utils: Function read_data which read file to vector. Also use it if possible
* util/log: custom formatter for Ptr<> type (it simplifies logging)
* util/tracy: set tracy_module_id variable static
* util/warning.h : header to cross-platform disable warnings
* renderer/transfer: fix strange (and maybe never run) code if pixel format is unknown
* nids: typo fix
* modules/module_parent: remove link to nids.inc from header
* modules/module_parent: move macro to other such macros in bridge.h
* kernel: refactoring use get_thread instead of lock_and_find
* mem/ptr: set type Ptr<T> trivial (trivially copiable, movable and so on)

Fix warnings:
* some retype in BitmapAllocator (mem-tests are OK)
* typecasts
* remove unused variables and fields
* push_back->emplace_back
* rename duplicate variables (usually in nested loops)
* drop excessive brackets
* remove some unused includes
* set 'static' for functions if possible
* gui:home_screen/draw_home_screen: same values around ? operator.
* convert declare SCE_*_ERROR_* to enums
* bracket initialisation instead of memset
* other compiler warnings
2025-04-16 23:03:10 +03:00
Pedro Montes Alcalde 4a14d546ba Tick Tick Tick, thats the sound of 2024 flying by (#3503) 2025-01-19 18:51:43 -03:00
bookmist d2c6c4ac4f kernel: more correct thread local storage emulation, also stub ThreadVfpException functions
used mostly for lle libkernel
2024-11-05 00:06:59 +03:00
Saturnsky 97764c04cf modules/SceKernel: Implement sceKernelGetEventPattern (#3397) 2024-10-05 18:42:51 +02:00
bookmist 1fda880a94 vita3k: big code cleanup
Improvements
* lang: a bit more verbose error on wrong lang xml

Bugfixes
* kernel/sync_primitives: fix theoretically possible AV
* modules/SceAudio: a bit more correct sceAudioOutSetConfig
* fix wrong objects initialisation ({0} -> {})

Warning fixes
* clang warning: Macro argument should be enclosed in parentheses
[bugprone-macro-parentheses]
* modules: set unsigned type for Sce*ErrorCode enums
* clang warning: variable might be not be initialized
* clang warning: Function returns by const value. Consider returning by non-const value instead.
* clang warning: Prefer transparent functors [modernize-use-transparent-functors]

Refactoring
* io/device: move functions implementation from .h to .cpp file
* vita3k: fix fs::path usage
* clang warning: 'if' statement is unnecessary; deleting null pointer has no effect
* vita3k: use structured bindings and references in for-each-loops
* vita3k: simplify container operations, extract frequent operations to utility functions
* clang⚠️ 'contains' member function can be used
* kernel/sync_primitives: refactoring. drop unused parameter of handle_timeout
* vita3k: drop unused function parameters

* vita3k: fix typecasts
use static_cast instead of reinterpret casts if possible
use correct constants (1/1.0/1.0f)
correct variable types to minimise typecasts
use explicit typecasts (not everywhere)
replace c-style typecasts to c++ style typecasts (not everywhere)
* clang warning: remove redundant typecasts
* clang warning: Cast drops const qualifier

Optimisation
* vita3k: remove unused includes
* clang warning: Constness of returning variable prevents automatic move
[performance-no-automatic-move]
* clang warning: String concatenation results in allocation of unnecessary temporary strings
[performance-inefficient-string-concatenation]
* vita3k: use std::move
* vita3k: optimization. push_back -> emplace_back
* vita3k: fix datatypes to avoid unnesessary conversions
* clang warning: remove unneeded string->c_str->string conversion
* clang warning: The parameter is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
* clang warning: 'find' called with a string literal consisting of a single character
[performance-faster-string-find]
* clang warning: Result of a postfix operator is discarded, consider replacing it with a prefix operator
* clang warning: Pass value parameters by const reference

Code cleanup
* io/io: remove once used variables
* net/posixsocket: remove struct keyword
* vita3k: use raw string literals to avoid excessive escaping
* vita3k: refactoring. replace Ptr<> to pointer in Sce functions
* vita3k: drop unused variables and incorrect comments
* clang warning: readability-inconsistent-declaration-parameter-name
* clang warning: Extra ';' after member function definition
* clang warning: Possible misuse of comma operator (, is used instead of ;)
* clang warning: Algorithm accepting an iterator and a count can be used
* clang warning: Declaration and assignment can be joined
* clang warning: Type trait can be simplified using a template alias or a variable template

* vita3k: cleanup class methods
remove unimplemented (and obviously not used) methods
move deleted methods to public
change empty body to =default
remove auto constructors
set member default values
2024-03-18 15:44:56 +03:00
Pedro Montes Alcalde 34565e3ef4 Vita2024K: Happy 2024 2024-01-01 12:36:32 -03:00
Macdu 74edbed7d3 modules/SceThreadmgr: Return 1 as the process id (#3148) 2023-12-30 16:39:47 +01:00
Macdu 3e4bade31a modules/SceThreadMgr: Fix sceKernelOpenTimer 2023-09-27 15:35:21 +02:00
Macdu e64fa370c7 modules: cleanup 2023-09-10 23:35:12 +02:00
Macdu 5cb4c46c17 kernel: Fix thread start/end callbacks and cleanup 2023-07-26 19:55:09 +02:00
Macdu 569fe85f5a modules/SceThreadmgr: Remove assert 2023-07-25 14:10:50 +02:00
Macdu b4249a67f4 kernel: Implement sceKernelRegisterThreadEventHandler 2023-07-24 19:53:09 +02:00
Zangetsu38 e1560db6de modules/SceKernelThreadMgr: Implement sceKernelOpenEventFlag.
- Add sync primitive log on other find functions.
2023-07-20 12:30:03 +02:00
Zangetsu38 4fedf56459 modules/SceKernelThreadMgr: Implement some Kernel functions.
- Implement sceKernelDeleteMsgPipe
- Implement sceKernelOpenMutex
- Implement sceKernelOpenSema
2023-07-18 15:05:16 +02:00
Macdu 91d43d122d kernel: Implement timer events 2023-07-11 21:57:44 +02:00
bookmist 0fb1cd7c9a modules/SceThreadmgr: more correct _sceKernelGetThreadCpuAffinityMask 2023-07-04 23:49:53 +03:00
bookmist 04b356173b modules/SceLibKernel: stubbed sceKernelGetRWLockInfo, sceKernelTrySendMsgPipe 2023-05-27 20:45:58 +03:00
bookmist 1733c14a8c modules/SceThreadmgr: implement sceKernelDeleteCallback 2023-05-27 20:45:58 +03:00
bookmist dd603f3417 modules: implement some functions:
modules/SceThreadmgr: implement _sceKernelGetMutexInfo, sceKernelSetTimerTimeWide
refactor _sceKernelGetLwMutexInfoById
_sceKernelGetSemaInfo - fix returning data
_sceKernelGetThreadInfo - also return thread exit status
sceKernelChangeThreadVfpException, sceIoIoctl - describe parameters

modules/SceGxm: implement sceGxmProgramGetOutputRegisterFormat, sceGxmDepthStencilSurfaceGetFormat

modules/SceRtcUser: implement sceRtcCompareTick, sceRtcGetDosTime, sceRtcGetWin32FileTime

modules/SceKernelModulemgr: sceKernelGetModuleInfo change assert to error code

modules/SceLibKernel: sceKernelCreateMutex: add stub if priority ceiling feature is used

config/state: add forgotten module (SceNetInternal) into tracy modules list
2023-03-01 23:30:26 +01:00
bookmist d28f780b42 modules/SceThreadmgr: implement sceKernelCancelSema, _sceKernelCancelSema
kernel/sync_primitives: fix error code in semaphore_signal
modules/SceThreadmgr: describe some functions, fix an assert, drop unused header
2023-01-19 13:35:30 +03:00
EXtremeExploit 41a17e79c7 Planet Earth Season 2023 2023-01-02 10:46:20 +01:00
Pedro Montes Alcalde 4a50a4e0d4 modules/timers: fix some timers returns and add some checks 2022-11-27 18:32:11 -03:00
bookmist f03c257a33 modules: Add Tracy to all implemented functions in implemented modules.
modules/tracy: module name macro
Remove unused hack from SceMp4, mark ScePgf/sceFontNewLib unimplemented
2022-10-29 20:35:17 +03:00
Macdu 31d7edda61 kernel: Fix sceKernelWaitThreadEndCB 2022-09-17 15:04:07 +02:00
Macdu 636b1dfedd kernel: Rewrite the way svc and callbacks are handled 2022-09-16 21:57:57 +02:00
Macdu 2eefc9751e vita3k: Remove unnecessary dependencies between librairies and files 2022-07-28 12:24:06 +02:00
hobyst 2233966ab2 Build: Change name of package lib to "packages"
"package" is a reserved CMake target name when CPack is used. Since
OpenSSL enables CPack in their project and it will be implemented in the
emulator in the future, this commit changes its name to "packages" to
avoid conflicts with CPack.
2022-07-11 12:25:35 +02:00
Macdu d4bb55a414 kernel: Implement sceKernelCancelEventFlag 2022-07-04 19:08:10 +02:00
hobyst 1169da50bc host: Rename host to emuenv
This commit renames the host library as emuenv (emulated PS Vita
environment) to avoid confusion with the future host OS abstraction
layer
2022-07-03 14:31:24 +02:00
hobyst 0f65fac20d host, package: Decouple package code from host
Since most code inside host library doesn't really have to do with the
emulated PS Vita environment but rather with handling the different
package formats used in the console, this commit moves the code from
the host library into its own dedicated library. In summary:
- Moved package code into its own library and edited function calls
to accomodate the change
- Edited some function interfaces in order not to cause a dependency
hell due to cross-referenced types in headers that depended in
one another and edited function calls and resource access to accomodate
the change
- copy_directories() and copy_path() from `vita3k/interface.cpp` have
been modified and moved to io library due to being used in package
library and others. Keeping them as they were before causes dependency
hell
- All functions whose interface has been changed now have a Doxygen
comment block explaining the new interface
- host has been declared as an INTERFACE CMake library to fix linking
issues on Windows due to the fact that it doesn't compile C++ source
files anymore
2022-07-03 14:31:24 +02:00
Zangetsu38 1dd24ba741 modules/SceLibKernel: add sceKernelWaitSignalCB. 2022-06-08 15:58:12 +02:00
Zangetsu38 5221d68c89 modules/SceLibKernel: add process callbacks on cb function. 2022-06-08 13:17:38 +02:00
Macdu bb84106cc2 kernel: Implement simple events 2022-06-04 14:37:52 +02:00
Macdu 9889c472a9 kernel: better handling of thread priority and mask affinity 2022-05-25 15:23:21 +03:00
Macdu 3c221fdc5b kernel: Implement RWLock 2022-05-16 20:23:05 +02:00
Zangetsu38 9c224e3358 modules/SceThreadmgr: using callback of sceKernelWaitSemaCB. 2022-05-02 21:41:05 +02:00
Macdu 7e7ad01dcb modules/SceKernelThreadMgr: Handle null workarea for _sceKernelDeleteLwMutex 2022-04-19 01:36:50 +02:00
sunho f703e4a5e3 kernel: Fix callback execution. 2022-04-03 00:03:31 +02:00
Zangetsu38 77fd8e8f78 project: run format. 2022-03-16 02:11:11 +01:00
bookmist dc7a8f8b1e modules/SceKernelThreadMgr: fix pointer type 2021-12-23 13:25:44 +01:00
Nicolas Jallamion 85cdbbf200 modules/SceKernelThreadMgr: stub sceKernel(Resume/Suspend)ThreadForVM. (#1493)
- Stub sceKernelGetThreadContextForVM.
- prepare sceKernelGmSetThreadContextForVM of futur implemênt.

Co-authored-by: sunho <ksunhokim123@naver.com>

Co-authored-by: sunho <ksunhokim123@naver.com>
2021-11-08 09:52:23 +01:00
sunho 563e7575d1 kernel: Fix race condition in kernel callback 2021-11-07 07:24:56 +09:00
Zangetsu38 bdfebfad58 modules/SceKernelThreadMgr: implement sceKernelGet(EventFlag/Cond)Info.
- move sceKernelCreateCond inside it and refactor sceKernelGetThreadInfo.
2021-11-06 12:27:47 +01:00
bookmist 9188447fce modules/SceKernelThreadMgr: fix mutex deadlock and clean code of callback implementation 2021-11-05 20:16:32 +01:00
Zangetsu38 ce225b5733 modules/SceThreadmgr: Implement sceKernelGetSemaInfo.
- fix find callbackId and return error in few Callback function.
2021-11-05 20:14:24 +01:00
CreepNT e095ab06af kernel: Add Callback object implementation.
- modules/SceKernelThreadMgr: add some callback function.
- build fixed by sunho
2021-11-04 19:18:51 +01:00
hobyst 168dfb19ca Add license notice on source files which didn't have one
- Also updated the copyright notice year on all files to 2021
2021-08-19 23:14:27 +02:00