blob: 072d41faffd48cd567030ad6c7727d7271da2303 [file] [log] [blame]
Simon Glassc53fc492013-02-10 17:00:38 -08001/*
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 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef FLASHMAP_LIB_LAYOUT_H__
21#define FLASHMAP_LIB_LAYOUT_H__
22
23typedef struct romlayout {
24 unsigned int start;
25 unsigned int end;
26 unsigned int included;
27 char name[256];
28 char file[256]; /* file[0]=='\0' means not specified. */
29} romlayout_t;
30
Simon Glass9ad06c12013-07-03 22:08:17 +090031/**
32 * Extract regions to current directory
33 *
34 * @flash: Information about flash chip to access
35 * @return 0 if OK, non-zero on error
36 */
Souvik Ghoshd75cd672016-06-17 14:21:39 -070037int extract_regions(struct flashctx *flash);
Simon Glass9ad06c12013-07-03 22:08:17 +090038
David Hendricksa98dfd02016-09-12 20:45:45 -070039int specified_partition();
40int read_romlayout(char *name);
41int find_romentry(char *name);
David Hendricksc36685a2016-09-12 20:41:05 -070042int fill_romentry(romlayout_t *entry, int n);
Vadim Bendeburycc9577d2018-05-09 11:52:00 -070043int get_fmap_entries(const char *filename, struct flashctx *flash);
David Hendricksa98dfd02016-09-12 20:45:45 -070044int get_num_include_args(void);
45int register_include_arg(char *name);
46int process_include_args(void);
47int num_include_files(void);
48int included_regions_overlap(void);
David Hendricksa98dfd02016-09-12 20:45:45 -070049int handle_partial_read(
50 struct flashctx *flash,
51 uint8_t *buf,
52 int (*read) (struct flashctx *flash, uint8_t *buf,
53 unsigned int start, unsigned int len),
54 int write_to_file);
55 /* RETURN: the number of partitions that have beenpartial read.
56 * ==0 means no partition is specified.
57 * < 0 means writing file error. */
58int handle_partial_verify(
59 struct flashctx *flash,
60 uint8_t *buf,
61 int (*verify) (struct flashctx *flash, uint8_t *buf, unsigned int start,
62 unsigned int len, const char* message));
63 /* RETURN: ==0 means all identical.
64 !=0 means buf and flash are different. */
David Hendricksc36685a2016-09-12 20:41:05 -070065
Vadim Bendebury2b4dcef2018-05-21 10:47:18 -070066/*
67 * In case layout is used, return the largest offset of the end of all
68 * included sections. If layout is not used, return zero.
69 */
70size_t top_section_offset(void);
71
72/*
73 * In case user specified sections to program (using the -i command line
74 * option), prepare new contents such that only the required sections are
75 * re-programmed.
76 *
77 * If no -i command line option was used - do nothing.
78 *
79 * All areas outside of sections included in -i command line options are set
80 * to the same value as old contents (modulo lowest erase block size). This
81 * would make sure that those areas remain unchanged.
82 *
83 * If flashrom was invoked for writing the chip, fill the sections to be
84 * written from the user provided image file.
85 *
86 * If flashrom was invoked for erasing - leave the sections in question
87 * untouched, they have been set to flash erase value already.
88 */
89int handle_romentries(struct flashctx *flash, uint8_t *oldcontents,
90 uint8_t *newcontents, int erase_mode);
91
Simon Glassc53fc492013-02-10 17:00:38 -080092#endif