blob: e9835746ae145fd37ced84bcc2fa5e56b6153236 [file] [log] [blame]
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -07001/* Copyright 2018 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5#ifndef __FLASHROM_ACTION_DESCRIPTOR_H
6#define __FLASHROM_ACTION_DESCRIPTOR_H
7
8#include <stddef.h>
9#include <stdint.h>
Edward O'Callaghand13334a2020-07-23 12:51:00 +100010#include <stdbool.h>
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -070011
12/*
13 * Structure containing information about the processing flashrom is supposed
14 * to perform on the current run.
15 *
16 * The variable size 'processing_units' array contains description of
17 * processing to the flash block granularity.
18 */
19struct action_descriptor {
20 void *oldcontents;
21 void *newcontents;
22 struct processing_unit {
23 size_t block_size; /* Block size granularity of this unit. */
24 size_t offset; /* Offset of the first block. */
25 size_t num_blocks; /* Number of consecutive blocks. Value of
26 * zero indicates the last entry in the
27 * processing_units array. */
28 int block_eraser_index; /* Index into 'block_erasers'. */
29 int block_region_index; /* Index into 'eraseblocks'. */
30 } processing_units[0];
31};
32
33/* Forward reference for the flash descriptor structure defined in flash.h. */
34struct flashctx;
35
36/*
37 * Function to create an action descriptor based on the 'before' and 'after'
38 * flash contents.
39 */
40struct action_descriptor *prepare_action_descriptor(struct flashctx *flash,
41 void *oldcontents,
Vadim Bendebury2f346a32018-05-21 10:24:18 -070042 void *newcontents,
43 int do_diff);
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -070044
45/*
Edward O'Callaghand13334a2020-07-23 12:51:00 +100046 * Returns if the op should be consider a dry-run and return early or not.
47 *
48 * This function is set to indicate that the invoked flash programming
49 * command should not be executed, but just verified for validity.
50 *
51 * This is useful when one needs to determine if a certain flash erase command
52 * supported by the chip is allowed by the Intel controller on the device.
53 */
54bool is_dry_run();
55
56/*
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -070057 * A function to test action descriptor implementation, returns number of
58 * failures.
59 */
60int test_action_descriptor(void);
61
62#endif /* ! __FLASHROM_ACTION_DESCRIPTOR_H */