1
0
Fork 0
forked from koniifer/ableos
This commit is contained in:
able 2023-06-16 05:20:37 -05:00
parent 1a98fe8908
commit c2b8341667
5 changed files with 28 additions and 29 deletions

View file

@ -2,21 +2,21 @@ use core::{arch::asm, fmt, ops::Deref, slice, str};
#[repr(u32)] #[repr(u32)]
pub enum RequestType { pub enum RequestType {
BasicInformation = 0x00000000, BasicInformation = 0x0000_0000,
VersionInformation = 0x00000001, VersionInformation = 0x0000_0001,
ThermalPowerManagementInformation = 0x00000006, ThermalPowerManagementInformation = 0x0000_0006,
StructuredExtendedInformation = 0x00000007, StructuredExtendedInformation = 0x0000_0007,
ExtendedFunctionInformation = 0x80000000, ExtendedFunctionInformation = 0x8000_0000,
ExtendedProcessorSignature = 0x80000001, ExtendedProcessorSignature = 0x8000_0001,
BrandString1 = 0x80000002, BrandString1 = 0x8000_0002,
BrandString2 = 0x80000003, BrandString2 = 0x8000_0003,
BrandString3 = 0x80000004, BrandString3 = 0x8000_0004,
// reserved = 0x80000005, // reserved = 0x80000005,
CacheLine = 0x80000006, CacheLine = 0x8000_0006,
TimeStampCounter = 0x80000007, TimeStampCounter = 0x8000_0007,
PhysicalAddressSize = 0x80000008, PhysicalAddressSize = 0x8000_0008,
} }
#[allow(clippy::similar_names)]
pub fn cpuid(code: RequestType) -> (u32, u32, u32, u32) { pub fn cpuid(code: RequestType) -> (u32, u32, u32, u32) {
let eax; let eax;
let ebx; let ebx;
@ -424,7 +424,7 @@ impl Clone for BrandString {
for (d, s) in bytes.iter_mut().zip(self.bytes.iter()) { for (d, s) in bytes.iter_mut().zip(self.bytes.iter()) {
*d = *s; *d = *s;
} }
BrandString { bytes: bytes } BrandString { bytes }
} }
} }
@ -761,8 +761,8 @@ impl Master {
thermal_power_management_information: tpm, thermal_power_management_information: tpm,
structured_extended_information: sei, structured_extended_information: sei,
extended_processor_signature: eps, extended_processor_signature: eps,
brand_string: brand_string, brand_string,
cache_line: cache_line, cache_line,
time_stamp_counter: tsc, time_stamp_counter: tsc,
physical_address_size: pas, physical_address_size: pas,
} }

View file

@ -1,12 +1,10 @@
//! Logging (as in terms of console / serial output) //! Logging (as in terms of console / serial output)
#![allow(deprecated)] #![allow(deprecated)]
use spin::Lazy;
use { use {
core::fmt::Write, core::fmt::Write,
limine::{TerminalRequest, TerminalResponse}, limine::{TerminalRequest, TerminalResponse},
spin::Mutex, spin::{Lazy, Mutex},
uart_16550::SerialPort, uart_16550::SerialPort,
}; };

View file

@ -2,9 +2,11 @@
use { use {
crate::ipc::message::Message, crate::ipc::message::Message,
alloc::vec::Vec,
crossbeam_queue::{ArrayQueue, SegQueue}, crossbeam_queue::{ArrayQueue, SegQueue},
hbvm::engine::Engine, hbvm::engine::Engine,
log::trace, log::trace,
HostError::MemoryError,
}; };
/// Host errors /// Host errors
pub enum HostError { pub enum HostError {
@ -20,13 +22,13 @@ pub fn ipc_send(engine: &mut Engine) -> Result<(), HostError> {
let message_start = engine.registers.f1; let message_start = engine.registers.f1;
let message_length = engine.registers.f2; let message_length = engine.registers.f2;
let mut ipc_msg: alloc::vec::Vec<u8> = alloc::vec![]; let mut ipc_msg: Vec<u8> = alloc::vec![];
for x in message_start..message_start + message_length { for x in message_start..message_start + message_length {
let byte = engine.read_mem_addr_8(x); let byte = engine.read_mem_addr_8(x);
match byte { match byte {
Ok(byte) => ipc_msg.push(byte), Ok(byte) => ipc_msg.push(byte),
Err(_) => return Err(HostError::MemoryError), Err(_) => return Err(MemoryError),
} }
} }
log::trace!("Message bytes {:?}", ipc_msg); log::trace!("Message bytes {:?}", ipc_msg);

View file

@ -2,9 +2,11 @@
use { use {
crate::{alloc::string::ToString, arch::logging::SERIAL_CONSOLE, device_tree::DeviceTree}, crate::{alloc::string::ToString, arch::logging::SERIAL_CONSOLE, device_tree::DeviceTree},
clparse::Arguments,
hbvm::engine::Engine, hbvm::engine::Engine,
log::{debug, trace}, log::{debug, trace},
spin::{Lazy, Mutex}, spin::{Lazy, Mutex},
xml::XMLElement,
}; };
pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! { pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! {
@ -14,10 +16,10 @@ pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! {
cmdline.pop(); cmdline.pop();
cmdline.remove(0); cmdline.remove(0);
let kcmd = clparse::Arguments::parse(cmdline.to_string()).unwrap(); let kcmd = Arguments::parse(cmdline.to_string()).unwrap();
trace!("Cmdline: {kcmd:?}"); trace!("Cmdline: {kcmd:?}");
let mut kcl = xml::XMLElement::new("Kernel Command Line"); let mut kcl = XMLElement::new("Kernel Command Line");
for (key, value) in kcmd.arguments { for (key, value) in kcmd.arguments {
kcl.set_attribute(key, value); kcl.set_attribute(key, value);
} }
@ -34,7 +36,7 @@ pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! {
} }
let dt = DEVICE_TREE.lock(); let dt = DEVICE_TREE.lock();
trace!("Device Tree{}", dt); log::info!("Device Tree{}", dt);
let bytes = alloc::vec![0]; let bytes = alloc::vec![0];
let mut prog = Engine::new(bytes); let mut prog = Engine::new(bytes);
@ -62,10 +64,8 @@ pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! {
let byte = sc.receive(); let byte = sc.receive();
if byte == b'\r' { if byte == b'\r' {
sc.send(b'\n'); sc.send(b'\n');
sc.send(b'\r');
} else {
sc.send(byte);
} }
sc.send(byte);
} }
} }
} }

View file

@ -13,10 +13,9 @@
ptr_sub_ptr, ptr_sub_ptr,
custom_test_frameworks custom_test_frameworks
)] )]
#![deny(clippy::pedantic, warnings)] #![deny(clippy::pedantic, missing_docs, warnings)]
#![allow(dead_code)] #![allow(dead_code)]
#![test_runner(crate::test_runner)] #![test_runner(crate::test_runner)]
#![deny(missing_docs)]
extern crate alloc; extern crate alloc;