1
0
Fork 0
forked from AbleOS/ableos

Merge master

This commit is contained in:
peony 2024-11-16 21:52:45 +01:00
commit 98b15d4c10
13 changed files with 72 additions and 27 deletions

8
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "aarch64-cpu"
@ -213,12 +213,12 @@ dependencies = [
[[package]]
name = "hbbytecode"
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]]
name = "hblang"
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 = [
"hashbrown",
"hbbytecode",
@ -229,7 +229,7 @@ dependencies = [
[[package]]
name = "hbvm"
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 = [
"hbbytecode",
]

View file

@ -1,6 +1,3 @@
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]
[build]
target = "./targets/x86_64-ableos.json"

View file

@ -38,6 +38,7 @@ SECTIONS
.data : {
*(.data .data.*)
*(.got .got.*)
} :data
.bss : {

View file

@ -14,3 +14,29 @@ arch_cond!(
riscv64: "riscv64",
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)
});

View file

@ -11,8 +11,9 @@ static mut LAPIC: LocalApic = unsafe { MaybeUninit::zeroed().assume_init() };
static mut IDT: InterruptDescriptorTable = unsafe { MaybeUninit::zeroed().assume_init() };
#[repr(u8)]
#[derive(Debug)]
enum Interrupt {
#[derive(Debug, Eq, Hash, PartialEq)]
pub enum Interrupt {
Timer = 32,
ApicErr = u8::MAX - 1,
Spurious = u8::MAX,
@ -61,6 +62,8 @@ extern "x86-interrupt" fn page_fault(
}
extern "x86-interrupt" fn timer(_isf: InterruptStackFrame) {
// interrupt(Interrupt::Timer);
unsafe {
LAPIC.end_of_interrupt();
}
@ -81,6 +84,27 @@ extern "x86-interrupt" fn spurious(_: InterruptStackFrame) {
}
fn interrupt(interrupt_type: Interrupt) {
log::info!("Interrupt type {:?}", interrupt_type);
panic!()
use crate::arch::INTERRUPT_LIST;
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);
}
}

View file

@ -33,7 +33,7 @@ const INITIAL_KERNEL_HEAP_SIZE: *const () = _initial_kernel_heap_size as _;
#[cfg(not(target_feature = "avx2"))]
unsafe extern "C" fn _kernel_start() -> ! {
// Initialise SSE, then jump to kernel entrypoint
core::arch::asm!(
core::arch::naked_asm!(
// Initialise SSE
"mov rax, cr0",
"and ax, 0xfffb",
@ -46,7 +46,6 @@ unsafe extern "C" fn _kernel_start() -> ! {
// Jump to the kernel entry point
"jmp {}",
sym start,
options(noreturn),
)
}
@ -54,7 +53,7 @@ unsafe extern "C" fn _kernel_start() -> ! {
#[naked]
#[cfg(target_feature = "avx2")]
unsafe extern "C" fn _kernel_start() -> ! {
core::arch::asm!(
core::arch::naked_asm!(
// Enable protected mode and configure control registers
"mov rax, cr0",
"and ax, 0xFFFB", // Clear CR0.EM (bit 2) for coprocessor emulation
@ -100,7 +99,6 @@ unsafe extern "C" fn _kernel_start() -> ! {
"jmp {0}",
sym start,
sym oops,
options(noreturn),
)
}

View file

@ -92,8 +92,7 @@ fn sds_create_service(protocol: &'static str) -> u64 {
// let a: protocol::Protocol = protocol.into();
buff_id
}
fn sds_search_service(protocol: &str) -> u64 {
pub fn sds_search_service(protocol: &str) -> u64 {
let services = SERVICES.lock();
let compare = Protocol::from(protocol);
for (bid, protocol_canidate) in &services.0 {

View file

@ -1,5 +1,5 @@
mod ecah;
mod kernel_services;
pub mod kernel_services;
mod mem;
use {

View file

@ -5,7 +5,6 @@
#![feature(
slice_split_once,
exclusive_wrapper,
new_uninit,
core_intrinsics,
abi_x86_interrupt,
alloc_error_handler,
@ -15,7 +14,7 @@
pointer_is_aligned_to
)]
#![test_runner(crate::test_runner)]
#![allow(dead_code, internal_features)]
#![allow(dead_code, internal_features, static_mut_refs)]
extern crate alloc;
mod allocator;

View file

@ -1,6 +1,6 @@
{
"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,
"env": "",
"executables": true,

View file

@ -1,3 +1,5 @@
[toolchain]
channel = "nightly-2024-07-27"
# old toolchain
# channel = "nightly-2024-07-27"
channel = "nightly"
components = ["rust-src", "llvm-tools"]

View file

@ -6,7 +6,7 @@ $uninit := fn($Expr: type): ?Expr {
return null
}
dangling := fn($Expr: type): ^Expr {
$dangling := fn($Expr: type): ^Expr {
return @bitcast(@alignof(Expr))
}
@ -23,7 +23,7 @@ alloc := fn($Expr: type, num: uint): ^Expr {
ptr := request_page(MAX_ALLOC)
remaining := pages - MAX_ALLOC
loop if remaining < MAX_ALLOC break else {
_ = request_page(@intcast(MAX_ALLOC))
_ = request_page(MAX_ALLOC)
remaining -= MAX_ALLOC
}
_ = request_page(@intcast(remaining))

View file

@ -25,7 +25,6 @@ example := fn(): void {
render.clear(screen, render.black)
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)
// 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, 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)