mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-21 20:03:11 +00:00
mc.mitm: modifications to build with latest libstratosphere
This commit is contained in:
parent
7b810497ea
commit
a55955708e
7 changed files with 60 additions and 138 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,6 +4,7 @@
|
|||
tests/
|
||||
dist/
|
||||
mc_mitm/build/
|
||||
mc_mitm/out/
|
||||
*.log
|
||||
*.elf
|
||||
*.nro
|
||||
|
|
10
Makefile
10
Makefile
|
@ -23,9 +23,9 @@ clean:
|
|||
|
||||
dist: all
|
||||
rm -rf dist
|
||||
|
||||
|
||||
mkdir -p dist/atmosphere/contents/$(MC_MITM_TID)
|
||||
cp mc_mitm/mc_mitm.nsp dist/atmosphere/contents/$(MC_MITM_TID)/exefs.nsp
|
||||
cp mc_mitm/out/nintendo_nx_arm64_armv8a/release/mc_mitm.nsp dist/atmosphere/contents/$(MC_MITM_TID)/exefs.nsp
|
||||
echo "btdrv" >> dist/atmosphere/contents/$(MC_MITM_TID)/mitm.lst
|
||||
echo "btm" >> dist/atmosphere/contents/$(MC_MITM_TID)/mitm.lst
|
||||
|
||||
|
@ -33,13 +33,13 @@ dist: all
|
|||
touch dist/atmosphere/contents/$(MC_MITM_TID)/flags/boot2.flag
|
||||
|
||||
cp mc_mitm/toolbox.json dist/atmosphere/contents/$(MC_MITM_TID)/toolbox.json
|
||||
|
||||
|
||||
cp -r exefs_patches dist/atmosphere/
|
||||
|
||||
mkdir -p dist/config/MissionControl
|
||||
mkdir -p dist/config/MissionControl/controllers
|
||||
cp mc_mitm/config.ini dist/config/MissionControl/missioncontrol.ini.template
|
||||
|
||||
|
||||
cd dist; zip -r $(PROJECT_NAME)-$(BUILD_VERSION).zip ./*; cd ../;
|
||||
|
||||
|
||||
.PHONY: all clean dist $(TARGETS)
|
||||
|
|
137
mc_mitm/Makefile
137
mc_mitm/Makefile
|
@ -1,124 +1,41 @@
|
|||
#---------------------------------------------------------------------------------
|
||||
# pull in common stratosphere sysmodule configuration
|
||||
#---------------------------------------------------------------------------------
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../lib/Atmosphere-libs/config/templates/stratosphere.mk
|
||||
ATMOSPHERE_BUILD_CONFIGS :=
|
||||
all: nx_release
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CURRENT_DIRECTORY := $(abspath $(dir $(THIS_MAKEFILE)))
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
define ATMOSPHERE_ADD_TARGET
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
ATMOSPHERE_BUILD_CONFIGS += $(strip $1)
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
$(strip $1):
|
||||
@echo "Building $(strip $1)"
|
||||
@$$(MAKE) -f $(CURRENT_DIRECTORY)/system_module.mk ATMOSPHERE_MAKEFILE_TARGET="$(strip $1)" ATMOSPHERE_BUILD_NAME="$(strip $2)" ATMOSPHERE_BOARD="$(strip $3)" ATMOSPHERE_CPU="$(strip $4)" $(strip $5)
|
||||
|
||||
clean-$(strip $1):
|
||||
@echo "Cleaning $(strip $1)"
|
||||
@$$(MAKE) -f $(CURRENT_DIRECTORY)/system_module.mk clean ATMOSPHERE_MAKEFILE_TARGET="$(strip $1)" ATMOSPHERE_BUILD_NAME="$(strip $2)" ATMOSPHERE_BOARD="$(strip $3)" ATMOSPHERE_CPU="$(strip $4)" $(strip $5)
|
||||
|
||||
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)))
|
||||
endef
|
||||
|
||||
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)))
|
||||
define ATMOSPHERE_ADD_TARGETS
|
||||
|
||||
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)))
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, $(strip $1)_release, release, $(strip $2), $(strip $3), \
|
||||
ATMOSPHERE_BUILD_SETTINGS="$(strip $4)" \
|
||||
))
|
||||
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, $(strip $1)_debug, debug, $(strip $2), $(strip $3), \
|
||||
ATMOSPHERE_BUILD_SETTINGS="$(strip $4) -DAMS_BUILD_FOR_DEBUGGING" ATMOSPHERE_BUILD_FOR_DEBUGGING=1 \
|
||||
))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGET, $(strip $1)_audit, audit, $(strip $2), $(strip $3), \
|
||||
ATMOSPHERE_BUILD_SETTINGS="$(strip $4) -DAMS_BUILD_FOR_AUDITING" ATMOSPHERE_BUILD_FOR_DEBUGGING=1 ATMOSPHERE_BUILD_FOR_AUDITING=1 \
|
||||
))
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
endef
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
$(eval $(call ATMOSPHERE_ADD_TARGETS, nx, nx-hac-001, arm-cortex-a57,))
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
clean: $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),clean-$(config))
|
||||
|
||||
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
|
||||
|
||||
ifeq ($(strip $(CONFIG_JSON)),)
|
||||
jsons := $(wildcard *.json)
|
||||
ifneq (,$(findstring $(TARGET).json,$(jsons)))
|
||||
export APP_JSON := $(TOPDIR)/$(TARGET).json
|
||||
else
|
||||
ifneq (,$(findstring config.json,$(jsons)))
|
||||
export APP_JSON := $(TOPDIR)/config.json
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
.PHONY: all
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
all : $(OUTPUT).nsp $(OUTPUT).nro
|
||||
|
||||
$(OUTPUT).nsp : $(OUTPUT).elf
|
||||
|
||||
$(OUTPUT).nso : $(OUTPUT).elf
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
||||
.PHONY: all clean $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS), $(config) clean-$(config))
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace ams::bluetooth {
|
|||
void CircularBuffer::Finalize(void) {
|
||||
if (!this->isInitialized)
|
||||
fatalThrow(-1);
|
||||
|
||||
|
||||
this->isInitialized = false;
|
||||
this->event = nullptr;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace ams::bluetooth {
|
|||
else
|
||||
size = readOffset - writeOffset - 1;
|
||||
|
||||
if (size > BLUETOOTH_BUFFER_SIZE)
|
||||
if (size > BLUETOOTH_BUFFER_SIZE)
|
||||
size = 0;
|
||||
|
||||
return size;
|
||||
|
@ -80,17 +80,21 @@ namespace ams::bluetooth {
|
|||
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
ON_SCOPE_EXIT {
|
||||
ON_SCOPE_EXIT {
|
||||
if (this->event)
|
||||
os::SignalEvent(this->event);
|
||||
};
|
||||
|
||||
if (size + sizeof(CircularBufferPacketHeader) <= this->GetWriteableSize()) {
|
||||
if (size + 2*sizeof(CircularBufferPacketHeader) > BLUETOOTH_BUFFER_SIZE - this->writeOffset) {
|
||||
R_TRY(this->_write(0xff, nullptr, (BLUETOOTH_BUFFER_SIZE - this->writeOffset) - sizeof(CircularBufferPacketHeader)));
|
||||
if (const auto res = this->_write(0xff, nullptr, (BLUETOOTH_BUFFER_SIZE - this->writeOffset) - sizeof(CircularBufferPacketHeader)); res != 0) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
R_TRY(this->_write(type, data, size));
|
||||
if (const auto res = this->_write(type, data, size); res != 0) {
|
||||
return res;
|
||||
}
|
||||
this->_updateUtilization();
|
||||
|
||||
return 0;
|
||||
|
@ -131,21 +135,21 @@ namespace ams::bluetooth {
|
|||
u64 CircularBuffer::Free(void) {
|
||||
if (!this->isInitialized)
|
||||
return -1;
|
||||
|
||||
|
||||
if (this->readOffset == this->writeOffset)
|
||||
return -1;
|
||||
|
||||
|
||||
auto packet = reinterpret_cast<CircularBufferPacket *>(&this->data[this->readOffset]);
|
||||
u32 newOffset = this->readOffset + packet->header.size + sizeof(packet->header);
|
||||
|
||||
|
||||
if (newOffset >= BLUETOOTH_BUFFER_SIZE)
|
||||
newOffset = 0;
|
||||
|
||||
|
||||
if (newOffset < BLUETOOTH_BUFFER_SIZE) {
|
||||
this->readOffset = newOffset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
fatalThrow(-1);
|
||||
}
|
||||
|
||||
|
@ -180,7 +184,7 @@ namespace ams::bluetooth {
|
|||
if (type != 0xff) {
|
||||
if (data && (size > 0))
|
||||
memcpy(&packet->data, data, size);
|
||||
else
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -189,7 +193,7 @@ namespace ams::bluetooth {
|
|||
return -1;
|
||||
|
||||
if (newOffset == BLUETOOTH_BUFFER_SIZE)
|
||||
this->writeOffset = 0;
|
||||
this->writeOffset = 0;
|
||||
else
|
||||
this->writeOffset = newOffset;
|
||||
|
||||
|
@ -212,24 +216,24 @@ namespace ams::bluetooth {
|
|||
return nullptr;
|
||||
|
||||
packet = reinterpret_cast<CircularBufferPacket *>(&this->data[this->readOffset]);
|
||||
|
||||
|
||||
if (packet->header.type != 0xff)
|
||||
return packet;
|
||||
|
||||
|
||||
if (!this->isInitialized)
|
||||
return nullptr;
|
||||
|
||||
|
||||
if (this->readOffset != this->writeOffset) {
|
||||
newOffset = this->readOffset + packet->header.size + sizeof(packet->header);
|
||||
if (newOffset >= BLUETOOTH_BUFFER_SIZE)
|
||||
newOffset = 0;
|
||||
|
||||
|
||||
this->_setReadOffset(newOffset);
|
||||
}
|
||||
|
||||
|
||||
} while (this->isInitialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
AMS_SF_METHOD_INFO(C, H, 65005, void, RedirectBleEvents, (bool redirect), (redirect)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 65006, void, SignalHidReportRead, (void), ()) \
|
||||
|
||||
AMS_SF_DEFINE_MITM_INTERFACE(ams::mitm::bluetooth, IBtdrvMitmInterface, AMS_BTDRV_MITM_INTERFACE_INFO)
|
||||
AMS_SF_DEFINE_MITM_INTERFACE(ams::mitm::bluetooth, IBtdrvMitmInterface, AMS_BTDRV_MITM_INTERFACE_INFO, 0xAACFC9A7)
|
||||
|
||||
namespace ams::mitm::bluetooth {
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
AMS_SF_METHOD_INFO(C, H, 9, Result, GetDeviceInfoDeprecated, (sf::Out<ams::btm::DeviceInfoList> out), (out), hos::Version_1_0_0, hos::Version_12_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, GetDeviceInfo, (u32 id, const sf::OutArray<ams::btm::DeviceInfo> &out, sf::Out<s32> total_out), (id, out, total_out), hos::Version_13_0_0) \
|
||||
|
||||
AMS_SF_DEFINE_MITM_INTERFACE(ams::mitm::btm, IBtmMitmInterface, AMS_BTM_MITM_INTERFACE_INFO)
|
||||
AMS_SF_DEFINE_MITM_INTERFACE(ams::mitm::btm, IBtmMitmInterface, AMS_BTM_MITM_INTERFACE_INFO, 0xB5E45686)
|
||||
|
||||
namespace ams::mitm::btm {
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ namespace ams::controller {
|
|||
|
||||
// Ensure config directory for this controller exists
|
||||
std::string path = GetControllerDirectory(&m_address);
|
||||
R_TRY(fs::EnsureDirectoryRecursively(path.c_str()));
|
||||
R_TRY(fs::EnsureDirectory(path.c_str()));
|
||||
|
||||
// Check if the virtual spi flash file already exists and initialise it if not
|
||||
path += "/spi_flash.bin";
|
||||
|
@ -491,7 +491,7 @@ namespace ams::controller {
|
|||
.raw = { 0x00 }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return this->FakeSubCmdResponse(&response);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue