2018-04-11 17:27:11 +04:00
|
|
|
extern crate cc;
|
|
|
|
|
2018-05-20 19:56:41 +04:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::{Write, Result};
|
|
|
|
|
2018-04-11 17:27:11 +04:00
|
|
|
fn main() {
|
2018-08-04 12:20:25 +04:00
|
|
|
if std::env::var("TARGET").unwrap().find("x86_64").is_some() {
|
2018-09-07 08:44:40 +04:00
|
|
|
// cc::Build::new()
|
|
|
|
// .file("src/arch/x86_64/driver/apic/lapic.c")
|
|
|
|
// .file("src/arch/x86_64/driver/keyboard/keyboard.c")
|
|
|
|
// .flag("-mcmodel=large")
|
|
|
|
// .compile("cobj");
|
2018-07-04 12:23:11 +04:00
|
|
|
gen_vector_asm().unwrap();
|
|
|
|
}
|
2018-10-17 15:37:53 +04:00
|
|
|
if std::env::var("TARGET").unwrap().find("riscv32").is_some() {
|
|
|
|
cc::Build::new()
|
|
|
|
.file("src/arch/riscv32/compiler_rt.c")
|
|
|
|
.flag("-march=rv32ima")
|
|
|
|
.compile("atomic_rt");
|
|
|
|
}
|
2018-05-20 19:56:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn gen_vector_asm() -> Result<()> {
|
2018-08-05 13:50:56 +04:00
|
|
|
let mut f = File::create("src/arch/x86_64/interrupt/vector.asm").unwrap();
|
2018-05-20 19:56:41 +04:00
|
|
|
|
|
|
|
writeln!(f, "# generated by build.rs - do not edit")?;
|
2018-08-05 13:50:56 +04:00
|
|
|
writeln!(f, ".section .text")?;
|
|
|
|
writeln!(f, ".intel_syntax noprefix")?;
|
2018-05-20 19:56:41 +04:00
|
|
|
for i in 0..256 {
|
|
|
|
writeln!(f, "vector{}:", i)?;
|
|
|
|
if !(i == 8 || (i >= 10 && i <= 14) || i == 17) {
|
|
|
|
writeln!(f, "\tpush 0")?;
|
|
|
|
}
|
|
|
|
writeln!(f, "\tpush {}", i)?;
|
|
|
|
writeln!(f, "\tjmp __alltraps")?;
|
|
|
|
}
|
|
|
|
|
2018-08-05 13:50:56 +04:00
|
|
|
writeln!(f, "\n.section .rodata")?;
|
|
|
|
writeln!(f, ".global __vectors")?;
|
2018-05-20 19:56:41 +04:00
|
|
|
writeln!(f, "__vectors:")?;
|
|
|
|
for i in 0..256 {
|
2018-08-05 13:50:56 +04:00
|
|
|
writeln!(f, "\t.quad vector{}", i)?;
|
2018-05-20 19:56:41 +04:00
|
|
|
}
|
|
|
|
Ok(())
|
2018-04-11 17:27:11 +04:00
|
|
|
}
|