1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
Simon Renblad 7707399f51 remove undefined behavior in asserts 2024-10-17 14:15:47 +08:00
Simon Renblad 239bd2e65f add xbuild target features 2024-10-17 11:21:41 +08:00
Simon Renblad e4914f5872 cargo: change resolver 2024-10-17 10:33:41 +08:00
3 changed files with 3 additions and 7 deletions

View File

@ -1,7 +1,7 @@
[target.armv7-none-eabihf] [target.armv7-none-eabihf]
rustflags = [ rustflags = [
"-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tlink.x",
"-C", "target-feature=a9,armv7-a,neon", "-C", "target-feature=+a9,+armv7-a,+neon",
"-C", "target-cpu=cortex-a9", "-C", "target-cpu=cortex-a9",
] ]

View File

@ -9,6 +9,7 @@ members = [
"experiments", "experiments",
"szl", "szl",
] ]
resolver = "2"
[profile.release] [profile.release]
panic = "abort" panic = "abort"

View File

@ -1,6 +1,5 @@
use core::{ use core::{
ops::{Deref, DerefMut}, mem::{align_of, size_of}, ops::{Deref, DerefMut}, panic
mem::{align_of, size_of},
}; };
use alloc::alloc::{dealloc, Layout, LayoutError}; use alloc::alloc::{dealloc, Layout, LayoutError};
use crate::mmu::{L1_PAGE_SIZE, L1Table}; use crate::mmu::{L1_PAGE_SIZE, L1Table};
@ -20,7 +19,6 @@ impl<T> UncachedSlice<T> {
let layout = Layout::from_size_align(size, align)?; let layout = Layout::from_size_align(size, align)?;
let ptr = unsafe { alloc::alloc::alloc(layout).cast::<T>() }; let ptr = unsafe { alloc::alloc::alloc(layout).cast::<T>() };
let start = ptr as usize; let start = ptr as usize;
assert_eq!(start & (L1_PAGE_SIZE - 1), 0);
for page_start in (start..(start + size)).step_by(L1_PAGE_SIZE) { for page_start in (start..(start + size)).step_by(L1_PAGE_SIZE) {
// non-shareable device // non-shareable device
@ -31,10 +29,7 @@ impl<T> UncachedSlice<T> {
l1_section.bufferable = false; l1_section.bufferable = false;
}); });
} }
let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) }; let slice = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
// verify size
assert!(unsafe { slice.get_unchecked(len) } as *const _ as usize <= start + size);
// initialize // initialize
for e in slice.iter_mut() { for e in slice.iter_mut() {
*e = default(); *e = default();