summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-13 00:27:25 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-13 00:29:32 +0100
commitbecc2c7fa5026e96db6d8dde6d85989913a3f794 (patch)
treeed3e4e85641088a33de4fb60192c32e63080ad34 /Kernel
parente4cb9b298579cbb8274dd9f32dd730b7249d025b (diff)
downloadserenity-becc2c7fa5026e96db6d8dde6d85989913a3f794.zip
Make GraphicsBitmaps be Region-backed when running in the kernel.
This is a lot better than having them in kmalloc memory. I'm gonna need a way to keep track of which process owns which bitmap eventually, maybe through some sort of resource keying system. We'll see.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/MemoryManager.h2
-rw-r--r--Kernel/Process.cpp4
-rw-r--r--Kernel/Process.h1
-rw-r--r--Kernel/i386.cpp4
4 files changed, 9 insertions, 2 deletions
diff --git a/Kernel/MemoryManager.h b/Kernel/MemoryManager.h
index cb8863ac81..a2b58cd727 100644
--- a/Kernel/MemoryManager.h
+++ b/Kernel/MemoryManager.h
@@ -11,6 +11,8 @@
#include <AK/AKString.h>
#include <VirtualFileSystem/VirtualFileSystem.h>
+#define PAGE_ROUND_UP(x) ((((dword)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)))
+
class Process;
extern Process* current;
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 60347dfcd9..5843bd730b 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -68,6 +68,7 @@ Vector<Process*> Process::allProcesses()
Region* Process::allocate_region(LinearAddress laddr, size_t size, String&& name, bool is_readable, bool is_writable, bool commit)
{
+ size = PAGE_ROUND_UP(size);
// FIXME: This needs sanity checks. What if this overlaps existing regions?
if (laddr.is_null()) {
laddr = m_nextRegion;
@@ -84,7 +85,7 @@ Region* Process::allocate_region(LinearAddress laddr, size_t size, String&& name
Region* Process::allocate_file_backed_region(LinearAddress laddr, size_t size, RetainPtr<Vnode>&& vnode, String&& name, bool is_readable, bool is_writable)
{
ASSERT(!vnode->isCharacterDevice());
-
+ size = PAGE_ROUND_UP(size);
// FIXME: This needs sanity checks. What if this overlaps existing regions?
if (laddr.is_null()) {
laddr = m_nextRegion;
@@ -99,6 +100,7 @@ Region* Process::allocate_file_backed_region(LinearAddress laddr, size_t size, R
Region* Process::allocate_region_with_vmo(LinearAddress laddr, size_t size, RetainPtr<VMObject>&& vmo, size_t offset_in_vmo, String&& name, bool is_readable, bool is_writable)
{
ASSERT(vmo);
+ size = PAGE_ROUND_UP(size);
// FIXME: This needs sanity checks. What if this overlaps existing regions?
if (laddr.is_null()) {
laddr = m_nextRegion;
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 45a0584338..3dd906dc63 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -43,6 +43,7 @@ struct DisplayInfo {
class Process : public InlineLinkedListNode<Process> {
friend class InlineLinkedListNode<Process>;
friend class WindowManager; // FIXME: Make a better API for allocate_region().
+ friend class GraphicsBitmap; // FIXME: Make a better API for allocate_region().
public:
static Process* create_kernel_process(String&& name, void (*entry)());
static Process* create_user_process(const String& path, uid_t, gid_t, pid_t ppid, int& error, Vector<String>&& arguments = Vector<String>(), Vector<String>&& environment = Vector<String>(), TTY* = nullptr);
diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp
index e752708654..40bc91d707 100644
--- a/Kernel/i386.cpp
+++ b/Kernel/i386.cpp
@@ -231,8 +231,10 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs)
);
#endif
- if (current->isRing0())
+ if (current->isRing0()) {
+ current->dumpRegions();
HANG;
+ }
auto response = MM.handle_page_fault(PageFault(regs.exception_code, LinearAddress(faultAddress)));