Created
December 17, 2017 12:57
-
-
Save raw-bin/95fda9a0ed9ed673e3cb66a4583f4eec to your computer and use it in GitHub Desktop.
Build glue for pre-kstart early init asm code - is this a viable way to do it ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Cargo.toml b/Cargo.toml | |
index 45a5681..7a57d03 100644 | |
--- a/Cargo.toml | |
+++ b/Cargo.toml | |
@@ -1,6 +1,7 @@ | |
[package] | |
name = "kernel" | |
version = "0.1.32" | |
+links = "early_init" | |
build = "build.rs" | |
[lib] | |
@@ -14,6 +15,10 @@ bitflags = "1" | |
spin = "0.4" | |
redox_syscall = { path = "syscall" } | |
+[build-dependencies] | |
+cc = "1.0.3" | |
+rustc-cfg = "0.3.0" | |
+ | |
[target.'cfg(target_arch = "x86_64")'.dependencies] | |
raw-cpuid = "3.0" | |
x86 = "0.7" | |
diff --git a/build.rs b/build.rs | |
index 4efa33e..acd48d5 100644 | |
--- a/build.rs | |
+++ b/build.rs | |
@@ -3,7 +3,10 @@ use std::fs; | |
use std::io::{Error, Write}; | |
use std::path::Path; | |
use std::collections::HashMap; | |
+use rustc_cfg::Cfg; | |
+extern crate cc; | |
+extern crate rustc_cfg; | |
// View loc folder with subfolders, get listings | |
// Returns touple (folder_map, file_list) | |
@@ -117,4 +120,12 @@ mod gen { | |
} | |
} | |
").unwrap(); | |
+ | |
+ // Build pre kstart init asm code | |
+ let cfg = Cfg::new(env::var_os("TARGET").unwrap()).unwrap(); | |
+ if cfg.target_arch == "aarch64" { | |
+ cc::Build::new() | |
+ .file("src/arch/arm64/early_init.S") | |
+ .compile("early_init"); | |
+ } | |
} | |
diff --git a/linkers/aarch64.ld b/linkers/aarch64.ld | |
index eb9d7af..d1cdbee 100644 | |
--- a/linkers/aarch64.ld | |
+++ b/linkers/aarch64.ld | |
@@ -1,4 +1,4 @@ | |
-ENTRY(kstart) | |
+ENTRY(early_init) | |
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64") | |
KERNEL_OFFSET = 0xffffff0000100000; | |
diff --git a/src/arch/arm64/early_init.S b/src/arch/arm64/early_init.S | |
new file mode 100644 | |
index 0000000..b3b2d06 | |
--- /dev/null | |
+++ b/src/arch/arm64/early_init.S | |
@@ -0,0 +1,5 @@ | |
+ .text | |
+ .globl early_init | |
+early_init: | |
+ b kstart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment