Yuri Kunde Schlesner
7ada357b2d
Memmap: Re-organize memory function in two files
...
memory.cpp/h contains definitions related to acessing memory and
configuring the address space
mem_map.cpp/h contains higher-level definitions related to configuring
the address space accoording to the kernel and allocating memory.
11 years ago
Lioncash
150e700729
process: Get rid of warnings
...
Sign mismatches and "forcing value to bool" warnings.
11 years ago
Lioncash
207087c856
thread: Fix a conditional check in Reschedule
11 years ago
bunnei
cb2b2071a8
Merge pull request #748 from Subv/tls_max
...
Core/Memory: Add TLS support for creating up to 300 threads
11 years ago
bunnei
ee8da4c356
Merge pull request #751 from yuriks/idle-thread
...
Thread: Remove the idle thread
11 years ago
bunnei
6e26d063a5
Merge pull request #757 from Subv/scheduling
...
Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is called
11 years ago
Yuri Kunde Schlesner
4f7a055081
Thread: Remove the idle thread
...
Instead just use nullptr to represent no thread is active.
11 years ago
Subv
dda94e56dd
Core/Memory: Add TLS support for creating up to 300 threads
11 years ago
Yuri Kunde Schlesner
820b97787c
Merge pull request #750 from Subv/process_svc
...
Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
11 years ago
Subv
dbc1320923
Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is called
11 years ago
Subv
25c010dc7d
fixup!
11 years ago
Subv
41f74a16fd
Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
11 years ago
Yuri Kunde Schlesner
d16c2bd956
Thread: Correctly set main thread initial stack position
11 years ago
archshift
e98fbadf4a
Merge pull request #740 from yuriks/gsp-shmem
...
Fix crashes due to un-initialized GSP shared memory
11 years ago
Subv
115ad8e16a
fixup! Set the TLS address in the scheduler
11 years ago
Subv
000876858d
Core/Memory: Give every emulated thread it's own TLS area.
...
The TLS area for thread T with id Ti is located at TLS_AREA_VADDR + (Ti - 1) * 0x200.
This allows some games like Mario Kart 7 to continue further.
11 years ago
Yuri Kunde Schlesner
774eea8374
Kernel: Zero-fill shared memory blocks when mapping
...
This works around crashes related to GSP/HID/etc. shared memory blocks
having garbage values. The proper fix requires proper management of
mapped memory blocks in the process.
11 years ago
Yuri Kunde Schlesner
c96f22490a
Kernel: Capture SharedMemory attributes at creation, not when mapping
11 years ago
Yuri Kunde Schlesner
b700b55696
Common: Remove the BIT macro
...
When the macro was introduced in 326ec51261
it wasn't noticed that it conflicted in name with a heavily used macro
inside of dyncom. This causes some compiler warnings. Since it's only
lightly used, it was opted to simply remove the new macro.
11 years ago
Yuri Kunde Schlesner
1c0b87edc2
Memory: Re-organize and rename memory area address constants
11 years ago
Yuri Kunde Schlesner
7c50b999fa
Kernel: Remove unused g_main_thread variable
11 years ago
Yuri Kunde Schlesner
3cb19c9589
Process: Rename StaticAddressMapping => AddressMapping
11 years ago
Yuri Kunde Schlesner
83ccf85bb2
Process: Add more documentation to the class members
11 years ago
Yuri Kunde Schlesner
2f5904611d
Process: Use BitField to store process flags
11 years ago
Yuri Kunde Schlesner
2af30d465f
Process: Support parsing of exheader kernel caps
11 years ago
Yuri Kunde Schlesner
a5eba2f984
Kernel: Remove g_program_id
...
This has been obsoleted by the field in Process.
11 years ago
Yuri Kunde Schlesner
6d60acf0f1
Kernel: Introduce skeleton Process class to hold process data
11 years ago
Yuri Kunde Schlesner
e1fbac3ca1
Common: Remove common.h
11 years ago
Yuri Kunde Schlesner
c916bcf7b5
Move typedefs from kernel.h to more appropriate places
11 years ago
bunnei
c7dc799e19
Kernel: Properly initialize and shutdown all modules.
11 years ago
Emmanuel Gil Peyrot
0d69b2f7bd
Kernel: Use the correct format string for u64 hex.
11 years ago
bunnei
c077bcefa9
SVC: Update various SVCs to cause a reschedule.
...
- CreateMutex/ReleaseMutex/ReleaseSemaphore/SetTimer/CancelTimer/ArbitrateAddress
11 years ago
bunnei
9c3419ebcc
Kernel: Implemented priority inheritance for mutexes.
11 years ago
bunnei
7b9f428b23
Thread: Implement priority boost for starved threads.
...
SVC: Return correct error code on invalid CreateThread processor ID.
SVC: Assert when creating a thread with an invalid userland priority.
11 years ago
bunnei
e08f55b1a7
Kernel: Fixed default thread priority.
11 years ago
Gareth Higgins
25a43cd2ec
Initialize base address to 0x0
11 years ago
archshift
4fb75d220a
Misc cleanup of common and related functions
11 years ago
Subv
8e2b248e05
Build: Fixed some warnings
11 years ago
archshift
ef24e72b26
Asserts: break/crash program, fit to style guide; log.h->assert.h
...
Involves making asserts use printf instead of the log functions (log functions are asynchronous and, as such, the log won't be printed in time)
As such, the log type argument was removed (printf obviously can't use it, and it's made obsolete by the file and line printing)
Also removed some GEKKO cruft.
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
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
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
664c79ff47
Thread: Modernize two functions that slipped through previous rebases
11 years ago
Lioncash
3f00dd9117
arm: Clean up ARMul_State
...
Remove unnecessary/unused struct variables.
11 years ago
Lioncash
96c174aed4
shared_memory: Fix assignments in SharedMemory::Map
11 years ago
Yuri Kunde Schlesner
d917a9bf77
Kernel: Mark all appropriate kernel objects as "final"
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
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
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
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
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
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
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
Lioncash
a3f5e5605c
core: Fix a few docstrings
11 years ago
Subv
9e2ae289b8
AddrArbiter: Implement arbitration types 3 and 4.
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
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
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