From 8c8ad3ab94499a5f42b29350e5621f362e580347 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 5 May 2026 23:58:17 +0800 Subject: [PATCH] api level changes to allow wdt to move earlier in boot right now the inability to move the WDT object through the hardware manager is causing it to be initialized fairly late in boot which makes it less useful for recovering from boot failures --- libs/bao1x-hal/src/wdt.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/bao1x-hal/src/wdt.rs b/libs/bao1x-hal/src/wdt.rs index 3144ec43b..c8c6d2126 100644 --- a/libs/bao1x-hal/src/wdt.rs +++ b/libs/bao1x-hal/src/wdt.rs @@ -207,6 +207,16 @@ impl Wdt { } } + /// reveals the internal CSR address for the WDT. The recipient of this address must promise + /// not to do any concurrent access with the donor; the primary purpose of this method is to + /// provide a method for moving the CSR between threads + pub unsafe fn to_raw(&self) -> usize { self.csr.base() as usize } + + /// create a WDT from an internal CSR address. The caller must guarantee that the donor + /// of the address has released the address, and also that the address is in fact a valid + /// mapping for the WDT. + pub unsafe fn from_raw(mem: usize) -> Self { Wdt { csr: CSR::new(mem as *mut u32) } } + // -- Lock helpers --------------------------------------------------------- #[inline]