blob: 0abbde477fb93fe17b6f0ebf92939730518038fe [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. */
Edward O'Callaghan8bc8b092020-12-04 15:31:56 +110034struct flashrom_flashctx;
35#define flashctx flashrom_flashctx /* TODO: Agree on a name and convert all occurences. */
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -070036
37/*
38 * Function to create an action descriptor based on the 'before' and 'after'
39 * flash contents.
40 */
41struct action_descriptor *prepare_action_descriptor(struct flashctx *flash,
42 void *oldcontents,
Vadim Bendebury2f346a32018-05-21 10:24:18 -070043 void *newcontents,
44 int do_diff);
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -070045
46/*
Edward O'Callaghand13334a2020-07-23 12:51:00 +100047 * Returns if the op should be consider a dry-run and return early or not.
48 *
49 * This function is set to indicate that the invoked flash programming
50 * command should not be executed, but just verified for validity.
51 *
52 * This is useful when one needs to determine if a certain flash erase command
53 * supported by the chip is allowed by the Intel controller on the device.
54 */
Nikolai Artemievb7957292021-02-12 11:40:58 +110055bool is_dry_run(void);
Edward O'Callaghand13334a2020-07-23 12:51:00 +100056
57/*
Vadim Bendebury5f6a97d2018-05-15 10:38:14 -070058 * A function to test action descriptor implementation, returns number of
59 * failures.
60 */
61int test_action_descriptor(void);
62
63#endif /* ! __FLASHROM_ACTION_DESCRIPTOR_H */