Init DRAM in assembly instead of Rust
See https://github.com/rust-embedded/cortex-m-rt/issues/300pull/115/head
parent
39a066c246
commit
7f666000ce
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! BSP Memory Management.
|
||||
|
||||
use core::{cell::UnsafeCell, ops::RangeInclusive};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Definitions
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
// Symbols from the linker script.
|
||||
extern "Rust" {
|
||||
static __bss_start: UnsafeCell<u64>;
|
||||
static __bss_end_inclusive: UnsafeCell<u64>;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Return the inclusive range spanning the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Values are provided by the linker script and must be trusted as-is.
|
||||
/// - The linker-provided addresses must be u64 aligned.
|
||||
pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> {
|
||||
let range;
|
||||
unsafe {
|
||||
range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get());
|
||||
}
|
||||
assert!(!range.is_empty());
|
||||
|
||||
range
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! BSP Memory Management.
|
||||
|
||||
use core::{cell::UnsafeCell, ops::RangeInclusive};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Definitions
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
// Symbols from the linker script.
|
||||
extern "Rust" {
|
||||
static __bss_start: UnsafeCell<u64>;
|
||||
static __bss_end_inclusive: UnsafeCell<u64>;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Return the inclusive range spanning the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Values are provided by the linker script and must be trusted as-is.
|
||||
/// - The linker-provided addresses must be u64 aligned.
|
||||
pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> {
|
||||
let range;
|
||||
unsafe {
|
||||
range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get());
|
||||
}
|
||||
assert!(!range.is_empty());
|
||||
|
||||
range
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! BSP Memory Management.
|
||||
|
||||
use core::{cell::UnsafeCell, ops::RangeInclusive};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Definitions
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
// Symbols from the linker script.
|
||||
extern "Rust" {
|
||||
static __bss_start: UnsafeCell<u64>;
|
||||
static __bss_end_inclusive: UnsafeCell<u64>;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Return the inclusive range spanning the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Values are provided by the linker script and must be trusted as-is.
|
||||
/// - The linker-provided addresses must be u64 aligned.
|
||||
pub fn bss_range_inclusive() -> RangeInclusive<*mut u64> {
|
||||
let range;
|
||||
unsafe {
|
||||
range = RangeInclusive::new(__bss_start.get(), __bss_end_inclusive.get());
|
||||
}
|
||||
assert!(!range.is_empty());
|
||||
|
||||
range
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::RangeInclusive;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out an inclusive memory range.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `range.start` and `range.end` must be valid.
|
||||
/// - `range.start` and `range.end` must be `T` aligned.
|
||||
pub unsafe fn zero_volatile<T>(range: RangeInclusive<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = *range.start();
|
||||
let end_inclusive = *range.end();
|
||||
|
||||
while ptr <= end_inclusive {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
zero_bss();
|
||||
|
||||
crate::kernel_init()
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2021 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Rust runtime initialization code.
|
||||
|
||||
use crate::{bsp, memory};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Private Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Zero out the .bss section.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Must only be called pre `kernel_init()`.
|
||||
#[inline(always)]
|
||||
unsafe fn zero_bss() {
|
||||
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Public Code
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
||||
/// init code.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - Only a single core must be active and running this function.
|
||||
pub unsafe fn runtime_init() -> ! {
|
||||
extern "Rust" {
|
||||
fn kernel_init() -> !;
|
||||
}
|
||||
|
||||
zero_bss();
|
||||
kernel_init()
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue