Change to new aarch64-unknown-none-softloat target.

Also, add safety docs where demanded by clippy.
pull/30/head
Andre Richter 5 years ago
parent d44dfc5580
commit f13e6e4513
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

@ -26,9 +26,9 @@ much as possible, we are already setting up a Rust crate. This allows us to use
The Raspberry Pi 3 features a processor that uses ARM's `AArch64` architecture.
Conveniently, Rust already provides a generic target for bare-metal aarch64 code
that we can leverage. It is called [aarch64-unknown-none].
that we can leverage. It is called [aarch64-unknown-none-softfloat].
[aarch64-unknown-none]: https://github.com/andre-richter/rust/blob/master/src/librustc_target/spec/aarch64_unknown_none.rs
[aarch64-unknown-none-softfloat]: https://github.com/rust-lang/rust/blob/master/src/librustc_target/spec/aarch64_unknown_none_softfloat.rs
In the `Makefile`, we select this target in various places by passing it to
cargo using the `--target` cmdline argument.
@ -37,17 +37,20 @@ Additionally, we provide a config file in `.cargo/config` were we make further
specializations:
```toml
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]
```
The first line tells rustc to use our custom `link.ld` linker script. The second
line instructs the compiler to not use floating point operations. This is a
common choice when writing an operating system kernel. If floating point is not
The first line tells rustc to use our custom `link.ld` linker script. The
second argument specifies the exact CPU type that is used on Raspberry Pi 3, so
that the compiler can optimize for it.
The target itself tells the compiler already to not use floating point
operations, which is hinted by the `-softfloat` appendix. This is a common
choice when writing an operating system kernel. If floating point is not
explicitly disabled, it is possible that the compiler uses auto-vectorization to
optimize, for example, operations on array data structures. This would
implicitly result in use of floating point registers and operations. However,
@ -55,10 +58,7 @@ since it is very costly to save and restore floating point registers during
context-switches, use of fp is usually disabled from the get go to save the
cycles and optimize the kernel for fast context switching.
Finally, the third arguments specifies the exact CPU type that is used in
Raspberry Pi 3, so that the compiler can optimize for it.
Since the `aarch64-unknown-none` target is not shipped with an associated
Since the `aarch64-unknown-none-softfloat` target is not shipped with an associated
precompiled standard library, and since we anyways modify the target via the
`.cargo/config` file, we are using [cargo-xbuild][xbuild] to compile our own
standard library. This way, we can ensure that our bare-metal code is optimized

Binary file not shown.

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

@ -36,6 +36,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -49,6 +53,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn reset() -> ! {
extern "C" {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

@ -36,6 +36,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -49,6 +53,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn reset() -> ! {
extern "C" {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -36,6 +36,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -49,6 +53,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn reset() -> ! {
extern "C" {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

@ -36,6 +36,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -49,6 +53,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn reset() -> ! {
extern "C" {

@ -1,7 +1,6 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
"-C", "relocation-model=pic",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

@ -92,10 +92,9 @@ To enable PIC for our loader, we add the following line to the compiler flags in
the`.cargo/config`:
```toml
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
"-C", "relocation-model=pic", # <-- New
]

Binary file not shown.

@ -36,6 +36,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -49,6 +53,10 @@ macro_rules! entry {
/// Reset function.
///
/// Trampolines into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
#[no_mangle]
pub unsafe extern "C" fn reset() -> ! {
extern "Rust" {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

@ -93,7 +93,7 @@ should yield something like the following, where you can see that the stack
pointer is not used apart from ourselves setting it.
```console
ferris@box:~$ cargo objdump --target aarch64-unknown-none -- -disassemble -print-imm-hex kernel8
ferris@box:~$ cargo objdump --target aarch64-unknown-none-softfloat -- -disassemble -print-imm-hex kernel8
[...] (Some output omitted)

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -69,6 +77,10 @@ unsafe fn reset() -> ! {
///
/// Parks all cores except core0, and then jumps to the internal
/// `reset()` function.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -69,6 +77,10 @@ unsafe fn reset() -> ! {
///
/// Parks all cores except core0, and then jumps to the internal
/// `reset()` function.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -69,6 +77,10 @@ unsafe fn reset() -> ! {
///
/// Parks all cores except core0, and then jumps to the internal
/// `reset()` function.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -69,6 +77,10 @@ unsafe fn reset() -> ! {
///
/// Parks all cores except core0, and then jumps to the internal
/// `reset()` function.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -69,6 +77,10 @@ unsafe fn reset() -> ! {
///
/// Parks all cores except core0, and then jumps to the internal
/// `reset()` function.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

@ -122,7 +122,7 @@ do not have a stack yet. We should double-check the generated machine code:
```console
ferris@box:~$ make objdump
cargo objdump --target aarch64-unknown-none -- -disassemble -print-imm-hex kernel8
cargo objdump --target aarch64-unknown-none-softfloat -- -disassemble -print-imm-hex kernel8
kernel8: file format ELF64-aarch64-little

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -109,6 +117,10 @@ fn setup_and_enter_el1_from_el2() -> ! {
///
/// Parks all cores except core0 and checks if we started in EL2. If
/// so, proceeds with setting up EL1.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -109,6 +117,10 @@ fn setup_and_enter_el1_from_el2() -> ! {
///
/// Parks all cores except core0 and checks if we started in EL2. If
/// so, proceeds with setting up EL1.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -276,6 +276,10 @@ static mut LVL3_TABLE: PageTable = PageTable {
/// Set up identity mapped page tables for the first 1 GiB of address space.
///
/// The first 2 MiB are 4 KiB granule, the rest 2 MiB.
///
/// # Safety
///
/// - User must ensure that the hardware supports the paremeters being set here.
pub unsafe fn init() -> Result<(), &'static str> {
// Prepare the memory attribute indirection register.
set_up_mair();

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -109,6 +117,10 @@ fn setup_and_enter_el1_from_el2() -> ! {
///
/// Parks all cores except core0 and checks if we started in EL2. If
/// so, proceeds with setting up EL1.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -266,6 +266,10 @@ static mut LVL3_TABLE: PageTable = PageTable {
/// Set up identity mapped page tables for the first 1 GiB of address space.
///
/// The first 2 MiB are 4 KiB granule, the rest 2 MiB.
///
/// # Safety
///
/// - User must ensure that the hardware supports the paremeters being set here.
pub unsafe fn init() -> Result<(), &'static str> {
// Prepare the memory attribute indirection register.
set_up_mair();

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -109,6 +117,10 @@ fn setup_and_enter_el1_from_el2() -> ! {
///
/// Parks all cores except core0 and checks if we started in EL2. If
/// so, proceeds with setting up EL1.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -266,6 +266,10 @@ static mut LVL3_TABLE: PageTable = PageTable {
/// Set up identity mapped page tables for the first 1 GiB of address space.
///
/// The first 2 MiB are 4 KiB granule, the rest 2 MiB.
///
/// # Safety
///
/// - User must ensure that the hardware supports the paremeters being set here.
pub unsafe fn init() -> Result<(), &'static str> {
// Prepare the memory attribute indirection register.
set_up_mair();

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -109,6 +117,10 @@ fn setup_and_enter_el1_from_el2() -> ! {
///
/// Parks all cores except core0 and checks if we started in EL2. If
/// so, proceeds with setting up EL1.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -266,6 +266,10 @@ static mut LVL3_TABLE: PageTable = PageTable {
/// Set up identity mapped page tables for the first 1 GiB of address space.
///
/// The first 2 MiB are 4 KiB granule, the rest 2 MiB.
///
/// # Safety
///
/// - User must ensure that the hardware supports the paremeters being set here.
pub unsafe fn init() -> Result<(), &'static str> {
// Prepare the memory attribute indirection register.
set_up_mair();

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -109,6 +117,10 @@ fn setup_and_enter_el1_from_el2() -> ! {
///
/// Parks all cores except core0 and checks if we started in EL2. If
/// so, proceeds with setting up EL1.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

@ -27,6 +27,10 @@ use cortex_a::{barrier, regs::*};
global_asm!(include_str!("vectors.S"));
/// # Safety
///
/// - User must ensure to call this function at a suitable place, since it
/// changes the state of the hardware.
pub unsafe fn set_vbar_el1_checked(vec_base_addr: u64) -> bool {
if vec_base_addr.trailing_zeros() < 11 {
false

@ -266,6 +266,10 @@ static mut LVL3_TABLE: PageTable = PageTable {
/// Set up identity mapped page tables for the first 1 GiB of address space.
///
/// The first 2 MiB are 4 KiB granule, the rest 2 MiB.
///
/// # Safety
///
/// - User must ensure that the hardware supports the paremeters being set here.
pub unsafe fn init() -> Result<(), &'static str> {
// Prepare the memory attribute indirection register.
set_up_mair();

@ -1,6 +1,5 @@
[target.aarch64-unknown-none]
[target.aarch64-unknown-none-softfloat]
rustflags = [
"-C", "link-arg=-Tlink.ld",
"-C", "target-feature=-fp-armv8",
"-C", "target-cpu=cortex-a53",
]

@ -22,7 +22,7 @@
# SOFTWARE.
#
TARGET = aarch64-unknown-none
TARGET = aarch64-unknown-none-softfloat
SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) link.ld

Binary file not shown.

Binary file not shown.

@ -35,6 +35,10 @@ extern crate panic_abort;
#[macro_export]
macro_rules! entry {
($path:path) => {
/// # Safety
///
/// - User must ensure to provide a suitable main function for the
/// platform.
#[export_name = "main"]
pub unsafe fn __main() -> ! {
// type check the given path
@ -48,6 +52,10 @@ macro_rules! entry {
/// Reset function.
///
/// Initializes the bss section before calling into the user's `main()`.
///
/// # Safety
///
/// - Only a single core must be active and running this function.
unsafe fn reset() -> ! {
extern "C" {
// Boundaries of the .bss section, provided by the linker script
@ -69,6 +77,10 @@ unsafe fn reset() -> ! {
///
/// Parks all cores except core0, and then jumps to the internal
/// `reset()` function.
///
/// # Safety
///
/// - Linker script must ensure to place this function at `0x80_000`.
#[link_section = ".text.boot"]
#[no_mangle]
pub unsafe extern "C" fn _boot_cores() -> ! {

Loading…
Cancel
Save