[kernel] Spit out vm_area types

The vm_space allow() functionality was a bit janky; using VMAs for all
regions would be a lot cleaner. To that end, this change:

- Adds a "static array" ctor to kutil::vector for setting the kernel
  address space's VMA list. This way a kernel heap VMA can be created
  without the heap already existing.
- Splits vm_area into different subclasses depending on desired behavior
- Splits out the concept of vm_mapper which maps vm_areas to vm_spaces,
  so that some kinds of VMA can be inherently single-space
- Implements VMA resizing so that userspace can grow allocations.
- Obsolete page_table_indices is removed

Also, the following bugs were fixed:

- kutil::map iterators on empty maps no longer break
- memory::page_count was doing page-align, not page-count

See: Github bug #242
See: [frobozz blog post](https://jsix.dev/posts/frobozz/)

Tags:
This commit is contained in:
2020-09-26 21:47:15 -07:00
parent 0e0975e5f6
commit 13aee1755e
19 changed files with 533 additions and 190 deletions

View File

@@ -105,16 +105,19 @@ public:
}
iterator begin() {
if (!m_count) return iterator {0};
iterator it {m_nodes - 1, m_nodes + m_capacity};
return ++it;
}
const iterator begin() const {
if (!m_count) return iterator {0};
iterator it {m_nodes - 1, m_nodes + m_capacity};
return ++it;
}
const iterator end() const {
if (!m_count) return iterator {0};
return iterator(m_nodes + m_capacity);
}

View File

@@ -45,7 +45,7 @@ public:
}
/// Move constructor. Takes ownership of the other's array.
vector(vector&& other) :
vector(vector &&other) :
m_size(other.m_size),
m_capacity(other.m_capacity),
m_elements(other.m_elements)
@@ -55,6 +55,15 @@ public:
other.m_elements = nullptr;
}
/// Static array constructor. Starts the vector off with the given
/// static storage.
vector(T *data, size_t size, size_t capacity) :
m_size(size),
m_capacity(capacity),
m_elements(&data[0])
{
}
/// Destructor. Destroys any remaining items in the array.
~vector()
{

View File

@@ -4,7 +4,11 @@
push rbp
mov rbp, rsp
; address of args should already be in rdi, etc
; args should already be in rdi, etc, but rcx will
; get stomped, so shift args out one spot from rcx
mov r9, r8
mov r8, rcx
mov rax, %2
syscall
; result is now already in rax, so just return
@@ -17,5 +21,7 @@
%define SYSCALL(n, name, a) SYSCALL name, n
%define SYSCALL(n, name, a, b) SYSCALL name, n
%define SYSCALL(n, name, a, b, c) SYSCALL name, n
%define SYSCALL(n, name, a, b, c, d) SYSCALL name, n
%define SYSCALL(n, name, a, b, c, d, e) SYSCALL name, n
%include "syscalls.inc"