Vadim Bendebury | 5f6a97d | 2018-05-15 10:38:14 -0700 | [diff] [blame] | 1 | /* 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'Callaghan | d13334a | 2020-07-23 12:51:00 +1000 | [diff] [blame] | 10 | #include <stdbool.h> |
Vadim Bendebury | 5f6a97d | 2018-05-15 10:38:14 -0700 | [diff] [blame] | 11 | |
| 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 | */ |
| 19 | struct 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'Callaghan | 8bc8b09 | 2020-12-04 15:31:56 +1100 | [diff] [blame] | 34 | struct flashrom_flashctx; |
| 35 | #define flashctx flashrom_flashctx /* TODO: Agree on a name and convert all occurences. */ |
Vadim Bendebury | 5f6a97d | 2018-05-15 10:38:14 -0700 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * Function to create an action descriptor based on the 'before' and 'after' |
| 39 | * flash contents. |
| 40 | */ |
| 41 | struct action_descriptor *prepare_action_descriptor(struct flashctx *flash, |
| 42 | void *oldcontents, |
Vadim Bendebury | 2f346a3 | 2018-05-21 10:24:18 -0700 | [diff] [blame] | 43 | void *newcontents, |
| 44 | int do_diff); |
Vadim Bendebury | 5f6a97d | 2018-05-15 10:38:14 -0700 | [diff] [blame] | 45 | |
| 46 | /* |
Edward O'Callaghan | d13334a | 2020-07-23 12:51:00 +1000 | [diff] [blame] | 47 | * 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 Artemiev | b795729 | 2021-02-12 11:40:58 +1100 | [diff] [blame] | 55 | bool is_dry_run(void); |
Edward O'Callaghan | d13334a | 2020-07-23 12:51:00 +1000 | [diff] [blame] | 56 | |
| 57 | /* |
Vadim Bendebury | 5f6a97d | 2018-05-15 10:38:14 -0700 | [diff] [blame] | 58 | * A function to test action descriptor implementation, returns number of |
| 59 | * failures. |
| 60 | */ |
| 61 | int test_action_descriptor(void); |
| 62 | |
| 63 | #endif /* ! __FLASHROM_ACTION_DESCRIPTOR_H */ |