diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-24 18:09:46 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-24 18:09:46 +0100 |
commit | aa24547e12228633addd5220d4aad55f7754392e (patch) | |
tree | d3b1946564934b54ea7ab509e596d0a9314b9bcd /Kernel | |
parent | e683f611f19eb1b32bb68c553efc370f9cadc19d (diff) | |
download | serenity-aa24547e12228633addd5220d4aad55f7754392e.zip |
Kernel: Finally stop exposing Region members to the public.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/MemoryManager.cpp | 108 | ||||
-rw-r--r-- | Kernel/MemoryManager.h | 44 | ||||
-rw-r--r-- | Kernel/ProcFileSystem.cpp | 18 | ||||
-rw-r--r-- | Kernel/Process.cpp | 48 | ||||
-rw-r--r-- | Kernel/ProcessGUI.cpp | 2 | ||||
-rw-r--r-- | Kernel/types.h | 12 |
6 files changed, 129 insertions, 103 deletions
diff --git a/Kernel/MemoryManager.cpp b/Kernel/MemoryManager.cpp index 11b24a8cc5..0751dab286 100644 --- a/Kernel/MemoryManager.cpp +++ b/Kernel/MemoryManager.cpp @@ -164,12 +164,12 @@ auto MemoryManager::ensure_pte(PageDirectory& page_directory, LinearAddress ladd return PageTableEntry(&pde.pageTableBase()[page_table_index]); } -void MemoryManager::map_protected(LinearAddress linearAddress, size_t length) +void MemoryManager::map_protected(LinearAddress laddr, size_t length) { InterruptDisabler disabler; // FIXME: ASSERT(linearAddress is 4KB aligned); for (dword offset = 0; offset < length; offset += PAGE_SIZE) { - auto pteAddress = linearAddress.offset(offset); + auto pteAddress = laddr.offset(offset); auto pte = ensure_pte(kernel_page_directory(), pteAddress); pte.set_physical_page_base(pteAddress.get()); pte.set_user_allowed(false); @@ -223,7 +223,7 @@ bool MemoryManager::zero_page(Region& region, unsigned page_index_in_region) dbgprintf(" >> ZERO P%x\n", physical_page->paddr().get()); #endif unquickmap_page(); - region.cow_map.set(page_index_in_region, false); + region.m_cow_map.set(page_index_in_region, false); vmo.physical_pages()[page_index_in_region] = move(physical_page); remap_region_page(region, page_index_in_region, true); return true; @@ -237,7 +237,7 @@ bool MemoryManager::copy_on_write(Region& region, unsigned page_index_in_region) #ifdef PAGE_FAULT_DEBUG dbgprintf(" >> It's a COW page but nobody is sharing it anymore. Remap r/w\n"); #endif - region.cow_map.set(page_index_in_region, false); + region.m_cow_map.set(page_index_in_region, false); remap_region_page(region, page_index_in_region, true); return true; } @@ -248,14 +248,14 @@ bool MemoryManager::copy_on_write(Region& region, unsigned page_index_in_region) auto physical_page_to_copy = move(vmo.physical_pages()[page_index_in_region]); auto physical_page = allocate_physical_page(); byte* dest_ptr = quickmap_page(*physical_page); - const byte* src_ptr = region.linearAddress.offset(page_index_in_region * PAGE_SIZE).asPtr(); + const byte* src_ptr = region.laddr().offset(page_index_in_region * PAGE_SIZE).as_ptr(); #ifdef PAGE_FAULT_DEBUG dbgprintf(" >> COW P%x <- P%x\n", physical_page->paddr().get(), physical_page_to_copy->paddr().get()); #endif memcpy(dest_ptr, src_ptr, PAGE_SIZE); vmo.physical_pages()[page_index_in_region] = move(physical_page); unquickmap_page(); - region.cow_map.set(page_index_in_region, false); + region.m_cow_map.set(page_index_in_region, false); remap_region_page(region, page_index_in_region, true); return true; } @@ -282,7 +282,7 @@ bool Region::page_in() bool MemoryManager::page_in_from_inode(Region& region, unsigned page_index_in_region) { - ASSERT(region.m_page_directory); + ASSERT(region.page_directory()); auto& vmo = region.vmo(); ASSERT(!vmo.is_anonymous()); ASSERT(vmo.inode()); @@ -295,7 +295,7 @@ bool MemoryManager::page_in_from_inode(Region& region, unsigned page_index_in_re return false; } remap_region_page(region, page_index_in_region, true); - byte* dest_ptr = region.linearAddress.offset(page_index_in_region * PAGE_SIZE).asPtr(); + byte* dest_ptr = region.laddr().offset(page_index_in_region * PAGE_SIZE).as_ptr(); #ifdef MM_DEBUG dbgprintf("MM: page_in_from_inode ready to read from inode, will write to L%x!\n", dest_ptr); #endif @@ -337,7 +337,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault) return PageFaultResponse::Continue; } } else if (fault.is_protection_violation()) { - if (region->cow_map.get(page_index_in_region)) { + if (region->m_cow_map.get(page_index_in_region)) { dbgprintf("PV(cow) fault in Region{%p}[%u]\n", region, page_index_in_region); bool success = copy_on_write(*region, page_index_in_region); ASSERT(success); @@ -406,7 +406,7 @@ byte* MemoryManager::quickmap_page(PhysicalPage& physical_page) #ifdef MM_DEBUG dbgprintf("MM: >> quickmap_page L%x => P%x @ PTE=%p\n", page_laddr, physical_page.paddr().get(), pte.ptr()); #endif - return page_laddr.asPtr(); + return page_laddr.as_ptr(); } void MemoryManager::unquickmap_page() @@ -428,35 +428,35 @@ void MemoryManager::unquickmap_page() void MemoryManager::remap_region_page(Region& region, unsigned page_index_in_region, bool user_allowed) { - ASSERT(region.m_page_directory); + ASSERT(region.page_directory()); InterruptDisabler disabler; - auto page_laddr = region.linearAddress.offset(page_index_in_region * PAGE_SIZE); - auto pte = ensure_pte(*region.m_page_directory, page_laddr); + auto page_laddr = region.laddr().offset(page_index_in_region * PAGE_SIZE); + auto pte = ensure_pte(*region.page_directory(), page_laddr); auto& physical_page = region.vmo().physical_pages()[page_index_in_region]; ASSERT(physical_page); pte.set_physical_page_base(physical_page->paddr().get()); pte.set_present(true); // FIXME: Maybe we should use the is_readable flag here? - if (region.cow_map.get(page_index_in_region)) + if (region.m_cow_map.get(page_index_in_region)) pte.set_writable(false); else - pte.set_writable(region.is_writable); + pte.set_writable(region.is_writable()); pte.set_user_allowed(user_allowed); - region.m_page_directory->flush(page_laddr); + region.page_directory()->flush(page_laddr); #ifdef MM_DEBUG - dbgprintf("MM: >> remap_region_page (PD=%x, PTE=P%x) '%s' L%x => P%x (@%p)\n", region.m_page_directory->cr3(), pte.ptr(), region.name.characters(), page_laddr.get(), physical_page->paddr().get(), physical_page.ptr()); + dbgprintf("MM: >> remap_region_page (PD=%x, PTE=P%x) '%s' L%x => P%x (@%p)\n", region.page_directory()->cr3(), pte.ptr(), region.name.characters(), page_laddr.get(), physical_page->paddr().get(), physical_page.ptr()); #endif } void MemoryManager::remap_region(Process& process, Region& region) { InterruptDisabler disabler; - map_region_at_address(process.page_directory(), region, region.linearAddress, true); + map_region_at_address(process.page_directory(), region, region.laddr(), true); } void MemoryManager::map_region_at_address(PageDirectory& page_directory, Region& region, LinearAddress laddr, bool user_allowed) { InterruptDisabler disabler; - region.m_page_directory = page_directory; + region.set_page_directory(page_directory); auto& vmo = region.vmo(); #ifdef MM_DEBUG dbgprintf("MM: map_region_at_address will map VMO pages %u - %u (VMO page count: %u)\n", region.first_page_index(), region.last_page_index(), vmo.page_count()); @@ -469,14 +469,14 @@ void MemoryManager::map_region_at_address(PageDirectory& page_directory, Region& pte.set_physical_page_base(physical_page->paddr().get()); pte.set_present(true); // FIXME: Maybe we should use the is_readable flag here? // FIXME: It seems wrong that the *region* cow map is essentially using *VMO* relative indices. - if (region.cow_map.get(region.first_page_index() + i)) + if (region.m_cow_map.get(region.first_page_index() + i)) pte.set_writable(false); else - pte.set_writable(region.is_writable); + pte.set_writable(region.is_writable()); } else { pte.set_physical_page_base(0); pte.set_present(false); - pte.set_writable(region.is_writable); + pte.set_writable(region.is_writable()); } pte.set_user_allowed(user_allowed); page_directory.flush(page_laddr); @@ -488,28 +488,28 @@ void MemoryManager::map_region_at_address(PageDirectory& page_directory, Region& bool MemoryManager::unmap_region(Region& region) { - ASSERT(region.m_page_directory); + ASSERT(region.page_directory()); InterruptDisabler disabler; for (size_t i = 0; i < region.page_count(); ++i) { - auto laddr = region.linearAddress.offset(i * PAGE_SIZE); - auto pte = ensure_pte(*region.m_page_directory, laddr); + auto laddr = region.laddr().offset(i * PAGE_SIZE); + auto pte = ensure_pte(*region.page_directory(), laddr); pte.set_physical_page_base(0); pte.set_present(false); pte.set_writable(false); pte.set_user_allowed(false); - region.m_page_directory->flush(laddr); + region.page_directory()->flush(laddr); #ifdef MM_DEBUG auto& physical_page = region.vmo().physical_pages()[region.first_page_index() + i]; dbgprintf("MM: >> Unmapped L%x => P%x <<\n", laddr, physical_page ? physical_page->paddr().get() : 0); #endif } - region.m_page_directory.clear(); + region.release_page_directory(); return true; } bool MemoryManager::map_region(Process& process, Region& region) { - map_region_at_address(process.page_directory(), region, region.linearAddress, true); + map_region_at_address(process.page_directory(), region, region.laddr(), true); return true; } @@ -549,57 +549,57 @@ RetainPtr<Region> Region::clone() { InterruptDisabler disabler; - if (m_shared || (is_readable && !is_writable)) { + if (m_shared || (m_readable && !m_writable)) { // Create a new region backed by the same VMObject. - return adopt(*new Region(linearAddress, size, m_vmo.copyRef(), m_offset_in_vmo, String(name), is_readable, is_writable)); + return adopt(*new Region(laddr(), size(), m_vmo.copyRef(), m_offset_in_vmo, String(m_name), m_readable, m_writable)); } dbgprintf("%s<%u> Region::clone(): cowing %s (L%x)\n", current->name().characters(), current->pid(), - name.characters(), - linearAddress.get()); + m_name.characters(), + laddr().get()); // Set up a COW region. The parent (this) region becomes COW as well! for (size_t i = 0; i < page_count(); ++i) - cow_map.set(i, true); + m_cow_map.set(i, true); MM.remap_region(*current, *this); - return adopt(*new Region(linearAddress, size, m_vmo->clone(), m_offset_in_vmo, String(name), is_readable, is_writable, true)); + return adopt(*new Region(laddr(), size(), m_vmo->clone(), m_offset_in_vmo, String(m_name), m_readable, m_writable, true)); } Region::Region(LinearAddress a, size_t s, String&& n, bool r, bool w, bool cow) - : linearAddress(a) - , size(s) + : m_laddr(a) + , m_size(s) , m_vmo(VMObject::create_anonymous(s)) - , name(move(n)) - , is_readable(r) - , is_writable(w) - , cow_map(Bitmap::create(m_vmo->page_count(), cow)) + , m_name(move(n)) + , m_readable(r) + , m_writable(w) + , m_cow_map(Bitmap::create(m_vmo->page_count(), cow)) { - m_vmo->set_name(name); + m_vmo->set_name(m_name); MM.register_region(*this); } Region::Region(LinearAddress a, size_t s, RetainPtr<Inode>&& inode, String&& n, bool r, bool w) - : linearAddress(a) - , size(s) + : m_laddr(a) + , m_size(s) , m_vmo(VMObject::create_file_backed(move(inode), s)) - , name(move(n)) - , is_readable(r) - , is_writable(w) - , cow_map(Bitmap::create(m_vmo->page_count())) + , m_name(move(n)) + , m_readable(r) + , m_writable(w) + , m_cow_map(Bitmap::create(m_vmo->page_count())) { MM.register_region(*this); } Region::Region(LinearAddress a, size_t s, RetainPtr<VMObject>&& vmo, size_t offset_in_vmo, String&& n, bool r, bool w, bool cow) - : linearAddress(a) - , size(s) + : m_laddr(a) + , m_size(s) , m_offset_in_vmo(offset_in_vmo) , m_vmo(move(vmo)) - , name(move(n)) - , is_readable(r) - , is_writable(w) - , cow_map(Bitmap::create(m_vmo->page_count(), cow)) + , m_name(move(n)) + , m_readable(r) + , m_writable(w) + , m_cow_map(Bitmap::create(m_vmo->page_count(), cow)) { MM.register_region(*this); } @@ -713,7 +713,7 @@ int Region::commit() { InterruptDisabler disabler; #ifdef MM_DEBUG - dbgprintf("MM: commit %u pages in Region %p (VMO=%p) at L%x\n", vmo().page_count(), this, &vmo(), linearAddress.get()); + dbgprintf("MM: commit %u pages in Region %p (VMO=%p) at L%x\n", vmo().page_count(), this, &vmo(), laddr.get()); #endif for (size_t i = first_page_index(); i <= last_page_index(); ++i) { if (!vmo().physical_pages()[i].is_null()) diff --git a/Kernel/MemoryManager.h b/Kernel/MemoryManager.h index 4aa2741064..9b01df68d2 100644 --- a/Kernel/MemoryManager.h +++ b/Kernel/MemoryManager.h @@ -111,12 +111,21 @@ private: }; class Region : public Retainable<Region> { + friend class MemoryManager; public: Region(LinearAddress, size_t, String&&, bool r, bool w, bool cow = false); Region(LinearAddress, size_t, RetainPtr<VMObject>&&, size_t offset_in_vmo, String&&, bool r, bool w, bool cow = false); Region(LinearAddress, size_t, RetainPtr<Inode>&&, String&&, bool r, bool w); ~Region(); + LinearAddress laddr() const { return m_laddr; } + size_t size() const { return m_size; } + bool is_readable() const { return m_readable; } + bool is_writable() const { return m_writable; } + String name() const { return m_name; } + + void set_name(String&& name) { m_name = move(name); } + const VMObject& vmo() const { return *m_vmo; } VMObject& vmo() { return *m_vmo; } @@ -125,12 +134,12 @@ public: RetainPtr<Region> clone(); bool contains(LinearAddress laddr) const { - return laddr >= linearAddress && laddr < linearAddress.offset(size); + return laddr >= m_laddr && laddr < m_laddr.offset(size()); } unsigned page_index_from_address(LinearAddress laddr) const { - return (laddr - linearAddress).get() / PAGE_SIZE; + return (laddr - m_laddr).get() / PAGE_SIZE; } size_t first_page_index() const @@ -145,7 +154,7 @@ public: size_t page_count() const { - return size / PAGE_SIZE; + return m_size / PAGE_SIZE; } bool page_in(); @@ -153,16 +162,33 @@ public: size_t committed() const; + PageDirectory* page_directory() { return m_page_directory.ptr(); } + + void set_page_directory(PageDirectory& page_directory) + { + ASSERT(!m_page_directory || m_page_directory.ptr() == &page_directory); + m_page_directory = page_directory; + } + + void release_page_directory() + { + ASSERT(m_page_directory); + m_page_directory.clear(); + } + + const Bitmap& cow_map() const { return m_cow_map; } + +private: RetainPtr<PageDirectory> m_page_directory; - LinearAddress linearAddress; - size_t size { 0 }; + LinearAddress m_laddr; + size_t m_size { 0 }; size_t m_offset_in_vmo { 0 }; RetainPtr<VMObject> m_vmo; - String name; - bool is_readable { true }; - bool is_writable { true }; + String m_name; + bool m_readable { true }; + bool m_writable { true }; bool m_shared { false }; - Bitmap cow_map; + Bitmap m_cow_map; }; #define MM MemoryManager::the() diff --git a/Kernel/ProcFileSystem.cpp b/Kernel/ProcFileSystem.cpp index 65606929fa..86cefbb230 100644 --- a/Kernel/ProcFileSystem.cpp +++ b/Kernel/ProcFileSystem.cpp @@ -52,11 +52,11 @@ ByteBuffer procfs$pid_vm(Process& process) builder.appendf("BEGIN END SIZE COMMIT NAME\n"); for (auto& region : process.regions()) { builder.appendf("%x -- %x %x %x %s\n", - region->linearAddress.get(), - region->linearAddress.offset(region->size - 1).get(), - region->size, + region->laddr().get(), + region->laddr().offset(region->size() - 1).get(), + region->size(), region->committed(), - region->name.characters()); + region->name().characters()); } return builder.to_byte_buffer(); } @@ -68,10 +68,10 @@ ByteBuffer procfs$pid_vmo(Process& process) builder.appendf("BEGIN END SIZE NAME\n"); for (auto& region : process.regions()) { builder.appendf("%x -- %x %x %s\n", - region->linearAddress.get(), - region->linearAddress.offset(region->size - 1).get(), - region->size, - region->name.characters()); + region->laddr().get(), + region->laddr().offset(region->size() - 1).get(), + region->size(), + region->name().characters()); builder.appendf("VMO: %s \"%s\" @ %x(%u)\n", region->vmo().is_anonymous() ? "anonymous" : "file-backed", region->vmo().name().characters(), @@ -81,7 +81,7 @@ ByteBuffer procfs$pid_vmo(Process& process) auto& physical_page = region->vmo().physical_pages()[i]; builder.appendf("P%x%s(%u) ", physical_page ? physical_page->paddr().get() : 0, - region->cow_map.get(i) ? "!" : "", + region->cow_map().get(i) ? "!" : "", physical_page ? physical_page->retain_count() : 0 ); } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index e312edb7c5..1f0aa1dce0 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -132,7 +132,7 @@ bool Process::deallocate_region(Region& region) Region* Process::regionFromRange(LinearAddress laddr, size_t size) { for (auto& region : m_regions) { - if (region->linearAddress == laddr && region->size == size) + if (region->laddr() == laddr && region->size() == size) return region.ptr(); } return nullptr; @@ -145,7 +145,7 @@ int Process::sys$set_mmap_name(void* addr, size_t size, const char* name) auto* region = regionFromRange(LinearAddress((dword)addr), size); if (!region) return -EINVAL; - region->name = name; + region->set_name(String(name)); return 0; } @@ -170,7 +170,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params) auto* region = allocate_region(LinearAddress(), size, "mmap", prot & PROT_READ, prot & PROT_WRITE, false); if (!region) return (void*)-ENOMEM; - return region->linearAddress.asPtr(); + return region->laddr().as_ptr(); } if (offset & ~PAGE_MASK) return (void*)-EINVAL; @@ -187,7 +187,7 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* params) auto* region = allocate_file_backed_region(LinearAddress(), size, descriptor->inode(), move(region_name), prot & PROT_READ, prot & PROT_WRITE); if (!region) return (void*)-ENOMEM; - return region->linearAddress.asPtr(); + return region->laddr().as_ptr(); } int Process::sys$munmap(void* addr, size_t size) @@ -229,7 +229,7 @@ Process* Process::fork(RegisterDump& regs) for (auto& region : m_regions) { #ifdef FORK_DEBUG - dbgprintf("fork: cloning Region{%p} \"%s\" L%x\n", region.ptr(), region->name.characters(), region->linearAddress.get()); + dbgprintf("fork: cloning Region{%p} \"%s\" L%x\n", region.ptr(), region->name.characters(), region->laddr().get()); #endif auto cloned_region = region->clone(); child->m_regions.append(move(cloned_region)); @@ -324,20 +324,20 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri InterruptDisabler disabler; // Okay, here comes the sleight of hand, pay close attention.. auto old_regions = move(m_regions); - ELFLoader loader(region->linearAddress.asPtr()); + ELFLoader loader(region->laddr().as_ptr()); loader.map_section_hook = [&] (LinearAddress laddr, size_t size, size_t alignment, size_t offset_in_image, bool is_readable, bool is_writable, const String& name) { ASSERT(size); ASSERT(alignment == PAGE_SIZE); size = ((size / 4096) + 1) * 4096; // FIXME: Use ceil_div? (void) allocate_region_with_vmo(laddr, size, vmo.copyRef(), offset_in_image, String(name), is_readable, is_writable); - return laddr.asPtr(); + return laddr.as_ptr(); }; loader.alloc_section_hook = [&] (LinearAddress laddr, size_t size, size_t alignment, bool is_readable, bool is_writable, const String& name) { ASSERT(size); ASSERT(alignment == PAGE_SIZE); size = ((size / 4096) + 1) * 4096; // FIXME: Use ceil_div? (void) allocate_region(laddr, size, String(name), is_readable, is_writable); - return laddr.asPtr(); + return laddr.as_ptr(); }; bool success = loader.load(); if (!success) { @@ -399,7 +399,7 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri m_tss.cr3 = page_directory().cr3(); m_stack_region = allocate_region(LinearAddress(), defaultStackSize, "stack"); ASSERT(m_stack_region); - m_stackTop3 = m_stack_region->linearAddress.offset(defaultStackSize).get(); + m_stackTop3 = m_stack_region->laddr().offset(defaultStackSize).get(); m_tss.esp = m_stackTop3; m_tss.ss0 = 0x10; m_tss.esp0 = old_esp0; @@ -521,7 +521,7 @@ int Process::sys$get_environment(char*** environ) if (!region) return -ENOMEM; MM.map_region(*this, *region); - char* envpage = (char*)region->linearAddress.get(); + char* envpage = (char*)region->laddr().get(); *environ = (char**)envpage; char* bufptr = envpage + (sizeof(char*) * (m_initial_environment.size() + 1)); for (size_t i = 0; i < m_initial_environment.size(); ++i) { @@ -540,7 +540,7 @@ int Process::sys$get_arguments(int* argc, char*** argv) if (!region) return -ENOMEM; MM.map_region(*this, *region); - char* argpage = (char*)region->linearAddress.get(); + char* argpage = (char*)region->laddr().get(); *argc = m_initial_arguments.size(); *argv = (char**)argpage; char* bufptr = argpage + (sizeof(char*) * (m_initial_arguments.size() + 1)); @@ -674,7 +674,7 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring } else { auto* region = allocate_region(LinearAddress(), defaultStackSize, "stack"); ASSERT(region); - m_stackTop3 = region->linearAddress.offset(defaultStackSize).get(); + m_stackTop3 = region->laddr().offset(defaultStackSize).get(); m_tss.esp = m_stackTop3; } } @@ -713,10 +713,10 @@ void Process::dumpRegions() kprintf("BEGIN END SIZE NAME\n"); for (auto& region : m_regions) { kprintf("%x -- %x %x %s\n", - region->linearAddress.get(), - region->linearAddress.offset(region->size - 1).get(), - region->size, - region->name.characters()); + region->laddr().get(), + region->laddr().offset(region->size() - 1).get(), + region->size(), + region->name().characters()); } } @@ -798,7 +798,7 @@ bool Process::dispatch_signal(byte signal) m_pending_signals &= ~(1 << signal); - if (handler_laddr.asPtr() == SIG_IGN) { + if (handler_laddr.as_ptr() == SIG_IGN) { dbgprintf("%s(%u) ignored signal %u\n", name().characters(), pid(), signal); return false; } @@ -828,9 +828,9 @@ bool Process::dispatch_signal(byte signal) ASSERT(m_signal_stack_user_region); } m_tss.ss = 0x23; - m_tss.esp = m_signal_stack_user_region->linearAddress.offset(defaultStackSize).get() & 0xfffffff8; + m_tss.esp = m_signal_stack_user_region->laddr().offset(defaultStackSize).get() & 0xfffffff8; m_tss.ss0 = 0x10; - m_tss.esp0 = m_signal_stack_kernel_region->linearAddress.offset(defaultStackSize).get() & 0xfffffff8; + m_tss.esp0 = m_signal_stack_kernel_region->laddr().offset(defaultStackSize).get() & 0xfffffff8; push_value_on_stack(ret_eflags); push_value_on_stack(ret_cs); push_value_on_stack(ret_eip); @@ -863,8 +863,8 @@ bool Process::dispatch_signal(byte signal) // FIXME: This should be a global trampoline shared by all processes, not one created per process! // FIXME: Remap as read-only after setup. auto* region = allocate_region(LinearAddress(), PAGE_SIZE, "signal_trampoline", true, true); - m_return_to_ring3_from_signal_trampoline = region->linearAddress; - byte* code_ptr = m_return_to_ring3_from_signal_trampoline.asPtr(); + m_return_to_ring3_from_signal_trampoline = region->laddr(); + byte* code_ptr = m_return_to_ring3_from_signal_trampoline.as_ptr(); *code_ptr++ = 0x61; // popa *code_ptr++ = 0x9d; // popf *code_ptr++ = 0xc3; // ret @@ -1598,9 +1598,9 @@ bool Process::validate_read_from_kernel(LinearAddress laddr) const // FIXME: What if we're indexing into the ksym with the highest address though? if (laddr.get() >= ksym_lowest_address && laddr.get() <= ksym_highest_address) return true; - if (is_kmalloc_address(laddr.asPtr())) + if (is_kmalloc_address(laddr.as_ptr())) return true; - return validate_read(laddr.asPtr(), 1); + return validate_read(laddr.as_ptr(), 1); } bool Process::validate_read(const void* address, size_t size) const @@ -1917,7 +1917,7 @@ DisplayInfo Process::get_display_info() auto framebuffer_vmo = VMObject::create_framebuffer_wrapper(PhysicalAddress(vmode->framebuffer), framebuffer_size); m_display_framebuffer_region = allocate_region_with_vmo(LinearAddress(0xe0000000), framebuffer_size, move(framebuffer_vmo), 0, "framebuffer", true, true); } - info.framebuffer = m_display_framebuffer_region->linearAddress.asPtr(); + info.framebuffer = m_display_framebuffer_region->laddr().as_ptr(); return info; } diff --git a/Kernel/ProcessGUI.cpp b/Kernel/ProcessGUI.cpp index 8109ee4262..312850ab6e 100644 --- a/Kernel/ProcessGUI.cpp +++ b/Kernel/ProcessGUI.cpp @@ -100,7 +100,7 @@ int Process::gui$get_window_backing_store(int window_id, GUI_WindowBackingStoreI info->bpp = sizeof(RGBA32); info->pitch = window.backing()->pitch(); info->size = window.backing()->size(); - info->pixels = reinterpret_cast<RGBA32*>(window.backing()->client_region()->linearAddress.asPtr()); + info->pixels = reinterpret_cast<RGBA32*>(window.backing()->client_region()->laddr().as_ptr()); return 0; } diff --git a/Kernel/types.h b/Kernel/types.h index 99bc61dd95..605a5e6a8c 100644 --- a/Kernel/types.h +++ b/Kernel/types.h @@ -61,10 +61,10 @@ public: bool is_null() const { return m_address == 0; } - byte* asPtr() { return reinterpret_cast<byte*>(m_address); } - const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); } + byte* as_ptr() { return reinterpret_cast<byte*>(m_address); } + const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); } - dword pageBase() const { return m_address & 0xfffff000; } + dword page_base() const { return m_address & 0xfffff000; } bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; } @@ -91,10 +91,10 @@ public: bool operator==(const LinearAddress& other) const { return m_address == other.m_address; } bool operator!=(const LinearAddress& other) const { return m_address != other.m_address; } - byte* asPtr() { return reinterpret_cast<byte*>(m_address); } - const byte* asPtr() const { return reinterpret_cast<const byte*>(m_address); } + byte* as_ptr() { return reinterpret_cast<byte*>(m_address); } + const byte* as_ptr() const { return reinterpret_cast<const byte*>(m_address); } - dword pageBase() const { return m_address & 0xfffff000; } + dword page_base() const { return m_address & 0xfffff000; } private: dword m_address { 0 }; |