For educational purposes, use own zero_bss().
parent
a41190e298
commit
c64dd1197a
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
//
|
||||
// Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
|
||||
|
||||
//! Memory Management.
|
||||
|
||||
use core::ops::Range;
|
||||
|
||||
/// Zero out a memory region.
|
||||
///
|
||||
/// # 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: Range<*mut T>)
|
||||
where
|
||||
T: From<u8>,
|
||||
{
|
||||
let mut ptr = range.start;
|
||||
|
||||
while ptr < range.end {
|
||||
core::ptr::write_volatile(ptr, T::from(0));
|
||||
ptr = ptr.offset(1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue