Commit graph

612 commits

Author SHA1 Message Date
Yuri Kunde Schlesner
88a4a808c6 Kernel: Stop creating useless Handles during object creation
They're finally unnecessary, and will stop cluttering the application's
handle table.
2015-02-02 15:37:09 -02:00
Yuri Kunde Schlesner
52f58e64ef Kernel: Make WaitObjects share ownership of Threads waiting on them
During normal operation, a thread waiting on an WaitObject and the
object hold mutual references to each other for the duration of the
wait.

If a process is forcefully terminated (The CTR kernel has a SVC to do
this, TerminateProcess, though no equivalent exists for threads.) its
threads would also be stopped and destroyed, leaving dangling pointers
in the WaitObjects.

The solution is to simply have the Thread remove itself from WaitObjects
when it is stopped. The vector of Threads in WaitObject has also been
changed to hold SharedPtrs, just in case. (Better to have a reference
cycle than a crash.)
2015-02-02 15:37:08 -02:00
Yuri Kunde Schlesner
7725256f64 Explicitly instantiate constructors/destructors for Kernel objects
This should speed up compile times a bit, as well as enable more liberal
use of forward declarations. (Due to SharedPtr not trying to emit the
destructor anymore.)
2015-02-02 15:37:07 -02:00
Yuri Kunde Schlesner
4e84df8be3 Mutex: Replace g_mutex_held_locks with a set inside Thread 2015-02-02 15:37:06 -02:00
Yuri Kunde Schlesner
0f69668fc6 HID: Fix crash when pressing a key when the emulator is stopped 2015-02-02 15:37:05 -02:00
Yuri Kunde Schlesner
c4208c1171 SVC: Enable CloseHandle, clean up DuplicateHandle 2015-02-02 15:37:04 -02:00
Yuri Kunde Schlesner
e8330dd162 Kernel: Fix bug in HandleTable::Close 2015-02-02 15:37:04 -02:00
Yuri Kunde Schlesner
5354a479bc Kernel: Remove Object::GetHandle (it's not used anymore :D) 2015-02-02 15:37:04 -02:00
Yuri Kunde Schlesner
869ec46683 Kernel: Introduce unique Object ids for debugging 2015-02-02 15:37:03 -02:00
Yuri Kunde Schlesner
a9b86db3cf Kernel: Use separate Handle tables for CoreTiming userdata
This is to support the removal of GetHandle soon
2015-02-02 15:37:03 -02:00
Yuri Kunde Schlesner
ec9c773251 Kernel: Remove previous scheduled event when a Timer is re-Set 2015-02-02 15:37:02 -02:00
Yuri Kunde Schlesner
8441591659 FS: Remove use of GetHandle 2015-02-02 15:37:01 -02:00
Yuri Kunde Schlesner
664c79ff47 Thread: Modernize two functions that slipped through previous rebases 2015-02-02 15:37:01 -02:00
Yuri Kunde Schlesner
6e11570862 Service: Store function names as const char* instead of std::string
Uses less memory (strings and function table is stored in constant data)
and speeds up start up (no need to allocate and copy strings).
2015-02-02 15:37:00 -02:00
Yuri Kunde Schlesner
a79d21c83e Service: Clean-up Interface 2015-02-02 15:36:59 -02:00
Yuri Kunde Schlesner
8779b31fe6 Make Port/Service registration and querying more HW-accurate 2015-02-02 15:36:59 -02:00
Yuri Kunde Schlesner
5e91fc0d1a Filesys: Move creation of Handles for File/Directory to service handlers 2015-02-02 15:36:58 -02:00
Lioncash
3f00dd9117 arm: Clean up ARMul_State
Remove unnecessary/unused struct variables.
2015-01-31 21:55:34 -05:00
Tony Wasserka
73a7a379d6 Merge pull request #512 from lioncash/assignment
shared_memory: Fix assignments in SharedMemory::Map
2015-01-31 12:59:00 +01:00
Lioncash
96c174aed4 shared_memory: Fix assignments in SharedMemory::Map 2015-01-30 11:37:53 -05:00
Lioncash
551264f815 archive: Fix initializer list order for the File class. 2015-01-30 11:30:22 -05:00
Lioncash
0c53cc52bd apt_u: Fix missing printf specifiers 2015-01-30 11:28:09 -05:00
Yuri Kunde Schlesner
d917a9bf77 Kernel: Mark all appropriate kernel objects as "final" 2015-01-30 11:49:46 -02:00
Yuri Kunde Schlesner
58b544db99 SVC: Use CASCADE_RESULT in SVC handlers 2015-01-30 11:49:46 -02:00
Yuri Kunde Schlesner
09ae6e1fa3 Remove result.h InvalidHandle
It was only being used in two places, where it was replaced by a local
constant.
2015-01-30 11:49:45 -02:00
Yuri Kunde Schlesner
44f90340dc SVC: Change return type of handlers to ResultCode 2015-01-30 11:49:44 -02:00
Yuri Kunde Schlesner
d52d859936 Kernel: Convert Event to not use Handles 2015-01-30 11:49:43 -02:00
Yuri Kunde Schlesner
ad80ff1e32 Kernel: Convert Timer to (mostly) not use Handles 2015-01-30 11:47:07 -02:00
Yuri Kunde Schlesner
882b6fed75 Kernel: Convert Mutex to not use Handles 2015-01-30 11:47:06 -02:00
Yuri Kunde Schlesner
38e7122f23 Kernel: Convert AddressArbiter to not use Handles 2015-01-30 11:47:06 -02:00
Yuri Kunde Schlesner
d9b19be1d9 Kernel: Convert Semaphore to not use Handles 2015-01-30 11:47:05 -02:00
Yuri Kunde Schlesner
4bb33dfc30 Kernel: Convert SharedMemory to not use Handles 2015-01-30 11:47:04 -02:00
Yuri Kunde Schlesner
afc416c607 Additions to ResultVal to make it more convenient to use. 2015-01-30 11:47:02 -02:00
Yuri Kunde Schlesner
b5ee4f9df9 Move VAddr/PAddr typedefs to kernel.h 2015-01-30 11:47:01 -02:00
Yuri Kunde Schlesner
9a345de2bd Kernel: Remove useless/duplicated comments; mark functions static 2015-01-30 11:47:01 -02:00
bunnei
206cabc0e4 Merge pull request #412 from purpasmart96/svc_table_cleanup
SVC: Update the SVC function table
2015-01-28 17:36:23 -05:00
purpasmart96
62f4365db1 SVC: Update the SVC function table 2015-01-26 20:42:28 -08:00
bunnei
326c451758 Merge pull request #345 from purpasmart96/apt_stubs
APT_U: Stub some functions & misc changes
2015-01-26 23:13:54 -05:00
bunnei
e7dd4d34aa Merge pull request #485 from Subv/more_servs
Services: Stubbed more services.
2015-01-25 22:13:13 -05:00
Subv
2ea60bdc7f Services/HID: Removed some files due to a rebase error 2015-01-24 15:54:24 -05:00
Subv
c2e9990149 Services: Stubbed more services.
Implemented FSUser::CreateExtSaveData
2015-01-24 15:44:40 -05:00
purpasmart96
2dd23b6467 APT_U: Stub some functions & misc changes 2015-01-22 16:03:48 -08:00
archshift
92a75df9b1 cam_u.h: fix indentation
Withholding my profanity towards Xcode.
2015-01-22 12:51:53 -08:00
bunnei
92550013cf Merge pull request #493 from archshift/ptmplay
Stubbed some services
2015-01-22 13:25:19 -05:00
bunnei
731154f79e WaitSynchronization: Added a result code for invalid result, fixed bug. 2015-01-21 20:49:43 -05:00
bunnei
68ddaaa2f5 Thread: Fix WaitSynchronization1 to not set register 1 on thread wakeup. 2015-01-21 20:48:46 -05:00
bunnei
4255f25647 Thread: Use std::find in CheckWait_WaitObject. 2015-01-21 20:48:46 -05:00
bunnei
2f3020a102 Mutex: Cleanup and remove redundant code. 2015-01-21 20:48:36 -05:00
bunnei
f09806aed2 Kernel: Renamed some functions for clarity.
- ReleaseNextThread->WakeupNextThread
- ReleaseAllWaitingThreads->WakeupAllWaitingThreads.
2015-01-21 20:48:30 -05:00
bunnei
15b6a4d9ad Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void. 2015-01-21 20:47:49 -05:00
bunnei
c68eb15695 WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual. 2015-01-21 20:47:49 -05:00
bunnei
69c5830ef2 Event: Fix implementation of "non-sticky" events. 2015-01-21 20:47:48 -05:00
bunnei
9e6ec3b6cd Session: Change to a WaitObject. 2015-01-21 20:47:47 -05:00
bunnei
d2759c578e Kernel: Reschedule on SignalEvent and SendSyncRequest, fix some bugs. 2015-01-21 20:47:47 -05:00
bunnei
dde02f79af Mutex: Fix a bug where the thread should not wait if it already has the mutex. 2015-01-21 20:47:46 -05:00
bunnei
9412996c8f Kernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely. 2015-01-21 20:47:46 -05:00
bunnei
c06d64528a SVC: Removed a Sleep that made no sense
- Would deadlock the calling thread
- Code would never get hit anyways
2015-01-21 20:47:45 -05:00
bunnei
254e4ebd58 AddressArbiter: Changed to Kernel::Object, big cleanup, removed code that made no sense. 2015-01-21 20:47:45 -05:00
bunnei
e5a9f1c644 Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks. 2015-01-21 20:47:38 -05:00
bunnei
6deb1a0119 WaitSynchronizationN: Improved comments 2015-01-21 19:12:51 -05:00
bunnei
6643673f28 WaitSynchronizationN: Refactor to fix several bugs
- Separate wait checking from waiting the current thread
- Resume thread when wait_all=true only if all objects are available at once
- Set output to correct wait object index when there are duplicate handles
2015-01-21 19:11:47 -05:00
bunnei
aa01c57ae9 Kernel: Separate WaitSynchronization into Wait and Acquire methods. 2015-01-21 19:10:24 -05:00
bunnei
627e96fc15 WaitSynchronizationN: Handle case where handles=nullptr. 2015-01-21 19:09:10 -05:00
bunnei
f5c6d367c9 WaitSynchronizationN: Handle case where handle_count is invalid. 2015-01-21 19:09:09 -05:00
bunnei
064be2b86f WaitSynchronizationN: Handle case where handle_count=0. 2015-01-21 19:09:09 -05:00
bunnei
7faf2d8e06 WaitSynchronizationN: Implement return values 2015-01-21 19:09:03 -05:00
bunnei
e4a5d8ad4f Event: Fixed some bugs and cleanup (Subv) 2015-01-21 18:43:50 -05:00
bunnei
1f7a04f05a Thread: Keep track of multiple wait objects. 2015-01-21 18:42:04 -05:00
bunnei
14cbbf4d9b Event: Get rid of permanent_lock hack. 2015-01-21 18:42:04 -05:00
bunnei
5e77e2e1de WaitObject: Added RemoveWaitingThread, fixed a bug, and cleanup. 2015-01-21 18:41:58 -05:00
bunnei
c22bac6398 Kernel: Added WaitObject and changed "waitable" objects inherit from it. 2015-01-21 18:41:00 -05:00
archshift
1f109c6b49 Added HID_SPVR service and split HID_U implementation into service/hid/hid.xxx 2015-01-21 13:31:10 -08:00
archshift
a68dda6328 Stubbed cam:u service 2015-01-21 12:50:18 -08:00
archshift
7516ceaf93 Stubbed ptm:play service 2015-01-21 12:50:18 -08:00
Lioncash
a3f5e5605c core: Fix a few docstrings 2015-01-20 13:52:44 -05:00
bunnei
cbbe9e1500 Merge pull request #492 from archshift/apt
Expose GetSharedFont and NotifyToWait to APT:A and APT:S respectively
2015-01-20 12:55:53 -05:00
bunnei
be8f665142 Merge pull request #383 from zhuowei/shared_page
Add some support for the shared page
2015-01-18 18:31:52 -05:00
archshift
4d316cbd8e Expose GetSharedFont and NotifyToWait to APT:A and APT:S respectively 2015-01-18 15:15:14 -08:00
Zhuowei Zhang
edb8450420 Add some support for the shared page (currently 3d slider is implemented) 2015-01-15 22:16:13 -05:00
bunnei
2572a62480 APT: Fix typo in setting return code for NotifyToWait 2015-01-15 18:23:53 -05:00
bunnei
350c5a7e32 DSP: Removed useless spam log for SignalInterrupt 2015-01-15 18:20:58 -05:00
bunnei
4b47ed6194 Merge pull request #482 from yuriks/fix-vblank
Correctness fixes for GPU flipping and interrupts
2015-01-15 18:11:03 -05:00
bunnei
3ff5a80d46 Merge pull request #481 from Subv/hm_b
APTU: Stubbed NotifyToWait, taken from 3dmoo.
2015-01-14 21:39:49 -05:00
Sebastian Valle
fd1b600e05 APT: Fixed the comment style in some variables 2015-01-14 10:14:22 -05:00
bunnei
394d44cf74 Merge pull request #480 from Subv/arb_2
AddrArbiter: Implement arbitration types 3 and 4.
2015-01-14 10:04:33 -05:00
Yuri Kunde Schlesner
7630b31672 GSP: Fix appending of interrupts to the shared memory buffer
The code was previously appending the interrupt to after the end of the
buffer, instead of at the end.
2015-01-14 05:20:13 -02:00
Yuri Kunde Schlesner
5961a2852d GSP: Update framebuffer info on all interrupts
Hardware testing determined that the GSP processes shared memory
framebuffer update info even when no memory transfer or filling GX
commands are used. They are now updated on every interrupt, which isn't
confirmed correct but matches hardware behaviour more closely.

This also reverts the hack introduced in #404. It made a few games
behave better, but I believe it's incorrect and also breaks other games.
2015-01-14 05:20:12 -02:00
Yuri Kunde Schlesner
98e3274935 GPU: Fire GPU interrupts at the correct places.
PDC0 and PDC1 are both VBlank interrupts. PDC0 was being treated as a
HBlank interrupt and fired many more times than it should. They now both
fire together at 60 Hz. This puzzlingly *improves* apparent framerate on
many applications.

A few other interrupts were being fired inside the GSP command
processing instead of on the actual GPU register writes, so they were
moved there, which should cover direct writes tho those registers not
going through the GX command queue.
2015-01-14 05:07:35 -02:00
Subv
728c932dba APTU: Stubbed NotifyToWait, taken from 3dmoo.
Also renamed some handles in the APT:U service to be more descriptive.
Fixed a typo in InquireNotification
2015-01-13 19:18:10 -05:00
Subv
9e2ae289b8 AddrArbiter: Implement arbitration types 3 and 4. 2015-01-13 14:49:26 -05:00
Subv
cf071cd897 Services: Added some missing services.
cfg:s, ptm:sysm, apt:s.
apt:s is almost exactly the same as apt:u as per 3dbrew
2015-01-13 14:43:30 -05:00
darkf
67c644e317 Fix building on MinGW 2015-01-11 20:22:08 -08:00
bunnei
b33380ca59 Merge pull request #456 from Subv/waitsync1
SVC: Wake up the thread after the delay in WaitSync1
2015-01-11 18:52:09 -05:00
bunnei
542b0b0057 Merge pull request #466 from Subv/wake
Thread: Prevent waking a thread multiple times.
2015-01-11 13:39:23 -05:00
Subv
b68d51ed30 Thread: Prevent waking a thread multiple times.
If a thread was woken up by something, cancel the wakeup timeout.
2015-01-11 13:18:52 -05:00
Subv
38da198aa1 SVC: Wake up the thread after the delay in WaitSync1 2015-01-11 10:42:59 -05:00
archshift
3b555e2512 Stubbed y2r:u IsBusyConversion
There is no documentation available on this function, but we set the result to false as a stub.
This allows Super Little Acorns to move all the way in game with pp3c.
2015-01-10 22:47:31 -08:00
archshift
95be6ad7ae Added Archive ID to fs:USER debug logs involving opening the archive. 2015-01-10 14:32:11 -08:00
archshift
228843c43e Logging: Log all called service functions (under trace). Compile out all trace logs under release for performance. 2015-01-10 14:32:10 -08:00
Yuri Kunde Schlesner
8ad41775cc Kernel: Start using boost::intrusive_ptr for lifetime management 2015-01-09 19:43:52 -02:00