[kernel] Move vm_space into kernel

The vm_space code should not have been in kutil, moving it to kernel.
This commit is contained in:
2020-09-13 16:11:24 -07:00
parent 9dee5e4138
commit e8564c755b
7 changed files with 12 additions and 21 deletions

View File

@@ -1,10 +1,10 @@
#include "kutil/assert.h"
#include "kutil/vm_space.h"
#include "kernel_memory.h"
#include "page_manager.h"
#include "buffer_cache.h"
#include "vm_space.h"
extern kutil::vm_space g_kernel_space;
extern vm_space g_kernel_space;
using memory::frame_size;
using memory::kernel_stack_pages;

View File

@@ -5,7 +5,6 @@
#include "initrd/initrd.h"
#include "kutil/assert.h"
#include "kutil/vm_space.h"
#include "apic.h"
#include "block_device.h"
#include "console.h"

View File

@@ -5,12 +5,12 @@
#include "kutil/assert.h"
#include "kutil/heap_allocator.h"
#include "kutil/no_construct.h"
#include "kutil/vm_space.h"
#include "frame_allocator.h"
#include "io.h"
#include "log.h"
#include "page_manager.h"
#include "vm_space.h"
using memory::frame_size;
using memory::heap_start;
@@ -24,7 +24,7 @@ using memory::table_entries;
using namespace kernel;
kutil::vm_space g_kernel_space {kernel_offset, (heap_start-kernel_offset)};
vm_space g_kernel_space {kernel_offset, (heap_start-kernel_offset)};
// These objects are initialized _before_ global constructors are called,
@@ -54,7 +54,7 @@ void walk_page_table(
page_table::level level,
uintptr_t &current_start,
size_t &current_bytes,
kutil::vm_space &kspace)
vm_space &kspace)
{
constexpr size_t huge_page_size = (1ull<<30);
constexpr size_t large_page_size = (1ull<<21);

View File

@@ -1,9 +1,9 @@
#include "kutil/assert.h"
#include "kutil/vm_space.h"
#include "console.h"
#include "io.h"
#include "log.h"
#include "page_manager.h"
#include "vm_space.h"
using memory::frame_size;
using memory::heap_start;
@@ -333,12 +333,12 @@ page_manager::fault_handler(uintptr_t addr)
if (!addr)
return false;
extern kutil::vm_space g_kernel_space;
extern vm_space g_kernel_space;
bool is_heap = addr >= ::memory::heap_start &&
addr < ::memory::heap_start + ::memory::kernel_max_heap;
if (!is_heap &&
g_kernel_space.get(addr) != kutil::vm_state::committed)
g_kernel_space.get(addr) != vm_state::committed)
return false;
uintptr_t page = addr & ~0xfffull;

View File

@@ -1,9 +1,7 @@
#include <algorithm>
#include "kutil/logger.h"
#include "kutil/vector.h"
#include "kutil/vm_space.h"
namespace kutil {
#include "log.h"
#include "vm_space.h"
using node_type = kutil::avl_node<vm_range>;
using node_vec = kutil::vector<node_type*>;
@@ -256,5 +254,3 @@ vm_space::get(uintptr_t addr)
node_type *node = find_overlapping(m_ranges.root(), addr, 1);
return node ? node->state : vm_state::unknown;
}
} // namespace kutil

View File

@@ -5,14 +5,11 @@
#include <stdint.h>
#include "kutil/avl_tree.h"
namespace kutil {
enum class vm_state : uint8_t {
unknown,
none,
reserved,
committed,
mapped
committed
};
struct vm_range
@@ -74,4 +71,3 @@ private:
tree_type m_ranges;
};
} // namespace kutil