Structure.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // std
4 #include <map>
5 #include <stdexcept>
6 
7 // project
8 #include "Section.hpp"
9 #include "Type.hpp"
10 
11 namespace dai
12 {
13 namespace bootloader
14 {
15 
16 // Memory section structure
17 struct Structure {
18  Structure() = default;
19  std::map<Section, long> offset, size;
20 protected:
21  Structure(decltype(offset) a, decltype(size) b) : offset(a), size(b) {}
22 };
23 
24 // Structure
26 
27  constexpr static long HEADER_OFFSET = 0;
28  constexpr static long HEADER_SIZE = 512;
29  constexpr static long CONFIG_SIZE = 16 * 1024;
30  constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE;
31  constexpr static long BOOTLOADER_SIZE = 4 * 1024 * 1024 - HEADER_SIZE;
33  constexpr static long USER_BOOTLOADER_SIZE = 8 * 1024 * 1024 - BOOTLOADER_SIZE - CONFIG_SIZE - HEADER_SIZE;
35  constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE;
36 
43  }, {
49  }) {}
50 
51 };
52 
53 // Structure
55 
56  constexpr static long HEADER_OFFSET = 0;
57  constexpr static long HEADER_SIZE = 512;
58  constexpr static long CONFIG_SIZE = 16 * 1024;
59  constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE;
60  constexpr static long BOOTLOADER_SIZE = 1 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE;
61  constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE;
62  constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE;
63 
69  }, {
74  }) {}
75 
76 };
77 
79  switch(type){
80  case Type::AUTO: throw std::invalid_argument("Invalid argument to getStructure function");
81  case Type::USB: return UsbBootloaderStructure();
83  }
84  // Default
85  return UsbBootloaderStructure();
86 }
87 
88 } // namespace bootloader
89 } // namespace dai
90 
dai::bootloader::NetworkBootloaderStructure::BOOTLOADER_OFFSET
constexpr static long BOOTLOADER_OFFSET
Definition: Structure.hpp:30
dai::bootloader::NetworkBootloaderStructure::CONFIG_SIZE
constexpr static long CONFIG_SIZE
Definition: Structure.hpp:29
dai::bootloader::NetworkBootloaderStructure::NetworkBootloaderStructure
NetworkBootloaderStructure()
Definition: Structure.hpp:37
dai::bootloader::UsbBootloaderStructure::BOOTLOADER_OFFSET
constexpr static long BOOTLOADER_OFFSET
Definition: Structure.hpp:59
dai::bootloader::Section::BOOTLOADER
@ BOOTLOADER
dai::bootloader::NetworkBootloaderStructure::HEADER_SIZE
constexpr static long HEADER_SIZE
Definition: Structure.hpp:28
dai::bootloader::Structure::Structure
Structure(decltype(offset) a, decltype(size) b)
Definition: Structure.hpp:21
dai::bootloader::NetworkBootloaderStructure::HEADER_OFFSET
constexpr static long HEADER_OFFSET
Definition: Structure.hpp:27
dai::bootloader::getStructure
const Structure getStructure(Type type)
Definition: Structure.hpp:78
Section.hpp
dai::bootloader::Structure::offset
std::map< Section, long > offset
Definition: Structure.hpp:19
Type.hpp
dai::bootloader::Structure::size
std::map< Section, long > size
Definition: Structure.hpp:19
dai::bootloader::Section::HEADER
@ HEADER
dai::bootloader::UsbBootloaderStructure::HEADER_OFFSET
constexpr static long HEADER_OFFSET
Definition: Structure.hpp:56
dai::bootloader::Structure
Definition: Structure.hpp:17
dai::bootloader::Type
Type
Definition: Type.hpp:11
dai::bootloader::Section::BOOTLOADER_CONFIG
@ BOOTLOADER_CONFIG
dai::bootloader::NetworkBootloaderStructure::USER_BOOTLOADER_SIZE
constexpr static long USER_BOOTLOADER_SIZE
Definition: Structure.hpp:33
dai::bootloader::UsbBootloaderStructure::BOOTLOADER_SIZE
constexpr static long BOOTLOADER_SIZE
Definition: Structure.hpp:60
dai::bootloader::Section::USER_BOOTLOADER
@ USER_BOOTLOADER
dai::bootloader::NetworkBootloaderStructure::USER_BOOTLOADER_OFFSET
constexpr static long USER_BOOTLOADER_OFFSET
Definition: Structure.hpp:32
dai::bootloader::NetworkBootloaderStructure
Definition: Structure.hpp:25
dai::bootloader::Type::NETWORK
@ NETWORK
dai::bootloader::Type::AUTO
@ AUTO
dai::bootloader::NetworkBootloaderStructure::APPLICATION_OFFSET
constexpr static long APPLICATION_OFFSET
Definition: Structure.hpp:35
dai::bootloader::Type::USB
@ USB
dai::bootloader::UsbBootloaderStructure::CONFIG_SIZE
constexpr static long CONFIG_SIZE
Definition: Structure.hpp:58
nanorpc::core::detail::pack::meta::type
type
Definition: pack_meta.h:26
dai::bootloader::UsbBootloaderStructure
Definition: Structure.hpp:54
dai::bootloader::UsbBootloaderStructure::CONFIG_OFFSET
constexpr static long CONFIG_OFFSET
Definition: Structure.hpp:61
dai::bootloader::Structure::Structure
Structure()=default
dai::bootloader::NetworkBootloaderStructure::CONFIG_OFFSET
constexpr static long CONFIG_OFFSET
Definition: Structure.hpp:34
dai::bootloader::NetworkBootloaderStructure::BOOTLOADER_SIZE
constexpr static long BOOTLOADER_SIZE
Definition: Structure.hpp:31
dai::bootloader::UsbBootloaderStructure::APPLICATION_OFFSET
constexpr static long APPLICATION_OFFSET
Definition: Structure.hpp:62
dai::bootloader::Section::APPLICATION
@ APPLICATION
dai::bootloader::UsbBootloaderStructure::UsbBootloaderStructure
UsbBootloaderStructure()
Definition: Structure.hpp:64
dai
Definition: CameraExposureOffset.hpp:6
dai::bootloader::UsbBootloaderStructure::HEADER_SIZE
constexpr static long HEADER_SIZE
Definition: Structure.hpp:57


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19