Skip to content

Commit

Permalink
Kernel: Rename LinearAddress => VirtualAddress.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 7, 2019
1 parent 0ed8944 commit e42c3b4
Show file tree
Hide file tree
Showing 33 changed files with 272 additions and 272 deletions.
4 changes: 2 additions & 2 deletions AK/ELF/ELFImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ELFImage {
dword type() const { return m_program_header.p_type; }
dword flags() const { return m_program_header.p_flags; }
dword offset() const { return m_program_header.p_offset; }
LinearAddress laddr() const { return LinearAddress(m_program_header.p_vaddr); }
VirtualAddress vaddr() const { return VirtualAddress(m_program_header.p_vaddr); }
dword size_in_memory() const { return m_program_header.p_memsz; }
dword size_in_image() const { return m_program_header.p_filesz; }
dword alignment() const { return m_program_header.p_align; }
Expand Down Expand Up @@ -117,7 +117,7 @@ class ELFImage {
bool is_executable() const { return header().e_type == ET_EXEC; }
bool is_relocatable() const { return header().e_type == ET_REL; }

LinearAddress entry() const { return LinearAddress(header().e_entry); }
VirtualAddress entry() const { return VirtualAddress(header().e_entry); }

private:
bool parse_header();
Expand Down
8 changes: 4 additions & 4 deletions AK/ELF/ELFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ bool ELFLoader::layout()
if (program_header.type() != PT_LOAD)
return;
#ifdef ELFLOADER_DEBUG
kprintf("PH: L%x %u r:%u w:%u\n", program_header.laddr().get(), program_header.size_in_memory(), program_header.is_readable(), program_header.is_writable());
kprintf("PH: L%x %u r:%u w:%u\n", program_header.vaddr().get(), program_header.size_in_memory(), program_header.is_readable(), program_header.is_writable());
#endif
if (program_header.is_writable()) {
alloc_section_hook(
program_header.laddr(),
program_header.vaddr(),
program_header.size_in_memory(),
program_header.alignment(),
program_header.is_readable(),
program_header.is_writable(),
String::format("elf-alloc-%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "")
);
memcpy(program_header.laddr().as_ptr(), program_header.raw_data(), program_header.size_in_image());
memcpy(program_header.vaddr().as_ptr(), program_header.raw_data(), program_header.size_in_image());
} else {
map_section_hook(
program_header.laddr(),
program_header.vaddr(),
program_header.size_in_memory(),
program_header.alignment(),
program_header.offset(),
Expand Down
8 changes: 4 additions & 4 deletions AK/ELF/ELFLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <AK/OwnPtr.h>
#include <AK/Vector.h>
#if defined(KERNEL)
#include <Kernel/LinearAddress.h>
#include <Kernel/VirtualAddress.h>
#endif
#include <AK/ELF/ELFImage.h>

Expand All @@ -16,9 +16,9 @@ class ELFLoader {

bool load();
#if defined(KERNEL)
Function<void*(LinearAddress, size_t, size_t, bool, bool, const String&)> alloc_section_hook;
Function<void*(LinearAddress, size_t, size_t, size_t, bool r, bool w, bool x, const String&)> map_section_hook;
LinearAddress entry() const { return m_image.entry(); }
Function<void*(VirtualAddress, size_t, size_t, bool, bool, const String&)> alloc_section_hook;
Function<void*(VirtualAddress, size_t, size_t, size_t, bool r, bool w, bool x, const String&)> map_section_hook;
VirtualAddress entry() const { return m_image.entry(); }
#endif
char* symbol_ptr(const char* name);

Expand Down
8 changes: 4 additions & 4 deletions Kernel/Devices/BXVGADevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ dword BXVGADevice::find_framebuffer_address()
return framebuffer_address;
}

KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot)
{
ASSERT(offset == 0);
ASSERT(size == framebuffer_size_in_bytes());
auto vmo = VMObject::create_for_physical_range(framebuffer_address(), framebuffer_size_in_bytes());
auto* region = process.allocate_region_with_vmo(
preferred_laddr,
preferred_vaddr,
framebuffer_size_in_bytes(),
move(vmo),
0,
"BXVGA Framebuffer",
prot);
kprintf("BXVGA: %s(%u) created Region{%p} with size %u for framebuffer P%x with laddr L%x\n",
kprintf("BXVGA: %s(%u) created Region{%p} with size %u for framebuffer P%x with vaddr L%x\n",
process.name().characters(), process.pid(),
region, region->size(), framebuffer_address().as_ptr(), region->laddr().get());
region, region->size(), framebuffer_address().as_ptr(), region->vaddr().get());
ASSERT(region);
return region;
}
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Devices/BXVGADevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BXVGADevice final : public BlockDevice {
void set_y_offset(int);

virtual int ioctl(FileDescription&, unsigned request, unsigned arg) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t, int prot) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t, int prot) override;

size_t framebuffer_size_in_bytes() const { return m_framebuffer_size.area() * sizeof(dword) * 2; }
Size framebuffer_size() const { return m_framebuffer_size; }
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Devices/BlockDevice.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <Kernel/Devices/Device.h>
#include <Kernel/LinearAddress.h>
#include <Kernel/VirtualAddress.h>

class BlockDevice : public Device {
public:
Expand Down
2 changes: 1 addition & 1 deletion Kernel/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int File::ioctl(FileDescription&, unsigned, unsigned)
return -ENOTTY;
}

KResultOr<Region*> File::mmap(Process&, FileDescription&, LinearAddress, size_t, size_t, int)
KResultOr<Region*> File::mmap(Process&, FileDescription&, VirtualAddress, size_t, size_t, int)
{
return KResult(-ENODEV);
}
4 changes: 2 additions & 2 deletions Kernel/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <AK/Retained.h>
#include <AK/Types.h>
#include <Kernel/KResult.h>
#include <Kernel/LinearAddress.h>
#include <Kernel/VirtualAddress.h>
#include <Kernel/UnixTypes.h>

class FileDescription;
Expand Down Expand Up @@ -52,7 +52,7 @@ class File : public Retainable<File> {
virtual ssize_t read(FileDescription&, byte*, ssize_t) = 0;
virtual ssize_t write(FileDescription&, const byte*, ssize_t) = 0;
virtual int ioctl(FileDescription&, unsigned request, unsigned arg);
virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot);
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot);

virtual String absolute_path(const FileDescription&) const = 0;

Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/FileDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ InodeMetadata FileDescription::metadata() const
return {};
}

KResultOr<Region*> FileDescription::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)
KResultOr<Region*> FileDescription::mmap(Process& process, VirtualAddress vaddr, size_t offset, size_t size, int prot)
{
return m_file->mmap(process, *this, laddr, offset, size, prot);
return m_file->mmap(process, *this, vaddr, offset, size, prot);
}

KResult FileDescription::truncate(off_t length)
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/FileDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/LinearAddress.h>
#include <Kernel/VirtualAddress.h>
#include <Kernel/Net/Socket.h>

class File;
Expand Down Expand Up @@ -67,7 +67,7 @@ class FileDescription : public Retainable<FileDescription> {
Custody* custody() { return m_custody.ptr(); }
const Custody* custody() const { return m_custody.ptr(); }

KResultOr<Region*> mmap(Process&, LinearAddress, size_t offset, size_t, int prot);
KResultOr<Region*> mmap(Process&, VirtualAddress, size_t offset, size_t, int prot);

bool is_blocking() const { return m_is_blocking; }
void set_blocking(bool b) { m_is_blocking = b; }
Expand Down
4 changes: 2 additions & 2 deletions Kernel/FileSystem/InodeFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ ssize_t InodeFile::write(FileDescription& descriptor, const byte* data, ssize_t
return m_inode->write_bytes(descriptor.offset(), count, data, &descriptor);
}

KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& descriptor, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& descriptor, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot)
{
ASSERT(offset == 0);
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
InterruptDisabler disabler;
auto* region = process.allocate_file_backed_region(preferred_laddr, size, inode(), descriptor.absolute_path(), prot);
auto* region = process.allocate_file_backed_region(preferred_vaddr, size, inode(), descriptor.absolute_path(), prot);
if (!region)
return KResult(-ENOMEM);
return region;
Expand Down
2 changes: 1 addition & 1 deletion Kernel/FileSystem/InodeFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InodeFile final : public File {

virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot) override;

virtual String absolute_path(const FileDescription&) const override;

Expand Down
10 changes: 5 additions & 5 deletions Kernel/FileSystem/ProcFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
if (region->is_writable())
flags_builder.append('W');
builder.appendf("%x -- %x %x %x % 4s %s\n",
region->laddr().get(),
region->laddr().offset(region->size() - 1).get(),
region->vaddr().get(),
region->vaddr().offset(region->size() - 1).get(),
region->size(),
region->amount_resident(),
flags_builder.to_string().characters(),
Expand Down Expand Up @@ -263,8 +263,8 @@ ByteBuffer procfs$pid_vmo(InodeIdentifier identifier)
builder.appendf("BEGIN END SIZE NAME\n");
for (auto& region : process.regions()) {
builder.appendf("%x -- %x %x %s\n",
region->laddr().get(),
region->laddr().offset(region->size() - 1).get(),
region->vaddr().get(),
region->vaddr().offset(region->size() - 1).get(),
region->size(),
region->name().characters());
builder.appendf("VMO: %s \"%s\" @ %x(%u)\n",
Expand Down Expand Up @@ -300,7 +300,7 @@ ByteBuffer procfs$pid_stack(InodeIdentifier identifier)
builder.appendf("Thread %d:\n", thread.tid());
Vector<RecognizedSymbol, 64> recognized_symbols;
recognized_symbols.append({ thread.tss().eip, ksymbolicate(thread.tss().eip) });
for (dword* stack_ptr = (dword*)thread.frame_ptr(); process.validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
for (dword* stack_ptr = (dword*)thread.frame_ptr(); process.validate_read_from_kernel(VirtualAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
dword retaddr = stack_ptr[1];
recognized_symbols.append({ retaddr, ksymbolicate(retaddr) });
}
Expand Down
4 changes: 2 additions & 2 deletions Kernel/KSyms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
RecognizedSymbol recognized_symbols[max_recognized_symbol_count];
int recognized_symbol_count = 0;
if (use_ksyms) {
for (dword* stack_ptr = (dword*)ebp; current->process().validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
for (dword* stack_ptr = (dword*)ebp; current->process().validate_read_from_kernel(VirtualAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
dword retaddr = stack_ptr[1];
recognized_symbols[recognized_symbol_count++] = { retaddr, ksymbolicate(retaddr) };
}
} else {
for (dword* stack_ptr = (dword*)ebp; current->process().validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
for (dword* stack_ptr = (dword*)ebp; current->process().validate_read_from_kernel(VirtualAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
dword retaddr = stack_ptr[1];
dbgprintf("%x (next: %x)\n", retaddr, stack_ptr ? (dword*)*stack_ptr : 0);
}
Expand Down
39 changes: 0 additions & 39 deletions Kernel/LinearAddress.h

This file was deleted.

10 changes: 5 additions & 5 deletions Kernel/Net/E1000NetworkAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address pci_address, byte irq)
enable_bus_mastering(m_pci_address);

m_mmio_base = PhysicalAddress(PCI::get_BAR0(m_pci_address));
MM.map_for_kernel(LinearAddress(m_mmio_base.get()), m_mmio_base);
MM.map_for_kernel(LinearAddress(m_mmio_base.offset(4096).get()), m_mmio_base.offset(4096));
MM.map_for_kernel(LinearAddress(m_mmio_base.offset(8192).get()), m_mmio_base.offset(8192));
MM.map_for_kernel(LinearAddress(m_mmio_base.offset(12288).get()), m_mmio_base.offset(12288));
MM.map_for_kernel(LinearAddress(m_mmio_base.offset(16384).get()), m_mmio_base.offset(16384));
MM.map_for_kernel(VirtualAddress(m_mmio_base.get()), m_mmio_base);
MM.map_for_kernel(VirtualAddress(m_mmio_base.offset(4096).get()), m_mmio_base.offset(4096));
MM.map_for_kernel(VirtualAddress(m_mmio_base.offset(8192).get()), m_mmio_base.offset(8192));
MM.map_for_kernel(VirtualAddress(m_mmio_base.offset(12288).get()), m_mmio_base.offset(12288));
MM.map_for_kernel(VirtualAddress(m_mmio_base.offset(16384).get()), m_mmio_base.offset(16384));
m_use_mmio = true;
m_io_base = PCI::get_BAR1(m_pci_address) & ~1;
m_interrupt_line = PCI::get_interrupt_line(m_pci_address);
Expand Down
Loading

0 comments on commit e42c3b4

Please sign in to comment.