From 5a1a84b1c7bb9f0b402dde0eecdb776e5b774dfe Mon Sep 17 00:00:00 2001 From: Able Date: Mon, 7 Feb 2022 06:38:18 -0600 Subject: [PATCH] syscall --- ableos/src/kmain.rs | 67 ++++++++++++++++--------------- ableos/src/syscalls/file_calls.rs | 9 +++-- lib_syscalls/C/file_calls.c | 29 +++++++++++++ lib_syscalls/README.md | 1 + 4 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 lib_syscalls/C/file_calls.c create mode 100644 lib_syscalls/README.md diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 9b741bc..5b38e78 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -42,43 +42,43 @@ pub fn kernel_main() -> ! { log::set_max_level(BOOT_CONF.log_level()); { - { - let mut scheduler = SCHEDULER.lock(); + let mut scheduler = SCHEDULER.lock(); - use crate::scheduler::Priority::*; - let mut process_1 = scheduler.new_process(High); - process_1.capabilities.files = FileAccess::Some(vec![PathRep { - location: FileLocations::Home, - file_name: "test".to_string(), - }]); - scheduler.add_process(process_1); - for ref_process in &scheduler.list { - trace!("{:?}", ref_process); - } - drop(scheduler); - } - - use crate::proto_filetable::file::FileLocations; - - { - let mut sock_print_id = SimpleSock::new(); - sock_print_id.register_protocol("Screen Printer".to_string()); - sock_print_id.write(format!("🐑").into()); - - let mut mode = SCREEN_BUFFER.lock(); - - mode.force_redraw(); - for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() { - mode.draw_char(0, 0, current, from_vga_16(Color16::Red)); - } - mode.copy_to_buffer(); + use crate::scheduler::Priority::*; + let mut process_1 = scheduler.new_process(High); + process_1.capabilities.files = FileAccess::Some(vec![PathRep { + location: FileLocations::Home, + file_name: "test".to_string(), + }]); + scheduler.add_process(process_1); + for ref_process in &scheduler.list { + trace!("{:?}", ref_process); } + drop(scheduler); } + + use crate::proto_filetable::file::FileLocations; + + if false { + let mut sock_print_id = SimpleSock::new(); + sock_print_id.register_protocol("Screen Printer".to_string()); + sock_print_id.write(format!("🐑").into()); + + let mut mode = SCREEN_BUFFER.lock(); + + mode.force_redraw(); + for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() { + mode.draw_char(0, 0, current, from_vga_16(Color16::Red)); + } + mode.copy_to_buffer(); + } + if false { // Currently not implemented - let acpi_handler = ACPI_struct {}; + let acpi_handler = AcpiStruct {}; + let mut table; unsafe { - let table = AcpiTables::search_for_rsdp_bios(acpi_handler); + table = AcpiTables::search_for_rsdp_bios(acpi_handler); } } @@ -95,6 +95,7 @@ pub fn tick() { crate::kernel_state::KERNEL_STATE.lock().update_state(); // let mut scheduler = SCHEDULER.lock(); // scheduler.bump_exec(); + // drop(scheduler); TICK.store(data, Relaxed) } @@ -124,9 +125,9 @@ pub fn generate_process_pass() -> u128 { // TODO: move to a better place #[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct ACPI_struct {} +pub struct AcpiStruct {} -impl acpi::AcpiHandler for ACPI_struct { +impl acpi::AcpiHandler for AcpiStruct { unsafe fn map_physical_region( &self, physical_address: usize, diff --git a/ableos/src/syscalls/file_calls.rs b/ableos/src/syscalls/file_calls.rs index d4cb492..653eced 100644 --- a/ableos/src/syscalls/file_calls.rs +++ b/ableos/src/syscalls/file_calls.rs @@ -18,13 +18,16 @@ pub extern "C" fn remove_directory(path: Path, force_delete: bool) { /// # Arguments /// * `full_path` - The full path of the directory to create #[no_mangle] -pub extern "C" fn create_directory(path: Path) -> Result<(), FileErrors> { +pub extern "C" fn create_directory(path: Path) -> FSReturns { unimplemented!(); } #[repr(C)] -/// Errors that can occur when messing with files -pub enum FileErrors { +/// A return used by the file related system calls +pub enum FSReturns { + /// The system call was successful + Ok, + /// The directory can not be created DirectoryCouldNotBeCreated, /// The directory could not be removed diff --git a/lib_syscalls/C/file_calls.c b/lib_syscalls/C/file_calls.c new file mode 100644 index 0000000..cb28bea --- /dev/null +++ b/lib_syscalls/C/file_calls.c @@ -0,0 +1,29 @@ +enum FSReturns { + /// The system call was successful + Ok, + /// The directory can not be created + DirectoryCouldNotBeCreated, + /// The directory could not be removed + DirectoryCouldNotBeRemoved, + /// + FileCouldNotBeCreated, + /// + FileCouldNotBeRemoved, + /// The file could not be opened + FileCouldNotBeOpened, + /// + FileCouldNotBeClosed, +}; + +int create_directory(path) { + return DirectoryCouldNotBeCreated; +} +/// +int remove_directory(path) { + return DirectoryCouldNotBeRemoved; +} + + + + + diff --git a/lib_syscalls/README.md b/lib_syscalls/README.md new file mode 100644 index 0000000..72dff5f --- /dev/null +++ b/lib_syscalls/README.md @@ -0,0 +1 @@ +# The libraries here are simplified examples of syscall APi \ No newline at end of file