-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
385: First bits of the second edition r=phil-opp a=phil-opp This PR adds the first two posts for the second edition, “A Freestanding Rust Binary” and “A Minimal Rust Kernel”. The largest changes in comparison to the first edition are: - Instead of GRUB, we use our own [bootloader](https://github.com/rust-osdev/bootloader) (written in Rust) and our [bootimage](https://github.com/rust-osdev/bootimage) tool. This removes the dependencies on GRUB and `nasm`. Note that both tools are still experimental and might contain bugs. - Support for Windows and Mac: Without GRUB, there's nothing preventing us from building on Windows or Mac OS anymore! We added additional CI jobs at travis and appveyor to ensure that the project always builds on all three platforms. (At the moment, users still need to install LLD, but with the [LLVM 6 update of rustc](rust-lang/rust#47828) we should have a builtin LLD soon.) - No assembly in the main posts. Instead, we're creating a `no_std` _executable_ and relying on our custom bootloader to perform the initial page mapping and the switch to long mode. - No linker script: Our bootloader loads the kernel in a clean address space, so we can just use the default executable layout and don't need a linker script. (This also means that users that want a higher half kernel just need to update the mapping in their linker script. However, I'm not sure if it's a good idea to add this to the blog. Maybe later, when we begin to run user programs.) These changes only land in “beta mode” with this PR, which means that they're not linked from the front page yet. We will do that in a follow up PR.
- Loading branch information
Showing
62 changed files
with
1,386 additions
and
1,981 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
branches: | ||
except: | ||
# Used by bors | ||
- staging.tmp | ||
|
||
# Appveyor configuration template for Rust using rustup for Rust installation | ||
# https://github.com/starkat99/appveyor-rust | ||
|
||
## Operating System (VM environment) ## | ||
|
||
# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets. | ||
os: Visual Studio 2015 | ||
|
||
## Build Matrix ## | ||
environment: | ||
matrix: | ||
|
||
### MSVC Toolchains ### | ||
# Nightly 64-bit MSVC | ||
- channel: nightly | ||
target: x86_64-pc-windows-msvc | ||
MSYS_BITS: 64 | ||
# Nightly 32-bit MSVC | ||
- channel: nightly | ||
target: i686-pc-windows-msvc | ||
MSYS_BITS: 32 | ||
|
||
### GNU Toolchains ### | ||
# Nightly 64-bit GNU | ||
- channel: nightly | ||
target: x86_64-pc-windows-gnu | ||
MSYS_BITS: 64 | ||
# Nightly 32-bit GNU | ||
- channel: nightly | ||
target: i686-pc-windows-gnu | ||
MSYS_BITS: 32 | ||
|
||
cache: | ||
- '%USERPROFILE%\.cargo\bin' | ||
- '%USERPROFILE%\.cargo\config' | ||
- '%USERPROFILE%\.cargo\env' | ||
- '%USERPROFILE%\.cargo\.crates.toml' | ||
- '%USERPROFILE%\.xargo' | ||
- target | ||
|
||
## Install Script ## | ||
|
||
# This is the most important part of the Appveyor configuration. This installs the version of Rust | ||
# specified by the 'channel' and 'target' environment variables from the build matrix. This uses | ||
# rustup to install Rust. | ||
# | ||
# For simple configurations, instead of using the build matrix, you can simply set the | ||
# default-toolchain and default-host manually here. | ||
install: | ||
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe | ||
- rustup-init -yv --default-toolchain %channel% --default-host %target% | ||
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin | ||
- rustc -vV | ||
- cargo -vV | ||
|
||
## Build Script ## | ||
|
||
# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents | ||
# the "directory does not contain a project or solution file" error. | ||
build: false | ||
|
||
before_test: | ||
- mkdir bin | ||
- mklink "bin\ld.exe" "C:\Program Files\LLVM\bin\lld.exe" | ||
- set PATH=%CD%\bin;C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH% | ||
- rustup component add rust-src | ||
- set RUST_BACKTRACE=1 | ||
- if not exist %USERPROFILE%\.cargo\bin\cargo-install-update.exe cargo install cargo-update | ||
- if not exist %USERPROFILE%\.cargo\bin\xargo.exe cargo install xargo | ||
- if not exist %USERPROFILE%\.cargo\bin\bootimage.exe cargo install bootimage | ||
- cargo install-update -a | ||
|
||
# Uses 'cargo test' to run tests and build. Alternatively, the project may call compiled programs | ||
# directly or perform other testing commands. Rust will automatically be placed in the PATH | ||
# environment variable. | ||
test_script: | ||
- bootimage --target x86_64-blog_os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,53 @@ | ||
language: rust | ||
|
||
sudo: false | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: change | ||
|
||
branches: | ||
except: | ||
# Used by bors | ||
- staging.tmp | ||
|
||
rust: | ||
- nightly | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
addons: | ||
apt: | ||
sources: | ||
- llvm-toolchain-trusty-5.0 | ||
packages: | ||
- lld-5.0 | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cargo | ||
- $HOME/.xargo | ||
- $TRAVIS_BUILD_DIR/target | ||
- $HOME/.cargo | ||
- $HOME/.xargo | ||
- $TRAVIS_BUILD_DIR/target | ||
|
||
before_install: | ||
- | | ||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then | ||
set -e | ||
LLVM_URL="https://releases.llvm.org/5.0.1/clang+llvm-5.0.1-x86_64-apple-darwin.tar.xz" | ||
travis_retry wget -O llvm.tar.xz -nv ${LLVM_URL} | ||
tar -xJ -f llvm.tar.xz | ||
export PATH="`pwd`/clang+llvm-5.0.1-final-x86_64-apple-darwin/bin:$PATH" | ||
fi | ||
before_script: | ||
- rustup component add rust-src | ||
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update) | ||
- (test -x $HOME/.cargo/bin/xargo || cargo install xargo) | ||
- (test -x $HOME/.cargo/bin/bootimage || cargo install bootimage) | ||
- cargo install-update -a | ||
|
||
sudo: false | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: change | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- nasm | ||
|
||
script: | ||
- make | ||
- bootimage --target x86_64-blog_os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,14 @@ | ||
[package] | ||
authors = ["Philipp Oppermann <dev@phil-opp.com>"] | ||
name = "blog_os" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
|
||
[dependencies] | ||
bit_field = "0.7.0" | ||
bitflags = "0.9.1" | ||
multiboot2 = "0.1.0" | ||
once = "0.3.2" | ||
rlibc = "1.0" | ||
spin = "0.4.5" | ||
volatile = "0.1.0" | ||
x86_64 = "0.1.2" | ||
linked_list_allocator = "0.4.2" | ||
|
||
[dependencies.lazy_static] | ||
features = ["spin_no_std"] | ||
version = "0.2.1" | ||
# the profile used for `cargo build` | ||
[profile.dev] | ||
panic = "abort" # disable stack unwinding on panic | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
# the profile used for `cargo build --release` | ||
[profile.release] | ||
panic = "abort" # disable stack unwinding on panic |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
+++ | ||
title = "First Edition" | ||
template = "index.html" | ||
+++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
+++ | ||
title = "Second Edition" | ||
template = "second-edition/index.html" | ||
+++ |
Oops, something went wrong.