Litrally almost functional PS/2 driver. #19
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aarch64-cpu"
|
name = "aarch64-cpu"
|
||||||
|
@ -213,12 +213,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbbytecode"
|
name = "hbbytecode"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a64383e72b0920ef1c03773aac197404c78b330f"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#12bb7029b4bafd1edff77ed9a12888374cc7f8be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a64383e72b0920ef1c03773aac197404c78b330f"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#12bb7029b4bafd1edff77ed9a12888374cc7f8be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
|
@ -229,7 +229,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a64383e72b0920ef1c03773aac197404c78b330f"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#12bb7029b4bafd1edff77ed9a12888374cc7f8be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std = ["core", "compiler_builtins", "alloc"]
|
build-std = ["core", "compiler_builtins", "alloc"]
|
||||||
build-std-features = ["compiler-builtins-mem"]
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
|
|
||||||
[build]
|
|
||||||
target = "./targets/x86_64-ableos.json"
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ SECTIONS
|
||||||
|
|
||||||
.data : {
|
.data : {
|
||||||
*(.data .data.*)
|
*(.data .data.*)
|
||||||
|
*(.got .got.*)
|
||||||
} :data
|
} :data
|
||||||
|
|
||||||
.bss : {
|
.bss : {
|
||||||
|
|
|
@ -14,3 +14,29 @@ arch_cond!(
|
||||||
riscv64: "riscv64",
|
riscv64: "riscv64",
|
||||||
x86_64: "x86_64",
|
x86_64: "x86_64",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use {crate::arch::interrupts::Interrupt, alloc::string::String};
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
pub struct InterruptList {
|
||||||
|
list: HashMap<Interrupt, String>,
|
||||||
|
}
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use hashbrown::HashMap;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
impl InterruptList {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
list: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
use spin::{Lazy, Mutex};
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
pub static INTERRUPT_LIST: Lazy<Mutex<InterruptList>> = Lazy::new(|| {
|
||||||
|
let mut il = InterruptList::new();
|
||||||
|
use crate::alloc::string::ToString;
|
||||||
|
il.list.insert(Interrupt::Timer, "PS/2 Mouse".to_string());
|
||||||
|
Mutex::new(il)
|
||||||
|
});
|
||||||
|
|
|
@ -11,8 +11,9 @@ static mut LAPIC: LocalApic = unsafe { MaybeUninit::zeroed().assume_init() };
|
||||||
static mut IDT: InterruptDescriptorTable = unsafe { MaybeUninit::zeroed().assume_init() };
|
static mut IDT: InterruptDescriptorTable = unsafe { MaybeUninit::zeroed().assume_init() };
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, Hash, PartialEq)]
|
||||||
enum Interrupt {
|
|
||||||
|
pub enum Interrupt {
|
||||||
Timer = 32,
|
Timer = 32,
|
||||||
ApicErr = u8::MAX - 1,
|
ApicErr = u8::MAX - 1,
|
||||||
Spurious = u8::MAX,
|
Spurious = u8::MAX,
|
||||||
|
@ -61,6 +62,8 @@ extern "x86-interrupt" fn page_fault(
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) {
|
extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) {
|
||||||
|
// interrupt(Interrupt::Timer);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
LAPIC.end_of_interrupt();
|
LAPIC.end_of_interrupt();
|
||||||
}
|
}
|
||||||
|
@ -80,7 +83,28 @@ extern "x86-interrupt" fn spurious(_: InterruptStackFrame) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn interrupt(interrupt_type: Interrupt){
|
fn interrupt(interrupt_type: Interrupt) {
|
||||||
log::info!("Interrupt type {:?}", interrupt_type);
|
use crate::arch::INTERRUPT_LIST;
|
||||||
panic!()
|
let il = INTERRUPT_LIST.lock();
|
||||||
}
|
let val = il.list.get(&interrupt_type).unwrap();
|
||||||
|
|
||||||
|
use crate::holeybytes::kernel_services::service_definition_service::sds_search_service;
|
||||||
|
let buffer = sds_search_service(val);
|
||||||
|
if buffer != 0 {
|
||||||
|
use {crate::kmain::IPC_BUFFERS, alloc::vec::Vec};
|
||||||
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
|
match buffs.get_mut(&buffer) {
|
||||||
|
Some(buff) => {
|
||||||
|
let mut msg_vec = Vec::new();
|
||||||
|
msg_vec.push(0xFF);
|
||||||
|
buff.push(msg_vec.to_vec());
|
||||||
|
log::debug!("Sent Message {:?} to Buffer({})", msg_vec, buffer);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
log::error!("Access of non-existent buffer {}", buffer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// log::info!("{}", buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ const INITIAL_KERNEL_HEAP_SIZE: *const () = _initial_kernel_heap_size as _;
|
||||||
#[cfg(not(target_feature = "avx2"))]
|
#[cfg(not(target_feature = "avx2"))]
|
||||||
unsafe extern "C" fn _kernel_start() -> ! {
|
unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
// Initialise SSE, then jump to kernel entrypoint
|
// Initialise SSE, then jump to kernel entrypoint
|
||||||
core::arch::asm!(
|
core::arch::naked_asm!(
|
||||||
// Initialise SSE
|
// Initialise SSE
|
||||||
"mov rax, cr0",
|
"mov rax, cr0",
|
||||||
"and ax, 0xfffb",
|
"and ax, 0xfffb",
|
||||||
|
@ -46,7 +46,6 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
// Jump to the kernel entry point
|
// Jump to the kernel entry point
|
||||||
"jmp {}",
|
"jmp {}",
|
||||||
sym start,
|
sym start,
|
||||||
options(noreturn),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
#[naked]
|
#[naked]
|
||||||
#[cfg(target_feature = "avx2")]
|
#[cfg(target_feature = "avx2")]
|
||||||
unsafe extern "C" fn _kernel_start() -> ! {
|
unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
core::arch::asm!(
|
core::arch::naked_asm!(
|
||||||
// Enable protected mode and configure control registers
|
// Enable protected mode and configure control registers
|
||||||
"mov rax, cr0",
|
"mov rax, cr0",
|
||||||
"and ax, 0xFFFB", // Clear CR0.EM (bit 2) for coprocessor emulation
|
"and ax, 0xFFFB", // Clear CR0.EM (bit 2) for coprocessor emulation
|
||||||
|
@ -100,7 +99,6 @@ unsafe extern "C" fn _kernel_start() -> ! {
|
||||||
"jmp {0}",
|
"jmp {0}",
|
||||||
sym start,
|
sym start,
|
||||||
sym oops,
|
sym oops,
|
||||||
options(noreturn),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,7 @@ fn sds_create_service(protocol: &'static str) -> u64 {
|
||||||
// let a: protocol::Protocol = protocol.into();
|
// let a: protocol::Protocol = protocol.into();
|
||||||
buff_id
|
buff_id
|
||||||
}
|
}
|
||||||
|
pub fn sds_search_service(protocol: &str) -> u64 {
|
||||||
fn sds_search_service(protocol: &str) -> u64 {
|
|
||||||
let services = SERVICES.lock();
|
let services = SERVICES.lock();
|
||||||
let compare = Protocol::from(protocol);
|
let compare = Protocol::from(protocol);
|
||||||
for (bid, protocol_canidate) in &services.0 {
|
for (bid, protocol_canidate) in &services.0 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
mod ecah;
|
mod ecah;
|
||||||
mod kernel_services;
|
pub mod kernel_services;
|
||||||
mod mem;
|
mod mem;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#![feature(
|
#![feature(
|
||||||
slice_split_once,
|
slice_split_once,
|
||||||
exclusive_wrapper,
|
exclusive_wrapper,
|
||||||
new_uninit,
|
|
||||||
core_intrinsics,
|
core_intrinsics,
|
||||||
abi_x86_interrupt,
|
abi_x86_interrupt,
|
||||||
alloc_error_handler,
|
alloc_error_handler,
|
||||||
|
@ -15,7 +14,7 @@
|
||||||
pointer_is_aligned_to
|
pointer_is_aligned_to
|
||||||
)]
|
)]
|
||||||
#![test_runner(crate::test_runner)]
|
#![test_runner(crate::test_runner)]
|
||||||
#![allow(dead_code, internal_features)]
|
#![allow(dead_code, internal_features, static_mut_refs)]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
mod allocator;
|
mod allocator;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"arch": "aarch64",
|
"arch": "aarch64",
|
||||||
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
|
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32",
|
||||||
"disable-redzone": true,
|
"disable-redzone": true,
|
||||||
"env": "",
|
"env": "",
|
||||||
"executables": true,
|
"executables": true,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2024-07-27"
|
# old toolchain
|
||||||
|
# channel = "nightly-2024-07-27"
|
||||||
|
channel = "nightly"
|
||||||
components = ["rust-src", "llvm-tools"]
|
components = ["rust-src", "llvm-tools"]
|
||||||
|
|
|
@ -6,7 +6,7 @@ $uninit := fn($Expr: type): ?Expr {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
dangling := fn($Expr: type): ^Expr {
|
$dangling := fn($Expr: type): ^Expr {
|
||||||
return @bitcast(@alignof(Expr))
|
return @bitcast(@alignof(Expr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ alloc := fn($Expr: type, num: uint): ^Expr {
|
||||||
ptr := request_page(MAX_ALLOC)
|
ptr := request_page(MAX_ALLOC)
|
||||||
remaining := pages - MAX_ALLOC
|
remaining := pages - MAX_ALLOC
|
||||||
loop if remaining < MAX_ALLOC break else {
|
loop if remaining < MAX_ALLOC break else {
|
||||||
_ = request_page(@intcast(MAX_ALLOC))
|
_ = request_page(MAX_ALLOC)
|
||||||
remaining -= MAX_ALLOC
|
remaining -= MAX_ALLOC
|
||||||
}
|
}
|
||||||
_ = request_page(@intcast(remaining))
|
_ = request_page(@intcast(remaining))
|
||||||
|
|
|
@ -25,7 +25,6 @@ example := fn(): void {
|
||||||
render.clear(screen, render.black)
|
render.clear(screen, render.black)
|
||||||
render.put_filled_circle(screen, .(screen.width / 2, screen.height / 2), 128, render.light_yellow)
|
render.put_filled_circle(screen, .(screen.width / 2, screen.height / 2), 128, render.light_yellow)
|
||||||
render.put_circle(screen, .(screen.width / 2, screen.height / 2), 256, render.light_blue)
|
render.put_circle(screen, .(screen.width / 2, screen.height / 2), 256, render.light_blue)
|
||||||
// Precision issues?
|
|
||||||
render.put_textured_circle(screen, able, .(able.width / 2, able.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle) * 256)), screen.height / 2 + @intcast(@fti(cos(angle) * 256))), able.width / 2 - 1)
|
render.put_textured_circle(screen, able, .(able.width / 2, able.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle) * 256)), screen.height / 2 + @intcast(@fti(cos(angle) * 256))), able.width / 2 - 1)
|
||||||
render.put_textured_circle(screen, mini, .(mini.width / 2, mini.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle + PI) * 256)), screen.height / 2 + @intcast(@fti(cos(angle + PI) * 256))), mini.width / 2 - 1)
|
render.put_textured_circle(screen, mini, .(mini.width / 2, mini.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle + PI) * 256)), screen.height / 2 + @intcast(@fti(cos(angle + PI) * 256))), mini.width / 2 - 1)
|
||||||
render.sync(screen)
|
render.sync(screen)
|
||||||
|
|
Loading…
Reference in a new issue