Commit Graph

669 Commits (c96f22490a4a459d477f446fd4e5f894f580b69c)

Author SHA1 Message Date
Yuri Kunde Schlesner 3f1a3952d7 FS: Allow multiple instances of the same archive type to be open at once 11 years ago
Yuri Kunde Schlesner 4468625080 FS: Get rid of completely useless Archive class 11 years ago
Kevin Hartman 5fcbfc06eb Scheduler refactor Pt. 1
* Simplifies scheduling logic, specifically regarding thread status. It should be much clearer which statuses are valid
for a thread at any given point in the system.
* Removes dead code from thread.cpp.
* Moves the implementation of resetting a ThreadContext to the corresponding core's implementation.

Other changes:
* Fixed comments in arm interfaces.
* Updated comments in thread.cpp
* Removed confusing, useless, functions like MakeReady() and ChangeStatus() from thread.cpp.
* Removed stack_size from Thread. In the CTR kernel, the thread's stack would be allocated before thread creation.
11 years ago
bunnei 1b0bf00cbc Mutex: Locks should be recursive. 11 years ago
bunnei caa58acc84 WaitSynch: Always reschedule (verified behavior on hw). 11 years ago
purpasmart96 60ce36f721 Services: Stub some functions 11 years ago
Lioncash 676daef3c7 core: Fix some warnings on OSX 11 years ago
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.
11 years ago
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.)
11 years ago
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.)
11 years ago
Yuri Kunde Schlesner 4e84df8be3 Mutex: Replace g_mutex_held_locks with a set inside Thread 11 years ago
Yuri Kunde Schlesner 0f69668fc6 HID: Fix crash when pressing a key when the emulator is stopped 11 years ago
Yuri Kunde Schlesner c4208c1171 SVC: Enable CloseHandle, clean up DuplicateHandle 11 years ago
Yuri Kunde Schlesner e8330dd162 Kernel: Fix bug in HandleTable::Close 11 years ago
Yuri Kunde Schlesner 5354a479bc Kernel: Remove Object::GetHandle (it's not used anymore :D) 11 years ago
Yuri Kunde Schlesner 869ec46683 Kernel: Introduce unique Object ids for debugging 11 years ago
Yuri Kunde Schlesner a9b86db3cf Kernel: Use separate Handle tables for CoreTiming userdata
This is to support the removal of GetHandle soon
11 years ago
Yuri Kunde Schlesner ec9c773251 Kernel: Remove previous scheduled event when a Timer is re-Set 11 years ago
Yuri Kunde Schlesner 8441591659 FS: Remove use of GetHandle 11 years ago
Yuri Kunde Schlesner 664c79ff47 Thread: Modernize two functions that slipped through previous rebases 11 years ago
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).
11 years ago
Yuri Kunde Schlesner a79d21c83e Service: Clean-up Interface 11 years ago
Yuri Kunde Schlesner 8779b31fe6 Make Port/Service registration and querying more HW-accurate 11 years ago
Yuri Kunde Schlesner 5e91fc0d1a Filesys: Move creation of Handles for File/Directory to service handlers 11 years ago
Lioncash 3f00dd9117 arm: Clean up ARMul_State
Remove unnecessary/unused struct variables.
11 years ago
Tony Wasserka 73a7a379d6 Merge pull request #512 from lioncash/assignment
shared_memory: Fix assignments in SharedMemory::Map
11 years ago
Lioncash 96c174aed4 shared_memory: Fix assignments in SharedMemory::Map 11 years ago
Lioncash 551264f815 archive: Fix initializer list order for the File class. 11 years ago
Lioncash 0c53cc52bd apt_u: Fix missing printf specifiers 11 years ago
Yuri Kunde Schlesner d917a9bf77 Kernel: Mark all appropriate kernel objects as "final" 11 years ago
Yuri Kunde Schlesner 58b544db99 SVC: Use CASCADE_RESULT in SVC handlers 11 years ago
Yuri Kunde Schlesner 09ae6e1fa3 Remove result.h InvalidHandle
It was only being used in two places, where it was replaced by a local
constant.
11 years ago
Yuri Kunde Schlesner 44f90340dc SVC: Change return type of handlers to ResultCode 11 years ago
Yuri Kunde Schlesner d52d859936 Kernel: Convert Event to not use Handles 11 years ago
Yuri Kunde Schlesner ad80ff1e32 Kernel: Convert Timer to (mostly) not use Handles 11 years ago
Yuri Kunde Schlesner 882b6fed75 Kernel: Convert Mutex to not use Handles 11 years ago
Yuri Kunde Schlesner 38e7122f23 Kernel: Convert AddressArbiter to not use Handles 11 years ago
Yuri Kunde Schlesner d9b19be1d9 Kernel: Convert Semaphore to not use Handles 11 years ago
Yuri Kunde Schlesner 4bb33dfc30 Kernel: Convert SharedMemory to not use Handles 11 years ago
Yuri Kunde Schlesner afc416c607 Additions to ResultVal to make it more convenient to use. 11 years ago
Yuri Kunde Schlesner b5ee4f9df9 Move VAddr/PAddr typedefs to kernel.h 11 years ago
Yuri Kunde Schlesner 9a345de2bd Kernel: Remove useless/duplicated comments; mark functions static 11 years ago
bunnei 206cabc0e4 Merge pull request #412 from purpasmart96/svc_table_cleanup
SVC: Update the SVC function table
11 years ago
purpasmart96 62f4365db1 SVC: Update the SVC function table 11 years ago
bunnei 326c451758 Merge pull request #345 from purpasmart96/apt_stubs
APT_U: Stub some functions & misc changes
11 years ago
bunnei e7dd4d34aa Merge pull request #485 from Subv/more_servs
Services: Stubbed more services.
11 years ago
Subv 2ea60bdc7f Services/HID: Removed some files due to a rebase error 11 years ago
Subv c2e9990149 Services: Stubbed more services.
Implemented FSUser::CreateExtSaveData
11 years ago
purpasmart96 2dd23b6467 APT_U: Stub some functions & misc changes 11 years ago
archshift 92a75df9b1 cam_u.h: fix indentation
Withholding my profanity towards Xcode.
11 years ago
bunnei 92550013cf Merge pull request #493 from archshift/ptmplay
Stubbed some services
11 years ago
bunnei 731154f79e WaitSynchronization: Added a result code for invalid result, fixed bug. 11 years ago
bunnei 68ddaaa2f5 Thread: Fix WaitSynchronization1 to not set register 1 on thread wakeup. 11 years ago
bunnei 4255f25647 Thread: Use std::find in CheckWait_WaitObject. 11 years ago
bunnei 2f3020a102 Mutex: Cleanup and remove redundant code. 11 years ago
bunnei f09806aed2 Kernel: Renamed some functions for clarity.
- ReleaseNextThread->WakeupNextThread
- ReleaseAllWaitingThreads->WakeupAllWaitingThreads.
11 years ago
bunnei 15b6a4d9ad Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void. 11 years ago
bunnei c68eb15695 WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual. 11 years ago
bunnei 69c5830ef2 Event: Fix implementation of "non-sticky" events. 11 years ago
bunnei 9e6ec3b6cd Session: Change to a WaitObject. 11 years ago
bunnei d2759c578e Kernel: Reschedule on SignalEvent and SendSyncRequest, fix some bugs. 11 years ago
bunnei dde02f79af Mutex: Fix a bug where the thread should not wait if it already has the mutex. 11 years ago
bunnei 9412996c8f Kernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely. 11 years ago
bunnei c06d64528a SVC: Removed a Sleep that made no sense
- Would deadlock the calling thread
- Code would never get hit anyways
11 years ago
bunnei 254e4ebd58 AddressArbiter: Changed to Kernel::Object, big cleanup, removed code that made no sense. 11 years ago
bunnei e5a9f1c644 Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks. 11 years ago
bunnei 6deb1a0119 WaitSynchronizationN: Improved comments 11 years ago
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
11 years ago
bunnei aa01c57ae9 Kernel: Separate WaitSynchronization into Wait and Acquire methods. 11 years ago
bunnei 627e96fc15 WaitSynchronizationN: Handle case where handles=nullptr. 11 years ago
bunnei f5c6d367c9 WaitSynchronizationN: Handle case where handle_count is invalid. 11 years ago
bunnei 064be2b86f WaitSynchronizationN: Handle case where handle_count=0. 11 years ago
bunnei 7faf2d8e06 WaitSynchronizationN: Implement return values 11 years ago
bunnei e4a5d8ad4f Event: Fixed some bugs and cleanup (Subv) 11 years ago
bunnei 1f7a04f05a Thread: Keep track of multiple wait objects. 11 years ago
bunnei 14cbbf4d9b Event: Get rid of permanent_lock hack. 11 years ago
bunnei 5e77e2e1de WaitObject: Added RemoveWaitingThread, fixed a bug, and cleanup. 11 years ago
bunnei c22bac6398 Kernel: Added WaitObject and changed "waitable" objects inherit from it. 11 years ago
archshift 1f109c6b49 Added HID_SPVR service and split HID_U implementation into service/hid/hid.xxx 11 years ago
archshift a68dda6328 Stubbed cam:u service 11 years ago
archshift 7516ceaf93 Stubbed ptm:play service 11 years ago
Lioncash a3f5e5605c core: Fix a few docstrings 11 years ago
bunnei cbbe9e1500 Merge pull request #492 from archshift/apt
Expose GetSharedFont and NotifyToWait to APT:A and APT:S respectively
11 years ago
bunnei be8f665142 Merge pull request #383 from zhuowei/shared_page
Add some support for the shared page
11 years ago
archshift 4d316cbd8e Expose GetSharedFont and NotifyToWait to APT:A and APT:S respectively 11 years ago
Zhuowei Zhang edb8450420 Add some support for the shared page (currently 3d slider is implemented) 11 years ago
bunnei 2572a62480 APT: Fix typo in setting return code for NotifyToWait 11 years ago
bunnei 350c5a7e32 DSP: Removed useless spam log for SignalInterrupt 11 years ago
bunnei 4b47ed6194 Merge pull request #482 from yuriks/fix-vblank
Correctness fixes for GPU flipping and interrupts
11 years ago
bunnei 3ff5a80d46 Merge pull request #481 from Subv/hm_b
APTU: Stubbed NotifyToWait, taken from 3dmoo.
11 years ago
Sebastian Valle fd1b600e05 APT: Fixed the comment style in some variables 11 years ago
bunnei 394d44cf74 Merge pull request #480 from Subv/arb_2
AddrArbiter: Implement arbitration types 3 and 4.
11 years ago
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.
11 years ago
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.
11 years ago
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.
11 years ago
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
11 years ago
Subv 9e2ae289b8 AddrArbiter: Implement arbitration types 3 and 4. 11 years ago
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
11 years ago
darkf 67c644e317 Fix building on MinGW 11 years ago
bunnei b33380ca59 Merge pull request #456 from Subv/waitsync1
SVC: Wake up the thread after the delay in WaitSync1
11 years ago
bunnei 542b0b0057 Merge pull request #466 from Subv/wake
Thread: Prevent waking a thread multiple times.
11 years ago
Subv b68d51ed30 Thread: Prevent waking a thread multiple times.
If a thread was woken up by something, cancel the wakeup timeout.
11 years ago
Subv 38da198aa1 SVC: Wake up the thread after the delay in WaitSync1 11 years ago
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.
11 years ago
archshift 95be6ad7ae Added Archive ID to fs:USER debug logs involving opening the archive. 11 years ago
archshift 228843c43e Logging: Log all called service functions (under trace). Compile out all trace logs under release for performance. 11 years ago
Yuri Kunde Schlesner 8ad41775cc Kernel: Start using boost::intrusive_ptr for lifetime management 11 years ago
Yuri Kunde Schlesner d751de7341 Kernel: Don't re-assign object's handle when duplicating one 11 years ago
bunnei 6ae12424df Merge pull request #444 from yuriks/handle-reform2
Kernel Lifetime Reform Pt. 2
11 years ago
bunnei 86e07124ad Merge pull request #436 from kevinhartman/system-core
Warn if a new thread is intended to be run on the system CPU core
11 years ago
Yuri Kunde Schlesner 78ea76e12f Thread: Fix nullptr access in a logging function 11 years ago
Yuri Kunde Schlesner 7f1557fbbd Thread: Rename thread_queue => thread_list 11 years ago
Yuri Kunde Schlesner 9bf8462b96 Thread: Reduce use of Handles and move some funcs to inside the class. 11 years ago
Yuri Kunde Schlesner ba72208cd4 Kernel: Move Thread's definition to the header file 11 years ago
Yuri Kunde Schlesner 7b3452c730 Move ThreadContext to core/core.h and deal with the fallout 11 years ago
bunnei d46f650036 Merge pull request #255 from Subv/cbranch_3
Implemented timers
11 years ago
Subv 07044651ef SVC: Implemented the Timer service calls. 11 years ago
Subv dfc440785a SVC: Fixed SleepThread.
It will now properly wait the specified number of nanoseconds and then wake up the thread.
11 years ago
Subv 60a373a786 Threads: Use a dummy idle thread when no other are ready.
This thread will not actually execute instructions, it will only advance the timing/events and try to yield immediately to the next ready thread, if there aren't any ready threads then it will be rescheduled and start its job again.
11 years ago
bunnei b659cac2dc Merge pull request #404 from bunnei/more-frame-synch-fixes
GPU: Toggle active framebuffer each frame
11 years ago
bunnei f7a3f45f1e GSP: Toggle active framebuffer each frame 11 years ago
bunnei e6864a1f41 Merge pull request #431 from yuriks/thread-queue-cleanup
Common: Clean up ThreadQueueList
11 years ago
Kevin Hartman 63be6aaadd Warn if a new thread is intended to be run on the system CPU core until we implement correct scheduling for such a thread. 11 years ago
Yuri Kunde Schlesner 122c2bb324 Common: Clean up ThreadQueueList
Replace all the C-style complicated buffer management with a std::deque.
In addition to making the code easier to understand it also adds support
for non-POD IdTypes.

Also clean the rest of the code to follow our code style.
11 years ago
Yuri Kunde Schlesner a6ad68190f Fix double-free in Service manager during shutdown
Fixes #423.
11 years ago
bunnei 088863c921 Merge pull request #376 from Subv/arc_reorder
Archives: Change the folder layout of some archives.
11 years ago
Subv 32dbb76e00 Archives: Changed the unimplemented archives comment.
It now refers to me as the PoC
11 years ago
Subv 5244ac0e9c Archives: Addressed some comments 11 years ago
bunnei 9eaef4e04a Merge pull request #413 from purpasmart96/serv_clean
Services: Clean up a few things and add a few function names
11 years ago
bunnei 9b83f0e158 Merge pull request #272 from rohit-n/sign-compare
Silence some -Wsign-compare warnings.
11 years ago
purpasmart96 379b39e583 Services: Clean up a few things and add a few function names 11 years ago
bunnei e9650f1c61 DSP: Signal (faked) interrupt on every frame.
- Hack to work around games checking that the DSP event has been signaled by a real DSP interrupt.
11 years ago
bunnei cc23269ff4 Merge pull request #407 from Subv/arbiter
AddressArbiter: Ported arbitration type 2 from 3dmoo.
11 years ago
bunnei 96e6b2aa50 Merge pull request #408 from Subv/mutex
Mutex: Add the calling thread to the waiting list when needed
11 years ago
bunnei 26f31a2dfb Merge pull request #386 from archshift/y2ru
Stub the y2r:u service
11 years ago
Subv ea80363cc2 Mutex: Add the calling thread to the waiting list when needed
This will happen when the mutex is already owned by another thread. Should fix some issues with games being stuck due to waiting threads not being awoken.
11 years ago
Subv 90dffe3fc1 Archives: Make SYSTEM_ID and SDCARD_ID strings 11 years ago
Subv 71a063f45c Archives: Changed the way paths are built for the archives.
Each archive now takes a mount point of either NAND or SDMC, and builds its own directory structure there, trying to simulate an HLE-friendly hardware layout
11 years ago
archshift 48130b1eaa Stub the y2r:u service 11 years ago
Subv 0276a75f24 AddressArbiter: Ported arbitration type 2 from 3dmoo.
(Thanks 3dmoo!)
11 years ago
Subv 3bc9f5509b Archives: Change the folder layout of some archives.
This is to better represent the hardware layout, they are still aren't quite accurate, but this better and will help a bit when implementing the other archives like NAND-RO and NAND-RW
11 years ago
Subv aade417b14 Archives: Reduced duplicate code in RomFS and SaveCheck.
Fixed a few warnings and cleaned up the code
11 years ago
Subv 13efbdc201 SaveDataCheck: Preliminary work in this archive.
This allows Steel Diver to boot further, some files are needed.

This is still not ready and needs a big cleanup, this will possibly be delayed until the way we handle archives is fixed (with factory classes instead of ahead-of-time creation of archives)
11 years ago
bunnei 3d9bf13439 Merge pull request #391 from lioncash/pedantic
archive/elf: Minor misc changes.
11 years ago
Lioncash 0d81b1e75b archive: Fix initializer list order 11 years ago
Lioncash bdbd111c7e soc_u: Fix a missing formatting argument 11 years ago
Rohit Nirmal c589d82052 Silence some -Wsign-compare warnings. 11 years ago
Subv 97a7381d29 SOC_U: Preliminary implementation of sockets.
Stubbed CreateMemoryBlock

Using Berkeley sockets, and Winsock2.2 on Windows.
So far ftpony creates the socket and accepts incoming connections

SOC_U: Renamed functions to maintain consistency

Also prevents possible scope errors / conflicts with the actual Berkeley socket functions

SOCU: Close all the opened sockets when cleaning up SOCU
11 years ago
Subv 545ded954d APT:A: Some style changes 11 years ago
Subv 2c89d4d5cd Archives: Implemented ExtSaveData and SharedExtSaveData
They will be stored in /extsavedata/SDMC and /extsavedata/NAND respectively.
Also redirect some APT_A functions to their APT_U equivalents.
Implemented the gamecoin.dat file in SharedExtSaveData in the PTM module.
Implemented formatting the savegame.
Retake a previous savegame if it exists instead of reporting them as not formatted every time a game is loaded.
11 years ago