05b4b214cdcb8c2968de0394cad713d2c61689e4
[platform/upstream/hailort.git] /
1 /**
2  * Copyright (c) 2024 Hailo Technologies Ltd. All rights reserved.
3  * Distributed under the MIT license (https://opensource.org/licenses/MIT)
4 **/
5 /**
6  * @file ddr_action_list_buffer_builder.hpp
7  * @brief Class used to build the action list sent to the firmware through DDR.
8  **/
9 #ifndef _HAILO_DDR_ACTION_LIST_BUFFER_BUILDER_HPP_
10 #define _HAILO_DDR_ACTION_LIST_BUFFER_BUILDER_HPP_
11
12 #include "hailo/hailort.h"
13 #include "context_switch_defs.h"
14 #include "core_op/resource_manager/action_list_buffer_builder/action_list_buffer_builder.hpp"
15 #include "vdma/memory/continuous_buffer.hpp"
16
17 #define DDR_ACTION_LIST_ENV_VAR         ("HAILO_DDR_ACTION_LIST")
18 #define DDR_ACTION_LIST_ENV_VAR_VALUE   ("1")
19
20 namespace hailort
21 {
22
23 class DDRActionListBufferBuilder : public ActionListBufferBuilder {
24 public:
25     DDRActionListBufferBuilder(vdma::ContinuousBuffer &&buffer);
26     virtual ~DDRActionListBufferBuilder() = default;
27     static Expected<std::shared_ptr<DDRActionListBufferBuilder>> create(size_t num_contexts, HailoRTDriver &driver);
28
29     virtual hailo_status write_action(MemoryView action, CONTROL_PROTOCOL__context_switch_context_type_t context_type,
30         bool is_new_context, bool last_action_buffer_in_context) override;
31
32     virtual uint64_t get_mapped_buffer_dma_address() const override;
33 private:    
34     vdma::ContinuousBuffer m_action_list_buffer;
35     // TODO: HRT-12512 : Can remove this check when / if continuous buffer comes from designated region
36     static bool verify_dma_addr(vdma::ContinuousBuffer &buffer);
37     size_t m_write_offset;
38     CONTROL_PROTOCOL__context_switch_context_info_chunk_t m_current_context_info;
39 };
40
41 } /* namespace hailort */
42
43 #endif /* _HAILO_DDR_ACTION_LIST_BUFFER_BUILDER_HPP_ */