From 232c667fc71738825ba5cebd62d7c0b25c457a88 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Sat, 2 Nov 2024 12:16:18 +0100 Subject: [PATCH] Add structures to syscalls doc --- doc/syscalls.md | 52 +++++++++++++++++++--------- www/devices.html | 2 +- www/manual.html | 2 +- www/syscalls.html | 86 +++++++++++++++++++++++++++++------------------ 4 files changed, 92 insertions(+), 50 deletions(-) diff --git a/doc/syscalls.md b/doc/syscalls.md index 27c50466..18452ea9 100644 --- a/doc/syscalls.md +++ b/doc/syscalls.md @@ -2,61 +2,72 @@ This list is unstable and subject to change between versions of MOROS. -## EXIT (0x1) +## EXIT (0x01) ```rust fn exit(code: usize) -> usize ``` -## SPAWN (0x2) +## SPAWN (0x02) ```rust fn spawn(path: &str) -> isize ``` -## READ (0x3) +## READ (0x03) ```rust fn read(handle: usize, buf: &mut [u8]) -> isize ``` -## WRITE (0x4) +## WRITE (0x04) ```rust fn write(handle: usize, buf: &mut [u8]) -> isize ``` -## OPEN (0x5) +## OPEN (0x05) ```rust fn open(path: &str, flags: usize) -> isize ``` -## CLOSE (0x6) +## CLOSE (0x06) ```rust fn close(handle: usize) ``` -## INFO (0x7) +## INFO (0x07) ```rust fn info(path: &str, info: &mut FileInfo) -> isize ``` -## DUP (0x8) +This syscall will set the following attributes of the given structure: + +```rust +pub struct FileInfo { + kind: FileType, + size: u32, + time: u64, + name: String, +} +``` + +## DUP (0x08) ```rust fn dup(old_handle: usize, new_handle: usize) -> isize ``` -## DELETE (0x9) +## DELETE (0x09) ```rust fn delete(path: &str) -> isize ``` -## STOP (0xA) +## STOP (0x0A) ```rust fn stop(code: usize) @@ -64,31 +75,31 @@ fn stop(code: usize) The system will reboot with `0xCAFE` and halt with `0xDEAD`. -## SLEEP (0xB) +## SLEEP (0x0B) ```rust fn sleep(seconds: f64) ``` -## POLL (0xC) +## POLL (0x0C) ```rust fn poll(list: &[(usize, IO)]) -> isize ``` -## CONNECT (0xD) +## CONNECT (0x0D) ```rust fn connect(handle, usize, addr: &str, port: u16) -> isize ``` -## LISTEN (0xE) +## LISTEN (0x0E) ```rust fn listen(handle, usize, port: u16) -> isize ``` -## ACCEPT (0xF) +## ACCEPT (0x0F) ```rust fn accept(handle, usize, addr: &str) -> isize @@ -111,3 +122,14 @@ fn free(ptr: *mut u8, size: usize, align: usize) ```rust fn kind(handle: usize) -> isize ``` + +This syscall will return a integer corresponding to the `FileType` of the given +file handle when successful: + +```rust +pub enum FileType { + Dir = 0, + File = 1, + Device = 2, +} +``` diff --git a/www/devices.html b/www/devices.html index dcb2df64..99e98d39 100644 --- a/www/devices.html +++ b/www/devices.html @@ -58,7 +58,7 @@

Clock Devices

Changing the system time:

-
> print "2025-01-01 00:00:00" => /dev/clk/rtc
+    
> print 2025-01-01 00:00:00 => /dev/clk/rtc
 [580.327629] RTC 2025-01-01 00:00:00 +0000
 
diff --git a/www/manual.html b/www/manual.html index babe01f2..b3255bbb 100644 --- a/www/manual.html +++ b/www/manual.html @@ -290,7 +290,7 @@

Time

You can update the real time clock by writing the correct time to its device file:

-
> print "2023-03-21 10:00:00" => /dev/clk/rtc
+    
> print 2023-03-21 10:00:00 => /dev/clk/rtc
 
 > date
 2023-03-21 10:00:00 +0000
diff --git a/www/syscalls.html b/www/syscalls.html
index 9397fdcf..fd365a1c 100644
--- a/www/syscalls.html
+++ b/www/syscalls.html
@@ -10,96 +10,116 @@ 

MOROS Syscalls

This list is unstable and subject to change between versions of MOROS.

-

EXIT (0x1)

+

EXIT (0x01)

-
pub fn exit(code: usize) -> usize
+    
fn exit(code: usize) -> usize
 
-

SPAWN (0x2)

+

SPAWN (0x02)

-
pub fn spawn(path: &str) -> isize
+    
fn spawn(path: &str) -> isize
 
-

READ (0x3)

+

READ (0x03)

-
pub fn read(handle: usize, buf: &mut [u8]) -> isize
+    
fn read(handle: usize, buf: &mut [u8]) -> isize
 
-

WRITE (0x4)

+

WRITE (0x04)

-
pub fn write(handle: usize, buf: &mut [u8]) -> isize
+    
fn write(handle: usize, buf: &mut [u8]) -> isize
 
-

OPEN (0x5)

+

OPEN (0x05)

-
pub fn open(path: &str, flags: usize) -> isize
+    
fn open(path: &str, flags: usize) -> isize
 
-

CLOSE (0x6)

+

CLOSE (0x06)

-
pub fn close(handle: usize)
+    
fn close(handle: usize)
 
-

INFO (0x7)

+

INFO (0x07)

-
pub fn info(path: &str, info: &mut FileInfo) -> isize
+    
fn info(path: &str, info: &mut FileInfo) -> isize
 
-

DUP (0x8)

+

This syscall will set the following attributes of the given structure:

-
pub fn dup(old_handle: usize, new_handle: usize) -> isize
+    
pub struct FileInfo {
+    kind: FileType,
+    size: u32,
+    time: u64,
+    name: String,
+}
 
-

DELETE (0x9)

+

DUP (0x08)

-
pub fn delete(path: &str) -> isize
+    
fn dup(old_handle: usize, new_handle: usize) -> isize
 
-

STOP (0xA)

+

DELETE (0x09)

-
pub fn stop(code: usize)
+    
fn delete(path: &str) -> isize
+
+ +

STOP (0x0A)

+ +
fn stop(code: usize)
 

The system will reboot with 0xCAFE and halt with 0xDEAD.

-

SLEEP (0xB)

+

SLEEP (0x0B)

-
pub fn sleep(seconds: f64)
+    
fn sleep(seconds: f64)
 
-

POLL (0xC)

+

POLL (0x0C)

-
pub fn poll(list: &[(usize, IO)]) -> isize
+    
fn poll(list: &[(usize, IO)]) -> isize
 
-

CONNECT (0xD)

+

CONNECT (0x0D)

-
pub fn connect(handle, usize, addr: &str, port: u16) -> isize
+    
fn connect(handle, usize, addr: &str, port: u16) -> isize
 
-

LISTEN (0xE)

+

LISTEN (0x0E)

-
pub fn listen(handle, usize, port: u16) -> isize
+    
fn listen(handle, usize, port: u16) -> isize
 
-

ACCEPT (0xF)

+

ACCEPT (0x0F)

-
pub fn accept(handle, usize, addr: &str) -> isize
+    
fn accept(handle, usize, addr: &str) -> isize
 

ALLOC (0x10)

-
pub fn alloc(size: usize, align: usize) -> *mut u8
+    
fn alloc(size: usize, align: usize) -> *mut u8
 

FREE (0x11)

-
pub fn free(ptr: *mut u8, size: usize, align: usize)
+    
fn free(ptr: *mut u8, size: usize, align: usize)
 

KIND (0x12)

-
pub fn kind(handle: usize) -> isize
+    
fn kind(handle: usize) -> isize
+
+ +

This syscall will return a integer corresponding to the FileType of the given +file handle when successful:

+ +
pub enum FileType {
+    Dir = 0,
+    File = 1,
+    Device = 2,
+}