Skip to content

Conversation

@williampMSFT
Copy link
Contributor

This is an attempt to implement a service that can respond to requests that would be needed to implement an ACPI time-and-alarm device.

@github-actions
Copy link

Cargo Vet Audit Failed

cargo vet has failed in this PR. Please run cargo vet --locked locally to check for new or updated unvetted dependencies.
Details about the vetting process can be found in supply-chain/README.md

If the unvetted dependencies are not needed

Please modify Cargo.toml file to avoid including the dependencies.

If the unvetted dependencies are needed

Post a new comment with the questionnaire below to the PR to help the auditors vet the dependencies.
After the auditors have vetted the dependencies, the PR will need to be rebased to pick up the new audits and pass this check.

Copy and paste the questionnaire as a new comment and provide your answers:

1. What crates (with version) need to be audited?

2. How many of the crates are version updates vs new dependencies?

3. To confirm none of the already included crates serve your needs, please provide a brief description of the purpose of the new crates.

4. Any extra notes to the auditors to help with their audits.

@github-actions github-actions bot added the cargo vet PRs pending auditor review label Sep 24, 2025
service_storage: &'static mut OnceLock<Service>,
spawner: &embassy_executor::Spawner,
backing_clock: &'static mut impl DatetimeClock,
tz_storage: &'static mut dyn NvramStorage<'static, u32>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation requires 5 NVRAM slots. Most MCU have between 4-8 u32 words. To use 5 slots for timealarm service is a lot. Can we compact some of them into a single slot? Does all these need to be u32s?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative is to put this in flash instead of NVRAM if the frequence to update these values are low.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we need 2x u32 for 'power source policy', 2x u32 for the alarm time, 2 bits for DST and 12 bits for time zone, so if the granularity we have for storage is u32s then we need at least 5 (I'm packing DST and time zone into the same register to save space).

We can definitely move this to using flash as persistent storage, though - might even be able to do an implementation of the NvramStorage trait that's backed by flash and leverage that? That way we could give the application layer control over how they want to spend their NVRAM registers

Also, tangentially related, that analysis that we need 5x u32 assumes we're willing to fall over in 2106 when a u32 overflows, which this currently does - I was kicking around the idea of using some of the leftover bits from the DST + TZ register as some sort of global offset for stored unix time but figured that might be out of scope for the first version of this.

self.send_acpi_response(respond_to_endpoint, &COMMAND_SUCCEEDED).await;
match response_payload {
AcpiTimeAlarmCommandResult::Timestamp(timestamp) => {
self.send_acpi_response(respond_to_endpoint, &timestamp.as_bytes())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are sending multiple OOB packets to respond to one request? Can we combine the response into one packet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have a note about that on line 407 and definitely intend to revisit this before checking in. I figured the solution for this might look a bit different if we end up adopting something like postcard, so didn't want to invest time in an optimization like that until I had reasonable confidence that it's not going to get deleted before the PR gets published :)

@jerrysxie
Copy link
Contributor

@williampMSFT This service as it is should be able to be tested with a mock eSPI service or mock host service like https://github.com/OpenDevicePartnership/embedded-services/blob/main/examples/std/src/bin/debug.rs or https://github.com/OpenDevicePartnership/embedded-services/blob/main/examples/rt685s-evk/src/bin/mock_espi_service.rs. We should do that to test it out.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a service to provide ACPI time-and-alarm device functionality. The service handles timer operations for both AC and DC power sources and manages real-time clock operations with timezone support.

  • Adds a new time-alarm-service crate with complete ACPI timer and clock management functionality
  • Updates communication infrastructure to route messages to the new service
  • Removes legacy time-alarm data structures from the embedded-service crate

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
time-alarm-service/src/timer.rs Core timer implementation with persistent storage and power source state management
time-alarm-service/src/lib.rs Main service implementation handling ACPI commands and timer coordination
time-alarm-service/src/acpi_timestamp.rs ACPI timestamp format handling with timezone and daylight savings support
time-alarm-service/Cargo.toml Package configuration and dependencies for the new service
espi-service/src/espi_service.rs Updates message routing to remove legacy time-alarm handling
embedded-service/src/ec_type/structure.rs Removes legacy TimeAlarm structure definition
embedded-service/src/ec_type/protocols/mctp.rs Adds MCTP endpoint mapping for time-alarm service
embedded-service/src/ec_type/mod.rs Removes legacy time-alarm message handling functions
embedded-service/src/ec_type/message.rs Removes legacy TimeAlarmMessage enum
embedded-service/src/ec_type/generator/ec_memory_map.yaml Removes TimeAlarm structure from YAML configuration
Cargo.toml Adds time-alarm-service to workspace and required dependencies

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cargo vet PRs pending auditor review

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants