Uwe Hermann | 75f5107 | 2008-03-04 16:29:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2005-2008 coresystems GmbH |
| 5 | * (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH) |
Stefan Tauner | 949ccc8 | 2013-09-15 14:01:06 +0000 | [diff] [blame] | 6 | * Copyright (C) 2011-2013 Stefan Tauner |
Uwe Hermann | 75f5107 | 2008-03-04 16:29:54 +0000 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
Carl-Daniel Hailfinger | 831e8f4 | 2010-05-30 22:24:40 +0000 | [diff] [blame] | 22 | #include <stdio.h> |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 25 | #include <limits.h> |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 26 | #include "flash.h" |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 27 | #include "programmer.h" |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 28 | |
David Hendricks | 444cefc | 2010-10-29 20:17:41 +0000 | [diff] [blame] | 29 | #define MAX_ROMLAYOUT 32 |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 30 | |
| 31 | typedef struct { |
Stefan Tauner | 8268fdb | 2013-09-23 14:21:06 +0000 | [diff] [blame] | 32 | chipoff_t start; |
| 33 | chipoff_t end; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 34 | unsigned int included; |
| 35 | char name[256]; |
Stefan Tauner | 97b6c11 | 2013-08-30 22:23:02 +0000 | [diff] [blame] | 36 | } romentry_t; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 37 | |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 38 | /* rom_entries store the entries specified in a layout file and associated run-time data */ |
Stefan Tauner | 97b6c11 | 2013-08-30 22:23:02 +0000 | [diff] [blame] | 39 | static romentry_t rom_entries[MAX_ROMLAYOUT]; |
Stefan Tauner | 8268fdb | 2013-09-23 14:21:06 +0000 | [diff] [blame] | 40 | static int num_rom_entries = 0; /* the number of successfully parsed rom_entries */ |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 41 | |
| 42 | /* include_args holds the arguments specified at the command line with -i. They must be processed at some point |
| 43 | * so that desired regions are marked as "included" in the rom_entries list. */ |
| 44 | static char *include_args[MAX_ROMLAYOUT]; |
| 45 | static int num_include_args = 0; /* the number of valid include_args. */ |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 46 | |
Patrick Georgi | a9095a9 | 2010-09-30 17:03:32 +0000 | [diff] [blame] | 47 | #ifndef __LIBPAYLOAD__ |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 48 | int read_romlayout(char *name) |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 49 | { |
| 50 | FILE *romlayout; |
| 51 | char tempstr[256]; |
| 52 | int i; |
| 53 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 54 | romlayout = fopen(name, "r"); |
| 55 | |
| 56 | if (!romlayout) { |
Carl-Daniel Hailfinger | 831e8f4 | 2010-05-30 22:24:40 +0000 | [diff] [blame] | 57 | msg_gerr("ERROR: Could not open ROM layout (%s).\n", |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 58 | name); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 59 | return -1; |
| 60 | } |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 61 | |
| 62 | while (!feof(romlayout)) { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 63 | char *tstr1, *tstr2; |
Carl-Daniel Hailfinger | da53ada | 2010-12-04 11:56:52 +0000 | [diff] [blame] | 64 | |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 65 | if (num_rom_entries >= MAX_ROMLAYOUT) { |
Carl-Daniel Hailfinger | da53ada | 2010-12-04 11:56:52 +0000 | [diff] [blame] | 66 | msg_gerr("Maximum number of ROM images (%i) in layout " |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 67 | "file reached.\n", MAX_ROMLAYOUT); |
Stefan Reinauer | 4c00d09 | 2014-04-26 16:11:39 +0000 | [diff] [blame] | 68 | fclose(romlayout); |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 69 | return 1; |
Carl-Daniel Hailfinger | da53ada | 2010-12-04 11:56:52 +0000 | [diff] [blame] | 70 | } |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 71 | if (2 != fscanf(romlayout, "%s %s\n", tempstr, rom_entries[num_rom_entries].name)) |
Peter Stuge | 1fec0f3 | 2009-01-12 21:00:35 +0000 | [diff] [blame] | 72 | continue; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 73 | #if 0 |
| 74 | // fscanf does not like arbitrary comments like that :( later |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 75 | if (tempstr[0] == '#') { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 76 | continue; |
| 77 | } |
| 78 | #endif |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 79 | tstr1 = strtok(tempstr, ":"); |
| 80 | tstr2 = strtok(NULL, ":"); |
Uwe Hermann | 58783e3 | 2008-12-22 16:42:59 +0000 | [diff] [blame] | 81 | if (!tstr1 || !tstr2) { |
Stefan Tauner | eb58257 | 2012-09-21 12:52:50 +0000 | [diff] [blame] | 82 | msg_gerr("Error parsing layout file. Offending string: \"%s\"\n", tempstr); |
Uwe Hermann | 58783e3 | 2008-12-22 16:42:59 +0000 | [diff] [blame] | 83 | fclose(romlayout); |
| 84 | return 1; |
| 85 | } |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 86 | rom_entries[num_rom_entries].start = strtol(tstr1, (char **)NULL, 16); |
| 87 | rom_entries[num_rom_entries].end = strtol(tstr2, (char **)NULL, 16); |
| 88 | rom_entries[num_rom_entries].included = 0; |
| 89 | num_rom_entries++; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 90 | } |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 91 | |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 92 | for (i = 0; i < num_rom_entries; i++) { |
Carl-Daniel Hailfinger | 831e8f4 | 2010-05-30 22:24:40 +0000 | [diff] [blame] | 93 | msg_gdbg("romlayout %08x - %08x named %s\n", |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 94 | rom_entries[i].start, |
| 95 | rom_entries[i].end, rom_entries[i].name); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | fclose(romlayout); |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 99 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 100 | return 0; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 101 | } |
Patrick Georgi | a9095a9 | 2010-09-30 17:03:32 +0000 | [diff] [blame] | 102 | #endif |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 103 | |
Stefan Tauner | 23bb6d5 | 2012-04-15 14:09:16 +0000 | [diff] [blame] | 104 | /* returns the index of the entry (or a negative value if it is not found) */ |
| 105 | int find_include_arg(const char *const name) |
| 106 | { |
| 107 | unsigned int i; |
| 108 | for (i = 0; i < num_include_args; i++) { |
| 109 | if (!strcmp(include_args[i], name)) |
| 110 | return i; |
| 111 | } |
| 112 | return -1; |
| 113 | } |
| 114 | |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 115 | /* register an include argument (-i) for later processing */ |
| 116 | int register_include_arg(char *name) |
| 117 | { |
| 118 | if (num_include_args >= MAX_ROMLAYOUT) { |
| 119 | msg_gerr("Too many regions included (%i).\n", num_include_args); |
| 120 | return 1; |
| 121 | } |
| 122 | |
| 123 | if (name == NULL) { |
| 124 | msg_gerr("<NULL> is a bad region name.\n"); |
| 125 | return 1; |
| 126 | } |
| 127 | |
Stefan Tauner | 23bb6d5 | 2012-04-15 14:09:16 +0000 | [diff] [blame] | 128 | if (find_include_arg(name) != -1) { |
| 129 | msg_gerr("Duplicate region name: \"%s\".\n", name); |
| 130 | return 1; |
| 131 | } |
| 132 | |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 133 | include_args[num_include_args] = name; |
| 134 | num_include_args++; |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | /* returns the index of the entry (or a negative value if it is not found) */ |
| 139 | static int find_romentry(char *name) |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 140 | { |
| 141 | int i; |
| 142 | |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 143 | if (num_rom_entries == 0) |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 144 | return -1; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 145 | |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 146 | msg_gspew("Looking for region \"%s\"... ", name); |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 147 | for (i = 0; i < num_rom_entries; i++) { |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 148 | if (!strcmp(rom_entries[i].name, name)) { |
| 149 | rom_entries[i].included = 1; |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 150 | msg_gspew("found.\n"); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 151 | return i; |
| 152 | } |
| 153 | } |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 154 | msg_gspew("not found.\n"); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 155 | return -1; |
| 156 | } |
| 157 | |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 158 | /* process -i arguments |
| 159 | * returns 0 to indicate success, >0 to indicate failure |
| 160 | */ |
| 161 | int process_include_args(void) |
| 162 | { |
| 163 | int i; |
| 164 | unsigned int found = 0; |
| 165 | |
| 166 | if (num_include_args == 0) |
| 167 | return 0; |
| 168 | |
Stefan Tauner | 23bb6d5 | 2012-04-15 14:09:16 +0000 | [diff] [blame] | 169 | /* User has specified an area, but no layout file is loaded. */ |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 170 | if (num_rom_entries == 0) { |
Stefan Tauner | 23bb6d5 | 2012-04-15 14:09:16 +0000 | [diff] [blame] | 171 | msg_gerr("Region requested (with -i \"%s\"), " |
| 172 | "but no layout data is available.\n", |
| 173 | include_args[0]); |
| 174 | return 1; |
| 175 | } |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 176 | |
Stefan Tauner | 23bb6d5 | 2012-04-15 14:09:16 +0000 | [diff] [blame] | 177 | for (i = 0; i < num_include_args; i++) { |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 178 | if (find_romentry(include_args[i]) < 0) { |
Stefan Tauner | 23bb6d5 | 2012-04-15 14:09:16 +0000 | [diff] [blame] | 179 | msg_gerr("Invalid region specified: \"%s\".\n", |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 180 | include_args[i]); |
| 181 | return 1; |
| 182 | } |
| 183 | found++; |
| 184 | } |
| 185 | |
| 186 | msg_ginfo("Using region%s: \"%s\"", num_include_args > 1 ? "s" : "", |
| 187 | include_args[0]); |
| 188 | for (i = 1; i < num_include_args; i++) |
| 189 | msg_ginfo(", \"%s\"", include_args[i]); |
| 190 | msg_ginfo(".\n"); |
| 191 | return 0; |
| 192 | } |
| 193 | |
Stefan Tauner | 949ccc8 | 2013-09-15 14:01:06 +0000 | [diff] [blame] | 194 | void layout_cleanup(void) |
| 195 | { |
| 196 | int i; |
| 197 | for (i = 0; i < num_include_args; i++) { |
| 198 | free(include_args[i]); |
| 199 | include_args[i] = NULL; |
| 200 | } |
| 201 | num_include_args = 0; |
| 202 | |
| 203 | for (i = 0; i < num_rom_entries; i++) { |
| 204 | rom_entries[i].included = 0; |
| 205 | } |
| 206 | num_rom_entries = 0; |
| 207 | } |
| 208 | |
Stefan Tauner | 97b6c11 | 2013-08-30 22:23:02 +0000 | [diff] [blame] | 209 | romentry_t *get_next_included_romentry(unsigned int start) |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 210 | { |
| 211 | int i; |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 212 | unsigned int best_start = UINT_MAX; |
Stefan Tauner | 97b6c11 | 2013-08-30 22:23:02 +0000 | [diff] [blame] | 213 | romentry_t *best_entry = NULL; |
| 214 | romentry_t *cur; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 215 | |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 216 | /* First come, first serve for overlapping regions. */ |
Stefan Tauner | c70bc8a | 2013-08-30 22:22:57 +0000 | [diff] [blame] | 217 | for (i = 0; i < num_rom_entries; i++) { |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 218 | cur = &rom_entries[i]; |
| 219 | if (!cur->included) |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 220 | continue; |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 221 | /* Already past the current entry? */ |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 222 | if (start > cur->end) |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 223 | continue; |
| 224 | /* Inside the current entry? */ |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 225 | if (start >= cur->start) |
| 226 | return cur; |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 227 | /* Entry begins after start. */ |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 228 | if (best_start > cur->start) { |
| 229 | best_start = cur->start; |
| 230 | best_entry = cur; |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 231 | } |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 232 | } |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 233 | return best_entry; |
| 234 | } |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 235 | |
Stefan Tauner | 8268fdb | 2013-09-23 14:21:06 +0000 | [diff] [blame] | 236 | /* Validate and - if needed - normalize layout entries. */ |
| 237 | int normalize_romentries(const struct flashctx *flash) |
| 238 | { |
| 239 | chipsize_t total_size = flash->chip->total_size * 1024; |
| 240 | int ret = 0; |
| 241 | |
| 242 | int i; |
| 243 | for (i = 0; i < num_rom_entries; i++) { |
| 244 | if (rom_entries[i].start >= total_size || rom_entries[i].end >= total_size) { |
| 245 | msg_gwarn("Warning: Address range of region \"%s\" exceeds the current chip's " |
| 246 | "address space.\n", rom_entries[i].name); |
| 247 | if (rom_entries[i].included) |
| 248 | ret = 1; |
| 249 | } |
| 250 | if (rom_entries[i].start > rom_entries[i].end) { |
| 251 | msg_gerr("Error: Size of the address range of region \"%s\" is not positive.\n", |
| 252 | rom_entries[i].name); |
| 253 | ret = 1; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return ret; |
| 258 | } |
| 259 | |
| 260 | int build_new_image(const struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents) |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 261 | { |
| 262 | unsigned int start = 0; |
Stefan Tauner | 97b6c11 | 2013-08-30 22:23:02 +0000 | [diff] [blame] | 263 | romentry_t *entry; |
Carl-Daniel Hailfinger | 5a7cb84 | 2012-08-25 01:17:58 +0000 | [diff] [blame] | 264 | unsigned int size = flash->chip->total_size * 1024; |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 265 | |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 266 | /* If no regions were specified for inclusion, assume |
| 267 | * that the user wants to write the complete new image. |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 268 | */ |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 269 | if (num_include_args == 0) |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 270 | return 0; |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 271 | |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 272 | /* Non-included romentries are ignored. |
| 273 | * The union of all included romentries is used from the new image. |
| 274 | */ |
| 275 | while (start < size) { |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 276 | entry = get_next_included_romentry(start); |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 277 | /* No more romentries for remaining region? */ |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 278 | if (!entry) { |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 279 | memcpy(newcontents + start, oldcontents + start, |
| 280 | size - start); |
| 281 | break; |
| 282 | } |
Louis Yung-Chieh Lo | 9bcf268 | 2011-12-25 09:12:16 +0000 | [diff] [blame] | 283 | /* For non-included region, copy from old content. */ |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 284 | if (entry->start > start) |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 285 | memcpy(newcontents + start, oldcontents + start, |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 286 | entry->start - start); |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 287 | /* Skip to location after current romentry. */ |
Stefan Tauner | 104b0d9 | 2011-12-25 09:07:59 +0000 | [diff] [blame] | 288 | start = entry->end + 1; |
Carl-Daniel Hailfinger | cb6ad16 | 2010-11-02 03:12:51 +0000 | [diff] [blame] | 289 | /* Catch overflow. */ |
| 290 | if (!start) |
| 291 | break; |
| 292 | } |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 293 | return 0; |
| 294 | } |