Moving the rest (except ACPI tables) to high mem

Also the debug messaging to verify it.
This commit is contained in:
Justin C. Miller
2018-09-03 15:15:19 -07:00
parent 799fbbdd10
commit d5b8902d8f
4 changed files with 30 additions and 13 deletions

View File

@@ -191,6 +191,7 @@ memory_virtualize(EFI_RUNTIME_SERVICES *runsvc, struct memory_map *map)
case KERNEL_FONT_MEMTYPE: case KERNEL_FONT_MEMTYPE:
case KERNEL_DATA_MEMTYPE: case KERNEL_DATA_MEMTYPE:
d->Attribute |= EFI_MEMORY_RUNTIME; d->Attribute |= EFI_MEMORY_RUNTIME;
d->VirtualStart = d->PhysicalStart + KERNEL_VIRT_ADDRESS;
default: default:
if (d->Attribute & EFI_MEMORY_RUNTIME) { if (d->Attribute & EFI_MEMORY_RUNTIME) {

View File

@@ -85,6 +85,19 @@ kernel_main(popcorn_data *header)
init_console(header); init_console(header);
log::debug(logs::boot, " Popcorn header is at: %016lx", header);
log::debug(logs::boot, " Framebuffer is at: %016lx", header->frame_buffer);
log::debug(logs::boot, " Font data is at: %016lx", header->font);
log::debug(logs::boot, " Kernel data is at: %016lx", header->data);
log::debug(logs::boot, " Memory map is at: %016lx", header->memory_map);
log::debug(logs::boot, "ACPI root table is at: %016lx", header->acpi_table);
log::debug(logs::boot, "Runtime service is at: %016lx", header->runtime);
/*
pager->dump_pml4(nullptr, 0);
pager->dump_blocks(true);
*/
device_manager *devices = device_manager *devices =
new (&device_manager::get()) device_manager(header->acpi_table); new (&device_manager::get()) device_manager(header->acpi_table);

View File

@@ -141,7 +141,7 @@ page_block::dump(page_block *list, const char *name, bool show_unmapped)
if (cur->virtual_address) { if (cur->virtual_address) {
page_table_indices start{cur->virtual_address}; page_table_indices start{cur->virtual_address};
log::info(logs::memory, " %lx %x [%6d] %lx (%d,%d,%d,%d)", log::info(logs::memory, " %016lx %08x [%6d] %016lx (%d,%d,%d,%d)",
cur->physical_address, cur->physical_address,
cur->flags, cur->flags,
cur->count, cur->count,
@@ -149,7 +149,7 @@ page_block::dump(page_block *list, const char *name, bool show_unmapped)
start[0], start[1], start[2], start[3]); start[0], start[1], start[2], start[3]);
} else { } else {
page_table_indices start{cur->virtual_address}; page_table_indices start{cur->virtual_address};
log::info(logs::memory, " %lx %x [%6d]", log::info(logs::memory, " %016lx %08x [%6d]",
cur->physical_address, cur->physical_address,
cur->flags, cur->flags,
cur->count); cur->count);
@@ -276,18 +276,19 @@ page_manager::map_offset_pointer(void **pointer, size_t length)
} }
void void
page_manager::dump_blocks() page_manager::dump_blocks(bool used_only)
{ {
page_block::dump(m_used, "used", true); page_block::dump(m_used, "used", true);
page_block::dump(m_free, "free", true); if (!used_only)
page_block::dump(m_free, "free", true);
} }
void void
page_manager::dump_pml4(page_table *pml4) page_manager::dump_pml4(page_table *pml4, int max_index)
{ {
if (pml4 == nullptr) if (pml4 == nullptr)
pml4 = get_pml4(); pml4 = get_pml4();
pml4->dump(); pml4->dump(4, max_index);
} }
page_block * page_block *
@@ -623,7 +624,7 @@ page_manager::pop_pages(size_t count, addr_t *address)
void void
page_table::dump(int level, uint64_t offset) page_table::dump(int level, int max_index, uint64_t offset)
{ {
console *cons = console::get(); console *cons = console::get();
@@ -650,13 +651,13 @@ page_table::dump(int level, uint64_t offset)
} }
if (--level > 0) { if (--level > 0) {
for (int i=0; i<512; ++i) { for (int i=0; i<=max_index; ++i) {
uint64_t ent = entries[i]; uint64_t ent = entries[i];
if ((ent & 0x1) == 0) continue; if ((ent & 0x1) == 0) continue;
if ((ent & 0x80)) continue; if ((ent & 0x80)) continue;
page_table *next = reinterpret_cast<page_table *>((ent & ~0xffful) + offset); page_table *next = reinterpret_cast<page_table *>((ent & ~0xffful) + offset);
next->dump(level, offset); next->dump(level, 511, offset);
} }
} }
} }

View File

@@ -101,11 +101,13 @@ public:
} }
/// Log the current free/used block lists. /// Log the current free/used block lists.
void dump_blocks(); /// \arg used_only If true, skip printing free list. Default false.
void dump_blocks(bool used_only = false);
/// Dump the given or current PML4 to the console /// Dump the given or current PML4 to the console
/// \arg pml4 The page table to use, null for the current one /// \arg pml4 The page table to use, null for the current one
void dump_pml4(page_table *pml4 = nullptr); /// \arg max_index The max index of pml4 to print
void dump_pml4(page_table *pml4 = nullptr, int max_index = 511);
/// Get the system page manager. /// Get the system page manager.
/// \returns A pointer to the system page manager /// \returns A pointer to the system page manager
@@ -303,7 +305,7 @@ struct page_table
entries[i] = (reinterpret_cast<uint64_t>(p) - pm::page_offset) | (flags & 0xfff); entries[i] = (reinterpret_cast<uint64_t>(p) - pm::page_offset) | (flags & 0xfff);
} }
void dump(int level = 4, uint64_t offset = page_manager::page_offset); void dump(int level = 4, int max_index = 511, uint64_t offset = page_manager::page_offset);
}; };