Merge pull request 'master' (#3) from IntoTheNight/holey-bytes:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/holey-bytes/pulls/3
This commit is contained in:
commit
6f4f156ca0
23
Cargo.lock
generated
23
Cargo.lock
generated
|
@ -19,6 +19,16 @@ version = "0.2.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9"
|
checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ariadne"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72fe02fc62033df9ba41cba57ee19acf5e742511a140c7dbc3a873e19a19a1bd"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width",
|
||||||
|
"yansi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "beef"
|
name = "beef"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
|
@ -90,6 +100,7 @@ dependencies = [
|
||||||
name = "hbasm"
|
name = "hbasm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ariadne",
|
||||||
"hashbrown 0.14.0",
|
"hashbrown 0.14.0",
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
"lasso",
|
"lasso",
|
||||||
|
@ -250,8 +261,20 @@ version = "1.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
|
checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "yansi"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
|
||||||
|
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
||||||
hbbytecode = { path = "../hbbytecode" }
|
hbbytecode = { path = "../hbbytecode" }
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
hashbrown = "0.14.0"
|
hashbrown = "0.14.0"
|
||||||
|
ariadne = "0.3.0"
|
||||||
|
|
||||||
[dependencies.lasso]
|
[dependencies.lasso]
|
||||||
version = "0.7"
|
version = "0.7"
|
||||||
|
|
|
@ -66,7 +66,6 @@ macro_rules! impl_asm {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub(super) use {impl_asm, impl_asm_opcodes};
|
pub(super) use {impl_asm, impl_asm_opcodes};
|
||||||
|
|
||||||
#[allow(clippy::single_component_path_imports)]
|
#[allow(clippy::single_component_path_imports)]
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use std::{
|
use {
|
||||||
error::Error,
|
ariadne::{ColorGenerator, Label, Report, ReportKind, Source},
|
||||||
io::{stdin, stdout, Read, Write},
|
std::{
|
||||||
|
error::Error,
|
||||||
|
io::{stdin, Read},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
@ -8,14 +11,36 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
stdin().read_to_string(&mut code)?;
|
stdin().read_to_string(&mut code)?;
|
||||||
|
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
|
|
||||||
if let Err(e) = hbasm::text::assembly(&code, &mut buf) {
|
if let Err(e) = hbasm::text::assembly(&code, &mut buf) {
|
||||||
eprintln!(
|
let mut colors = ColorGenerator::new();
|
||||||
"Error {:?} at {:?} (`{}`)",
|
|
||||||
e.kind,
|
let e_code = match e.kind {
|
||||||
e.span.clone(),
|
hbasm::text::ErrorKind::UnexpectedToken => 1,
|
||||||
&code[e.span],
|
hbasm::text::ErrorKind::InvalidToken => 2,
|
||||||
);
|
hbasm::text::ErrorKind::UnexpectedEnd => 3,
|
||||||
|
hbasm::text::ErrorKind::InvalidSymbol => 4,
|
||||||
|
};
|
||||||
|
let message = match e.kind {
|
||||||
|
hbasm::text::ErrorKind::UnexpectedToken => "This token is not expected!",
|
||||||
|
hbasm::text::ErrorKind::InvalidToken => "The token is not valid!",
|
||||||
|
hbasm::text::ErrorKind::UnexpectedEnd => "The assembler reached the end of input unexpectedly!",
|
||||||
|
hbasm::text::ErrorKind::InvalidSymbol => "This referenced symbol doesn't have a corresponding label!",
|
||||||
|
};
|
||||||
|
let a = colors.next();
|
||||||
|
|
||||||
|
Report::build(ReportKind::Error, "engine_internal", e.span.clone().start)
|
||||||
|
.with_code(e_code)
|
||||||
|
.with_message(format!("{:?}", e.kind))
|
||||||
|
.with_label(
|
||||||
|
Label::new(("engine_internal", e.span.clone()))
|
||||||
|
.with_message(message)
|
||||||
|
.with_color(a),
|
||||||
|
)
|
||||||
|
.finish()
|
||||||
|
.eprint(("engine_internal", Source::from(&code)))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
stdout().write_all(&buf)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
pub mod paging;
|
pub mod paging;
|
||||||
|
|
||||||
use self::paging::{PageTable, Permission, PtEntry};
|
use {
|
||||||
use super::{trap::HandleTrap, VmRunError};
|
self::paging::{PageTable, Permission, PtEntry},
|
||||||
use alloc::boxed::Box;
|
super::{trap::HandleTrap, VmRunError},
|
||||||
use core::mem::MaybeUninit;
|
alloc::boxed::Box,
|
||||||
use derive_more::Display;
|
core::mem::MaybeUninit,
|
||||||
|
derive_more::Display,
|
||||||
|
};
|
||||||
|
|
||||||
/// HoleyBytes virtual memory
|
/// HoleyBytes virtual memory
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
//! Page table and associated structures implementation
|
//! Page table and associated structures implementation
|
||||||
|
|
||||||
use core::{
|
use {
|
||||||
fmt::Debug,
|
core::{
|
||||||
mem::MaybeUninit,
|
fmt::Debug,
|
||||||
ops::{Index, IndexMut},
|
mem::MaybeUninit,
|
||||||
slice::SliceIndex,
|
ops::{Index, IndexMut},
|
||||||
|
slice::SliceIndex,
|
||||||
|
},
|
||||||
|
delegate::delegate,
|
||||||
};
|
};
|
||||||
use delegate::delegate;
|
|
||||||
|
|
||||||
/// Page entry permission
|
/// Page entry permission
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||||
|
@ -30,7 +32,7 @@ pub enum Permission {
|
||||||
pub struct PtEntry(u64);
|
pub struct PtEntry(u64);
|
||||||
impl PtEntry {
|
impl PtEntry {
|
||||||
/// Create new
|
/// Create new
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// - `ptr` has to point to valid data and shall not be deallocated
|
/// - `ptr` has to point to valid data and shall not be deallocated
|
||||||
/// troughout the entry lifetime
|
/// troughout the entry lifetime
|
||||||
|
@ -61,7 +63,6 @@ impl Debug for PtEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Page table
|
/// Page table
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
#[repr(align(4096))]
|
#[repr(align(4096))]
|
||||||
|
@ -145,7 +146,7 @@ impl Default for PageTable {
|
||||||
#[repr(C, align(4096))]
|
#[repr(C, align(4096))]
|
||||||
pub union PtPointedData {
|
pub union PtPointedData {
|
||||||
/// Node - next page table
|
/// Node - next page table
|
||||||
pub pt: PageTable,
|
pub pt: PageTable,
|
||||||
/// Leaf
|
/// Leaf
|
||||||
pub page: u8,
|
pub page: u8,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue