Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 126 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ringbuf = { version = "0.4.8", default-features = false, features = ["alloc"] }
bitflags = "2.9.1"
futures = { version = "0.3.31", default-features = false, features = ["alloc", "async-await"] }
rand = { version = "0.9.2", default-features = false, features = ["small_rng"] }
smoltcp = { version = "0.12.0", default-features = false, features = ["alloc", "medium-ethernet", "medium-ip", "proto-ipv4", "proto-ipv6", "socket-tcp", "socket-udp"] }

[features]
default = ["smp"]
Expand Down
6 changes: 6 additions & 0 deletions libkernel/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ pub enum KernelError {
#[error("Operation not supported")]
NotSupported,

#[error("Address family not supported")]
AddressFamilyNotSupported,

#[error("Device probe failed: {0}")]
Probe(#[from] ProbeError),

Expand Down Expand Up @@ -186,6 +189,9 @@ pub enum KernelError {
#[error("Operation timed out")]
TimedOut,

#[error("Not a socket")]
NotASocket,

#[error("{0}")]
Other(&'static str),
}
Expand Down
11 changes: 10 additions & 1 deletion src/arch/arm64/exceptions/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ use crate::{
threading::{futex::sys_futex, sys_set_robust_list, sys_set_tid_address},
},
sched::{current::current_task, sys_sched_yield},
socket::syscalls::{
accept::sys_accept, bind::sys_bind, connect::sys_connect, listen::sys_listen,
shutdown::sys_shutdown, socket::sys_socket,
},
};
use alloc::boxed::Box;
use libkernel::{
Expand Down Expand Up @@ -390,7 +394,12 @@ pub async fn handle_syscall() {
0xb1 => sys_getegid().map_err(|e| match e {}),
0xb2 => sys_gettid().map_err(|e| match e {}),
0xb3 => sys_sysinfo(TUA::from_value(arg1 as _)).await,
0xc6 => Err(KernelError::NotSupported),
0xc6 => sys_socket(arg1 as _, arg2 as _, arg3 as _).await,
0xc8 => sys_bind(arg1.into(), UA::from_value(arg2 as _), arg3 as _).await,
0xc9 => sys_listen(arg1.into(), arg2 as _).await,
0xca => sys_accept(arg1.into()).await,
0xcb => sys_connect(arg1.into(), UA::from_value(arg2 as _), arg3 as _).await,
0xd2 => sys_shutdown(arg1.into(), arg2 as _).await,
0xd6 => sys_brk(VA::from_value(arg1 as _))
.await
.map_err(|e| match e {}),
Expand Down
4 changes: 4 additions & 0 deletions src/fs/fops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,8 @@ pub trait FileOps: Send + Sync {
) -> Result<usize> {
Err(KernelError::InvalidValue)
}

fn as_socket(&mut self) -> Option<&mut dyn crate::socket::SocketOps> {
None
}
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ mod kernel;
mod memory;
mod process;
mod sched;
mod socket;
mod sync;

#[panic_handler]
Expand Down
Loading