Merge pull request #1 from redox-os/master

Update
This commit is contained in:
Emanuele Antonio Faraone 2017-08-17 08:37:02 +02:00 • committed by GitHub
commit 1595cb9ccb
269 changed files with 800 additions and 21034 deletions

View file

@ -4,7 +4,8 @@
**Actual behavior**: [describe the actual behavior, which is presented through the repro.].
**Build information**: [output of `rustc -V`, `git rev-parse HEAD`, `qemu-i386 -version`, `uname -a`, etc.]
**Build information**: [only when using a self build version: output of `rustc -V`, `git rev-parse HEAD` `qemu-i386 -version`, `uname -a`, etc.]
**Redox release**: [only when using a prebuild version: redox version]
**Blocking/related**: [issues or PRs blocking or being related to this issue.]

6
.gitignore vendored
View file

@ -1,7 +1 @@
Cargo.lock
build
target
initfs/bin
filesystem/bin
filesystem/ref
filesystem/sbin

75
.gitmodules vendored
View file

@ -1,60 +1,21 @@
[submodule "rust"]
path = rust
url = https://github.com/redox-os/rust.git
[submodule "ion"]
path = programs/ion
url = https://github.com/redox-os/ion.git
[submodule "programs/coreutils"]
path = programs/coreutils
url = https://github.com/redox-os/coreutils.git
[submodule "schemes/redoxfs"]
path = schemes/redoxfs
url = https://github.com/redox-os/redoxfs
[submodule "programs/extrautils"]
path = programs/extrautils
url = https://github.com/redox-os/extrautils.git
[submodule "programs/smith"]
path = programs/smith
url = https://github.com/IGI-111/Smith.git
[submodule "programs/userutils"]
path = programs/userutils
url = https://github.com/redox-os/userutils.git
[submodule "programs/netutils"]
path = programs/netutils
url = https://github.com/redox-os/netutils.git
[submodule "schemes/orbital"]
path = schemes/orbital
url = https://github.com/redox-os/orbital.git
[submodule "programs/orbutils"]
path = programs/orbutils
url = https://github.com/redox-os/orbutils.git
[submodule "filesystem/ui"]
path = filesystem/ui
url = https://github.com/redox-os/orbdata.git
[submodule "programs/acid"]
path = programs/acid
url = https://github.com/redox-os/acid.git
[submodule "programs/tar"]
path = programs/tar
url = https://github.com/redox-os/tar-rs.git
[submodule "programs/pkgutils"]
path = programs/pkgutils
url = https://github.com/redox-os/pkgutils.git
[submodule "bootloader"]
path = bootloader
url = https://github.com/redox-os/bootloader.git
[submodule "cookbook"]
path = cookbook
url = https://github.com/redox-os/cookbook.git
[submodule "installer"]
path = installer
url = https://github.com/redox-os/installer.git
[submodule "syscall"]
path = syscall
url = https://github.com/redox-os/syscall.git
[submodule "crates/docgen"]
path = crates/docgen
url = https://github.com/redox-os/docgen.git
[submodule "programs/binutils"]
path = programs/binutils
url = https://github.com/redox-os/binutils.git
[submodule "libc-artifacts"]
path = libc-artifacts
url = https://github.com/redox-os/libc-artifacts.git
[submodule "programs/games"]
path = programs/games
url = https://github.com/redox-os/games.git
[submodule "isolinux"]
path = isolinux
url = https://github.com/redox-os/isolinux.git
[submodule "kernel"]
path = kernel
url = https://github.com/redox-os/kernel.git
[submodule "rust"]
path = rust
url = https://github.com/redox-os/rust.git
[submodule "redoxfs"]
path = redoxfs
url = https://github.com/redox-os/redoxfs.git

View file

@ -5,23 +5,30 @@ rust:
cache: cargo
os:
- linux
#- osx
#matrix:
# allow_failures:
# - os: osx
dist: trusty
before_install:
- if [ `uname` = "Linux" ]; then
sudo apt-get install -qq nasm pkg-config fuse libfuse-dev genisoimage syslinux &&
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-key adv -q --batch --yes --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F &&
sudo add-apt-repository 'deb https://static.redox-os.org/toolchain/apt ./' &&
sudo apt-get update -qq &&
sudo apt-get purge -qq binutils-doc &&
sudo apt-get install -qq nasm pkg-config fuse libfuse-dev genisoimage syslinux x86-64-unknown-redox-gcc &&
sudo modprobe fuse &&
sudo chmod 666 /dev/fuse &&
sudo chown root:$USER /etc/fuse.conf;
fi
- if [ `uname` = "Darwin" ]; then brew update &&
brew install nasm gcc49 pkg-config Caskroom/cask/osxfuse &&
brew tap glendc/gcc_cross_compilers &&
brew install glendc/gcc_cross_compilers/x64-elf-binutils glendc/gcc_cross_compilers/x64-elf-gcc;
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update &&
brew install nasm pkg-config Caskroom/cask/osxfuse &&
travis_wait 30 brew install redox-os/gcc_cross_compilers/x86_64-elf-gcc;
fi
- cd cookbook && ./setup.sh && cd ..
script:
- make clean &&
make update &&
make build/harddrive.bin.gz build/livedisk.bin.gz build/livedisk.iso -j 2
- make clean && make travis
notifications:
email: false
webhooks: http://37.139.9.28:54863/travis
@ -29,11 +36,10 @@ deploy:
provider: releases
api_key:
secure: E5w3mgFbW4fAFNJn0FGcvwGKK33d+StC4izDX7dsGPxX/gwAsMnZqabDWpsrj8n/jFI5NdPzuyz4Ojkip4AXrEs0DWfX96d9CSWvJmWIirwwKhALnxZ5cqnHnBXY3wpk9k8MKpdODzKs3ZjM3pPug2jjjp2EHdrEV6iyc8LlnLAJutbtPpNJv0rJrx/TfCZRx70YWKQyx2Lfx5P6Vj+5yoYsKk+SHmKZlIQfj2E1cfC8+/w+fzc9CRTNhM9XFBisKnu9qql3nNhEW8VUNQ9FnltGpunmcTnCmsKzHPfs8Zv6kM/6y3wuoqxwPnIwRu+zsntkjM/eT7Zy3DtTBqJDjq+L5jov50QWOxzjUuFYMv0lAMeMC0PIGn0ECpFs546M+Wqvd7HKgabac0UhilEBPbinOdW+6aOOhbo+Fe2I2ec0XIGxlQpccQeWQUsjjOQ+6QuvnpPE+CbvQaVyrx27rVAkqD44cOP8xqOq2Es651J+Dt0O1OIhLdPB3FxOLCDpEIHU5Ojci1QbUxZgGKjShpo44nNqcTv7v71JrfzFSVG2pF9a35Mpo6bFEkzyQprOyrwH2fcnN+4jyxdJXzdNsgraXsQopWAB5cL/8i7SXMwHy9ivpFaX/zgoHQqpc1a4VjrmTtPA08rLORIllw9CplfvJNsmNmCi2aSeTXR06Xk=
file:
- build/harddrive.bin.gz
- build/livedisk.bin.gz
- build/livedisk.iso
file_glob: true
file: build/travis/*
on:
repo: redox-os/redox
tags: true
condition: $TRAVIS_OS_NAME = linux
skip_cleanup: true

View file

@ -1,17 +1,18 @@
# Contributing to Redox
Thank you for your interest in contributing to Redox! This document is a guide to help newcomers contribute!
There are many ways to help us out and we appreciate all of them.
Thank you for your interest in contributing to Redox! This document will outline the basics of where to start if you wish to contribute to the project. There are many ways to help us out and and we appreciate all of them. We look forward to your contribution!
## Index
* [Communication](#communication)
* [Chat](#chat)
* [Reddit](#reddit)
* [Direct Contributing](#direct-contributing)
* [Low-Hanging Fruit - Easy Targets for Newbies](#easy-targets)
* [GitHub Issues](#gh-issues)
* [GitHub Issues](#issues)
* [Pull Requests](#prs)
* [Discourse](#discourse)
* [Reddit](#reddit)
* [News](#news)
* [Code Contributions](#code-contributions)
* [Low-Hanging Fruit - Easy Targets for Newbies](#easy-targets)
* [Creating a Pull Request](#creating-a-pr)
* [Best Practices/Guidelines](#best-practices)
* [General](#general)
@ -22,10 +23,11 @@ There are many ways to help us out and we appreciate all of them.
* [Git](#git-style-guidelines)
* [Other Ways to Contribute](#other)
* [Graphic Design](#graphic-design)
* [Patreon](#patreon)
## <a name="extern-links"> Other External Links </a>
* [redox-os.org](http://redox-os.org)
* [redox-os.org](https://redox-os.org)
* [rust-os-comparison](https://github.com/flosse/rust-os-comparison)
* [rust-lang.org](http://rust-lang.org)
@ -33,70 +35,77 @@ There are many ways to help us out and we appreciate all of them.
### <a name="chat"> Chat </a>
The quickest and most open way to communicate with the Redox team is on our chat server. Currently, the only way to join it is by sending an email to [info@redox-os.org](mailto:info@redox-os.org), which might take a little while, since it's not automated. We're currently working on an easier way to do this, but this is the most convenient way right now.
The quickest and most open way to communicate with the Redox team is on our chat server. Currently, you can only get an invite by sending an email request to [info@redox-os.org](mailto:info@redox-os.org), which might take a little while, since it's not automated. Simply say you'd like to join the chat. We're working on an better way to do this, but this is the best way right now.
### <a name="issues"> GitHub Issues </a>
A bit more formal way of communication with fellow Redox devs, but a little less quick and convenient like the chat. Submit an issue when you run into problems compiling, testing, or just would like to discuss a certain topic, be it features, code style, code inconsistencies, minor changes and fixes, etc.
### <a name="prs"> Pull Requests </a>
It's fine to just submit a small pull request without first making an issue or asking in the chat, but if it's a significant change that will require a lot of planning and reviewing. Also see [Creating a Pull Request](#creating-a-pr) and [Git Style Guidelines](#git-style-guidelines).
### <a name="discourse"> Discourse </a>
We have a discourse forum at [discourse.redox-os.org](https://discourse.redox-os.org). This is the best way to discuss more general topics that aren't about specific things that need to be addressed one way or another. You can sign up like any other website.
### <a name="reddit"> Reddit </a>
You can find Redox on Reddit in [/r/rust/](https://www.reddit.com/r/rust) and [/r/redox/](https://www.reddit.com/r/redox). The weekly update news is posted on the former.
You can also find Redox on Reddit in [/r/rust/](https://www.reddit.com/r/rust) and [/r/redox/](https://www.reddit.com/r/redox). Redox news and discussion is posted on the latter, and Rust news and discussion, as well as some Redox posts, is on the former.
## <a name="direct-contributing"> Direct Contributing </a>
### <a name="news"> News </a>
News and updates for Redox are posted at [redox-os.org/news](https://redox-os.org/news). It's more one-way than the other things on this list, but it should provide a good summary of what's been going on with the project lately. It's usually updated weekly, but with some exceptions. A mailing list may be included eventually, but it's not set up right now.
## <a name="code-contributions"> Code Contributions </a>
### <a name="easy-targets"> Low-Hanging Fruit - Easy Targets for Newbies </a>
* If you're not fluent in Rust:
#### If you're not fluent in Rust:
* Writing documentation
* Using/testing Redox, filing issues for bugs and needed features
* Web development ([Redox website, separate repo](https://github.com/redox-os/website))
* Writing unit tests (may require minimal knowledge of rust)
* If you are fluent in Rust, but not OS Development:
#### If you are fluent in Rust, but not OS Development:
* Apps development
* Shell ([Ion](https://github.com/redox-os/ion)) development
* Package manager ([Magnet](https://github.com/redox-os/magnet)) development
* Package management ([pkgutils](https://github.com/redox-os/pkgutils)) development
* Other high-level code tasks
* If you are fluent in Rust, and have experience with OS Dev:
#### If you are fluent in Rust, and have experience with OS Dev:
* Familiarize yourself with the repository and codebase
* Grep for `TODO`, `FIXME`, `BUG`, `UNOPTIMIZED`, `REWRITEME`, `DOCME`, and `PRETTYFYME` and fix the code you find.
* Improve and optimize code, especially in the kernel
### <a name="gh-issues"> GitHub Issues </a>
A bit more formal way of communication with fellow Redox devs, but a little less quick and convenient like the chat (unless of course you aren't in it yet, which if you're going to be involved in this project really at all, it is recommended that you request to join). These are for more specific topics.
### <a name="prs"> Pull Requests </a>
It's completely okay to just submit a small pull request without first making an issue or something, but if it's a significant change that will require a lot of planning and reviewing, it's best you start with writing an issue first. Also see [git guidelines](#git-style-guidelines)
### <a name="creating-a-pr"> Creating a Pull Request </a>
1. Fork the repository
2. Clone the original repository to your local PC using one of the following commands based on the protocol you are using:
* HTTPS:`git clone https://github.com/redox-os/redox.git --origin upstream --recursive`
* SSH:`git clone git@github.com:redox-os/redox.git --origin upstream --recursive`
* Then rebase: `git rebase upstream master`
Use HTTPS if you don't know which one to use. (Recommended: learn about SSH if you don't want to have to log in every time you push/pull!)
* Then rebase: `git rebase upstream master`
If you use HTTPS, you will have to log in each time when pushing to your fork. (Recommended: learn about git SSH support, it logs in automatically using SSH keys)
3. Add your fork with
* HTTPS:`git remote add origin https://github.com/your-username/redox.git`
* SSH:`git remote add origin git@github.com:your-username/redox.git`
4. Alternatively, if you already have a fork and copy of the repo, you can simply check to make sure you're up-to-date
* Fetch the upstream:`git fetch upstream master`
* Rebase with local commits:`git rebase upstream/master`
* Update the submodules:`git submodule update --init`
5. Optionally create a separate branch (recommended if you're making multiple changes simultaneously) (`git checkout -b my-branch`)
* Pull the upstream:`git pull upstream --rebase`
* Update the submodules:`git submodule update --recursive --init`
5. Create a separate branch (recommended if you're making multiple changes simultaneously) (`git checkout -b my-branch`)
6. Make changes
7. Commit (`git add . --all; git commit -m "my commit"`)
7. Commit (`git add <item(s) you changed>; git commit`) and write your commit message
8. Optionally run [rustfmt](https://github.com/rust-lang-nursery/rustfmt) on the files you changed and commit again if it did anything (check with `git diff` first)
9. Test your changes with `make qemu` or `make virtualbox` (you might have to use `make qemu kvm=no`, formerly `make qemu_no_kvm`)
9. Test your changes by cleaning (`make clean; git clean -Xfd`) and building with `make qemu` (you might have to use `make qemu kvm=no`) or `make virtualbox`.
(see [Best Practices and Guidelines](#best-practices))
10. Pull from upstream (`git fetch upstream; git rebase upstream/master`) (Note: try not to use `git pull`, it is equivalent to doing `git fetch upstream; git merge master upstream/master`, which is not usually preferred for local/fork repositories, although it is fine in some cases.)
10. Pull from upstream (`git pull upstream --rebase`) (Note: Make sure to include `--rebase`, as it will apply your changes on top of the changes you just pulled, allowing for a much cleaner merge)
11. Repeat step 9 to make sure the rebase still builds and starts
12. Push to your fork (`git push origin my-branch`)
12. Push to your fork (`git push origin <branch>`), `<branch>` being the branch you created earlier
13. Create a pull request
14. Describe your changes
14. If your changes are minor, you can just describe them in a paragraph or less. If they're major, please fill out the provided form.
15. Submit!
## <a name="best-practices"> Best Practices and Guidelines </a>
@ -105,36 +114,36 @@ It's completely okay to just submit a small pull request without first making an
* **Remember to do a `git rebase -i upstream/master` before you send your patch!**
* **Make sure your code is readable, commented, and well-documented.**
* **Don't hesitate to ask for help!**
* **Before implementing something, discuss it! Open an issue, or join the chat.**
* **Don't hesitate to ask for help, comments or suggestions!**
* **Before implementing something, discuss it! Open an issue, or ask in the chat.**
##### On the more technical side:
* Test, test, and test!
* Follow the style conventions
* Follow the style conventions (See [rust style guidelines](#rust-style-guidelines))
* Use `std::mem::replace` and `std::mem::swap` when you can.
* `libredox` should be 1-to-1 with the official `libstd`.
* Use `.into()` and `.to_owned()` over `.to_string()`.
* Prefer `.into()` and `.to_owned()` over `.to_string()`.
* Prefer passing references to the data over owned data. (Don't take `String`, take `&str`. Don't take `Vec<T>` take `&[T]`).
* Use generics, traits, and other abstractions Rust provides.
* Avoid using lossy conversions (for example: don't do `my_u32 as u16 == my_u16`, prefer `my_u32 == my_u16 as my_u32`).
* Prefer in place (`box` keyword) when doing heap allocations.
* Prefer platform independently sized integer over pointer sized integer (`u32` over `usize`, for example).
* Follow the usual idioms of programming, such as "composition over inheritance", "let your program be divided in smaller pieces", and "resource acquisition is initialization".
* When `unsafe` is unnecessary, don't use it. 10 lines longer safe code is better than more compact unsafe code!
* Be sure to mark parts that need work with `TODO`, `FIXME`, `BUG`, `UNOPTIMIZED`, `REWRITEME`, `DOCME`, and `PRETTYFYME`.
* When `unsafe` is unnecessary, don't use it. **Longer safe code is better than shorter unsafe code!**
* Be sure to mark parts that need work with `TODO`, `FIXME`, `BUG`, `UNOPTIMIZED`, `REWRITEME`, `DOCME`, and `PRETTYFYME`. Always elaborate on these messages, too. Nothing is more annoying than seeing a `TODO` and not knowing how to actually fix it.
* Use the compiler hint attributes, such as `#[inline]`, `#[cold]`, etc. when it makes sense to do so.
* Check the [chat](#chat), [the Website](http://redox-os.org), and [the Rust subreddit](https://www.reddit.com/r/rust) frequently.
* Check the [chat](#chat), [the website](http://redox-os.org/news), and [the Rust subreddit](https://www.reddit.com/r/rust) frequently.
### <a name="kernel"> Kernel </a>
* When trying to access a slice, **always** use the `common::GetSlice` trait and the `.get_slice()` method to get a slice without causing the kernel to panic.
The problem with slicing in regular Rust, e.g. `foo[a..b]`, is that if someone tries to access with a range that is out of bounds of an array/string/slice, it will cause a panic at runtime, as a safety measure. Same thing when accessing an element.
* When trying to access a slice, **always** use the `common::GetSlice` trait and the `.get_slice()` method to get a slice without causing the kernel to panic.
The problem with slicing in regular Rust, e.g. `foo[a..b]`, is that if someone tries to access with a range that is out of bounds of an array/string/slice, it will cause a panic at runtime, as a safety measure. Same thing when accessing an element.
Always use `foo.get(n)` instead of `foo[n]` and try to cover for the possibility of `Option::None`. Doing the regular way may work fine for applications, but never in the kernel. No possible panics should ever exist in kernel space, because then the whole OS would just stop working.
### <a name="testing-practices"> Testing Practices </a>
* It's always better to test boot (`make qemu` or `make virtualbox`) every time you make a change, because it is important to see how the OS boots and works after it compiles.
Even though Rust is a safety-oriented language, something as unstable as an in-dev operating system will have problems in many cases and may completely break on even the slightest critical change.
* It's always better to test boot (`make qemu` or `make virtualbox`) every time you make a change, because it is important to see how the OS boots and works after it compiles.
Even though Rust is a safety-oriented language, something as unstable and low-level as an in-dev operating system will almost certainly have problems in many cases and may completely break on even the slightest critical change.
Also, make sure you check how the unmodified version runs on your machine before making any changes. Else, you won't have anything to compare to, and it will generally just lead to confusion. TLDR: Rebuild and test boot often.
* To run the ZFS tests:
@ -150,14 +159,33 @@ Since Rust is a relatively small and new language compared to others like C, the
### <a name="git-style-guidelines"> Git </a>
* Commit messages should describe their changes in present tense, e.g. "`Add stuff to file.ext`" instead of "`added stuff to file.ext`".
* Try to remove useless duplicate/merge commits from PRs as these clutter up history, and may make it hard to read.
* Usually, when syncing your local copy with the master branch, you will want to rebase instead of merge. This is because it will create duplicate commits that don't actually do anything when merged into the master branch.
* When you start to make changes, you will want to create a separate branch, and keep the `master` branch of your fork identical to the main repository, so that you can compare your changes with the main branch and test out a more stable build if you need to.
* You should have a fork of the repository on GitHub and a local copy on your computer. The local copy should have two remotes; `upstream` and `origin`, `upstream` should be set to the main repository and `origin` should be your fork.
* When you start to make changes, you will want to create a separate branch, and keep the `master` branch of your fork identical to the main repository, so that you can compare your changes with the main branch and test out a more stable build if you need to.
* Usually, when syncing your local copy with the master branch, you'll want to rebase instead of merge. This is because it will create duplicate commits that don't actually do anything when merged into the master branch. You can do this in one command with `git pull upstream --rebase`. This will pull from the upstream, then roll back to the current state of the upstream, and "replay" your changes on top of it. Make sure you commit before doing this, though. Git won't be able to rebase if you don't.
* Prefer to omit the `-m` when using `git commit`. This opens your editor and should help get you in the habit of writing longer commit messages.
* Commit messages should describe their changes in present tense, e.g. "`Add stuff to file.ext`" instead of "`added stuff to file.ext`". This makes sense as sometimes when you revert back, then run through commits one-by-one, you want to see what a commit will do, instead of just what the person did when they made the commit. It's also just being consistent.
* Try to remove useless duplicate/merge commits from PRs as these don't do anything except clutter up history and make it harder to read.
## <a name="other"> Other Ways to Contribute </a>
### <a name="graphic-design"> Graphic Design </a>
If you're not big on coding, but you still want to help keep the project going, you can still contribute/support in a variety of ways! We'll try to find a way to use anything you have to offer.
### <a name="design"> Design </a>
If you're a good designer, whether it's 2D graphics, 3D graphics, interfaces, web design, you can help. We need logos, UI design, UI skins, app icons, desktop backgrounds, etc. More information to come on this in the future, for now just join [the chat](#chat) and ask about graphic design.
### <a name="patreon"> Patreon </a>
Our BDFL, [jackpot51](https://github.com/jackpot51), has a [Patreon campaign](https://www.patreon.com/redox_os)! All money recieved will go towards Redox OS development. If you donate, you will be listed in the Redox credits as one of the people that made Redox OS possible. You'll also get other rewards the more you donate. However, please don't donate if you can't afford it.
<!--
POSSIBLE OTHER TOPICS TO INCLUDE
- Merch (maybe in the future)
- Sound Design (things like notifications, popups, etc. for orbital)
- Video Production/Motion Graphics (tutorials, introduction videos, etc.)
- Non-Rust programming, scripting, etc. (if we even have a need for this)
- Hosting/download/git mirrors (this is not needed right now, but when downloads increase it may be necessary)
-->
If you're a good designer, you can help with logos, UI design, app icons, other graphics (e.g. stock desktop backgrounds), etc. More information to come on this, for now just join [the chat](#chat) and ask about graphic design.

View file

@ -1,37 +0,0 @@
[package]
name = "kernel"
version = "0.1.0"
[lib]
name = "kernel"
path = "kernel/lib.rs"
crate-type = ["staticlib"]
[dependencies]
bitflags = "*"
spin = "*"
redox_syscall = { path = "syscall/" }
[dependencies.goblin]
git = "https://github.com/m4b/goblin.git"
default-features = false
features = ["elf32", "elf64"]
[dev-dependencies]
arch_test = { path = "arch/test" }
[target.'cfg(target_arch = "arm")'.dependencies]
arch_arm = { path = "arch/arm" }
[target.'cfg(target_arch = "x86_64")'.dependencies]
arch_x86_64 = { path = "arch/x86_64" }
[features]
default = []
live = []
[profile.dev]
panic = "unwind"
[profile.release]
panic = "abort"

646
Makefile
View file

@ -1,31 +1,5 @@
ARCH?=x86_64
ROOT=$(PWD)
export RUST_TARGET_PATH=$(ROOT)/targets
#TODO: Use libssp
export CFLAGS=-fno-stack-protector -U_FORTIFY_SOURCE
# Kernel variables
KTARGET=$(ARCH)-unknown-none
KBUILD=build/kernel
KRUSTC=./krustc.sh
KRUSTCFLAGS=--target $(KTARGET) -C opt-level=2 -C debuginfo=0 -C soft-float
KRUSTDOC=./krustdoc.sh
KCARGO=RUSTC="$(KRUSTC)" RUSTDOC="$(KRUSTDOC)" cargo
KCARGOFLAGS=--target $(KTARGET) --release -- -C soft-float
# Userspace variables
TARGET=$(ARCH)-unknown-redox
BUILD=build/userspace
RUSTC=./rustc.sh
RUSTCFLAGS=--target $(TARGET).json -C opt-level=2 -C debuginfo=0
RUSTDOC=./rustdoc.sh
CARGO=RUSTC="$(RUSTC)" RUSTDOC="$(RUSTDOC)" cargo
CARGOFLAGS=--target $(TARGET).json --release --
# Default targets
.PHONY: all live iso clean doc ref test update pull qemu bochs drivers schemes binutils coreutils extrautils netutils userutils wireshark FORCE
# Configuration and variables
include mk/config.mk
all: build/harddrive.bin
@ -33,130 +7,15 @@ live: build/livedisk.bin
iso: build/livedisk.iso
FORCE:
clean:
cargo clean
cargo clean --manifest-path rust/src/libstd/Cargo.toml
cargo clean --manifest-path drivers/ahcid/Cargo.toml
cargo clean --manifest-path drivers/e1000d/Cargo.toml
cargo clean --manifest-path drivers/ps2d/Cargo.toml
cargo clean --manifest-path drivers/pcid/Cargo.toml
cargo clean --manifest-path drivers/rtl8168d/Cargo.toml
cargo clean --manifest-path drivers/vesad/Cargo.toml
cargo clean --manifest-path programs/acid/Cargo.toml
cargo clean --manifest-path programs/contain/Cargo.toml
cargo clean --manifest-path programs/init/Cargo.toml
cargo clean --manifest-path programs/ion/Cargo.toml
cargo clean --manifest-path programs/binutils/Cargo.toml
cargo clean --manifest-path programs/coreutils/Cargo.toml
cargo clean --manifest-path programs/extrautils/Cargo.toml
cargo clean --manifest-path programs/games/Cargo.toml
cargo clean --manifest-path programs/netutils/Cargo.toml
cargo clean --manifest-path programs/orbutils/Cargo.toml
cargo clean --manifest-path programs/pkgutils/Cargo.toml
cargo clean --manifest-path programs/userutils/Cargo.toml
cargo clean --manifest-path programs/smith/Cargo.toml
cargo clean --manifest-path programs/tar/Cargo.toml
cargo clean --manifest-path schemes/ethernetd/Cargo.toml
cargo clean --manifest-path schemes/example/Cargo.toml
cargo clean --manifest-path schemes/ipd/Cargo.toml
cargo clean --manifest-path schemes/orbital/Cargo.toml
cargo clean --manifest-path schemes/ptyd/Cargo.toml
cargo clean --manifest-path schemes/randd/Cargo.toml
cargo clean --manifest-path schemes/redoxfs/Cargo.toml
cargo clean --manifest-path schemes/tcpd/Cargo.toml
cargo clean --manifest-path schemes/udpd/Cargo.toml
-$(FUMOUNT) build/filesystem/
rm -rf initfs/bin
rm -rf filesystem/bin filesystem/sbin filesystem/ui/bin
cd cookbook && ./clean.sh
cargo clean --manifest-path cookbook/pkgutils/Cargo.toml
cargo clean --manifest-path installer/Cargo.toml
cargo clean --manifest-path kernel/Cargo.toml
cargo clean --manifest-path redoxfs/Cargo.toml
-$(FUMOUNT) build/filesystem/ || true
rm -rf build
doc: \
doc-kernel \
doc-std
#FORCE to let cargo decide if docs need updating
doc-kernel: $(KBUILD)/libkernel.a FORCE
$(KCARGO) doc --target $(KTARGET).json
doc-std: $(BUILD)/libstd.rlib FORCE
$(CARGO) doc --target $(TARGET).json --manifest-path rust/src/libstd/Cargo.toml
ref: FORCE
rm -rf filesystem/ref/
mkdir -p filesystem/ref/
cargo run --manifest-path crates/docgen/Cargo.toml -- programs/binutils/src/bin/ filesystem/ref/
cargo run --manifest-path crates/docgen/Cargo.toml -- programs/coreutils/src/bin/ filesystem/ref/
cargo run --manifest-path crates/docgen/Cargo.toml -- programs/extrautils/src/bin/ filesystem/ref/
cargo run --manifest-path crates/docgen/Cargo.toml -- programs/netutils/src/ filesystem/ref/
test:
cargo test
cargo test --manifest-path rust/src/libstd/Cargo.toml
cargo test --manifest-path drivers/ahcid/Cargo.toml
cargo test --manifest-path drivers/e1000d/Cargo.toml
cargo test --manifest-path drivers/ps2d/Cargo.toml
cargo test --manifest-path drivers/pcid/Cargo.toml
cargo test --manifest-path drivers/rtl8168d/Cargo.toml
cargo test --manifest-path drivers/vesad/Cargo.toml
cargo test --manifest-path programs/acid/Cargo.toml
cargo test --manifest-path programs/contain/Cargo.toml
cargo test --manifest-path programs/init/Cargo.toml
cargo test --manifest-path programs/ion/Cargo.toml
cargo test --manifest-path programs/binutils/Cargo.toml
cargo test --manifest-path programs/coreutils/Cargo.toml
cargo test --manifest-path programs/extrautils/Cargo.toml
cargo test --manifest-path programs/games/Cargo.toml
cargo test --manifest-path programs/netutils/Cargo.toml
cargo test --manifest-path programs/orbutils/Cargo.toml
cargo test --manifest-path programs/pkgutils/Cargo.toml
cargo test --manifest-path programs/userutils/Cargo.toml
cargo test --manifest-path programs/smith/Cargo.toml
cargo test --manifest-path programs/tar/Cargo.toml
cargo test --manifest-path schemes/ethernetd/Cargo.toml
cargo test --manifest-path schemes/example/Cargo.toml
cargo test --manifest-path schemes/ipd/Cargo.toml
cargo test --manifest-path schemes/orbital/Cargo.toml
cargo test --manifest-path schemes/ptyd/Cargo.toml
cargo test --manifest-path schemes/randd/Cargo.toml
cargo test --manifest-path schemes/redoxfs/Cargo.toml
cargo test --manifest-path schemes/tcpd/Cargo.toml
cargo test --manifest-path schemes/udpd/Cargo.toml
update:
cargo update
cargo update --manifest-path rust/src/libstd/Cargo.toml
cargo update --manifest-path drivers/ahcid/Cargo.toml
cargo update --manifest-path drivers/e1000d/Cargo.toml
cargo update --manifest-path drivers/ps2d/Cargo.toml
cargo update --manifest-path drivers/pcid/Cargo.toml
cargo update --manifest-path drivers/rtl8168d/Cargo.toml
cargo update --manifest-path drivers/vesad/Cargo.toml
cargo update --manifest-path programs/acid/Cargo.toml
cargo update --manifest-path programs/contain/Cargo.toml
cargo update --manifest-path programs/init/Cargo.toml
cargo update --manifest-path programs/ion/Cargo.toml
cargo update --manifest-path programs/binutils/Cargo.toml
cargo update --manifest-path programs/coreutils/Cargo.toml
cargo update --manifest-path programs/extrautils/Cargo.toml
cargo update --manifest-path programs/games/Cargo.toml
cargo update --manifest-path programs/netutils/Cargo.toml
cargo update --manifest-path programs/orbutils/Cargo.toml
cargo update --manifest-path programs/pkgutils/Cargo.toml
cargo update --manifest-path programs/userutils/Cargo.toml
cargo update --manifest-path programs/smith/Cargo.toml
cargo update --manifest-path programs/tar/Cargo.toml
cargo update --manifest-path schemes/ethernetd/Cargo.toml
cargo update --manifest-path schemes/example/Cargo.toml
cargo update --manifest-path schemes/ipd/Cargo.toml
cargo update --manifest-path schemes/orbital/Cargo.toml
cargo update --manifest-path schemes/ptyd/Cargo.toml
cargo update --manifest-path schemes/randd/Cargo.toml
cargo update --manifest-path schemes/redoxfs/Cargo.toml
cargo update --manifest-path schemes/tcpd/Cargo.toml
cargo update --manifest-path schemes/udpd/Cargo.toml
pull:
git pull --rebase --recurse-submodules
git submodule sync
@ -165,472 +24,49 @@ pull:
make clean
make update
# Emulation
QEMU=SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-$(ARCH)
QEMUFLAGS=-serial mon:stdio -d cpu_reset -d guest_errors
ifeq ($(ARCH),arm)
QEMUFLAGS+=-cpu arm1176 -machine integratorcp
QEMUFLAGS+=-nographic
update:
cd cookbook; \
./update.sh "$$(cargo run --manifest-path ../installer/Cargo.toml -- --list-packages ../initfs.toml ../filesystem.toml)"
cargo update --manifest-path cookbook/pkgutils/Cargo.toml
cargo update --manifest-path installer/Cargo.toml
cargo update --manifest-path kernel/Cargo.toml
cargo update --manifest-path redoxfs/Cargo.toml
export CC=$(ARCH)-none-eabi-gcc
export CXX=$(ARCH)-none-eabi-g++
export LD=$(ARCH)-none-eabi-ld
fetch:
cd cookbook; \
./fetch.sh "$$(cargo run --manifest-path ../installer/Cargo.toml -- --list-packages ../initfs.toml ../filesystem.toml)"
KRUSTCFLAGS+=-C linker=$(CC)
KCARGOFLAGS+=-C linker=$(CC)
RUSTCFLAGS+=-C linker=$(CC)
CARGOFLAGS+=-C linker=$(CC)
# Emulation recipes
include mk/qemu.mk
include mk/bochs.mk
include mk/virtualbox.mk
%.list: %
$(ARCH)-none-eabi-objdump -C -D $< > $@
# Kernel recipes
include mk/kernel.mk
build/harddrive.bin: $(KBUILD)/kernel
cp $< $@
# Filesystem recipes
include mk/initfs.mk
include mk/filesystem.mk
qemu: build/harddrive.bin
$(QEMU) $(QEMUFLAGS) -kernel $<
else
QEMUFLAGS+=-smp 4 -m 1024
ifeq ($(iommu),yes)
QEMUFLAGS+=-machine q35,iommu=on
else
QEMUFLAGS+=-machine q35
endif
ifeq ($(net),no)
QEMUFLAGS+=-net none
else
QEMUFLAGS+=-net nic,model=e1000 -net user -net dump,file=build/network.pcap
ifeq ($(net),redir)
QEMUFLAGS+=-redir tcp:8080::8080
endif
endif
ifeq ($(vga),no)
QEMUFLAGS+=-nographic -vga none
endif
#,int,pcall
#-device intel-iommu
# Disk images
include mk/disk.mk
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
export CC=$(ARCH)-elf-gcc
export CXX=$(ARCH)-elf-g++
ECHO=/bin/echo
FUMOUNT=sudo umount
export LD=$(ARCH)-elf-ld
export LDFLAGS=--gc-sections
VB_AUDIO=coreaudio
VBM="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
else
export CC=gcc
export CXX=g++
ECHO=echo
FUMOUNT=fusermount -u
export LD=ld
export LDFLAGS=--gc-sections
ifneq ($(kvm),no)
QEMUFLAGS+=-enable-kvm -cpu host
endif
VB_AUDIO="pulse"
VBM=VBoxManage
endif
# Travis target
travis: FORCE
INSTALLER_FLAGS= make build/harddrive.bin.gz build/livedisk.iso
rm -rf build/travis
mkdir build/travis
mv build/harddrive.bin.gz build/travis/redox_$(TRAVIS_TAG).bin.gz
mv build/livedisk.iso build/travis/redox_$(TRAVIS_TAG).iso
cd build/travis && sha256sum -b redox_$(TRAVIS_TAG).bin.gz redox_$(TRAVIS_TAG).iso > SHA256SUM
KRUSTCFLAGS+=-C linker=$(CC)
KCARGOFLAGS+=-C linker=$(CC)
RUSTCFLAGS+=-C linker=$(CC)
CARGOFLAGS+=-C linker=$(CC)
# An empty target
FORCE:
# A method of creating a listing for any binary
%.list: %
objdump -C -M intel -D $< > $@
build/harddrive.bin: $(KBUILD)/kernel bootloader/$(ARCH)/** build/filesystem.bin
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/harddrive.asm
build/livedisk.bin: $(KBUILD)/kernel_live bootloader/$(ARCH)/**
nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/livedisk.asm
build/%.bin.gz: build/%.bin
gzip -k -f $<
build/livedisk.iso: build/livedisk.bin.gz
rm -rf build/iso/
mkdir -p build/iso/
cp -RL isolinux build/iso/
cp $< build/iso/livedisk.gz
genisoimage -o $@ -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
build/iso/
isohybrid $@
qemu: build/harddrive.bin
$(QEMU) $(QEMUFLAGS) -drive file=$<,format=raw
qemu_extra: build/harddrive.bin
if [ ! -e build/extra.bin ]; then dd if=/dev/zero of=build/extra.bin bs=1M count=1024; fi
$(QEMU) $(QEMUFLAGS) -drive file=$<,format=raw -drive file=build/extra.bin,format=raw
qemu_no_build:
$(QEMU) $(QEMUFLAGS) -drive file=build/harddrive.bin,format=raw
qemu_live: build/livedisk.bin
$(QEMU) $(QEMUFLAGS) -device usb-ehci,id=flash_bus -drive id=flash_drive,file=$<,format=raw,if=none -device usb-storage,drive=flash_drive,bus=flash_bus.0
qemu_live_no_build:
$(QEMU) $(QEMUFLAGS) -device usb-ehci,id=flash_bus -drive id=flash_drive,file=build/livedisk.bin,format=raw,if=none -device usb-storage,drive=flash_drive,bus=flash_bus.0
qemu_iso: build/livedisk.iso
$(QEMU) $(QEMUFLAGS) -boot d -cdrom $<
qemu_iso_no_build:
$(QEMU) $(QEMUFLAGS) -boot d -cdrom build/livedisk.iso
endif
bochs: build/harddrive.bin
bochs -f bochs.$(ARCH)
virtualbox: build/harddrive.bin
echo "Delete VM"
-$(VBM) unregistervm Redox --delete; \
if [ $$? -ne 0 ]; \
then \
if [ -d "$$HOME/VirtualBox VMs/Redox" ]; \
then \
echo "Redox directory exists, deleting..."; \
$(RM) -rf "$$HOME/VirtualBox VMs/Redox"; \
fi \
fi
echo "Delete Disk"
-$(RM) harddrive.vdi
echo "Create VM"
$(VBM) createvm --name Redox --register
echo "Set Configuration"
$(VBM) modifyvm Redox --memory 1024
$(VBM) modifyvm Redox --vram 16
if [ "$(net)" != "no" ]; \
then \
$(VBM) modifyvm Redox --nic1 nat; \
$(VBM) modifyvm Redox --nictype1 82540EM; \
$(VBM) modifyvm Redox --cableconnected1 on; \
$(VBM) modifyvm Redox --nictrace1 on; \
$(VBM) modifyvm Redox --nictracefile1 build/network.pcap; \
fi
$(VBM) modifyvm Redox --uart1 0x3F8 4
$(VBM) modifyvm Redox --uartmode1 file build/serial.log
$(VBM) modifyvm Redox --usb off # on
$(VBM) modifyvm Redox --keyboard ps2
$(VBM) modifyvm Redox --mouse ps2
$(VBM) modifyvm Redox --audio $(VB_AUDIO)
$(VBM) modifyvm Redox --audiocontroller ac97
$(VBM) modifyvm Redox --nestedpaging off
echo "Create Disk"
$(VBM) convertfromraw $< build/harddrive.vdi
echo "Attach Disk"
$(VBM) storagectl Redox --name ATA --add sata --controller IntelAHCI --bootable on --portcount 1
$(VBM) storageattach Redox --storagectl ATA --port 0 --device 0 --type hdd --medium build/harddrive.vdi
echo "Run VM"
$(VBM) startvm Redox
# Kernel recipes
$(KBUILD)/libcore.rlib: rust/src/libcore/lib.rs
mkdir -p $(KBUILD)
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
$(KBUILD)/librand.rlib: rust/src/librand/lib.rs $(KBUILD)/libcore.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
$(KBUILD)/liballoc.rlib: rust/src/liballoc/lib.rs $(KBUILD)/libcore.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
$(KBUILD)/libstd_unicode.rlib: rust/src/libstd_unicode/lib.rs $(KBUILD)/libcore.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
$(KBUILD)/libcollections.rlib: rust/src/libcollections/lib.rs $(KBUILD)/libcore.rlib $(KBUILD)/liballoc.rlib $(KBUILD)/libstd_unicode.rlib
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
$(KBUILD)/libkernel.a: kernel/** $(KBUILD)/libcore.rlib $(KBUILD)/liballoc.rlib $(KBUILD)/libcollections.rlib $(BUILD)/initfs.rs
$(KCARGO) rustc $(KCARGOFLAGS) -C lto -o $@
$(KBUILD)/libkernel_live.a: kernel/** $(KBUILD)/libcore.rlib $(KBUILD)/liballoc.rlib $(KBUILD)/libcollections.rlib $(BUILD)/initfs.rs build/filesystem.bin
$(KCARGO) rustc --lib $(KCARGOFLAGS) --cfg 'feature="live"' -C lto --emit obj=$@
$(KBUILD)/kernel: $(KBUILD)/libkernel.a
$(LD) $(LDFLAGS) -z max-page-size=0x1000 -T arch/$(ARCH)/src/linker.ld -o $@ $<
$(KBUILD)/kernel_live: $(KBUILD)/libkernel_live.a
$(LD) $(LDFLAGS) -z max-page-size=0x1000 -T arch/$(ARCH)/src/linker.ld -o $@ $<
# Userspace recipes
$(BUILD)/libstd.rlib: rust/src/libstd/Cargo.toml rust/src/libstd/**
mkdir -p $(BUILD)
$(CARGO) rustc --verbose --manifest-path $< $(CARGOFLAGS) -L native=libc-artifacts/lib -o $@
cp rust/src/target/$(TARGET)/release/deps/*.rlib $(BUILD)
initfs/bin/%: drivers/%/Cargo.toml drivers/%/src/** $(BUILD)/libstd.rlib
mkdir -p initfs/bin
$(CARGO) rustc --manifest-path $< $(CARGOFLAGS) -o $@
strip $@
initfs/bin/%: programs/%/Cargo.toml programs/%/src/** $(BUILD)/libstd.rlib
mkdir -p initfs/bin
$(CARGO) rustc --manifest-path $< $(CARGOFLAGS) -o $@
#strip $@
initfs/bin/%: schemes/%/Cargo.toml schemes/%/src/** $(BUILD)/libstd.rlib
mkdir -p initfs/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
$(BUILD)/initfs.rs: \
initfs/bin/init \
initfs/bin/ahcid \
initfs/bin/bgad \
initfs/bin/pcid \
initfs/bin/ps2d \
initfs/bin/redoxfs \
initfs/bin/vesad \
initfs/etc/**
echo 'use collections::BTreeMap;' > $@
echo 'pub fn gen() -> BTreeMap<&'"'"'static [u8], (&'"'"'static [u8], bool)> {' >> $@
echo ' let mut files: BTreeMap<&'"'"'static [u8], (&'"'"'static [u8], bool)> = BTreeMap::new();' >> $@
for folder in `find initfs -type d | sort`; do \
name=$$(echo $$folder | sed 's/initfs//' | cut -d '/' -f2-) ; \
$(ECHO) -n ' files.insert(b"'$$name'", (b"' >> $@ ; \
ls -1 $$folder | sort | awk 'NR > 1 {printf("\\n")} {printf("%s", $$0)}' >> $@ ; \
echo '", true));' >> $@ ; \
done
find initfs -type f -o -type l | cut -d '/' -f2- | sort | awk '{printf(" files.insert(b\"%s\", (include_bytes!(\"../../initfs/%s\"), false));\n", $$0, $$0)}' >> $@
echo ' files' >> $@
echo '}' >> $@
filesystem/sbin/%: drivers/%/Cargo.toml drivers/%/src/** $(BUILD)/libstd.rlib
mkdir -p filesystem/sbin
$(CARGO) rustc --manifest-path $< $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/%/Cargo.toml programs/%/src/** $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/sh: filesystem/bin/ion
cp $< $@
filesystem/bin/%: programs/binutils/Cargo.toml programs/binutils/src/bin/%.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/coreutils/Cargo.toml programs/coreutils/src/bin/%.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/extrautils/Cargo.toml programs/extrautils/src/bin/%.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/games/Cargo.toml programs/games/src/%/**.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/netutils/Cargo.toml programs/netutils/src/%/**.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/ui/bin/%: programs/orbutils/Cargo.toml programs/orbutils/src/%/**.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/ui/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/pkgutils/Cargo.toml programs/pkgutils/src/%/**.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/bin/%: programs/userutils/Cargo.toml programs/userutils/src/bin/%.rs $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/sbin/%: schemes/%/Cargo.toml schemes/%/src/** $(BUILD)/libstd.rlib
mkdir -p filesystem/sbin
$(CARGO) rustc --manifest-path $< --bin $* $(CARGOFLAGS) -o $@
strip $@
filesystem/sbin/redoxfs-mkfs: schemes/redoxfs/Cargo.toml schemes/redoxfs/src/** $(BUILD)/libstd.rlib
mkdir -p filesystem/bin
$(CARGO) rustc --manifest-path $< --bin redoxfs-mkfs $(CARGOFLAGS) -o $@
strip $@
drivers: \
filesystem/sbin/pcid \
filesystem/sbin/e1000d \
filesystem/sbin/rtl8168d
binutils: \
filesystem/bin/hex \
filesystem/bin/hexdump \
filesystem/bin/strings
coreutils: \
filesystem/bin/basename \
filesystem/bin/cat \
filesystem/bin/chmod \
filesystem/bin/clear \
filesystem/bin/cp \
filesystem/bin/cut \
filesystem/bin/date \
filesystem/bin/dd \
filesystem/bin/df \
filesystem/bin/du \
filesystem/bin/echo \
filesystem/bin/env \
filesystem/bin/false \
filesystem/bin/free \
filesystem/bin/head \
filesystem/bin/kill \
filesystem/bin/ls \
filesystem/bin/mkdir \
filesystem/bin/mv \
filesystem/bin/printenv \
filesystem/bin/ps \
filesystem/bin/pwd \
filesystem/bin/realpath \
filesystem/bin/reset \
filesystem/bin/rmdir \
filesystem/bin/rm \
filesystem/bin/seq \
filesystem/bin/sleep \
filesystem/bin/sort \
filesystem/bin/tail \
filesystem/bin/tee \
filesystem/bin/time \
filesystem/bin/touch \
filesystem/bin/true \
filesystem/bin/wc \
filesystem/bin/yes
#filesystem/bin/shutdown filesystem/bin/test
extrautils: \
filesystem/bin/calc \
filesystem/bin/cksum \
filesystem/bin/cur \
filesystem/bin/grep \
filesystem/bin/less \
filesystem/bin/man \
filesystem/bin/mdless \
filesystem/bin/mtxt \
filesystem/bin/rem \
#filesystem/bin/dmesg filesystem/bin/info filesystem/bin/watch
games: \
filesystem/bin/ice \
filesystem/bin/minesweeper \
filesystem/bin/reblox \
filesystem/bin/rusthello \
filesystem/bin/snake
netutils: \
filesystem/bin/dhcpd \
filesystem/bin/dns \
filesystem/bin/httpd \
filesystem/bin/irc \
filesystem/bin/nc \
filesystem/bin/ntp \
filesystem/bin/wget
orbutils: \
filesystem/ui/bin/browser \
filesystem/ui/bin/calculator \
filesystem/ui/bin/character_map \
filesystem/ui/bin/editor \
filesystem/ui/bin/file_manager \
filesystem/ui/bin/launcher \
filesystem/ui/bin/orblogin \
filesystem/ui/bin/terminal \
filesystem/ui/bin/viewer
pkgutils: \
filesystem/bin/pkg
userutils: \
filesystem/bin/getty \
filesystem/bin/id \
filesystem/bin/login \
filesystem/bin/passwd \
filesystem/bin/su \
filesystem/bin/sudo
schemes: \
filesystem/sbin/ethernetd \
filesystem/sbin/ipd \
filesystem/sbin/orbital \
filesystem/sbin/ptyd \
filesystem/sbin/randd \
filesystem/sbin/redoxfs \
filesystem/sbin/redoxfs-mkfs \
filesystem/sbin/tcpd \
filesystem/sbin/udpd
build/filesystem.bin: \
drivers \
coreutils \
extrautils \
games \
netutils \
orbutils \
pkgutils \
userutils \
schemes \
filesystem/bin/acid \
filesystem/bin/contain \
filesystem/bin/ion \
filesystem/bin/sh \
filesystem/bin/smith \
filesystem/bin/tar
-$(FUMOUNT) build/filesystem/
rm -rf $@ build/filesystem/
dd if=/dev/zero of=$@ bs=1M count=128
cargo run --manifest-path schemes/redoxfs/Cargo.toml --release --bin redoxfs-mkfs $@
mkdir -p build/filesystem/
cargo build --manifest-path schemes/redoxfs/Cargo.toml --release --bin redoxfs
schemes/redoxfs/target/release/redoxfs $@ build/filesystem/
sleep 2
pgrep redoxfs
cp -RL filesystem/* build/filesystem/
chown -R 0:0 build/filesystem
chown -R 1000:1000 build/filesystem/home/user
chmod -R uog+rX build/filesystem
chmod -R u+w build/filesystem
chmod -R og-w build/filesystem
chmod -R 755 build/filesystem/bin
chmod -R u+rwX build/filesystem/root
chmod -R og-rwx build/filesystem/root
chmod -R u+rwX build/filesystem/home/user
chmod -R og-rwx build/filesystem/home/user
chmod +s build/filesystem/bin/passwd
chmod +s build/filesystem/bin/su
chmod +s build/filesystem/bin/sudo
mkdir build/filesystem/tmp
chmod 1777 build/filesystem/tmp
sync
-$(FUMOUNT) build/filesystem/
rm -rf build/filesystem/
mount: FORCE
mkdir -p build/filesystem/
cargo build --manifest-path schemes/redoxfs/Cargo.toml --release --bin redoxfs
schemes/redoxfs/target/release/redoxfs build/harddrive.bin build/filesystem/
sleep 2
pgrep redoxfs
unmount: FORCE
sync
-$(FUMOUNT) build/filesystem/
rm -rf build/filesystem/
# Wireshark
wireshark: FORCE
wireshark build/network.pcap

View file

@ -1,38 +1,40 @@
<p align="center">
<img alt="Redox" height="120" src="https://github.com/redox-os/assets/raw/master/logo.png">
<img alt="Redox" width="346" src="https://github.com/redox-os/assets/raw/master/logos/redox/logo.png">
</p>
**Redox** is an operating system written in Rust, a language with focus on safety and high performance. Redox, following the microkernel design, aims to be secure, usable, and free. Redox is inspired by previous kernels and operating systems, such as SeL4, Minix, Plan 9, and BSD.
Redox _is not_ just a kernel, it's a full-featured Operating System, providing packages (memory allocator, file system, display manager, core utilities, etc.) that together makes up a functional and convenient operating system. You can loosly think of it as the GNU or BSD ecosystem, but in a memory safe language and with modern technology. See [this list](#ecosystem) for overview of the ecosystem.
Redox _is not_ just a kernel, it's a **full-featured Operating System**, providing packages (memory allocator, file system, display manager, core utilities, etc.) that together make up a functional and convenient operating system. You can loosely think of it as the GNU or BSD ecosystem, but in a memory safe language and with modern technology. See [this list](#ecosystem) for overview of the ecosystem.
The website can be found at https://www.redox-os.org.
Please make sure you use the **latest nightly** of `rustc` before building (for more troubleshooting, see ["Help! Redox won't compile!"](#compile-help)).
[![Travis Build Status](https://travis-ci.org/redox-os/redox.svg?branch=master)](https://travis-ci.org/redox-os/redox)
[![Downloads](https://img.shields.io/github/downloads/redox-os/redox/total.svg)](https://github.com/redox-os/redox/releases)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)
![Rust Version](https://img.shields.io/badge/rust-1.15.0--nightly%20(71c06a56a%202016--12--18)-lightgrey.svg)
![Rust Version](https://img.shields.io/badge/rust-nightly%202017--07--26-lightgrey.svg)
## Contents
* [What it looks like](#what-it-looks-like)
* [What it looks like](#screenshots)
* [Ecosystem](#ecosystem)
* [Help! Redox won't compile](#compile-help)
* [Contributing to Redox](#contributing)
* [Cloning, Building and running](#cloning-building-running)
* [Quick Setup](#quick-setup)
* [Manual Setup](#manual-setup)
* [Setup Using Docker](#setup-using-docker)
## <a name="what-it-looks-like"> What it looks like </a>
## <a name="screenshots"> What it looks like </a>
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/Desktop.png">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/Fancy_opacity.png">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/File_manager.png">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/redox running.jpeg">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/IMG_1460.PNG">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/Sodium_v1.png">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/Boot.png">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/start.png">
<img alt="Redox" height="150" src="https://github.com/redox-os/assets/raw/master/screenshots/IMG_1459.PNG">
## <a name="ecosystem"> Ecosystem </a>
@ -40,48 +42,49 @@ The ecosystem and software Redox OS provides is listed below.
| Name (lexicographic order) | Maintainer
|-----------------------------------------------------------------------------|---------------------------
| [Ion (shell)](https://github.com/redox-os/ion) | [**@skylerberg**](https://github.com/skylerberg) & [**@jackpot51**](https://github.com/jackpot51)
| [RANSID](https://github.com/redox-os/ransid) | [**@jackpot51**](https://github.com/jackpot51)
| [Sodium (editor)](https://github.com/redox-os/sodium) | [**@ticki**](https://github.com/ticki)
| [Standard library](https://github.com/redox-os/libstd) | [**@jackpot51**](https://github.com/jackpot51)
| [TFS (filesystem)](https://github.com/ticki/tfs) | [**@ticki**](https://github.com/ticki)
| [The Redox book](https://github.com/redox-os/book) | [**@ticki**](https://github.com/ticki)
| [The old kernel](https://github.com/redox-os/old) | abandoned
| [ZFS](https://github.com/redox-os/zfs) | abandoned, superseded by TFS
| [acid tests](https://github.com/redox-os/acid) | [**@jackpot51**](https://github.com/jackpot51) (co.: [**@ticki**](https://github.com/ticki), [**@nilset](https://github.com/nilset))
| [acid (kernel integration tests)](https://github.com/redox-os/acid) | [**@jackpot51**](https://github.com/jackpot51) (co.: [**@ticki**](https://github.com/ticki), [**@nilset](https://github.com/nilset))
| [binutils](https://github.com/redox-os/binutils) | [**@ticki**](https://github.com/ticki)
| [bots (other internal bots)](https://github.com/redox-os/bots) | [**@ticki**](https://github.com/ticki)
| [bots (custom Mattermost bots)](https://github.com/redox-os/bots) | [**@ticki**](https://github.com/ticki)
| [cookbook](https://github.com/redox-os/cookbook) | [**@jackpot51**](https://github.com/jackpot51)
| [coreutils](https://github.com/redox-os/coreutils) | [**@ticki**](https://github.com/ticki) (co.: [**@stratact**](https://github.com/stratact))
| [extrautils](https://github.com/redox-os/extrautils) | [**@ticki**](https://github.com/ticki)
| [games](https://github.com/redox-os/games) | [**@ticki**](https://github.com/ticki)
| [Ion (shell)](https://github.com/redox-os/ion) | [**@skylerberg**](https://github.com/skylerberg) & [**@jackpot51**](https://github.com/jackpot51)
| [kernel](https://github.com/redox-os/kernel) | [**@jackpot51**](https://github.com/jackpot51)
| [libextra](https://github.com/redox-os/libextra) | [**@ticki**](https://github.com/ticki)
| [libpager](https://github.com/redox-os/libpager) | [**@ticki**](https://github.com/ticki)
| [magnet (future package manager)](https://github.com/redox-os/magnet) | [**@ticki**](https://github.com/ticki)
| [libstd (Redox standard library)](https://github.com/redox-os/libstd) | [**@jackpot51**](https://github.com/jackpot51)
| [netutils](https://github.com/redox-os/netutils) | [**@jackpot51**](https://github.com/jackpot51)
| [orbclient](https://github.com/redox-os/orbclient) | [**@jackpot51**](https://github.com/jackpot51)
| [orbclient (Orbital client)](https://github.com/redox-os/orbclient) | [**@jackpot51**](https://github.com/jackpot51)
| [orbdata](https://github.com/redox-os/orbdata) | [**@jackpot51**](https://github.com/jackpot51)
| [orbital](https://github.com/redox-os/orbital) | [**@jackpot51**](https://github.com/jackpot51)
| [orbtk](https://github.com/redox-os/orbtk) | [**@stratact**](https://github.com/stratact)
| [orbutils](https://github.com/redox-os/orbutils) | [**@jackpot51**](https://github.com/jackpot51)
| [Orbital (windowing and compositing system)](https://github.com/redox-os/orbital) | [**@jackpot51**](https://github.com/jackpot51)
| [orbtk (Orbital toolkit)](https://github.com/redox-os/orbtk) | [**@stratact**](https://github.com/stratact)
| [orbutils (Orbital utilities)](https://github.com/redox-os/orbutils) | [**@jackpot51**](https://github.com/jackpot51)
| [pkgutils (current package manager)](https://github.com/redox-os/pkgutils) | [**@jackpot51**](https://github.com/jackpot51)
| [playbot (internal REPL bot)](https://github.com/redox-os/playbot) | [**@ticki**](https://github.com/ticki)
| [ralloc](https://github.com/redox-os/ralloc) | [**@ticki**](https://github.com/ticki)
| [RANSID (Rust ANSI driver)](https://github.com/redox-os/ransid) | [**@jackpot51**](https://github.com/jackpot51)
| [redoxfs (old filesystem)](https://github.com/redox-os/redoxfs) | [**@jackpot51**](https://github.com/jackpot51)
| [syscall](https://github.com/redox-os/syscall) | [**@jackpot51**](https://github.com/jackpot51)
| [Sodium (Vim-inspired text editor)](https://github.com/redox-os/sodium) | [**@ticki**](https://github.com/ticki)
| [userutils](https://github.com/redox-os/userutils) | [**@jackpot51**](https://github.com/jackpot51)
| [TFS (ticki filesystem)](https://github.com/ticki/tfs) | [**@ticki**](https://github.com/ticki)
| [The Redox book](https://github.com/redox-os/book) | [**@ticki**](https://github.com/ticki)
| [The old kernel](https://github.com/redox-os/old) | **abandoned**
| [ZFS](https://github.com/redox-os/zfs) | **abandoned, superseded by [TFS](https://github.com/ticki/tfs)**
## <a name="compile-help"> Help! Redox won't compile! </a>
Sometimes things go wrong when compiling. Try the following before opening an issue:
1. Run `make clean`.
2. Run `git clean -X -f -d`.
3. Make sure you have **the latest version of Rust nightly!** ([rustup.rs](https://www.rustup.rs) is recommended for managing Rust versions).
4. Update **GNU Make**, **NASM** and **QEMU/VirtualBox**.
5. Pull the upstream master branch (`git remote add upstream git@github.com:redox-os/redox.git; git pull upstream master`).
6. Update submodules (`git submodule update --recursive --init`).
1. Make sure you have a redox toolchain (`x86_64-unknown-redox-gcc`).
* You can install from .deb packages(`https://static.redox-os.org/toolchain/apt/`) or build [redox-os/libc](https://github.com/redox-os/libc) manually.
1. Run `rustup update`
1. Run `make clean pull`.
1. Make sure you have **the latest version of Rust nightly!** ([rustup.rs](https://www.rustup.rs) is recommended for managing Rust versions. If you already have it, run `rustup`).
1. Update **GNU Make**, **NASM** and **QEMU/VirtualBox**.
1. Pull the upstream master branch (`git remote add upstream git@github.com:redox-os/redox.git; git pull upstream master`).
1. Update submodules (`git submodule update --recursive --init`).
and then rebuild!
@ -89,9 +92,9 @@ and then rebuild!
If you're interested in this project, and you'd like to help us out, [here](CONTRIBUTING.md) is a list of ways you can do just that.
## <a name="cloning-building-running"> Cloning, Building, and Running </a>
## <a name="cloning-building-running"> Cloning, Building and Running </a>
Redox is big (even compressed)! So cloning Redox takes a lot of bandwidth, and (depending on your data plan) can be costly, so clone at your own risk!
Redox is big, even compressed. Downloading the full history may take a lot of bandwidth, and can even be costly on some data plans. Clone at your own risk!
### <a name="quick-setup" /> Quick Setup </a>
@ -101,6 +104,9 @@ $ cd path/to/your/projects/folder/
# Run bootstrap setup
$ curl -sf https://raw.githubusercontent.com/redox-os/redox/master/bootstrap.sh -o bootstrap.sh && bash -e bootstrap.sh
#Change to project directory
$ cd redox
# Build Redox
$ make all
@ -112,11 +118,11 @@ $ make qemu kvm=no
#### QEMU with KVM
To use QEMU with KVM (kernel-based virtual Machine), which is faster than without KVM, you need a CPU with Intel® Virtualization Technology (Intel® VT) or AMD Virtualization™ (AMD-V™) support. Most systems have this disabled in the BIOS by default, so you may need to reboot and enable the feature in the BIOS.
To use QEMU with KVM (kernel-based virtual Machine), which is faster than without KVM, you need a CPU with Intel® Virtualization Technology (Intel® VT) or AMD Virtualization™ (AMD-V™) support. Most systems have this disabled by default, so you may need to reboot, go into the BIOS, and enable it.
### <a name="manual-setup"> Manual Setup </a>
To manually clone, build and run Redox using a Linux host, run the following commands (with exceptions, be sure to read the comments):
To manually clone, build and run Redox using a Unix-based host, run the following commands (with exceptions, be sure to read the comments):
```bash
$ cd path/to/your/projects/folder/
@ -128,7 +134,7 @@ $ git clone git@github.com:redox-os/redox.git --origin upstream --recursive
$ cd redox/
# Install/update dependencies
$ bash bootstrap.sh -d
$ ./bootstrap.sh -d
# Install rustup.rs
$ curl https://sh.rustup.rs -sSf | sh
@ -146,6 +152,22 @@ $ make all
# Launch using QEMU
$ make qemu
# Launch using QEMU without using KVM (Kernel Virtual Machine). Try if QEMU gives an error.
$ make qemu kvm=no
# Launch using QEMU without using KVM (Kernel Virtual Machine) nor Graphics
make qemu kvm=no vga=no
```
### <a name="setup-using-docker"> Setup using Docker </a>
We also provide docker image. After cloning this repository, please follow README under the `docker` directory.
### Updating the codebase using the Makefile
To update the codebase run:
```
make pull; make fetch
```
`make pull` pulls and updates the submodules, and `make fetch` updates the sources for cookbook recipes.

View file

@ -1,8 +0,0 @@
[package]
name = "arch_arm"
version = "0.1.0"
[dependencies]
bitflags = "*"
hole_list_allocator = { path = "../../crates/hole_list_allocator"}
spin = "*"

View file

@ -1,9 +0,0 @@
#[derive(Debug)]
pub struct Context;
impl Context {
pub fn new() -> Self {
Context
}
}

View file

@ -1,70 +0,0 @@
/// Memcpy
///
/// Copy N bytes of memory from one location to another.
#[no_mangle]
pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8,
n: usize) -> *mut u8 {
let mut i = 0;
while i < n {
*dest.offset(i as isize) = *src.offset(i as isize);
i += 1;
}
dest
}
/// Memmove
///
/// Copy N bytes of memory from src to dest. The memory areas may overlap.
#[no_mangle]
pub unsafe extern fn memmove(dest: *mut u8, src: *const u8,
n: usize) -> *mut u8 {
if src < dest as *const u8 {
let mut i = n;
while i != 0 {
i -= 1;
*dest.offset(i as isize) = *src.offset(i as isize);
}
} else {
let mut i = 0;
while i < n {
*dest.offset(i as isize) = *src.offset(i as isize);
i += 1;
}
}
dest
}
/// Memset
///
/// Fill a block of memory with a specified value.
#[no_mangle]
pub unsafe extern fn memset(s: *mut u8, c: i32, n: usize) -> *mut u8 {
let mut i = 0;
while i < n {
*s.offset(i as isize) = c as u8;
i += 1;
}
s
}
/// Memcmp
///
/// Compare two blocks of memory.
#[no_mangle]
pub unsafe extern fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
let mut i = 0;
while i < n {
let a = *s1.offset(i as isize);
let b = *s2.offset(i as isize);
if a != b {
return a as i32 - b as i32
}
i += 1;
}
0
}

View file

@ -1,30 +0,0 @@
//! Interrupt instructions
/// Clear interrupts
#[inline(always)]
pub unsafe fn disable() {
}
/// Set interrupts
#[inline(always)]
pub unsafe fn enable() {
}
/// Set interrupts and halt
#[inline(always)]
pub unsafe fn enable_and_halt() {
halt();
}
/// Halt instruction
#[inline(always)]
pub unsafe fn halt() {
//asm!("wfi" : : : : "volatile");
asm!("nop" : : : : "volatile");
}
/// Get a stack trace
//TODO: Check for stack being mapped before dereferencing
#[inline(never)]
pub unsafe fn stack_trace() {
}

View file

@ -1,39 +0,0 @@
//! Architecture support for ARM
#![feature(asm)]
#![feature(lang_items)]
#![feature(naked_functions)]
#![no_std]
extern crate hole_list_allocator as allocator;
#[macro_use]
extern crate bitflags;
extern crate spin;
/// Print to console
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ({});
}
/// Print with new line to console
#[macro_export]
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
/// Context switching
pub mod context;
/// Memset, memcpy, etc.
pub mod externs;
/// Interrupt handling
pub mod interrupt;
/// Panic support
pub mod panic;
/// Initialization function
pub mod start;

View file

@ -1,60 +0,0 @@
ENTRY(kstart)
OUTPUT_ARCH(arm)
OUTPUT_FORMAT(elf32-littlearm)
KERNEL_OFFSET = 0;
SECTIONS {
. = KERNEL_OFFSET;
.text : AT(ADDR(.text) - KERNEL_OFFSET) {
__text_start = .;
*(.text*)
. = ALIGN(4096);
__text_end = .;
}
.rodata : AT(ADDR(.rodata) - KERNEL_OFFSET) {
__rodata_start = .;
*(.rodata*)
. = ALIGN(4096);
__rodata_end = .;
}
.data : AT(ADDR(.data) - KERNEL_OFFSET) {
__data_start = .;
*(.data*)
. = ALIGN(4096);
__data_end = .;
}
.tdata : AT(ADDR(.tdata) - KERNEL_OFFSET) {
__tdata_start = .;
*(.tdata*)
. = ALIGN(4096);
__tdata_end = .;
__tbss_start = .;
*(.tbss*)
. += 8;
. = ALIGN(4096);
__tbss_end = .;
}
.bss : AT(ADDR(.bss) - KERNEL_OFFSET) {
__bss_start = .;
*(.bss*)
. = ALIGN(4096);
__bss_end = .;
}
__end = .;
/DISCARD/ : {
*(.comment*)
*(.debug*)
*(.eh_frame*)
*(.gcc_except_table*)
*(.note*)
*(.rel.eh_frame*)
}
}

View file

@ -1,38 +0,0 @@
//! Intrinsics for panic handling
use interrupt;
#[cfg(not(test))]
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
#[cfg(not(test))]
/// Required to handle panics
#[lang = "panic_fmt"]
extern "C" fn panic_fmt(fmt: ::core::fmt::Arguments, file: &str, line: u32) -> ! {
println!("PANIC: {}", fmt);
println!("FILE: {}", file);
println!("LINE: {}", line);
unsafe { interrupt::stack_trace(); }
println!("HALT");
loop {
unsafe { interrupt::halt(); }
}
}
#[allow(non_snake_case)]
#[no_mangle]
/// Required to handle panics
pub extern "C" fn _Unwind_Resume() -> ! {
loop {
unsafe { interrupt::halt(); }
}
}
/// Required for linker
#[no_mangle]
pub extern "C" fn __aeabi_unwind_cpp_pr0() {
loop {}
}

View file

@ -1,27 +0,0 @@
const SERIAL_BASE: *mut u8 = 0x16000000 as *mut u8;
const SERIAL_FLAG_REGISTER: *const u8 = 0x16000018 as *const u8;
const SERIAL_BUFFER_FULL: u8 = (1 << 5);
unsafe fn putc (c: u8)
{
/* Wait until the serial buffer is empty */
while *SERIAL_FLAG_REGISTER & SERIAL_BUFFER_FULL == SERIAL_BUFFER_FULL {}
/* Put our character, c, into the serial buffer */
*SERIAL_BASE = c;
}
unsafe fn puts(string: &str)
{
for b in string.bytes() {
putc(b);
}
}
#[no_mangle]
#[naked]
pub unsafe extern fn kstart() -> ! {
asm!("mov sp, 0x18000" : : : : "volatile");
puts("TEST\r\n");
loop {}
}

View file

@ -1,3 +0,0 @@
[package]
name = "arch_test"
version = "0.1.0"

View file

@ -1,43 +0,0 @@
//! Interrupt instructions
static mut INTERRUPTS_ENABLED: bool = false;
/// Clear interrupts
#[inline(always)]
pub unsafe fn disable() {
println!("CLEAR INTERRUPTS");
INTERRUPTS_ENABLED = false;
}
/// Set interrupts
#[inline(always)]
pub unsafe fn enable() {
println!("SET INTERRUPTS");
INTERRUPTS_ENABLED = true;
}
/// Halt instruction
#[inline(always)]
pub unsafe fn halt() {
assert!(INTERRUPTS_ENABLED);
::std::thread::yield_now();
}
/// Pause instruction
#[inline(always)]
pub unsafe fn pause() {
}
/// Set interrupts and nop
#[inline(always)]
pub unsafe fn enable_and_nop() {
enable();
}
/// Set interrupts and halt
#[inline(always)]
pub unsafe fn enable_and_halt() {
enable();
halt();
}

View file

@ -1,43 +0,0 @@
//! Architecture support for testing
pub use std::io;
/// Print to console
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ({
use $crate::io::Write;
let _ = write!($crate::io::stdout(), $($arg)*);
});
}
/// Print with new line to console
#[macro_export]
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
/// Create an interrupt function that can safely run rust code
#[macro_export]
macro_rules! interrupt {
($name:ident, $func:block) => {
pub unsafe extern fn $name () {
unsafe fn inner() {
$func
}
// Call inner rust function
inner();
}
};
}
/// Interrupt instructions
pub mod interrupt;
/// Initialization and main function
pub mod main;
/// Time functions
pub mod time;

View file

@ -1,11 +0,0 @@
/// This function is where the kernel sets up IRQ handlers
/// It is increcibly unsafe, and should be minimal in nature
extern {
fn kmain() -> !;
}
#[no_mangle]
pub unsafe extern fn kstart() -> ! {
kmain();
}

Some files were not shown because too many files have changed in this diff Show more