Merge branch 'master' of https://github.com/jzck/kernel
This commit is contained in:
commit
b730734cef
4 changed files with 40 additions and 45 deletions
1
kernel-rs/.gitignore
vendored
1
kernel-rs/.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
target
|
||||
build
|
||||
Cargo.lock
|
||||
|
|
|
|||
|
|
@ -92,16 +92,11 @@ pub fn kbd_callback() {
|
|||
Some(b"\0\0") => {
|
||||
match scancode {
|
||||
0x2A | 0x36 => {SHIFT = !is_release},
|
||||
0x38 => {ALT = !is_release},
|
||||
0x1D => {CTRL = !is_release},
|
||||
0x0F => {
|
||||
CONTEXT.current_term().keypress('T' as u8);
|
||||
0x38 => {ALT = !is_release; println!("atl")},
|
||||
0x1D => {CTRL = !is_release; println!("ctrl")},
|
||||
0x0F if !is_release => {
|
||||
CONTEXT.switch_term();
|
||||
CONTEXT.current_term().keypress('T' as u8);
|
||||
CONTEXT.current_term().flush();
|
||||
CONTEXT.current_term().keypress('T' as u8);
|
||||
CONTEXT.current_term().keypress('T' as u8);
|
||||
CONTEXT.current_term().keypress('T' as u8);
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -110,11 +105,11 @@ pub fn kbd_callback() {
|
|||
// CONTEXT.switch_term();
|
||||
// CONTEXT.current_term().flush();
|
||||
// },
|
||||
Some(b"1!") if CTRL => {
|
||||
CONTEXT.switch_term();
|
||||
CONTEXT.current_term().keypress('>' as u8);
|
||||
CONTEXT.current_term().flush();
|
||||
},
|
||||
// Some(b"1!") if CTRL && !is_release => {
|
||||
// CONTEXT.switch_term();
|
||||
// CONTEXT.current_term().keypress('>' as u8);
|
||||
// CONTEXT.current_term().flush();
|
||||
// },
|
||||
Some(ascii) if !is_release => {
|
||||
let mut terminal = CONTEXT.current_term();
|
||||
if SHIFT {
|
||||
|
|
|
|||
|
|
@ -34,24 +34,21 @@ pub extern fn kmain() -> ! {
|
|||
// use vga::color::Color;
|
||||
// use vga::color::ColorCode;
|
||||
|
||||
// WRITER.lock().reset_screen();
|
||||
// WRITER.lock().color_code = ColorCode::new(Color::Yellow, Color::Black);
|
||||
// println!(r#" ,--, "#);
|
||||
// println!(r#" ,--.'| ,----, "#);
|
||||
// println!(r#" ,--, | : .' .' \ "#);
|
||||
// println!(r#",---.'| : ' ,----,' | "#);
|
||||
// println!(r#"; : | | ; | : . ; "#);
|
||||
// println!(r#"| | : _' | ; |.' / "#);
|
||||
// println!(r#": : |.' | `----'/ ; "#);
|
||||
// println!(r#"| ' ' ; : / ; / "#);
|
||||
// println!(r#"\ \ .'. | ; / /-, "#);
|
||||
// println!(r#" `---`: | ' / / /.`| "#);
|
||||
// println!(r#" ' ; |./__; : "#);
|
||||
// println!(r#" | : ;| : .' "#);
|
||||
// println!(r#" ' ,/ ; | .' "#);
|
||||
// println!(r#" '--' `---' "#);
|
||||
// WRITER.lock().color_code = ColorCode::new(Color::White, Color::Black);
|
||||
// println!(">> Kernel startup...");
|
||||
println!(r#" ,--, "#);
|
||||
println!(r#" ,--.'| ,----, "#);
|
||||
println!(r#" ,--, | : .' .' \ "#);
|
||||
println!(r#",---.'| : ' ,----,' | "#);
|
||||
println!(r#"; : | | ; | : . ; "#);
|
||||
println!(r#"| | : _' | ; |.' / "#);
|
||||
println!(r#": : |.' | `----'/ ; "#);
|
||||
println!(r#"| ' ' ; : / ; / "#);
|
||||
println!(r#"\ \ .'. | ; / /-, "#);
|
||||
println!(r#" `---`: | ' / / /.`| "#);
|
||||
println!(r#" ' ; |./__; : "#);
|
||||
println!(r#" | : ;| : .' "#);
|
||||
println!(r#" ' ,/ ; | .' "#);
|
||||
println!(r#" '--' `---' "#);
|
||||
println!(">> Kernel startup...");
|
||||
|
||||
loop {
|
||||
keyboard::kbd_callback();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use super::{Color, ColorCode};
|
||||
use ::context::CONTEXT;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[repr(C)]
|
||||
|
|
@ -16,21 +17,21 @@ struct ScreenChar {
|
|||
color_code: ColorCode,
|
||||
}
|
||||
|
||||
// macro_rules! print {
|
||||
// ($($arg:tt)*) => ({
|
||||
// $crate::vga_buffer::print(format_args!($($arg)*));
|
||||
// });
|
||||
// }
|
||||
macro_rules! print {
|
||||
($($arg:tt)*) => ({
|
||||
$crate::vga::buffer::print(format_args!($($arg)*));
|
||||
});
|
||||
}
|
||||
|
||||
// macro_rules! println {
|
||||
// ($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||
// ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
||||
// }
|
||||
macro_rules! println {
|
||||
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
||||
}
|
||||
|
||||
// pub fn print(args: fmt::Arguments) {
|
||||
// use core::fmt::Write;
|
||||
// context.current_screen().write_fmt(args).unwrap();
|
||||
// }
|
||||
pub fn print(args: fmt::Arguments) {
|
||||
use core::fmt::Write;
|
||||
unsafe { CONTEXT.current_term().write_fmt(args).unwrap() };
|
||||
}
|
||||
|
||||
|
||||
extern crate core;
|
||||
|
|
@ -59,6 +60,7 @@ impl Writer {
|
|||
|
||||
pub fn keypress(&mut self, ascii: u8) {
|
||||
self.write_byte(ascii);
|
||||
self.flush();
|
||||
}
|
||||
|
||||
pub fn write_byte(&mut self, byte: u8) {
|
||||
|
|
@ -87,7 +89,6 @@ impl Writer {
|
|||
self.buffer[self.position] = b' ';
|
||||
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
|
||||
|
||||
self.flush();
|
||||
}
|
||||
|
||||
pub fn flush(&mut self) {
|
||||
|
|
@ -119,6 +120,7 @@ impl fmt::Write for Writer {
|
|||
for byte in s.bytes() {
|
||||
self.write_byte(byte)
|
||||
}
|
||||
self.flush();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue