[dice] Retrieve the DICE data range from FDT in service VM
Bug: 287233786
Test: atest rialto_test
Change-Id: I3e3c4e1c5579726d8b139ed74780acb43b6c4ce9
diff --git a/libs/libfdt/src/lib.rs b/libs/libfdt/src/lib.rs
index a305e03..1bf285e 100644
--- a/libs/libfdt/src/lib.rs
+++ b/libs/libfdt/src/lib.rs
@@ -341,7 +341,8 @@
self.fdt
}
- fn next_compatible(self, compatible: &CStr) -> Result<Option<Self>> {
+ /// Returns the compatible node of the given name that is next after this node.
+ pub fn next_compatible(self, compatible: &CStr) -> Result<Option<Self>> {
// SAFETY: Accesses (read-only) are constrained to the DT totalsize.
let ret = unsafe {
libfdt_bindgen::fdt_node_offset_by_compatible(
@@ -354,6 +355,11 @@
Ok(fdt_err_or_option(ret)?.map(|offset| Self { fdt: self.fdt, offset }))
}
+ /// Returns the first range of `reg` in this node.
+ pub fn first_reg(&self) -> Result<Reg<u64>> {
+ self.reg()?.ok_or(FdtError::NotFound)?.next().ok_or(FdtError::NotFound)
+ }
+
fn address_cells(&self) -> Result<AddrCells> {
// SAFETY: Accesses are constrained to the DT totalsize (validated by ctor).
unsafe { libfdt_bindgen::fdt_address_cells(self.fdt.as_ptr(), self.offset) }
@@ -526,7 +532,7 @@
Ok(FdtNode { fdt: &*self.fdt, offset: fdt_err(ret)? })
}
- /// Return the compatible node of the given name that is next to this node
+ /// Returns the compatible node of the given name that is next after this node
pub fn next_compatible(self, compatible: &CStr) -> Result<Option<Self>> {
// SAFETY: Accesses (read-only) are constrained to the DT totalsize.
let ret = unsafe {