1 /* 2 * Copyright 2018 The ChromiumOS Authors 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 #ifndef __EXTRA_USB_UPDATER_DESC_PARSER_H 7 #define __EXTRA_USB_UPDATER_DESC_PARSER_H 8 9 #include <stddef.h> 10 #include <stdint.h> 11 12 struct result_node { 13 uint8_t expected_result[32]; 14 }; 15 16 enum range_type_t { 17 NOT_A_RANGE, 18 AP_RANGE, 19 EC_RANGE, 20 EC_GANG_RANGE, 21 }; 22 23 struct addr_range { 24 enum range_type_t range_type; 25 uint32_t base_addr; 26 uint32_t range_size; 27 size_t variant_count; /* Set to zero for dump ranges. */ 28 struct result_node variants[0]; 29 }; 30 31 /* Board description retrieval API includes the following functions. */ 32 33 /* 34 * In the given hash database file find board by its ID. Return zero on 35 * success, or OS error of error. In particular ENODATA is returned if the 36 * section for the required board ID is not found in the file. 37 */ 38 int parser_find_board(const char *hash_file_name, const char *board_id); 39 40 /* 41 * Find next range for the previousely defined board, parse it into the 42 * addr_range structure and return pointer to the parsed structure to the 43 * caller, set pointer to NULL if no more entries are available or in case of 44 * error. 45 * 46 * Caller of this function is responsible for returning memory allocated for 47 * the entry. 48 * 49 * Return value set to zero on success, or to OS error if one occurs. EIO is 50 * used if an attmept to get next range is made before hash database file was 51 * opened and board entry in it was found. 52 */ 53 int parser_get_next_range(struct addr_range **range); 54 55 /* Close the hash database file. */ 56 void parser_done(void); 57 58 #endif // __EXTRA_USB_UPDATER_DESC_PARSER_H 59