Skip to content

Commit

Permalink
Add structures to syscalls doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Nov 2, 2024
1 parent 7a4c76c commit 232c667
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 50 deletions.
52 changes: 37 additions & 15 deletions doc/syscalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,104 @@

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)
```

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
Expand All @@ -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,
}
```
2 changes: 1 addition & 1 deletion www/devices.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2>Clock Devices</h2>

<p>Changing the system time:</p>

<pre><code>&gt; print &quot;2025-01-01 00:00:00&quot; =&gt; /dev/clk/rtc
<pre><code>&gt; print 2025-01-01 00:00:00 =&gt; /dev/clk/rtc
[580.327629] RTC 2025-01-01 00:00:00 +0000
</code></pre>

Expand Down
2 changes: 1 addition & 1 deletion www/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ <h2>Time</h2>
<p>You can update the real time clock by writing the correct time to its device
file:</p>

<pre><code>&gt; print &quot;2023-03-21 10:00:00&quot; =&gt; /dev/clk/rtc
<pre><code>&gt; print 2023-03-21 10:00:00 =&gt; /dev/clk/rtc

&gt; date
2023-03-21 10:00:00 +0000
Expand Down
86 changes: 53 additions & 33 deletions www/syscalls.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,116 @@ <h1>MOROS Syscalls</h1>

<p>This list is unstable and subject to change between versions of MOROS.</p>

<h2>EXIT (0x1)</h2>
<h2>EXIT (0x01)</h2>

<pre><code class="rust">pub fn exit(code: usize) -&gt; usize
<pre><code class="rust">fn exit(code: usize) -&gt; usize
</code></pre>

<h2>SPAWN (0x2)</h2>
<h2>SPAWN (0x02)</h2>

<pre><code class="rust">pub fn spawn(path: &amp;str) -&gt; isize
<pre><code class="rust">fn spawn(path: &amp;str) -&gt; isize
</code></pre>

<h2>READ (0x3)</h2>
<h2>READ (0x03)</h2>

<pre><code class="rust">pub fn read(handle: usize, buf: &amp;mut [u8]) -&gt; isize
<pre><code class="rust">fn read(handle: usize, buf: &amp;mut [u8]) -&gt; isize
</code></pre>

<h2>WRITE (0x4)</h2>
<h2>WRITE (0x04)</h2>

<pre><code class="rust">pub fn write(handle: usize, buf: &amp;mut [u8]) -&gt; isize
<pre><code class="rust">fn write(handle: usize, buf: &amp;mut [u8]) -&gt; isize
</code></pre>

<h2>OPEN (0x5)</h2>
<h2>OPEN (0x05)</h2>

<pre><code class="rust">pub fn open(path: &amp;str, flags: usize) -&gt; isize
<pre><code class="rust">fn open(path: &amp;str, flags: usize) -&gt; isize
</code></pre>

<h2>CLOSE (0x6)</h2>
<h2>CLOSE (0x06)</h2>

<pre><code class="rust">pub fn close(handle: usize)
<pre><code class="rust">fn close(handle: usize)
</code></pre>

<h2>INFO (0x7)</h2>
<h2>INFO (0x07)</h2>

<pre><code class="rust">pub fn info(path: &amp;str, info: &amp;mut FileInfo) -&gt; isize
<pre><code class="rust">fn info(path: &amp;str, info: &amp;mut FileInfo) -&gt; isize
</code></pre>

<h2>DUP (0x8)</h2>
<p>This syscall will set the following attributes of the given structure:</p>

<pre><code class="rust">pub fn dup(old_handle: usize, new_handle: usize) -&gt; isize
<pre><code class="rust">pub struct FileInfo {
kind: FileType,
size: u32,
time: u64,
name: String,
}
</code></pre>

<h2>DELETE (0x9)</h2>
<h2>DUP (0x08)</h2>

<pre><code class="rust">pub fn delete(path: &amp;str) -&gt; isize
<pre><code class="rust">fn dup(old_handle: usize, new_handle: usize) -&gt; isize
</code></pre>

<h2>STOP (0xA)</h2>
<h2>DELETE (0x09)</h2>

<pre><code class="rust">pub fn stop(code: usize)
<pre><code class="rust">fn delete(path: &amp;str) -&gt; isize
</code></pre>

<h2>STOP (0x0A)</h2>

<pre><code class="rust">fn stop(code: usize)
</code></pre>

<p>The system will reboot with <code>0xCAFE</code> and halt with <code>0xDEAD</code>.</p>

<h2>SLEEP (0xB)</h2>
<h2>SLEEP (0x0B)</h2>

<pre><code class="rust">pub fn sleep(seconds: f64)
<pre><code class="rust">fn sleep(seconds: f64)
</code></pre>

<h2>POLL (0xC)</h2>
<h2>POLL (0x0C)</h2>

<pre><code class="rust">pub fn poll(list: &amp;[(usize, IO)]) -&gt; isize
<pre><code class="rust">fn poll(list: &amp;[(usize, IO)]) -&gt; isize
</code></pre>

<h2>CONNECT (0xD)</h2>
<h2>CONNECT (0x0D)</h2>

<pre><code class="rust">pub fn connect(handle, usize, addr: &amp;str, port: u16) -&gt; isize
<pre><code class="rust">fn connect(handle, usize, addr: &amp;str, port: u16) -&gt; isize
</code></pre>

<h2>LISTEN (0xE)</h2>
<h2>LISTEN (0x0E)</h2>

<pre><code class="rust">pub fn listen(handle, usize, port: u16) -&gt; isize
<pre><code class="rust">fn listen(handle, usize, port: u16) -&gt; isize
</code></pre>

<h2>ACCEPT (0xF)</h2>
<h2>ACCEPT (0x0F)</h2>

<pre><code class="rust">pub fn accept(handle, usize, addr: &amp;str) -&gt; isize
<pre><code class="rust">fn accept(handle, usize, addr: &amp;str) -&gt; isize
</code></pre>

<h2>ALLOC (0x10)</h2>

<pre><code class="rust">pub fn alloc(size: usize, align: usize) -&gt; *mut u8
<pre><code class="rust">fn alloc(size: usize, align: usize) -&gt; *mut u8
</code></pre>

<h2>FREE (0x11)</h2>

<pre><code class="rust">pub fn free(ptr: *mut u8, size: usize, align: usize)
<pre><code class="rust">fn free(ptr: *mut u8, size: usize, align: usize)
</code></pre>

<h2>KIND (0x12)</h2>

<pre><code class="rust">pub fn kind(handle: usize) -&gt; isize
<pre><code class="rust">fn kind(handle: usize) -&gt; isize
</code></pre>

<p>This syscall will return a integer corresponding to the <code>FileType</code> of the given
file handle when successful:</p>

<pre><code class="rust">pub enum FileType {
Dir = 0,
File = 1,
Device = 2,
}
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
Expand Down

0 comments on commit 232c667

Please sign in to comment.