summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/Cargo.toml9
-rwxr-xr-xkernel/build.sh8
-rw-r--r--kernel/src/boot.asm6
-rw-r--r--kernel/src/lib.rs9
-rw-r--r--kernel/src/long_mode_init.asm4
-rw-r--r--kernel/src/vga_text.rs7
6 files changed, 30 insertions, 13 deletions
diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml
index 9dd89c3..2b883f4 100644
--- a/kernel/Cargo.toml
+++ b/kernel/Cargo.toml
@@ -8,5 +8,10 @@ edition = "2018"
[lib]
crate-type = ["staticlib"]
-[dependencies]
-compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins" }
+[package.metadata.cargo-xbuild]
+sysroot_path = "target/sysroot"
+
+[dependencies.compiler_builtins]
+version = "0.1.19"
+git = "https://github.com/rust-lang/compiler-builtins"
+features = ["mem"]
diff --git a/kernel/build.sh b/kernel/build.sh
index 8fa91ce..a162d57 100755
--- a/kernel/build.sh
+++ b/kernel/build.sh
@@ -68,6 +68,12 @@ build_clean() {
remove_target
}
+build_build() {
+ build_clean
+ cargo xbuild
+ build_run
+}
+
build_all() {
build_kernel_elf
}
@@ -82,6 +88,7 @@ for arg in "$@"; do
"launch") build_launch;;
"run") build_run;;
"clean") build_clean;;
+ "build") build_build;;
"all") build_all;;
*)
echo "warn: ignoring unknown option '$arg'"
@@ -101,6 +108,7 @@ print_help() {
echo
echo " kernel-elf build the kernel-elf"
echo " kernel-iso build the kernel-elf if necessary and the kernel-iso"
+ echo " build build the kernel-iso with rust binaries"
echo " all build kernel"
}
diff --git a/kernel/src/boot.asm b/kernel/src/boot.asm
index e3484c1..451e455 100644
--- a/kernel/src/boot.asm
+++ b/kernel/src/boot.asm
@@ -22,7 +22,7 @@ check_multiboot:
cmp eax, 0x36d76289
jne .no_multiboot
ret
-.no_multiboot
+.no_multiboot:
mov al, "0"
jmp error
@@ -75,7 +75,7 @@ check_long_mode:
jz .no_long_mode
ret
-.no_long_mode
+.no_long_mode:
mov al, "2"
jmp error
@@ -160,5 +160,5 @@ p3_table:
p2_table:
resb 4096
stack_bottom:
- resb 64
+ resb 4096
stack_top:
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
index a27f0a7..48cb93d 100644
--- a/kernel/src/lib.rs
+++ b/kernel/src/lib.rs
@@ -1,6 +1,6 @@
+#![no_main]
#![feature(compiler_builtins_lib)]
#![no_std]
-#![no_main]
extern crate compiler_builtins;
@@ -11,11 +11,16 @@ use core::fmt::Write;
#[no_mangle]
pub extern "C" fn _start() -> ! {
-
let mut stdout = vga_text::OStream::new();
stdout.clear();
+
write!(&mut stdout, "hello world!");
+ core::iter::successors(Some(0), |n| Some(n + 1))
+ .for_each(|n|
+ write!(&mut stdout, "hello world {}!", n).unwrap()
+ );
+
loop {}
}
diff --git a/kernel/src/long_mode_init.asm b/kernel/src/long_mode_init.asm
index 751af9b..8c1b1e7 100644
--- a/kernel/src/long_mode_init.asm
+++ b/kernel/src/long_mode_init.asm
@@ -16,6 +16,4 @@ long_mode_start:
mov qword [0xb8000], rax
extern _start
- call _start
-
- hlt
+ jmp _start
diff --git a/kernel/src/vga_text.rs b/kernel/src/vga_text.rs
index ef488e9..5298da7 100644
--- a/kernel/src/vga_text.rs
+++ b/kernel/src/vga_text.rs
@@ -35,10 +35,11 @@ impl CharState {
}
}
+#[no_mangle]
#[derive(Clone, Copy)]
pub struct VgaChar {
+ pub byte: u8,
pub state: CharState,
- pub byte: u8
}
impl VgaChar {
@@ -57,7 +58,7 @@ impl OStream {
pub fn new() -> Self {
Self {
pos: (0, 0),
- cursor: 0xb8000 as *mut VgaChar,
+ cursor: Self::at(0),
state: CharState::from_colors(Color::White, Color::Black)
}
}
@@ -85,7 +86,7 @@ impl OStream {
self.compute_cursor()
}
- fn set_char(&mut self, c: VgaChar) {
+ pub fn set_char(&mut self, c: VgaChar) {
unsafe {self.cursor.write_volatile(c)}
}