forked from koniifer/ableos
breaking changes
This commit is contained in:
parent
5ced36a916
commit
26a553083c
8
.github/workflows/rust.yml
vendored
8
.github/workflows/rust.yml
vendored
|
@ -6,11 +6,11 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
|
@ -18,5 +18,5 @@ jobs:
|
||||||
components: rust-src
|
components: rust-src
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: repbuild
|
||||||
args: --release
|
args: run
|
||||||
|
|
34
ableos/Cargo.lock
generated
34
ableos/Cargo.lock
generated
|
@ -9,6 +9,7 @@ dependencies = [
|
||||||
"bootloader",
|
"bootloader",
|
||||||
"cpuio",
|
"cpuio",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"linked_list_allocator",
|
||||||
"pic8259",
|
"pic8259",
|
||||||
"psp",
|
"psp",
|
||||||
"spin",
|
"spin",
|
||||||
|
@ -60,6 +61,24 @@ dependencies = [
|
||||||
"spin",
|
"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]]
|
[[package]]
|
||||||
name = "num_enum"
|
name = "num_enum"
|
||||||
version = "0.5.4"
|
version = "0.5.4"
|
||||||
|
@ -145,12 +164,27 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
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]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.81"
|
version = "1.0.81"
|
||||||
|
|
|
@ -15,11 +15,15 @@ run-args=["-serial", "stdio"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
spin = "0.5.2"
|
spin = "0.5.2"
|
||||||
|
linked_list_allocator = "0.9.0"
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
[dependencies.lazy_static]
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [dependencies.rhai]
|
# [dependencies.rhai]
|
||||||
# version = "*"
|
# version = "*"
|
||||||
# features = ["no_std"]
|
# features = ["no_std"]
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
86-v
|
86-v
|
||||||
87-w
|
87-w
|
||||||
88-x
|
88-x
|
||||||
89-
|
89-y
|
||||||
90-z
|
90-z
|
||||||
91-
|
91-
|
||||||
92-
|
92-
|
||||||
|
|
14
ableos/src/allocator/dummy.rs
Normal file
14
ableos/src/allocator/dummy.rs
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
24
ableos/src/allocator/mod.rs
Normal file
24
ableos/src/allocator/mod.rs
Normal 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)
|
||||||
|
}
|
|
@ -32,19 +32,19 @@ pub extern "C" fn not_main() {
|
||||||
ptr::write_volatile(UART0, *byte);
|
ptr::write_volatile(UART0, *byte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
let gpios = Pins::take();
|
// let gpios = Pins::take();
|
||||||
let mut led = gpios.p0_31;
|
// let mut led = gpios.p0_31;
|
||||||
|
//
|
||||||
loop {
|
// loop {
|
||||||
led.set_high();
|
// led.set_high();
|
||||||
delay(2_000_000);
|
// delay(2_000_000);
|
||||||
|
//
|
||||||
led.set_low();
|
// led.set_low();
|
||||||
delay(6_000_000);
|
// delay(6_000_000);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
led.set_push_pull_output(Level::Low);
|
// led.set_push_pull_output(Level::Low);
|
||||||
crate::kmain::kernel_main();
|
crate::kmain::kernel_main();
|
||||||
|
|
||||||
sloop();
|
sloop();
|
||||||
|
|
|
@ -29,10 +29,11 @@ unsafe extern "C" fn _boot() -> ! {
|
||||||
",
|
",
|
||||||
sym _start, options(noreturn));
|
sym _start, options(noreturn));
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::serial::SERIAL;
|
use crate::serial::SERIAL;
|
||||||
|
|
||||||
extern "C" fn _start() -> ! {
|
extern "C" fn _start() -> ! {
|
||||||
SERIAL.lock().out(format_args!("Hi"));
|
SERIAL.lock().out(format_args!("Hi"));
|
||||||
// Serial123::out();
|
|
||||||
sloop()
|
sloop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
ableos/src/arch/x86_64/drivers/allocator.rs
Normal file
15
ableos/src/arch/x86_64/drivers/allocator.rs
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
|
pub mod allocator;
|
||||||
pub mod graphics;
|
pub mod graphics;
|
||||||
pub mod serial;
|
pub mod serial;
|
||||||
|
|
||||||
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
|
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
|
||||||
pub mod vga;
|
pub mod vga;
|
||||||
|
|
|
@ -30,7 +30,7 @@ Memory: {}
|
||||||
);
|
);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
*/
|
// */
|
||||||
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
|
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
/// A constant to check if the kernel is in debug mode
|
/// A constant to check if the kernel is in debug mode
|
||||||
|
|
|
@ -130,24 +130,32 @@ macro_rules! keycode_enum {
|
||||||
keycode_enum! {
|
keycode_enum! {
|
||||||
AltLeft = 0x00,
|
AltLeft = 0x00,
|
||||||
AltRight = 0x01,
|
AltRight = 0x01,
|
||||||
|
|
||||||
ArrowDown = 0x02,
|
ArrowDown = 0x02,
|
||||||
ArrowLeft = 0x03,
|
ArrowLeft = 0x03,
|
||||||
ArrowRight = 0x04,
|
ArrowRight = 0x04,
|
||||||
ArrowUp = 0x05,
|
ArrowUp = 0x05,
|
||||||
|
|
||||||
BackSlash = 0x06,
|
BackSlash = 0x06,
|
||||||
Backspace = 0x07,
|
Backspace = 0x07,
|
||||||
BackTick = 0x08,
|
BackTick = 0x08,
|
||||||
|
|
||||||
BracketSquareLeft = 0x09,
|
BracketSquareLeft = 0x09,
|
||||||
BracketSquareRight = 0x0A,
|
BracketSquareRight = 0x0A,
|
||||||
|
|
||||||
CapsLock = 0x0B,
|
CapsLock = 0x0B,
|
||||||
|
|
||||||
Comma = 0x0C,
|
Comma = 0x0C,
|
||||||
|
|
||||||
ControlLeft = 0x0D,
|
ControlLeft = 0x0D,
|
||||||
ControlRight = 0x0E,
|
ControlRight = 0x0E,
|
||||||
|
|
||||||
Delete = 0x0F,
|
Delete = 0x0F,
|
||||||
End = 0x10,
|
End = 0x10,
|
||||||
Enter = 0x11,
|
Enter = 0x11,
|
||||||
Escape = 0x12,
|
Escape = 0x12,
|
||||||
Equals = 0x13,
|
Equals = 0x13,
|
||||||
|
|
||||||
F1 = 0x14,
|
F1 = 0x14,
|
||||||
F2 = 0x15,
|
F2 = 0x15,
|
||||||
F3 = 0x16,
|
F3 = 0x16,
|
||||||
|
@ -160,9 +168,13 @@ keycode_enum! {
|
||||||
F10 = 0x1D,
|
F10 = 0x1D,
|
||||||
F11 = 0x1E,
|
F11 = 0x1E,
|
||||||
F12 = 0x1F,
|
F12 = 0x1F,
|
||||||
|
|
||||||
Fullstop = 0x20,
|
Fullstop = 0x20,
|
||||||
|
|
||||||
Home = 0x21,
|
Home = 0x21,
|
||||||
|
|
||||||
Insert = 0x22,
|
Insert = 0x22,
|
||||||
|
|
||||||
Key1 = 0x23,
|
Key1 = 0x23,
|
||||||
Key2 = 0x24,
|
Key2 = 0x24,
|
||||||
Key3 = 0x25,
|
Key3 = 0x25,
|
||||||
|
@ -173,8 +185,11 @@ keycode_enum! {
|
||||||
Key8 = 0x2A,
|
Key8 = 0x2A,
|
||||||
Key9 = 0x2B,
|
Key9 = 0x2B,
|
||||||
Key0 = 0x2C,
|
Key0 = 0x2C,
|
||||||
|
|
||||||
Menus = 0x2D,
|
Menus = 0x2D,
|
||||||
|
|
||||||
Minus = 0x2E,
|
Minus = 0x2E,
|
||||||
|
|
||||||
Numpad0 = 0x2F,
|
Numpad0 = 0x2F,
|
||||||
Numpad1 = 0x30,
|
Numpad1 = 0x30,
|
||||||
Numpad2 = 0x31,
|
Numpad2 = 0x31,
|
||||||
|
@ -185,6 +200,7 @@ keycode_enum! {
|
||||||
Numpad7 = 0x36,
|
Numpad7 = 0x36,
|
||||||
Numpad8 = 0x37,
|
Numpad8 = 0x37,
|
||||||
Numpad9 = 0x38,
|
Numpad9 = 0x38,
|
||||||
|
|
||||||
NumpadEnter = 0x39,
|
NumpadEnter = 0x39,
|
||||||
NumpadLock = 0x3A,
|
NumpadLock = 0x3A,
|
||||||
NumpadSlash = 0x3B,
|
NumpadSlash = 0x3B,
|
||||||
|
@ -192,20 +208,25 @@ keycode_enum! {
|
||||||
NumpadMinus = 0x3D,
|
NumpadMinus = 0x3D,
|
||||||
NumpadPeriod = 0x3E,
|
NumpadPeriod = 0x3E,
|
||||||
NumpadPlus = 0x3F,
|
NumpadPlus = 0x3F,
|
||||||
|
|
||||||
PageDown = 0x40,
|
PageDown = 0x40,
|
||||||
PageUp = 0x41,
|
PageUp = 0x41,
|
||||||
|
|
||||||
PauseBreak = 0x42,
|
PauseBreak = 0x42,
|
||||||
PrintScreen = 0x43,
|
PrintScreen = 0x43,
|
||||||
ScrollLock = 0x44,
|
ScrollLock = 0x44,
|
||||||
SemiColon = 0x45,
|
SemiColon = 0x45,
|
||||||
|
|
||||||
ShiftLeft = 0x46,
|
ShiftLeft = 0x46,
|
||||||
ShiftRight = 0x47,
|
ShiftRight = 0x47,
|
||||||
|
|
||||||
Slash = 0x48,
|
Slash = 0x48,
|
||||||
Spacebar = 0x49,
|
Spacebar = 0x49,
|
||||||
Tab = 0x4A,
|
Tab = 0x4A,
|
||||||
Quote = 0x4B,
|
Quote = 0x4B,
|
||||||
WindowsLeft = 0x4C,
|
WindowsLeft = 0x4C,
|
||||||
WindowsRight = 0x4D,
|
WindowsRight = 0x4D,
|
||||||
|
|
||||||
A = 0x4E,
|
A = 0x4E,
|
||||||
B = 0x4F,
|
B = 0x4F,
|
||||||
C = 0x50,
|
C = 0x50,
|
||||||
|
@ -232,15 +253,21 @@ keycode_enum! {
|
||||||
X = 0x65,
|
X = 0x65,
|
||||||
Y = 0x66,
|
Y = 0x66,
|
||||||
Z = 0x67,
|
Z = 0x67,
|
||||||
|
|
||||||
HashTilde = 0x68,
|
HashTilde = 0x68,
|
||||||
|
|
||||||
PrevTrack = 0x69,
|
PrevTrack = 0x69,
|
||||||
NextTrack = 0x6A,
|
NextTrack = 0x6A,
|
||||||
|
|
||||||
Mute = 0x6B,
|
Mute = 0x6B,
|
||||||
|
|
||||||
Calculator = 0x6C,
|
Calculator = 0x6C,
|
||||||
|
|
||||||
Play = 0x6D,
|
Play = 0x6D,
|
||||||
Stop = 0x6E,
|
Stop = 0x6E,
|
||||||
VolumeDown = 0x6F,
|
VolumeDown = 0x6F,
|
||||||
VolumeUp = 0x70,
|
VolumeUp = 0x70,
|
||||||
|
|
||||||
WWWHome = 0x71,
|
WWWHome = 0x71,
|
||||||
PowerOnTestOk = 0x72,
|
PowerOnTestOk = 0x72,
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,17 @@ pub extern "C" fn kernel_main() {
|
||||||
GraphicsBuffer::show_cursor();
|
GraphicsBuffer::show_cursor();
|
||||||
seed_rng();
|
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
|
/* If AES is present then AES init rng as well
|
||||||
// Maybe via a cfg
|
// Maybe via a cfg
|
||||||
AES::init_rng();
|
AES::init_rng();
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#![feature(
|
#![feature(
|
||||||
abi_x86_interrupt,
|
abi_x86_interrupt,
|
||||||
asm,
|
asm,
|
||||||
|
alloc_error_handler,
|
||||||
core_intrinsics,
|
core_intrinsics,
|
||||||
global_asm,
|
global_asm,
|
||||||
lang_items,
|
lang_items,
|
||||||
|
@ -27,7 +28,6 @@ pub mod arch;
|
||||||
pub mod print;
|
pub mod print;
|
||||||
|
|
||||||
use arch::drivers::serial;
|
use arch::drivers::serial;
|
||||||
|
|
||||||
pub mod driver_traits;
|
pub mod driver_traits;
|
||||||
pub mod experiments;
|
pub mod experiments;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
|
@ -36,3 +36,7 @@ pub mod panic;
|
||||||
pub mod relib;
|
pub mod relib;
|
||||||
|
|
||||||
use experiments::server;
|
use experiments::server;
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
|
pub mod allocator;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
pub struct Stdout;
|
pub struct Stdout;
|
||||||
use core::fmt::Arguments;
|
use core::fmt::{Arguments, Error};
|
||||||
use core::fmt::Error;
|
|
||||||
impl Stdout {
|
impl Stdout {
|
||||||
pub fn write_fmt(&mut self, arg: Arguments<'_>) /*-> Result<(), Error> */
|
pub fn write_fmt(&mut self, arg: Arguments<'_>) /*-> Result<(), Error> */
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,6 @@ enum Command {
|
||||||
#[derive(clap::ArgEnum, Debug, Clone)]
|
#[derive(clap::ArgEnum, Debug, Clone)]
|
||||||
enum MachineType {
|
enum MachineType {
|
||||||
X86,
|
X86,
|
||||||
/// hi
|
|
||||||
RISCV,
|
RISCV,
|
||||||
ARM,
|
ARM,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue