mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-22 20:06:40 +00:00
Stratosphere: extract common code to libstratosphere.
This commit is contained in:
parent
6a51ce25b3
commit
b81ceeca21
15 changed files with 171 additions and 21 deletions
4
stratosphere/libstratosphere/.gitignore
vendored
Normal file
4
stratosphere/libstratosphere/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
debug
|
||||
release
|
||||
lib
|
||||
*.bz2
|
150
stratosphere/libstratosphere/Makefile
Normal file
150
stratosphere/libstratosphere/Makefile
Normal file
|
@ -0,0 +1,150 @@
|
|||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/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
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# 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
|
||||
#---------------------------------------------------------------------------------------
|
||||
|
8
stratosphere/libstratosphere/include/stratosphere.hpp
Normal file
8
stratosphere/libstratosphere/include/stratosphere.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "stratosphere/ipc_templating.hpp"
|
||||
#include "stratosphere/iwaitable.hpp"
|
||||
#include "stratosphere/iserviceobject.hpp"
|
||||
#include "stratosphere/servicesession.hpp"
|
||||
#include "stratosphere/serviceserver.hpp"
|
||||
#include "stratosphere/waitablemanager.hpp"
|
|
@ -1,12 +1,10 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <tuple>
|
||||
#include <boost/callable_traits.hpp>
|
||||
#include <type_traits>
|
||||
#include <iomanip>
|
||||
|
||||
/* Represents an A descriptor. */
|
||||
template <typename T>
|
|
@ -92,11 +92,7 @@ class ServiceServer : public IWaitable {
|
|||
Handle session_h;
|
||||
svcAcceptSession(&session_h, this->port_handle);
|
||||
|
||||
fprintf(stderr, "Accept %08X -> %08X\n", this->port_handle, session_h);
|
||||
fprintf(stderr, "Sessions: %08X/%08X\n", this->num_sessions, this->max_sessions);
|
||||
|
||||
if (this->num_sessions >= this->max_sessions) {
|
||||
fprintf(stderr, "Closing because of max sessions...\n");
|
||||
svcCloseHandle(session_h);
|
||||
return 0x10601;
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <type_traits>
|
||||
#include <cstdio>
|
||||
|
||||
#include "ipc_templating.hpp"
|
||||
#include "iserviceobject.hpp"
|
||||
|
@ -89,10 +88,7 @@ class ServiceSession : public IWaitable {
|
|||
|
||||
IpcParsedCommand r;
|
||||
IpcCommand c;
|
||||
|
||||
|
||||
fprintf(stderr, "Doing ServiceSession parse...\n");
|
||||
|
||||
|
||||
ipcInitialize(&c);
|
||||
|
||||
retval = ipcParse(&r);
|
|
@ -3,7 +3,7 @@
|
|||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
#include "waitablemanager.hpp"
|
||||
#include <stratosphere/waitablemanager.hpp>
|
||||
|
||||
|
||||
unsigned int WaitableManager::get_num_signalable() {
|
|
@ -48,18 +48,18 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \
|
|||
|
||||
CFLAGS += $(INCLUDE) -D__SWITCH__
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++1z
|
||||
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
|
||||
LIBS := -lstratosphere -lnx
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX)
|
||||
LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#include "iserviceobject.hpp"
|
||||
#include <stratosphere/iserviceobject.hpp>
|
||||
#include "ldr_registration.hpp"
|
||||
|
||||
enum DebugMonitorServiceCmd {
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
#include <malloc.h>
|
||||
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#include "waitablemanager.hpp"
|
||||
#include "serviceserver.hpp"
|
||||
#include "ldr_process_manager.hpp"
|
||||
#include "ldr_debug_monitor.hpp"
|
||||
#include "ldr_shell.hpp"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <stratosphere/iserviceobject.hpp>
|
||||
|
||||
#include "iserviceobject.hpp"
|
||||
#include "ldr_registration.hpp"
|
||||
#include "ldr_process_creation.hpp"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#include "iserviceobject.hpp"
|
||||
#include <stratosphere/iserviceobject.hpp>
|
||||
|
||||
enum ShellServiceCmd {
|
||||
Shell_Cmd_AddTitleToLaunchQueue = 0,
|
||||
|
|
Loading…
Reference in a new issue