You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// 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;
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
// Public Code
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// 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);
|
|
|
|
}
|
|
|
|
}
|