Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
12 changes: 5 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly-2022-01-20
profile: minimal
components: rust-src
- name: Build docs
run: |
Expand All @@ -23,8 +22,7 @@ jobs:
aarch64-unknown-none-softfloat \
riscv32imac-unknown-none-elf \
riscv64imac-unknown-none-elf \
riscv64imac-unknown-none-elf \
mipsel-unknown-linux-gnu
riscv64imac-unknown-none-elf
do
Comment thread
jiegec marked this conversation as resolved.
rustup target add ${target}
cargo doc --target ${target}
Expand All @@ -34,7 +32,7 @@ jobs:
do
rustup target add ${target}
cargo doc --target ${target}
cargo doc --target ${target} -Z build-std=core,alloc
cargo +nightly doc --target ${target} -Z build-std=core,alloc
mv target/${target}/doc doc/${target}
done
- name: Deploy to Github Pages
Expand Down
100 changes: 25 additions & 75 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@ on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rm rust-toolchain
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: nightly-2022-01-20
override: true
components: rustfmt, clippy
- name: Check code format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- run: cargo fmt --all -- --check

build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
target: [
Expand All @@ -31,84 +23,42 @@ jobs:
aarch64-unknown-none-softfloat,
riscv32imac-unknown-none-elf,
riscv64imac-unknown-none-elf,
mipsel-unknown-linux-gnu,
]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: nightly-2022-01-20
target: ${{ matrix.target }}
targets: ${{ matrix.target }}
components: clippy
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --target ${{ matrix.target }}
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --target ${{ matrix.target }}
- name: Docs
uses: actions-rs/cargo@v1
with:
command: doc
args: --target ${{ matrix.target }}
- run: cargo build --all-features --target ${{ matrix.target }}
- run: cargo clippy --target ${{ matrix.target }}
- run: cargo doc --target ${{ matrix.target }}

build-x86_64-none:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: nightly-2022-01-20
components: rust-src
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --target x86_64-unknown-linux-gnu -Z build-std=core,alloc
- name: Docs
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features --target x86_64-unknown-linux-gnu -Z build-std=core,alloc
- run: cargo +nightly build --all-features --target x86_64-unknown-linux-gnu -Z build-std=core,alloc
- run: cargo +nightly doc --all-features --target x86_64-unknown-linux-gnu -Z build-std=core,alloc

test-x86_64:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- run: rm rust-toolchain
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2022-01-20
override: true
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features

test-aarch64:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rm rust-toolchain
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2022-01-20
target: aarch64-unknown-linux-gnu
override: true
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
use-cross: true
command: test
args: --target aarch64-unknown-linux-gnu
targets: aarch64-unknown-linux-gnu
- run: cargo build --target aarch64-unknown-linux-gnu
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exclude = ["docs", ".idea"]
[dependencies]

[target.'cfg(target_arch = "x86_64")'.dependencies]
x86_64 = "0.15"
x86_64 = { version = "0.15", default-features = false, features = ["instructions"] }
raw-cpuid = "11.0"

[features]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/riscv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ edition = "2018"
[dependencies]
log = "0.4"
riscv = "0.7"
opensbi-rt = { git = "https://github.com/rcore-os/opensbi-rt.git", rev = "abdfeb7" }
opensbi-rt = { git = "https://github.com/rcore-os/opensbi-rt.git", rev = "6d44fced33f6116bfea68d52b0e027bea6414e85" }
trapframe = { path = "../.." }
14 changes: 5 additions & 9 deletions examples/riscv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ arch ?= riscv64
target := $(arch)imac-unknown-none-elf
mode := debug
kernel := target/$(target)/$(mode)/riscv
bin := target/$(target)/$(mode)/kernel.bin

sysroot := $(shell rustc --print sysroot)
objdump := $(shell find $(sysroot) -name llvm-objdump) --arch-name=$(arch)
Expand All @@ -21,17 +20,14 @@ endif

.PHONY: kernel build clean qemu run env

build: $(bin)
build: kernel

env:
rustup component add llvm-tools-preview rustfmt
rustup target add $(target)
rustup component add llvm-tools-preview rustfmt --toolchain nightly
rustup target add $(target) --toolchain nightly

kernel:
cargo build $(BUILD_ARGS)

$(bin): kernel
$(objcopy) $(kernel) --strip-all -O binary $@
cargo +nightly build $(BUILD_ARGS)

asm:
$(objdump) -d $(kernel) | less
Expand All @@ -50,6 +46,6 @@ qemu: $(bin)
-machine virt \
-nographic \
-bios default \
-device loader,file=$(bin),addr=$(START_ADDR)
-kernel $(kernel)
Comment thread
jiegec marked this conversation as resolved.

run: build qemu
2 changes: 1 addition & 1 deletion examples/riscv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern "C" fn main() {
t6: 31,
},
sstatus: 0xdead_beaf,
sepc: user_entry as usize,
sepc: user_entry as *const () as usize,
};
println!("Go to user: {:#x?}", regs);
regs.run();
Expand Down
6 changes: 0 additions & 6 deletions examples/uefi/.cargo/config

This file was deleted.

2 changes: 2 additions & 0 deletions examples/uefi/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "x86_64-unknown-uefi"
13 changes: 9 additions & 4 deletions examples/uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
name = "uefi"
version = "0.1.0"
authors = ["Runji Wang <wangrunji0408@163.com>"]
edition = "2018"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

[dependencies]
log = "0.4"
x86_64 = "0.14"
uefi = "0.14"
uefi-services = "0.11"
x86_64 = { version = "0.15", default-features = false, features = ["instructions"] }
uefi = { version = "0.38", features = ["global_allocator", "logger", "panic_handler"] }
trapframe = { path = "../.." }
2 changes: 1 addition & 1 deletion examples/uefi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TARGET := target
OVMF := OVMF.fd
EFI := $(TARGET)/x86_64-unknown-uefi/$(MODE)/uefi.efi
ESP := $(TARGET)/x86_64-unknown-uefi/$(MODE)/esp
QEMU_ARGS := -net none -nographic
QEMU_ARGS := -net none -nographic -cpu max
OBJDUMP := rust-objdump

ifeq (${MODE}, release)
Expand Down
32 changes: 18 additions & 14 deletions examples/uefi/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#![no_std]
#![no_main]
#![feature(abi_efiapi)]
#![feature(core_intrinsics)]
#![feature(naked_functions)]
#![deny(warnings)]

extern crate alloc;

use core::arch::asm;
use core::intrinsics::breakpoint;
use log::*;
use trapframe::{GeneralRegs, TrapFrame, UserContext};
use uefi::prelude::*;
use x86_64::registers::control::*;
use x86_64::structures::paging::{PageTable, PageTableFlags};

core::arch::global_asm!(
r#"
.global user_entry
user_entry:
syscall
int3
"#
);

extern "C" {
fn user_entry();
}

#[entry]
fn efi_main(_image: Handle, mut st: SystemTable<Boot>) -> uefi::Status {
uefi_services::init(&mut st).expect_success("Failed to initialize utilities");
fn efi_main() -> Status {
uefi::helpers::init().expect("Failed to initialize utilities");
check_and_set_cpu_features();
allow_user_access(user_entry as usize);
allow_user_access(user_entry as *const () as usize);
unsafe {
trapframe::init();
}
Expand All @@ -42,7 +51,7 @@ fn efi_main(_image: Handle, mut st: SystemTable<Boot>) -> uefi::Status {
r13: 13,
r14: 14,
r15: 15,
rip: user_entry as usize,
rip: user_entry as *const () as usize,
rflags: 0x202,
fsbase: 18,
gsbase: 19,
Expand All @@ -62,7 +71,7 @@ fn efi_main(_image: Handle, mut st: SystemTable<Boot>) -> uefi::Status {

// trap from kernel
unsafe {
breakpoint();
asm!("int3", options(nomem, nostack));
}
unimplemented!()
}
Expand All @@ -78,11 +87,6 @@ extern "sysv64" fn trap_handler(tf: &mut TrapFrame) {
}
}

#[naked]
unsafe extern "C" fn user_entry() {
asm!("syscall", "int3", options(noreturn));
}

/// Set user bit for 4-level PDEs of the `page`.
/// This is a workaround since `x86_64` crate does not set user bit for PDEs.
fn allow_user_access(vaddr: usize) {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-01-20
stable
8 changes: 4 additions & 4 deletions src/arch/aarch64/fncall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ elr_location:
let mut cx = UserContext {
general,
sp: stack.as_mut_ptr() as usize + 0x1000,
elr: dump_registers as usize,
elr: dump_registers as *const () as usize,
..Default::default()
};
cx.run_fncall();
Expand All @@ -157,7 +157,7 @@ elr_location:
assert_eq!(
general_dump,
GeneralRegs {
x30: dump_registers as usize,
x30: dump_registers as *const () as usize,
..general
}
);
Expand Down Expand Up @@ -195,10 +195,10 @@ elr_location:
x27: 100 + 27,
x28: 100 + 28,
x29: 100 + 29,
x30: elr_location as usize,
x30: elr_location as *const () as usize,
..cx.general
}
);
assert_eq!(cx.elr, elr_location as usize);
assert_eq!(cx.elr, elr_location as *const () as usize);
}
}
2 changes: 1 addition & 1 deletion src/arch/aarch64/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ global_asm!(include_str!("trap.S"));
/// You **MUST NOT** modify these registers later.
pub unsafe fn init() {
// Set the exception vector address
asm!("msr VBAR_EL1, {}", in(reg) __vectors as usize);
asm!("msr VBAR_EL1, {}", in(reg) __vectors as *const () as usize);
}

/// Trap frame of kernel interrupt
Expand Down
Loading
Loading