mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-15 07:34:23 -04:00
fatal: wip (pending libnx pr) update for new sf semantics
This commit is contained in:
parent
ed7c0605f9
commit
402e4d1adb
7 changed files with 191 additions and 28 deletions
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
u32 __nx_applet_type = AppletType_None;
|
||||
u32 __nx_fs_num_sessions = 1;
|
||||
|
||||
#define INNER_HEAP_SIZE 0x240000
|
||||
#define INNER_HEAP_SIZE 0x0
|
||||
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
|
||||
char nx_inner_heap[INNER_HEAP_SIZE];
|
||||
|
||||
|
@ -40,6 +40,9 @@ extern "C" {
|
|||
alignas(16) u8 __nx_exception_stack[ams::os::MemoryPageSize];
|
||||
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
|
||||
void __libnx_exception_handler(ThreadExceptionDump *ctx);
|
||||
|
||||
void *__libnx_thread_alloc(size_t size);
|
||||
void __libnx_thread_free(void *mem);
|
||||
}
|
||||
|
||||
namespace ams {
|
||||
|
@ -56,6 +59,29 @@ namespace ams {
|
|||
|
||||
using namespace ams;
|
||||
|
||||
namespace ams::fatal {
|
||||
|
||||
namespace {
|
||||
|
||||
constinit u8 g_fs_heap_memory[2_KB];
|
||||
lmem::HeapHandle g_fs_heap_handle;
|
||||
|
||||
void *AllocateForFs(size_t size) {
|
||||
return lmem::AllocateFromExpHeap(g_fs_heap_handle, size);
|
||||
}
|
||||
|
||||
void DeallocateForFs(void *p, size_t size) {
|
||||
return lmem::FreeToExpHeap(g_fs_heap_handle, p);
|
||||
}
|
||||
|
||||
void InitializeFsHeap() {
|
||||
g_fs_heap_handle = lmem::CreateExpHeap(g_fs_heap_memory, sizeof(g_fs_heap_memory), lmem::CreateOption_ThreadSafe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void __libnx_exception_handler(ThreadExceptionDump *ctx) {
|
||||
ams::CrashHandler(ctx);
|
||||
}
|
||||
|
@ -75,6 +101,9 @@ void __libnx_initheap(void) {
|
|||
void __appInit(void) {
|
||||
hos::InitializeForStratosphere();
|
||||
|
||||
fatal::InitializeFsHeap();
|
||||
fs::SetAllocator(fatal::AllocateForFs, fatal::DeallocateForFs);
|
||||
|
||||
sm::DoWithSession([&]() {
|
||||
R_ABORT_UNLESS(setInitialize());
|
||||
R_ABORT_UNLESS(setsysInitialize());
|
||||
|
@ -137,8 +166,38 @@ namespace {
|
|||
|
||||
sf::hipc::ServerManager<NumServers, ServerOptions, NumSessions> g_server_manager;
|
||||
|
||||
constinit sf::UnmanagedServiceObject<fatal::impl::IService, fatal::srv::Service> g_user_service_object;
|
||||
constinit sf::UnmanagedServiceObject<fatal::impl::IPrivateService, fatal::srv::Service> g_private_service_object;
|
||||
|
||||
}
|
||||
|
||||
namespace ams {
|
||||
|
||||
void *Malloc(size_t size) {
|
||||
AMS_ABORT("ams::Malloc was called");
|
||||
}
|
||||
|
||||
void Free(void *ptr) {
|
||||
AMS_ABORT("ams::Free was called");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void *operator new(size_t size) {
|
||||
AMS_ABORT("operator new(size_t) was called");
|
||||
}
|
||||
|
||||
void operator delete(void *p) {
|
||||
AMS_ABORT("operator delete(void *) was called");
|
||||
}
|
||||
|
||||
void *__libnx_thread_alloc(size_t size) {
|
||||
AMS_ABORT("__libnx_thread_alloc was called");
|
||||
}
|
||||
|
||||
void __libnx_thread_free(void *mem) {
|
||||
AMS_ABORT("__libnx_thread_free was called");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -156,8 +215,8 @@ int main(int argc, char **argv)
|
|||
fatal::srv::CheckRepairStatus();
|
||||
|
||||
/* Create services. */
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::impl::IPrivateService, fatal::srv::PrivateService>(PrivateServiceName, PrivateMaxSessions)));
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<fatal::impl::IService, fatal::srv::Service>(UserServiceName, UserMaxSessions)));
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterObjectForServer(g_user_service_object.GetShared(), UserServiceName, UserMaxSessions));
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterObjectForServer(g_private_service_object.GetShared(), PrivateServiceName, PrivateMaxSessions));
|
||||
|
||||
/* Add dirty event holder. */
|
||||
auto *dirty_event_holder = ams::fatal::srv::GetFatalDirtyWaitableHolder();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue