Skip to content

Commit

Permalink
Update website
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Nov 1, 2024
1 parent c00a137 commit 8d3e5cd
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 4 deletions.
172 changes: 172 additions & 0 deletions www/devices.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MOROS Devices</title>
<link rel="stylesheet" type="text/css" href="moros.css">
</head>
<body>
<h1>MOROS Devices</h1>

<p>Creating the devices in the file system:</p>

<pre><code class="sh">write /dev/
write /dev/ata/
write /dev/ata/0/
write /dev/ata/0/0 -d ata-0-0
write /dev/ata/0/1 -d ata-0-1
write /dev/ata/1/
write /dev/ata/1/0 -d ata-1-0
write /dev/ata/1/1 -d ata-1-1
write /dev/clk/
write /dev/clk/boot -d clk-boot
write /dev/clk/epoch -d clk-epoch
write /dev/clk/rtc -d clk-rtc
write /dev/console -d console
write /dev/net/
write /dev/net/tcp -d tcp
write /dev/net/udp -d udp
write /dev/null -d null
write /dev/random -d random
write /dev/speaker -d speaker
write /dev/vga/
write /dev/vga/buffer -d vga-buffer
write /dev/vga/font -d vga-font
write /dev/vga/mode -d vga-mode
write /dev/vga/palette -d vga-palette
</code></pre>

<h2>Clock Devices</h2>

<p>Reading the number of seconds since boot:</p>

<pre><code>&gt; read /dev/clk/boot
89.570360
</code></pre>

<p>Reading the number of seconds since Unix Epoch:</p>

<pre><code>&gt; read /dev/clk/epoch
1730398385.175973
</code></pre>

<p>Reading the real time clock (RTC):</p>

<pre><code>&gt; read /dev/clk/rtc
2024-10-31 18:20:02
</code></pre>

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

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

<h2>Network Devices</h2>

<p>Opening <code>/dev/net/tcp</code> or <code>/dev/net/udp</code> with the <code>OPEN</code> syscall and the device
flag will return a file handle for a TCP or UDP socket supporting the standard
<code>READ</code> and <code>WRITE</code> syscalls after establishing a connection using the
<code>CONNECT</code>, or <code>LISTEN</code> and <code>ACCEPT</code> syscalls.</p>

<p>The size of those files give the maximum size of the buffer that can be used
when reading or writing to a socket:</p>

<pre><code>&gt; list /dev/net
1446 2024-09-28 09:57:55 tcp
1458 2024-09-28 09:57:55 udp
</code></pre>

<p>Reading a socket with a 1 byte buffer will return the status of the socket:</p>

<pre><code>+-----+--------------+
| Bit | Status |
+-----+--------------+
| 0 | Is Listening |
| 1 | Is Active |
| 2 | Is Open |
| 3 | Can Send |
| 4 | May Send |
| 5 | Can Recv |
| 6 | May Recv |
| 7 | Reserved |
+-----+--------------+
</code></pre>

<h2>Speaker Device</h2>

<p>Playing a 440 Hz sound on the PC speaker:</p>

<pre><code>&gt; print 440 =&gt; /dev/speaker
</code></pre>

<p>Stopping the sound:</p>

<pre><code>&gt; print 0 =&gt; /dev/speaker
</code></pre>

<h2>Null Device</h2>

<p>Writing to <code>/dev/null</code> will discard any data sent to it:</p>

<pre><code>&gt; print hello
hello

&gt; print hello =&gt; /dev/null
</code></pre>

<p>It can be used to suppress errors:</p>

<pre><code>&gt; copy none.txt some.txt
Error: Could not read file &#39;none.txt&#39;

&gt; copy none.txt some.txt [2]=&gt; /dev/null
</code></pre>

<h2>Random Device</h2>

<p>Reading from <code>/dev/random</code> will return bytes from a cryptographically secure
random number generator that uses the <a href="https://en.wikipedia.org/wiki/HC-256">HC-128</a> algorithm seeded from the
<a href="https://en.wikipedia.org/wiki/RDRAND">RDRAND</a> instruction when available.</p>

<h2>VGA Devices</h2>

<h3>VGA Font Device</h3>

<p>Changing the VGA font:</p>

<pre><code>&gt; copy /ini/fonts/zap-light-8x16.psf /dev/vga/font
</code></pre>

<h3>VGA Mode Device</h3>

<p>Changing the VGA mode:</p>

<pre><code>&gt; print 320x200 =&gt; /dev/vga/mode
</code></pre>

<p>The accepted modes are:</p>

<ul>
<li><code>80x25</code> for the primary text mode with 16 colors</li>
<li><code>320x200</code> for the primary graphics mode with 256 colors</li>
<li><code>640x480</code> for the secondary graphics mode with 16 colors</li>
</ul>

<p>It is possible to read the current mode from this device file.</p>

<h3>VGA Palette Device</h3>

<p>Changing the VGA palette is done by writting a 768 bytes buffer to
<code>/dev/vga/palette</code> containing the RGB values of 256 colors.</p>

<p>It is possible to read the current palette from this device file.</p>

<h3>VGA Buffer Device</h3>

<p>Changing the VGA framebuffer is done by writting a 64 KB bytes buffer to
<code>/dev/vga/buffer</code> containing the index of the color of each pixel on the
screen while in <code>320x200</code> mode.</p>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
7 changes: 5 additions & 2 deletions www/filesystem.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ <h3>Setup in diskless console</h3>
&gt; write /var/ # Variable files
</code></pre>

<p>See the <a href="devices.html">devices</a> documentation to create the device files in the
<code>/dev</code> directory.</p>

<p>Then the following should be added to the boot script with the
command <code>edit /ini/boot.sh</code> to allow MOROS to finish booting:</p>

Expand Down Expand Up @@ -167,7 +170,7 @@ <h3>DirEntry</h3>
<p>A directory entry represents a file or a directory contained inside a
directory. Each entry use a variable number of bytes that must fit inside the
data of one block. Those bytes represent the kind of entry (file or dir), the
address of the first block, the filesize (max 4GB), the last modified time in
address of the first block, the filesize (max 4 GB), the last modified time in
seconds since Unix Epoch, the length of the filename, and the filename (max
255 chars) of the entry.</p>

Expand All @@ -186,7 +189,7 @@ <h3>DirEntry</h3>

<h3>FileInfo</h3>

<p>The <code>info</code> syscall on a file or directory and the <code>read</code> syscall on a directory
<p>The <code>INFO</code> syscall on a file or directory and the <code>READ</code> syscall on a directory
return a subset of a directory entry for userspace programs.</p>

<p>Structure:</p>
Expand Down
1 change: 0 additions & 1 deletion www/moros.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ img {
background: #28282878;
padding: 2px;
}

footer {
margin-top: 2em;
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion www/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h2>Combiners (TODO)</h2>
<pre><code>&gt; read foo.txt or read bar.txt
</code></pre>

<h2>Pipes and redirections (WIP)</h2>
<h2>Pipes and Redirections (WIP)</h2>

<p>A thin arrow <code>-&gt;</code> can be used for piping the output from one command to the
input of another command (TODO):</p>
Expand Down

0 comments on commit 8d3e5cd

Please sign in to comment.