bug squashing & testing
This commit is contained in:
parent
d9caa17f3c
commit
2321efd2e7
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -61,9 +61,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.88"
|
version = "1.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356"
|
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
|
@ -148,9 +148,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.18"
|
version = "1.1.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476"
|
checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
@ -395,7 +395,7 @@ source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4a9b9de87fd56a6bbd5
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/ableos/holey-bytes#c133c2dbe71b3f1e1142bacef200775ae0c1d22d"
|
source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#6968e7d769d905c41fbe4c195d9d34d3339c32cf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
|
@ -416,9 +416,9 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/ableos/holey-bytes#c133c2dbe71b3f1e1142bacef200775ae0c1d22d"
|
source = "git+https://git.ablecorp.us/ableos/holey-bytes.git#6968e7d769d905c41fbe4c195d9d34d3339c32cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)",
|
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes.git)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -597,7 +597,7 @@ dependencies = [
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"embedded-graphics",
|
"embedded-graphics",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)",
|
"hbvm 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes.git)",
|
||||||
"limine",
|
"limine",
|
||||||
"log",
|
"log",
|
||||||
"sbi",
|
"sbi",
|
||||||
|
|
|
@ -6,7 +6,7 @@ version = "0.2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embedded-graphics = "0.8"
|
embedded-graphics = "0.8"
|
||||||
hbvm.git = "https://git.ablecorp.us/ableos/holey-bytes"
|
hbvm.git = "https://git.ablecorp.us/ableos/holey-bytes.git"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
spin = "0.9"
|
spin = "0.9"
|
||||||
slab = { version = "0.4", default-features = false }
|
slab = { version = "0.4", default-features = false }
|
||||||
|
|
|
@ -97,55 +97,37 @@ pub fn handler(vm: &mut Vm) {
|
||||||
let msg_vec = block_read(mem_addr, length);
|
let msg_vec = block_read(mem_addr, length);
|
||||||
let msg_type = msg_vec[0];
|
let msg_type = msg_vec[0];
|
||||||
match msg_type {
|
match msg_type {
|
||||||
0 => 'wow: {
|
0 => {
|
||||||
let size = match msg_vec[0] {
|
let size = msg_vec[1];
|
||||||
0 => 1,
|
let addr = u16::from_le_bytes(msg_vec[2..4].try_into().unwrap());
|
||||||
1 => 2,
|
|
||||||
2 => 4,
|
|
||||||
_ => {
|
|
||||||
error!("Tried to write more than 32 bits");
|
|
||||||
break 'wow;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let addr = u16::from_le_bytes(msg_vec[1..3].try_into().unwrap());
|
|
||||||
let value = unsafe {
|
let value = unsafe {
|
||||||
match size {
|
match size {
|
||||||
1 => x86_in::<u8>(addr) as u64,
|
0 => x86_in::<u8>(addr) as u64,
|
||||||
2 => x86_in::<u16>(addr) as u64,
|
1 => x86_in::<u16>(addr) as u64,
|
||||||
4 => x86_in::<u32>(addr) as u64,
|
2 => x86_in::<u32>(addr) as u64,
|
||||||
_ => panic!("how?"),
|
_ => panic!("how?"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
trace!("Read the value {} from address {}", value, addr);
|
info!("Read the value {} from address {}", value, addr);
|
||||||
vm.registers[1] = hbvm::value::Value(value);
|
vm.registers[1] = hbvm::value::Value(value);
|
||||||
}
|
}
|
||||||
1 => 'wow: {
|
1 => {
|
||||||
let size = match msg_vec[1] {
|
let size = msg_vec[1];
|
||||||
0 => 1,
|
let addr = u16::from_le_bytes(msg_vec[2..4].try_into().unwrap());
|
||||||
1 => 2,
|
|
||||||
2 => 4,
|
|
||||||
_ => {
|
|
||||||
error!("Tried to write more than 32 bits");
|
|
||||||
break 'wow;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let addr = unsafe {
|
|
||||||
u16::from_le_bytes(msg_vec[1..3].try_into().unwrap_unchecked())
|
|
||||||
};
|
|
||||||
trace!("Setting address {}", addr);
|
trace!("Setting address {}", addr);
|
||||||
unsafe {
|
unsafe {
|
||||||
match size {
|
match size {
|
||||||
1 => x86_out(addr, msg_vec[3]),
|
0 => x86_out(addr, msg_vec[4]),
|
||||||
2 => x86_out(
|
1 => x86_out(
|
||||||
addr,
|
addr,
|
||||||
u16::from_le_bytes(
|
u16::from_le_bytes(
|
||||||
msg_vec[3..5].try_into().unwrap_unchecked(),
|
msg_vec[4..6].try_into().unwrap_unchecked(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
4 => x86_out(
|
2 => x86_out(
|
||||||
addr,
|
addr,
|
||||||
u32::from_le_bytes(
|
u32::from_le_bytes(
|
||||||
msg_vec[3..7].try_into().unwrap_unchecked(),
|
msg_vec[4..8].try_into().unwrap_unchecked(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_ => panic!("How?"),
|
_ => panic!("How?"),
|
||||||
|
|
|
@ -6,6 +6,6 @@ pub mod mem_serve;
|
||||||
pub mod service_definition_service;
|
pub mod service_definition_service;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn block_read<'a>(mem_addr: u64, length: usize) -> &'a [u8] {
|
pub fn block_read<'a>(mem_addr: u64, length: usize) -> &'a mut [u8] {
|
||||||
unsafe { slice::from_raw_parts(mem_addr as *const u8, length) }
|
unsafe { slice::from_raw_parts_mut(mem_addr as *mut _, length) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,28 +61,22 @@ impl<'p> Future for ExecThread {
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
match self.vm.run() {
|
match self.vm.run() {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers);
|
log::error!("HBVM Error\r\nRegister dump: {:?}", self.vm.registers,);
|
||||||
Poll::Ready(Err(err))
|
return Poll::Ready(Err(err));
|
||||||
}
|
|
||||||
Ok(VmRunOk::End) => Poll::Ready(Ok(())),
|
|
||||||
Ok(VmRunOk::Ecall) => {
|
|
||||||
ecah::handler(&mut self.vm);
|
|
||||||
cx.waker().wake_by_ref();
|
|
||||||
Poll::Pending
|
|
||||||
}
|
|
||||||
Ok(VmRunOk::Timer) => {
|
|
||||||
cx.waker().wake_by_ref();
|
|
||||||
Poll::Pending
|
|
||||||
}
|
}
|
||||||
|
Ok(VmRunOk::End) => return Poll::Ready(Ok(())),
|
||||||
|
Ok(VmRunOk::Ecall) => ecah::handler(&mut self.vm),
|
||||||
|
Ok(VmRunOk::Timer) => (),
|
||||||
Ok(VmRunOk::Breakpoint) => {
|
Ok(VmRunOk::Breakpoint) => {
|
||||||
error!(
|
log::error!(
|
||||||
"HBVM Debug breakpoint\r\nRegister dump: {:?}",
|
"HBVM Debug breakpoint\r\nRegister dump: {:?}",
|
||||||
self.vm.registers
|
self.vm.registers,
|
||||||
);
|
);
|
||||||
cx.waker().wake_by_ref();
|
|
||||||
Poll::Pending
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cx.waker().wake_by_ref();
|
||||||
|
Poll::Pending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use {
|
||||||
hashbrown::HashMap,
|
hashbrown::HashMap,
|
||||||
hbvm::mem::Address,
|
hbvm::mem::Address,
|
||||||
limine::{Framebuffer, FramebufferRequest, NonNullPtr},
|
limine::{Framebuffer, FramebufferRequest, NonNullPtr},
|
||||||
log::{debug, info},
|
log::{debug, trace},
|
||||||
spin::{Lazy, Mutex},
|
spin::{Lazy, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
|
||||||
let dt = DEVICE_TREE.lock();
|
let dt = DEVICE_TREE.lock();
|
||||||
|
|
||||||
// TODO(Able): This line causes a deadlock
|
// TODO(Able): This line causes a deadlock
|
||||||
info!("Device Tree: {}", dt);
|
debug!("Device Tree: {}", dt);
|
||||||
|
|
||||||
info!("Boot complete. Moving to init_system");
|
trace!("Boot complete. Moving to init_system");
|
||||||
|
|
||||||
// TODO: schedule the disk driver from the initramfs
|
// TODO: schedule the disk driver from the initramfs
|
||||||
// TODO: schedule the filesystem driver from the initramfs
|
// TODO: schedule the filesystem driver from the initramfs
|
||||||
|
@ -60,39 +60,32 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
|
||||||
disp.set_attribute("pitch", fb1.pitch);
|
disp.set_attribute("pitch", fb1.pitch);
|
||||||
dt.devices.insert("Displays".to_string(), alloc::vec![disp]);
|
dt.devices.insert("Displays".to_string(), alloc::vec![disp]);
|
||||||
}
|
}
|
||||||
log::info!("Graphics initialised");
|
debug!("Graphics initialised");
|
||||||
log::info!(
|
debug!(
|
||||||
"Graphics front ptr {:?}",
|
"Graphics front ptr {:?}",
|
||||||
fb1.address.as_ptr().unwrap() as *const u8
|
fb1.address.as_ptr().unwrap() as *const u8
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut executor = crate::task::Executor::new(256);
|
let mut executor = crate::task::Executor::new(256);
|
||||||
let bm_take = boot_modules.len();
|
|
||||||
unsafe {
|
unsafe {
|
||||||
for module in boot_modules.into_iter().take(bm_take) {
|
for module in boot_modules.iter() {
|
||||||
let mut cmd = module.cmd;
|
let cmd = module.cmd.trim_matches('"');
|
||||||
if cmd.len() > 2 {
|
|
||||||
// // Remove the quotes
|
|
||||||
// cmd.remove(0);
|
|
||||||
// cmd.pop();
|
|
||||||
cmd = &cmd[1..cmd.len()]
|
|
||||||
}
|
|
||||||
let cmd_len = cmd.len() as u64;
|
let cmd_len = cmd.len() as u64;
|
||||||
|
|
||||||
log::info!("Spawning {} with arguments \"{}\"", module.path, cmd);
|
log::info!("Spawning {} with arguments \"{}\"", module.path, cmd);
|
||||||
|
|
||||||
|
let mut thr = ExecThread::new(&module.bytes, Address::new(0));
|
||||||
|
if cmd_len > 0 {
|
||||||
|
thr.set_arguments(cmd.as_ptr() as u64, cmd_len);
|
||||||
|
}
|
||||||
executor.spawn(async move {
|
executor.spawn(async move {
|
||||||
let mut thr = ExecThread::new(&module.bytes, Address::new(0));
|
|
||||||
if cmd_len > 0 {
|
|
||||||
thr.set_arguments(cmd.as_bytes().as_ptr() as u64, cmd_len);
|
|
||||||
}
|
|
||||||
if let Err(e) = thr.await {
|
if let Err(e) = thr.await {
|
||||||
log::error!("{e:?}");
|
log::error!("{e:?}");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Random number: {}", hardware_random_u64());
|
debug!("Random number: {}", hardware_random_u64());
|
||||||
|
|
||||||
executor.run();
|
executor.run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
//! Named akern.
|
//! Named akern.
|
||||||
//! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better
|
//! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(new_uninit)]
|
|
||||||
#![feature(
|
#![feature(
|
||||||
|
new_uninit,
|
||||||
abi_x86_interrupt,
|
abi_x86_interrupt,
|
||||||
alloc_error_handler,
|
alloc_error_handler,
|
||||||
ptr_sub_ptr,
|
ptr_sub_ptr,
|
||||||
|
|
|
@ -18,21 +18,13 @@ release_page := fn(ptr: ^u8, page_count: u8): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
outb := fn(addr: u16, value: u8): void {
|
outb := fn(addr: u16, value: u8): void {
|
||||||
msg := "\0\0\0\0\0";
|
msg := [u8; 5].(1, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF), value)
|
||||||
*@as(^u8, msg) = @as(u8, 1);
|
return @eca(void, 3, 3, &msg, 5)
|
||||||
*@as(^u8, msg + 1) = @as(u8, 0);
|
|
||||||
*@as(^u16, @bitcast(msg + 2)) = addr;
|
|
||||||
*@as(^u8, msg + 4) = value
|
|
||||||
@eca(void, 3, 3, msg, 5)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inb := fn(addr: u16): u8 {
|
inb := fn(addr: u16): u8 {
|
||||||
msg := "\0\0\0\0";
|
msg := [u8; 4].(0, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF))
|
||||||
*@as(^u8, msg) = @as(u8, 0);
|
return @eca(u8, 3, 3, &msg, 4)
|
||||||
*@as(^u8, msg + 1) = @as(u8, 0);
|
|
||||||
*@as(^u16, @bitcast(msg + 2)) = addr
|
|
||||||
return @eca(u8, 3, 3, msg, 4)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outl := fn(addr: u16, value: u32): void {
|
outl := fn(addr: u16, value: u32): void {
|
||||||
|
|
3
sysdata/programs/ps2_driver/README.md
Normal file
3
sysdata/programs/ps2_driver/README.md
Normal 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
|
11
sysdata/programs/ps2_driver/meta.toml
Normal file
11
sysdata/programs/ps2_driver/meta.toml
Normal 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"
|
33
sysdata/programs/ps2_driver/src/main.hb
Normal file
33
sysdata/programs/ps2_driver/src/main.hb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
send_byte := fn(byte: u8): u8 {
|
||||||
|
memory.outb(96, byte)
|
||||||
|
return memory.inb(96)
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
send_byte(238)
|
||||||
|
log.info("PS/2 Driver Loaded\0")
|
||||||
|
if send_byte(238) == 238 {
|
||||||
|
log.info("PS/2 Keyboard Echoed\0")
|
||||||
|
}
|
||||||
|
a := 0
|
||||||
|
a += 1
|
||||||
|
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(96)
|
||||||
|
if input == prev_input {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
prev_input = input
|
||||||
|
keycode_str := string.display_int(input, ptr)
|
||||||
|
log.info(string.display_int(input, ptr))
|
||||||
|
buffer.send_message(keycode_str, buf)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
Loading…
Reference in a new issue