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

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