mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Reset code to post-03 branch
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -1,13 +1,5 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
|
||||||
name = "array-init"
|
|
||||||
version = "0.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "array-init"
|
name = "array-init"
|
||||||
version = "0.0.4"
|
version = "0.0.4"
|
||||||
@@ -30,7 +22,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
name = "blog_os"
|
name = "blog_os"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"array-init 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"bootloader 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bootloader 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -247,7 +238,6 @@ version = "0.1.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
"checksum array-init 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c3cc8456d0ae81a8c76f59e384683a601548c38949a4bfcb65dd31ded5c75ff3"
|
|
||||||
"checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72"
|
"checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72"
|
||||||
"checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
|
"checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
|
||||||
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ spin = "0.4.9"
|
|||||||
version = "1.0"
|
version = "1.0"
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
array-init = "0.0.3"
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ steps:
|
|||||||
- script: bootimage build
|
- script: bootimage build
|
||||||
displayName: 'Build'
|
displayName: 'Build'
|
||||||
|
|
||||||
- script: cargo test
|
|
||||||
displayName: 'Unit Tests'
|
|
||||||
|
|
||||||
- script: rustup component add rustfmt
|
- script: rustup component add rustfmt
|
||||||
displayName: 'Install Rustfmt'
|
displayName: 'Install Rustfmt'
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
#![cfg_attr(not(test), no_std)]
|
#![no_std]
|
||||||
#![cfg_attr(not(test), no_main)]
|
#![no_main]
|
||||||
#![cfg_attr(test, allow(unused_imports))]
|
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
mod vga_buffer;
|
mod vga_buffer;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
@@ -15,7 +13,6 @@ pub extern "C" fn _start() -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This function is called on panic.
|
/// This function is called on panic.
|
||||||
#[cfg(not(test))]
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
println!("{}", info);
|
println!("{}", info);
|
||||||
|
|||||||
@@ -169,86 +169,3 @@ pub fn _print(args: fmt::Arguments) {
|
|||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
WRITER.lock().write_fmt(args).unwrap();
|
WRITER.lock().write_fmt(args).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
fn construct_writer() -> Writer {
|
|
||||||
use std::boxed::Box;
|
|
||||||
|
|
||||||
let buffer = construct_buffer();
|
|
||||||
Writer {
|
|
||||||
column_position: 0,
|
|
||||||
color_code: ColorCode::new(Color::Blue, Color::Magenta),
|
|
||||||
buffer: Box::leak(Box::new(buffer)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn construct_buffer() -> Buffer {
|
|
||||||
use array_init::array_init;
|
|
||||||
|
|
||||||
Buffer {
|
|
||||||
chars: array_init(|_| array_init(|_| Volatile::new(empty_char()))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn empty_char() -> ScreenChar {
|
|
||||||
ScreenChar {
|
|
||||||
ascii_character: b' ',
|
|
||||||
color_code: ColorCode::new(Color::Green, Color::Brown),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn write_byte() {
|
|
||||||
let mut writer = construct_writer();
|
|
||||||
writer.write_byte(b'X');
|
|
||||||
writer.write_byte(b'Y');
|
|
||||||
|
|
||||||
for (i, row) in writer.buffer.chars.iter().enumerate() {
|
|
||||||
for (j, screen_char) in row.iter().enumerate() {
|
|
||||||
let screen_char = screen_char.read();
|
|
||||||
if i == BUFFER_HEIGHT - 1 && j == 0 {
|
|
||||||
assert_eq!(screen_char.ascii_character, b'X');
|
|
||||||
assert_eq!(screen_char.color_code, writer.color_code);
|
|
||||||
} else if i == BUFFER_HEIGHT - 1 && j == 1 {
|
|
||||||
assert_eq!(screen_char.ascii_character, b'Y');
|
|
||||||
assert_eq!(screen_char.color_code, writer.color_code);
|
|
||||||
} else {
|
|
||||||
assert_eq!(screen_char, empty_char());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn write_formatted() {
|
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
let mut writer = construct_writer();
|
|
||||||
writeln!(&mut writer, "a").unwrap();
|
|
||||||
writeln!(&mut writer, "b{}", "c").unwrap();
|
|
||||||
|
|
||||||
for (i, row) in writer.buffer.chars.iter().enumerate() {
|
|
||||||
for (j, screen_char) in row.iter().enumerate() {
|
|
||||||
let screen_char = screen_char.read();
|
|
||||||
if i == BUFFER_HEIGHT - 3 && j == 0 {
|
|
||||||
assert_eq!(screen_char.ascii_character, b'a');
|
|
||||||
assert_eq!(screen_char.color_code, writer.color_code);
|
|
||||||
} else if i == BUFFER_HEIGHT - 2 && j == 0 {
|
|
||||||
assert_eq!(screen_char.ascii_character, b'b');
|
|
||||||
assert_eq!(screen_char.color_code, writer.color_code);
|
|
||||||
} else if i == BUFFER_HEIGHT - 2 && j == 1 {
|
|
||||||
assert_eq!(screen_char.ascii_character, b'c');
|
|
||||||
assert_eq!(screen_char.color_code, writer.color_code);
|
|
||||||
} else if i >= BUFFER_HEIGHT - 2 {
|
|
||||||
assert_eq!(screen_char.ascii_character, b' ');
|
|
||||||
assert_eq!(screen_char.color_code, writer.color_code);
|
|
||||||
} else {
|
|
||||||
assert_eq!(screen_char, empty_char());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user