Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 1 | /* |
Mikael Olsson | c4f16ef | 2023-02-10 11:39:40 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2023, Arm Limited. All rights reserved. |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FCONF_ETHOSN_GETTER_H |
| 8 | #define FCONF_ETHOSN_GETTER_H |
| 9 | |
| 10 | #include <assert.h> |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 11 | #include <stdbool.h> |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 12 | |
| 13 | #include <lib/fconf/fconf.h> |
| 14 | |
| 15 | #define hw_config__ethosn_config_getter(prop) ethosn_config.prop |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 16 | #define hw_config__ethosn_device_getter(dev_idx) __extension__ ({ \ |
| 17 | assert(dev_idx < ethosn_config.num_devices); \ |
| 18 | ðosn_config.devices[dev_idx]; \ |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 19 | }) |
| 20 | |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 21 | #define ETHOSN_DEV_NUM_MAX U(2) |
| 22 | #define ETHOSN_DEV_CORE_NUM_MAX U(8) |
| 23 | #define ETHOSN_DEV_ASSET_ALLOCATOR_NUM_MAX U(16) |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 24 | |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 25 | struct ethosn_allocator_t { |
| 26 | uint32_t stream_id; |
| 27 | }; |
| 28 | |
| 29 | struct ethosn_main_allocator_t { |
| 30 | struct ethosn_allocator_t firmware; |
| 31 | struct ethosn_allocator_t working_data; |
| 32 | }; |
| 33 | |
| 34 | struct ethosn_asset_allocator_t { |
| 35 | struct ethosn_allocator_t command_stream; |
| 36 | struct ethosn_allocator_t weight_data; |
| 37 | struct ethosn_allocator_t buffer_data; |
| 38 | struct ethosn_allocator_t intermediate_data; |
| 39 | }; |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 40 | |
Laurent Carlier | 5205df2 | 2021-09-16 15:10:35 +0100 | [diff] [blame] | 41 | struct ethosn_core_t { |
| 42 | uint64_t addr; |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 43 | struct ethosn_main_allocator_t main_allocator; |
Laurent Carlier | 5205df2 | 2021-09-16 15:10:35 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 46 | struct ethosn_device_t { |
| 47 | bool has_reserved_memory; |
Mikael Olsson | c4f16ef | 2023-02-10 11:39:40 +0100 | [diff] [blame] | 48 | uint64_t reserved_memory_addr; |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 49 | uint32_t num_cores; |
Mikael Olsson | 3288b46 | 2022-08-15 17:12:58 +0200 | [diff] [blame] | 50 | struct ethosn_core_t cores[ETHOSN_DEV_CORE_NUM_MAX]; |
| 51 | uint32_t num_allocators; |
| 52 | struct ethosn_asset_allocator_t asset_allocators[ETHOSN_DEV_ASSET_ALLOCATOR_NUM_MAX]; |
| 53 | }; |
| 54 | |
| 55 | struct ethosn_config_t { |
| 56 | uint32_t num_devices; |
| 57 | struct ethosn_device_t devices[ETHOSN_DEV_NUM_MAX]; |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
Mikael Olsson | 7da6619 | 2021-02-12 17:30:22 +0100 | [diff] [blame] | 60 | extern struct ethosn_config_t ethosn_config; |
| 61 | |
| 62 | #endif /* FCONF_ETHOSN_GETTER_H */ |