Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve system information #553

Merged
merged 9 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions doc/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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>
Expand Down
26 changes: 22 additions & 4 deletions doc/syscalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,46 @@ 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)

```rust
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)
```
6 changes: 3 additions & 3 deletions dsk/src/bin/halt.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion run/bochs.rc
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/api/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/net/nic/rtl8139.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/sys/syscall/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ 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",
"mov cr3, rax"
);
}
}
0xdead => { // Halt
0xDEAD => { // Halt
sys::process::exit();
sys::acpi::shutdown();
}
Expand Down
4 changes: 2 additions & 2 deletions src/usr/beep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
2 changes: 1 addition & 1 deletion src/usr/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/usr/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/usr/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>");
println!(" Made with <3 in 2019-2023 by Vincent Ollivier <[email protected]>");
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions src/usr/httpd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/usr/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/usr/life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
8 changes: 4 additions & 4 deletions src/usr/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
2 changes: 1 addition & 1 deletion src/usr/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions src/usr/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,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
Expand All @@ -430,7 +430,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);
}
}
Expand Down
3 changes: 2 additions & 1 deletion www/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions www/calculator.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ <h1>MOROS Calculator</h1>
&gt; (2 + 3) * 4
20
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
1 change: 1 addition & 0 deletions www/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ <h2>Commands</h2>
<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>
1 change: 1 addition & 0 deletions www/filesystem.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,6 @@ <h3>FileInfo</h3>
n = length of name buffer
m = 13 + n
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
9 changes: 5 additions & 4 deletions www/games.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
<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>

<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>
1 change: 1 addition & 0 deletions www/hardware.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ <h3>Laptops</h3>
<li>[ ] NIC: Intel I219-LM</li>
</ul></li>
</ul>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ <h2>Demo</h2>

<pre><code>$ ssh [email protected]
</code></pre>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
1 change: 1 addition & 0 deletions www/lisp.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,6 @@ <h3>Unreleased</h3>
<ul>
<li>Add hexadecimal number literals</li>
</ul>
<footer><p><a href="/">MOROS</a></footer>
</body>
</html>
Loading