Simon Glass | c53fc49 | 2013-02-10 17:00:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
Simon Glass | c53fc49 | 2013-02-10 17:00:38 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef FLASHMAP_LIB_LAYOUT_H__ |
| 18 | #define FLASHMAP_LIB_LAYOUT_H__ |
| 19 | |
| 20 | typedef struct romlayout { |
| 21 | unsigned int start; |
| 22 | unsigned int end; |
| 23 | unsigned int included; |
| 24 | char name[256]; |
| 25 | char file[256]; /* file[0]=='\0' means not specified. */ |
| 26 | } romlayout_t; |
| 27 | |
Simon Glass | 9ad06c1 | 2013-07-03 22:08:17 +0900 | [diff] [blame] | 28 | /** |
| 29 | * Extract regions to current directory |
| 30 | * |
| 31 | * @flash: Information about flash chip to access |
| 32 | * @return 0 if OK, non-zero on error |
| 33 | */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 34 | int extract_regions(struct flashctx *flash); |
Simon Glass | 9ad06c1 | 2013-07-03 22:08:17 +0900 | [diff] [blame] | 35 | |
David Hendricks | a98dfd0 | 2016-09-12 20:45:45 -0700 | [diff] [blame] | 36 | int specified_partition(); |
| 37 | int read_romlayout(char *name); |
| 38 | int find_romentry(char *name); |
David Hendricks | c36685a | 2016-09-12 20:41:05 -0700 | [diff] [blame] | 39 | int fill_romentry(romlayout_t *entry, int n); |
Vadim Bendebury | cc9577d | 2018-05-09 11:52:00 -0700 | [diff] [blame] | 40 | int get_fmap_entries(const char *filename, struct flashctx *flash); |
David Hendricks | a98dfd0 | 2016-09-12 20:45:45 -0700 | [diff] [blame] | 41 | int get_num_include_args(void); |
| 42 | int register_include_arg(char *name); |
| 43 | int process_include_args(void); |
| 44 | int num_include_files(void); |
| 45 | int included_regions_overlap(void); |
David Hendricks | a98dfd0 | 2016-09-12 20:45:45 -0700 | [diff] [blame] | 46 | int handle_partial_read( |
| 47 | struct flashctx *flash, |
| 48 | uint8_t *buf, |
| 49 | int (*read) (struct flashctx *flash, uint8_t *buf, |
| 50 | unsigned int start, unsigned int len), |
| 51 | int write_to_file); |
| 52 | /* RETURN: the number of partitions that have beenpartial read. |
| 53 | * ==0 means no partition is specified. |
| 54 | * < 0 means writing file error. */ |
| 55 | int handle_partial_verify( |
| 56 | struct flashctx *flash, |
| 57 | uint8_t *buf, |
| 58 | int (*verify) (struct flashctx *flash, uint8_t *buf, unsigned int start, |
| 59 | unsigned int len, const char* message)); |
| 60 | /* RETURN: ==0 means all identical. |
| 61 | !=0 means buf and flash are different. */ |
David Hendricks | c36685a | 2016-09-12 20:41:05 -0700 | [diff] [blame] | 62 | |
Vadim Bendebury | 2b4dcef | 2018-05-21 10:47:18 -0700 | [diff] [blame] | 63 | /* |
| 64 | * In case layout is used, return the largest offset of the end of all |
| 65 | * included sections. If layout is not used, return zero. |
| 66 | */ |
| 67 | size_t top_section_offset(void); |
| 68 | |
| 69 | /* |
| 70 | * In case user specified sections to program (using the -i command line |
| 71 | * option), prepare new contents such that only the required sections are |
| 72 | * re-programmed. |
| 73 | * |
| 74 | * If no -i command line option was used - do nothing. |
| 75 | * |
| 76 | * All areas outside of sections included in -i command line options are set |
| 77 | * to the same value as old contents (modulo lowest erase block size). This |
| 78 | * would make sure that those areas remain unchanged. |
| 79 | * |
| 80 | * If flashrom was invoked for writing the chip, fill the sections to be |
| 81 | * written from the user provided image file. |
| 82 | * |
| 83 | * If flashrom was invoked for erasing - leave the sections in question |
| 84 | * untouched, they have been set to flash erase value already. |
| 85 | */ |
Edward O'Callaghan | f93b374 | 2019-02-24 17:24:27 +1100 | [diff] [blame] | 86 | int handle_romentries(const struct flashctx *flash, uint8_t *oldcontents, |
Vadim Bendebury | 2b4dcef | 2018-05-21 10:47:18 -0700 | [diff] [blame] | 87 | uint8_t *newcontents, int erase_mode); |
| 88 | |
Simon Glass | c53fc49 | 2013-02-10 17:00:38 -0800 | [diff] [blame] | 89 | #endif |