Compare commits
No commits in common. "e028f9ba631d5ee8e2e84fa5b2a5c994e1579d71" and "bfa71d5836ae27ef12658f2709fba8c971de20e8" have entirely different histories.
e028f9ba63
...
bfa71d5836
3 changed files with 6 additions and 70 deletions
|
|
@ -19,7 +19,7 @@ $(object_files): $(object_dir)%.o : $(source_dir)%
|
|||
kernel.bin: $(object_files)
|
||||
@mkdir -p $(output_dir)
|
||||
@echo "Linking kernel"
|
||||
@$(LD) --build-id=none --no-relax --no-warn-rwx-segments --orphan-handling=error -nostdlib -o $(output_dir)/kernel.bin -T $(linker_script) $(object_files)
|
||||
@$(LD) --build-id=none --no-relax --no-warn-rwx-segments -nostdlib -o $(output_dir)/kernel.bin -T $(linker_script) $(object_files)
|
||||
@echo "Disassembling kernel"
|
||||
@objdump -dC $(output_dir)/kernel.bin > $(output_dir)/kernel.asm
|
||||
@objdump -DC $(output_dir)/kernel.bin > $(output_dir)/kernel_full.asm
|
||||
|
|
|
|||
|
|
@ -33,14 +33,12 @@ SECTIONS
|
|||
} > START_MEMORY_PV
|
||||
.text : AT(ADDR(.text) - high_base) {
|
||||
__text_start__ = .;
|
||||
*(EXCLUDE_FILE(*trampoline*) .text .text.*)
|
||||
*(EXCLUDE_FILE(*trampoline*) .iplt)
|
||||
*(EXCLUDE_FILE(*trampoline*) .text)
|
||||
__text_end__ = .;
|
||||
} > HIGH_KERNEL_V
|
||||
.rodata : AT(ADDR(.rodata) - high_base) {
|
||||
__rodata_start__ = .;
|
||||
*(EXCLUDE_FILE(*trampoline*) .rodata .rodata.*)
|
||||
. = ALIGN(8);
|
||||
*(EXCLUDE_FILE(*trampoline*) .rodata)
|
||||
__reserved_ranges_start__ = .;
|
||||
KEEP(*(.reserved_ranges))
|
||||
__reserved_ranges_end__ = .;
|
||||
|
|
@ -52,13 +50,12 @@ SECTIONS
|
|||
} > HIGH_KERNEL_V
|
||||
.data : AT(ADDR(.data) - high_base) {
|
||||
__data_start__ = .;
|
||||
*(EXCLUDE_FILE(*trampoline*) .data .data.*)
|
||||
*(EXCLUDE_FILE(*trampoline*) .got .got.plt .igot.plt .data.rel.ro .data.rel.ro.*)
|
||||
*(EXCLUDE_FILE(*trampoline*) .data)
|
||||
__data_end__ = .;
|
||||
} > HIGH_KERNEL_V
|
||||
.bss (NOLOAD) : AT(ADDR(.bss) - high_base) {
|
||||
__bss_start__ = .;
|
||||
*(EXCLUDE_FILE(*trampoline*) .bss .bss.*)
|
||||
*(EXCLUDE_FILE(*trampoline*) .bss)
|
||||
__bss_end__ = .;
|
||||
} > HIGH_KERNEL_V
|
||||
|
||||
|
|
@ -86,33 +83,11 @@ SECTIONS
|
|||
__trampoline_bss_end__ = .;
|
||||
} > TRAMPOLINE_PV
|
||||
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_line_str 0 : { *(.debug_line_str) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_loclists 0 : { *(.debug_loclists) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.debug_rnglists 0 : { *(.debug_rnglists) }
|
||||
.debug_addr 0 : { *(.debug_addr) }
|
||||
.debug_str_offsets 0 : { *(.debug_str_offsets) }
|
||||
.debug_names 0 : { *(.debug_names) }
|
||||
.debug_types 0 : { *(.debug_types) }
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
*(.eh_frame)
|
||||
*(.note)
|
||||
*(.note.gnu.build-id)
|
||||
*(.note.GNU-stack)
|
||||
*(.rela*)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,33 +34,6 @@ static void step(const char* name, T&& fn) {
|
|||
print("\n");
|
||||
}
|
||||
|
||||
template<typename Fn>
|
||||
static void for_each_boot_reserved_range(Fn&& fn) {
|
||||
fn(paddr_t{0}, page_size);
|
||||
|
||||
const multiboot::info* mb = multiboot::get_multiboot_info();
|
||||
uint64_t info_phys = reinterpret_cast<uint64_t>(mb) - high_base;
|
||||
fn(paddr_t{info_phys}, mb->total_size);
|
||||
|
||||
multiboot::visit_all(mb, [&](const multiboot::tag_module* module) {
|
||||
fn(paddr_t{module->mod_start}, module->mod_end - module->mod_start);
|
||||
});
|
||||
}
|
||||
|
||||
static bool is_in_boot_reserved_range(paddr_t ptr, size_t size) {
|
||||
bool res = false;
|
||||
for_each_boot_reserved_range([&](paddr_t start, size_t length) {
|
||||
if(length == 0) {
|
||||
return;
|
||||
}
|
||||
if(ptr.address < start.address + length &&
|
||||
start.address < ptr.address + size) {
|
||||
res = true;
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
optional<paddr_t> findInitialMemoryPages(const multiboot::tag_mmap* multiboot_info, size_t count) {
|
||||
const auto* base = reinterpret_cast<const uint8_t*>(multiboot_info->entries);
|
||||
const auto* end = reinterpret_cast<const uint8_t*>(multiboot_info) + multiboot_info->size;
|
||||
|
|
@ -76,8 +49,7 @@ optional<paddr_t> findInitialMemoryPages(const multiboot::tag_mmap* multiboot_in
|
|||
continue;
|
||||
}
|
||||
for(auto ptr = start_ptr; ptr < (end_ptr - page_size * (count - 1)); ptr += page_size) {
|
||||
if(!is_in_reserved_section(paddr_t{ptr}, page_size) &&
|
||||
!is_in_boot_reserved_range(paddr_t{ptr}, page_size)) {
|
||||
if(!is_in_reserved_section(paddr_t{ptr}, page_size)) {
|
||||
return paddr_t{ptr};
|
||||
}
|
||||
}
|
||||
|
|
@ -126,17 +98,6 @@ void PhysicalAllocator::init(const multiboot::tag_mmap* multiboot_info) {
|
|||
});
|
||||
});
|
||||
|
||||
step("boot_reserved", [&]() {
|
||||
for_each_boot_reserved_range([&](paddr_t start, size_t length){
|
||||
if(length == 0) {
|
||||
return;
|
||||
}
|
||||
auto start_ptr = start.address & ~(page_size - 1);
|
||||
auto end_ptr = (start.address + length + page_size - 1) & ~(page_size - 1);
|
||||
alloc.force({paddr_t{start_ptr}, (end_ptr - start_ptr) / page_size}, false);
|
||||
});
|
||||
});
|
||||
|
||||
alloc.force({page, 1}, false);
|
||||
|
||||
PhysicalAllocator::getInstance() = alloc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue