mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-22 02:12:06 +00:00
ro: only hold sm session open when needed
This commit is contained in:
parent
30485f1df9
commit
13c825a8bb
2 changed files with 31 additions and 33 deletions
|
@ -13,7 +13,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -35,7 +35,7 @@ extern "C" {
|
||||||
#define INNER_HEAP_SIZE 0x30000
|
#define INNER_HEAP_SIZE 0x30000
|
||||||
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
|
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
|
||||||
char nx_inner_heap[INNER_HEAP_SIZE];
|
char nx_inner_heap[INNER_HEAP_SIZE];
|
||||||
|
|
||||||
void __libnx_initheap(void);
|
void __libnx_initheap(void);
|
||||||
void __appInit(void);
|
void __appInit(void);
|
||||||
void __appExit(void);
|
void __appExit(void);
|
||||||
|
@ -66,36 +66,33 @@ void __libnx_initheap(void) {
|
||||||
|
|
||||||
void __appInit(void) {
|
void __appInit(void) {
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
SetFirmwareVersionForLibnx();
|
SetFirmwareVersionForLibnx();
|
||||||
|
|
||||||
rc = smInitialize();
|
DoWithSmSession([&]() {
|
||||||
if (R_FAILED(rc)) {
|
rc = setsysInitialize();
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = setsysInitialize();
|
|
||||||
if (R_FAILED(rc)) {
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = fsInitialize();
|
|
||||||
if (R_FAILED(rc)) {
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetRuntimeFirmwareVersion() < FirmwareVersion_300) {
|
|
||||||
rc = pminfoInitialize();
|
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
rc = fsInitialize();
|
||||||
rc = fsdevMountSdmc();
|
if (R_FAILED(rc)) {
|
||||||
if (R_FAILED(rc)) {
|
std::abort();
|
||||||
std::abort();
|
}
|
||||||
}
|
|
||||||
|
if (GetRuntimeFirmwareVersion() < FirmwareVersion_300) {
|
||||||
|
rc = pminfoInitialize();
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = fsdevMountSdmc();
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);
|
CheckAtmosphereVersion(CURRENT_ATMOSPHERE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +103,6 @@ void __appExit(void) {
|
||||||
pminfoExit();
|
pminfoExit();
|
||||||
}
|
}
|
||||||
setsysExit();
|
setsysExit();
|
||||||
smExit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helpers to create RO objects. */
|
/* Helpers to create RO objects. */
|
||||||
|
@ -120,7 +116,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Static server manager. */
|
/* Static server manager. */
|
||||||
static auto s_server_manager = WaitableManager(1);
|
static auto s_server_manager = WaitableManager(1);
|
||||||
|
|
||||||
/* Create services. */
|
/* Create services. */
|
||||||
s_server_manager.AddWaitable(new ServiceServer<DebugMonitorService>("ro:dmnt", 2));
|
s_server_manager.AddWaitable(new ServiceServer<DebugMonitorService>("ro:dmnt", 2));
|
||||||
/* NOTE: Official code passes 32 for ldr:ro max sessions. We will pass 2, because that's the actual limit. */
|
/* NOTE: Official code passes 32 for ldr:ro max sessions. We will pass 2, because that's the actual limit. */
|
||||||
|
|
|
@ -30,9 +30,11 @@ static Registration::RoProcessContext g_process_contexts[Registration::MaxSessio
|
||||||
static bool g_is_development_hardware, g_is_development_function_enabled;
|
static bool g_is_development_hardware, g_is_development_function_enabled;
|
||||||
|
|
||||||
void Registration::Initialize() {
|
void Registration::Initialize() {
|
||||||
if (R_FAILED(splInitialize())) {
|
DoWithSmSession([&]() {
|
||||||
std::abort();
|
if (R_FAILED(splInitialize())) {
|
||||||
}
|
std::abort();
|
||||||
|
}
|
||||||
|
});
|
||||||
ON_SCOPE_EXIT { splExit(); };
|
ON_SCOPE_EXIT { splExit(); };
|
||||||
|
|
||||||
if (R_FAILED(splIsDevelopment(&g_is_development_hardware))) {
|
if (R_FAILED(splIsDevelopment(&g_is_development_hardware))) {
|
||||||
|
|
Loading…
Reference in a new issue