Julian Hall | 201ce46 | 2021-04-29 11:05:34 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef CLAIM_SOURCE_H |
| 8 | #define CLAIM_SOURCE_H |
| 9 | |
Julian Hall | 1d31302 | 2021-05-07 14:27:55 +0100 | [diff] [blame^] | 10 | #include <stdint.h> |
Julian Hall | 201ce46 | 2021-04-29 11:05:34 +0100 | [diff] [blame] | 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | struct claim; |
| 17 | |
| 18 | /** |
| 19 | * An abstract interface for getting a claim from some source. The source |
| 20 | * may return any type of claim variant so it could be a single claim or a |
| 21 | * collection. |
| 22 | */ |
| 23 | struct claim_source |
| 24 | { |
| 25 | bool (*get_claim)(void *context, struct claim *claim); |
| 26 | void *context; |
| 27 | |
Julian Hall | 1d31302 | 2021-05-07 14:27:55 +0100 | [diff] [blame^] | 28 | /** |
| 29 | * A bitmap of claim categories that this claim_source provides claims for. |
| 30 | * Claim categories are enumerated by enum claim_category. |
| 31 | */ |
| 32 | uint32_t category_map; |
| 33 | |
Julian Hall | 201ce46 | 2021-04-29 11:05:34 +0100 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | /** |
| 37 | * \brief Get a claim from the claim source |
| 38 | * |
| 39 | * \param[in] cs The claim source |
| 40 | * \param[out] claim The returned claim |
| 41 | * |
| 42 | * \return Returns true if a claim is returned. |
| 43 | */ |
| 44 | static inline bool claim_source_get_claim(struct claim_source *cs, struct claim *claim) |
| 45 | { |
| 46 | return cs->get_claim(cs->context, claim); |
| 47 | } |
| 48 | |
| 49 | #ifdef __cplusplus |
| 50 | } /* extern "C" */ |
| 51 | #endif |
| 52 | |
| 53 | #endif /* CLAIM_SOURCE_H */ |