early-access version 2545

This commit is contained in:
pineappleEA
2022-03-13 10:13:48 +01:00
parent 6d9b02c048
commit b98acbedfe
35 changed files with 382 additions and 239 deletions

View File

@@ -83,8 +83,8 @@ public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = typename IntrusiveRedBlackTreeImpl::value_type;
using difference_type = typename IntrusiveRedBlackTreeImpl::difference_type;
using pointer = typename std::conditional<Const, IntrusiveRedBlackTreeImpl::const_pointer,
IntrusiveRedBlackTreeImpl::pointer>::type;
using pointer = std::conditional_t<Const, IntrusiveRedBlackTreeImpl::const_pointer,
IntrusiveRedBlackTreeImpl::pointer>;
using reference =
typename std::conditional<Const, IntrusiveRedBlackTreeImpl::const_reference,
IntrusiveRedBlackTreeImpl::reference>::type;
@@ -263,7 +263,7 @@ namespace impl {
template <typename T, typename Default>
using RedBlackKeyType =
typename std::remove_pointer<decltype(impl::GetRedBlackKeyType<T, Default>())>::type;
typename std::remove_pointer_t<decltype(impl::GetRedBlackKeyType<T, Default>())>;
template <class T, class Traits, class Comparator>
class IntrusiveRedBlackTree {
@@ -299,7 +299,7 @@ public:
friend class IntrusiveRedBlackTree<T, Traits, Comparator>;
using ImplIterator =
typename std::conditional<Const, ImplType::const_iterator, ImplType::iterator>::type;
std::conditional_t<Const, ImplType::const_iterator, ImplType::iterator>;
using iterator_category = std::bidirectional_iterator_tag;
using value_type = typename IntrusiveRedBlackTree::value_type;
@@ -315,7 +315,7 @@ public:
private:
constexpr explicit Iterator(ImplIterator it) : m_impl(it) {}
constexpr explicit Iterator(typename ImplIterator::pointer p) : m_impl(p) {}
constexpr explicit Iterator(ImplIterator::pointer p) : m_impl(p) {}
constexpr ImplIterator GetImplIterator() const {
return m_impl;

View File

@@ -55,12 +55,6 @@ enum class RBColor {
#pragma pack(push, 4)
template <typename T>
class RBEntry {
private:
T* m_rbe_left{};
T* m_rbe_right{};
T* m_rbe_parent{};
RBColor m_rbe_color{RBColor::RB_BLACK};
public:
constexpr RBEntry() = default;
@@ -110,6 +104,12 @@ public:
constexpr void SetColor(RBColor c) {
m_rbe_color = c;
}
private:
T* m_rbe_left{};
T* m_rbe_right{};
T* m_rbe_parent{};
RBColor m_rbe_color{RBColor::RB_BLACK};
};
#pragma pack(pop)

View File

@@ -107,6 +107,12 @@ VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAd
return start + size;
}
size_t CalculateSlabHeapGapSize() {
constexpr size_t KernelSlabHeapGapSize = 2_MiB - 296_KiB;
static_assert(KernelSlabHeapGapSize <= KernelSlabHeapGapsSizeMax);
return KernelSlabHeapGapSize;
}
} // namespace
KSlabResourceCounts KSlabResourceCounts::CreateDefault() {
@@ -137,12 +143,6 @@ void InitializeSlabResourceCounts(KernelCore& kernel) {
}
}
size_t CalculateSlabHeapGapSize() {
constexpr size_t KernelSlabHeapGapSize = 2_MiB - 296_KiB;
static_assert(KernelSlabHeapGapSize <= KernelSlabHeapGapsSizeMax);
return KernelSlabHeapGapSize;
}
size_t CalculateTotalSlabHeapSize(const KernelCore& kernel) {
size_t size = 0;

View File

@@ -16,13 +16,8 @@
namespace Kernel {
class KPageBuffer final : public KSlabAllocated<KPageBuffer> {
private:
alignas(PageSize) std::array<u8, PageSize> m_buffer;
public:
KPageBuffer() {
std::memset(&m_buffer, 0, m_buffer.size());
}
KPageBuffer() = default;
PAddr GetPhysicalAddress(Core::System& system) const {
return system.DeviceMemory().GetPhysicalAddr(this);
@@ -32,6 +27,9 @@ public:
ASSERT(Common::IsAligned(phys_addr, PageSize));
return reinterpret_cast<KPageBuffer*>(system.DeviceMemory().GetPointer(phys_addr));
}
private:
alignas(PageSize) std::array<u8, PageSize> m_buffer{};
};
static_assert(sizeof(KPageBuffer) == PageSize);

View File

@@ -98,7 +98,7 @@ ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& co
UNREACHABLE();
return ResultSuccess; // Ignore error if asserts are off
}
if (auto strong_ptr = manager->DomainHandler(object_id - 1).lock(); strong_ptr) {
if (auto strong_ptr = manager->DomainHandler(object_id - 1).lock()) {
return strong_ptr->HandleSyncRequest(*this, context);
} else {
UNREACHABLE();

View File

@@ -4,6 +4,7 @@
#pragma once
#include <algorithm>
#include <array>
#include "common/alignment.h"
@@ -28,9 +29,7 @@ public:
public:
explicit KThreadLocalPage(VAddr addr = {}) : m_virt_addr(addr) {
for (size_t i = 0; i < m_is_region_free.size(); i++) {
m_is_region_free[i] = true;
}
m_is_region_free.fill(true);
}
constexpr VAddr GetAddress() const {
@@ -44,21 +43,13 @@ public:
void Release(VAddr addr);
bool IsAllUsed() const {
for (size_t i = 0; i < RegionsPerPage; i++) {
if (m_is_region_free[i]) {
return false;
}
}
return true;
return std::ranges::all_of(m_is_region_free.begin(), m_is_region_free.end(),
[](bool is_free) { return !is_free; });
}
bool IsAllFree() const {
for (size_t i = 0; i < RegionsPerPage; i++) {
if (!m_is_region_free[i]) {
return false;
}
}
return true;
return std::ranges::all_of(m_is_region_free.begin(), m_is_region_free.end(),
[](bool is_free) { return is_free; });
}
bool IsAnyUsed() const {

View File

@@ -284,16 +284,16 @@ struct KernelCore::Impl {
// Gets the dummy KThread for the caller, allocating a new one if this is the first time
KThread* GetHostDummyThread() {
auto init_thread_ = [this](KThread* thread) {
auto initialize = [this](KThread* thread) {
ASSERT(KThread::InitializeDummyThread(thread).IsSuccess());
thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId()));
return thread;
};
thread_local auto thread = KThread(system.Kernel());
thread_local auto init_thread = init_thread_(&thread);
thread_local auto raw_thread = KThread(system.Kernel());
thread_local auto thread = initialize(&raw_thread);
return &thread;
return thread;
}
/// Registers a CPU core thread by allocating a host thread ID for it

View File

@@ -1189,6 +1189,8 @@ void Config::SaveCpuValues() {
WriteBasicSetting(Settings::values.cpuopt_misc_ir);
WriteBasicSetting(Settings::values.cpuopt_reduce_misalign_checks);
WriteBasicSetting(Settings::values.cpuopt_fastmem);
WriteBasicSetting(Settings::values.cpuopt_fastmem_exclusives);
WriteBasicSetting(Settings::values.cpuopt_recompile_exclusives);
}
qt_config->endGroup();