Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework kernel.rs #91

Merged
merged 4 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 8 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ readme = "README.md"
edition = "2021"

[dependencies]
goblin = { version = "0.5", default-features = false, features = ["elf64", "elf32", "endian_fd"] }
goblin = { version = "0.5", default-features = false, features = ["elf64"] }
plain = "0.2"
static-alloc = "0.2"

[target.'cfg(target_arch = "x86_64")'.dependencies]
Expand All @@ -17,6 +18,7 @@ x86 = { version = "0.48", default-features = false }

[target.'cfg(target_arch = "aarch64")'.dependencies]
aarch64 = "0.0.7"
align-data = "0.1"

[build-dependencies]
cc = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub use crate::arch::bootinfo::*;
use crate::arch::paging::*;
use crate::arch::serial::SerialPort;
use core::arch::asm;
use goblin::elf;

extern "C" {
static kernel_end: u8;
Expand All @@ -19,7 +18,8 @@ extern "C" {
static mut L0mib_pgtable: u64;
}

pub const ELF_ARCH: u16 = elf::header::EM_AARCH64;
pub const ELF_ARCH: u16 = goblin::elf::header::EM_AARCH64;
pub const R_RELATIVE: u32 = goblin::elf::reloc::R_AARCH64_RELATIVE;

/// start address of the RAM at Qemu's virt emulation
const RAM_START: u64 = 0x40000000;
Expand Down Expand Up @@ -53,7 +53,7 @@ pub unsafe fn get_memory(_memory_size: u64) -> u64 {
}

pub fn find_kernel() -> &'static [u8] {
include_bytes!(env!("HERMIT_APP"))
align_data::include_aligned!(goblin::elf64::header::Header, env!("HERMIT_APP"))
}

pub unsafe fn boot_kernel(
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::arch::x86_64::paging::{BasePageSize, LargePageSize, PageSize, PageTab
use crate::arch::x86_64::serial::SerialPort;
use core::ptr::{copy, write_bytes};
use core::{cmp, mem, slice};
use goblin::elf;
use multiboot::information::{MemoryManagement, Multiboot, PAddr};

extern "C" {
Expand All @@ -17,7 +16,8 @@ extern "C" {
}

// CONSTANTS
pub const ELF_ARCH: u16 = elf::header::EM_X86_64;
pub const ELF_ARCH: u16 = goblin::elf::header::EM_X86_64;
pub const R_RELATIVE: u32 = goblin::elf::reloc::R_X86_64_RELATIVE;

const KERNEL_STACK_SIZE: u64 = 32_768;
const SERIAL_PORT_ADDRESS: u16 = 0x3F8;
Expand Down
Loading