[Misc] Cleanup in Kernel

This commit is contained in:
Gliniak
2025-05-29 10:15:44 +02:00
committed by Radosław Gliński
parent 50492a951e
commit b864149575
101 changed files with 184 additions and 374 deletions

View File

@@ -6,10 +6,10 @@
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <algorithm>
#include "xenia/kernel/util/crypto_utils.h"
#include "xenia/xbox.h"
#include "third_party/crypto/TinySHA1.hpp"

View File

@@ -7,7 +7,10 @@
******************************************************************************
*/
#include "xenia/xbox.h"
#ifndef XENIA_KERNEL_UTIL_CRYPTO_UTILS_H_
#define XENIA_KERNEL_UTIL_CRYPTO_UTILS_H_
#include <cstdint>
namespace xe {
namespace kernel {
@@ -25,4 +28,6 @@ void RC4(const uint8_t* key, uint32_t key_size_in, const uint8_t* data,
} // namespace util
} // namespace kernel
} // namespace xe
} // namespace xe
#endif // XENIA_KERNEL_UTIL_CRYPTO_UTILS_H_

View File

@@ -22,8 +22,6 @@ GameInfoDatabase::GameInfoDatabase(const xam::SpaInfo* data) {
Init(data);
}
GameInfoDatabase::~GameInfoDatabase() {}
void GameInfoDatabase::Init(const xam::SpaInfo* data) {
spa_gamedata_ = std::make_unique<xam::SpaInfo>(*data);
spa_gamedata_->Load();

View File

@@ -88,7 +88,7 @@ class GameInfoDatabase {
// Normally titles have at least XDBF file embedded into xex. There are
// certain exceptions and that's why we need to check if it is even valid.
GameInfoDatabase(const xam::SpaInfo* data);
~GameInfoDatabase();
~GameInfoDatabase() = default;
bool IsValid() const { return is_valid_; }

View File

@@ -2,16 +2,16 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2023 Xenia Canary. All rights reserved. * Released under the BSD
*license - see LICENSE in the root for more details. *
* Copyright 2023 Xenia Canary. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/kernel/util/guest_object_table.h"
#include "xenia/base/atomic.h"
#include "xenia/cpu/processor.h"
#include "xenia/kernel/xboxkrnl/xboxkrnl_memory.h"
#include "xenia/kernel/xboxkrnl/xboxkrnl_threading.h"
namespace xe {
namespace kernel {
namespace util {

View File

@@ -2,16 +2,16 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2023 Xenia Canary. All rights reserved. * Released under the BSD
*license - see LICENSE in the root for more details. *
* Copyright 2023 Xenia Canary. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_KERNEL_UTIL_GUEST_OBJECT_TABLE_H_
#define XENIA_KERNEL_UTIL_GUEST_OBJECT_TABLE_H_
#include "xenia/kernel/kernel_state.h"
#include "xenia/xbox.h"
namespace xe {
namespace kernel {
namespace util {
@@ -32,9 +32,9 @@ struct X_HANDLE_TABLE {
uint8_t unk_36;
uint8_t unk_38;
};
static_assert_size(X_HANDLE_TABLE, 0x38);
/*
bool GrowHandleTable(uint32_t table_ptr, cpu::ppc::PPCContext* context);
uint32_t NewObjectHandle(uint32_t table_guest, uint32_t object_guest,
cpu::ppc::PPCContext* context);
@@ -45,6 +45,8 @@ uint32_t LookupHandleUnlocked(X_HANDLE_TABLE* table, guest_handle_t handle,
cpu::ppc::PPCContext* context);
uint32_t LookupHandle(uint32_t table, guest_handle_t handle,
uint32_t reference_object, cpu::ppc::PPCContext* context);
*/
} // namespace util
} // namespace kernel
} // namespace xe

View File

@@ -9,9 +9,6 @@
#include "xenia/kernel/util/object_table.h"
#include <algorithm>
#include <cstring>
#include "xenia/base/byte_stream.h"
#include "xenia/base/logging.h"
#include "xenia/kernel/xobject.h"

View File

@@ -8,7 +8,7 @@
*/
#include "xenia/kernel/util/presence_string_builder.h"
#include "xenia/kernel/util/shim_utils.h"
#include "third_party/fmt/include/fmt/format.h"
namespace xe {
namespace kernel {

View File

@@ -14,7 +14,6 @@
#include <string>
#include <type_traits>
#include "third_party/fmt/include/fmt/format.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/logging.h"
#include "xenia/base/memory.h"

View File

@@ -639,7 +639,7 @@ struct X_IMAGE_EXPORT_DIRECTORY {
uint32_t AddressOfNameOrdinals; // RVA from base of image
};
const std::unordered_map<uint32_t, std::string> xex2_system_flags_map = {
inline const std::unordered_map<uint32_t, std::string> xex2_system_flags_map = {
{XEX_SYSTEM_NO_FORCED_REBOOT, "XEX_SYSTEM_NO_FORCED_REBOOT"},
{XEX_SYSTEM_FOREGROUND_TASKS, "XEX_SYSTEM_FOREGROUND_TASKS"},
{XEX_SYSTEM_NO_ODD_MAPPING, "XEX_SYSTEM_NO_ODD_MAPPING"},

View File

@@ -0,0 +1,64 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2025 Xenia Canary. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_KERNEL_UTIL_XFILETIME_H_
#define XENIA_KERNEL_UTIL_XFILETIME_H_
#include "xenia/base/byte_order.h"
#include "xenia/base/chrono.h"
namespace xe {
namespace kernel {
struct X_FILETIME {
static constexpr uint64_t minimal_valid_time = 125911584000000000;
static constexpr uint64_t maximal_valid_time = 157469184000000000;
xe::be<uint32_t> high_part;
xe::be<uint32_t> low_part;
X_FILETIME() {
high_part = 0;
low_part = 0;
}
X_FILETIME(uint64_t filetime) {
high_part = static_cast<uint32_t>(filetime >> 32);
low_part = static_cast<uint32_t>(filetime);
}
X_FILETIME(std::time_t time) {
const auto file_time =
chrono::WinSystemClock::to_file_time(chrono::WinSystemClock::from_sys(
std::chrono::system_clock::from_time_t(time)));
high_part = static_cast<uint32_t>(file_time >> 32);
low_part = static_cast<uint32_t>(file_time);
}
chrono::WinSystemClock::time_point to_time_point() const {
const uint64_t filetime =
(static_cast<uint64_t>(high_part) << 32) | low_part;
return chrono::WinSystemClock::from_file_time(filetime);
}
bool is_valid() const {
const uint64_t filetime =
(static_cast<uint64_t>(high_part) << 32) | low_part;
return filetime >= minimal_valid_time && filetime <= maximal_valid_time;
}
};
static_assert_size(X_FILETIME, 0x8);
} // namespace kernel
} // namespace xe
#endif

View File

@@ -39,8 +39,6 @@ std::vector<uint32_t> XLastMatchmakingQuery::GetFilters() const {
return XLast::GetAllValuesFromNode(node_, "Filters", "left");
}
XLast::XLast() : parsed_xlast_(nullptr) {}
XLast::XLast(const uint8_t* compressed_xml_data,
const uint32_t compressed_data_size,
const uint32_t decompressed_data_size) {
@@ -84,8 +82,6 @@ XLast::XLast(const uint8_t* compressed_xml_data,
xlast_decompressed_xml_.size());
}
XLast::~XLast() {}
std::u16string XLast::GetTitleName() const {
std::string xpath = "/XboxLiveSubmissionProject/GameConfigProject";

View File

@@ -32,7 +32,7 @@ enum class ProductInformationEntry {
GenreTypeString
};
static const std::map<std::string, ProductInformationEntry>
inline const std::map<std::string, ProductInformationEntry>
product_information_entry_string_to_enum = {
{"offlinePlayersMax", ProductInformationEntry::MaxOfflinePlayers},
{"systemLinkPlayersMax", ProductInformationEntry::MaxSystemLinkPlayers},
@@ -43,7 +43,7 @@ static const std::map<std::string, ProductInformationEntry>
{"genreTextStringId", ProductInformationEntry::GenreTypeString},
};
static const std::map<XLanguage, std::string> language_mapping = {
inline const std::map<XLanguage, std::string> language_mapping = {
{XLanguage::kEnglish, "en-US"}, {XLanguage::kJapanese, "ja-JP"},
{XLanguage::kGerman, "de-DE"}, {XLanguage::kFrench, "fr-FR"},
{XLanguage::kSpanish, "es-ES"}, {XLanguage::kItalian, "it-IT"},
@@ -67,10 +67,10 @@ class XLastMatchmakingQuery {
class XLast {
public:
XLast();
XLast() = default;
XLast(const uint8_t* compressed_xml_data, const uint32_t compressed_data_size,
const uint32_t decompressed_data_size);
~XLast();
~XLast() = default;
std::u16string GetTitleName() const;
std::map<ProductInformationEntry, uint32_t> GetProductInformationAttributes()