1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright Tock Contributors 2024.
45//! AppID mechanisms based on TBF headers.
67use kernel::process::{Process, ProcessBinary, ShortId};
8use kernel::process_checker::{AppUniqueness, Compress};
910/// Assign AppIDs based on fields in the app's TBF header.
11///
12/// This uses the ShortId TBF header to assign short IDs to applications. If the
13/// header is not present the application will be assigned a
14/// `ShortID::LocallyUnique` ID.
15///
16/// This assigner uses ShortIds as the AppID, so the built-in check for ShortId
17/// uniqueness is sufficient.
18pub struct AppIdAssignerTbfHeader {}
1920impl AppUniqueness for AppIdAssignerTbfHeader {
21fn different_identifier(&self, _process_a: &ProcessBinary, _process_b: &ProcessBinary) -> bool {
22true
23}
2425fn different_identifier_process(
26&self,
27 _process_binary: &ProcessBinary,
28 _process: &dyn Process,
29 ) -> bool {
30true
31}
3233fn different_identifier_processes(
34&self,
35 _process_a: &dyn Process,
36 _process_b: &dyn Process,
37 ) -> bool {
38true
39}
40}
4142impl Compress for AppIdAssignerTbfHeader {
43fn to_short_id(&self, process: &ProcessBinary) -> ShortId {
44 process.header.get_fixed_short_id().into()
45 }
46}