Compare commits

..

4 commits

Author SHA1 Message Date
koniifer 58bc6facbc Merge remote-tracking branch 'origin/kodin/keyboard-driver' 2024-08-30 14:55:22 +01:00
Talha Qamar 1615297536 Detecting keypresses 2024-08-30 18:06:24 +05:00
Talha Qamar 0d3641e199 just getting started 2024-08-30 18:04:10 +05:00
Able 6295a7118e Added beef to ableOS 2024-08-30 07:38:04 -05:00
13 changed files with 161 additions and 21 deletions

54
Cargo.lock generated
View file

@ -110,6 +110,12 @@ version = "0.21.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
[[package]]
name = "beef"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1"
[[package]] [[package]]
name = "bit" name = "bit"
version = "0.1.1" version = "0.1.1"
@ -248,6 +254,9 @@ dependencies = [
[[package]] [[package]]
name = "dev" name = "dev"
version = "0.1.0" version = "0.1.0"
dependencies = [
"logos",
]
[[package]] [[package]]
name = "embedded-graphics" name = "embedded-graphics"
@ -638,6 +647,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0fc32485e41ae5e9dedd1442f36dec998431adc9f321224c2c5d645f38fdcb" checksum = "cb0fc32485e41ae5e9dedd1442f36dec998431adc9f321224c2c5d645f38fdcb"
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.149" version = "0.2.149"
@ -665,6 +680,39 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "logos"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff1ceb190eb9bdeecdd8f1ad6a71d6d632a50905948771718741b5461fb01e13"
dependencies = [
"logos-derive",
]
[[package]]
name = "logos-codegen"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90be66cb7bd40cb5cc2e9cfaf2d1133b04a3d93b72344267715010a466e0915a"
dependencies = [
"beef",
"fnv",
"lazy_static",
"proc-macro2",
"quote",
"regex-syntax",
"syn 2.0.38",
]
[[package]]
name = "logos-derive"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45154231e8e96586b39494029e58f12f8ffcb5ecf80333a603a13aa205ea8cbd"
dependencies = [
"logos-codegen",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.6.4" version = "2.6.4"
@ -803,6 +851,12 @@ dependencies = [
"rand_core", "rand_core",
] ]
[[package]]
name = "regex-syntax"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
[[package]] [[package]]
name = "repbuild" name = "repbuild"
version = "0.2.0" version = "0.2.0"

View file

@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
logos = "0.14.1"

20
dev/src/idl/mod.rs Normal file
View file

@ -0,0 +1,20 @@
use logos::Logos;
#[derive(Logos, Debug, PartialEq)]
#[logos(skip r"[ \t\n\f]+")] // Ignore this regex pattern between tokens
enum Token {
// Tokens can be literal strings, of any length.
#[token("protocol")]
Protocol,
#[token(".")]
Period,
// Or regular expressions.
#[regex("[a-zA-Z]+")]
Text,
}
pub fn main() {
let mut lex = Token::lexer("Create ridiculously fast Lexers.");
}

View file

@ -1,4 +1,5 @@
use std::{fmt::format, io::Write}; use std::io::Write;
pub mod idl;
pub enum Options { pub enum Options {
Build, Build,
@ -6,6 +7,12 @@ pub enum Options {
New, New,
Run, Run,
} }
#[derive(PartialEq)]
pub enum DevelopmentType {
Program,
Library,
IDL,
}
fn main() { fn main() {
let mut args: Vec<String> = std::env::args().collect(); let mut args: Vec<String> = std::env::args().collect();
@ -24,29 +31,31 @@ fn main() {
let binding = args.pop().unwrap(); let binding = args.pop().unwrap();
let dev_type = binding.as_str(); let dev_type = binding.as_str();
let name = args.pop().unwrap(); let name = args.pop().unwrap();
use DevelopmentType::*;
match dev_type { match dev_type {
"lib" | "library" => new(true, name), "lib" | "library" => new(Library, name),
"prog" | "program" => new(false, name), "prog" | "program" => new(Program, name),
"idl" => {
new(IDL, name);
// idl::main();
panic!("IDL is not finalized yet.")
}
_ => {} _ => {}
}; };
} }
"run" => run(), "run" => run(),
"help" => help(),
"help" => {
// println!("This is the help message.");
// println!("A prototype build tool meant to help with ableOS software development.");
help()
}
_ => { _ => {
println!("Error"); println!("Error");
} }
} }
} }
pub fn new(library: bool, name: String) { pub fn new(development_type: DevelopmentType, name: String) {
let (folder_hierarchy, entry_name) = match library { let (folder_hierarchy, entry_name) = match development_type {
true => ("libraries", "lib.hb"), DevelopmentType::Program => ("programs", "main.hb"),
false => ("programs", "main.hb"), DevelopmentType::Library => ("libraries", "lib.hb"),
DevelopmentType::IDL => ("idl", "protocol.aidl"),
}; };
let project_folder_path_string = format!("sysdata/{folder_hierarchy}/{name}"); let project_folder_path_string = format!("sysdata/{folder_hierarchy}/{name}");
@ -66,18 +75,24 @@ pub fn new(library: bool, name: String) {
let full_path_string = format!("{src_folder_path_string}/{entry_name}"); let full_path_string = format!("{src_folder_path_string}/{entry_name}");
let mut file = std::fs::File::create(full_path_string.clone()).unwrap(); let mut file = std::fs::File::create(full_path_string.clone()).unwrap();
let file_contents = if library { let file_contents = match development_type {
"" DevelopmentType::Program => "main := fn(): int {
} else {
"main := fn(): int {
return 0 return 0
}" }"
.to_string(),
DevelopmentType::Library => "".to_string(),
DevelopmentType::IDL => format!(
"protocol {} {{
}}",
name
)
.to_owned(),
} }
.to_string(); .to_string();
file.write_all(file_contents.as_bytes()).unwrap(); file.write_all(file_contents.as_bytes()).unwrap();
println!("New project created."); println!("New project created.");
if !library { if development_type == DevelopmentType::Program {
println!("You should add your project into the ableOS system configuration in sysdata/system_config.toml") println!("You should add your project into the ableOS system configuration in sysdata/system_config.toml")
} }
} }

View file

@ -0,0 +1 @@
# abc

View file

@ -0,0 +1,2 @@
protocol abc {
}

View file

@ -4,9 +4,9 @@ receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u
return @eca(^u8, 4, buffer_id, memory_map_location, length) return @eca(^u8, 4, buffer_id, memory_map_location, length)
} }
send_message := fn(message: ^u8, buffer_id: int): void { send_message := fn(msg: ^u8, buffer_id: int): void {
message_length := string.length(message) msg_length := string.length(msg)
@eca(i32, 3, buffer_id, message, message_length) @eca(i32, 3, buffer_id, msg, msg_length)
return return
} }

View file

@ -0,0 +1,3 @@
# PS/2 Driver
This program is a simple driver to read keypresses from a PS/2 Keyboard
Also will contain an abstraction for the PS/2 controller in general so the Mouse code will probably also live here...maybe

View file

@ -0,0 +1,11 @@
[package]
name = "ps2_driver"
authors = ["Talha Qamar"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang src/main.hb"

View file

@ -0,0 +1,30 @@
.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb")
send_byte := fn(byte: u8): u8 {
memory.outb(0, 96, byte)
return memory.inb(0, 96)
}
main := fn(): int {
log.info("PS/2 Driver Loaded\0")
if send_byte(238) == 238 {
log.info("PS/2 Keyboard Echoed\0")
}
if send_byte(244) == 250 {
log.info("Enabled scanning\0")
}
buf := buffer.create("XKeyboard\0")
ptr := memory.request_page(1)
prev_input := 250
loop {
input := memory.inb(0, 96)
if input == prev_input {
continue
}
prev_input = input
keycode_str := string.display_int(input, ptr)
log.info(string.display_int(buf))
buffer.send_message(keycode_str, buf)
}
return 0
}

View file

@ -23,6 +23,9 @@ resolution = "1024x768x24"
[boot.limine.ableos.modules.a_serial_driver] [boot.limine.ableos.modules.a_serial_driver]
path = "boot:///a_serial_driver.hbf" path = "boot:///a_serial_driver.hbf"
[boot.limine.ableos.modules.ps2_driver]
path = "boot:///ps2_driver.hbf"
[boot.limine.ableos.modules.diskio_driver] [boot.limine.ableos.modules.diskio_driver]
path = "boot:///diskio_driver.hbf" path = "boot:///diskio_driver.hbf"