diff --git a/Makefile b/Makefile index dd3eb63..1d98ab3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/doc/manual.md b/doc/manual.md index 5451283..8e95eeb 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -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 diff --git a/doc/syscalls.md b/doc/syscalls.md index deed4d0..59fa17e 100644 --- a/doc/syscalls.md +++ b/doc/syscalls.md @@ -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) +``` diff --git a/dsk/src/bin/halt.s b/dsk/src/bin/halt.s index 2b1d727..4ad97e7 100644 --- a/dsk/src/bin/halt.s +++ b/dsk/src/bin/halt.s @@ -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 diff --git a/run/bochs.rc b/run/bochs.rc index 34ae004..97fa044 100644 --- a/run/bochs.rc +++ b/run/bochs.rc @@ -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 diff --git a/src/api/syscall.rs b/src/api/syscall.rs index c37c30c..4e3fd72 100644 --- a/src/api/syscall.rs +++ b/src/api/syscall.rs @@ -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)> { diff --git a/src/lib.rs b/src/lib.rs index 3c26ba5..92d8a02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); } } diff --git a/src/sys/net/nic/rtl8139.rs b/src/sys/net/nic/rtl8139.rs index 6735457..92cd4d2 100644 --- a/src/sys/net/nic/rtl8139.rs +++ b/src/sys/net/nic/rtl8139.rs @@ -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 } } } diff --git a/src/sys/syscall/service.rs b/src/sys/syscall/service.rs index 6264c26..efcc0e5 100644 --- a/src/sys/syscall/service.rs +++ b/src/sys/syscall/service.rs @@ -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(); } diff --git a/src/usr/beep.rs b/src/usr/beep.rs index 6955e44..fe1c7d7 100644 --- a/src/usr/beep.rs +++ b/src/usr/beep.rs @@ -86,7 +86,7 @@ fn help() -> Result<(), ExitCode> { println!("{}Usage:{} beep {}{1}", csi_title, csi_reset, csi_option); println!(); println!("{}Options:{}", csi_title, csi_reset); - println!(" {0}-f{1},{0} --freq {1} Tone frequency", csi_option, csi_reset); - println!(" {0}-l{1},{0} --len {1} Tone length", csi_option, csi_reset); + println!(" {0}-f{1}, {0}--freq {1} Tone frequency", csi_option, csi_reset); + println!(" {0}-l{1}, {0}--len {1} Tone length", csi_option, csi_reset); Ok(()) } diff --git a/src/usr/disk.rs b/src/usr/disk.rs index 80eb999..25810ff 100644 --- a/src/usr/disk.rs +++ b/src/usr/disk.rs @@ -146,7 +146,7 @@ fn help_usage() { println!("{}Usage:{} disk usage {}{}", 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() { diff --git a/src/usr/find.rs b/src/usr/find.rs index b27e28b..dfb6355 100644 --- a/src/usr/find.rs +++ b/src/usr/find.rs @@ -161,6 +161,6 @@ fn usage() { println!("{}Usage:{} find {} {1}", csi_title, csi_reset, csi_option); println!(); println!("{}Options:{}", csi_title, csi_reset); - println!(" {0}-n{1},{0} --name \"\"{1} Find file name matching {0}{1}", csi_option, csi_reset); - println!(" {0}-l{1},{0} --line \"\"{1} Find lines matching {0}{1}", csi_option, csi_reset); + println!(" {0}-n{1}, {0}--name \"\"{1} Find file name matching {0}{1}", csi_option, csi_reset); + println!(" {0}-l{1}, {0}--line \"\"{1} Find lines matching {0}{1}", csi_option, csi_reset); } diff --git a/src/usr/help.rs b/src/usr/help.rs index 66ccf1b..9443edc 100644 --- a/src/usr/help.rs +++ b/src/usr/help.rs @@ -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 "); + println!(" Made with <3 in 2019-2023 by Vincent Ollivier "); Ok(()) } diff --git a/src/usr/httpd.rs b/src/usr/httpd.rs index ce62809..d4a8609 100644 --- a/src/usr/httpd.rs +++ b/src/usr/httpd.rs @@ -401,7 +401,7 @@ fn usage() { println!("{}Usage:{} httpd {}{1}", csi_title, csi_reset, csi_option); println!(); println!("{}Options:{}", csi_title, csi_reset); - println!(" {0}-d{1},{0} --dir {1} Set directory to {0}{1}", csi_option, csi_reset); - println!(" {0}-p{1},{0} --port {1} Listen to port {0}{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 {1} Set directory to {0}{1}", csi_option, csi_reset); + println!(" {0}-p{1}, {0}--port {1} Listen to port {0}{1}", csi_option, csi_reset); + println!(" {0}-r{1}, {0}--read-only{1} Set read-only mode", csi_option, csi_reset); } diff --git a/src/usr/install.rs b/src/usr/install.rs index 6a9bcf2..ebd9047 100644 --- a/src/usr/install.rs +++ b/src/usr/install.rs @@ -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); diff --git a/src/usr/life.rs b/src/usr/life.rs index 1f5110e..f97c1cc 100644 --- a/src/usr/life.rs +++ b/src/usr/life.rs @@ -232,8 +232,8 @@ fn usage() { println!("{}Usage:{} life {} []{1}", csi_title, csi_reset, csi_option); println!(); println!("{}Options:{}", csi_title, csi_reset); - println!(" {0}-p{1},{0} --population {1} Set the seed population to {0}{1}", csi_option, csi_reset); - println!(" {0}-i{1},{0} --interval {1} Set the seed interval to {0}{1}", csi_option, csi_reset); - println!(" {0}-s{1},{0} --speed {1} Set the simulation speed to {0}{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 {1} Set the seed population to {0}{1}", csi_option, csi_reset); + println!(" {0}-i{1}, {0}--interval {1} Set the seed interval to {0}{1}", csi_option, csi_reset); + println!(" {0}-s{1}, {0}--speed {1} Set the simulation speed to {0}{1}", csi_option, csi_reset); + println!(" {0}-q{1}, {0}--quiet{1} Enable quiet mode", csi_option, csi_reset); } diff --git a/src/usr/list.rs b/src/usr/list.rs index 48e24ac..63dd8d4 100644 --- a/src/usr/list.rs +++ b/src/usr/list.rs @@ -101,9 +101,9 @@ fn help() -> Result<(), ExitCode> { println!("{}Usage:{} list {} []{}", 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(()) } diff --git a/src/usr/memory.rs b/src/usr/memory.rs index 271511e..d3fcc5e 100644 --- a/src/usr/memory.rs +++ b/src/usr/memory.rs @@ -67,7 +67,7 @@ fn help_usage() { println!("{}Usage:{} memory usage {}{}", 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() { diff --git a/src/usr/shell.rs b/src/usr/shell.rs index 816cba7..e0b0f45 100644 --- a/src/usr/shell.rs +++ b/src/usr/shell.rs @@ -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); } } diff --git a/www/build.sh b/www/build.sh index 962202c..1a1695b 100644 --- a/www/build.sh +++ b/www/build.sh @@ -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/^> $html cat << EOF >> $html + EOF diff --git a/www/calculator.html b/www/calculator.html index 411df9b..e6851a7 100644 --- a/www/calculator.html +++ b/www/calculator.html @@ -46,5 +46,6 @@ MOROS Calc v0.1.0 > (2 + 3) * 4 20 + diff --git a/www/editor.html b/www/editor.html index ffb8880..d4ca7de 100644 --- a/www/editor.html +++ b/www/editor.html @@ -23,5 +23,6 @@
  • CTRL + y to copy (yank) a line
  • CTRL + p to paste (put) a line
  • + diff --git a/www/filesystem.html b/www/filesystem.html index f28cc71..c15edac 100644 --- a/www/filesystem.html +++ b/www/filesystem.html @@ -201,5 +201,6 @@ k = kind of entry n = length of name buffer m = 13 + n + diff --git a/www/games.html b/www/games.html index ed58f05..d332cad 100644 --- a/www/games.html +++ b/www/games.html @@ -8,10 +8,6 @@

    MOROS Games

    -

    2048

    - -

    2048

    -

    Chess

    chess

    @@ -19,5 +15,10 @@

    Conway's Game of Life

    life

    + +

    2048

    + +

    2048

    + diff --git a/www/hardware.html b/www/hardware.html index a48b97a..386757d 100644 --- a/www/hardware.html +++ b/www/hardware.html @@ -84,5 +84,6 @@
  • [ ] NIC: Intel I219-LM
  • + diff --git a/www/index.html b/www/index.html index 7e13d52..da2dc7c 100644 --- a/www/index.html +++ b/www/index.html @@ -73,5 +73,6 @@ system as a password for the guest account:

    $ ssh guest@try.moros.cc
     
    + diff --git a/www/lisp.html b/www/lisp.html index 87b98c9..a3f99ea 100644 --- a/www/lisp.html +++ b/www/lisp.html @@ -255,5 +255,6 @@ language and reading from the filesystem.

    • Add hexadecimal number literals
    + diff --git a/www/manual.html b/www/manual.html index 082755f..4377b69 100644 --- a/www/manual.html +++ b/www/manual.html @@ -146,8 +146,8 @@ Quit the console or reboot to apply changes 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

    @@ -243,7 +243,7 @@ Hello, World!

    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.
    @@ -361,7 +361,14 @@ 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>
    @@ -376,5 +383,6 @@ dns: 10.0.2.3
       </body>
     </html>
     
    + diff --git a/www/moros.css b/www/moros.css index 79ea24f..0447ff4 100644 --- a/www/moros.css +++ b/www/moros.css @@ -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; } diff --git a/www/network.html b/www/network.html index 5f72fad..ca15ae9 100644 --- a/www/network.html +++ b/www/network.html @@ -177,5 +177,6 @@ QUIT
    > socket 10.0.2.2:1234 <= /tmp/alice.txt
     
    + diff --git a/www/regex.html b/www/regex.html index a5a6913..6ebddd9 100644 --- a/www/regex.html +++ b/www/regex.html @@ -29,5 +29,6 @@

    The engine is UTF-8 aware, so for example the unicode character é will be matched by \w even if it's not present in the ASCII table and has a size of two bytes.

    + diff --git a/www/shell.html b/www/shell.html index df8720f..eef7adf 100644 --- a/www/shell.html +++ b/www/shell.html @@ -238,5 +238,6 @@ by files matching the pattern.

    The tilde character ~ is a shortcut to $HOME so ~/test will be expanded to $HOME/test by the shell.

    + diff --git a/www/syscalls.html b/www/syscalls.html index 1de7839..dc93056 100644 --- a/www/syscalls.html +++ b/www/syscalls.html @@ -60,26 +60,42 @@
    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)

    pub fn sleep(seconds: f64)
     
    -

    CONNECT (0xC)

    +

    POLL (0xC)

    + +
    pub fn poll(list: &[(usize, IO)]) -> isize
    +
    + +

    CONNECT (0xD)

    pub fn connect(handle, usize, addr: &str, port: u16) -> isize
     
    -

    LISTEN (0xD)

    +

    LISTEN (0xE)

    pub fn listen(handle, usize, port: u16) -> isize
     
    -

    ACCEPT (0xE)

    +

    ACCEPT (0xF)

    pub fn accept(handle, usize, addr: &str) -> isize
     
    + +

    ALLOC (0x10)

    + +
    pub fn alloc(size: usize, align: usize) -> *mut u8
    +
    + +

    FREE (0x11)

    + +
    pub fn free(ptr: *mut u8, size: usize, align: usize)
    +
    + diff --git a/www/test.html b/www/test.html index b9a43c8..32f13db 100644 --- a/www/test.html +++ b/www/test.html @@ -7,5 +7,6 @@

    MOROS

    +