blob: b6556020edac09477e4dbeeadb14e9ab8ffd76fe [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 *
Simon Glassc53fc492013-02-10 17:00:38 -080015 */
16
17#ifndef FLASHMAP_LIB_LAYOUT_H__
18#define FLASHMAP_LIB_LAYOUT_H__
19
20typedef 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 Glass9ad06c12013-07-03 22:08:17 +090028/**
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 Ghoshd75cd672016-06-17 14:21:39 -070034int extract_regions(struct flashctx *flash);
Simon Glass9ad06c12013-07-03 22:08:17 +090035
David Hendricksa98dfd02016-09-12 20:45:45 -070036int specified_partition();
37int read_romlayout(char *name);
38int find_romentry(char *name);
David Hendricksc36685a2016-09-12 20:41:05 -070039int fill_romentry(romlayout_t *entry, int n);
Vadim Bendeburycc9577d2018-05-09 11:52:00 -070040int get_fmap_entries(const char *filename, struct flashctx *flash);
David Hendricksa98dfd02016-09-12 20:45:45 -070041int get_num_include_args(void);
42int register_include_arg(char *name);
43int process_include_args(void);
44int num_include_files(void);
45int included_regions_overlap(void);
David Hendricksa98dfd02016-09-12 20:45:45 -070046int 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. */
55int 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 Hendricksc36685a2016-09-12 20:41:05 -070062
Vadim Bendebury2b4dcef2018-05-21 10:47:18 -070063/*
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 */
67size_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'Callaghanf93b3742019-02-24 17:24:27 +110086int handle_romentries(const struct flashctx *flash, uint8_t *oldcontents,
Vadim Bendebury2b4dcef2018-05-21 10:47:18 -070087 uint8_t *newcontents, int erase_mode);
88
Simon Glassc53fc492013-02-10 17:00:38 -080089#endif