You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
extern crate cc;
|
|
|
|
use std::fs::File;
|
|
use std::io::{Write, Result};
|
|
|
|
fn main() {
|
|
if std::env::var("TARGET").unwrap().find("x86_64").is_some() {
|
|
// 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");
|
|
gen_vector_asm().unwrap();
|
|
}
|
|
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");
|
|
}
|
|
}
|
|
|
|
fn gen_vector_asm() -> Result<()> {
|
|
let mut f = File::create("src/arch/x86_64/interrupt/vector.asm").unwrap();
|
|
|
|
writeln!(f, "# generated by build.rs - do not edit")?;
|
|
writeln!(f, ".section .text")?;
|
|
writeln!(f, ".intel_syntax noprefix")?;
|
|
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")?;
|
|
}
|
|
|
|
writeln!(f, "\n.section .rodata")?;
|
|
writeln!(f, ".global __vectors")?;
|
|
writeln!(f, "__vectors:")?;
|
|
for i in 0..256 {
|
|
writeln!(f, "\t.quad vector{}", i)?;
|
|
}
|
|
Ok(())
|
|
} |