Time
The Time module provides an explicitly constructed time source for Xila services.
Role in system
- Supplies current time to modules that stamp metadata (for example VFS attributes).
- Supplies uptime-like elapsed time since manager initialization.
- Acts as the canonical time source adapter for platform drivers.
Responsibilities and boundaries
In scope
- Manager construction with a borrowed direct character device source.
get_current_time()andget_current_time_since_startup()query APIs.- Conversion between device byte payload and
core::time::Duration.
Out of scope
- Time synchronization protocols.
- Timezone/calendar policy.
- Multi-source clock arbitration.
Internal architecture
Manager::new(driver)returns an owned manager; the compatibility helpertime::initialize(driver)also returns a manager, rather than installing a singleton.Managerstores:- a borrowed
DirectCharacterDevice + Send + Syncwith a lifetime tied to the manager, start_time: Durationcaptured at initialization.
- a borrowed
- Current-time reads deserialize
Durationdirectly from device bytes.
Contract vs implementation
- Contract: callers get
Durationvalues and error on device/read failures. - Implementation: exact wire representation assumes device emits in-memory
Durationlayout expected by this build.
Lifecycle and execution model
- Platform provides time device implementation.
time::Manager::new(driver)captures the startup timestamp.- Pass a reference to runtime consumers for current time or elapsed since startup.
Data/control flow
- Read path: module caller -> time manager -> direct character device read ->
Duration. - Uptime path: current read - cached startup time.
Concurrency and synchronization model
- Manager state is immutable after initialization (device handle + start time).
- Read calls are lock-free in manager layer and depend on driver thread-safety guarantees.
Dependency model
- Upstream dependency: platform
DirectCharacterDeviceimplementation. - Downstream consumers: VFS, graphics tick callback, network time conversion.
Failure semantics and recovery behavior
- Initialization fails if initial time read fails.
- Runtime queries propagate device read failures as
time::Error. - No internal retry/backoff policy; callers decide recovery strategy.
Extension points
- Replace time source driver per target.
- Add higher-level synchronization layers above this module.
- Extend manager with optional monotonic/wall-clock source separation.
Known limitations and trade-offs
- Read-only API surface (no set-time operation in current module).
- Accuracy/monotonic behavior depends entirely on device implementation.
- Wire contract currently assumes compatible
Durationrepresentation at device boundary.