Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ jobs:
- name: "Print QEMU Version"
run: qemu-system-x86_64 --version

- name: 'Build kernel with built-in target (no json-target-spec config)'
run: cargo bootimage --target x86_64-unknown-none
working-directory: example-kernel-built-in-target

- name: 'Build "basic" Kernel'
run: cargo bootimage --target ../x86_64-bootimage-example-kernels.json
working-directory: example-kernels/basic
Expand Down
2 changes: 2 additions & 0 deletions example-kernel-built-in-target/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[unstable]
build-std = ["core", "compiler_builtins"]
1 change: 1 addition & 0 deletions example-kernel-built-in-target/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
53 changes: 53 additions & 0 deletions example-kernel-built-in-target/Cargo.lock

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

8 changes: 8 additions & 0 deletions example-kernel-built-in-target/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "example-kernel-built-in-target"
version = "0.1.0"
edition = "2018"

[dependencies]
bootloader = "0.9.7"
x86_64 = "0.14.1"
1 change: 1 addition & 0 deletions example-kernel-built-in-target/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly
22 changes: 22 additions & 0 deletions example-kernel-built-in-target/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![no_std]
#![no_main]

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}

#[no_mangle]
pub extern "C" fn _start() -> ! {
unsafe { exit_qemu(); }
loop {}
}

unsafe fn exit_qemu() {
use x86_64::instructions::port::Port;

let mut port = Port::<u32>::new(0xf4);
port.write(51); // exit code is (51 << 1) | 1 = 103
}
Loading