1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

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.
This commit is contained in:
Andreas Kling 2019-01-13 00:27:25 +01:00
parent e4cb9b2985
commit becc2c7fa5
7 changed files with 30 additions and 3 deletions

View file

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

View file

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

View file

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

View file

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