mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 07:04:24 -04:00
gpio: implement more of server library for boot sysmodule client usage
This commit is contained in:
parent
e1b5d81d65
commit
bd3ab76fd2
26 changed files with 1162 additions and 24 deletions
|
@ -23,6 +23,7 @@ namespace ams::gpio {
|
|||
/* TODO: Manager object. */
|
||||
constinit os::SdkMutex g_init_mutex;
|
||||
constinit int g_initialize_count = 0;
|
||||
constinit bool g_remote = false;
|
||||
std::shared_ptr<sf::IManager> g_manager;
|
||||
|
||||
using InternalSession = std::shared_ptr<gpio::sf::IPadSession>;
|
||||
|
@ -40,9 +41,19 @@ namespace ams::gpio {
|
|||
if ((g_initialize_count++) == 0) {
|
||||
R_ABORT_UNLESS(::gpioInitialize());
|
||||
g_manager = ams::sf::MakeShared<sf::IManager, RemoteManagerImpl>();
|
||||
g_remote = true;
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeWith(std::shared_ptr<gpio::sf::IManager> &&sp) {
|
||||
std::scoped_lock lk(g_init_mutex);
|
||||
|
||||
AMS_ABORT_UNLESS(g_initialize_count == 0);
|
||||
|
||||
g_manager = std::move(sp);
|
||||
g_initialize_count = 1;
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
std::scoped_lock lk(g_init_mutex);
|
||||
|
||||
|
@ -50,7 +61,9 @@ namespace ams::gpio {
|
|||
|
||||
if ((--g_initialize_count) == 0) {
|
||||
g_manager.reset();
|
||||
::gpioExit();
|
||||
if (g_remote) {
|
||||
::gpioExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue