Several changes

This commit is contained in:
XorTroll 2020-06-29 12:57:54 +02:00
parent 3b60e0ad3d
commit 717ee63ca6
11 changed files with 132 additions and 32 deletions

View file

@ -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

View file

@ -1,14 +0,0 @@
#pragma once
#include <stratosphere.hpp>
namespace ams::lm {
enum class LogDestination : u32 {
TMA = 1,
UART = 2,
UARTSleeping = 4,
All = 0xFFFF,
};
}

View file

@ -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)

View file

@ -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": {

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#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<u64>(program_id));
fs::CreateDirectory(process_dir);
/* Use current system tick as the binary log's identifier / file name. */

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#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<u8[]> 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<u8[]>(size)), buf_size(size) {
LogPacketBuffer(ncm::ProgramId program_id, const void *buf, size_t size) : program_id(program_id), buf(std::make_unique<u8[]>(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;
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "lm_service.hpp"
extern "C" {

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "lm_service.hpp"
namespace ams::lm {
@ -57,9 +73,10 @@ namespace ams::lm {
}
void LogService::OpenLogger(const sf::ClientProcessId &client_pid, sf::Out<std::shared_ptr<Logger>> 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<u64>(client_pid.GetValue()));
ncm::ProgramId program_id;
pm::info::GetProgramId(&program_id, client_pid.GetValue());
auto logger = std::make_shared<Logger>(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<s64> out_log_id, sf::Out<u64> out_program_id) {
void LogService::AtmosphereGetLastLogInfo(sf::Out<s64> out_log_id, sf::Out<ncm::ProgramId> out_program_id) {
const auto info = impl::GetLastLogInfo();
out_log_id.SetValue(info.log_id);
out_program_id.SetValue(info.program_id);

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#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<impl::LogPacketBuffer> 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<s64> out_log_id, sf::Out<u64> out_program_id);
void AtmosphereGetLastLogInfo(sf::Out<s64> out_log_id, sf::Out<ncm::ProgramId> out_program_id);
public:
DEFINE_SERVICE_DISPATCH_TABLE {

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::lm {
enum class LogDestination : u32 {
TMA = (1 << 0),
UART = (1 << 1),
UARTSleeping = (1 << 2),
All = 0xFFFF,
};
}