From 8d3e5cd00693c3935cd223a75384a46b48f50ec9 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Fri, 1 Nov 2024 19:08:01 +0100 Subject: [PATCH] Update website --- www/devices.html | 172 ++++++++++++++++++++++++++++++++++++++++++++ www/filesystem.html | 7 +- www/moros.css | 1 - www/shell.html | 2 +- 4 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 www/devices.html diff --git a/www/devices.html b/www/devices.html new file mode 100644 index 00000000..39d4f7bc --- /dev/null +++ b/www/devices.html @@ -0,0 +1,172 @@ + + + + + MOROS Devices + + + +

MOROS Devices

+ +

Creating the devices in the file system:

+ +
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
+
+ +

Clock Devices

+ +

Reading the number of seconds since boot:

+ +
> read /dev/clk/boot
+89.570360
+
+ +

Reading the number of seconds since Unix Epoch:

+ +
> read /dev/clk/epoch
+1730398385.175973
+
+ +

Reading the real time clock (RTC):

+ +
> read /dev/clk/rtc
+2024-10-31 18:20:02
+
+ +

Changing the system time:

+ +
> print "2025-01-01 00:00:00" => /dev/clk/rtc
+[580.327629] RTC 2025-01-01 00:00:00 +0000
+
+ +

Network Devices

+ +

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

+ +

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

+ +
> list /dev/net
+1446 2024-09-28 09:57:55 tcp
+1458 2024-09-28 09:57:55 udp
+
+ +

Reading a socket with a 1 byte buffer will return the status of the socket:

+ +
+-----+--------------+
+| 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     |
++-----+--------------+
+
+ +

Speaker Device

+ +

Playing a 440 Hz sound on the PC speaker:

+ +
> print 440 => /dev/speaker
+
+ +

Stopping the sound:

+ +
> print 0 => /dev/speaker
+
+ +

Null Device

+ +

Writing to /dev/null will discard any data sent to it:

+ +
> print hello
+hello
+
+> print hello => /dev/null
+
+ +

It can be used to suppress errors:

+ +
> copy none.txt some.txt
+Error: Could not read file 'none.txt'
+
+> copy none.txt some.txt [2]=> /dev/null
+
+ +

Random Device

+ +

Reading from /dev/random will return bytes from a cryptographically secure +random number generator that uses the HC-128 algorithm seeded from the + RDRAND instruction when available.

+ +

VGA Devices

+ +

VGA Font Device

+ +

Changing the VGA font:

+ +
> copy /ini/fonts/zap-light-8x16.psf /dev/vga/font
+
+ +

VGA Mode Device

+ +

Changing the VGA mode:

+ +
> print 320x200 => /dev/vga/mode
+
+ +

The accepted modes are:

+ + + +

It is possible to read the current mode from this device file.

+ +

VGA Palette Device

+ +

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

+ +

It is possible to read the current palette from this device file.

+ +

VGA Buffer Device

+ +

Changing the VGA framebuffer is done by writting a 64 KB bytes buffer to + /dev/vga/buffer containing the index of the color of each pixel on the +screen while in 320x200 mode.

+ + + diff --git a/www/filesystem.html b/www/filesystem.html index c5b9dcd0..9a429330 100644 --- a/www/filesystem.html +++ b/www/filesystem.html @@ -68,6 +68,9 @@

Setup in diskless console

> write /var/ # Variable files +

See the devices documentation to create the device files in the + /dev directory.

+

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

@@ -167,7 +170,7 @@

DirEntry

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.

@@ -186,7 +189,7 @@

DirEntry

FileInfo

-

The info syscall on a file or directory and the read syscall on a directory +

The INFO syscall on a file or directory and the READ syscall on a directory return a subset of a directory entry for userspace programs.

Structure:

diff --git a/www/moros.css b/www/moros.css index 0447ff42..3a8825dc 100644 --- a/www/moros.css +++ b/www/moros.css @@ -56,7 +56,6 @@ img { background: #28282878; padding: 2px; } - footer { margin-top: 2em; text-align: center; diff --git a/www/shell.html b/www/shell.html index 31e27656..6d59433a 100644 --- a/www/shell.html +++ b/www/shell.html @@ -98,7 +98,7 @@

Combiners (TODO)

> read foo.txt or read bar.txt
 
-

Pipes and redirections (WIP)

+

Pipes and Redirections (WIP)

A thin arrow -> can be used for piping the output from one command to the input of another command (TODO):