From 5ef01edab5035e88c935d3db6059c70a6fcded85 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 8 Nov 2018 01:12:30 -0800 Subject: [PATCH] Delete libstratosphere in prep for submodule --- stratosphere/libstratosphere/.gitignore | 4 - stratosphere/libstratosphere/Makefile | 150 ---- .../libstratosphere/include/meta_tools.hpp | 53 -- .../libstratosphere/include/stratosphere.hpp | 33 - .../include/stratosphere/event.hpp | 132 ---- .../include/stratosphere/firmware_version.hpp | 49 -- .../include/stratosphere/hossynch.hpp | 215 ------ .../include/stratosphere/ipc.hpp | 22 - .../include/stratosphere/ipc/ipc_buffers.hpp | 117 --- .../stratosphere/ipc/ipc_domain_object.hpp | 128 ---- .../include/stratosphere/ipc/ipc_out.hpp | 75 -- .../stratosphere/ipc/ipc_response_context.hpp | 44 -- .../stratosphere/ipc/ipc_serialization.hpp | 666 ------------------ .../stratosphere/ipc/ipc_service_object.hpp | 130 ---- .../stratosphere/ipc/ipc_service_session.hpp | 356 ---------- .../ipc/ipc_session_manager_base.hpp | 34 - .../include/stratosphere/ipc/ipc_special.hpp | 144 ---- .../include/stratosphere/iwaitable.hpp | 80 --- .../include/stratosphere/message_queue.hpp | 73 -- .../include/stratosphere/mitm.hpp | 26 - .../stratosphere/mitm/imitmserviceobject.hpp | 43 -- .../stratosphere/mitm/mitm_query_service.hpp | 50 -- .../include/stratosphere/mitm/mitm_server.hpp | 112 --- .../stratosphere/mitm/mitm_session.hpp | 316 --------- .../include/stratosphere/mitm/sm_mitm.h | 24 - .../include/stratosphere/scope_guard.hpp | 61 -- .../include/stratosphere/servers.hpp | 87 --- .../include/stratosphere/services.hpp | 21 - .../include/stratosphere/services/smm_ams.h | 31 - .../include/stratosphere/version_check.hpp | 66 -- .../include/stratosphere/waitable_manager.hpp | 404 ----------- .../stratosphere/waitable_manager_base.hpp | 38 - .../libstratosphere/source/message_queue.cpp | 235 ------ .../source/mitm_query_service.cpp | 42 -- stratosphere/libstratosphere/source/sm_mitm.c | 190 ----- stratosphere/libstratosphere/source/smm_ams.c | 69 -- 36 files changed, 4320 deletions(-) delete mode 100644 stratosphere/libstratosphere/.gitignore delete mode 100644 stratosphere/libstratosphere/Makefile delete mode 100644 stratosphere/libstratosphere/include/meta_tools.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/event.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/firmware_version.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/hossynch.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_buffers.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_domain_object.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_out.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_response_context.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_serialization.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_service_object.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_service_session.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_session_manager_base.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ipc/ipc_special.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/iwaitable.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/message_queue.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/mitm.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/mitm/imitmserviceobject.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/mitm/mitm_query_service.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/mitm/mitm_server.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/mitm/mitm_session.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/mitm/sm_mitm.h delete mode 100644 stratosphere/libstratosphere/include/stratosphere/scope_guard.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/servers.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/services.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/services/smm_ams.h delete mode 100644 stratosphere/libstratosphere/include/stratosphere/version_check.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/waitable_manager.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/waitable_manager_base.hpp delete mode 100644 stratosphere/libstratosphere/source/message_queue.cpp delete mode 100644 stratosphere/libstratosphere/source/mitm_query_service.cpp delete mode 100644 stratosphere/libstratosphere/source/sm_mitm.c delete mode 100644 stratosphere/libstratosphere/source/smm_ams.c diff --git a/stratosphere/libstratosphere/.gitignore b/stratosphere/libstratosphere/.gitignore deleted file mode 100644 index 75ebfc783..000000000 --- a/stratosphere/libstratosphere/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -debug -release -lib -*.bz2 diff --git a/stratosphere/libstratosphere/Makefile b/stratosphere/libstratosphere/Makefile deleted file mode 100644 index 70ba1949b..000000000 --- a/stratosphere/libstratosphere/Makefile +++ /dev/null @@ -1,150 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -SOURCES := source -DATA := data -INCLUDES := include ../../common/include - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -LIBS := -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) -export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) -export OFILES := $(OFILES_BIN) $(OFILES_SRC) -export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I. \ - -iquote $(CURDIR)/include/switch/ - -.PHONY: clean all - -#--------------------------------------------------------------------------------- -all: lib/$(TARGET).a lib/$(TARGET)d.a - -lib: - @[ -d $@ ] || mkdir -p $@ - -release: - @[ -d $@ ] || mkdir -p $@ - -debug: - @[ -d $@ ] || mkdir -p $@ - -lib/$(TARGET).a : lib release $(SOURCES) $(INCLUDES) - @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ - BUILD_CFLAGS="-DNDEBUG=1 -O2" \ - DEPSDIR=$(CURDIR)/release \ - --no-print-directory -C release \ - -f $(CURDIR)/Makefile - -lib/$(TARGET)d.a : lib debug $(SOURCES) $(INCLUDES) - @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \ - BUILD_CFLAGS="-DDEBUG=1 -Og" \ - DEPSDIR=$(CURDIR)/debug \ - --no-print-directory -C debug \ - -f $(CURDIR)/Makefile - -dist-bin: all - @tar --exclude=*~ -cjf $(TARGET).tar.bz2 include lib - -dist-src: - @tar --exclude=*~ -cjf $(TARGET)-src.tar.bz2 include source Makefile - -dist: dist-src dist-bin - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr release debug lib *.bz2 - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT) : $(OFILES) - -$(OFILES_SRC) : $(HFILES) - -#--------------------------------------------------------------------------------- -%_bin.h %.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- - diff --git a/stratosphere/libstratosphere/include/meta_tools.hpp b/stratosphere/libstratosphere/include/meta_tools.hpp deleted file mode 100644 index f4c06e3c0..000000000 --- a/stratosphere/libstratosphere/include/meta_tools.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include - -namespace detail { - -template -struct class_of; - -template -struct class_of { - using type = C; -}; - -template -using class_of_t = typename class_of::type; - -template> -struct member_equals_fn_helper { - T ref; - Mem mem_fn; - - bool operator()(const C& val) const { - return (std::mem_fn(mem_fn)(val) == ref); - } - - bool operator()(C&& val) const { - return (std::mem_fn(mem_fn)(std::move(val)) == ref); - } -}; - -} // namespace detail - -template -auto member_equals_fn(Mem mem, T ref) { - return detail::member_equals_fn_helper{std::move(ref), std::move(mem)}; -} diff --git a/stratosphere/libstratosphere/include/stratosphere.hpp b/stratosphere/libstratosphere/include/stratosphere.hpp deleted file mode 100644 index 209e80e7e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "stratosphere/version_check.hpp" -#include "stratosphere/scope_guard.hpp" - -#include "stratosphere/hossynch.hpp" -#include "stratosphere/message_queue.hpp" -#include "stratosphere/iwaitable.hpp" -#include "stratosphere/event.hpp" - -#include "stratosphere/waitable_manager.hpp" - -#include "stratosphere/ipc.hpp" - -#include "stratosphere/mitm.hpp" - -#include "stratosphere/services.hpp" \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/event.hpp b/stratosphere/libstratosphere/include/stratosphere/event.hpp deleted file mode 100644 index 153cdd0df..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/event.hpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include -#include - -#include "iwaitable.hpp" - -class IEvent : public IWaitable { - public: - /* Information members. */ - Handle r_h; - Handle w_h; - bool autoclear; - public: - IEvent(bool a = false) : r_h(INVALID_HANDLE), w_h(INVALID_HANDLE), autoclear(a) { } - IEvent(Handle r, bool a = false) : r_h(r), w_h(INVALID_HANDLE), autoclear(a) { } - IEvent(Handle r, Handle w, bool a = false) : r_h(r), w_h(w), autoclear(a) { } - - ~IEvent() { - if (r_h != INVALID_HANDLE) { - svcCloseHandle(r_h); - } - if (w_h != INVALID_HANDLE) { - svcCloseHandle(w_h); - } - } - - /* Make it non-copyable */ - IEvent() = delete; - IEvent(const IEvent &) = delete; - IEvent& operator=(const IEvent&) = delete; - - - bool IsAutoClear() { - return this->autoclear; - } - - void Clear() { - std::scoped_lock lock(this->sig_lock); - this->is_signaled = false; - if (this->r_h != INVALID_HANDLE) { - svcResetSignal(this->r_h); - } - } - - void Signal() { - std::scoped_lock lock(this->sig_lock); - - if (this->w_h == INVALID_HANDLE && this->r_h != INVALID_HANDLE) { - /* We can't signal an event if we only have a read handle. */ - std::abort(); - } - - if (this->w_h == INVALID_HANDLE && this->is_signaled) { - return; - } - - this->is_signaled = true; - - if (this->w_h != INVALID_HANDLE) { - svcSignalEvent(this->w_h); - } else { - this->NotifyManagerSignaled(); - } - } - - virtual Result HandleSignaled(u64 timeout) = 0; - - /* IWaitable */ - virtual Handle GetHandle() override { - return this->r_h; - } -}; - -template -class HosEvent : public IEvent { - private: - F callback; - public: - HosEvent(F f, bool a = false) : IEvent(a), callback(std::move(f)) { } - HosEvent(Handle r, F f, bool a = false) : IEvent(r, a), callback(std::move(f)) { } - HosEvent(Handle r, Handle w, F f, bool a = false) : IEvent(r, w, a), callback(std::move(f)) { } - - virtual Result HandleSignaled(u64 timeout) override { - if (this->IsAutoClear()) { - this->Clear(); - } - return this->callback(timeout); - } -}; - -template -static IEvent *CreateHosEvent(F f, bool autoclear = false) { - return new HosEvent(INVALID_HANDLE, INVALID_HANDLE, std::move(f), autoclear); -} - -template -static IEvent *CreateSystemEvent(F f, bool autoclear = false) { - - Handle w_h, r_h; - if (R_FAILED(svcCreateEvent(&w_h, &r_h))) { - std::abort(); - } - - return new HosEvent(r_h, w_h, std::move(f), autoclear); -} - -template -static IEvent *CreateWriteOnlySystemEvent() { - return CreateSystemEvent([](u64 timeout) { std::abort(); return 0; }, a); -} - -template -static IEvent *LoadReadOnlySystemEvent(Handle r_h, F f, bool autoclear = false) { - return new HosEvent(r_h, f, autoclear); -} diff --git a/stratosphere/libstratosphere/include/stratosphere/firmware_version.hpp b/stratosphere/libstratosphere/include/stratosphere/firmware_version.hpp deleted file mode 100644 index 312c68c67..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/firmware_version.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -enum FirmwareVersion : u32 { - FirmwareVersion_Min = 0, - FirmwareVersion_100 = FirmwareVersion_Min, - FirmwareVersion_200 = 1, - FirmwareVersion_300 = 2, - FirmwareVersion_400 = 3, - FirmwareVersion_500 = 4, - FirmwareVersion_600 = 5, - FirmwareVersion_Current = FirmwareVersion_600, - FirmwareVersion_Max = 32, -}; - -static inline FirmwareVersion GetRuntimeFirmwareVersion() { - FirmwareVersion fw = FirmwareVersion_Min; - if (kernelAbove200()) { - fw = FirmwareVersion_200; - } - if (kernelAbove300()) { - fw = FirmwareVersion_300; - } - if (kernelAbove400()) { - fw = FirmwareVersion_400; - } - if (kernelAbove500()) { - fw = FirmwareVersion_500; - } - if (kernelAbove600()) { - fw = FirmwareVersion_600; - } - return fw; -} diff --git a/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp b/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp deleted file mode 100644 index 4f0cbd2de..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/hossynch.hpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include -#include - -class HosMutex { - private: - Mutex m; - Mutex *GetMutex() { - return &this->m; - } - public: - HosMutex() { - mutexInit(GetMutex()); - } - - void lock() { - mutexLock(GetMutex()); - } - - void unlock() { - mutexUnlock(GetMutex()); - } - - bool try_lock() { - return mutexTryLock(GetMutex()); - } - - void Lock() { - lock(); - } - - void Unlock() { - unlock(); - } - - bool TryLock() { - return try_lock(); - } - - friend class HosCondVar; -}; - -class HosRecursiveMutex { - private: - RMutex m; - RMutex *GetMutex() { - return &this->m; - } - public: - HosRecursiveMutex() { - rmutexInit(GetMutex()); - } - - void lock() { - rmutexLock(GetMutex()); - } - - void unlock() { - rmutexUnlock(GetMutex()); - } - - bool try_lock() { - return rmutexTryLock(GetMutex()); - } - - void Lock() { - lock(); - } - - void Unlock() { - unlock(); - } - - bool TryLock() { - return try_lock(); - } -}; - -class HosCondVar { - private: - CondVar cv; - public: - HosCondVar() { - condvarInit(&cv); - } - - Result TimedWait(u64 timeout, HosMutex *hm) { - return TimedWait(timeout, hm->GetMutex()); - } - - Result Wait(HosMutex *hm) { - return Wait(hm->GetMutex()); - } - - Result TimedWait(u64 timeout, Mutex *m) { - return condvarWaitTimeout(&cv, m, timeout); - } - - Result Wait(Mutex *m) { - return condvarWait(&cv, m); - } - - Result Wake(int num) { - return condvarWake(&cv, num); - } - - Result WakeOne() { - return condvarWakeOne(&cv); - } - - Result WakeAll() { - return condvarWakeAll(&cv); - } -}; - -class HosSemaphore { - private: - Semaphore s; - public: - HosSemaphore() { - semaphoreInit(&s, 0); - } - - HosSemaphore(u64 c) { - semaphoreInit(&s, c); - } - - void Signal() { - semaphoreSignal(&s); - } - - void Wait() { - semaphoreWait(&s); - } - - bool TryWait() { - return semaphoreTryWait(&s); - } -}; - -class TimeoutHelper { - private: - u64 end_tick; - public: - TimeoutHelper(u64 ns) { - /* Special case zero-time timeouts. */ - if (ns == 0) { - end_tick = 0; - return; - } - - u64 cur_tick = armGetSystemTick(); - this->end_tick = cur_tick + NsToTick(ns) + 1; - } - - static inline u64 NsToTick(u64 ns) { - return (ns * 12) / 625; - } - - static inline u64 TickToNs(u64 tick) { - return (tick * 625) / 12; - } - - bool TimedOut() { - if (this->end_tick == 0) { - return true; - } - - return armGetSystemTick() >= this->end_tick; - } -}; - -class HosThread { - private: - Thread thr = {0}; - public: - HosThread() {} - - Result Initialize(ThreadFunc entry, void *arg, size_t stack_sz, int prio, int cpuid = -2) { - return threadCreate(&this->thr, entry, arg, stack_sz, prio, cpuid); - } - - Handle GetHandle() const { - return this->thr.handle; - } - - Result Start() { - return threadStart(&this->thr); - } - - Result Join() { - Result rc = threadWaitForExit(&this->thr); - if (R_SUCCEEDED(rc)) { - rc = threadClose(&this->thr); - } - return rc; - } -}; \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc.hpp deleted file mode 100644 index e035fda52..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ipc.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "ipc/ipc_service_object.hpp" -#include "ipc/ipc_serialization.hpp" - -#include "ipc/ipc_service_session.hpp" \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_buffers.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_buffers.hpp deleted file mode 100644 index 6bf2f71c0..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_buffers.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include - -enum class IpcBufferType { - InBuffer, - OutBuffer, - InPointer, - OutPointer, -}; - -/* Base for In/Out Buffers. */ -struct IpcBufferBase {}; - -struct InOutBufferBase : public IpcBufferBase {}; - -/* Represents an A descriptor. */ -struct InBufferBase : public InOutBufferBase {}; - -template -struct InBuffer : public InBufferBase { - T *buffer; - size_t num_elements; - BufferType type; - static const BufferType expected_type = e_t; - - /* Convenience. */ - T& operator[](size_t i) const { - return buffer[i]; - } - - InBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { } -}; - -/* Represents a B descriptor. */ -struct OutBufferBase : public InOutBufferBase {}; - -template -struct OutBuffer : OutBufferBase { - T *buffer; - size_t num_elements; - BufferType type; - static const BufferType expected_type = e_t; - - /* Convenience. */ - T& operator[](size_t i) const { - return buffer[i]; - } - - OutBuffer(void *b, size_t n, BufferType t) : buffer((T *)b), num_elements(n/sizeof(T)), type(t) { } -}; - -/* Represents an X descriptor. */ -struct InPointerBase : public IpcBufferBase {}; - -template -struct InPointer : public InPointerBase { - T *pointer; - size_t num_elements; - - /* Convenience. */ - T& operator[](size_t i) const { - return pointer[i]; - } - - InPointer(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { } -}; - -/* Represents a C descriptor. */ -struct OutPointerWithServerSizeBase : public IpcBufferBase {}; - -template -struct OutPointerWithServerSize : public OutPointerWithServerSizeBase { - T *pointer; - static const size_t num_elements = N; - static const size_t element_size = sizeof(T); - - /* Convenience. */ - T& operator[](size_t i) const { - return pointer[i]; - } - - OutPointerWithServerSize(void *p) : pointer((T *)p) { } - OutPointerWithServerSize(void *p, size_t n) : pointer((T *)p) { } -}; - -struct OutPointerWithClientSizeBase : public IpcBufferBase {}; - -/* Represents a C descriptor with size in raw data. */ -template -struct OutPointerWithClientSize : public OutPointerWithClientSizeBase { - T *pointer; - size_t num_elements; - - /* Convenience. */ - T& operator[](size_t i) const { - return pointer[i]; - } - - OutPointerWithClientSize(void *p, size_t n) : pointer((T *)p), num_elements(n/sizeof(T)) { } -}; diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_domain_object.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_domain_object.hpp deleted file mode 100644 index 1394fc095..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_domain_object.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include -#include -#include - -#include "ipc_service_object.hpp" - -class IDomainObject; - -class DomainManager { - public: - virtual std::shared_ptr AllocateDomain() = 0; - virtual void FreeDomain(IDomainObject *domain) = 0; - virtual Result ReserveObject(IDomainObject *domain, u32 *out_object_id) = 0; - virtual Result ReserveSpecificObject(IDomainObject *domain, u32 object_id) = 0; - virtual void SetObject(IDomainObject *domain, u32 object_id, ServiceObjectHolder&& holder) = 0; - virtual ServiceObjectHolder *GetObject(IDomainObject *domain, u32 object_id) = 0; - virtual Result FreeObject(IDomainObject *domain, u32 object_id) = 0; - virtual Result ForceFreeObject(u32 object_id) = 0; -}; - -class IDomainObject : public IServiceObject { - private: - DomainManager *manager; - public: - IDomainObject(DomainManager *m) : manager(m) {} - - virtual ~IDomainObject() override { - this->manager->FreeDomain(this); - } - - DomainManager *GetManager() { - return this->manager; - } - - ServiceObjectHolder *GetObject(u32 object_id) { - return this->manager->GetObject(this, object_id); - } - - Result ReserveObject(u32 *out_object_id) { - return this->manager->ReserveObject(this, out_object_id); - } - - Result ReserveSpecificObject(u32 object_id) { - return this->manager->ReserveSpecificObject(this, object_id); - } - - void SetObject(u32 object_id, ServiceObjectHolder&& holder) { - this->manager->SetObject(this, object_id, std::move(holder)); - } - - Result FreeObject(u32 object_id) { - return this->manager->FreeObject(this, object_id); - } - - Result ForceFreeObject(u32 object_id) { - return this->manager->ForceFreeObject(object_id); - } - - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* IDomainObject has no callable functions. */ - }; -}; - -static constexpr bool IsDomainObject(ServiceObjectHolder &holder) { - return holder.GetServiceId() == ServiceObjectId(); -} - -static constexpr bool IsDomainObject(ServiceObjectHolder *holder) { - return holder->GetServiceId() == ServiceObjectId(); -} - -/* Out for service impl. */ -template -class Out> : public OutSessionTag { - static_assert(std::is_base_of_v, "OutSessions must be shared_ptr!"); - - template - friend class Out; - - private: - std::shared_ptr *srv; - IDomainObject *domain = nullptr; - u32 *object_id = nullptr; - public: - Out>(std::shared_ptr *s, IDomainObject *dm, u32 *o) : srv(reinterpret_cast *>(s)), domain(dm), object_id(o) { } - - ServiceObjectHolder GetHolder() { - std::shared_ptr clone = *srv; - return ServiceObjectHolder(std::move(clone)); - } - - bool IsDomain() { - return domain != nullptr; - } - - u32 GetObjectId() { - return *object_id; - } - - void ChangeObjectId(u32 o) { - domain->ForceFreeObject(*object_id); - domain->ReserveSpecificObject(o); - *object_id = o; - } - - void SetValue(std::shared_ptr &&s) { - *this->srv = std::move(s); - } -}; diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_out.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_out.hpp deleted file mode 100644 index fbd186d28..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_out.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include - -/* Declare false allowed struct. */ -template -struct AllowedOut : std::false_type {}; - -struct OutDataTag{}; -struct OutHandleTag{}; -struct OutSessionTag{}; - -/* Define out struct, so that we can get errors on enable_if */ -template -class Out { - static_assert(std::is_pod::value && !std::is_pod::value, "Invalid IPC Out Type!"); -}; - -template -class Out::value || AllowedOut::value>::type> : public OutDataTag { -private: - T *obj; -public: - Out(T *o) : obj(o) { } - - void SetValue(const T& t) { - *obj = t; - } - - const T& GetValue() { - return *obj; - } - - T *GetPointer() { - return obj; - } - - /* Convenience operators. */ - T& operator*() { - return *obj; - } - - T* operator->() { - return obj; - } -}; - -template -class Out { - static_assert(std::is_pod::value && !std::is_pod::value, "Invalid IPC Out Type (Raw Pointer)!"); -}; - -template -struct OutHelper; - -template -struct OutHelper> { - using type = T; -}; \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_response_context.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_response_context.hpp deleted file mode 100644 index 4e2ed8345..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_response_context.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -#include "ipc_service_object.hpp" -#include "ipc_domain_object.hpp" - -#include "ipc_special.hpp" - -#include "ipc_session_manager_base.hpp" - -struct IpcResponseContext { - /* Request/Reply data. */ - IpcParsedCommand request; - IpcCommand reply; - u8 out_data[0x100]; - std::shared_ptr *out_objs[8]; - Handle out_object_server_handles[8]; - IpcHandle out_handles[8]; - u32 out_object_ids[8]; - IpcCommandType cmd_type; - u64 cmd_id; - Result rc; - /* Context. */ - SessionManagerBase *manager; - ServiceObjectHolder *obj_holder; - unsigned char *pb; - size_t pb_size; -}; \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_serialization.hpp b/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_serialization.hpp deleted file mode 100644 index 7ce9bd39e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ipc/ipc_serialization.hpp +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Copyright (c) 2018 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include -#include -#include -#include -#include -#include - -#include "ipc_out.hpp" -#include "ipc_buffers.hpp" -#include "ipc_special.hpp" - -#include "ipc_domain_object.hpp" - -#include "ipc_response_context.hpp" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" - -template -struct PopFront; - -template -struct PopFront> { - using type = std::tuple; -}; - -template struct WhichType; - -template -struct TypeList{}; - -template -constexpr auto Concatenate(TypeList, TypeList) { - return TypeList{}; -} - -template