blob: 21f2f667d6a3149dc61db8fab9c3b217db74a35d [file] [log] [blame]
Zane Shelley5a266612019-08-15 16:23:53 -05001/**
2 * @file hei_main.hpp
3 *
4 * These are the primary APIs for Hardware Error Isolation (aka the isolator).
5 * The intended flow is to:
6 *
7 * - Call initialize() for each necessary Chip Data File.
8 *
Zane Shelleyb406de42019-09-09 16:10:38 -05009 * - Call isolate() for all chips that need error isolation.
Zane Shelley5a266612019-08-15 16:23:53 -050010 *
11 * - Once isolation is no longer needed, call uninitialize() to free up
12 * resources used for isolation.
13 *
14 * Note that initialize() allocates many objects used for isolation and keeps
15 * them in memory. Its purpose is to avoid initializing the objects each time
16 * isolation is required. The data provided by the Chip Data Files is static.
17 * So reinitializing would be a waste of time, unless for some reason the Chip
18 * Data Files themselves are updated, which would require reinitialization
19 * anyway. Of course, leaving the object in memory chews up resources. So, some
20 * users may need to weigh performance vs. memory usage.
21 */
22
23#pragma once
24
25#include <hei_includes.hpp>
26#include <hei_isolation_data.hpp>
27#include <isolator/hei_isolator.hpp>
28
29namespace libhei
30{
31
32/**
33 * @brief Initializes all isolation objects based on data from the given Chip
34 * Data File.
35 *
36 * This function only takes one Chip Data File at a time. Therefore, the
37 * user application must call this function for each Chip Data File required
38 * for isolation.
39 *
40 * Storage and management of the Chip Data Files will vary per user application.
41 * Therefore, the user application is responsible for loading the Chip Data
42 * Files into memory as needed, and providing the location and size of the data.
43 *
44 * Once this function returns, the Chip Data File is no longer needed in memory.
45 *
46 * Details of the Chip Data File format can be found in CHIP_DATA.md.
47 *
48 * @param i_buffer A pointer to the buffer containing a single Chip
49 * Data File.
50 *
51 * @param i_bufferSize The size (in bytes) of the target Chip Data File.
52 *
53 * @param i_forceInit It is possible the user application could call this
54 * function for a chip type that has already been
55 * initialized. This is useful if for some reason the Chip
56 * Data File for a specific chip type has been updated. If
57 * this function is called and a chip type has already been
58 * initialized:
59 * - false (default), the function will return
Zane Shelley11b89942019-11-07 11:07:28 -060060 * RC_CHIP_DATA_INITIALIZED and exit.
Zane Shelley5a266612019-08-15 16:23:53 -050061 * - true, the function will delete the previous isolation
62 * objects for this chip type and reinitialize.
63 *
Zane Shelleyca4b2f42019-08-30 15:48:40 -050064 * @return RC_SUCCESS or RC_CHIP_DATA_INVALID or RC_CHIP_DATA_INITIALIZED
Zane Shelley5a266612019-08-15 16:23:53 -050065 */
Zane Shelleyfe27b652019-10-28 11:33:07 -050066inline ReturnCode initialize(void* i_buffer, size_t i_bufferSize,
Zane Shelley83da2452019-10-25 15:45:34 -050067 bool i_forceInit = false)
Zane Shelley5a266612019-08-15 16:23:53 -050068{
Zane Shelley83da2452019-10-25 15:45:34 -050069 return Isolator::getSingleton().initialize(i_buffer, i_bufferSize,
70 i_forceInit);
Zane Shelley5a266612019-08-15 16:23:53 -050071}
72
73/**
74 * @brief Deletes all internal isolation objects that were created by
75 * initialize().
76 */
77inline void uninitialize()
78{
79 Isolator::getSingleton().uninitialize();
80}
81
82/**
Zane Shelleyb406de42019-09-09 16:10:38 -050083 * @brief Isolates all active hardware errors found on the given list of chips.
Zane Shelley5a266612019-08-15 16:23:53 -050084 *
85 * This functions requires initialize() to be called with the Chip Data File
Zane Shelleyb406de42019-09-09 16:10:38 -050086 * corresponding to the given chip types.
Zane Shelley5a266612019-08-15 16:23:53 -050087 *
Zane Shelleyb406de42019-09-09 16:10:38 -050088 * @param i_chipList The list of all chips that need to be analyzed. Generally,
89 * this would include all processor and memory chips in the
90 * system.
91 *
92 * @param o_isoData Initially, all data in the object will be flushed and then
93 * repopulated with a list of all active hardware errors found
94 * on the given list of chips, the contents of any registers
95 * associated with the active errors, and any other data that
96 * can be useful for debug.
Zane Shelley5a266612019-08-15 16:23:53 -050097 *
98 * @return RC_SUCCESS or RC_CHIP_DATA_MISSING
99 */
Zane Shelleyfe27b652019-10-28 11:33:07 -0500100inline ReturnCode isolate(const std::vector<Chip>& i_chipList,
101 IsolationData& o_isoData)
Zane Shelley5a266612019-08-15 16:23:53 -0500102{
Zane Shelley83da2452019-10-25 15:45:34 -0500103 return Isolator::getSingleton().isolate(i_chipList, o_isoData);
Zane Shelley5a266612019-08-15 16:23:53 -0500104}
105
106} // end namespace libhei