atmosphere: extract API version management to common folder
This commit is contained in:
@@ -21,7 +21,7 @@ TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
EXEFS_SRC := exefs_src
|
||||
|
||||
DEFINES := -DDISABLE_IPC
|
||||
|
||||
@@ -83,6 +83,8 @@ void __appInit(void) {
|
||||
fatalSimple(0xCAFE << 4 | 2);
|
||||
|
||||
fsdevMountSdmc();
|
||||
|
||||
CheckAtmosphereVersion();
|
||||
}
|
||||
|
||||
void __appExit(void) {
|
||||
|
||||
@@ -21,7 +21,7 @@ TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
EXEFS_SRC := exefs_src
|
||||
|
||||
DEFINES := -DDISABLE_IPC
|
||||
|
||||
@@ -21,7 +21,7 @@ TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
EXEFS_SRC := exefs_src
|
||||
|
||||
DEFINES := -DDISABLE_IPC
|
||||
|
||||
@@ -76,25 +76,7 @@ void __appInit(void) {
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS));
|
||||
}
|
||||
|
||||
rc = splInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(0xCAFE << 4 | 3);
|
||||
}
|
||||
|
||||
/* Check for exosphere API compatibility. */
|
||||
u64 exosphere_cfg;
|
||||
if (R_SUCCEEDED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
|
||||
/* MitM requires Atmosphere API 0.1. */
|
||||
u16 api_version = (exosphere_cfg >> 16) & 0xFFFF;
|
||||
if (api_version < 0x0001) {
|
||||
fatalSimple(0xCAFE << 4 | 0xFE);
|
||||
}
|
||||
} else {
|
||||
fatalSimple(0xCAFE << 4 | 0xFF);
|
||||
}
|
||||
|
||||
//splExit();
|
||||
CheckAtmosphereVersion();
|
||||
}
|
||||
|
||||
void __appExit(void) {
|
||||
|
||||
@@ -18,7 +18,7 @@ include $(DEVKITPRO)/libnx/switch_rules
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
|
||||
@@ -33,3 +33,5 @@
|
||||
|
||||
#include "stratosphere/waitablemanager.hpp"
|
||||
#include "stratosphere/multithreadedwaitablemanager.hpp"
|
||||
|
||||
#include "stratosphere/version_check.hpp"
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <atmosphere/version.h>
|
||||
|
||||
static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u32 *target_fw, u32 *mkey_rev) {
|
||||
if (R_FAILED(splInitialize())) {
|
||||
fatalSimple(0xCAFE << 4 | 0xD);
|
||||
}
|
||||
|
||||
/* Check for exosphere API compatibility. */
|
||||
u64 exosphere_cfg;
|
||||
if (R_FAILED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
|
||||
fatalSimple(0xCAFE << 4 | 0xE);
|
||||
}
|
||||
|
||||
if (mkey_rev) {
|
||||
*mkey_rev = (u32)((exosphere_cfg >> 0x00) & 0xFF);
|
||||
}
|
||||
|
||||
if (target_fw) {
|
||||
*target_fw = (u32)((exosphere_cfg >> 0x08) & 0xFF);
|
||||
}
|
||||
|
||||
if (micro) {
|
||||
*micro = (u32)((exosphere_cfg >> 0x10) & 0xFF);
|
||||
}
|
||||
|
||||
if (minor) {
|
||||
*minor = (u32)((exosphere_cfg >> 0x18) & 0xFF);
|
||||
}
|
||||
|
||||
if (major) {
|
||||
*major = (u32)((exosphere_cfg >> 0x20) & 0xFF);
|
||||
}
|
||||
|
||||
splExit();
|
||||
}
|
||||
|
||||
static inline u32 MakeAtmosphereVersion(u32 major, u32 minor, u32 micro) {
|
||||
return (major << 16) | (minor << 8) | micro;
|
||||
}
|
||||
|
||||
static inline void CheckAtmosphereVersion() {
|
||||
u32 major, minor, micro;
|
||||
GetAtmosphereApiVersion(&major, &minor, µ, nullptr, nullptr);
|
||||
|
||||
if (MakeAtmosphereVersion(major, minor, micro) < MakeAtmosphereVersion(ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO)) {
|
||||
fatalSimple(0xCAFE << 4 | 0xF);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
EXEFS_SRC := exefs_src
|
||||
|
||||
DEFINES := -DDISABLE_IPC
|
||||
|
||||
@@ -80,19 +80,7 @@ void __appInit(void) {
|
||||
fatalSimple(0xCAFE << 4 | 2);
|
||||
}
|
||||
|
||||
rc = splInitialize();
|
||||
if (R_FAILED(rc)) {
|
||||
fatalSimple(0xCAFE << 4 | 3);
|
||||
}
|
||||
|
||||
/* Check for exosphere API compatibility. */
|
||||
u64 exosphere_cfg;
|
||||
if (R_FAILED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
|
||||
//fatalSimple(0xCAFE << 4 | 0xFF);
|
||||
/* TODO: Does Loader need to know about target firmware/master key revision? If so, extract from exosphere_cfg. */
|
||||
}
|
||||
|
||||
//splExit();
|
||||
CheckAtmosphereVersion();
|
||||
}
|
||||
|
||||
void __appExit(void) {
|
||||
|
||||
@@ -21,7 +21,7 @@ TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
EXEFS_SRC := exefs_src
|
||||
|
||||
DEFINES := -DDISABLE_IPC
|
||||
|
||||
@@ -94,12 +94,7 @@ void __appInit(void) {
|
||||
fatalSimple(0xCAFE << 4 | 6);
|
||||
}
|
||||
|
||||
/* Check for exosphere API compatibility. */
|
||||
u64 exosphere_cfg;
|
||||
if (R_FAILED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
|
||||
fatalSimple(0xCAFE << 4 | 0xFF);
|
||||
/* TODO: Does PM need to know about target firmware/master key revision? If so, extract from exosphere_cfg. */
|
||||
}
|
||||
CheckAtmosphereVersion();
|
||||
}
|
||||
|
||||
void __appExit(void) {
|
||||
|
||||
@@ -21,7 +21,7 @@ TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include ../../common/include
|
||||
EXEFS_SRC := exefs_src
|
||||
|
||||
DEFINES := -DDISABLE_IPC
|
||||
|
||||
Reference in New Issue
Block a user