Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 1 | /** |
| 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 Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 9 | * - Call isolate() for all chips that need error isolation. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 10 | * |
| 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. |
Zane Shelley | dd109cc | 2020-04-30 21:41:41 -0500 | [diff] [blame] | 21 | * |
| 22 | * If data for a specific chip type changes and needs to be reinitialized, the |
| 23 | * user application must reinitialize all chip data as follows: |
| 24 | * |
| 25 | * - Call uninitialize() to flush isolation objects for ALL chip types. |
| 26 | * |
| 27 | * - Call initialize() for ALL necessary Chip Data Files. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #pragma once |
| 31 | |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 32 | #include <hei_chip.hpp> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 33 | #include <hei_isolation_data.hpp> |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 34 | |
| 35 | #include <vector> |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 36 | |
| 37 | namespace libhei |
| 38 | { |
| 39 | |
| 40 | /** |
| 41 | * @brief Initializes all isolation objects based on data from the given Chip |
| 42 | * Data File. |
| 43 | * |
| 44 | * This function only takes one Chip Data File at a time. Therefore, the |
| 45 | * user application must call this function for each Chip Data File required |
| 46 | * for isolation. |
| 47 | * |
| 48 | * Storage and management of the Chip Data Files will vary per user application. |
| 49 | * Therefore, the user application is responsible for loading the Chip Data |
| 50 | * Files into memory as needed, and providing the location and size of the data. |
| 51 | * |
| 52 | * Once this function returns, the Chip Data File is no longer needed in memory. |
| 53 | * |
| 54 | * Details of the Chip Data File format can be found in CHIP_DATA.md. |
| 55 | * |
Zane Shelley | dd109cc | 2020-04-30 21:41:41 -0500 | [diff] [blame] | 56 | * IMPORTANT: |
| 57 | * This function will build and store objects as it is parsing the Chip Data |
| 58 | * Files. It will assert: |
| 59 | * - Each file is the proper format and contains valid data. |
| 60 | * - No two files can share the same chip model/level. |
| 61 | * This ensures that the isolator does not use a partial (possibly invalid) or |
| 62 | * duplicate set of objects. |
| 63 | * |
| 64 | * @param i_buffer A pointer to the buffer containing a single Chip Data File. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 65 | * |
| 66 | * @param i_bufferSize The size (in bytes) of the target Chip Data File. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 67 | */ |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 68 | void initialize(void* i_buffer, size_t i_bufferSize); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * @brief Deletes all internal isolation objects that were created by |
| 72 | * initialize(). |
| 73 | */ |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 74 | void uninitialize(); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 75 | |
| 76 | /** |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 77 | * @brief Isolates all active hardware errors found on the given list of chips. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 78 | * |
Zane Shelley | 229c155 | 2020-05-04 22:44:15 -0500 | [diff] [blame] | 79 | * This functions will assert that initialize() has been called for each Chip |
| 80 | * Data File corresponding to the given chip types. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 81 | * |
Zane Shelley | b406de4 | 2019-09-09 16:10:38 -0500 | [diff] [blame] | 82 | * @param i_chipList The list of all chips that need to be analyzed. Generally, |
| 83 | * this would include all processor and memory chips in the |
| 84 | * system. |
| 85 | * |
| 86 | * @param o_isoData Initially, all data in the object will be flushed and then |
| 87 | * repopulated with a list of all active hardware errors found |
| 88 | * on the given list of chips, the contents of any registers |
| 89 | * associated with the active errors, and any other data that |
| 90 | * can be useful for debug. |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 91 | */ |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 92 | void isolate(const std::vector<Chip>& i_chipList, IsolationData& o_isoData); |
Zane Shelley | 5a26661 | 2019-08-15 16:23:53 -0500 | [diff] [blame] | 93 | |
| 94 | } // end namespace libhei |