aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/context_switching/syscall/main.hpp23
-rw-r--r--arch/x86_64/include/arch/memory/heap/user_heap_allocator.hpp9
2 files changed, 29 insertions, 3 deletions
diff --git a/arch/x86_64/include/arch/context_switching/syscall/main.hpp b/arch/x86_64/include/arch/context_switching/syscall/main.hpp
index 3af5a5a..8587ab2 100644
--- a/arch/x86_64/include/arch/context_switching/syscall/main.hpp
+++ b/arch/x86_64/include/arch/context_switching/syscall/main.hpp
@@ -15,6 +15,10 @@ namespace teachos::arch::context_switching::syscall
{
WRITE = 1U, ///< Loads the arg_0 parameter as an address pointing to a const char array, which will then be printed
///< onto the VGA buffer screen.
+ EXPAND_HEAP = 2U, /// Expands the User Heap by additonally mapping 100 KiB of virtual page memory. Ignores the
+ /// parameters and uses them as out parameters instead, where arg_0 is the start of the newly
+ /// mapped heap area and arg_1 is the size of the entire area. Can be less than 100 KiB if less
+ /// space remains.
};
/**
@@ -23,7 +27,8 @@ namespace teachos::arch::context_switching::syscall
*/
enum class error
{
- OK = 0U,
+ OK = 0U, ///< No error occured in syscall.
+ OUT_OF_MEMORY = 1U, ///< Expanding heap failed because we have run out of mappable virtual address space.
};
/**
@@ -50,6 +55,16 @@ namespace teachos::arch::context_switching::syscall
};
/**
+ * @brief Response of a systemcall always containin an error code, signaling if the syscall even succeeded or not.
+ * Additionally it may contain up to 6 return values in the values struct.
+ */
+ struct response
+ {
+ error error_code; ///< Error code returned by the syscall. If it failed all the values will be 0.
+ arguments values; ///< Optional return values of the syscall implementation.
+ };
+
+ /**
* @brief Calls the method associated with the given syscall number and passes the given optional arguments to it,
* over the RDI, RSI, RDX, R10, R8 and R9 register.
*
@@ -58,10 +73,12 @@ namespace teachos::arch::context_switching::syscall
* @param args Optional arguments passable to the different syscall methods, called depending on the syscall_number.
* Not passing the required parameters to the method, will result in passing 0 instead, which might make the fail or
* not function correctly.
- * @return Bool-convertable error code converting to true if the syscall failed or false if it didn't.
+ * @return The syscall implementation always returns a bool-convertable error code converting to true if the syscall
+ * failed or false if it didn't. Additionally it might pase additional values besides the error code, they will be set
+ * in the arguments struct. So the value can be read and used for further processing.
*/
[[gnu::section(".user_text")]]
- auto syscall(type syscall_number, arguments args = {}) -> error;
+ auto syscall(type syscall_number, arguments args) -> response;
} // namespace teachos::arch::context_switching::syscall
diff --git a/arch/x86_64/include/arch/memory/heap/user_heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/user_heap_allocator.hpp
index c50d2f6..cadec78 100644
--- a/arch/x86_64/include/arch/memory/heap/user_heap_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/heap/user_heap_allocator.hpp
@@ -48,6 +48,15 @@ namespace teachos::arch::memory::heap
[[gnu::section(".user_text")]] auto constexpr min_allocatable_size() -> std::size_t { return sizeof(memory_block); }
/**
+ * @brief Special functionality fo the user heap allocator. Which will result in it being expanded by a syscall with
+ * addtionally 100 KiB, which are mapped into the page table. Will always work until there is no physical memory
+ * left.
+ *
+ * @return Start of the newly with syscall allocated free memory block. Nullptr if the syscall failed.
+ */
+ [[gnu::section(".user_text")]] auto expand_heap_if_full() -> memory_block *;
+
+ /**
* @brief Removes a free memory block from the free list and returns its address so the caller can allocate into it.
*
* @param previous_block Free memory block before the block to allocate in our heap memory. Was to small to