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

Add chess game #230

Merged
merged 20 commits into from
Aug 12, 2021
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
73 changes: 68 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ time = { version = "0.2.27", default-features = false }
uart_16550 = "0.2.15"
vte = "0.10.1"
x86_64 = "0.14.4"
littlewing = { git = "https://github.com/vinc/littlewing", branch = "feature/add-no-std-support", default-features = false }
#littlewing = { path = "../littlewing", default-features = false }

[package.metadata.bootimage]
test-success-exit-code = 33 # (0x10 << 1) | 1
Binary file added doc/chess.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 79 additions & 6 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,100 @@

MOROS is a hobby operating system written in Rust for the x86 architecture.

It targets 64 bits processors with a legacy BIOS, so roughly computers from the
2010 era, but it also run well on most hypervisors.

![screenshot](moros.png)

Everything in MOROS is done from a command line interface and most tools are
The first task when running the OS is to install the
[filesystem](filesystem.md) on a disk (or in RAM) using the `install` program,
although it's possible to skip the installation and stay in read only mode.

Everything in MOROS is done from a command line interface and most programs are
rather minimalist.

It has a shell:
It has a [shell](shell.md):

![screenshot](shell.png)

With a few tools like `find` that use a regex engine to find files or lines:
With a few programs like `find` that use a [regex engine](regex.md) to find
files or lines:

![screenshot](find.png)

It also has a lisp interpreter:
It also has a [lisp](lisp.md) interpreter:

![screenshot](lisp.png)

And a text editor:
And a [text editor](editor.md):

![screenshot](edit.png)

It has a network stack with two drivers for RTL81339 and PCNET cards:
It has a [network stack](network.md) with two drivers for RTL81339 and PCNET cards:

![screenshot](network.png)

It even has a chess game:

![chess](chess.png)

Finally here are a few commands to try it out:

> date
2021-08-12T20:16:48

> memory
Size: 16777216
Used: 15400
Free: 16761816

> disk
Size: 8388608
Used: 445440
Free: 7943168

> list /tmp
5083 2021-08-07 15:10:09 alice.txt
118 2021-08-07 15:10:09 fibonacci.lisp

> goto /tmp

> read fibonacci.lisp
(label fib
(lambda (n)
(cond
((< n 2) n)
(true (+ (fib (- n 1)) (fib (- n 2)))))))

(print (fib 6))

> lisp fibonacci.lisp
8

> find /tmp --line "p.*nt"
/tmp/alice.txt
9: bank, and of having nothing to do: once or twice she had peeped into the
36: dipped suddenly down, so suddenly that Alice had not a moment to think
41: plenty of time as she went down to look about her and to wonder what was
48: disappointment it was empty: she did not like to drop the jar for fear
49: of killing somebody, so managed to put it into one of the cupboards as
85: began to get rather sleepy, and went on saying to herself, in a dreamy

/tmp/fibonacci.lisp
7: (print (fib 6))

> dhcp
DHCP Discover transmitted
DHCP Offer received
Leased: 10.0.2.15/24
Router: 10.0.2.2
DNS: 10.0.2.3

> tcp time.nist.gov 13
Connecting to 132.163.97.4:13

59438 21-08-12 20:18:27 50 0 0 358.8 UTC(NIST) *

> halt
MOROS has reached its fate, the system is now halting.
[782.191890] ACPI Shutdown
2 changes: 1 addition & 1 deletion doc/lisp.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A minimalist Lisp interpreter is available in MOROS to extend the capabilities
of the Shell.

It started from [Risp][https://github.com/stopachka/risp] and was extended to
It started from [Risp](https://github.com/stopachka/risp) and was extended to
include the seven primitive operators and the two special forms of John
McCarthy's paper "Recursive Functions of Symbolic Expressions and Their
Computation by Machine" (1960) and "The Roots of Lisp" (2002) by Paul Graham.
Expand Down
2 changes: 1 addition & 1 deletion src/sys/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use x86_64::structures::paging::{FrameAllocator, Mapper, Page, PageTableFlags, S
use x86_64::VirtAddr;

pub const HEAP_START: usize = 0x_4444_4444_0000;
pub const HEAP_SIZE: usize = 8 << 20; // MB
pub const HEAP_SIZE: usize = 16 << 20; // MB

#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
Expand Down
6 changes: 1 addition & 5 deletions src/sys/fs/block_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ impl BlockDeviceIO for MemBlockDevice {
}

pub fn mount_mem() {
let len = sys::allocator::HEAP_SIZE / 2 / 512;
// FIXME: `len` should be equal to `super::DISK_SIZE` which is set during
// compilation for now. But that's not the case because the allocator is
// too slow to allocate more than a few megabytes of memory. So we take
// half of the heap and will panic when this get full.
let len = super::DISK_SIZE / 2;
let dev = MemBlockDevice::new(len);
*BLOCK_DEVICE.lock() = Some(BlockDevice::Mem(dev));
}
Expand Down
Loading