breaking changes

This commit is contained in:
Able 2021-11-23 05:53:06 -06:00
parent 5ced36a916
commit 26a553083c
16 changed files with 153 additions and 26 deletions

View file

@ -6,11 +6,11 @@ on:
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
@ -18,5 +18,5 @@ jobs:
components: rust-src
- uses: actions-rs/cargo@v1
with:
command: build
args: --release
command: repbuild
args: run

34
ableos/Cargo.lock generated
View file

@ -9,6 +9,7 @@ dependencies = [
"bootloader",
"cpuio",
"lazy_static",
"linked_list_allocator",
"pic8259",
"psp",
"spin",
@ -60,6 +61,24 @@ dependencies = [
"spin",
]
[[package]]
name = "linked_list_allocator"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "549ce1740e46b291953c4340adcd74c59bcf4308f4cac050fd33ba91b7168f4a"
dependencies = [
"spinning_top",
]
[[package]]
name = "lock_api"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
dependencies = [
"scopeguard",
]
[[package]]
name = "num_enum"
version = "0.5.4"
@ -145,12 +164,27 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "spinning_top"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75adad84ee84b521fb2cca2d4fd0f1dab1d8d026bda3c5bea4ca63b5f9f9293c"
dependencies = [
"lock_api",
]
[[package]]
name = "syn"
version = "1.0.81"

View file

@ -15,11 +15,15 @@ run-args=["-serial", "stdio"]
[dependencies]
spin = "0.5.2"
linked_list_allocator = "0.9.0"
[dependencies.lazy_static]
features = ["spin_no_std"]
version = "1.0"
# [dependencies.rhai]
# version = "*"
# features = ["no_std"]

View file

@ -88,7 +88,7 @@
86-v
87-w
88-x
89-
89-y
90-z
91-
92-

View file

@ -0,0 +1,14 @@
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
pub struct Dummy;
unsafe impl GlobalAlloc for Dummy {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}

View file

@ -0,0 +1,24 @@
use alloc::alloc::{GlobalAlloc, Layout};
// use core::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
// mod dummy;
// use dummy::Dummy;
pub const HEAP_START: usize = 0x_4444_4444_0000;
/// 131072 bytes
pub const HEAP_MULTIPLIER: usize = 1024;
pub const HEAP_BASE: usize = 100;
pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;
// X86 alloc should be in arch/drivers/x86/alloc.rs
use crate::arch::drivers::allocator::Dummy;
#[global_allocator]
static ALLOCATOR: Dummy = Dummy;
#[alloc_error_handler]
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
panic!("allocation error: {:?}", layout)
}

View file

@ -32,19 +32,19 @@ pub extern "C" fn not_main() {
ptr::write_volatile(UART0, *byte);
}
}
let gpios = Pins::take();
let mut led = gpios.p0_31;
loop {
led.set_high();
delay(2_000_000);
led.set_low();
delay(6_000_000);
}
led.set_push_pull_output(Level::Low);
//
// let gpios = Pins::take();
// let mut led = gpios.p0_31;
//
// loop {
// led.set_high();
// delay(2_000_000);
//
// led.set_low();
// delay(6_000_000);
// }
//
// led.set_push_pull_output(Level::Low);
crate::kmain::kernel_main();
sloop();

View file

@ -29,10 +29,11 @@ unsafe extern "C" fn _boot() -> ! {
",
sym _start, options(noreturn));
}
use crate::serial::SERIAL;
extern "C" fn _start() -> ! {
SERIAL.lock().out(format_args!("Hi"));
// Serial123::out();
sloop()
}

View file

@ -0,0 +1,15 @@
use alloc::alloc::{GlobalAlloc, Layout};
// use core::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
pub struct Dummy;
unsafe impl GlobalAlloc for Dummy {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}

View file

@ -1,5 +1,5 @@
pub mod allocator;
pub mod graphics;
pub mod serial;
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
pub mod vga;

View file

@ -30,7 +30,7 @@ Memory: {}
);
return x;
}
*/
// */
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(debug_assertions)]
/// A constant to check if the kernel is in debug mode

View file

@ -130,24 +130,32 @@ macro_rules! keycode_enum {
keycode_enum! {
AltLeft = 0x00,
AltRight = 0x01,
ArrowDown = 0x02,
ArrowLeft = 0x03,
ArrowRight = 0x04,
ArrowUp = 0x05,
BackSlash = 0x06,
Backspace = 0x07,
BackTick = 0x08,
BracketSquareLeft = 0x09,
BracketSquareRight = 0x0A,
CapsLock = 0x0B,
Comma = 0x0C,
ControlLeft = 0x0D,
ControlRight = 0x0E,
Delete = 0x0F,
End = 0x10,
Enter = 0x11,
Escape = 0x12,
Equals = 0x13,
F1 = 0x14,
F2 = 0x15,
F3 = 0x16,
@ -160,9 +168,13 @@ keycode_enum! {
F10 = 0x1D,
F11 = 0x1E,
F12 = 0x1F,
Fullstop = 0x20,
Home = 0x21,
Insert = 0x22,
Key1 = 0x23,
Key2 = 0x24,
Key3 = 0x25,
@ -173,8 +185,11 @@ keycode_enum! {
Key8 = 0x2A,
Key9 = 0x2B,
Key0 = 0x2C,
Menus = 0x2D,
Minus = 0x2E,
Numpad0 = 0x2F,
Numpad1 = 0x30,
Numpad2 = 0x31,
@ -185,6 +200,7 @@ keycode_enum! {
Numpad7 = 0x36,
Numpad8 = 0x37,
Numpad9 = 0x38,
NumpadEnter = 0x39,
NumpadLock = 0x3A,
NumpadSlash = 0x3B,
@ -192,20 +208,25 @@ keycode_enum! {
NumpadMinus = 0x3D,
NumpadPeriod = 0x3E,
NumpadPlus = 0x3F,
PageDown = 0x40,
PageUp = 0x41,
PauseBreak = 0x42,
PrintScreen = 0x43,
ScrollLock = 0x44,
SemiColon = 0x45,
ShiftLeft = 0x46,
ShiftRight = 0x47,
Slash = 0x48,
Spacebar = 0x49,
Tab = 0x4A,
Quote = 0x4B,
WindowsLeft = 0x4C,
WindowsRight = 0x4D,
A = 0x4E,
B = 0x4F,
C = 0x50,
@ -232,15 +253,21 @@ keycode_enum! {
X = 0x65,
Y = 0x66,
Z = 0x67,
HashTilde = 0x68,
PrevTrack = 0x69,
NextTrack = 0x6A,
Mute = 0x6B,
Calculator = 0x6C,
Play = 0x6D,
Stop = 0x6E,
VolumeDown = 0x6F,
VolumeUp = 0x70,
WWWHome = 0x71,
PowerOnTestOk = 0x72,
}

View file

@ -29,11 +29,17 @@ pub extern "C" fn kernel_main() {
GraphicsBuffer::show_cursor();
seed_rng();
{
use alloc::{vec, vec::Vec};
let x: Vec<u8> = vec![1];
println!("{:?}", x);
}
/* If AES is present then AES init rng as well
// Maybe via a cfg
AES::init_rng();
*/
*/
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);

View file

@ -4,6 +4,7 @@
#![feature(
abi_x86_interrupt,
asm,
alloc_error_handler,
core_intrinsics,
global_asm,
lang_items,
@ -27,7 +28,6 @@ pub mod arch;
pub mod print;
use arch::drivers::serial;
pub mod driver_traits;
pub mod experiments;
pub mod keyboard;
@ -36,3 +36,7 @@ pub mod panic;
pub mod relib;
use experiments::server;
extern crate alloc;
pub mod allocator;

View file

@ -1,6 +1,5 @@
pub struct Stdout;
use core::fmt::Arguments;
use core::fmt::Error;
use core::fmt::{Arguments, Error};
impl Stdout {
pub fn write_fmt(&mut self, arg: Arguments<'_>) /*-> Result<(), Error> */
{

View file

@ -21,7 +21,6 @@ enum Command {
#[derive(clap::ArgEnum, Debug, Clone)]
enum MachineType {
X86,
/// hi
RISCV,
ARM,
}