aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Cargo.toml17
-rw-r--r--Makefile9
-rw-r--r--isofiles/boot/grub/grub.cfg2
-rwxr-xr-xkernelbin26344 -> 0 bytes
-rw-r--r--src/lib.rs23
-rw-r--r--src/machine/cgascr.rs41
-rw-r--r--x86_64-rustubs.json (renamed from x86_64_rustubs.json)0
8 files changed, 58 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore
index 66cb0a5..5d2957f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,4 @@ Cargo.lock
*.iso
*.o
/isofiles/boot/kernel
-
+kernel
diff --git a/Cargo.toml b/Cargo.toml
index 6eef6ef..5f91e89 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,9 +7,24 @@ edition = "2021"
[dependencies]
+
+[build]
+target = "x86_64-rustubs"
+
+[lib]
+crate-type = ["staticlib"]
+
[profile.dev]
panic = "abort"
+debug = 1
+lto = true
[profile.release]
panic = "abort"
-
+#opt-level = 0
+opt-level = 3
+debug = 0
+overflow-checks = false
+lto = true
+codegen-units = 1
+debug-assertions = false
diff --git a/Makefile b/Makefile
index 7a10efb..1302d9b 100644
--- a/Makefile
+++ b/Makefile
@@ -10,10 +10,15 @@ bootdisk.iso : kernel
grub-mkrescue /usr/lib/grub/i386-pc -o bootdisk.iso isofiles
kernel : rust_kernel startup.o
- ld -static -e startup -T sections -o ./kernel startup.o target/x86_64_rustubs/debug/librustubs.rlib
+ # ar -rcs ./target/x86_64_rustubs/debug/librustubs.a ./target/x86_64-rustubs/debug/librustubs.rlib
+ # ld -n --gc-sections -T sections -o kernel startup.o target/x86_64-rustubs/debug/librustubs.a
+ ld -static -e startup -T sections -o ./kernel startup.o target/x86_64-rustubs/debug/librustubs.a
rust_kernel:
- cargo rustc --target=x86_64_rustubs.json -- -C link-arg=-nostartfiles --emit=obj
+ # cargo rustc --target=x86_64-rustubs.json -- -C link-arg=-nostartfiles --emit=obj
+ # cargo rustc --target=x86_64-rustubs.json -- -C link-arg=-nostartfiles --crate-type=staticlib
+ # xargo build --target=x86_64-rustubs
+ cargo xbuild --target x86_64-rustubs.json
startup.o:
nasm -f elf64 -o startup.o src/arch/x86_64/asm/startup.s
diff --git a/isofiles/boot/grub/grub.cfg b/isofiles/boot/grub/grub.cfg
index 2fc735b..9c8c0fa 100644
--- a/isofiles/boot/grub/grub.cfg
+++ b/isofiles/boot/grub/grub.cfg
@@ -1,7 +1,7 @@
set timeout=0
set default=0
-menuentry "OOStuBS" {
+menuentry "RuStuBS" {
insmod all_video
multiboot /boot/kernel
boot
diff --git a/kernel b/kernel
deleted file mode 100755
index 889f35c..0000000
--- a/kernel
+++ /dev/null
Binary files differ
diff --git a/src/lib.rs b/src/lib.rs
index 767e547..c10460c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,23 +1,18 @@
#![no_std]
#![no_main]
mod arch;
-// use core::panic::PanicInfo;
+mod machine;
+use core::panic::PanicInfo;
+use machine::cgascr::CGAScreen;
-static HELLO: &[u8] = b"Hello World!";
-
-// #[panic_handler]
-// fn panic(_info: &PanicInfo) -> ! {
-//
-// loop {}
-// }
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+ loop {}
+}
#[no_mangle]
pub extern "C" fn _entry() -> ! {
- let vga_buffer = 0xb8000 as *mut u8;
-
- unsafe {
- *vga_buffer.offset(10 as isize * 2) = 'X' as u8;
- *vga_buffer.offset(10 as isize * 2 + 1) = 0xb;
- }
+ let scr = CGAScreen::new(80,25);
+ scr.test();
loop {}
}
diff --git a/src/machine/cgascr.rs b/src/machine/cgascr.rs
index a43e073..f67501c 100644
--- a/src/machine/cgascr.rs
+++ b/src/machine/cgascr.rs
@@ -1,9 +1,9 @@
-const CGA_START:u32 = 0xb8000;
+const vga_buffer:*mut u8 = 0xb8000 as *mut u8;
#[allow(dead_code)]
pub struct CGAScreen{
- max_cows:u32,
- max_rows:u32,
+ pub max_cows:u32,
+ pub max_rows:u32,
}
#[allow(dead_code)]
@@ -12,24 +12,31 @@ impl CGAScreen{
Self {max_cows: cows, max_rows:rows,}
}
- pub fn set_pos(x:u32, y:u32){
-
- }
-
- pub fn get_pos(x:&mut u32, y:&mut u32){
- // TODO
- *x = 1;
- *y = 1;
- }
-
- pub fn putchar(c:char, attr:u8){
-
- }
// this function should be the only one that "directly touches"
// the memory by address.
// and since it's unsafe, it shouldn't be public
- fn show(&self, x:u32, y:u32, c:char, attr:u8){
+ //
+ // fn show(&self, x:u32, y:u32, c:char, attr:u8){
+ //
+ // }
+ pub fn test(&self){
+ let mut r = 0;
+ let mut c = 0;
+
+ while r<self.max_rows {
+ while c<self.max_cows {
+ let index:u32 = r*self.max_cows + c;
+ unsafe {
+ *vga_buffer.offset(index as isize * 2) = index as u8;
+ *vga_buffer.offset(index as isize * 2 + 1) = index as u8;
+ }
+ c+=1;
+ }
+ r+=1;
+ c=0;
+ }
+
}
diff --git a/x86_64_rustubs.json b/x86_64-rustubs.json
index 2e90078..2e90078 100644
--- a/x86_64_rustubs.json
+++ b/x86_64-rustubs.json