Compare commits
6 Commits
main
...
ca906767db
| Author | SHA1 | Date | |
|---|---|---|---|
| ca906767db | |||
| ef8d028211 | |||
| 2886fe5ecf | |||
| c2c552ef25 | |||
| e722874cee | |||
| 27b0ed634c |
@@ -13,3 +13,9 @@
|
|||||||
[submodule "lib/lib_alloc"]
|
[submodule "lib/lib_alloc"]
|
||||||
path = lib/lib_alloc
|
path = lib/lib_alloc
|
||||||
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_alloc.git
|
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_alloc.git
|
||||||
|
[submodule "lib/lib_async"]
|
||||||
|
path = lib/lib_async
|
||||||
|
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_async.git
|
||||||
|
[submodule "lib/lib_keyboard"]
|
||||||
|
path = lib/lib_keyboard
|
||||||
|
url = https://git.zxq5.dev/OsDev/FoundryOS-lib_keyboard.git
|
||||||
|
|||||||
Generated
+94
@@ -29,14 +29,52 @@ dependencies = [
|
|||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam"
|
||||||
|
version = "0.8.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-queue",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-queue"
|
||||||
|
version = "0.3.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foundry_os"
|
name = "foundry_os"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"lib_alloc",
|
"lib_alloc",
|
||||||
|
"lib_application",
|
||||||
"lib_ascii",
|
"lib_ascii",
|
||||||
|
"lib_async",
|
||||||
"lib_framebuffer",
|
"lib_framebuffer",
|
||||||
|
"lib_keyboard",
|
||||||
"lib_serial",
|
"lib_serial",
|
||||||
"limine",
|
"limine",
|
||||||
"pc-keyboard",
|
"pc-keyboard",
|
||||||
@@ -45,6 +83,30 @@ dependencies = [
|
|||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-task"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-util"
|
||||||
|
version = "0.3.31"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"pin-project-lite",
|
||||||
|
"pin-utils",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@@ -79,6 +141,15 @@ dependencies = [
|
|||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lib_async"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam",
|
||||||
|
"spin",
|
||||||
|
"x86_64",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lib_framebuffer"
|
name = "lib_framebuffer"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -87,6 +158,17 @@ dependencies = [
|
|||||||
"spin",
|
"spin",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lib_keyboard"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam",
|
||||||
|
"futures-util",
|
||||||
|
"lib_ascii",
|
||||||
|
"pc-keyboard",
|
||||||
|
"spin",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lib_serial"
|
name = "lib_serial"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -139,6 +221,18 @@ dependencies = [
|
|||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-utils"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.19"
|
version = "1.0.19"
|
||||||
|
|||||||
+4
-2
@@ -1,11 +1,13 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"kernel",
|
||||||
"lib/lib_framebuffer",
|
"lib/lib_framebuffer",
|
||||||
"lib/lib_serial",
|
"lib/lib_serial",
|
||||||
"lib/lib_ascii",
|
"lib/lib_ascii",
|
||||||
"kernel",
|
"lib/lib_application",
|
||||||
"lib/lib_application",
|
|
||||||
"lib/lib_alloc",
|
"lib/lib_alloc",
|
||||||
|
"lib/lib_async",
|
||||||
|
"lib/lib_keyboard",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#usage
|
# Usage
|
||||||
### Requirements
|
### Requirements
|
||||||
- Latest rust nightly release
|
- Latest rust nightly release
|
||||||
> rustup update
|
> rustup update
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ lib_framebuffer = { path = "../lib/lib_framebuffer" }
|
|||||||
lib_serial = { path = "../lib/lib_serial" }
|
lib_serial = { path = "../lib/lib_serial" }
|
||||||
lib_ascii = { path = "../lib/lib_ascii" }
|
lib_ascii = { path = "../lib/lib_ascii" }
|
||||||
lib_alloc = { path = "../lib/lib_alloc" }
|
lib_alloc = { path = "../lib/lib_alloc" }
|
||||||
|
lib_application = { path = "../lib/lib_application" }
|
||||||
|
lib_async = { path = "../lib/lib_async" }
|
||||||
|
lib_keyboard = { path = "../lib/lib_keyboard" }
|
||||||
|
|
||||||
x86_64 = "0.15.2"
|
x86_64 = "0.15.2"
|
||||||
spin = "0.9.8"
|
spin = "0.9.8"
|
||||||
pic8259 = "0.11.0"
|
pic8259 = "0.11.0"
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
use cc;
|
|
||||||
use std::process::Command;
|
|
||||||
use std::{env, path::Path};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Tell cargo to rerun if these files change
|
// Tell cargo to rerun if these files change
|
||||||
println!("cargo:rerun-if-changed=src");
|
println!("cargo:rerun-if-changed=src");
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ static TSS: Lazy<TaskStateSegment> = Lazy::new(|| {
|
|||||||
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
|
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
|
||||||
|
|
||||||
let stack_start = VirtAddr::from_ptr(&raw const STACK);
|
let stack_start = VirtAddr::from_ptr(&raw const STACK);
|
||||||
let stack_end = stack_start + STACK_SIZE.try_into().unwrap();
|
|
||||||
stack_end
|
stack_start + STACK_SIZE.try_into().unwrap()
|
||||||
};
|
};
|
||||||
tss
|
tss
|
||||||
});
|
});
|
||||||
@@ -40,8 +40,8 @@ static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
|
|||||||
Selectors {
|
Selectors {
|
||||||
code_selector,
|
code_selector,
|
||||||
data_selector,
|
data_selector,
|
||||||
user_code_selector,
|
_user_code_selector: user_code_selector,
|
||||||
user_data_selector,
|
_user_data_selector: user_data_selector,
|
||||||
tss_selector,
|
tss_selector,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -50,8 +50,8 @@ static GDT: Lazy<(GlobalDescriptorTable, Selectors)> = Lazy::new(|| {
|
|||||||
struct Selectors {
|
struct Selectors {
|
||||||
code_selector: SegmentSelector,
|
code_selector: SegmentSelector,
|
||||||
data_selector: SegmentSelector,
|
data_selector: SegmentSelector,
|
||||||
user_code_selector: SegmentSelector,
|
_user_code_selector: SegmentSelector,
|
||||||
user_data_selector: SegmentSelector,
|
_user_data_selector: SegmentSelector,
|
||||||
tss_selector: SegmentSelector,
|
tss_selector: SegmentSelector,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use lib_ascii::{print, println_log};
|
use lib_ascii::println_log;
|
||||||
use lib_serial::serial_println;
|
use lib_serial::serial_println;
|
||||||
use x86_64::instructions::port::Port;
|
// use x86_64::instructions::port::Port;
|
||||||
use x86_64::registers::control::Cr2;
|
use x86_64::registers::control::Cr2;
|
||||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||||
|
|
||||||
@@ -81,30 +81,24 @@ extern "x86-interrupt" fn double_fault_handler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStackFrame) {
|
||||||
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1};
|
use pc_keyboard::{layouts, HandleControl, Keyboard, ScancodeSet1};
|
||||||
|
// use pc_keyboard::DecodedKey;
|
||||||
use spin::Mutex;
|
use spin::Mutex;
|
||||||
use x86_64::instructions::port::Port;
|
use x86_64::instructions::port::Port;
|
||||||
|
|
||||||
static KEYBOARD: Lazy<Mutex<Keyboard<layouts::Us104Key, ScancodeSet1>>> = Lazy::new(|| {
|
static KEYBOARD: Lazy<Mutex<Keyboard<layouts::Uk105Key, ScancodeSet1>>> = Lazy::new(|| {
|
||||||
Mutex::new(Keyboard::new(
|
Mutex::new(Keyboard::new(
|
||||||
ScancodeSet1::new(),
|
ScancodeSet1::new(),
|
||||||
layouts::Us104Key,
|
layouts::Uk105Key,
|
||||||
HandleControl::Ignore,
|
HandleControl::Ignore,
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut keyboard = KEYBOARD.lock();
|
let _keyboard = KEYBOARD.lock();
|
||||||
let mut port = Port::new(0x60);
|
let mut port = Port::new(0x60);
|
||||||
|
|
||||||
let scancode: u8 = unsafe { port.read() };
|
let scancode: u8 = unsafe { port.read() };
|
||||||
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
|
lib_keyboard::add_scancode(scancode);
|
||||||
if let Some(key) = keyboard.process_keyevent(key_event) {
|
|
||||||
match key {
|
|
||||||
DecodedKey::Unicode(character) => print!("{}", character),
|
|
||||||
DecodedKey::RawKey(key) => print!("{:?}", key),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
PICS.lock()
|
PICS.lock()
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ static KERNEL_ADDRESS_REQUEST: KernelAddressRequest = KernelAddressRequest::new(
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Returns (virtual_base, physical_base)
|
/// Returns (virtual_base, physical_base)
|
||||||
pub static KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
pub static _KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
||||||
let resp = KERNEL_ADDRESS_REQUEST.get_response().unwrap();
|
let resp = KERNEL_ADDRESS_REQUEST.get_response().unwrap();
|
||||||
|
|
||||||
// These are base addresses, using Limine's built in page table.
|
// These are base addresses, using Limine's built in page table.
|
||||||
@@ -49,7 +49,7 @@ pub static KERNEL_PHYSICAL_MEMORY_OFFSET: Lazy<(u64, u64)> = Lazy::new(|| {
|
|||||||
/// Panics if the memory map was not found in MEMORY_MAP_REQUEST.
|
/// Panics if the memory map was not found in MEMORY_MAP_REQUEST.
|
||||||
pub fn get_memory_map() -> &'static MemoryMapResponse {
|
pub fn get_memory_map() -> &'static MemoryMapResponse {
|
||||||
if let Some(memory_map) = MEMORY_MAP_REQUEST.get_response() {
|
if let Some(memory_map) = MEMORY_MAP_REQUEST.get_response() {
|
||||||
return memory_map;
|
memory_map
|
||||||
} else {
|
} else {
|
||||||
unreachable!("Could not fetch memory map from Limine.")
|
unreachable!("Could not fetch memory map from Limine.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
use lib_alloc::allocator::FoundryAllocator;
|
// use lib_alloc::allocator::FoundryAllocator;
|
||||||
use limine::{memory_map::EntryType, response::MemoryMapResponse};
|
use limine::{memory_map::EntryType, response::MemoryMapResponse};
|
||||||
use x86_64::{
|
use x86_64::{
|
||||||
addr,
|
// addr,
|
||||||
registers::control::Cr3,
|
registers::control::Cr3,
|
||||||
structures::paging::{
|
structures::paging::{
|
||||||
page_table::FrameError, FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB,
|
// page_table::FrameError,
|
||||||
|
FrameAllocator,
|
||||||
|
OffsetPageTable,
|
||||||
|
PageTable,
|
||||||
|
PhysFrame,
|
||||||
|
Size4KiB,
|
||||||
},
|
},
|
||||||
PhysAddr, VirtAddr,
|
PhysAddr,
|
||||||
|
VirtAddr,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns a mutable reference to the current level 4 page table.
|
/// Returns a mutable reference to the current level 4 page table.
|
||||||
@@ -93,7 +99,6 @@ unsafe impl FrameAllocator<Size4KiB> for FoundryOSFrameAllocator {
|
|||||||
///
|
///
|
||||||
/// - `Some(PhysFrame)`: If a usable frame is available.
|
/// - `Some(PhysFrame)`: If a usable frame is available.
|
||||||
/// - `None`: If there are no more usable frames to allocate.
|
/// - `None`: If there are no more usable frames to allocate.
|
||||||
|
|
||||||
fn allocate_frame(&mut self) -> Option<PhysFrame> {
|
fn allocate_frame(&mut self) -> Option<PhysFrame> {
|
||||||
let frame = self.usable_frames().nth(self.next);
|
let frame = self.usable_frames().nth(self.next);
|
||||||
self.next += 1;
|
self.next += 1;
|
||||||
|
|||||||
+5
-13
@@ -5,13 +5,13 @@ extern crate alloc;
|
|||||||
|
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
use lib_alloc::allocator::init_heap;
|
use lib_alloc::allocator::init_heap;
|
||||||
use limine::request::{RequestsEndMarker, RequestsStartMarker};
|
|
||||||
use limine::BaseRevision;
|
use limine::BaseRevision;
|
||||||
|
|
||||||
pub use lib_ascii::{print, print_log, println, println_log, WRITER};
|
pub use lib_ascii::{print, print_log, println, println_log, WRITER};
|
||||||
pub use lib_serial::{serial_print, serial_println, serial_read};
|
pub use lib_serial::{serial_print, serial_println, serial_read};
|
||||||
use x86_64::structures::paging::Translate;
|
// use x86_64::structures::paging::Translate;
|
||||||
use x86_64::{PhysAddr, VirtAddr};
|
// use x86_64::PhysAddr;
|
||||||
|
use x86_64::VirtAddr;
|
||||||
|
|
||||||
mod arch;
|
mod arch;
|
||||||
|
|
||||||
@@ -23,14 +23,6 @@ mod arch;
|
|||||||
#[link_section = ".requests"]
|
#[link_section = ".requests"]
|
||||||
static BASE_REVISION: BaseRevision = BaseRevision::new();
|
static BASE_REVISION: BaseRevision = BaseRevision::new();
|
||||||
|
|
||||||
/// Define the stand and end markers for Limine requests.
|
|
||||||
#[used]
|
|
||||||
#[link_section = ".requests_start_marker"]
|
|
||||||
static _START_MARKER: RequestsStartMarker = RequestsStartMarker::new();
|
|
||||||
#[used]
|
|
||||||
#[link_section = ".requests_end_marker"]
|
|
||||||
static _END_MARKER: RequestsEndMarker = RequestsEndMarker::new();
|
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
println!("Kernel panic: {}", _info);
|
println!("Kernel panic: {}", _info);
|
||||||
@@ -82,8 +74,8 @@ pub fn boot() -> Result<(), &'static str> {
|
|||||||
println_log!("[Success]");
|
println_log!("[Success]");
|
||||||
|
|
||||||
print_log!(" Initialising Heap... ");
|
print_log!(" Initialising Heap... ");
|
||||||
if let Err(e) = init_heap(&mut l4_table, &mut frame_allocator) {
|
if init_heap(&mut l4_table, &mut frame_allocator).is_err() {
|
||||||
return Err("Failed to initialise heap");
|
return Err("Failed to initialise heap: error");
|
||||||
}
|
}
|
||||||
println_log!("[Success]");
|
println_log!("[Success]");
|
||||||
|
|
||||||
|
|||||||
+7
-6
@@ -3,15 +3,12 @@
|
|||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
|
||||||
|
|
||||||
use foundry_os::{println, println_log};
|
use foundry_os::{println, println_log};
|
||||||
|
use lib_async::task::{Executor, Task};
|
||||||
|
use lib_keyboard::print_keypresses;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn kmain() -> ! {
|
extern "C" fn kmain() -> ! {
|
||||||
// All limine requests must also be referenced in a called function, otherwise they may be
|
|
||||||
// removed by the linker.
|
|
||||||
|
|
||||||
println_log!(" [ Initialising Kernel Systems ] ");
|
println_log!(" [ Initialising Kernel Systems ] ");
|
||||||
if let Err(err) = foundry_os::boot() {
|
if let Err(err) = foundry_os::boot() {
|
||||||
panic!("{}", err);
|
panic!("{}", err);
|
||||||
@@ -46,5 +43,9 @@ unsafe extern "C" fn kmain() -> ! {
|
|||||||
"
|
"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut executor = Executor::new();
|
||||||
|
executor.spawn(Task::new(print_keypresses()));
|
||||||
|
executor.try_run();
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule lib/lib_alloc updated: af814bf2ab...cce44f5273
Submodule
+1
Submodule lib/lib_async added at 5e74d22e25
Submodule
+1
Submodule lib/lib_keyboard added at b475480d8f
Reference in New Issue
Block a user