4063 Commits

Author SHA1 Message Date
KorewaWatchful b52c735f39 overlay: fix input related bugs 2026-05-20 19:05:54 -04:00
Sergi (セルジ) 0517f5f5fb kernel/thread: rework run_loop lifecycle (drop ThreadToDo + something_to_do)
Replace ThreadToDo and the something_to_do condvar with four boolean
flags: exit_requested, delete_requested, suspend_requested,
single_stepping. run_loop() returns void.

call_level brackets each frame: incremented on entry, decremented just
before return.

All call-level exits (normal exit, guest return, delete) converge on a
single block at the top of the loop that fires the end callback and parks
dormant. This wakes wait_thread_end waiters on every exit path.
If deleted, return completely from all run_loop() nested levels.
2026-05-19 21:46:51 -04:00
bookmist 713143f16e mem: alloc_at returns 0 on failure
Previously, alloc_at would unconditionally return the requested address, only logging a critical error if the address was already in use.
2026-05-19 20:51:07 -04:00
nishinji dcfebeada8 Update labeler.yml 2026-05-19 20:47:23 -04:00
shinra-electric ceefd1b192 CI: Resolve actions build warnings (#3904)
* Bump ccache-action to v1.2.23

* Change msvc-dev-cmd to use TheMrMilchmann fork
2026-05-18 15:36:29 -04:00
KorewaWatchful 7b9b4f6976 android: fix adrenotools macro 2026-05-18 12:39:42 -04:00
Dicot0721 d9b605854b android: Add x86_64 ABI
- Disable adrenotools in Android x86_64 build to compile.
- Fix incorrect type for parameter of JNI function.
2026-05-18 11:38:20 -03:00
Macdu f52b3af7b4 renderer: Improve depth buffer accuracy
Co-authored-by: SaturnSky <ikadro@gmail.com>
2026-05-18 10:12:02 -04:00
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 74cae4a3f7 android: add trophy browser 2026-05-17 23:13:50 -04:00
bookmist 78d5574649 io: replace better-enums lib to boost::describe 2026-05-17 23:52:17 +03:00
bookmist 4e03f06a06 gui-qt: fix string/path/QString conversion for non ASCII strings for old Windows 2026-05-17 01:22:14 +03:00
KorewaWatchful c8efb16435 refresh controllers on app relaunch 2026-05-15 18:25:13 -04:00
KorewaWatchful 71a445f209 gui: bugfixes 2026-05-15 18:09:52 -04:00
aifunc 81e551db23 gui: fix macOS A key physical mapping 2026-05-15 11:31:32 -04:00
KorewaWatchful 91f533f86f emu: complete gui overhaul 2026-05-13 17:58:56 -04:00
KorewaWatchful a01f2b15b6 Revert "gui: Add Vita3K Network (V3KN) and cloud save manager."
This reverts commit cb1f592c8a.
2026-05-13 17:58:56 -04:00
Zangetsu38 cb1f592c8a gui: Add Vita3K Network (V3KN) and cloud save manager.
- Add V3KN account management dialog wtih create/login/logout/delete account, change avatar/panel/password/online id/server, quota refresh.
- Add show server error/success popup inside V3KN account management dialog.
- Add Cloud screen to LiveArea with cloud button for upload/download savedata on V3KN
- Add "Please wait" and "Connecting… Please wait." dialogs for network operations (upload/download, auth)
- Add overwrite confirmation dialog and "Copying" progress dialogs for cloud/local saves.
- Draw Cloud icons.
util/net_utils: Some refactor and protocol improvements.
- Add Upload file func with multipart/form-data support
- Add keep-alive support for (download/upload)file.
- Refactor get_web_response() to support POST bodies and return server-side errors
- Refactor download_file() for stability and clearer error handling
- Clean up duplicated logic and unify request handling.
2026-05-13 21:36:30 +02:00
Sergi (セルジ) 6e52f1ce0c cpu: move halt instruction block to KernelState, shared across all threads
Each thread was allocating its own identical 4-byte NOP+WFI block.
Since all threads point LR at the same sentinel, one allocation in KernelState is sufficient.

Note that this is a Dynarmic-specific "hack" to make it stop execution (`jit->Run()`) after the guest code returns (jumps back LR):
- Prior JIT execution, we prepare LR to point to this NOP+WFI block.
- When the guest function returns, it will jump into this NOP+WFI block and `Dynarmic::A32::Exception::WaitForInterrupt` will be called. Then we call `cpu->jit->HaltExecution()` which will make `jit->Run()` return
2026-05-13 19:10:50 +02:00
ikhoeyZX 9abe85f90f [Android/Overlay] Add L3 R3 and hide controller button 2026-05-11 17:33:07 +02:00
Sergi (セルジ) b72d34de59 kernel: extract abort dispatch into ThreadState::dispatch_abort
Makes `ThreadState::run_loop` simpler to understand.
2026-05-11 02:28:51 -04:00
Sergi (セルジ) 6a6bbfc8a7 kernel: remove CPUProtocol abstraction, inline SVC dispatch in run_loop
`CPUProtocol::get_watch_memory_addr` is never used, so we can drop it.
After that, `CPUProtocol` only has `call_svc`, whose implementation is
just 3 lines: read the NID, call `call_import`, and `clear_exclusive`.
We can inline those at the call site and get rid of `CPUProtocol`
completely.
2026-05-10 23:26:51 -04:00
Sergi (セルジ) ffbe7493fe debugger/kernel: remove unused trampoline machinery
The Debugger trampoline API (`Trampoline` struct, `TrampolineCallback`,
`add_trampoline` / `get_trampoline` / `remove_trampoline`, `TRAMPOLINE_JUMPER_SVC`
and `TRAMPOLINE_HANDLER_SVC`, plus the two SVC-dispatch branches in
`CPUProtocol::call_svc`) has never had a caller.
2026-05-10 21:48:26 -04:00
KorewaWatchful a91cc994a9 modules: fix debug string linkage, add missing tracy module name for vshbridge 2026-05-09 16:59:24 -04:00
Francisco José García García 66c21b65f7 kubridge: warn when registering unimplemented exception handler types
Only DABT (type 0) is dispatched from run_loop. PABT (1) and UNDEF (2)
are stored in exception_handlers[] but never triggered. Log a warning
so it's obvious when a plugin expects a type we don't dispatch yet.
2026-05-09 21:04:18 +02:00
Francisco José García García dbbf5bd758 stubs: return unique UIDs from stub allocators
ksceKernelAllocRemoteProcessHeap returned 0 (invalid UID on Vita) and
ksceKernelRegisterProcEventHandler returned the same hardcoded 0x40001
on every call. Use atomic counters to return distinct UIDs so callers
that pass them back to the corresponding Free/Unregister don't collide.
2026-05-09 21:04:18 +02:00
Francisco José García García 35e71d6eef taiHEN: reduce log noise in hot lookup paths
- Trim find_import_stub segment-address dump to a one-liner (fires per NID)
- Remove module_get_offset success log (fires on every offset query)
- Remove module_get_export_func cache-hit log (fires on every export lookup)
- Promote dynamic SVC stub creation to LOG_INFO (one-time per NID, useful)
2026-05-09 21:04:18 +02:00
Francisco José García García 3c9399e596 taiHEN: replace TaiHook raw pointers with unique_ptr
Raw new/delete across three allocation sites and one release site was
error-prone. Switched map to unique_ptr, removed the unused `next`
chain pointer, and eliminated the manual delete.
2026-05-09 21:04:18 +02:00
Francisco José García García 5c80509e96 modules: add Tracy instrumentation to taiHEN, kubridge, ScePowerForDriver
Addresses reviewer comment requesting TRACY_MODULE_NAME + TRACY_FUNC
in all new HLE modules added by this branch.
2026-05-09 21:04:18 +02:00
Francisco José García García 8927849a05 kubridge: apply requested protection in kuKernelMemCommit
The computed MemPerm was logged but ignored — the function always called
unprotect_inner regardless of the protection flags. Now it mirrors the
kuKernelMemProtect logic: restrictive perms use add_protect so the fault
handler can catch violations; ReadWrite unprotects as before.
2026-05-09 21:04:18 +02:00
Francisco José García García e52bc060e8 kernel: clear thread-local CPU state on run_loop exit
set_current_cpu_state was set on entry but never cleared. A recycled host
thread would carry a stale CPUState pointer into the next vita thread's
signal handler. Use a scope guard to clear it on all exit paths.
2026-05-09 21:04:18 +02:00
Francisco José García García ce5b4eb3d1 cpu: fix CP15 catch-all sharing state across unhandled registers
Using a single `dummy` field meant any unhandled MCR/MRC would read back
whatever the last unhandled write stored, silently corrupting guest reads.
Return CallbackOrAccessOneWord{} (no-op) instead.
2026-05-09 21:04:18 +02:00
Francisco José García García dfc31d5098 Address PR review: JIT cache invalidation + kernel.mutex locking
- SceCpuForDriver: ksceKernelCpuIcacheInvalidateRange and
  ksceKernelCpuIcacheAndL2WritebackInvalidateRange now call
  invalidate_jit_cache() to properly invalidate dynarmic's JIT cache
- taiHEN: All loaded_modules accesses now protected by kernel.mutex
  using scoped locks to avoid deadlocks with state->mutex and
  export_nids_mutex (lock order: kernel.mutex -> export_nids_mutex -> state->mutex)
2026-05-09 21:04:18 +02:00
Francisco José García García 7f9b366d5b Fix CI: clang-format + substitute_sym on non-Apple platforms 2026-05-09 21:04:18 +02:00
Francisco José García García 5e63470b0a Rename module files: SceLibTaihen→taiHEN, SceKubridge→kubridge
Drop vendor-invented names from source paths and internal names:
- vita3k/modules/SceLibTaihen/SceLibTaihen.cpp → taiHEN/taiHEN.cpp
- vita3k/modules/SceKubridge/SceKubridge.cpp → kubridge/kubridge.cpp
- LIBRARY_INIT: SceLibTaihen → taihen (correct name per taiHEN exports.yml)
- LIBRARY() registration updated accordingly
2026-05-09 21:04:18 +02:00
Francisco José García García c370630a55 kubridge: Implement real exception handler dispatch
- Add abort_pending/abort_fault_addr/abort_is_write atomics to CPUState
- Add thread-local set/get_current_cpu_state() for signal-safe access
- Store registered exception handlers in KernelState::exception_handlers[]
- kuKernelRegisterExceptionHandler: stores handler address (atomic)
- kuKernelReleaseExceptionHandler: clears handler address (atomic)
- MemProtect/Decommit fault callbacks halt CPU via abort_aware_fault_callback
- run_loop dispatches DABT handler with KuKernelAbortContext on guest stack
- SceLibTaihen: snapshot pre-plugin NIDs to avoid overriding system exports
2026-05-09 21:04:18 +02:00
Francisco José García García a92ac3d644 kubridge: Implement memory protection via add_protect callbacks
- kuKernelMemProtect: converts ku flags to MemPerm, calls protect_inner
- kuKernelMemCommit: applies requested protection via protect_inner
- kuKernelMemDecommit: marks range as MemPerm::None via protect_inner

24/24 tests passing.
2026-05-09 21:04:18 +02:00
Francisco José García García 2c777c7bac kubridge: Add HLE module for LLE export overrides
Add HLE implementations for kubridge exports that cannot run as LLE
(they depend on firmware-specific offsets and ARM MMU manipulation):
- kuKernelMemProtect: validates args, returns success (Option B stub)
- kuKernelMemReserve: allocates memory via alloc_at/alloc, tracks in vm_blocks
- kuKernelMemCommit: no-op stub (warns if baseBlock mirrors requested)
- kuKernelMemDecommit: no-op stub
- kuKernelRegisterExceptionHandler: stub returns success
- kuKernelReleaseExceptionHandler: stub void return

Dynamic override mechanism:
- apply_plugin_hle_overrides() iterates all LLE export_nids and automatically
  overrides any that have a matching HLE implementation (via has_hle_implementation)
- register_hle_override() creates SVC stubs and re-patches func_binding_infos
- No hardcoded NID lists — new HLE modules are picked up automatically

24/24 tests passing.
2026-05-09 21:04:18 +02:00
Francisco José García García f47f8501de ScePowerForDriver: Add kscePowerGet/SetSysClockFrequency stubs
Implement kernel power NIDs needed by kubridge:
- kscePowerGetSysClockFrequency (0xC63DACD5): returns 333 MHz
- kscePowerSetSysClockFrequency (0x0E333BEC): no-op, returns 0

Tests 17-18/18 GREEN.
2026-05-09 21:04:18 +02:00
Francisco José García García 94621f3f99 taiHEN: Add kernel NIDs and fix module_nid in taiGetModuleInfo
Implement the kernel driver functions that kubridge.skprx imports,
allowing it to run as native LLE ARM code instead of HLE overrides.

SceSysmemForDriver:
- ksceKernelAllocMemBlock: full impl with vbase (alloc_at) support
- ksceKernelGetMemBlockBase, ksceKernelFreeMemBlock
- ksceKernelMemcpyUserToKernel, ksceKernelStrncpyUserToKernel
- kscePUIDOpenByGUID: returns same UID (no user/kernel separation)
- Refactor: sceKernelAllocMemBlock/FreeMemBlock/GetMemBlockBase now
  delegate to kernel via CALL_EXPORT
- Extract SysmemState to shared header (modules/sysmem_state.h)

SceThreadmgrForDriver:
- ksceKernelCreateThread, ksceKernelStartThread, ksceKernelWaitThreadEnd

SceSysclibForDriver: kmemset
SceProcessmgrForDriver: ksceKernelCreateProcessLocalStorage (stub)
SceProcEventForDriver: ksceKernelRegisterProcEventHandler (stub)

CP15 coprocessor (dynarmic_cpu.cpp):
- Add SCTLR read/write (kuKernelEnableSwp thread)
- Add DACR read/write (kuKernelCpuUnrestrictedMemcpy)
- Add TPIDRURO write (ENTER_SYSCALL/EXIT_SYSCALL macros)
- Catch-all with LOG_WARN for unknown cp15 registers
2026-05-09 21:04:18 +02:00
Francisco José García García 28cff2a2f7 SceVshBridge: Implement _vshKernelSearchModuleByName
Search loaded modules by name and return the module UID.
Used by game ports (e.g. ff3_vita) to check if plugins like
kubridge are loaded before proceeding.
2026-05-09 21:04:18 +02:00
Francisco José García García 74eec2333d taiHEN: Implement HLE hooks, injections and module utils
Implement the core taiHEN plugin framework as HLE in SceLibTaihen:

Hooks:
- taiHookFunctionExportForUser/ForKernel: inline hooks via substitute's
  transform-dis for ARM/Thumb instruction relocation, with fallback to
  import stub patching when inline hooking fails (FUNC_TOO_SHORT)
- taiHookFunctionImportForUser/ForKernel: import stub patching (12-byte
  ARM stubs: movw/movt/bx)
- taiHookFunctionOffsetForUser/ForKernel: hook at module segment+offset
- taiHookRelease/ForKernel: restore original bytes/stubs, free trampoline
- Hook chaining with TAI_CONTINUE support via TaiHookUser structs

Injections:
- taiInjectAbs/ForKernel: arbitrary memory patching with save/restore
- taiInjectDataForUser/ForKernel: inject data at module segment+offset
- taiInjectRelease/ForKernel: restore original bytes

Module utils:
- taiGetModuleInfo/ForKernel: query module info by name
- module_get_offset: resolve segment+offset to address
- module_get_export_func: resolve NID to export address

Plugin loading:
- taiLoadKernelModule, taiLoadStartKernelModuleForUser,
  taiLoadStartModuleForPidForUser: load plugin .skprx/.suprx files
- Config parsing: ux0:tai/config.txt format (*KERNEL, *TITLEID sections)

External dependency:
- Add Vita3K/substitute as git submodule (forked from comex/substitute,
  LGPLv2.1+). Only the ARM transform-dis component is used for
  instruction relocation in inline hooks.

Tested with 10 integration tests covering all implemented APIs.
2026-05-09 21:04:18 +02:00
Francisco José García García 7b26e7031a Integrate taiHEN plugin loading into app startup
Call load_taihen_plugins_for_title() in load_app_impl() after system
modules are loaded. This loads KERNEL plugins (once) and title-specific
plugins from ux0:tai/config.txt before the app's entry point runs.
2026-05-09 21:04:18 +02:00
Francisco José García García 31968dbf3f taiHEN: Add HLE module for plugin support
- New module: SceLibTaihen with all taiHEN API exports (taihen, taihenUnsafe,
  taihenForKernel, taihenModuleUtils libraries)
- Config parser for ux0:tai/config.txt / ur0:tai/config.txt
- Plugin loading functions: load_taihen_config, load_taihen_plugins_for_title
- 33 NIDs added to nids.inc (SHA-256 per vita-toolchain algorithm)
- Functional implementations: taiGetModuleInfo, taiInjectAbs/Release,
  module_get_export_func (with dynamic SVC stub generation),
  module_get_offset, taiMemcpy*, taiLoadKernelModule
- TaihenState managed via kernel obj_store
- .gitignore: exclude copilot-instructions.md
2026-05-09 21:04:18 +02:00
shinra-electric 48ddef9356 Add ad-hoc codesigning for macOS builds 2026-05-07 09:36:45 -04:00
Pedro Montes Alcalde 9f955b8f0e mem: Add missing include for latest GCC/Clang (#3915) 2026-05-06 18:01:48 -03:00
dependabot[bot] faa4a632f0 build(deps): bump mozilla-actions/sccache-action in the ci-deps group
Bumps the ci-deps group with 1 update: [mozilla-actions/sccache-action](https://github.com/mozilla-actions/sccache-action).


Updates `mozilla-actions/sccache-action` from 0.0.9 to 0.0.10
- [Release notes](https://github.com/mozilla-actions/sccache-action/releases)
- [Commits](https://github.com/mozilla-actions/sccache-action/compare/v0.0.9...v0.0.10)

---
updated-dependencies:
- dependency-name: mozilla-actions/sccache-action
  dependency-version: 0.0.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: ci-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-01 15:23:41 +02:00
Zangetsu38 526e00c038 bgm player: Remove dependency of (Gui/EmuEnv)State.
- Send only pref path and state of option.
2026-04-30 15:19:59 +02:00
Sergi (セルジ) 8b1d1707d1 modules/SceFiber: default to LLE
SceFiber depends on `TLS_SP_TOP`/`TLS_SP_BOTTOM` entries.
Since they have been added and populated properly at thread creation,
LLE SceFiber works (or should) out of the box without needing the current HLE implementation,
which has some hacks and heap memory allocations that shouldn't be there (but kept).
2026-04-27 19:52:40 +02:00
Zangetsu38 703828d56d gui/settings dialog: Fix custom config of the custom driver on Android.
- Add custom gpu idx request for this too.
app/app init: Using current_config instead of cfg for set current_custom_driver.
2026-04-25 23:57:15 +02:00