refactor + wip bios call from protected mode
This commit is contained in:
1 parent
121e13165b
commit
766a9c981c
8 files changed
+389
-136
No files matched your search
+55
-9
@@ -5,9 +5,9 @@ fn main() {
|
||||
.expect("OUT_DIR not set");
|
||||
let out_dir = PathBuf::from(out_dir);
|
||||
|
||||
let path = SearchPath::load();
|
||||
let search_path = SearchPath::load();
|
||||
|
||||
let nasm_path = path.search("nasm")
|
||||
let nasm_path = search_path.search("nasm")
|
||||
.next()
|
||||
.expect("failed to find nasm in PATH");
|
||||
let nasm = Nasm::new(nasm_path);
|
||||
@@ -38,13 +38,42 @@ fn link_obj(path: &Path) {
|
||||
}
|
||||
|
||||
fn build_asm(nasm: &Nasm, out_dir: &Path) {
|
||||
let prelude_obj_path = out_dir.join("prelude.o");
|
||||
nasm.assemble(
|
||||
&prelude_obj_path,
|
||||
&["asm/prelude.s".as_ref()],
|
||||
&["../include".as_ref()],
|
||||
).unwrap();
|
||||
link_obj(&prelude_obj_path);
|
||||
let asm_srcs = fs::read_dir("asm")
|
||||
.expect("failed to get asm sources");
|
||||
|
||||
for asm_src in asm_srcs {
|
||||
let asm_src = asm_src.expect("failed to get asm source");
|
||||
|
||||
let ty = asm_src.file_type().expect("failed to get file type");
|
||||
if !ty.is_file() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let src_path = asm_src.path();
|
||||
|
||||
let is_asm = src_path
|
||||
.extension()
|
||||
.map(|ext| ext == "s")
|
||||
.unwrap_or(false);
|
||||
if !is_asm {
|
||||
continue;
|
||||
}
|
||||
|
||||
let out_filename = src_path
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.apply(PathBuf::from)
|
||||
.with_extension("o");
|
||||
let out_path = out_dir.join(out_filename);
|
||||
|
||||
nasm.assemble(
|
||||
&out_path,
|
||||
&[&src_path],
|
||||
&["../include".as_ref()]
|
||||
).expect("failed to assemble");
|
||||
|
||||
link_obj(&out_path);
|
||||
}
|
||||
}
|
||||
|
||||
struct Nasm {
|
||||
@@ -165,3 +194,20 @@ enum CmdErrorKind {
|
||||
Status(process::Output),
|
||||
}
|
||||
|
||||
trait Apply: Sized {
|
||||
fn apply<T, F>(self, f: F) -> T
|
||||
where
|
||||
F: FnOnce(Self) -> T;
|
||||
}
|
||||
|
||||
impl<U> Apply for U
|
||||
where
|
||||
U: Sized,
|
||||
{
|
||||
fn apply<T, F>(self, f: F) -> T
|
||||
where
|
||||
F: FnOnce(Self) -> T
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user