fix rust errors
This commit is contained in:
parent
855dfd0aab
commit
3e17ebe46e
@ -1,6 +1,6 @@
|
||||
|
||||
[unstable]
|
||||
build-std = ["core", "compiler_builtins"]
|
||||
build-std = ["core", "compiler_builtins", "alloc"]
|
||||
build-std-features = ["compiler-builtins-mem"]
|
||||
|
||||
[build]
|
||||
|
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
{
|
||||
"rust-analyzer.cargo.allTargets": false,
|
||||
"rust-analyzer.checkOnSave.allTargets": true, // not sure if this one is needed
|
||||
"rust-analyzer.checkOnSave.overrideCommand": [
|
||||
"./cargo",
|
||||
"xcheck",
|
||||
"--json-output",
|
||||
"--target",
|
||||
"thumbv7m-none-eabi"
|
||||
]
|
||||
}
|
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -18,16 +18,32 @@ checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
name = "mxrox_kernel"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"stable-vec",
|
||||
"volatile 0.6.1",
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "no-std-compat"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df270209a7f04d62459240d890ecb792714d5db12c92937823574a09930276b4"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
||||
|
||||
[[package]]
|
||||
name = "stable-vec"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1dff32a2ce087283bec878419027cebd888760d8760b2941ad0843531dc9ec8"
|
||||
dependencies = [
|
||||
"no-std-compat",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "volatile"
|
||||
version = "0.4.6"
|
||||
|
@ -6,3 +6,4 @@ edition = "2021"
|
||||
[dependencies]
|
||||
x86_64 = "0.15.2"
|
||||
volatile = "0.6.1"
|
||||
stable-vec = "0.4.1"
|
@ -1,14 +1,23 @@
|
||||
use vga::{fill, fill_with_color, put_char, put_string_by_index, read_char, VgaColor};
|
||||
use stable_vec::StableVec;
|
||||
use vga::{
|
||||
fill_with_color,
|
||||
put_string_by_index,
|
||||
VGA_COLOR_BLACK,
|
||||
VGA_COLOR_RED
|
||||
};
|
||||
|
||||
mod vga;
|
||||
mod ps2;
|
||||
mod acpi;
|
||||
mod thread;
|
||||
|
||||
type Vec<T> = StableVec<T>;
|
||||
|
||||
pub fn show_error(message: &str) {
|
||||
put_string_by_index(0, message, VgaColor::BLACK, VgaColor::LIGHT_RED);
|
||||
fill_with_color(VGA_COLOR_BLACK);
|
||||
put_string_by_index(0, message, VGA_COLOR_BLACK, VGA_COLOR_RED);
|
||||
}
|
||||
|
||||
pub fn start_kernel() {
|
||||
fill_with_color(VgaColor::BLACK);
|
||||
show_error("error test");
|
||||
}
|
@ -1,23 +1,27 @@
|
||||
use core::ptr::{read_volatile, write_volatile};
|
||||
|
||||
use super::Vec;
|
||||
|
||||
const DATA_PORT: *mut u8 = 0x60 as *mut u8;
|
||||
const STATUS_PORT: *mut u8 = 0x64 as *mut u8;
|
||||
|
||||
fn write_ps2_data(data: u8) {
|
||||
todo!()
|
||||
unsafe { write_volatile(DATA_PORT, data) }
|
||||
}
|
||||
|
||||
fn read_ps2_data() -> u8 {
|
||||
todo!()
|
||||
unsafe { read_volatile(DATA_PORT) }
|
||||
}
|
||||
|
||||
fn send_ps2_command(command: u8) {
|
||||
todo!()
|
||||
unsafe { write_volatile(STATUS_PORT, command) }
|
||||
}
|
||||
|
||||
fn read_ps2_status() -> u8 {
|
||||
todo!()
|
||||
unsafe { read_volatile(STATUS_PORT) }
|
||||
}
|
||||
|
||||
/// returns device type bytes
|
||||
fn init_ps2_controller() -> vec![u8; 2] {
|
||||
fn init_ps2_controller() -> Vec<u8> {
|
||||
todo!()
|
||||
}
|
@ -1,28 +1,26 @@
|
||||
use core::ptr::write_volatile;
|
||||
|
||||
const VGA_BUFFER: *mut u16 = 0xB8000 as *mut u16;
|
||||
|
||||
pub const VGA_WIDTH: usize = 80;
|
||||
pub const VGA_HEIGHT: usize = 25;
|
||||
|
||||
pub struct VgaColor(u8);
|
||||
|
||||
impl VgaColor {
|
||||
pub const BLACK: u8 = 0;
|
||||
pub const BLUE: u8 = 1;
|
||||
pub const GREEN: u8 = 2;
|
||||
pub const CYAN: u8 = 3;
|
||||
pub const RED: u8 = 4;
|
||||
pub const MAGENTA: u8 = 5;
|
||||
pub const BROWN: u8 = 6;
|
||||
pub const LIGHT_GREY: u8 = 7;
|
||||
pub const DARK_GREY: u8 = 8;
|
||||
pub const LIGHT_BLUE: u8 = 9;
|
||||
pub const LIGHT_GREEN: u8 = 10;
|
||||
pub const LIGHT_CYAN: u8 = 11;
|
||||
pub const LIGHT_RED: u8 = 12;
|
||||
pub const LIGHT_MAGENTA: u8 = 13;
|
||||
pub const LIGHT_BROWN: u8 = 14;
|
||||
pub const WHITE: u8 = 15;
|
||||
}
|
||||
pub const VGA_COLOR_BLACK: u8 = 0;
|
||||
pub const VGA_COLOR_BLUE: u8 = 1;
|
||||
pub const VGA_COLOR_GREEN: u8 = 2;
|
||||
pub const VGA_COLOR_CYAN: u8 = 3;
|
||||
pub const VGA_COLOR_RED: u8 = 4;
|
||||
pub const VGA_COLOR_MAGENTA: u8 = 5;
|
||||
pub const VGA_COLOR_BROWN: u8 = 6;
|
||||
pub const VGA_COLOR_LIGHT_GREY: u8 = 7;
|
||||
pub const VGA_COLOR_DARK_GREY: u8 = 8;
|
||||
pub const VGA_COLOR_LIGHT_BLUE: u8 = 9;
|
||||
pub const VGA_COLOR_LIGHT_GREEN: u8 = 10;
|
||||
pub const VGA_COLOR_LIGHT_CYAN: u8 = 11;
|
||||
pub const VGA_COLOR_LIGHT_RED: u8 = 12;
|
||||
pub const VGA_COLOR_LIGHT_MAGENTA: u8 = 13;
|
||||
pub const VGA_COLOR_LIGHT_BROWN: u8 = 14;
|
||||
pub const VGA_COLOR_WHITE: u8 = 15;
|
||||
|
||||
pub fn put_char_by_index(index: usize, c: char, bg: u8, fg: u8) {
|
||||
let c16 = c as u16;
|
||||
@ -30,7 +28,7 @@ pub fn put_char_by_index(index: usize, c: char, bg: u8, fg: u8) {
|
||||
let color16 = color as u16;
|
||||
|
||||
unsafe {
|
||||
ptr::write_volatile(VGA_BUFFER.add(index), c16 | (color16 << 8));
|
||||
write_volatile(VGA_BUFFER.add(index), c16 | (color16 << 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,6 @@
|
||||
extern "C" fn eh_personality() {}
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use core::sync::atomic;
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
use kernel::{start_kernel, show_error};
|
||||
|
||||
@ -23,7 +21,7 @@ fn panic(info: &PanicInfo) -> ! {
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
fn main() -> ! {
|
||||
extern "C" fn main() -> ! {
|
||||
start_kernel();
|
||||
loop {}
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
{
|
||||
"llvm-target": "i686-unknown-none",
|
||||
"data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",
|
||||
"arch": "x86",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-c-int-width": "32",
|
||||
"os": "none",
|
||||
"executables": true,
|
||||
"linker-flavor": "ld.lld",
|
||||
"linker": "rust-lld",
|
||||
"panic-strategy": "abort",
|
||||
"disable-redzone": true,
|
||||
"features": "+soft-float,-sse"
|
||||
}
|
||||
|
||||
"llvm-target": "i686-unknown-none",
|
||||
"data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128",
|
||||
"arch": "x86",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-c-int-width": "32",
|
||||
"os": "none",
|
||||
"executables": true,
|
||||
"linker-flavor": "ld.lld",
|
||||
"linker": "rust-lld",
|
||||
"panic-strategy": "abort",
|
||||
"disable-redzone": true,
|
||||
"features": "+soft-float,-sse"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user