diff options
Diffstat (limited to 'libflashrom.c')
-rw-r--r-- | libflashrom.c | 308 |
1 files changed, 0 insertions, 308 deletions
diff --git a/libflashrom.c b/libflashrom.c index 658d8122b..e70c1d1af 100644 --- a/libflashrom.c +++ b/libflashrom.c @@ -14,11 +14,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ -/** - * @mainpage - * - * Have a look at the Modules section for a function reference. - */ #include <errno.h> #include <stdlib.h> @@ -33,20 +28,10 @@ #include "libflashrom.h" #include "writeprotect.h" -/** - * @defgroup flashrom-general General - * @{ - */ /** Pointer to log callback function. */ static flashrom_log_callback *global_log_callback = NULL; -/** - * @brief Initialize libflashrom. - * - * @param perform_selfcheck If not zero, perform a self check. - * @return 0 on success - */ int flashrom_init(const int perform_selfcheck) { if (perform_selfcheck && selfcheck()) @@ -55,10 +40,6 @@ int flashrom_init(const int perform_selfcheck) return 0; } -/** - * @brief Shut down libflashrom. - * @return 0 on success - */ int flashrom_shutdown(void) { return 0; /* TODO: nothing to do? */ @@ -66,17 +47,6 @@ int flashrom_shutdown(void) /* TODO: flashrom_set_loglevel()? do we need it? For now, let the user decide in their callback. */ - -/** - * @brief Set the log callback function. - * - * Set a callback function which will be invoked whenever libflashrom wants - * to output messages. This allows frontends to do whatever they see fit with - * such messages, e.g. write them to syslog, or to file, or print them in a - * GUI window, etc. - * - * @param log_callback Pointer to the new log callback function. - */ void flashrom_set_log_callback(flashrom_log_callback *const log_callback) { global_log_callback = log_callback; @@ -95,28 +65,11 @@ int print(const enum flashrom_log_level level, const char *const fmt, ...) return 0; } -/** @} */ /* end flashrom-general */ - - - -/** - * @defgroup flashrom-query Querying - * @{ - */ - -/** - * @brief Returns flashrom version - * @return flashrom version - */ const char *flashrom_version_info(void) { return flashrom_version; } -/** - * @brief Returns list of supported flash chips - * @return List of supported flash chips, or NULL if an error occurred - */ struct flashrom_flashchip_info *flashrom_supported_flash_chips(void) { unsigned int i = 0; @@ -144,10 +97,6 @@ struct flashrom_flashchip_info *flashrom_supported_flash_chips(void) return supported_flashchips; } -/** - * @brief Returns list of supported mainboards - * @return List of supported mainboards, or NULL if an error occurred - */ struct flashrom_board_info *flashrom_supported_boards(void) { #if CONFIG_INTERNAL == 1 @@ -181,10 +130,6 @@ struct flashrom_board_info *flashrom_supported_boards(void) #endif } -/** - * @brief Returns list of supported chipsets - * @return List of supported chipsets, or NULL if an error occurred - */ struct flashrom_chipset_info *flashrom_supported_chipsets(void) { #if CONFIG_INTERNAL == 1 @@ -220,39 +165,12 @@ struct flashrom_chipset_info *flashrom_supported_chipsets(void) #endif } -/** - * @brief Frees memory allocated by libflashrom API - * @param Pointer to block of memory which should be freed - * @return 0 on success - */ int flashrom_data_free(void *const p) { free(p); return 0; } -/** @} */ /* end flashrom-query */ - - - -/** - * @defgroup flashrom-prog Programmers - * @{ - */ - -/** - * @brief Initialize the specified programmer. - * - * Currently, only one programmer may be initialized at a time. - * - * @param[out] flashprog Points to a pointer of type struct flashrom_programmer - * that will be set if programmer initialization succeeds. - * *flashprog has to be shutdown by the caller with @ref - * flashrom_programmer_shutdown. - * @param[in] prog_name Name of the programmer to initialize. - * @param[in] prog_param Pointer to programmer specific parameters. - * @return 0 on success - */ int flashrom_programmer_init(struct flashrom_programmer **const flashprog, const char *const prog_name, const char *const prog_param) { @@ -270,12 +188,6 @@ int flashrom_programmer_init(struct flashrom_programmer **const flashprog, return programmer_init(programmer_table[prog], prog_param); } -/** - * @brief Shut down the initialized programmer. - * - * @param flashprog The programmer to shut down. - * @return 0 on success - */ int flashrom_programmer_shutdown(struct flashrom_programmer *const flashprog) { return programmer_shutdown(); @@ -283,33 +195,6 @@ int flashrom_programmer_shutdown(struct flashrom_programmer *const flashprog) /* TODO: flashrom_programmer_capabilities()? */ -/** @} */ /* end flashrom-prog */ - - - -/** - * @defgroup flashrom-flash Flash chips - * @{ - */ - -/** - * @brief Probe for a flash chip. - * - * Probes for a flash chip and returns a flash context, that can be used - * later with flash chip and @ref flashrom-ops "image operations", if - * exactly one matching chip is found. - * - * @param[out] flashctx Points to a pointer of type struct flashrom_flashctx - * that will be set if exactly one chip is found. *flashctx - * has to be freed by the caller with @ref flashrom_flash_release. - * @param[in] flashprog The flash programmer used to access the chip. - * @param[in] chip_name Name of a chip to probe for, or NULL to probe for - * all known chips. - * @return 0 on success, - * 3 if multiple chips were found, - * 2 if no chip was found, - * or 1 on any other error. - */ int flashrom_flash_probe(struct flashrom_flashctx **const flashctx, const struct flashrom_programmer *const flashprog, const char *const chip_name) @@ -344,22 +229,11 @@ int flashrom_flash_probe(struct flashrom_flashctx **const flashctx, return ret; } -/** - * @brief Returns the size of the specified flash chip in bytes. - * - * @param flashctx The queried flash context. - * @return Size of flash chip in bytes. - */ size_t flashrom_flash_getsize(const struct flashrom_flashctx *const flashctx) { return flashctx->chip->total_size * 1024; } -/** - * @brief Free a flash context. - * - * @param flashctx Flash context to free. - */ void flashrom_flash_release(struct flashrom_flashctx *const flashctx) { if (!flashctx) @@ -370,13 +244,6 @@ void flashrom_flash_release(struct flashrom_flashctx *const flashctx) free(flashctx); } -/** - * @brief Set a flag in the given flash context. - * - * @param flashctx Flash context to alter. - * @param flag Flag that is to be set / cleared. - * @param value Value to set. - */ void flashrom_flag_set(struct flashrom_flashctx *const flashctx, const enum flashrom_flag flag, const bool value) { @@ -388,13 +255,6 @@ void flashrom_flag_set(struct flashrom_flashctx *const flashctx, } } -/** - * @brief Return the current value of a flag in the given flash context. - * - * @param flashctx Flash context to read from. - * @param flag Flag to be read. - * @return Current value of the flag. - */ bool flashrom_flag_get(const struct flashrom_flashctx *const flashctx, const enum flashrom_flag flag) { switch (flag) { @@ -406,36 +266,6 @@ bool flashrom_flag_get(const struct flashrom_flashctx *const flashctx, const enu } } -/** @} */ /* end flashrom-flash */ - - - -/** - * @defgroup flashrom-layout Layout handling - * @{ - */ - -/** - * @brief Read a layout from the Intel ICH descriptor in the flash. - * - * Optionally verify that the layout matches the one in the given - * descriptor dump. - * - * @param[out] layout Points to a struct flashrom_layout pointer that - * gets set if the descriptor is read and parsed - * successfully. - * @param[in] flashctx Flash context to read the descriptor from flash. - * @param[in] dump The descriptor dump to compare to or NULL. - * @param[in] len The length of the descriptor dump. - * - * @return 0 on success, - * 6 if descriptor parsing isn't implemented for the host, - * 5 if the descriptors don't match, - * 4 if the descriptor dump couldn't be parsed, - * 3 if the descriptor on flash couldn't be parsed, - * 2 if the descriptor on flash couldn't be read, - * 1 on any other error. - */ int flashrom_layout_read_from_ifd(struct flashrom_layout **const layout, struct flashctx *const flashctx, const void *const dump, const size_t len) { @@ -523,20 +353,6 @@ static int flashrom_layout_parse_fmap(struct flashrom_layout **layout, } #endif /* __FLASHROM_LITTLE_ENDIAN__ */ -/** - * @brief Read a layout by searching the flash chip for fmap. - * - * @param[out] layout Points to a struct flashrom_layout pointer that - * gets set if the fmap is read and parsed successfully. - * @param[in] flashctx Flash context - * @param[in] offset Offset to begin searching for fmap. - * @param[in] offset Length of address space to search. - * - * @return 0 on success, - * 3 if fmap parsing isn't implemented for the host, - * 2 if the fmap couldn't be read, - * 1 on any other error. - */ int flashrom_layout_read_fmap_from_rom(struct flashrom_layout **const layout, struct flashctx *const flashctx, size_t offset, size_t len) { @@ -563,20 +379,6 @@ int flashrom_layout_read_fmap_from_rom(struct flashrom_layout **const layout, #endif } -/** - * @brief Read a layout by searching buffer for fmap. - * - * @param[out] layout Points to a struct flashrom_layout pointer that - * gets set if the fmap is read and parsed successfully. - * @param[in] flashctx Flash context - * @param[in] buffer Buffer to search in - * @param[in] size Size of buffer to search - * - * @return 0 on success, - * 3 if fmap parsing isn't implemented for the host, - * 2 if the fmap couldn't be read, - * 1 on any other error. - */ int flashrom_layout_read_fmap_from_buffer(struct flashrom_layout **const layout, struct flashctx *const flashctx, const uint8_t *const buf, size_t size) { @@ -609,109 +411,44 @@ _ret: #endif } -/** - * @brief Set the active layout for a flash context. - * - * Note: This just sets a pointer. The caller must not release the layout - * as long as he uses it through the given flash context. - * - * @param flashctx Flash context whose layout will be set. - * @param layout Layout to bet set. - */ void flashrom_layout_set(struct flashrom_flashctx *const flashctx, const struct flashrom_layout *const layout) { flashctx->layout = layout; } -/** @} */ /* end flashrom-layout */ - - -/** - * @defgroup flashrom-wp - * @{ - */ - -/** - * @brief Create a new empty WP configuration. - * - * @param[out] cfg Points to a pointer of type struct flashrom_wp_cfg that will - * be set if creation succeeds. *cfg has to be freed by the - * caller with @ref flashrom_wp_cfg_release. - * @return 0 on success - * >0 on failure - */ enum flashrom_wp_result flashrom_wp_cfg_new(struct flashrom_wp_cfg **cfg) { *cfg = calloc(1, sizeof(**cfg)); return *cfg ? 0 : FLASHROM_WP_ERR_OTHER; } -/** - * @brief Free a WP configuration. - * - * @param[out] cfg Pointer to the flashrom_wp_cfg to free. - */ void flashrom_wp_cfg_release(struct flashrom_wp_cfg *cfg) { free(cfg); } -/** - * @brief Set the protection mode for a WP configuration. - * - * @param[in] mode The protection mode to set. - * @param[out] cfg Pointer to the flashrom_wp_cfg structure to modify. - */ void flashrom_wp_set_mode(struct flashrom_wp_cfg *cfg, enum flashrom_wp_mode mode) { cfg->mode = mode; } -/** - * @brief Get the protection mode from a WP configuration. - * - * @param[in] cfg The WP configuration to get the protection mode from. - * @return The configuration's protection mode. - */ enum flashrom_wp_mode flashrom_wp_get_mode(const struct flashrom_wp_cfg *cfg) { return cfg->mode; } -/** - * @brief Set the protection range for a WP configuration. - * - * @param[out] cfg Pointer to the flashrom_wp_cfg structure to modify. - * @param[in] start The range's start address. - * @param[in] len The range's length. - */ void flashrom_wp_set_range(struct flashrom_wp_cfg *cfg, size_t start, size_t len) { cfg->range.start = start; cfg->range.len = len; } -/** - * @brief Get the protection range from a WP configuration. - * - * @param[out] start Points to a size_t to write the range start to. - * @param[out] len Points to a size_t to write the range length to. - * @param[in] cfg The WP configuration to get the range from. - */ void flashrom_wp_get_range(size_t *start, size_t *len, const struct flashrom_wp_cfg *cfg) { *start = cfg->range.start; *len = cfg->range.len; } -/** - * @brief Write a WP configuration to a flash chip. - * - * @param[in] flash The flash context used to access the chip. - * @param[in] cfg The WP configuration to write to the chip. - * @return 0 on success - * >0 on failure - */ enum flashrom_wp_result flashrom_wp_write_cfg(struct flashctx *flash, const struct flashrom_wp_cfg *cfg) { if (flash->mst->buses_supported & BUS_SPI) @@ -723,15 +460,6 @@ enum flashrom_wp_result flashrom_wp_write_cfg(struct flashctx *flash, const stru return FLASHROM_WP_ERR_OTHER; } -/** - * @brief Read the current WP configuration from a flash chip. - * - * @param[out] cfg Pointer to a struct flashrom_wp_cfg to store the chip's - * configuration in. - * @param[in] flash The flash context used to access the chip. - * @return 0 on success - * >0 on failure - */ enum flashrom_wp_result flashrom_wp_read_cfg(struct flashrom_wp_cfg *cfg, struct flashctx *flash) { if (flash->mst->buses_supported & BUS_SPI) @@ -743,18 +471,6 @@ enum flashrom_wp_result flashrom_wp_read_cfg(struct flashrom_wp_cfg *cfg, struct return FLASHROM_WP_ERR_OTHER; } -/** - * @brief Get a list of protection ranges supported by the flash chip. - * - * @param[out] ranges Points to a pointer of type struct flashrom_wp_ranges - * that will be set if available ranges are found. Finding - * available ranges may not always be possible, even if the - * chip's protection range can be read or modified. *ranges - * must be freed using @ref flashrom_wp_ranges_free. - * @param[in] flash The flash context used to access the chip. - * @return 0 on success - * >0 on failure - */ enum flashrom_wp_result flashrom_wp_get_available_ranges(struct flashrom_wp_ranges **list, struct flashrom_flashctx *flash) { if (flash->mst->buses_supported & BUS_SPI) @@ -766,27 +482,11 @@ enum flashrom_wp_result flashrom_wp_get_available_ranges(struct flashrom_wp_rang return FLASHROM_WP_ERR_OTHER; } -/** - * @brief Get a number of protection ranges in a range list. - * - * @param[in] ranges The range list to get the count from. - * @return Number of ranges in the list. - */ size_t flashrom_wp_ranges_get_count(const struct flashrom_wp_ranges *list) { return list->count; } -/** - * @brief Get a protection range from a range list. - * - * @param[out] start Points to a size_t to write the range's start to. - * @param[out] len Points to a size_t to write the range's length to. - * @param[in] ranges The range list to get the range from. - * @param[in] index Index of the range to get. - * @return 0 on success - * >0 on failure - */ enum flashrom_wp_result flashrom_wp_ranges_get_range(size_t *start, size_t *len, const struct flashrom_wp_ranges *list, unsigned int index) { if (index >= list->count) @@ -798,11 +498,6 @@ enum flashrom_wp_result flashrom_wp_ranges_get_range(size_t *start, size_t *len, return 0; } -/** - * @brief Free a WP range list. - * - * @param[out] cfg Pointer to the flashrom_wp_ranges to free. - */ void flashrom_wp_ranges_release(struct flashrom_wp_ranges *list) { if (!list) @@ -811,6 +506,3 @@ void flashrom_wp_ranges_release(struct flashrom_wp_ranges *list) free(list->ranges); free(list); } - - -/** @} */ /* end flashrom-wp */ |