Commit graph

1478 commits

Author SHA1 Message Date
Subv 8432749db7 Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken.
This change makes for a clearer (less confusing) path of execution in the scheduler, now the code to execute when a thread awakes is closer to the code that puts the thread to sleep (WaitSynch1, WaitSynchN). It also allows us to implement the special wake up behavior of ReplyAndReceive without hacking up WaitObject::WakeupAllWaitingThreads.

If savestates are desired in the future, we can change this implementation to one similar to the CoreTiming event system, where we first register the callback functions at startup and assign their identifiers to the Thread callback variable instead of directly assigning a lambda to the wake up callback variable.
2017-09-28 11:53:32 -05:00
Subv 3165466b66 Kernel/Thread: Allow specifying which process a thread belongs to when creating it.
Don't automatically assume that Thread::Create will only be called when the parent process is currently scheduled. This assumption will be broken when applets or system modules are loaded.
2017-09-26 17:40:49 -05:00
Subv e27ae04696 HLE/APT: Always set up the APT parameter when starting a library applet.
Only use the HLE interface if an HLE applet with the desired id was started.

This commit reorganizes the APT code surrounding parameter creation and delivery to make it easier to support LLE applets in the future.

As future work, the HLE applet interface can be reworked to utilize the same facilities as the LLE interface.
2017-09-25 23:47:50 -05:00
Subv 774e7deae8 HLE/Archives: Allow multiple loaded applications to access their SelfNCCH archive independently.
The loaders now register each loaded ROM with the SelfNCCH factory, which keeps the data around for the duration of the emulation session.

When opening the SelfNCCH archive, the factory queries the current program's programid and uses that as a key to the map that contains the NCCHData structure (RomFS, Icon, Banner, etc).

3dsx files do not have a programid and will use a default of 0 for this value, thus, only 1 3dsx file with RomFS is loadable at the same time.
2017-09-25 09:45:02 -05:00
B3n30 d881dee818 Merge pull request #2952 from MerryMage/page-tables
Switchable Page Tables
2017-09-25 08:29:32 +02:00
B3n30 a21b9deb98 Merge pull request #2948 from Subv/register_service
HLE/SRV: Implemented RegisterService.
2017-09-25 08:22:05 +02:00
B3n30 d673d508dd Services/UDS: Added a function to send EAPoL-Start packets (#2920)
* Services/UDS: Added a function to generate the EAPoL-Start packet body.

* Services/UDS: Added filter for beacons.

* Services/UDS: Lock a mutex when accessing connection_status from both the emulation and network thread.

* Services/UDS: Handle the Association Response frame and respond with the EAPoL-Start frame.

* fixup: make use of current_node, changed received_beacons into a list, mutex and assert corrections

* fixup: fix damn clang-format
2017-09-25 08:16:27 +02:00
MerryMage c02bbb7030 memory: Add GetCurrentPageTable/SetCurrentPageTable
Don't expose Memory::current_page_table as a global.
2017-09-24 22:42:42 +01:00
Subv 7096f01c14 HLE/APT: Always return an error from PrepareToStartNewestHomeMenu so that the Home Menu doesn't try to reboot the system.
As per 3dbrew:
"During Home Menu start-up it uses APT:PrepareToStartNewestHomeMenu. If that doesn't return an error(normally NS returns 0xC8A0CFFC for that), Home Menu starts a hardware reboot with APT:StartNewestHomeMenu etc. "
2017-09-24 08:59:31 -05:00
Subv b57d58c0dc HLE/APT: Prepare the APT Wakeup parameter when the game calls Initialize
We need to know what is being run so we can set the APT parameter destination AppId correctly.
Delaying the preparation of the parameter until we know which AppId is running lets us support booting both the Home Menu and normal game Applications.
2017-09-24 08:59:30 -05:00
Subv 0b33e36292 HLE/SRV: Implemented RegisterService.
Now system modules can do more than just crash immediately on startup.
2017-09-24 00:12:58 -05:00
Yuri Kunde Schlesner 255fd8768d Merge pull request #2906 from Subv/ns_new_framework
Services/NS: Port ns:s to the new service framework.
2017-09-16 21:13:51 +02:00
Subv 3d86e3afc4 Services/NS: Port ns:s to the new service framework. 2017-09-16 10:52:45 -05:00
B3n30 813837c5cf Merge pull request #2842 from Subv/switchable_page_table
Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
2017-09-15 22:41:45 +02:00
Subv b178089251 Kernel/Threads: Don't clear the CPU instruction cache when performing a context switch from an idle thread into a thread in the same process.
We were unnecessarily clearing the cache when going from Process A -> Idle -> Process A, this caused extreme performance regressions.
2017-09-15 14:26:15 -05:00
Subv 214150f00c Kernel/Memory: Changed GetPhysicalPointer so that it doesn't go through the current process' page table to obtain a pointer. 2017-09-15 14:26:13 -05:00
bunnei 588077184b Merge pull request #2915 from wwylele/font-archive-2
APT: load different shared font depending on the region
2017-09-11 21:39:56 -04:00
Subv c34ec5e77c Kernel/Memory: Switch the current page table when a new process is scheduled. 2017-09-10 15:14:31 -05:00
Subv 6d2734a074 Kernel/Memory: Give each Process its own page table.
The loader is in charge of setting the newly created process's page table as the main one during the loading process.
2017-09-10 15:13:41 -05:00
Weiyi Wang 617b6974b9 Merge pull request #2831 from Subv/uds_auth
Services/UDS: Handle beacon frames and the basic AP connection sequence frames.
2017-09-05 15:03:56 +03:00
mailwl 11f2eff17d Remove _flag in var names 2017-09-04 12:15:15 +03:00
mailwl 589babbf74 Mii Selector Applet: update Mii structures 2017-09-04 12:04:12 +03:00
wwylele 59a9aaf388 APT: load different shared font depending on the region 2017-09-03 12:34:11 +03:00
bunnei 75cd28a7cc Merge pull request #2899 from wwylele/touch-refactor
Refactor touch input into a TouchDevice
2017-08-29 11:29:10 -04:00
danzel 8266064796 Use recursive_mutex instead of mutex to fix #2902 2017-08-29 20:39:55 +12:00
Subv f64cd87604 Services/UDS: Remove an old duplicated declaration of WifiPacket. 2017-08-27 10:48:15 -05:00
Subv d088dbfbe1 Services/UDS: Handle the connection sequence packets.
There is currently no stage tracking, a client is considered "Connected" when it receives the EAPoL Logoff packet from the server, this is not yet implemented.
2017-08-27 10:48:13 -05:00
Subv 2e9f544ecc Services/UDS: Store the received beacon frames until RecvBeaconBroadcastData is called, up to 15 beacons at the same time, removing any older beacon frames when the limit is exceeded. 2017-08-27 10:48:11 -05:00
Subv 54411bef4e Services/UDS: Add functions to generate 802.11 auth and assoc response frames. 2017-08-27 10:48:09 -05:00
wwylele c84e60b470 HID: use TouchDevice for touch pad 2017-08-24 13:56:43 +03:00
James Rowe 61442d6afb Merge pull request #2839 from Subv/global_kernel_lock
Kernel/HLE: Use a mutex  to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
2017-08-23 18:17:44 -06:00
bunnei 2bbff9fa96 Merge pull request #2893 from Subv/not_schedule_main_thread
Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.
2017-08-22 17:45:47 -04:00
Subv bca8916cea Kernel/HLE: Use a mutex to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
This mutex is acquired in SVC::CallSVC, ie, as soon as the guest application enters the HLE kernel, and should be acquired by the aforementioned threads before modifying kernel structures.
2017-08-22 09:30:55 -05:00
Subv fa228ca637 Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.
This is necessary for loading multiple processes at the same time.
The main thread will be automatically scheduled when necessary once the scheduler runs.
2017-08-21 20:54:29 -05:00
Subv 65f19b51c4 Warnings: Add UNREACHABLE macros to switches that contemplate all possible values. 2017-08-21 08:34:28 -05:00
Subv 145a7293a3 HLE/Applets: Fixed some conversion warnings when creating the framebuffer shared memory objects. 2017-08-21 08:34:27 -05:00
James Rowe bbfa9d0635 Merge pull request #2861 from wwylele/motion-refactor
Refactor MotionEmu into a InputDevice
2017-08-19 23:43:01 -06:00
wwylele 54c0c8adee HID: fix a comment and a warning 2017-08-20 08:37:48 +03:00
Yuri Kunde Schlesner 21204ba488 Merge pull request #2881 from MerryMage/dsp-firm-check
dsp_dsp: Remove size assertion in LoadComponent
2017-08-15 20:14:41 -07:00
MerryMage b67c2dc82c dsp_dsp: Remove size assertion in LoadComponent 2017-08-15 10:16:50 +01:00
Sebastian Valle d59f503729 Merge pull request #2843 from Subv/applet_slots
Services/APT: Use an array to hold data about the 4 possible concurrent applet types (Application, Library, HomeMenu, System)
2017-08-12 10:27:57 -05:00
wwylele 867eabd6b7 HID: use MotionDevice for Accelerometer and Gyroscope 2017-08-11 11:03:18 +03:00
Weiyi Wang aaf5161344 Merge pull request #2863 from wwylele/pad-state-zero
HID: zero unused PadState bits
2017-08-10 17:50:18 +03:00
wwylele 599de29ea3 HID: zero unused PadState bits 2017-08-10 17:01:03 +03:00
bunnei c2466a2f19 Merge pull request #2862 from j-selby/update-cryptopp
Update CryptoPP (byte ambiguity)
2017-08-09 16:18:43 -04:00
mailwl a6273dd56a Service/dlp: Update function tables according 3dbrew 2017-08-09 16:14:07 +03:00
James 1a44949ef7 Update cryptopp 2017-08-08 17:50:09 +10:00
Subv 177e8ce655 Services/APT: Use the AppletAttributes union directly when dealing with applet attrs. 2017-08-07 16:09:55 -05:00
Subv 73fba0de46 Services/APT: Use an array to hold data about the 4 possible concurrent applet types (Application, Library, HomeMenu, System).
This gives each applet type its own set of events as per the real NS module.
2017-08-07 14:53:58 -05:00
bunnei 5c631ec9c5 telemetry: Add field for RequiresSharedFont. 2017-08-03 20:10:37 -04:00
bunnei f15e5522dc Merge pull request #2840 from Subv/apt_parameter
Services/APT: Corrected the behavior of the Receive/Send/Glance/CancelParameter functions
2017-07-27 11:14:27 -04:00
Weiyi Wang 045d0b5bbd Merge pull request #2799 from yuriks/virtual-cached-range-flush
Add address conversion functions returning optional, Add function to flush virtual region from rasterizer cache
2017-07-22 10:15:52 +03:00
Subv e59ab7c1d6 Service/APT: Log Send/Cancel/Receive/GlanceParameter calls even if they return an error. 2017-07-21 15:03:06 -05:00
Subv 68596a7068 Services/APT: Return the proper error code when calling SendParameter with an outstanding parameter already in memory. 2017-07-21 14:59:26 -05:00
Subv a9bc417f59 Services/APT: Reset the APT parameter inside CancelParameter if the conditions are met. 2017-07-21 14:59:25 -05:00
Subv e403638d9b Services/APT: Properly clear the apt parameter after a successful ReceiveParameter call. 2017-07-21 14:59:22 -05:00
Subv 2dc720c355 Services/APT: Use the right error codes in ReceiveParameter and GlanceParameter when the parameter doesn't exist. 2017-07-21 14:59:21 -05:00
Subv 5682608df7 Services/APT: Use boost::optional for the APT parameter structure. 2017-07-21 14:59:20 -05:00
B3n30 7dbbd8a02e stubbed frd::UnscrambleLocalFriendCode (#2827) 2017-07-16 21:32:08 -05:00
Weiyi Wang e634b75754 Merge pull request #2784 from wwylele/font-archive
load shared font from system archive
2017-07-16 20:12:55 +03:00
mailwl 8582194a4c Service/boss:P: Add some functions to FunctionTable 2017-07-01 12:21:38 +03:00
Sebastian Valle 56d718b2a1 Merge pull request #2793 from Subv/replyandreceive
Kernel/SVC: Partially implemented svcReplyAndReceive
2017-06-29 17:05:22 -05:00
Subv b53fa9514f Kernel/SVC: Pass the current thread as a parameter to ClientSession::SendSyncRequest. 2017-06-29 12:30:34 -05:00
Sebastian Valle fa53ccc74b Merge pull request #2778 from Subv/uds_more
Services/UDS: Stub SendTo to generate the unencrypted data frames with the right headers
2017-06-26 19:35:52 -05:00
Subv 2eb174713b UDS: Use the ToDS and FromDS fields to properly calculate the AAD used during encryption. 2017-06-26 12:24:14 -05:00
Subv 1f1739d366 UDS: Move the UDS keyslot used to generate the CCMP key to the AES::KeySlotID enum. 2017-06-26 12:24:13 -05:00
Subv 87168bfe8b UDS: Run clang-format. 2017-06-26 12:24:11 -05:00
Subv 9befb8c887 UDS: Added functions to encrypt and decrypt the data frames.
The responsibility of encryption and encapsulation into an 802.11 MAC frame will fall into the callers of GenerateDataPayload.
2017-06-26 12:24:09 -05:00
Subv c3c9175a1c Kernel/Sessions: Clean up the list of pending request threads of a session when the client endpoint is closed. 2017-06-25 23:38:29 -05:00
Subv 88c93a7436 Kernel/SVC: Partially implemented svcReplyAndReceive.
It behaves mostly as WaitSynchronizationN with wait_all = false, except for IPC buffer translation.

The target thread of an IPC response will now wake up when responding.
IPC buffer translation is currently not implemented.
Error passing back to svcSendSyncRequest is currently not implemented.
2017-06-25 23:38:28 -05:00
wwylele 9549eed0be apt: load shared font from system archive 2017-06-26 01:38:12 +03:00
wwylele 22994607cc apt/shared_font: don't relocate zero offset 2017-06-26 00:43:23 +03:00
Subv 8feeb81af2 Kernel/ServerSession: Keep track of which threads have issued sync requests. 2017-06-25 14:47:25 -05:00
Yuri Kunde Schlesner e192d417ec Kernel: Implement AcceptSession SVC 2017-06-23 11:26:37 -07:00
Yuri Kunde Schlesner 8c6a8edaca Kernel: Fix SVC wrapper for CreatePort
The return parameters were flipped.
2017-06-23 11:22:04 -07:00
Yuri Kunde Schlesner aa0f3047d3 Kernel: Implement CreateSessionToPort SVC 2017-06-23 11:22:02 -07:00
Yuri Kunde Schlesner 6d436d7a52 Merge pull request #2798 from yuriks/svc-create-session
Kernel: Implement CreateSession SVC
2017-06-23 11:18:49 -07:00
Yuri Kunde Schlesner f94093d0fd Kernel: Implement CreateSession SVC 2017-06-22 00:39:27 -07:00
Yuri Kunde Schlesner d553135748 Memory: Add function to flush a virtual range from the rasterizer cache
This is slightly more ergonomic to use, correctly handles virtual
regions which are disjoint in physical addressing space, and checks only
regions which can be cached by the rasterizer.
2017-06-21 22:57:12 -07:00
Yuri Kunde Schlesner 326e7c7020 Memory: Make PhysicalToVirtualAddress return a boost::optional
And fix a few places in the code to take advantage of that.
2017-06-21 22:55:17 -07:00
Yuri Kunde Schlesner f64d0b3f26 Kernel/IPC: Support translation of null handles
Missed this in my first implementation. Thanks to @wwylele for pointing
out that this was missing.
2017-06-21 14:27:03 -07:00
Weiyi Wang c4f0927a62 Merge pull request #2789 from yuriks/misc-kernel
Trivial no-op additions
2017-06-21 20:34:12 +03:00
Yuri Kunde Schlesner b21dfbb295 Merge pull request #2790 from yuriks/remove-movefrom
Remove ResultVal::MoveFrom
2017-06-20 22:04:09 -07:00
Sebastian Valle 96dcccc80c Merge pull request #2779 from Subv/uds_more2
UDS: Added a hook for updating the connection status when a client connects to the network.
2017-06-21 02:29:00 +00:00
Yuri Kunde Schlesner 723dc644fa ResultVal: Remove MoveFrom()
Replace it with std::move(result_val).Unwrap(), or Foo().Unwrap() in
case you already have an rvalue.
2017-06-18 19:03:15 -07:00
Yuri Kunde Schlesner 4cb47b0278 ResultVal: Add an rvalue overload of Unwrap() 2017-06-18 18:49:46 -07:00
Yuri Kunde Schlesner 90b8d4dd36 Kernel: Add comment about the extended linear heap area 2017-06-18 18:38:40 -07:00
Yuri Kunde Schlesner 0dfafdbe59 Kernel/IPC: Make HLERequestContext usable from outside kernel 2017-06-18 16:05:12 -07:00
Subv 812b404492 UDS: Clarify comment about the first 4 bytes of the SecureData header.
It is likely that these 4 bytes are actually a different header, part of some protocol that encapsulates the SecureData protocol.
2017-06-15 12:08:55 -05:00
Subv 61ce89a55a UDS: Return the correct error messages in SendTo when not connected to a network or trying to send to itself. 2017-06-15 12:08:54 -05:00
Subv 7efb64132d UDS: Stub SendTo to generate the unencrypted data frame with the right headers. 2017-06-15 12:08:53 -05:00
Subv 38ceab13f6 UDS: Added a hook for updating the connection status when a client connects to the network. 2017-06-15 11:57:49 -05:00
Sebastian Valle ac168eeb5d Services/UDS: Set the proper bit in the ConnectionStatus structure when creating a network. (#2738)
* Services/UDS: Set the proper bit in the ConnectionStatus structure when creating a network.

This lets the application know that the host was successfully added to the session.

* Services/UDS: Reset the connection status when destroying the network

* Services/UDS: Reset the connection status's bitmask of changed nodes after reporting it to the game.
2017-06-13 22:00:58 +03:00
Yuri Kunde Schlesner d8f6000f54 Kernel/IPC: Use boost::small_vector for HLE context objects 2017-06-11 16:34:13 -07:00
Yuri Kunde Schlesner 92ca422088 Kernel: Allow clearing request_objects to re-use buffer space
Reduces the necessary allocation to max(in_handles, out_handles) rather
than (in_handles + out_handles).
2017-06-11 13:10:21 -07:00
Yuri Kunde Schlesner 8cb65fe65a Kernel: Basic support for IPC translation for HLE services 2017-06-11 13:10:21 -07:00
Yuri Kunde Schlesner 7656d83df5 Service/sm: Convert srv: to use IPC helpers 2017-06-11 13:10:21 -07:00
Yuri Kunde Schlesner 21436f5ef7 IPC: Add Pop/PushObjects methods to RequestParser/Builder
These use the context functions to create and look-up handles for the
user.
2017-06-11 13:10:20 -07:00
Yuri Kunde Schlesner 1c4b0ebb1f IPC: Add basic HLERequestContext support to RequestParser/Builder 2017-06-11 13:10:16 -07:00
Yuri Kunde Schlesner 05fee70211 Kernel: Add methods in HLERequestContext abstracting handle creation 2017-06-11 13:07:33 -07:00