Patch DT using information extracted from DT
A number of patch_* functions were added to patch the given DT using
information gathered from read_*_from functions.
For now, the same DT is patched. i.e. the tempalte DT is NOT used. This
CL however is to show that the patch routines are working correctly.
Bug: 249054080
Test: TH
Change-Id: Iacd188cb19d131f2b761ea03ed7ceac39933e063
diff --git a/pvmfw/src/helpers.rs b/pvmfw/src/helpers.rs
index fddd8c3..4df9386 100644
--- a/pvmfw/src/helpers.rs
+++ b/pvmfw/src/helpers.rs
@@ -114,6 +114,15 @@
flush(reg)
}
+/// Flatten [[T; N]] into &[T]
+/// TODO: use slice::flatten when it graduates from experimental
+pub fn flatten<T, const N: usize>(original: &[[T; N]]) -> &[T] {
+ // SAFETY: no overflow because original (whose size is len()*N) is already in memory
+ let len = original.len() * N;
+ // SAFETY: [T] has the same layout as [T;N]
+ unsafe { core::slice::from_raw_parts(original.as_ptr().cast(), len) }
+}
+
/// Create &CStr out of &str literal
#[macro_export]
macro_rules! cstr {