mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
libflashrom: Add probing v2 which can find all matching chips
Probing v2 can (if requested) go through all flashchips and find all the matching chip definitions. This is the way cli behaves, so cli becomes a client of probing v2. Previously cli and libflashrom had different probing logic, and different code in different source files. This patch also adds tests for probing v2. Testing from the cli: ./flashrom -p dummy:emulate=W25Q128FV -r dump.rom ./flashrom -p dummy:emulate=MX25L6436 -r dump.rom ./flashrom -p dummy:emulate=MX25L6436 -c "MX25L6473E" -r dump.rom ./flashrom -p dummy:emulate=SST25VF032B -E ./flashrom -p dummy:emulate=S25FL128L -r dump.rom ./flashrom -p dummy:emulate=INVALID -r dump.rom ./flashrom -p dummy:emulate=MX25L6436 -c "NONEXISTENT" -r dump.rom Change-Id: Idfcf377a8071e22028ba98515f08495ed2a6e9f0 Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/87341 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
This commit is contained in:
@ -279,6 +279,45 @@ int flashrom_programmer_shutdown(struct flashrom_programmer *flashprog);
|
||||
* or 1 on any other error.
|
||||
*/
|
||||
int flashrom_flash_probe(struct flashrom_flashctx **flashctx, const struct flashrom_programmer *flashprog, const char *chip_name);
|
||||
|
||||
/**
|
||||
* @brief Probe for a flash chip, v2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Returns the list of names for all chips that matched, and the count of
|
||||
* how many chips matched.
|
||||
*
|
||||
* Memory for the list of chips is dynamically allocated according to the
|
||||
* number of chips found, and always needs to be freed with flashrom_data_free
|
||||
* afterwards (including when no matches found or error happened).
|
||||
*
|
||||
* Note that if chip_name param is set, then probing happens only once, only
|
||||
* for this one requested chip name. So the number of matches that can be
|
||||
* returned in this case will be either 1 or 0 (and -1 for error).
|
||||
*
|
||||
* @param[out] flashctx Points to a 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[out] all_matched_names pointer to an array containing the names of all chips
|
||||
* that were successfully probed, terminated with a NULL pointer.
|
||||
* If no chips are found, the returned array contains
|
||||
* a single NULL element. Callers must free the array once unused
|
||||
* by calling `flashrom_data_free`.
|
||||
* @param[in] flashprog The flash programmer used to access the chip,
|
||||
* currently unused.
|
||||
* @param[in] chip_name Name of a chip to probe for, or NULL to probe for
|
||||
* all known chips.
|
||||
* @return the number of matched chips (which can be 0) on success,
|
||||
* -1 if error happened during probing.
|
||||
*/
|
||||
int flashrom_flash_probe_v2(struct flashrom_flashctx *flashctx,
|
||||
const char *** const all_matched_names,
|
||||
const struct flashrom_programmer *flashprog,
|
||||
const char *chip_name);
|
||||
|
||||
/**
|
||||
* @brief Returns the size of the specified flash chip in bytes.
|
||||
*
|
||||
|
Reference in New Issue
Block a user