Improve system information (#553)

* Add socket command to manual

* Update syscall doc

* Update copyright year in help command

* Fix lisp include

* Fix error styling in shell

* Use uppercase hex

* Update website

* Move some CSI color positions

* Update line-height
This commit is contained in:
Vincent Ollivier 2023-12-01 16:51:02 +01:00 committed by GitHub
parent ae6d47aec7
commit d22c504726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 164 additions and 64 deletions

View File

@ -58,7 +58,6 @@ image: $(img)
cargo bootimage $(cargo-opts)
dd conv=notrunc if=$(bin) of=$(img)
qemu-opts = -m $(memory) -drive file=$(img),format=raw \
-audiodev $(audio),id=a0 -machine pcspk-audiodev=a0 \
-netdev user,id=e0,hostfwd=tcp::8080-:80 -device $(nic),netdev=e0
@ -93,7 +92,7 @@ qemu:
test:
cargo test --release --lib --no-default-features --features serial -- \
-m $(memory) -display none -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x04
-m $(memory) -display none -serial stdio -device isa-debug-exit,iobase=0xF4,iosize=0x04
website:
cd www && sh build.sh

View File

@ -136,8 +136,8 @@ You can then use `^D` (a key combination of `CTRL` and `D`) to quit the
diskless mode and let MOROS run the bootscript `/ini/boot.sh` to login and use
the shell.
If no disks were detected or if you prefer not to use them you can mount the
system in memory to use a virtual disk with `memory format` before `install`.
If no disks were detected or if you prefer not to use any you can mount the
system in memory and use a virtual disk with `memory format` before `install`.
## Shell
@ -225,7 +225,7 @@ You can edit a file with the `edit` command that will run the text editor.
Use `^W` (a key combination of `CTRL` and `W`) inside the editor to write the
content to the file and `^Q` to quit the editor and go back to the shell.
The help command has a subcommand `help edit` to list the editor commands:
The `help` command has a subcommand `help edit` to list the editor commands:
> help edit
MOROS text editor is a very simple editor inspired by Pico, Nano, and Micro.
@ -333,7 +333,13 @@ with `dhcp`:
gw: 10.0.2.2
dns: 10.0.2.3
A few tools are available like the `http` command:
A few tools are available like the generalist `socket` command that be used to
send and receive TCP packets:
> socket 10.0.2.2:1234
Hello, World!
Or the more specialized `http` command to request a document from a web server:
> http moros.cc /test.html
<!doctype html>

View File

@ -62,7 +62,7 @@ pub fn delete(path: &str) -> isize
pub fn stop(code: usize)
```
The system will reboot with `0xcafe` and halt with `0xdead`.
The system will reboot with `0xCAFE` and halt with `0xDEAD`.
## SLEEP (0xB)
@ -70,20 +70,38 @@ The system will reboot with `0xcafe` and halt with `0xdead`.
pub fn sleep(seconds: f64)
```
## CONNECT (0xC)
## POLL (0xC)
```rust
pub fn poll(list: &[(usize, IO)]) -> isize
```
## CONNECT (0xD)
```rust
pub fn connect(handle, usize, addr: &str, port: u16) -> isize
```
## LISTEN (0xD)
## LISTEN (0xE)
```rust
pub fn listen(handle, usize, port: u16) -> isize
```
## ACCEPT (0xE)
## ACCEPT (0xF)
```rust
pub fn accept(handle, usize, addr: &str) -> isize
```
## ALLOC (0x10)
```rust
pub fn alloc(size: usize, align: usize) -> *mut u8
```
## FREE (0x11)
```rust
pub fn free(ptr: *mut u8, size: usize, align: usize)
```

View File

@ -13,10 +13,10 @@ _start:
mov rdx, len ; size of string
int 0x80
mov rax, 0xb ; syscall number for SLEEP
mov rax, 0xB ; syscall number for SLEEP
mov rdi, __?float64?__(0.5) ; duration
int 0x80
mov rax, 0xa ; syscall number for STOP
mov rdi, 0xdead ; halt code
mov rax, 0xA ; syscall number for STOP
mov rdi, 0xDEAD ; halt code
int 0x80

View File

@ -1,4 +1,4 @@
megs: 32
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0: enabled=1, ioaddr1=0x1F0, ioaddr2=0x3F0, irq=14
ata0-master: type=disk, path="../disk.img", mode=flat, cylinders=0, heads=0, spt=0
boot: disk

View File

@ -103,11 +103,11 @@ pub fn stop(code: usize) {
}
pub fn reboot() {
stop(0xcafe);
stop(0xCAFE);
}
pub fn halt() {
stop(0xdead);
stop(0xDEAD);
}
pub fn poll(list: &[(usize, IO)]) -> Option<(usize, IO)> {

View File

@ -83,7 +83,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) {
use x86_64::instructions::port::Port;
unsafe {
let mut port = Port::new(0xf4);
let mut port = Port::new(0xF4);
port.write(exit_code as u32);
}
}

View File

@ -296,7 +296,7 @@ pub fn interrupt_handler() {
printk!("RTL8139 interrupt!\n");
if let Some(mut guard) = sys::net::IFACE.try_lock() {
if let Some(ref mut iface) = *guard {
unsafe { iface.device_mut().ports.isr.write(0xffff) } // Clear the interrupt
unsafe { iface.device_mut().ports.isr.write(0xFFFF) } // Clear the interrupt
}
}
}

View File

@ -114,7 +114,7 @@ pub fn spawn(path: &str, args_ptr: usize, args_len: usize) -> ExitCode {
pub fn stop(code: usize) -> usize {
match code {
0xcafe => { // Reboot
0xCAFE => { // Reboot
unsafe {
asm!(
"xor rax, rax",
@ -122,7 +122,7 @@ pub fn stop(code: usize) -> usize {
);
}
}
0xdead => { // Halt
0xDEAD => { // Halt
sys::process::exit();
sys::acpi::shutdown();
}

View File

@ -86,7 +86,7 @@ fn help() -> Result<(), ExitCode> {
println!("{}Usage:{} beep {}<options>{1}", csi_title, csi_reset, csi_option);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-f{1},{0} --freq <hertz>{1} Tone frequency", csi_option, csi_reset);
println!(" {0}-l{1},{0} --len <milliseconds>{1} Tone length", csi_option, csi_reset);
println!(" {0}-f{1}, {0}--freq <hertz>{1} Tone frequency", csi_option, csi_reset);
println!(" {0}-l{1}, {0}--len <milliseconds>{1} Tone length", csi_option, csi_reset);
Ok(())
}

View File

@ -146,7 +146,7 @@ fn help_usage() {
println!("{}Usage:{} disk usage {}<options>{}", csi_title, csi_reset, csi_option, csi_reset);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-b{1},{0} --binary-size{1} Use binary size", csi_option, csi_reset);
println!(" {0}-b{1}, {0}--binary-size{1} Use binary size", csi_option, csi_reset);
}
fn help() {

View File

@ -161,6 +161,6 @@ fn usage() {
println!("{}Usage:{} find {}<options> <path>{1}", csi_title, csi_reset, csi_option);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-n{1},{0} --name \"<pattern>\"{1} Find file name matching {0}<pattern>{1}", csi_option, csi_reset);
println!(" {0}-l{1},{0} --line \"<pattern>\"{1} Find lines matching {0}<pattern>{1}", csi_option, csi_reset);
println!(" {0}-n{1}, {0}--name \"<pattern>\"{1} Find file name matching {0}<pattern>{1}", csi_option, csi_reset);
println!(" {0}-l{1}, {0}--line \"<pattern>\"{1} Find lines matching {0}<pattern>{1}", csi_option, csi_reset);
}

View File

@ -57,7 +57,7 @@ fn help_summary() -> Result<(), ExitCode> {
println!();
println!("{}Credits:{}", csi_color, csi_reset);
println!(" Made with <3 in 2019-2022 by Vincent Ollivier <v@vinc.cc>");
println!(" Made with <3 in 2019-2023 by Vincent Ollivier <v@vinc.cc>");
Ok(())
}

View File

@ -401,7 +401,7 @@ fn usage() {
println!("{}Usage:{} httpd {}<options>{1}", csi_title, csi_reset, csi_option);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-d{1},{0} --dir <path>{1} Set directory to {0}<path>{1}", csi_option, csi_reset);
println!(" {0}-p{1},{0} --port <number>{1} Listen to port {0}<number>{1}", csi_option, csi_reset);
println!(" {0}-r{1},{0} --read-only{1} Set read-only mode", csi_option, csi_reset);
println!(" {0}-d{1}, {0}--dir <path>{1} Set directory to {0}<path>{1}", csi_option, csi_reset);
println!(" {0}-p{1}, {0}--port <number>{1} Listen to port {0}<number>{1}", csi_option, csi_reset);
println!(" {0}-r{1}, {0}--read-only{1} Set read-only mode", csi_option, csi_reset);
}

View File

@ -65,7 +65,7 @@ pub fn copy_files(verbose: bool) {
create_dir("/tmp/lisp", verbose);
copy_file("/tmp/lisp/colors.lsp", include_bytes!("../../dsk/tmp/lisp/colors.lsp"), verbose);
copy_file("/tmp/lisp/factorial.lsp", include_bytes!("../../dsk/tmp/lisp/factorial.lsp"), verbose);
//copy_file("/tmp/lisp/fetch.lsp", include_bytes!("../../dsk/tmp/lisp/ntp.lsp"), verbose);
//copy_file("/tmp/lisp/fetch.lsp", include_bytes!("../../dsk/tmp/lisp/fetch.lsp"), verbose);
copy_file("/tmp/lisp/fibonacci.lsp", include_bytes!("../../dsk/tmp/lisp/fibonacci.lsp"), verbose);
copy_file("/tmp/lisp/geotime.lsp", include_bytes!("../../dsk/tmp/lisp/geotime.lsp"), verbose);
//copy_file("/tmp/lisp/ntp.lsp", include_bytes!("../../dsk/tmp/lisp/ntp.lsp"), verbose);

View File

@ -232,8 +232,8 @@ fn usage() {
println!("{}Usage:{} life {}<options> [<path>]{1}", csi_title, csi_reset, csi_option);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-p{1},{0} --population <num>{1} Set the seed population to {0}<num>{1}", csi_option, csi_reset);
println!(" {0}-i{1},{0} --interval <num>{1} Set the seed interval to {0}<num>{1}", csi_option, csi_reset);
println!(" {0}-s{1},{0} --speed <num>{1} Set the simulation speed to {0}<num>{1}", csi_option, csi_reset);
println!(" {0}-q{1},{0} --quiet{1} Enable quiet mode", csi_option, csi_reset);
println!(" {0}-p{1}, {0}--population <num>{1} Set the seed population to {0}<num>{1}", csi_option, csi_reset);
println!(" {0}-i{1}, {0}--interval <num>{1} Set the seed interval to {0}<num>{1}", csi_option, csi_reset);
println!(" {0}-s{1}, {0}--speed <num>{1} Set the simulation speed to {0}<num>{1}", csi_option, csi_reset);
println!(" {0}-q{1}, {0}--quiet{1} Enable quiet mode", csi_option, csi_reset);
}

View File

@ -101,9 +101,9 @@ fn help() -> Result<(), ExitCode> {
println!("{}Usage:{} list {}<options> [<dir>]{}", csi_title, csi_reset, csi_option, csi_reset);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-a{1},{0} --all{1} Show dot files", csi_option, csi_reset);
println!(" {0}-n{1},{0} --name{1} Sort by name", csi_option, csi_reset);
println!(" {0}-s{1},{0} --size{1} Sort by size", csi_option, csi_reset);
println!(" {0}-t{1},{0} --time{1} Sort by time", csi_option, csi_reset);
println!(" {0}-a{1}, {0}--all{1} Show dot files", csi_option, csi_reset);
println!(" {0}-n{1}, {0}--name{1} Sort by name", csi_option, csi_reset);
println!(" {0}-s{1}, {0}--size{1} Sort by size", csi_option, csi_reset);
println!(" {0}-t{1}, {0}--time{1} Sort by time", csi_option, csi_reset);
Ok(())
}

View File

@ -67,7 +67,7 @@ fn help_usage() {
println!("{}Usage:{} memory usage {}<options>{}", csi_title, csi_reset, csi_option, csi_reset);
println!();
println!("{}Options:{}", csi_title, csi_reset);
println!(" {0}-b{1},{0} --binary-size{1} Use binary size", csi_option, csi_reset);
println!(" {0}-b{1}, {0}--binary-size{1} Use binary size", csi_option, csi_reset);
}
fn help() {

View File

@ -415,17 +415,17 @@ fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> {
restore_handles = true;
if !num.is_empty() {
// if let Ok(right_handle) = num.parse() {}
println!("Redirecting to a handle has not been implemented yet");
error!("Redirecting to a handle has not been implemented yet");
return Err(ExitCode::Failure);
} else {
if i == n - 1 {
println!("Could not parse path for redirection");
error!("Could not parse path for redirection");
return Err(ExitCode::Failure);
}
let path = args[i + 1];
let append_mode = head_count > 1;
if api::fs::reopen(path, left_handle, append_mode).is_err() {
println!("Could not open path for redirection");
error!("Could not open path for redirection");
return Err(ExitCode::Failure);
}
args.remove(i); // Remove path from args
@ -434,7 +434,7 @@ fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> {
n -= 1;
args.remove(i); // Remove redirection from args
} else if is_thin_arrow {
println!("Piping has not been implemented yet");
error!("Piping has not been implemented yet");
return Err(ExitCode::Failure);
}
}

View File

@ -2,7 +2,7 @@ set -e
mkdir -p images
for file in ../doc/images/*.png; do
ln -s "../$file" images/
ln -fs "../$file" images/
done
echo "# MOROS" > ../doc/test.md
@ -23,6 +23,7 @@ for md in ../doc/*.md; do
EOF
redcarpet --parse fenced-code-blocks ../doc/$md | sed "s/.md/.html/g" | sed "s/^</ </" | sed "s/ <\/code/<\/code/" >> $html
cat << EOF >> $html
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
EOF

View File

@ -46,5 +46,6 @@ MOROS Calc v0.1.0
&gt; (2 + 3) * 4
20
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -23,5 +23,6 @@
<li><code>CTRL</code> + <code>y</code> to copy (yank) a line</li>
<li><code>CTRL</code> + <code>p</code> to paste (put) a line</li>
</ul>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -201,5 +201,6 @@ k = kind of entry
n = length of name buffer
m = 13 + n
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -8,10 +8,6 @@
<body>
<h1>MOROS Games</h1>
<h2>2048</h2>
<p><img src="images/2048.png" alt="2048"></p>
<h2>Chess</h2>
<p><img src="images/chess.png" alt="chess"></p>
@ -19,5 +15,10 @@
<h2>Conway&#39;s Game of Life</h2>
<p><img src="images/life.png" alt="life"></p>
<h2>2048</h2>
<p><img src="images/2048.png" alt="2048"></p>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -84,5 +84,6 @@
<li>[ ] NIC: Intel I219-LM</li>
</ul></li>
</ul>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -73,5 +73,6 @@ system as a password for the guest account:</p>
<pre><code>$ ssh guest@try.moros.cc
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -255,5 +255,6 @@ language and reading from the filesystem.</p>
<ul>
<li>Add hexadecimal number literals</li>
</ul>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -146,8 +146,8 @@ Quit the console or reboot to apply changes
diskless mode and let MOROS run the bootscript <code>/ini/boot.sh</code> to login and use
the shell.</p>
<p>If no disks were detected or if you prefer not to use them you can mount the
system in memory to use a virtual disk with <code>memory format</code> before <code>install</code>.</p>
<p>If no disks were detected or if you prefer not to use any you can mount the
system in memory and use a virtual disk with <code>memory format</code> before <code>install</code>.</p>
<h2>Shell</h2>
@ -243,7 +243,7 @@ Hello, World!
<p>Use <code>^W</code> (a key combination of <code>CTRL</code> and <code>W</code>) inside the editor to write the
content to the file and <code>^Q</code> to quit the editor and go back to the shell.</p>
<p>The help command has a subcommand <code>help edit</code> to list the editor commands:</p>
<p>The <code>help</code> command has a subcommand <code>help edit</code> to list the editor commands:</p>
<pre><code>&gt; help edit
MOROS text editor is a very simple editor inspired by Pico, Nano, and Micro.
@ -361,7 +361,14 @@ gw: 10.0.2.2
dns: 10.0.2.3
</code></pre>
<p>A few tools are available like the <code>http</code> command:</p>
<p>A few tools are available like the generalist <code>socket</code> command that be used to
send and receive TCP packets:</p>
<pre><code>&gt; socket 10.0.2.2:1234
Hello, World!
</code></pre>
<p>Or the more specialized <code>http</code> command to request a document from a web server:</p>
<pre><code>&gt; http moros.cc /test.html
&lt;!doctype html&gt;
@ -376,5 +383,6 @@ dns: 10.0.2.3
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -1,22 +1,63 @@
:where(pre) {
all: revert;
}
html {
display: grid;
place-content: center;
--shadow-color: 49deg 36% 46%;
--img-width: 720px;
}
body {
font-family: sans-serif;
max-width: 720px;
max-width: var(--img-width);
margin: 1rem;
color: #111;
background: #FBF1C7;
color: #3C3836;
font-size: 18px;
line-height: 1.5;
}
li code,
p code {
background: #eee;
padding: 0.125rem;
a {
color: #8F3F71;
}
a:hover, a:active {
color: #B17286;
}
li code, p code, pre {
color: #EBDBB2;
border-radius: 0.25rem;
}
li code, p code {
background: #7C6F64;
padding: 0.125rem;
}
pre {
background: #eee;
background: #282828;
padding: 1rem;
border-radius: 0.25rem;
line-height: 1.1;
}
img {
width: var(--img-width);
margin-left: calc(-16px - 2px);
margin-bottom: 1em;
border: solid 16px #D5C4A1;
border-radius: 16px;
box-shadow:
0.2px 0.2px 0.4px hsl(var(--shadow-color) / 0.14),
0.9px 0.9px 1.6px -0.2px hsl(var(--shadow-color) / 0.16),
1.7px 1.6px 3px -0.4px hsl(var(--shadow-color) / 0.19),
2.5px 2.5px 4.5px -0.6px hsl(var(--shadow-color) / 0.21),
3.8px 3.7px 6.8px -0.9px hsl(var(--shadow-color) / 0.23),
5.6px 5.4px 9.9px -1.1px hsl(var(--shadow-color) / 0.25),
8.1px 7.9px 14.4px -1.3px hsl(var(--shadow-color) / 0.28),
11.6px 11.4px 20.7px -1.5px hsl(var(--shadow-color) / 0.3);
outline: solid 2px #28282828;
outline-offset: 1px;
background: #28282878;
padding: 2px;
}
footer {
margin-top: 2em;
text-align: center;
}

View File

@ -177,5 +177,6 @@ QUIT
<pre><code>&gt; socket 10.0.2.2:1234 &lt;= /tmp/alice.txt
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -29,5 +29,6 @@
<p>The engine is UTF-8 aware, so for example the unicode character <code>é</code> will be
matched by <code>\w</code> even if it&#39;s not present in the ASCII table and has a size
of two bytes.</p>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -238,5 +238,6 @@ by files matching the pattern.</p>
<p>The tilde character <code>~</code> is a shortcut to <code>$HOME</code> so <code>~/test</code> will be expanded
to <code>$HOME/test</code> by the shell.</p>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -60,26 +60,42 @@
<pre><code class="rust">pub fn stop(code: usize)
</code></pre>
<p>The system will reboot with <code>0xcafe</code> and halt with <code>0xdead</code>.</p>
<p>The system will reboot with <code>0xCAFE</code> and halt with <code>0xDEAD</code>.</p>
<h2>SLEEP (0xB)</h2>
<pre><code class="rust">pub fn sleep(seconds: f64)
</code></pre>
<h2>CONNECT (0xC)</h2>
<h2>POLL (0xC)</h2>
<pre><code class="rust">pub fn poll(list: &amp;[(usize, IO)]) -&gt; isize
</code></pre>
<h2>CONNECT (0xD)</h2>
<pre><code class="rust">pub fn connect(handle, usize, addr: &amp;str, port: u16) -&gt; isize
</code></pre>
<h2>LISTEN (0xD)</h2>
<h2>LISTEN (0xE)</h2>
<pre><code class="rust">pub fn listen(handle, usize, port: u16) -&gt; isize
</code></pre>
<h2>ACCEPT (0xE)</h2>
<h2>ACCEPT (0xF)</h2>
<pre><code class="rust">pub 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
</code></pre>
<h2>FREE (0x11)</h2>
<pre><code class="rust">pub fn free(ptr: *mut u8, size: usize, align: usize)
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>

View File

@ -7,5 +7,6 @@
</head>
<body>
<h1>MOROS</h1>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>