[LINT] Linted files + Added lint job to CI

This commit is contained in:
Gliniak
2024-03-12 08:59:10 +01:00
committed by Radosław Gliński
parent e8afad8f8a
commit b9061e6292
117 changed files with 1177 additions and 883 deletions

View File

@@ -54,9 +54,7 @@ struct X_FILE_FS_ATTRIBUTE_INFORMATION {
};
static_assert_size(X_FILE_FS_ATTRIBUTE_INFORMATION, 16);
enum X_FILE_DEVICE_TYPE : uint32_t {
FILE_DEVICE_UNKNOWN = 0x22
};
enum X_FILE_DEVICE_TYPE : uint32_t { FILE_DEVICE_UNKNOWN = 0x22 };
struct X_FILE_FS_DEVICE_INFORMATION {
be<X_FILE_DEVICE_TYPE> device_type;

View File

@@ -1322,7 +1322,7 @@ void KernelState::InitializeKernelGuestGlobals() {
block->ObSymbolicLinkObjectType.delete_proc =
kernel_trampoline_group_.NewLongtermTrampoline(DeleteSymlink);
#define offsetof32(s, m) static_cast<uint32_t>( offsetof(s, m) )
#define offsetof32(s, m) static_cast<uint32_t>(offsetof(s, m))
host_object_type_enum_to_guest_object_type_ptr_ = {
{XObject::Type::Event,

View File

@@ -651,7 +651,8 @@ void UserModule::Dump() {
for (uint32_t i = 0; i < opt_alternate_title_id->count(); i++) {
if (opt_alternate_title_id->values[i] != 0) {
title_ids.append(fmt::format(" {:08X},", opt_alternate_title_id->values[i]));
title_ids.append(
fmt::format(" {:08X},", opt_alternate_title_id->values[i]));
}
}
// Remove last character as it is not necessary

View File

@@ -117,7 +117,7 @@ class UserModule : public XModule {
bool is_dll_module_ = false;
uint32_t entry_point_ = 0;
uint32_t stack_size_ = 0;
uint32_t workspace_size_ = 384*1024;
uint32_t workspace_size_ = 384 * 1024;
uint32_t mod_checksum_ = 0;
uint32_t time_date_stamp_ = 0;

View File

@@ -2,8 +2,8 @@
******************************************************************************
* 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. *
******************************************************************************
*/
@@ -95,9 +95,10 @@ bool GrowHandleTable(uint32_t table_ptr, PPCContext* context) {
/*
copy old bucket list contents to new, larger bucket list
*/
memcpy(context->TranslateVirtual(new_dynamic_buckets),
context->TranslateVirtual(table->table_dynamic_buckets),
sizeof(uint32_t) * (new_bucket_handle_base / SIZE_PER_HANDLE_BUCKET));
memcpy(
context->TranslateVirtual(new_dynamic_buckets),
context->TranslateVirtual(table->table_dynamic_buckets),
sizeof(uint32_t) * (new_bucket_handle_base / SIZE_PER_HANDLE_BUCKET));
if (context->TranslateVirtualBE<uint32_t>(table->table_dynamic_buckets) !=
&table->table_static_buckets[0]) {

View File

@@ -2,8 +2,8 @@
******************************************************************************
* 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. *
******************************************************************************
*/
@@ -26,7 +26,7 @@ struct X_HANDLE_TABLE {
xe::be<uint32_t> table_dynamic_buckets;
xe::be<uint32_t> table_static_buckets[8];
X_KSPINLOCK table_lock;
//used as unknown arg 3 to pool allocations
// used as unknown arg 3 to pool allocations
uint8_t unk_pool_arg_34;
uint8_t handle_high_byte;
uint8_t unk_36;

View File

@@ -25,5 +25,5 @@ struct X_OBJECT_CREATE_INFORMATION;
namespace xe::kernel::util {
class NativeList;
class ObjectTable;
}
} // namespace xe::kernel::util
#endif

View File

@@ -168,8 +168,8 @@ static void XeInsertHeadList(uint32_t list_head, X_LIST_ENTRY* entry,
template <typename VirtualTranslator>
static void XeInsertHeadList(X_LIST_ENTRY* list_head, X_LIST_ENTRY* entry,
VirtualTranslator context) {
XeInsertHeadList(list_head, XeGuestList(list_head, context),
entry, XeGuestList(entry, context), context);
XeInsertHeadList(list_head, XeGuestList(list_head, context), entry,
XeGuestList(entry, context), context);
}
template <typename TObject, size_t EntryListOffset>
@@ -216,7 +216,7 @@ struct X_TYPED_LIST : public X_LIST_ENTRY {
uint32_t end() { return vt->HostToGuestVirtual(thiz); }
};
template<typename VirtualTranslator>
template <typename VirtualTranslator>
ForwardIteratorBegin<VirtualTranslator> IterateForward(VirtualTranslator vt) {
return ForwardIteratorBegin<VirtualTranslator>{vt, this};
}
@@ -227,13 +227,14 @@ struct X_TYPED_LIST : public X_LIST_ENTRY {
}
template <typename VirtualTranslator>
void InsertHead(TObject* entry, VirtualTranslator translator) {
XeInsertHeadList(static_cast<X_LIST_ENTRY*>(this), ObjectListEntry(entry), translator);
XeInsertHeadList(static_cast<X_LIST_ENTRY*>(this), ObjectListEntry(entry),
translator);
}
template <typename VirtualTranslator>
void InsertTail(TObject* entry, VirtualTranslator translator) {
XeInsertTailList(this, ObjectListEntry(entry), translator);
}
template<typename VirtualTranslator>
template <typename VirtualTranslator>
bool empty(VirtualTranslator vt) const {
return vt->TranslateVirtual<X_LIST_ENTRY*>(flink_ptr) == this;
}

View File

@@ -111,8 +111,8 @@ class ObjectTable {
// Generic lookup
template <>
object_ref<XObject> ObjectTable::LookupObject<XObject>(
X_HANDLE handle, bool already_locked);
object_ref<XObject> ObjectTable::LookupObject<XObject>(X_HANDLE handle,
bool already_locked);
} // namespace util
} // namespace kernel

View File

@@ -35,8 +35,7 @@ using PPCContext = xe::cpu::ppc::PPCContext;
library_name, ordinals::export_name, \
(xe::cpu::xe_kernel_export_shim_fn)export_name##_entry);
#define SHIM_MEM_ADDR(a) \
((a) ? ppc_context->TranslateVirtual(a) : nullptr)
#define SHIM_MEM_ADDR(a) ((a) ? ppc_context->TranslateVirtual(a) : nullptr)
#define SHIM_MEM_8(a) xe::load_and_swap<uint8_t>(SHIM_MEM_ADDR(a))
#define SHIM_MEM_16(a) xe::load_and_swap<uint16_t>(SHIM_MEM_ADDR(a))
@@ -158,9 +157,8 @@ class Param {
} else {
uint32_t stack_ptr =
uint32_t(init.ppc_context->r[1]) + 0x54 + (ordinal_ - 8) * 8;
*out_value = xe::load_and_swap<V>(
init.ppc_context->TranslateVirtual(
stack_ptr));
*out_value =
xe::load_and_swap<V>(init.ppc_context->TranslateVirtual(stack_ptr));
}
}
@@ -216,6 +214,7 @@ class ContextParam : public Param {
X_KPCR* GetPCR() const { return TranslateGPR<X_KPCR*>(13); }
XThread* CurrentXThread() const;
protected:
PPCContext* XE_RESTRICT ctx_;
};
@@ -223,10 +222,7 @@ class ContextParam : public Param {
class PointerParam : public ParamBase<uint32_t> {
public:
PointerParam(Init& init) : ParamBase(init) {
host_ptr_ =
value_
? init.ppc_context->TranslateVirtual(value_)
: nullptr;
host_ptr_ = value_ ? init.ppc_context->TranslateVirtual(value_) : nullptr;
}
PointerParam(void* host_ptr) : ParamBase(), host_ptr_(host_ptr) {}
PointerParam& operator=(void*& other) {
@@ -296,10 +292,7 @@ class StringPointerParam : public ParamBase<uint32_t> {
public:
StringPointerParam(Init& init) : ParamBase(init) {
host_ptr_ =
value_
? init.ppc_context->TranslateVirtual<CHAR*>(
value_)
: nullptr;
value_ ? init.ppc_context->TranslateVirtual<CHAR*>(value_) : nullptr;
}
StringPointerParam(CHAR* host_ptr) : ParamBase(), host_ptr_(host_ptr) {}
StringPointerParam& operator=(const CHAR*& other) {
@@ -323,9 +316,7 @@ class TypedPointerParam : public ParamBase<uint32_t> {
public:
TypedPointerParam(Init& init) : ParamBase(init) {
host_ptr_ =
value_ ? init.ppc_context->TranslateVirtual<T*>(
value_)
: nullptr;
value_ ? init.ppc_context->TranslateVirtual<T*>(value_) : nullptr;
}
TypedPointerParam(T* host_ptr) : ParamBase(), host_ptr_(host_ptr) {}
TypedPointerParam& operator=(const T*& other) {

View File

@@ -216,7 +216,7 @@ std::vector<XdbfViewTable> XdbfWrapper::GetStatsView() const {
}
const uint8_t* XdbfWrapper::ReadXLast(uint32_t& compressed_size,
uint32_t& decompressed_size) const {
uint32_t& decompressed_size) const {
auto xlast_table = GetEntry(XdbfSection::kMetadata, kXdbfIdXsrc);
if (!xlast_table) {
return nullptr;

View File

@@ -187,8 +187,7 @@ class XdbfWrapper {
XdbfPropertyTableEntry GetProperty(const uint32_t id) const;
XdbfContextTableEntry GetContext(const uint32_t id) const;
std::vector<XdbfViewTable> GetStatsView() const;
XdbfSharedView GetSharedView(const uint8_t* ptr,
uint32_t& byte_count) const;
XdbfSharedView GetSharedView(const uint8_t* ptr, uint32_t& byte_count) const;
void GetPropertyBagMetadata(const uint8_t* ptr, uint32_t& byte_count,
std::vector<xe::be<uint32_t>>& contexts,
@@ -196,7 +195,8 @@ class XdbfWrapper {
XdbfPropertyBag GetMatchCollection() const;
const uint8_t* ReadXLast(uint32_t& compressed_size, uint32_t& decompressed_size) const;
const uint8_t* ReadXLast(uint32_t& compressed_size,
uint32_t& decompressed_size) const;
private:
const uint8_t* data_ = nullptr;

View File

@@ -10,8 +10,8 @@
#include "xenia/kernel/xam/content_manager.h"
#include <array>
#include <string>
#include <set>
#include <string>
#include "third_party/fmt/include/fmt/format.h"
#include "xenia/base/filesystem.h"

View File

@@ -33,19 +33,18 @@
#include "third_party/fmt/include/fmt/format.h"
DEFINE_int32(
avpack, 8,
"Video modes\n"
" 0 = PAL-60 Component (SD)\n"
" 1 = Unused\n"
" 2 = PAL-60 SCART\n"
" 3 = 480p Component (HD)\n"
" 4 = HDMI+A\n"
" 5 = PAL-60 Composite/S-Video\n"
" 6 = VGA\n"
" 7 = TV PAL-60\n"
" 8 = HDMI (default)",
"Video");
DEFINE_int32(avpack, 8,
"Video modes\n"
" 0 = PAL-60 Component (SD)\n"
" 1 = Unused\n"
" 2 = PAL-60 SCART\n"
" 3 = 480p Component (HD)\n"
" 4 = HDMI+A\n"
" 5 = PAL-60 Composite/S-Video\n"
" 6 = VGA\n"
" 7 = TV PAL-60\n"
" 8 = HDMI (default)",
"Video");
DECLARE_int32(user_country);
DECLARE_int32(user_language);

View File

@@ -431,7 +431,8 @@ dword_result_t XamGetLocaleEx_entry(dword_t max_country_id,
static_cast<uint8_t>(max_locale_id));
}
DECLARE_XAM_EXPORT1(XamGetLocaleEx, kLocale, kImplemented);
//originally a switch table, wrote a script to extract the values for all possible cases
// originally a switch table, wrote a script to extract the values for all
// possible cases
static constexpr uint8_t XamLocaleDateFmtTable[] = {
2, 1, 3, 1, 3, 3, 3, 3, 3, 3, 3, 2, 3, 2, 1, 4, 2, 3, 1, 2, 2, 3,

View File

@@ -1083,7 +1083,7 @@ dword_result_t NetDll_XNetRegisterKey_entry(dword_t caller, lpdword_t key_id,
DECLARE_XAM_EXPORT1(NetDll_XNetRegisterKey, kNetworking, kStub);
dword_result_t NetDll_XNetUnregisterKey_entry(dword_t caller, lpdword_t key_id,
lpdword_t exchange_key) {
lpdword_t exchange_key) {
return 0;
}
DECLARE_XAM_EXPORT1(NetDll_XNetUnregisterKey, kNetworking, kStub);

View File

@@ -56,7 +56,7 @@ dword_result_t XamTaskSchedule_entry(lpvoid_t callback,
auto option = ctx->TranslateVirtual<XAM_TASK_ARGS*>(optional_ptr);
auto v1 = option->value1;
auto v2 = option->value2; //typically 0?
auto v2 = option->value2; // typically 0?
XELOGI("Got xam task args: v1 = {:08X}, v2 = {:08X}", v1, v2);
}
@@ -66,9 +66,9 @@ dword_result_t XamTaskSchedule_entry(lpvoid_t callback,
// Stack must be aligned to 16kb pages
stack_size = std::max((uint32_t)0x4000, ((stack_size + 0xFFF) & 0xFFFFF000));
auto thread =
object_ref<XThread>(new XThread(kernel_state(), stack_size, 0, callback,
message.guest_address(), 0, true, false, kernel_state()->GetSystemProcess()));
auto thread = object_ref<XThread>(new XThread(
kernel_state(), stack_size, 0, callback, message.guest_address(), 0, true,
false, kernel_state()->GetSystemProcess()));
X_STATUS result = thread->Create();

View File

@@ -738,7 +738,7 @@ dword_result_t XamUserCreateStatsEnumerator_entry(
}
if (buffer_size_ptr) {
*buffer_size_ptr = 0; // sizeof(X_STATS_DETAILS) * stats_ptr->stats_amount;
*buffer_size_ptr = 0; // sizeof(X_STATS_DETAILS) * stats_ptr->stats_amount;
}
auto e = object_ref<XUserStatsEnumerator>(

View File

@@ -686,12 +686,12 @@ dword_result_t XeKeysHmacShaUsingKey_entry(lpvoid_t obscured_key,
}
DECLARE_XBOXKRNL_EXPORT1(XeKeysHmacShaUsingKey, kNone, kImplemented);
//going off of usage in some hbrew xex
//0 and 1 appear to be devkit, 2 is retail
//we default to saying we're retail
dword_result_t XeKeysGetConsoleType_entry(lpdword_t type_out) {
*type_out = 2;
return 0;
// going off of usage in some hbrew xex
// 0 and 1 appear to be devkit, 2 is retail
// we default to saying we're retail
dword_result_t XeKeysGetConsoleType_entry(lpdword_t type_out) {
*type_out = 2;
return 0;
}
DECLARE_XBOXKRNL_EXPORT1(XeKeysGetConsoleType, kNone, kImplemented);

View File

@@ -120,7 +120,7 @@ void HandleCppException(pointer_t<X_EXCEPTION_RECORD> record) {
kernel_memory()->TranslateVirtual<x_s__CatchableTypeArray*>(
throw_info->catchable_type_array_ptr);
//xe::debugging::Break();
// xe::debugging::Break();
XELOGE("Guest attempted to throw a C++ exception!");
}
@@ -138,9 +138,10 @@ void RtlRaiseException_entry(pointer_t<X_EXCEPTION_RECORD> record) {
// TODO(benvanik): unwinding.
// This is going to suck.
// xe::debugging::Break();
// xe::debugging::Break();
//RtlRaiseException definitely wasn't a noreturn function, we can return safe-ish
// RtlRaiseException definitely wasn't a noreturn function, we can return
// safe-ish
XELOGE("Guest attempted to trigger a breakpoint!");
}
DECLARE_XBOXKRNL_EXPORT2(RtlRaiseException, kDebug, kStub, kImportant);

View File

@@ -723,8 +723,9 @@ dword_result_t IoCreateDevice_entry(dword_t driver_object,
}
DECLARE_XBOXKRNL_EXPORT1(IoCreateDevice, kFileSystem, kStub);
//supposed to invoke a callback on the driver object! its some sort of destructor function
//intended to be called for all devices created from the driver
// supposed to invoke a callback on the driver object! its some sort of
// destructor function intended to be called for all devices created from the
// driver
void IoDeleteDevice_entry(dword_t device_ptr, const ppc_context_t& ctx) {
if (device_ptr) {
auto kernel_mem = ctx->kernel_state->memory();

View File

@@ -697,7 +697,7 @@ DECLARE_XBOXKRNL_EXPORT1(ExAllocatePool, kMemory, kImplemented);
void xeFreePool(PPCContext* context, uint32_t base_address) {
auto memory = context->kernel_state->memory();
//if 4kb aligned, there is no pool header!
// if 4kb aligned, there is no pool header!
if ((base_address & (4096 - 1)) == 0) {
memory->SystemHeapFree(base_address);
} else {

View File

@@ -16,7 +16,6 @@
namespace xe {
namespace kernel {
namespace xboxkrnl {
uint32_t xeMmAllocatePhysicalMemoryEx(uint32_t flags, uint32_t region_size,

View File

@@ -132,7 +132,7 @@ uint32_t xeObCreateObject(X_OBJECT_TYPE* object_factory,
return X_STATUS_OBJECT_NAME_INVALID;
}
// the object and its name are all created in a single allocation
unsigned int aligned_object_size =
xe::align<uint32_t>(object_size_without_headers, 4);
{

View File

@@ -434,9 +434,11 @@ pointer_result_t RtlImageNtHeader_entry(lpvoid_t module) {
}
DECLARE_XBOXKRNL_EXPORT1(RtlImageNtHeader, kNone, kImplemented);
// https://learn.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-imagedirectoryentrytodata
dword_result_t RtlImageDirectoryEntryToData_entry(dword_t Base, dword_t MappedAsImage_,
word_t DirectoryEntry, dword_t Size,
const ppc_context_t& ctx) {
dword_result_t RtlImageDirectoryEntryToData_entry(dword_t Base,
dword_t MappedAsImage_,
word_t DirectoryEntry,
dword_t Size,
const ppc_context_t& ctx) {
bool MappedAsImage = static_cast<unsigned char>(MappedAsImage_);
uint32_t aligned_base = Base;
if ((Base & 1) != 0) {
@@ -830,7 +832,7 @@ static void RtlRip_entry(const ppc_context_t& ctx) {
XELOGE("RtlRip called, arg1 = {}, arg2 = {}\n", msg_str1, msg_str2);
//we should break here... not sure what to do exactly
// we should break here... not sure what to do exactly
}
DECLARE_XBOXKRNL_EXPORT1(RtlRip, kNone, kImportant);

View File

@@ -63,7 +63,8 @@ uint32_t xeNtQueueApcThread(uint32_t thread_handle, uint32_t apc_routine,
void xeKfLowerIrql(PPCContext* ctx, unsigned char new_irql);
unsigned char xeKfRaiseIrql(PPCContext* ctx, unsigned char new_irql);
void xeKeKfReleaseSpinLock(PPCContext* ctx, X_KSPINLOCK* lock, uint32_t old_irql, bool change_irql=true);
void xeKeKfReleaseSpinLock(PPCContext* ctx, X_KSPINLOCK* lock,
uint32_t old_irql, bool change_irql = true);
uint32_t xeKeKfAcquireSpinLock(PPCContext* ctx, X_KSPINLOCK* lock,
bool change_irql = true);

View File

@@ -388,7 +388,9 @@ object_ref<XObject> XObject::GetNativeObject(KernelState* kernel_state,
// Already initialized.
// TODO: assert if the type of the object != as_type
uint32_t handle = header->wait_list_blink;
result = kernel_state->object_table()->LookupObject<XObject>(handle, true).release();
result = kernel_state->object_table()
->LookupObject<XObject>(handle, true)
.release();
} else {
// First use, create new.
// https://www.nirsoft.net/kernel_struct/vista/KOBJECTS.html

View File

@@ -12,8 +12,8 @@
#include "xenia/base/threading.h"
#include "xenia/kernel/xobject.h"
#include "xenia/xbox.h"
#include "xenia/kernel/xthread.h"
#include "xenia/xbox.h"
namespace xe {
namespace kernel {

View File

@@ -59,8 +59,8 @@ struct XAPC {
// KAPC is 0x28(40) bytes? (what's passed to ExAllocatePoolWithTag)
// This is 4b shorter than NT - looks like the reserved dword at +4 is gone.
// NOTE: stored in guest memory.
uint16_t type; // +0
uint8_t apc_mode; // +2
uint16_t type; // +0
uint8_t apc_mode; // +2
uint8_t enqueued; // +3
xe::be<uint32_t> thread_ptr; // +4
X_LIST_ENTRY list_entry; // +8
@@ -202,11 +202,11 @@ struct X_KTHREAD {
// times while the process is being created
uint8_t process_type_dup;
uint8_t process_type;
//apc_mode determines which list an apc goes into
util::X_TYPED_LIST<XAPC, offsetof(XAPC, list_entry)> apc_lists[2];
// apc_mode determines which list an apc goes into
util::X_TYPED_LIST<XAPC, offsetof(XAPC, list_entry)> apc_lists[2];
TypedGuestPointer<X_KPROCESS> process; // 0x84
uint8_t unk_88[0x3]; // 0x88
uint8_t may_queue_apcs; // 0x8B
uint8_t may_queue_apcs; // 0x8B
X_KSPINLOCK apc_lock; // 0x8C
uint8_t unk_90[0xC]; // 0x90
xe::be<uint32_t> msr_mask; // 0x9C
@@ -358,6 +358,7 @@ class XThread : public XObject, public cpu::Thread {
pending_mutant_acquires_.push_back(mutant);
}
void SetCurrentThread();
protected:
bool AllocateStack(uint32_t size);
void FreeStack();
@@ -391,7 +392,8 @@ class XThread : public XObject, public cpu::Thread {
class XHostThread : public XThread {
public:
XHostThread(KernelState* kernel_state, uint32_t stack_size,
uint32_t creation_flags, std::function<int()> host_fn, uint32_t guest_process=0);
uint32_t creation_flags, std::function<int()> host_fn,
uint32_t guest_process = 0);
virtual void Execute();