Compare commits
8 commits
master
...
kold/inter
Author | SHA1 | Date | |
---|---|---|---|
7acf2a869f | |||
a658189efe | |||
4b9107c4d6 | |||
6534340a86 | |||
5a9fe9a0bd | |||
4a45c929a1 | |||
f65a5bd79c | |||
2b33a65e6b |
|
@ -1,85 +1,28 @@
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
extern crate syn;
|
extern crate syn;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
proc_macro::TokenStream,
|
proc_macro::TokenStream,
|
||||||
quote::quote,
|
quote::quote,
|
||||||
syn::{parse::Parse, parse_macro_input, Expr, ItemFn, Token}
|
syn::{parse_macro_input, ItemFn}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KtestInput {
|
|
||||||
lhs: Expr,
|
|
||||||
_comma: Token![,],
|
|
||||||
rhs: Expr,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for KtestInput {
|
|
||||||
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
lhs: input.parse()?,
|
|
||||||
_comma: input.parse()?,
|
|
||||||
rhs: input.parse()?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn ktest_eq(item: TokenStream) -> TokenStream {
|
|
||||||
let input = parse_macro_input!(item as KtestInput);
|
|
||||||
|
|
||||||
let lhs = input.lhs;
|
|
||||||
let rhs = input.rhs;
|
|
||||||
|
|
||||||
let out = quote! {
|
|
||||||
if #lhs != #rhs {
|
|
||||||
return Err(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TokenStream::from(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
|
||||||
pub fn ktest_neq(item: TokenStream) -> TokenStream {
|
|
||||||
let input = parse_macro_input!(item as KtestInput);
|
|
||||||
|
|
||||||
let lhs = input.lhs;
|
|
||||||
let rhs = input.rhs;
|
|
||||||
|
|
||||||
let out = quote! {
|
|
||||||
if #lhs == #rhs {
|
|
||||||
return Err(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TokenStream::from(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
let input = parse_macro_input!(item as ItemFn);
|
let input = parse_macro_input!(item as ItemFn);
|
||||||
let test_name = &input.sig.ident;
|
let test_name = &input.sig.ident;
|
||||||
let test_string = test_name.to_string();
|
|
||||||
let static_var_name = syn::Ident::new(
|
let static_var_name = syn::Ident::new(
|
||||||
&format!("__ktest_{}", test_name).to_uppercase(),
|
&format!("__ktest_{}", test_name),
|
||||||
test_name.span(),
|
test_name.span(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let block = &input.block;
|
|
||||||
let out = quote! {
|
let out = quote! {
|
||||||
#[cfg(feature = "ktest")]
|
// #[cfg(feature = "ktest")]
|
||||||
fn #test_name() -> Result<String, String> {
|
#input
|
||||||
use crate::alloc::string::ToString;
|
|
||||||
let name = #test_string.to_string();
|
|
||||||
|
|
||||||
#block
|
// #[cfg(feature = "ktest")]
|
||||||
|
|
||||||
return Ok(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "ktest")]
|
|
||||||
#[unsafe(link_section = ".note.ktest")]
|
#[unsafe(link_section = ".note.ktest")]
|
||||||
#[used]
|
#[used]
|
||||||
pub static #static_var_name: fn() -> Result<String, String> = #test_name;
|
pub static #static_var_name: fn() = #test_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
TokenStream::from(out)
|
TokenStream::from(out)
|
||||||
|
|
|
@ -6,11 +6,6 @@ SECTIONS
|
||||||
.text.boot : { *(.text.boot) }
|
.text.boot : { *(.text.boot) }
|
||||||
.text : { *(.text) }
|
.text : { *(.text) }
|
||||||
.data : { *(.data) }
|
.data : { *(.data) }
|
||||||
.note.ktest : {
|
|
||||||
__ktest_start = .;
|
|
||||||
*(.note.ktest)
|
|
||||||
__ktest_end = .;
|
|
||||||
}
|
|
||||||
.rodata : { *(.rodata) }
|
.rodata : { *(.rodata) }
|
||||||
.bss : {
|
.bss : {
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
|
|
|
@ -83,31 +83,33 @@ extern "x86-interrupt" fn spurious(_: InterruptStackFrame) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
fn interrupt(interrupt_type: Interrupt) {
|
fn interrupt(interrupt_type: Interrupt) {
|
||||||
use crate::{arch::INTERRUPT_LIST, kmain::EXECUTOR};
|
use crate::arch::INTERRUPT_LIST;
|
||||||
// let il = INTERRUPT_LIST.lock();
|
use crate::kmain::EXECUTOR;
|
||||||
// let val = il.list.get(&interrupt_type).unwrap();
|
let il = INTERRUPT_LIST.lock();
|
||||||
|
let val = il.list.get(&interrupt_type).unwrap();
|
||||||
|
|
||||||
// use crate::holeybytes::kernel_services::service_definition_service::sds_search_service;
|
use crate::holeybytes::kernel_services::service_definition_service::sds_search_service;
|
||||||
// let buffer = sds_search_service(val);
|
let buffer = sds_search_service(val);
|
||||||
// if buffer != 0 {
|
if buffer != 0 {
|
||||||
// use {crate::kmain::IPC_BUFFERS, alloc::vec::Vec};
|
use {crate::kmain::IPC_BUFFERS, alloc::vec::Vec};
|
||||||
// let mut buffs = IPC_BUFFERS.lock();
|
let mut buffs = IPC_BUFFERS.lock();
|
||||||
// match buffs.get_mut(&buffer) {
|
match buffs.get_mut(&buffer) {
|
||||||
// Some(buff) => {
|
Some(buff) => {
|
||||||
// let mut msg_vec = Vec::new();
|
let mut msg_vec = Vec::new();
|
||||||
// msg_vec.push(0xFF);
|
msg_vec.push(0xFF);
|
||||||
// buff.push(msg_vec.to_vec());
|
buff.push(msg_vec.to_vec());
|
||||||
// log::debug!("Sent Message {:?} to Buffer({})", msg_vec, buffer);
|
log::debug!("Sent Message {:?} to Buffer({})", msg_vec, buffer);
|
||||||
// }
|
}
|
||||||
// None => {
|
None => {
|
||||||
// log::error!("Access of non-existent buffer {}", buffer)
|
log::error!("Access of non-existent buffer {}", buffer)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
unsafe {
|
// log::info!("{}", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe{
|
||||||
EXECUTOR.send_interrupt(interrupt_type as u8);
|
EXECUTOR.send_interrupt(interrupt_type as u8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! Environment call handling routines
|
//! Environment call handling routines
|
||||||
|
|
||||||
|
use log::log;
|
||||||
|
|
||||||
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
use {alloc::boxed::Box, core::cell::LazyCell, hbvm::mem::Address};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -80,10 +82,6 @@ pub fn handler(vm: &mut Vm, pid: &usize) {
|
||||||
let length = vm.registers[5].cast::<u64>() as usize;
|
let length = vm.registers[5].cast::<u64>() as usize;
|
||||||
trace!("IPC address: {:?}", mem_addr);
|
trace!("IPC address: {:?}", mem_addr);
|
||||||
|
|
||||||
unsafe { LazyCell::<Executor>::get_mut(&mut EXECUTOR) }
|
|
||||||
.unwrap()
|
|
||||||
.send_buffer(buffer_id as usize);
|
|
||||||
|
|
||||||
match buffer_id {
|
match buffer_id {
|
||||||
0 => match sds_msg_handler(vm, mem_addr, length) {
|
0 => match sds_msg_handler(vm, mem_addr, length) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
|
@ -246,26 +244,13 @@ pub fn handler(vm: &mut Vm, pid: &usize) {
|
||||||
vm.registers[3] = x
|
vm.registers[3] = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6 => {
|
6 => { // Wait till interrupt
|
||||||
// Wait till interrupt
|
|
||||||
use crate::kmain::EXECUTOR;
|
use crate::kmain::EXECUTOR;
|
||||||
let interrupt_type = vm.registers[3].cast::<u8>();
|
let interrupt_type = vm.registers[3].cast::<u8>();
|
||||||
debug!("Interrupt subscribed: {}", interrupt_type);
|
info!("Interrupt subscribled: {}", interrupt_type);
|
||||||
unsafe {
|
unsafe{
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
EXECUTOR.pause(pid.clone());
|
||||||
.unwrap()
|
LazyCell::<Executor>::get_mut(&mut EXECUTOR).unwrap().interrupt_subscribe(pid.clone(), interrupt_type);
|
||||||
.interrupt_subscribe(*pid, interrupt_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7 => {
|
|
||||||
// Wait till buffer
|
|
||||||
use crate::kmain::EXECUTOR;
|
|
||||||
let buffer_id = vm.registers[3].cast::<u64>() as usize;
|
|
||||||
debug!("Buffer subscribed: {}", buffer_id);
|
|
||||||
unsafe {
|
|
||||||
LazyCell::<Executor>::get_mut(&mut EXECUTOR)
|
|
||||||
.unwrap()
|
|
||||||
.buffer_subscribe(*pid, buffer_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -24,11 +24,8 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
|
||||||
|
|
||||||
#[cfg(feature = "ktest")]
|
#[cfg(feature = "ktest")]
|
||||||
{
|
{
|
||||||
use {
|
use crate::ktest;
|
||||||
crate::ktest,
|
debug!("TESTING");
|
||||||
log::info,
|
|
||||||
};
|
|
||||||
info!("Running tests");
|
|
||||||
ktest::test_main();
|
ktest::test_main();
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|
|
@ -1,51 +1,38 @@
|
||||||
pub use ktest_macro::*;
|
pub use ktest_macro::ktest;
|
||||||
|
use log::debug;
|
||||||
use {
|
|
||||||
alloc::string::String,
|
|
||||||
log::{error, info},
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static __ktest_start: fn() -> Result<String, String>;
|
static __ktest_start: fn();
|
||||||
static __ktest_end: fn() -> Result<String, String>;
|
static __ktest_end: fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement ktest for arm and riscv (Later problems, see below)
|
// TODO: Get test_fn linker name (may require no_mangle in macro)
|
||||||
|
// More info on tests (run the rest even if panic)
|
||||||
|
// Implement ktest for arm and riscv (Later problems, see below)
|
||||||
// Allow for arch specific tests (Leave for now)
|
// Allow for arch specific tests (Leave for now)
|
||||||
// Should panic tests
|
// Allow for ktest test name attr
|
||||||
// Test specific panic handler
|
// Usefull message at the end of testing
|
||||||
pub fn test_main() {
|
pub fn test_main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut current_test = &__ktest_start as *const fn() -> Result<String, String>;
|
let mut current_test = &__ktest_start as *const fn();
|
||||||
let test_end = &__ktest_end as *const fn() -> Result<String, String>;
|
let mut current = 1;
|
||||||
|
let test_end = &__ktest_end as *const fn();
|
||||||
let mut pass = 0;
|
|
||||||
let mut fail = 0;
|
|
||||||
|
|
||||||
while current_test < test_end {
|
while current_test < test_end {
|
||||||
let test_fn = *current_test;
|
let test_fn = *current_test;
|
||||||
|
|
||||||
let test_name = test_fn();
|
debug!("Running test {}", current);
|
||||||
match test_name {
|
|
||||||
Ok(name) => {
|
test_fn();
|
||||||
info!("Test: {} passed", name);
|
debug!("Test {} passed", current);
|
||||||
pass += 1;
|
|
||||||
},
|
|
||||||
Err(name) => {
|
|
||||||
error!("Test: {} failed", name);
|
|
||||||
fail += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_test = current_test.add(1);
|
current_test = current_test.add(1);
|
||||||
|
current += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("{}/{} tests passed", pass, pass + fail);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ktest]
|
#[ktest]
|
||||||
pub fn trivial_assertion() {
|
pub fn trivial_assertion() {
|
||||||
ktest_eq!(1, 1);
|
assert_eq!(1, 1);
|
||||||
ktest_neq!(0, 1);
|
|
||||||
}
|
}
|
|
@ -34,10 +34,10 @@ mod memory;
|
||||||
mod task;
|
mod task;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
#[allow(improper_ctypes, non_upper_case_globals)]
|
// #[cfg(feature = "tests")]
|
||||||
mod ktest;
|
mod ktest;
|
||||||
|
|
||||||
use versioning::Version;
|
use {alloc::string::ToString, versioning::Version};
|
||||||
|
|
||||||
/// Kernel's version
|
/// Kernel's version
|
||||||
pub const VERSION: Version = Version {
|
pub const VERSION: Version = Version {
|
||||||
|
@ -49,7 +49,6 @@ pub const VERSION: Version = Version {
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(target_os = "none")]
|
||||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||||
use alloc::string::ToString;
|
|
||||||
arch::register_dump();
|
arch::register_dump();
|
||||||
|
|
||||||
if let Some(loc) = info.location() {
|
if let Some(loc) = info.location() {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
use {
|
use {
|
||||||
alloc::{
|
alloc::{boxed::Box, sync::Arc},
|
||||||
boxed::Box,
|
|
||||||
collections::{BTreeMap, BTreeSet},
|
|
||||||
sync::Arc,
|
|
||||||
},
|
|
||||||
core::{
|
core::{
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -40,7 +36,6 @@ pub struct Executor {
|
||||||
tasks: Slab<Task>,
|
tasks: Slab<Task>,
|
||||||
task_queue: Arc<SegQueue<usize>>,
|
task_queue: Arc<SegQueue<usize>>,
|
||||||
interrupt_lookup: [Option<usize>; u8::MAX as usize],
|
interrupt_lookup: [Option<usize>; u8::MAX as usize],
|
||||||
buffer_lookup: BTreeMap<usize, BTreeSet<usize>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Executor {
|
impl Executor {
|
||||||
|
@ -49,7 +44,6 @@ impl Executor {
|
||||||
tasks: Slab::new(),
|
tasks: Slab::new(),
|
||||||
task_queue: Arc::new(SegQueue::new()),
|
task_queue: Arc::new(SegQueue::new()),
|
||||||
interrupt_lookup: [None; u8::MAX as usize],
|
interrupt_lookup: [None; u8::MAX as usize],
|
||||||
buffer_lookup: BTreeMap::new(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,20 +67,10 @@ impl Executor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn interrupt_subscribe(&mut self, pid: usize, interrupt_type: u8) {
|
pub fn interrupt_subscribe(&mut self, pid : usize, interrupt_type: u8){
|
||||||
self.pause(pid);
|
|
||||||
self.interrupt_lookup[interrupt_type as usize] = Some(pid);
|
self.interrupt_lookup[interrupt_type as usize] = Some(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_subscribe(&mut self, pid: usize, buffer_id: usize) {
|
|
||||||
self.pause(pid);
|
|
||||||
if let Some(buf) = self.buffer_lookup.get_mut(&buffer_id) {
|
|
||||||
buf.insert(pid);
|
|
||||||
} else {
|
|
||||||
self.buffer_lookup.insert(buffer_id, BTreeSet::from([pid]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
let mut task_batch = [0; 32];
|
let mut task_batch = [0; 32];
|
||||||
loop {
|
loop {
|
||||||
|
@ -101,7 +85,7 @@ impl Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if batch_len == 0 {
|
if batch_len == 0 {
|
||||||
// break;
|
//break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,34 +100,26 @@ impl Executor {
|
||||||
|
|
||||||
if let Poll::Ready(()) = task.poll(&mut cx) {
|
if let Poll::Ready(()) = task.poll(&mut cx) {
|
||||||
self.tasks.remove(id);
|
self.tasks.remove(id);
|
||||||
self.interrupt_lookup.map(|pid| {
|
self.interrupt_lookup.map(|pid|{
|
||||||
if let Some(pid) = pid {
|
if let Some(pid) = pid{
|
||||||
if pid == id {
|
if pid == id {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pid;
|
return pid;
|
||||||
});
|
});
|
||||||
self.buffer_lookup.iter_mut().for_each(|(_, pid_set)| {
|
|
||||||
pid_set.remove(&id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_interrupt(&self, interrupt: u8) {
|
pub fn send_interrupt(&self, interrupt : u8){
|
||||||
let id = self.interrupt_lookup[interrupt as usize];
|
let id = self.interrupt_lookup[interrupt as usize];
|
||||||
if let Some(id) = id {
|
if let Some(id) = id{
|
||||||
self.unpause(id);
|
self.unpause(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn send_buffer(&self, id: usize) {
|
|
||||||
if let Some(buf) = self.buffer_lookup.get(&id) {
|
|
||||||
buf.iter().for_each(|pid| self.unpause(*pid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
string := @use("string.hb")
|
string := @use("string.hb")
|
||||||
|
|
||||||
$await := fn(buffer_id: uint): void {
|
|
||||||
return @eca(7, buffer_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
$recv := fn($Expr: type, buffer_id: uint, memory_map_location: ^Expr): void {
|
$recv := fn($Expr: type, buffer_id: uint, memory_map_location: ^Expr): void {
|
||||||
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
|
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ random := @use("random.hb")
|
||||||
file := @use("file_io.hb")
|
file := @use("file_io.hb")
|
||||||
dt := @use("dt.hb")
|
dt := @use("dt.hb")
|
||||||
process := @use("process.hb")
|
process := @use("process.hb")
|
||||||
sleep := @use("sleep.hb")
|
|
||||||
|
|
||||||
panic := fn(message: ?^u8): never {
|
panic := fn(message: ?^u8): never {
|
||||||
log.error("Error: Panic Called, Message:\0")
|
log.error("Error: Panic Called, Message:\0")
|
||||||
|
|
|
@ -48,8 +48,6 @@ await_channel := fn(): Channel {
|
||||||
await_message := fn($Expr: type, buffer_id: uint): Message(Expr) {
|
await_message := fn($Expr: type, buffer_id: uint): Message(Expr) {
|
||||||
response := @as(?Message(Expr), null)
|
response := @as(?Message(Expr), null)
|
||||||
loop {
|
loop {
|
||||||
// awaiting here causes flickering... idk why
|
|
||||||
buffer.await(buffer_id)
|
|
||||||
buffer.recv(?Message(Expr), buffer_id, &response)
|
buffer.recv(?Message(Expr), buffer_id, &response)
|
||||||
if response != null {
|
if response != null {
|
||||||
return @as(Message(Expr), response)
|
return @as(Message(Expr), response)
|
||||||
|
@ -60,11 +58,9 @@ await_message := fn($Expr: type, buffer_id: uint): Message(Expr) {
|
||||||
await_header := fn(buffer_id: uint): MessageHeader {
|
await_header := fn(buffer_id: uint): MessageHeader {
|
||||||
response := @as(?MessageHeader, null)
|
response := @as(?MessageHeader, null)
|
||||||
loop {
|
loop {
|
||||||
// awaiting here causes flickering... idk why
|
|
||||||
buffer.await(buffer_id)
|
|
||||||
buffer.recv(?MessageHeader, buffer_id, &response)
|
buffer.recv(?MessageHeader, buffer_id, &response)
|
||||||
if response != null {
|
if response != null {
|
||||||
return @as(MessageHeader, response)
|
return @as(?MessageHeader, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
sysdata/programs/alloc_test/README.md
Normal file
1
sysdata/programs/alloc_test/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# alloc_test
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "test"
|
name = "alloc_test"
|
||||||
authors = ["koniifer", "able"]
|
authors = [""]
|
||||||
|
|
||||||
[dependants.libraries]
|
[dependants.libraries]
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
stn := @use("../../../../../libraries/stn/src/lib.hb");
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||||
.{allocators, panic, log} := stn
|
.{allocators, panic, log} := stn
|
||||||
|
|
||||||
AStruct := struct {
|
AStruct := struct {
|
||||||
a_field: u8,
|
a_field: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
test := fn(): uint {
|
main := fn(): void {
|
||||||
// alloc := allocators.FakeAlloc.init()
|
// alloc := allocators.FakeAlloc.init()
|
||||||
// astruct := alloc.alloc(AStruct, 2)
|
// astruct := alloc.alloc(AStruct, 2)
|
||||||
// if astruct.ptr != null{
|
// if astruct.ptr != null{
|
||||||
|
@ -26,5 +26,5 @@ test := fn(): uint {
|
||||||
// log.info("Allocator functioned.\0")
|
// log.info("Allocator functioned.\0")
|
||||||
// }
|
// }
|
||||||
// balloc.dealloc(bstruct_ptr, AStruct, 2)
|
// balloc.dealloc(bstruct_ptr, AStruct, 2)
|
||||||
return 0
|
return
|
||||||
}
|
}
|
1
sysdata/programs/dt_buffer_test/README.md
Normal file
1
sysdata/programs/dt_buffer_test/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# dt_buffer_test
|
11
sysdata/programs/dt_buffer_test/meta.toml
Normal file
11
sysdata/programs/dt_buffer_test/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "dt_buffer_test"
|
||||||
|
authors = ["able"]
|
||||||
|
|
||||||
|
[dependants.libraries]
|
||||||
|
|
||||||
|
[dependants.binaries]
|
||||||
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "hblang src/main.hb"
|
13
sysdata/programs/dt_buffer_test/src/main.hb
Normal file
13
sysdata/programs/dt_buffer_test/src/main.hb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
.{dt} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
main := fn(): void {
|
||||||
|
dt.get(void, "framebuffer/fb0/width\0")
|
||||||
|
dt.get(void, "cpu/cpu0/architecture\0")
|
||||||
|
|
||||||
|
// Checking if the first detected serial port is memory mapped or port mapped
|
||||||
|
// 0 -> memory mapped
|
||||||
|
// 1 -> port mapped
|
||||||
|
dt.get(void, "serial_ports/sp0/mapping\0")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
11
sysdata/programs/hash_test/meta.toml
Normal file
11
sysdata/programs/hash_test/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "hash_test"
|
||||||
|
authors = [""]
|
||||||
|
|
||||||
|
[dependants.libraries]
|
||||||
|
|
||||||
|
[dependants.binaries]
|
||||||
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "hblang src/main.hb"
|
|
@ -1,6 +1,6 @@
|
||||||
.{hashers, log, memory, string} := @use("../../../../../libraries/stn/src/lib.hb")
|
.{hashers, log, memory, string} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
test := fn(): uint {
|
main := fn(): void {
|
||||||
buffer := memory.request_page(1)
|
buffer := memory.request_page(1)
|
||||||
target := "abcdefghijklmnop\0"
|
target := "abcdefghijklmnop\0"
|
||||||
strings := [^u8].("abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0")
|
strings := [^u8].("abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0")
|
||||||
|
@ -28,5 +28,4 @@ test := fn(): uint {
|
||||||
log.debug(string.display_int(@bitcast(d), buffer, 16))
|
log.debug(string.display_int(@bitcast(d), buffer, 16))
|
||||||
string.clear(buffer)
|
string.clear(buffer)
|
||||||
}
|
}
|
||||||
return 0
|
|
||||||
}
|
}
|
11
sysdata/programs/processes/meta.toml
Normal file
11
sysdata/programs/processes/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "processes"
|
||||||
|
authors = ["koniifer"]
|
||||||
|
|
||||||
|
[dependants.libraries]
|
||||||
|
|
||||||
|
[dependants.binaries]
|
||||||
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "hblang src/main.hb"
|
|
@ -1,8 +1,8 @@
|
||||||
.{process, log, string, memory} := @use("../../../../../libraries/stn/src/lib.hb")
|
.{process, log, string, memory} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
exe := @embed("./assets/hello_world_and_spin.hbf")
|
exe := @embed("./hello_world_and_spin.hbf")
|
||||||
|
|
||||||
test := fn(): uint {
|
main := fn(): void {
|
||||||
buf := "\0\0\0\0\0\0\0"
|
buf := "\0\0\0\0\0\0\0"
|
||||||
loop {
|
loop {
|
||||||
log.info(
|
log.info(
|
||||||
|
@ -16,5 +16,4 @@ test := fn(): uint {
|
||||||
i := 0
|
i := 0
|
||||||
loop if i == 1000000 break else i += 1
|
loop if i == 1000000 break else i += 1
|
||||||
}
|
}
|
||||||
return 0
|
|
||||||
}
|
}
|
11
sysdata/programs/serial_driver_test/meta.toml
Normal file
11
sysdata/programs/serial_driver_test/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "serial_driver_test"
|
||||||
|
authors = ["able"]
|
||||||
|
|
||||||
|
[dependants.libraries]
|
||||||
|
|
||||||
|
[dependants.binaries]
|
||||||
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "hblang src/main.hb"
|
20
sysdata/programs/serial_driver_test/src/main.hb
Normal file
20
sysdata/programs/serial_driver_test/src/main.hb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
.{string, buffer} := @use("../../../libraries/stn/src/lib.hb")
|
||||||
|
|
||||||
|
log_info := fn(): void {
|
||||||
|
a := buffer.search("XNumber\0")
|
||||||
|
if a == 0 {
|
||||||
|
} else {
|
||||||
|
msg := "XABC\0"
|
||||||
|
// inline is broked
|
||||||
|
// msg_length := @inline(string.length, msg)
|
||||||
|
msg_length := 5
|
||||||
|
@as(void, @eca(3, a, msg, msg_length))
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
log_info()
|
||||||
|
return 0
|
||||||
|
}
|
|
@ -91,8 +91,8 @@ main := fn(): int {
|
||||||
|
|
||||||
// Mouse cursor
|
// Mouse cursor
|
||||||
{
|
{
|
||||||
render.put_filled_circle(screen, .(mouse_x, mouse_y), 10, sunset.server.DECO_COLOUR_DARKER)
|
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), sunset.server.DECO_COLOUR_DARKER)
|
||||||
render.put_circle(screen, .(mouse_x, mouse_y), 10, sunset.server.DECO_COLOUR)
|
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), sunset.server.DECO_COLOUR)
|
||||||
}
|
}
|
||||||
|
|
||||||
render.sync(screen)
|
render.sync(screen)
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
stn := @use("./tests/stn/lib.hb")
|
|
||||||
serial_driver := @use("./tests/serial_driver.hb")
|
|
||||||
|
|
||||||
main := fn(): uint {
|
|
||||||
// return serial_driver.test()
|
|
||||||
return stn.sleep.test()
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
.{string, buffer} := @use("../../../../libraries/stn/src/lib.hb")
|
|
||||||
|
|
||||||
log_info := fn(): void {
|
|
||||||
a := buffer.search("XNumber\0")
|
|
||||||
if a == 0 {
|
|
||||||
} else {
|
|
||||||
msg := "XABC\0"
|
|
||||||
msg_length := string.length(msg)
|
|
||||||
@eca(3, a, msg, msg_length)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
test := fn(): uint {
|
|
||||||
log_info()
|
|
||||||
return 0
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
.{dt, memory, string, log} := @use("../../../../../libraries/stn/src/lib.hb")
|
|
||||||
|
|
||||||
test := fn(): uint {
|
|
||||||
buffer := memory.request_page(1)
|
|
||||||
|
|
||||||
log.info(string.display_int(dt.get(int, "framebuffer/fb0/width\0"), buffer, 10))
|
|
||||||
string.clear(buffer)
|
|
||||||
|
|
||||||
log.info(string.display_int(dt.get(int, "cpu/cpu0/architecture\0"), buffer, 10))
|
|
||||||
string.clear(buffer)
|
|
||||||
|
|
||||||
// 0 -> memory mapped
|
|
||||||
// 1 -> port mapped
|
|
||||||
|
|
||||||
log.info(string.display_int(dt.get(int, "serial_ports/sp0/mapping\0"), buffer, 10))
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
hashers := @use("./hashers.hb")
|
|
||||||
allocators := @use("./allocators.hb")
|
|
||||||
sleep := @use("./sleep.hb")
|
|
||||||
dt := @use("./dt.hb")
|
|
||||||
process := @use("./process.hb")
|
|
|
@ -1,8 +0,0 @@
|
||||||
.{sleep, log} := @use("../../../../../libraries/stn/src/lib.hb")
|
|
||||||
|
|
||||||
test := fn(): uint {
|
|
||||||
log.info("BEFORE\0")
|
|
||||||
sleep.sleep_until_interrupt(32)
|
|
||||||
log.info("AFTER\0")
|
|
||||||
return 0
|
|
||||||
}
|
|
11
sysdata/programs/timer_test/meta.toml
Normal file
11
sysdata/programs/timer_test/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "timer_test"
|
||||||
|
authors = ["Talha Qamar"]
|
||||||
|
|
||||||
|
[dependants.libraries]
|
||||||
|
|
||||||
|
[dependants.binaries]
|
||||||
|
hblang.version = "1.0.0"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "hblang src/main.hb"
|
8
sysdata/programs/timer_test/src/main.hb
Normal file
8
sysdata/programs/timer_test/src/main.hb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
sleep := @use("../../../libraries/stn/src/sleep.hb")
|
||||||
|
log := @use("../../../libraries/stn/src/log.hb")
|
||||||
|
|
||||||
|
main := fn(): int {
|
||||||
|
log.info("BEFORE\0")
|
||||||
|
sleep.sleep_until_interrupt(32)
|
||||||
|
log.info("AFTER\0")
|
||||||
|
}
|
|
@ -28,26 +28,32 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.horizon]
|
# [boot.limine.ableos.modules.horizon]
|
||||||
# path = "boot:///horizon.hbf"
|
# path = "boot:///horizon.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.ps2_mouse_driver]
|
# path = "boot:///ps2_mouse_driver.hbf"
|
||||||
path = "boot:///ps2_mouse_driver.hbf"
|
# [boot.limine.ableos.modules.ps2_mouse_driver]
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.sunset_client]
|
[boot.limine.ableos.modules.timer_test]
|
||||||
path = "boot:///sunset_client.hbf"
|
path = "boot:///timer_test.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.sunset_client_2]
|
|
||||||
path = "boot:///sunset_client_2.hbf"
|
|
||||||
|
|
||||||
|
# [boot.limine.ableos.modules.sunset_client]
|
||||||
|
# path = "boot:///sunset_client.hbf"
|
||||||
|
#
|
||||||
|
# [boot.limine.ableos.modules.sunset_client_2]
|
||||||
|
# path = "boot:///sunset_client_2.hbf"
|
||||||
|
#
|
||||||
# [boot.limine.ableos.modules.sdoom]
|
# [boot.limine.ableos.modules.sdoom]
|
||||||
# path = "boot:///sdoom.hbf"
|
# path = "boot:///sdoom.hbf"
|
||||||
|
#
|
||||||
[boot.limine.ableos.modules.sunset_server]
|
# [boot.limine.ableos.modules.sunset_server]
|
||||||
path = "boot:///sunset_server.hbf"
|
# path = "boot:///sunset_server.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.pcspkr]
|
# [boot.limine.ableos.modules.pcspkr]
|
||||||
# path = "boot:///pcspkr.hbf"
|
# path = "boot:///pcspkr.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.test]
|
# [boot.limine.ableos.modules.alloc_test]
|
||||||
# path = "boot:///test.hbf"
|
# path = "boot:///alloc_test.hbf"
|
||||||
|
|
||||||
|
# [boot.limine.ableos.modules.hash_test]
|
||||||
|
# path = "boot:///hash_test.hbf"
|
||||||
|
|
Loading…
Reference in a new issue