diff --git a/Makefile b/Makefile index 641c3ce..a11cafb 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ grub_cfg := $(boot_src)/grub.cfg assembly_source_files := $(wildcard $(boot_src)/*.asm) assembly_object_files := $(patsubst $(boot_src)/%.asm, \ build/arch/$(arch)/boot/%.o, $(assembly_source_files)) -user_object_files := $(wildcard user/*.o) +user_image_files := $(wildcard user/*.img) +user_object_files := $(patsubst user/%.img, build/user/%.o, $(user_image_files)) qemu_opts := -cdrom $(iso) -smp 4 -serial mon:stdio features := use_apic @@ -95,6 +96,11 @@ build/arch/$(arch)/boot/%.o: $(boot_src)/%.asm @mkdir -p $(shell dirname $@) @nasm -felf64 $< -o $@ +# make .o from .img file +build/user/%.o: user/%.img + @mkdir -p $(shell dirname $@) + @$(ld) -r -b binary $< -o $@ + # used by docker_* targets docker_image ?= blog_os tag ?= 0.1 diff --git a/src/fs.rs b/src/fs.rs index 8081805..92ec3c2 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -3,10 +3,10 @@ use alloc::boxed::Box; use process; extern { - fn _binary_user_sfs_img_start(); - fn _binary_user_sfs_img_end(); - fn _binary_user_forktest_start(); - fn _binary_user_forktest_end(); + fn _binary_user_ucore32_img_start(); + fn _binary_user_ucore32_img_end(); + fn _binary_user_xv6_64_img_start(); + fn _binary_user_xv6_64_img_end(); } struct MemBuf(&'static [u8]); @@ -31,7 +31,7 @@ impl Device for MemBuf { } pub fn load_sfs() { - let slice = unsafe { MemBuf::new(_binary_user_sfs_img_start, _binary_user_sfs_img_end) }; + let slice = unsafe { MemBuf::new(_binary_user_ucore32_img_start, _binary_user_ucore32_img_end) }; let sfs = SimpleFileSystem::open(Box::new(slice)).unwrap(); let root = sfs.root_inode(); let files = root.borrow().list().unwrap(); @@ -45,7 +45,5 @@ pub fn load_sfs() { process::add_user_process(name, unsafe { &BUF[..len] }); } -// process::add_user_process("forktest", unsafe { MemBuf::new(_binary_user_forktest_start, _binary_user_forktest_end).0 }); - process::print(); } \ No newline at end of file diff --git a/user/forktest.o b/user/forktest.o deleted file mode 100755 index 13d05d5..0000000 Binary files a/user/forktest.o and /dev/null differ diff --git a/user/ucore32.img b/user/ucore32.img new file mode 100644 index 0000000..88949ab Binary files /dev/null and b/user/ucore32.img differ diff --git a/user/xv6_64.img b/user/xv6_64.img new file mode 100644 index 0000000..94090c8 Binary files /dev/null and b/user/xv6_64.img differ