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
|
target
|
||||||
|
build
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
|
|
||||||
|
|
@ -92,16 +92,11 @@ pub fn kbd_callback() {
|
||||||
Some(b"\0\0") => {
|
Some(b"\0\0") => {
|
||||||
match scancode {
|
match scancode {
|
||||||
0x2A | 0x36 => {SHIFT = !is_release},
|
0x2A | 0x36 => {SHIFT = !is_release},
|
||||||
0x38 => {ALT = !is_release},
|
0x38 => {ALT = !is_release; println!("atl")},
|
||||||
0x1D => {CTRL = !is_release},
|
0x1D => {CTRL = !is_release; println!("ctrl")},
|
||||||
0x0F => {
|
0x0F if !is_release => {
|
||||||
CONTEXT.current_term().keypress('T' as u8);
|
|
||||||
CONTEXT.switch_term();
|
CONTEXT.switch_term();
|
||||||
CONTEXT.current_term().keypress('T' as u8);
|
|
||||||
CONTEXT.current_term().flush();
|
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.switch_term();
|
||||||
// CONTEXT.current_term().flush();
|
// CONTEXT.current_term().flush();
|
||||||
// },
|
// },
|
||||||
Some(b"1!") if CTRL => {
|
// Some(b"1!") if CTRL && !is_release => {
|
||||||
CONTEXT.switch_term();
|
// CONTEXT.switch_term();
|
||||||
CONTEXT.current_term().keypress('>' as u8);
|
// CONTEXT.current_term().keypress('>' as u8);
|
||||||
CONTEXT.current_term().flush();
|
// CONTEXT.current_term().flush();
|
||||||
},
|
// },
|
||||||
Some(ascii) if !is_release => {
|
Some(ascii) if !is_release => {
|
||||||
let mut terminal = CONTEXT.current_term();
|
let mut terminal = CONTEXT.current_term();
|
||||||
if SHIFT {
|
if SHIFT {
|
||||||
|
|
|
||||||
|
|
@ -34,24 +34,21 @@ pub extern fn kmain() -> ! {
|
||||||
// use vga::color::Color;
|
// use vga::color::Color;
|
||||||
// use vga::color::ColorCode;
|
// use vga::color::ColorCode;
|
||||||
|
|
||||||
// WRITER.lock().reset_screen();
|
println!(r#" ,--, "#);
|
||||||
// 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#": : |.' | `----'/ ; "#);
|
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...");
|
||||||
// println!(r#" '--' `---' "#);
|
|
||||||
// WRITER.lock().color_code = ColorCode::new(Color::White, Color::Black);
|
|
||||||
// println!(">> Kernel startup...");
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
keyboard::kbd_callback();
|
keyboard::kbd_callback();
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use super::{Color, ColorCode};
|
use super::{Color, ColorCode};
|
||||||
|
use ::context::CONTEXT;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
@ -16,21 +17,21 @@ struct ScreenChar {
|
||||||
color_code: ColorCode,
|
color_code: ColorCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
// macro_rules! print {
|
macro_rules! print {
|
||||||
// ($($arg:tt)*) => ({
|
($($arg:tt)*) => ({
|
||||||
// $crate::vga_buffer::print(format_args!($($arg)*));
|
$crate::vga::buffer::print(format_args!($($arg)*));
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// macro_rules! println {
|
macro_rules! println {
|
||||||
// ($fmt:expr) => (print!(concat!($fmt, "\n")));
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||||
// ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn print(args: fmt::Arguments) {
|
pub fn print(args: fmt::Arguments) {
|
||||||
// use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
// context.current_screen().write_fmt(args).unwrap();
|
unsafe { CONTEXT.current_term().write_fmt(args).unwrap() };
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
@ -59,6 +60,7 @@ impl Writer {
|
||||||
|
|
||||||
pub fn keypress(&mut self, ascii: u8) {
|
pub fn keypress(&mut self, ascii: u8) {
|
||||||
self.write_byte(ascii);
|
self.write_byte(ascii);
|
||||||
|
self.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_byte(&mut self, byte: u8) {
|
pub fn write_byte(&mut self, byte: u8) {
|
||||||
|
|
@ -87,7 +89,6 @@ impl Writer {
|
||||||
self.buffer[self.position] = b' ';
|
self.buffer[self.position] = b' ';
|
||||||
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
|
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
|
||||||
|
|
||||||
self.flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush(&mut self) {
|
pub fn flush(&mut self) {
|
||||||
|
|
@ -119,6 +120,7 @@ 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