Commit graph

197 commits

Author SHA1 Message Date
Yuri Kunde Schlesner e3a8292495 Common: Remove section measurement from profiler (#1731)
This has been entirely superseded by MicroProfile. The rest of the code
can go when a simpler frametime/FPS meter is added to the GUI.
2016-04-29 00:07:10 -07:00
mailwl bd8cc69893 ac:u: stub CloseAsync; check memory size aling in svc:GetProcessInfo(type=2) 2016-04-21 10:34:45 +03:00
Lioncash 856a1d0386 svc: Move ResetType enum to the kernel event header 2016-03-12 21:47:41 -05:00
Kloen 1149e66820 ThreadProcessorId_All on SVC::CreateThread 2016-03-01 12:03:32 +01:00
Subv d90d5a0ee6 HLE/SVC: Implement UnmapMemoryBlock.
This implementation will need to be (almost completely) changed when we implement multiprocess support.
2016-01-14 11:29:19 -05:00
Lioncash 270cbb0119 svc: Remove superfluous printf argument 2015-12-25 14:21:45 -05:00
Lioncash 84afaaa10c svc: Fix compilation with LOG_TRACE enabled 2015-12-12 18:14:36 -05:00
Yuri Kunde Schlesner 84a22cb594 Kernel: Implement svcGetSystemInfo
This makes smealum/ctrulib@b96dd51d33 work
with Citra.
2015-11-30 19:49:44 -08:00
Yuri Kunde Schlesner 18c1c39d5e SVC: Advance time when calling GetSystemTick to escape busy-wait loops
Cubic Ninja waited for the frame to end by spinning on a loop calling
GetSystemTick while doing nothing else. Since GetSystemTick doesn't
cause a reschedule (which advances time), this meant that very little
emulated time would pass inside that loop, causing the game to spend
most of the frame burning away CPU.
2015-08-30 00:07:02 -03:00
Yuri Kunde Schlesner 0fcabd2b11 Integrate the MicroProfile profiling library
This brings goodies such as a configurable user interface and
multi-threaded timeline view.
2015-08-24 22:16:28 -03:00
Yuri Kunde Schlesner 14eca982f4 Kernel: Implement svcGetProcessInfo in a basic way
This also adds some basic memory usage accounting. These two types are
used by Super Smash Bros. during startup.
2015-08-16 01:03:48 -03:00
Yuri Kunde Schlesner 74d4bc0af1 Kernel: Add more infrastructure to support different memory layouts
This adds some structures necessary to support multiple memory regions
in the future. It also adds support for different system memory types
and the new linear heap mapping at 0x30000000.
2015-08-16 01:03:47 -03:00
Yuri Kunde Schlesner 69c3021a8d Move core/mem_map.{cpp,h} => core/hle/kernel/memory.{cpp,h} 2015-08-16 01:03:46 -03:00
Yuri Kunde Schlesner cdeeecf080 Kernel: Properly implement ControlMemory FREE and COMMIT 2015-08-16 01:03:45 -03:00
Yuri Kunde Schlesner 24d7c05c8d Merge pull request #888 from zawata/Warning-Fixes-2
Core\HLE : Fix Warning
2015-07-25 12:55:34 -07:00
Lioncash c2689b8c2c dyncom: Pass SVC immediates directly.
Previously it would just re-read the already decoded instruction and extract the immediate value.
2015-07-21 03:56:29 -04:00
Subv 83fa3f977d Kernel/SVC: Implemented svcQueryProcessMemory 2015-07-17 14:55:35 -05:00
Subv 9e2962081a Kernel/SVC: Implemented svcQueryMemory. 2015-07-17 11:03:56 -05:00
zawata f723a498e7 Core\HLE : Fix Warning
"signed/unsigned mismatch"
2015-07-17 00:50:53 -07:00
bunnei 71e8822d23 kernel: Fix svcWaitSynch to always acquire requested wait objects. 2015-06-16 22:34:39 -04:00
Emmanuel Gil Peyrot b1503b2020 Remove every trailing whitespace from the project (but externals). 2015-05-29 21:59:29 +01:00
Subv 732839b1f4 Core/SVC: Map the shared memory created in CreateMemoryBlock to the specified address.
This SharedMemory can be passed to service functions (Which should map the memory into their own address space).
2015-05-25 16:17:26 -05:00
bunnei 0b7d2941cf Kernel: Move reschedules from SVCs to actual mechanisms that reschedule. 2015-05-20 18:05:47 -04:00
archshift 11057488f9 Implement svcBreak 2015-05-16 22:06:59 -07:00
Subv d3634d4bf4 Core/ResourceLimits: Implemented the basic structure of ResourceLimits.
Implemented svcs GetResourceLimit, GetResourceLimitCurrentValues and GetResourceLimitLimitValues.

Note that the resource limits do not currently keep track of used objects, since we have no way to distinguish between an object created by the application, and an object created by some HLE module once we're inside Kernel::T::Create.
2015-05-14 22:50:13 -05:00
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.
2015-05-15 00:04:38 -03:00
Subv 25c010dc7d fixup! 2015-05-11 18:23:45 -05:00
Subv 41f74a16fd Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread 2015-05-11 09:15:10 -05:00
Yuri Kunde Schlesner c96f22490a Kernel: Capture SharedMemory attributes at creation, not when mapping 2015-05-10 19:47:07 -03:00
Yuri Kunde Schlesner c956e8a686 Fix printf format warning 2015-05-07 15:45:22 -03:00
Yuri Kunde Schlesner e1fbac3ca1 Common: Remove common.h 2015-05-07 15:45:22 -03:00
Yuri Kunde Schlesner ecff2351a1 HLE: Clean up SVC dispatch mechanism 2015-05-06 00:24:39 -03:00
bunnei db4bd98bac SVC: Assert on unsupported CreateThread processor ID. 2015-04-09 22:55:18 -04:00
bunnei c077bcefa9 SVC: Update various SVCs to cause a reschedule.
- CreateMutex/ReleaseMutex/ReleaseSemaphore/SetTimer/CancelTimer/ArbitrateAddress
2015-04-09 19:06:42 -04:00
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.
2015-04-09 19:05:21 -04:00
bunnei ee3377b67d SVC: Reschedule on svcCreateThread. 2015-04-09 19:04:20 -04:00
Lioncash 8cf81643a9 arm_interface: Get rid of GetTicks.
Removes a TODO.
2015-03-16 12:18:37 -04:00
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.
2015-02-10 18:30:31 -08:00
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.
2015-02-09 21:47:12 -08:00
bunnei caa58acc84 WaitSynch: Always reschedule (verified behavior on hw). 2015-02-09 22:05:39 -05:00
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 c4208c1171 SVC: Enable CloseHandle, clean up DuplicateHandle 2015-02-02 15:37:04 -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 8779b31fe6 Make Port/Service registration and querying more HW-accurate 2015-02-02 15:36:59 -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
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 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 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 d2759c578e Kernel: Reschedule on SignalEvent and SendSyncRequest, fix some bugs. 2015-01-21 20:47:47 -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
Subv 9e2ae289b8 AddrArbiter: Implement arbitration types 3 and 4. 2015-01-13 14:49:26 -05:00
Subv 38da198aa1 SVC: Wake up the thread after the delay in WaitSync1 2015-01-11 10:42:59 -05: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
bunnei 6ae12424df Merge pull request #444 from yuriks/handle-reform2
Kernel Lifetime Reform Pt. 2
2015-01-09 12:59:35 -05:00
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
2015-01-09 11:14:35 -05:00
Yuri Kunde Schlesner 9bf8462b96 Thread: Reduce use of Handles and move some funcs to inside the class. 2015-01-09 04:02:15 -02:00
Yuri Kunde Schlesner 7b3452c730 Move ThreadContext to core/core.h and deal with the fallout 2015-01-09 03:51:55 -02:00
bunnei d46f650036 Merge pull request #255 from Subv/cbranch_3
Implemented timers
2015-01-08 22:38:33 -05:00
Subv 07044651ef SVC: Implemented the Timer service calls. 2015-01-08 21:22:14 -05:00
Subv dfc440785a SVC: Fixed SleepThread.
It will now properly wait the specified number of nanoseconds and then wake up the thread.
2015-01-08 18:39:12 -05:00
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. 2015-01-07 14:14:48 -08:00
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
2014-12-31 10:51:44 -05:00
Yuri Kunde Schlesner 7e2903cb74 Kernel: New handle manager
This handle manager more closely mirrors the behaviour of the CTR-OS
one. In addition object ref-counts and support for DuplicateHandle have
been added.

Note that support for DuplicateHandle is still experimental, since parts
of the kernel still use Handles internally, which will likely cause
troubles if two different handles to the same object are used to e.g.
wait on a synchronization primitive.
2014-12-28 11:52:55 -02:00
Yuri Kunde Schlesner 73fba22c01 Rename ObjectPool to HandleTable 2014-12-28 11:52:52 -02:00
bunnei 0de6a08d75 Merge pull request #291 from purpasmart96/license
License change
2014-12-21 16:05:44 -05:00
purpasmart96 ebfd831ccb License change 2014-12-20 21:20:24 -08:00
bunnei 4fcdbed9f6 Thread: Wait current thread on svc_SleepThread
- Removed unused VBLANK sleep mode
- Added error log for bad context switch
- Renamed VerifyWait to CheckWaitType to be more clear
2014-12-20 23:20:19 -05:00
bunnei 7bae450379 Merge pull request #185 from purpasmart96/mem_perm
Kernel: Add missing permissions
2014-12-17 20:56:04 -05:00
Yuri Kunde Schlesner e321decf98 Remove SyncRequest from K::Object and create a new K::Session type
This is a first step at fixing the conceptual insanity that is our
handling of service and IPC calls. For now, interfaces still directly
derived from Session because we don't have the infrastructure to do it
properly. (That is, Processes and scheduling them.)
2014-12-15 18:26:17 -02:00
Subv 1051795c32 Kernel/Semaphores: Fixed build 2014-12-13 13:43:01 -05:00
Subv 49b31badba SVC: Implemented ReleaseSemaphore.
This behavior was tested on hardware, however i'm still not sure what use the "initial_count" parameter has
2014-12-13 13:40:10 -05:00
Subv 82c84883a5 SVC: Implemented svcCreateSemaphore
ToDo: Implement svcReleaseSemaphore
* Some testing against hardware needed
2014-12-13 13:40:09 -05:00
Yuri Kunde Schlesner 0600e2d8b5 Convert old logging calls to new logging macros 2014-12-13 02:08:02 -02:00
bunnei 4cb7a44d4e MemMap: Renamed "GSP" heap to "linear", as this is not specific to GSP.
- Linear simply indicates that the mapped physical address is always MappedVAddr+0x0C000000, thus this memory can be used for hardware devices' DMA (such as the GPU).
2014-12-12 00:15:47 -05:00
Subv 029ff9f1fd SVC: Implemented GetThreadId.
For now threads are using their Handle value as their Id, it should not really cause any problems because Handle values are unique in Citra, but it should be changed. I left a ToDo there because this is not correct behavior as per hardware.
2014-12-04 00:25:35 -05:00
bunnei f985469901 SVC: Add debug log to ArbitrateAddress. 2014-11-26 15:04:07 -05:00
bunnei e0e7443517 SVC: SleepThread should yield to the next ready thread. 2014-11-26 15:04:07 -05:00
Yuri Kunde Schlesner c2588403c0 HLE: Revamp error handling throrough the HLE code
All service calls in the CTR OS return result codes indicating the
success or failure of the call. Previous to this commit, Citra's HLE
emulation of services and the kernel universally either ignored errors
or returned dummy -1 error codes.

This commit makes an initial effort to provide an infrastructure for
error reporting and propagation which can be use going forward to make
HLE calls accurately return errors as the original system. A few parts
of the code have been updated to use the new system where applicable.

One part of this effort is the definition of the `ResultCode` type,
which provides facilities for constructing and parsing error codes in
the structured format used by the CTR.

The `ResultVal` type builds on `ResultCode` by providing a container for
values returned by function that can report errors. It enforces that
correct error checking will be done on function returns by preventing
the use of the return value if the function returned an error code.

Currently this change is mostly internal since errors are still
suppressed on the ARM<->HLE border, as a temporary compatibility hack.
As functionality is implemented and tested this hack can be eventually
removed.
2014-11-24 17:08:36 -02:00