Files
drone_core
drone_cortexm
drone_ctypes
drone_nrf_map
drone_nrf_map_periph_uarte
drone_nrf_map_pieces
drone_nrf_map_pieces_1
drone_nrf_map_pieces_10
drone_nrf_map_pieces_11
drone_nrf_map_pieces_12
drone_nrf_map_pieces_2
drone_nrf_map_pieces_3
drone_nrf_map_pieces_4
drone_nrf_map_pieces_5
drone_nrf_map_pieces_6
drone_nrf_map_pieces_7
drone_nrf_map_pieces_8
drone_nrf_map_pieces_9
futures
futures_channel
futures_core
futures_io
futures_sink
futures_task
futures_util
pin_project_lite
pin_utils
proc_macro_nested
typenum
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Basic functions for dealing with memory.

use core::{cell::UnsafeCell, ptr};

extern "C" {
    static BSS_START: UnsafeCell<usize>;
    static BSS_END: UnsafeCell<usize>;
    static DATA_LOAD: UnsafeCell<usize>;
    static DATA_START: UnsafeCell<usize>;
    static DATA_END: UnsafeCell<usize>;
}

/// Initializes the BSS mutable memory segment.
///
/// This function **must** be called as early as possible.
///
/// See also [`data_init`].
///
/// # Safety
///
/// This function reverts the state of initially zeroed mutable statics.
pub unsafe fn bss_init() {
    unsafe {
        let length = BSS_END.get() as usize - BSS_START.get() as usize;
        ptr::write_bytes(BSS_START.get(), 0, length >> 2);
    }
}

/// Initializes the DATA mutable memory segment.
///
/// This function **must** be called as early as possible.
///
/// See also [`bss_init`].
///
/// # Safety
///
/// This function reverts the state of initially non-zeroed mutable statics.
pub unsafe fn data_init() {
    unsafe {
        let length = DATA_END.get() as usize - DATA_START.get() as usize;
        ptr::copy_nonoverlapping(DATA_LOAD.get(), DATA_START.get(), length >> 2);
    }
}