From 717ee63ca628f02b79f1aeb89ecc50a06398db8a Mon Sep 17 00:00:00 2001 From: XorTroll Date: Mon, 29 Jun 2020 12:57:54 +0200 Subject: [PATCH] Several changes --- Makefile | 4 +-- stratosphere/LogManager/source/lm_types.hpp | 14 --------- stratosphere/Makefile | 2 +- stratosphere/{LogManager => lm}/Makefile | 0 .../LogManager.json => lm/lm.json} | 12 +++++--- .../source/impl/lm_logging.cpp | 18 +++++++++++- .../source/impl/lm_logging.hpp | 24 ++++++++++++--- .../{LogManager => lm}/source/lm_main.cpp | 16 ++++++++++ .../{LogManager => lm}/source/lm_service.cpp | 23 +++++++++++++-- .../{LogManager => lm}/source/lm_service.hpp | 22 ++++++++++++-- stratosphere/lm/source/lm_types.hpp | 29 +++++++++++++++++++ 11 files changed, 132 insertions(+), 32 deletions(-) delete mode 100644 stratosphere/LogManager/source/lm_types.hpp rename stratosphere/{LogManager => lm}/Makefile (100%) rename stratosphere/{LogManager/LogManager.json => lm/lm.json} (94%) rename stratosphere/{LogManager => lm}/source/impl/lm_logging.cpp (81%) rename stratosphere/{LogManager => lm}/source/impl/lm_logging.hpp (76%) rename stratosphere/{LogManager => lm}/source/lm_main.cpp (84%) rename stratosphere/{LogManager => lm}/source/lm_service.cpp (78%) rename stratosphere/{LogManager => lm}/source/lm_service.hpp (64%) create mode 100644 stratosphere/lm/source/lm_types.hpp diff --git a/Makefile b/Makefile index bd4653398..4ef600202 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ dist-no-debug: all cp stratosphere/creport/creport.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036/exefs.nsp cp stratosphere/ro/ro.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/exefs.nsp cp stratosphere/jpegdec/jpegdec.nsp atmosphere-$(AMSVER)/atmosphere/contents/010000000000003C/exefs.nsp - cp stratosphere/LogManager/LogManager.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000015/exefs.nsp + cp stratosphere/lm/lm.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000015/exefs.nsp mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags touch atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags/boot2.flag mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags @@ -143,7 +143,7 @@ dist: dist-no-debug cp stratosphere/spl/spl.elf atmosphere-$(AMSVER)-debug/spl.elf cp stratosphere/erpt/erpt.elf atmosphere-$(AMSVER)-debug/erpt.elf cp stratosphere/jpegdec/jpegdec.elf atmosphere-$(AMSVER)-debug/jpegdec.elf - cp stratosphere/LogManager/LogManager.elf atmosphere-$(AMSVER)-debug/LogManager.elf + cp stratosphere/lm/lm.elf atmosphere-$(AMSVER)-debug/lm.elf cd atmosphere-$(AMSVER)-debug; zip -r ../atmosphere-$(AMSVER)-debug.zip ./*; cd ../; rm -r atmosphere-$(AMSVER)-debug mv atmosphere-$(AMSVER)-debug.zip out/atmosphere-$(AMSVER)-debug.zip diff --git a/stratosphere/LogManager/source/lm_types.hpp b/stratosphere/LogManager/source/lm_types.hpp deleted file mode 100644 index a26db3d50..000000000 --- a/stratosphere/LogManager/source/lm_types.hpp +++ /dev/null @@ -1,14 +0,0 @@ - -#pragma once -#include - -namespace ams::lm { - - enum class LogDestination : u32 { - TMA = 1, - UART = 2, - UARTSleeping = 4, - All = 0xFFFF, - }; - -} \ No newline at end of file diff --git a/stratosphere/Makefile b/stratosphere/Makefile index 1d0416dd8..4d22c93e7 100644 --- a/stratosphere/Makefile +++ b/stratosphere/Makefile @@ -1,4 +1,4 @@ -MODULES := loader ncm pm sm boot ams_mitm spl eclct.stub ro creport fatal dmnt boot2 erpt pgl jpegdec LogManager +MODULES := loader ncm pm sm boot ams_mitm spl eclct.stub ro creport fatal dmnt boot2 erpt pgl jpegdec lm SUBFOLDERS := $(MODULES) diff --git a/stratosphere/LogManager/Makefile b/stratosphere/lm/Makefile similarity index 100% rename from stratosphere/LogManager/Makefile rename to stratosphere/lm/Makefile diff --git a/stratosphere/LogManager/LogManager.json b/stratosphere/lm/lm.json similarity index 94% rename from stratosphere/LogManager/LogManager.json rename to stratosphere/lm/lm.json index 518f4a56b..d616a057c 100644 --- a/stratosphere/LogManager/LogManager.json +++ b/stratosphere/lm/lm.json @@ -3,14 +3,14 @@ "title_id": "0x0100000000000015", "title_id_range_min": "0x0100000000000015", "title_id_range_max": "0x0100000000000015", - "main_thread_stack_size": "0x00004000", - "main_thread_priority": 10, + "main_thread_stack_size": "0x00003000", + "main_thread_priority": 38, "default_cpu_id": 3, "process_category": 0, "is_retail": true, "pool_partition": 2, "is_64_bit": true, - "address_space_type": 1, + "address_space_type": 3, "filesystem_access": { "permissions": "0xFFFFFFFFFFFFFFFF" }, @@ -21,7 +21,7 @@ "type": "kernel_flags", "value": { "highest_thread_priority": 63, - "lowest_thread_priority": 8, + "lowest_thread_priority": 24, "lowest_cpu_id": 3, "highest_cpu_id": 3 } @@ -92,6 +92,10 @@ "type": "min_kernel_version", "value": "0x0030" }, + { + "type": "handle_table_size", + "value": 64 + }, { "type": "debug_flags", "value": { diff --git a/stratosphere/LogManager/source/impl/lm_logging.cpp b/stratosphere/lm/source/impl/lm_logging.cpp similarity index 81% rename from stratosphere/LogManager/source/impl/lm_logging.cpp rename to stratosphere/lm/source/impl/lm_logging.cpp index bbd373717..7eaf2d8b5 100644 --- a/stratosphere/LogManager/source/impl/lm_logging.cpp +++ b/stratosphere/lm/source/impl/lm_logging.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#include #include "lm_logging.hpp" namespace ams::lm::impl { @@ -41,7 +57,7 @@ namespace ams::lm::impl { /* Ensure process's directory for debug logs exists. */ char process_dir[FS_MAX_PATH] = {}; - std::snprintf(process_dir, sizeof(process_dir), "%s/0x%016lX", DebugLogDirectory, program_id); + std::snprintf(process_dir, sizeof(process_dir), "%s/0x%016lX", DebugLogDirectory, static_cast(program_id)); fs::CreateDirectory(process_dir); /* Use current system tick as the binary log's identifier / file name. */ diff --git a/stratosphere/LogManager/source/impl/lm_logging.hpp b/stratosphere/lm/source/impl/lm_logging.hpp similarity index 76% rename from stratosphere/LogManager/source/impl/lm_logging.hpp rename to stratosphere/lm/source/impl/lm_logging.hpp index 33440acac..7c3d25786 100644 --- a/stratosphere/LogManager/source/impl/lm_logging.hpp +++ b/stratosphere/lm/source/impl/lm_logging.hpp @@ -1,5 +1,21 @@ +/* + * Copyright (c) 2018-2020 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 "../lm_types.hpp" namespace ams::lm::impl { @@ -34,19 +50,19 @@ namespace ams::lm::impl { struct LogInfo { s64 log_id; /* This is the system tick value when the log was saved. */ - u64 program_id; + ncm::ProgramId program_id; }; /* Store log packet buffers as a unique_ptr, so that they automatically get disposed after they're used. */ struct LogPacketBuffer { - u64 program_id; + ncm::ProgramId program_id; std::unique_ptr buf; size_t buf_size; LogPacketBuffer() : program_id(0), buf(nullptr), buf_size(0) {} - LogPacketBuffer(u64 program_id, const void *buf, size_t size) : program_id(program_id), buf(std::make_unique(size)), buf_size(size) { + LogPacketBuffer(ncm::ProgramId program_id, const void *buf, size_t size) : program_id(program_id), buf(std::make_unique(size)), buf_size(size) { if(this->buf != nullptr) { std::memcpy(this->buf.get(), buf, size); } @@ -92,7 +108,7 @@ namespace ams::lm::impl { return header->IsTail(); } - inline u64 GetProgramId() const { + inline ncm::ProgramId GetProgramId() const { return this->program_id; } diff --git a/stratosphere/LogManager/source/lm_main.cpp b/stratosphere/lm/source/lm_main.cpp similarity index 84% rename from stratosphere/LogManager/source/lm_main.cpp rename to stratosphere/lm/source/lm_main.cpp index 780f25492..4e321532e 100644 --- a/stratosphere/LogManager/source/lm_main.cpp +++ b/stratosphere/lm/source/lm_main.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#include #include "lm_service.hpp" extern "C" { diff --git a/stratosphere/LogManager/source/lm_service.cpp b/stratosphere/lm/source/lm_service.cpp similarity index 78% rename from stratosphere/LogManager/source/lm_service.cpp rename to stratosphere/lm/source/lm_service.cpp index be6caee71..a891e9041 100644 --- a/stratosphere/LogManager/source/lm_service.cpp +++ b/stratosphere/lm/source/lm_service.cpp @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#include #include "lm_service.hpp" namespace ams::lm { @@ -57,9 +73,10 @@ namespace ams::lm { } void LogService::OpenLogger(const sf::ClientProcessId &client_pid, sf::Out> out_logger) { - u64 program_id = 0; /* Apparently lm succeeds on many/all commands, so we will succeed on them too. */ - pminfoGetProgramId(&program_id, static_cast(client_pid.GetValue())); + ncm::ProgramId program_id; + pm::info::GetProgramId(&program_id, client_pid.GetValue()); + auto logger = std::make_shared(program_id); out_logger.SetValue(std::move(logger)); } @@ -68,7 +85,7 @@ namespace ams::lm { out_event.SetValue(impl::GetLogEventHandle()); } - void LogService::AtmosphereGetLastLogInfo(sf::Out out_log_id, sf::Out out_program_id) { + void LogService::AtmosphereGetLastLogInfo(sf::Out out_log_id, sf::Out out_program_id) { const auto info = impl::GetLastLogInfo(); out_log_id.SetValue(info.log_id); out_program_id.SetValue(info.program_id); diff --git a/stratosphere/LogManager/source/lm_service.hpp b/stratosphere/lm/source/lm_service.hpp similarity index 64% rename from stratosphere/LogManager/source/lm_service.hpp rename to stratosphere/lm/source/lm_service.hpp index 1bf199f16..b1be5f646 100644 --- a/stratosphere/LogManager/source/lm_service.hpp +++ b/stratosphere/lm/source/lm_service.hpp @@ -1,5 +1,21 @@ +/* + * Copyright (c) 2018-2020 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 "impl/lm_logging.hpp" namespace ams::lm { @@ -13,11 +29,11 @@ namespace ams::lm { }; private: - u64 program_id; + ncm::ProgramId program_id; LogDestination destination; std::vector queued_packets; public: - Logger(u64 program_id) : program_id(program_id), destination(LogDestination::TMA), queued_packets() {} + Logger(ncm::ProgramId program_id) : program_id(program_id), destination(LogDestination::TMA), queued_packets() {} private: void Log(const sf::InAutoSelectBuffer &buf); @@ -45,7 +61,7 @@ namespace ams::lm { /* Atmosphere commands. */ void AtmosphereGetLogEvent(sf::OutCopyHandle out_event); - void AtmosphereGetLastLogInfo(sf::Out out_log_id, sf::Out out_program_id); + void AtmosphereGetLastLogInfo(sf::Out out_log_id, sf::Out out_program_id); public: DEFINE_SERVICE_DISPATCH_TABLE { diff --git a/stratosphere/lm/source/lm_types.hpp b/stratosphere/lm/source/lm_types.hpp new file mode 100644 index 000000000..87e5a2ceb --- /dev/null +++ b/stratosphere/lm/source/lm_types.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2020 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 ams::lm { + + enum class LogDestination : u32 { + TMA = (1 << 0), + UART = (1 << 1), + UARTSleeping = (1 << 2), + All = 0xFFFF, + }; + +} \ No newline at end of file