Compare commits

..

No commits in common. "ad0f6546d7c94c39037855db9b892110b33cd937" and "74235c2c998d47d78e6e63ccd15feacf874fbc5f" have entirely different histories.

8 changed files with 4 additions and 62 deletions

View File

@ -15,7 +15,6 @@ set(SOURCES
src/thread/Spinlock.cpp
src/thread/Thread.cpp
src/thread/Scheduler.cpp
src/InitRD.cpp
)
if("${ARCH}" MATCHES "x86_64")

View File

@ -1,18 +0,0 @@
#include "InitRD.h"
#include "arch/MMU.h"
#include "boot/bootboot.h"
#include "memory/MemoryManager.h"
#include <luna/Alignment.h>
TarStream g_initrd;
extern const BOOTBOOT bootboot;
void InitRD::initialize()
{
u64 virtual_initrd_address =
MemoryManager::get_kernel_mapping_for_frames(
bootboot.initrd_ptr, get_blocks_from_size(bootboot.initrd_size, ARCH_PAGE_SIZE), MMU::NoExecute)
.expect_value("Unable to map the initial ramdisk into virtual memory");
g_initrd.initialize((void*)virtual_initrd_address, bootboot.initrd_size);
}

View File

@ -1,9 +0,0 @@
#pragma once
#include <luna/TarStream.h>
extern TarStream g_initrd;
namespace InitRD
{
void initialize();
}

View File

@ -1,5 +1,4 @@
#include "boot/Init.h"
#include "InitRD.h"
#include "Log.h"
#include "arch/CPU.h"
#include "boot/bootboot.h"
@ -29,7 +28,6 @@ void Init::early_init()
setup_log(log_debug_enabled(), log_serial_enabled(), true);
MemoryManager::init();
InitRD::initialize();
CPU::platform_init();

View File

@ -1,4 +1,3 @@
#include "InitRD.h"
#include "Log.h"
#include "arch/CPU.h"
#include "arch/MMU.h"
@ -12,6 +11,7 @@
#include "thread/Scheduler.h"
#include <luna/CString.h>
#include <luna/Result.h>
#include <luna/TarStream.h>
#include <luna/Units.h>
extern const BOOTBOOT bootboot;
@ -67,8 +67,9 @@ Result<void> init()
kinfoln("Used memory: %s", to_dynamic_unit(MemoryManager::used()).release_value().chars());
kinfoln("Reserved memory: %s", to_dynamic_unit(MemoryManager::reserved()).release_value().chars());
TarStream stream((void*)bootboot.initrd_ptr, bootboot.initrd_size);
TarStream::Entry entry;
while (TRY(g_initrd.read_next_entry().try_set_value_with_specific_error(entry, 0)))
while (TRY(stream.read_next_entry().try_set_value_with_specific_error(entry, 0)))
{
if (entry.type == TarStream::EntryType::RegularFile)
{
@ -77,7 +78,7 @@ Result<void> init()
if (!strcmp(entry.name, "sys/config"))
{
auto contents = TRY(g_initrd.read_contents_as_string(entry, 0, entry.size));
auto contents = TRY(stream.read_contents_as_string(entry, 0, entry.size));
kinfoln("%s", contents.chars());
}

View File

@ -247,32 +247,6 @@ namespace MemoryManager
return start;
}
Result<u64> get_kernel_mapping_for_frames(u64 phys, usize count, int flags)
{
u64 start = TRY(KernelVM::alloc_several_pages(count));
usize pages_mapped = 0;
auto guard = make_scope_guard([=, &pages_mapped] {
KernelVM::free_several_pages(start, pages_mapped);
unmap_weak(start, pages_mapped);
});
u64 virt = start;
while (pages_mapped < count)
{
TRY(MMU::map(virt, phys, flags));
virt += ARCH_PAGE_SIZE;
phys += ARCH_PAGE_SIZE;
pages_mapped++;
}
guard.deactivate();
return start;
}
Result<void> unmap_owned(u64 virt, usize count)
{
CHECK_PAGE_ALIGNED(virt);

View File

@ -25,8 +25,6 @@ namespace MemoryManager
Result<u64> alloc_at(u64 virt, usize count, int flags);
Result<u64> alloc_for_kernel(usize count, int flags);
Result<u64> get_kernel_mapping_for_frames(u64 phys, usize count, int flags);
Result<void> unmap_owned(u64 virt, usize count);
Result<void> unmap_owned_and_free_vm(u64 virt, usize count);
Result<void> unmap_weak(u64 virt, usize count);

View File

@ -24,7 +24,6 @@ class TarStream
friend class TarStream;
};
TarStream() = default;
TarStream(void* base, usize size);
void initialize(void* base, usize size);