2019-11-25 18:54:05 +00:00
|
|
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
2019-09-24 20:55:23 +00:00
|
|
|
//
|
2020-01-01 23:41:03 +00:00
|
|
|
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
2019-09-24 20:55:23 +00:00
|
|
|
|
|
|
|
//! Rust runtime initialization code.
|
|
|
|
|
2020-09-28 19:40:59 +00:00
|
|
|
use crate::{bsp, memory};
|
2020-01-04 17:15:43 +00:00
|
|
|
|
2020-03-28 12:27:14 +00:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
// Private Code
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
2020-01-04 17:15:43 +00:00
|
|
|
/// Zero out the .bss section.
|
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// - Must only be called pre `kernel_init()`.
|
|
|
|
#[inline(always)]
|
|
|
|
unsafe fn zero_bss() {
|
2020-10-05 21:47:18 +00:00
|
|
|
memory::zero_volatile(bsp::memory::bss_range_inclusive());
|
2020-01-04 17:15:43 +00:00
|
|
|
}
|
|
|
|
|
2020-03-28 12:27:14 +00:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
// Public Code
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
2019-10-20 12:42:59 +00:00
|
|
|
/// Equivalent to `crt0` or `c0` code in C/C++ world. Clears the `bss` section, then jumps to kernel
|
|
|
|
/// init code.
|
2019-09-24 20:55:23 +00:00
|
|
|
///
|
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// - Only a single core must be active and running this function.
|
|
|
|
#[no_mangle]
|
2020-10-05 22:01:50 +00:00
|
|
|
pub unsafe fn runtime_init() -> ! {
|
2020-01-04 17:15:43 +00:00
|
|
|
zero_bss();
|
2019-09-24 20:55:23 +00:00
|
|
|
|
2019-10-20 12:42:59 +00:00
|
|
|
crate::kernel_init()
|
2019-09-24 20:55:23 +00:00
|
|
|
}
|