blob: f10589d6089d9cdd6004a11eb284e11765876729 [file] [log] [blame]
Zane Shelleydd69c962020-05-05 22:19:11 -05001#include <chip_data/hei_chip_data.hpp>
2#include <chip_data/hei_chip_data_stream.hpp>
3
4namespace libhei
5{
6
7//------------------------------------------------------------------------------
8
9using FileKeyword_t = uint64_t;
10
11constexpr FileKeyword_t KW_CHIPDATA = 0x4348495044415441; // "CHIPDATA" ASCII
12
13using SectionKeyword_t = uint32_t;
14
15constexpr SectionKeyword_t KW_REGS = 0x43484950; // "REGS" ASCII
16constexpr SectionKeyword_t KW_NODE = 0x4e4f4445; // "NODE" ASCII
17constexpr SectionKeyword_t KW_ROOT = 0x524f4f54; // "ROOT" ASCII
18
19using Version_t = uint8_t;
20
21constexpr Version_t VERSION_1 = 0x01;
22
23//------------------------------------------------------------------------------
24
25void parseChipDataFile(void* i_buffer, size_t i_bufferSize,
26 IsolationChipMap& io_isoChips)
27{
28 ChipDataStream stream{i_buffer, i_bufferSize};
29
30 // Read the file metadata.
31 FileKeyword_t file_kw = 0;
32 ChipType_t chipType = 0;
33 Version_t version = 0;
34 stream >> file_kw >> chipType >> version;
35
36 // Check the file ID.
37 HEI_ASSERT(KW_CHIPDATA == file_kw);
38
39 // This chip type should not already exist.
40 HEI_ASSERT(io_isoChips.end() == io_isoChips.find(chipType));
41
42 // Allocate memory for the new isolation chip.
43 auto isoChip = std::make_unique<IsolationChip>(chipType);
44
45 // TODO
46
47 // Add this isolation chip to the collective list of isolation chips.
48 auto ret = io_isoChips.emplace(chipType, std::move(isoChip));
49 HEI_ASSERT(ret.second); // Just in case.
50}
51
52//------------------------------------------------------------------------------
53
54} // namespace libhei