diff --git a/README.md b/README.md index 66d2257d..da207a78 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ In addition to those credited in [Atmosphère's credits](https://github.com/Atmo * @[devkitPro](https://github.com/devkitPro) * @[yellows8](https://github.com/yellows8) * @[qlutoo](https://github.com/plutooo) +* @[hedgeberg](https://github.com/hedgeberg) * @[Nintendo](https://github.com/Nintendo) * @[NVidia](https://github.com/NVidia) +* @[Kaphotics](https://github.com/kwsch) Additional credits may be found in the README.md for specific libraries. \ No newline at end of file diff --git a/config/common.mk b/config/common.mk index 037b4c17..91505afd 100644 --- a/config/common.mk +++ b/config/common.mk @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------------- export ATMOSPHERE_CONFIG_MAKE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -export ATMOSPHERE_LIBRARY_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/.. +export ATMOSPHERE_LIBRARIES_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/.. ifeq ($(strip $(ATMOSPHERE_BOARD)),) export ATMOSPHERE_BOARD := nx-hac-001 @@ -18,9 +18,57 @@ export ATMOSPHERE_ASFLAGS := ifeq ($(ATMOSPHERE_BOARD),nx-hac-001) -export ATMOSPHERE_ARCH_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/arch/arm64 -export ATMOSPHERE_BOARD_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/board/nintendo/switch +export ATMOSPHERE_ARCH_DIR := arch/arm64 +export ATMOSPHERE_BOARD_DIR := board/nintendo/switch +export ATMOSPHERE_OS_DIR := os/horizon + +export ATMOSPHERE_ARCH_NAME := arm64 +export ATMOSPHERE_BOARD_NAME := nintendo_switch +export ATMOSPHERE_OS_NAME := horizon endif + +export ATMOSPHERE_ARCH_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/$(ATMOSPHERE_ARCH_DIR) +export ATMOSPHERE_BOARD_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/$(ATMOSPHERE_BOARD_DIR) +export ATMOSPHERE_OS_MAKE_DIR := $(ATMOSPHERE_CONFIG_MAKE_DIR)/$(ATMOSPHERE_OS_DIR) + include $(ATMOSPHERE_ARCH_MAKE_DIR)/arch.mk include $(ATMOSPHERE_BOARD_MAKE_DIR)/board.mk +include $(ATMOSPHERE_OS_MAKE_DIR)/os.mk + +#--------------------------------------------------------------------------------- +# get atmosphere git revision information +#--------------------------------------------------------------------------------- +export ATMOSPHERE_GIT_BRANCH := $(shell git symbolic-ref --short HEAD) + +ifeq ($(strip $(shell git status --porcelain 2>/dev/null)),) +export ATMOSPHERE_GIT_REVISION := $(ATMOSPHERE_GIT_BRANCH)-$(shell git rev-parse --short HEAD) +else +export ATMOSPHERE_GIT_REVISION := $(ATMOSPHERE_GIT_BRANCH)-$(shell git rev-parse --short HEAD)-dirty +endif + +ATMOSPHERE_DEFINES += -DATMOSPHERE_GIT_BRANCH=\"$(ATMOSPHERE_GIT_BRANCH)\" -DATMOSPHERE_GIT_REVISION=\"$(ATMOSPHERE_GIT_REVISION)\" + +#--------------------------------------------------------------------------------- +# 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 +#--------------------------------------------------------------------------------- +export TARGET := $(notdir $(CURDIR)) +export BUILD := build +export DATA := data +export INCLUDES := include +export SOURCES ?= $(shell find source -type d \ + -not \( -path source/arch -prune \) \ + -not \( -path source/board -prune \) \) + +ifneq ($(strip $(wildcard source/$(ATMOSPHERE_ARCH_DIR)./.*)),) +SOURCES += $(shell find source/$(ATMOSPHERE_ARCH_DIR) -type d) +endif +ifneq ($(strip $(wildcard source/$(ATMOSPHERE_BOARD_DIR)./.*)),) +SOURCES += $(shell find source/$(ATMOSPHERE_BOARD_DIR) -type d) +endif +ifneq ($(strip $(wildcard source/$(ATMOSPHERE_OS_DIR)./.*)),) +SOURCES += $(shell find source/$(ATMOSPHERE_OS_DIR) -type d) +endif diff --git a/config/os/horizon/os.mk b/config/os/horizon/os.mk new file mode 100644 index 00000000..5c972b74 --- /dev/null +++ b/config/os/horizon/os.mk @@ -0,0 +1,5 @@ +export ATMOSPHERE_DEFINES += -DATMOSPHERE_OS_HORIZON +export ATMOSPHERE_SETTINGS += +export ATMOSPHERE_CFLAGS += +export ATMOSPHERE_CXXFLAGS += +export ATMOSPHERE_ASFLAGS += diff --git a/config/templates/stratosphere.mk b/config/templates/stratosphere.mk new file mode 100644 index 00000000..a876019d --- /dev/null +++ b/config/templates/stratosphere.mk @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------------------- +# pull in common atmosphere configuration +#--------------------------------------------------------------------------------- +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../common.mk + +#--------------------------------------------------------------------------------- +# pull in switch rules +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif + +include $(DEVKITPRO)/libnx/switch_rules + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +export DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_STRATOSPHERE +export SETTINGS := $(ATMOSPHERE_SETTINGS) -O2 +export CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) +export CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) +export ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) + +export CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ + -Wl,--wrap,__cxa_throw \ + -Wl,--wrap,__cxa_rethrow \ + -Wl,--wrap,__cxa_allocate_exception \ + -Wl,--wrap,__cxa_free_exception \ + -Wl,--wrap,__cxa_begin_catch \ + -Wl,--wrap,__cxa_end_catch \ + -Wl,--wrap,__cxa_call_unexpected \ + -Wl,--wrap,__cxa_call_terminate \ + -Wl,--wrap,__gxx_personality_v0 \ + -Wl,--wrap,_Unwind_Resume \ + -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ + -Wl,--wrap,_ZSt20__throw_length_errorPKc \ + -Wl,--wrap,_ZNSt11logic_errorC2EPKc + +export LDFLAGS := -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) + +export LIBS := -lstratosphere -lnx + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +export LIBDIRS := $(PORTLIBS) $(LIBNX) $(ATMOSPHERE_LIBRARIES_DIR)/libvapours $(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere + +#--------------------------------------------------------------------------------- +# stratosphere sysmodules may (but usually do not) have an exefs source dir +#--------------------------------------------------------------------------------- +export EXEFS_SRC := exefs_src \ No newline at end of file diff --git a/libstratosphere/Makefile b/libstratosphere/Makefile index 7efd98a9..928fe042 100644 --- a/libstratosphere/Makefile +++ b/libstratosphere/Makefile @@ -12,17 +12,6 @@ endif 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)) -DATA := data -INCLUDES := include -SOURCES ?= $(shell find source -type d) - #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- @@ -32,7 +21,7 @@ CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE) CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -flto ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) -LDFLAGS := -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) -Wl,-Map,$(notdir $.map) +LDFLAGS := -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) -Wl,-Map,$(notdir $*.map) LIBS := -lnx @@ -40,7 +29,7 @@ LIBS := -lnx # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(ATMOSPHERE_LIBRARY_DIR)/libvapours +LIBDIRS := $(PORTLIBS) $(LIBNX) $(ATMOSPHERE_LIBRARIES_DIR)/libvapours #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -52,10 +41,23 @@ 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)/*.*))) +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C diff --git a/libstratosphere/include/stratosphere.hpp b/libstratosphere/include/stratosphere.hpp index f510abd1..aae1f69c 100644 --- a/libstratosphere/include/stratosphere.hpp +++ b/libstratosphere/include/stratosphere.hpp @@ -19,6 +19,9 @@ /* libvapours (pulls in util, svc, results). */ #include +/* Libstratosphere-only utility. */ +#include "stratosphere/util.hpp" + /* Critical modules with no dependencies. */ #include "stratosphere/ams.hpp" #include "stratosphere/os.hpp" diff --git a/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp b/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp index 9307ae7b..1fc60aff 100644 --- a/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp +++ b/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp @@ -35,10 +35,6 @@ namespace ams::exosphere { namespace ams { /* Version checking utility. */ -#ifdef ATMOSPHERE_RELEASE_VERSION_MAJOR - -#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO - inline void CheckApiVersion() { const u32 runtime_version = exosphere::GetApiInfo().GetVersion(); const u32 build_version = exosphere::GetVersion(ATMOSPHERE_RELEASE_VERSION); @@ -48,6 +44,4 @@ namespace ams { } } -#endif - } diff --git a/libstratosphere/include/stratosphere/ams/ams_types.hpp b/libstratosphere/include/stratosphere/ams/ams_types.hpp index 22b170e1..9ac1fdd3 100644 --- a/libstratosphere/include/stratosphere/ams/ams_types.hpp +++ b/libstratosphere/include/stratosphere/ams/ams_types.hpp @@ -21,41 +21,22 @@ namespace ams::exosphere { + #define AMS_DEFINE_TARGET_FIRMWARE_ENUM(n) TargetFirmware_##n = ATMOSPHERE_TARGET_FIRMWARE_##n enum TargetFirmware : u32 { - TargetFirmware_100 = 1, - TargetFirmware_200 = 2, - TargetFirmware_300 = 3, - TargetFirmware_400 = 4, - TargetFirmware_500 = 5, - TargetFirmware_600 = 6, - TargetFirmware_620 = 7, - TargetFirmware_700 = 8, - TargetFirmware_800 = 9, - TargetFirmware_810 = 10, - TargetFirmware_900 = 11, - TargetFirmware_910 = 12, + AMS_DEFINE_TARGET_FIRMWARE_ENUM(100), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(200), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(300), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(400), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(500), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(600), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(620), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(700), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(800), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(810), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(900), + AMS_DEFINE_TARGET_FIRMWARE_ENUM(910), }; - -#ifdef ATMOSPHERE_H -/* #ifdef __has_include() */ - -#define AMS_VALIDATE_TARGET_FIRMWARE_ENUM(n) static_assert(TargetFirmware_##n == ATMOSPHERE_TARGET_FIRMWARE_##n) - - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(100); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(200); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(300); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(400); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(500); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(620); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(700); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(800); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(810); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(900); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(910); - -#undef AMS_VALIDATE_TARGET_FIRMWARE_ENUM - -#endif + #undef AMS_DEFINE_TARGET_FIRMWARE_ENUM constexpr inline u32 GetVersion(u32 major, u32 minor, u32 micro) { return (major << 16) | (minor << 8) | (micro); @@ -130,9 +111,9 @@ namespace ams { } #endif -#ifdef ATMOSPHERE_GIT_REV +#ifdef ATMOSPHERE_GIT_REVISION NX_CONSTEXPR const char *GetGitRevision() { - return ATMOSPHERE_GIT_REV; + return ATMOSPHERE_GIT_REVISION; } #endif diff --git a/libvapours/include/vapours/ams/ams_api_version.h b/libvapours/include/vapours/ams/ams_api_version.h new file mode 100644 index 00000000..e0bdb766 --- /dev/null +++ b/libvapours/include/vapours/ams/ams_api_version.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-2019 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 + +#define ATMOSPHERE_RELEASE_VERSION_MAJOR 0 +#define ATMOSPHERE_RELEASE_VERSION_MINOR 10 +#define ATMOSPHERE_RELEASE_VERSION_MICRO 0 + +#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO + +#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR 9 +#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR 1 +#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 0 diff --git a/libvapours/include/vapours/ams/ams_target_firmware.h b/libvapours/include/vapours/ams/ams_target_firmware.h new file mode 100644 index 00000000..09d15a4e --- /dev/null +++ b/libvapours/include/vapours/ams/ams_target_firmware.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2019 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 + +#define ATMOSPHERE_TARGET_FIRMWARE_100 1 +#define ATMOSPHERE_TARGET_FIRMWARE_200 2 +#define ATMOSPHERE_TARGET_FIRMWARE_300 3 +#define ATMOSPHERE_TARGET_FIRMWARE_400 4 +#define ATMOSPHERE_TARGET_FIRMWARE_500 5 +#define ATMOSPHERE_TARGET_FIRMWARE_600 6 +#define ATMOSPHERE_TARGET_FIRMWARE_620 7 +#define ATMOSPHERE_TARGET_FIRMWARE_700 8 +#define ATMOSPHERE_TARGET_FIRMWARE_800 9 +#define ATMOSPHERE_TARGET_FIRMWARE_810 10 +#define ATMOSPHERE_TARGET_FIRMWARE_900 11 +#define ATMOSPHERE_TARGET_FIRMWARE_910 12 + +#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_910 + +#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE_100 +#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_CURRENT diff --git a/libvapours/include/vapours/ams_version.h b/libvapours/include/vapours/ams_version.h new file mode 100644 index 00000000..624f966b --- /dev/null +++ b/libvapours/include/vapours/ams_version.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2019 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 "ams/ams_api_version.h" +#include "ams/ams_target_firmware.h" diff --git a/libvapours/include/vapours/includes.hpp b/libvapours/include/vapours/includes.hpp index 80e97a19..811034f4 100644 --- a/libvapours/include/vapours/includes.hpp +++ b/libvapours/include/vapours/includes.hpp @@ -64,6 +64,4 @@ #endif /* ATMOSPHERE_BOARD_NINTENDO_SWITCH */ /* Atmosphere meta. */ -#if __has_include() -#include -#endif +#include "ams_version.h"