merged kfs-1 changes
This commit is contained in:
commit
13005548ee
2 changed files with 29 additions and 28 deletions
|
|
@ -14,6 +14,9 @@ mod vga;
|
||||||
mod context;
|
mod context;
|
||||||
mod keyboard;
|
mod keyboard;
|
||||||
|
|
||||||
|
use context::CONTEXT;
|
||||||
|
use vga::{Color, ColorCode};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod cpuio;
|
mod cpuio;
|
||||||
|
|
||||||
|
|
@ -52,21 +55,24 @@ fn shutdown() -> ! {
|
||||||
}
|
}
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn kmain() -> ! {
|
pub extern fn kmain() -> ! {
|
||||||
println!(r#" ,--, "#);
|
unsafe { CONTEXT.current_term().color_code = ColorCode::new(Color::White, Color::Cyan); }
|
||||||
println!(r#" ,--.'| ,----, "#);
|
print!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
|
||||||
println!(r#" ,--, | : .' .' \ "#);
|
format_args!("{: ^80}", r#" ,--, "#),
|
||||||
println!(r#",---.'| : ' ,----,' | "#);
|
format_args!("{: ^80}", r#" ,--.'| ,----, "#),
|
||||||
println!(r#"; : | | ; | : . ; "#);
|
format_args!("{: ^80}", r#" ,--, | : .' .' \ "#),
|
||||||
println!(r#"| | : _' | ; |.' / "#);
|
format_args!("{: ^80}", r#",---.'| : ' ,----,' | "#),
|
||||||
println!(r#": : |.' | `----'/ ; "#);
|
format_args!("{: ^80}", r#"; : | | ; | : . ; "#),
|
||||||
println!(r#"| ' ' ; : / ; / "#);
|
format_args!("{: ^80}", r#"| | : _' | ; |.' / "#),
|
||||||
println!(r#"\ \ .'. | ; / /-, "#);
|
format_args!("{: ^80}", r#": : |.' | `----'/ ; "#),
|
||||||
println!(r#" `---`: | ' / / /.`| "#);
|
format_args!("{: ^80}", r#"| ' ' ; : / ; / "#),
|
||||||
println!(r#" ' ; |./__; : "#);
|
format_args!("{: ^80}", r#"\ \ .'. | ; / /-, "#),
|
||||||
println!(r#" | : ;| : .' "#);
|
format_args!("{: ^80}", r#" `---`: | ' / / /.`| "#),
|
||||||
println!(r#" ' ,/ ; | .' "#);
|
format_args!("{: ^80}", r#" ' ; |./__; : "#),
|
||||||
println!(r#" '--' `---' "#);
|
format_args!("{: ^80}", r#" | : ;| : .' "#),
|
||||||
println!(">> Kernel startup...");
|
format_args!("{: ^80}", r#" ' ,/ ; | .' "#),
|
||||||
|
format_args!("{: ^80}", r#" '--' `---' "#));
|
||||||
|
unsafe { CONTEXT.current_term().color_code = ColorCode::new(Color::White, Color::Black); }
|
||||||
|
print!(">");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
keyboard::kbd_callback();
|
keyboard::kbd_callback();
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
use super::{Color, ColorCode};
|
use super::{Color, ColorCode};
|
||||||
use ::context::CONTEXT;
|
use ::context::CONTEXT;
|
||||||
|
use cpuio;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
@ -31,21 +32,17 @@ macro_rules! println {
|
||||||
pub fn print(args: fmt::Arguments) {
|
pub fn print(args: fmt::Arguments) {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
unsafe { CONTEXT.current_term().write_fmt(args).unwrap() };
|
unsafe { CONTEXT.current_term().write_fmt(args).unwrap() };
|
||||||
|
unsafe { CONTEXT.current_term().flush() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
// pub const unsafe fn vga_slice() -> &'static [u8] {
|
|
||||||
// unsafe { core::slice::from_raw_parts_mut(0xb8000 as *mut u8, 4000) }
|
|
||||||
// }
|
|
||||||
|
|
||||||
const BUFFER_ROWS: usize = 25;
|
const BUFFER_ROWS: usize = 25;
|
||||||
const BUFFER_COLS: usize = 80 * 2;
|
const BUFFER_COLS: usize = 80 * 2;
|
||||||
|
|
||||||
pub struct Writer {
|
pub struct Writer {
|
||||||
pub position: usize,
|
pub position: usize,
|
||||||
color_code: ColorCode,
|
pub color_code: ColorCode,
|
||||||
buffer: [u8; BUFFER_ROWS * BUFFER_COLS],
|
buffer: [u8; BUFFER_ROWS * BUFFER_COLS],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,8 +66,6 @@ impl Writer {
|
||||||
match byte {
|
match byte {
|
||||||
|
|
||||||
b'\n' => {
|
b'\n' => {
|
||||||
//reset cursor
|
|
||||||
self.buffer[self.position + 1] = ColorCode::new(Color::White, Color::Black).0;
|
|
||||||
let current_line = self.position / (BUFFER_COLS);
|
let current_line = self.position / (BUFFER_COLS);
|
||||||
self.position = (current_line + 1) * BUFFER_COLS;
|
self.position = (current_line + 1) * BUFFER_COLS;
|
||||||
}
|
}
|
||||||
|
|
@ -85,10 +80,11 @@ impl Writer {
|
||||||
self.scroll();
|
self.scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// cursor
|
let cursor_position = self.position / 2;
|
||||||
self.buffer[self.position] = b' ';
|
cpuio::outb(14, 0x3D4);
|
||||||
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
|
cpuio::outb((cursor_position >> 8) as u8, 0x3D5);
|
||||||
|
cpuio::outb(15, 0x3D4);
|
||||||
|
cpuio::outb((cursor_position >> 0) as u8 & 0x00ff, 0x3D5);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush(&mut self) {
|
pub fn flush(&mut self) {
|
||||||
|
|
@ -120,7 +116,6 @@ impl fmt::Write for Writer {
|
||||||
for byte in s.bytes() {
|
for byte in s.bytes() {
|
||||||
self.write_byte(byte)
|
self.write_byte(byte)
|
||||||
}
|
}
|
||||||
self.flush();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue