Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 Stefan Tauner |
| 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 | #include <stdint.h> |
| 21 | #include <stdlib.h> |
Carl-Daniel Hailfinger | 2d25124 | 2012-02-24 23:49:30 +0000 | [diff] [blame^] | 22 | #include <string.h> |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 23 | #include "flash.h" |
| 24 | #include "spi.h" |
| 25 | #include "chipdrivers.h" |
| 26 | |
| 27 | static int spi_sfdp_read_sfdp_chunk(struct flashctx *flash, uint32_t address, uint8_t *buf, int len) |
| 28 | { |
| 29 | int i, ret; |
Carl-Daniel Hailfinger | 2d25124 | 2012-02-24 23:49:30 +0000 | [diff] [blame^] | 30 | uint8_t *newbuf; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 31 | const unsigned char cmd[JEDEC_SFDP_OUTSIZE] = { |
| 32 | JEDEC_SFDP, |
| 33 | (address >> 16) & 0xff, |
| 34 | (address >> 8) & 0xff, |
| 35 | (address >> 0) & 0xff, |
| 36 | /* FIXME: the following dummy byte explodes on some programmers. |
Carl-Daniel Hailfinger | 2d25124 | 2012-02-24 23:49:30 +0000 | [diff] [blame^] | 37 | * One workaround is to read the dummy byte |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 38 | * instead and discard its value. |
| 39 | */ |
| 40 | 0 |
| 41 | }; |
| 42 | msg_cspew("%s: addr=0x%x, len=%d, data:\n", __func__, address, len); |
Carl-Daniel Hailfinger | 2d25124 | 2012-02-24 23:49:30 +0000 | [diff] [blame^] | 43 | newbuf = malloc(len + 1); |
| 44 | if (!newbuf) |
| 45 | return SPI_PROGRAMMER_ERROR; |
| 46 | ret = spi_send_command(flash, sizeof(cmd) - 1, len + 1, cmd, newbuf); |
| 47 | memmove(buf, newbuf + 1, len); |
| 48 | free(newbuf); |
| 49 | if (ret) |
| 50 | return ret; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 51 | for (i = 0; i < len; i++) |
| 52 | msg_cspew(" 0x%02x", buf[i]); |
| 53 | msg_cspew("\n"); |
Carl-Daniel Hailfinger | 2d25124 | 2012-02-24 23:49:30 +0000 | [diff] [blame^] | 54 | return 0; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static int spi_sfdp_read_sfdp(struct flashctx *flash, uint32_t address, uint8_t *buf, int len) |
| 58 | { |
Carl-Daniel Hailfinger | 2d25124 | 2012-02-24 23:49:30 +0000 | [diff] [blame^] | 59 | /* FIXME: There are different upper bounds for the number of bytes to |
| 60 | * read on the various programmers (even depending on the rest of the |
| 61 | * structure of the transaction). 2 is a safe bet. */ |
| 62 | int maxstep = 2; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 63 | int ret = 0; |
| 64 | while (len > 0) { |
| 65 | int step = min(len, maxstep); |
| 66 | ret = spi_sfdp_read_sfdp_chunk(flash, address, buf, step); |
| 67 | if (ret) |
| 68 | return ret; |
| 69 | address += step; |
| 70 | buf += step; |
| 71 | len -= step; |
| 72 | } |
| 73 | return ret; |
| 74 | } |
| 75 | |
| 76 | struct sfdp_tbl_hdr { |
| 77 | uint8_t id; |
| 78 | uint8_t v_minor; |
| 79 | uint8_t v_major; |
| 80 | uint8_t len; |
| 81 | uint32_t ptp; /* 24b pointer */ |
| 82 | }; |
| 83 | |
| 84 | static int sfdp_add_uniform_eraser(struct flashctx *flash, uint8_t opcode, uint32_t block_size) |
| 85 | { |
| 86 | int i; |
| 87 | uint32_t total_size = flash->total_size * 1024; |
| 88 | erasefunc_t *erasefn = spi_get_erasefn_from_opcode(opcode); |
| 89 | |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 90 | if (erasefn == NULL || total_size == 0 || block_size == 0 || |
| 91 | total_size % block_size != 0) { |
| 92 | msg_cdbg("%s: invalid input, please report to " |
| 93 | "flashrom@flashrom.org\n", __func__); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 94 | return 1; |
| 95 | } |
| 96 | |
| 97 | for (i = 0; i < NUM_ERASEFUNCTIONS; i++) { |
| 98 | struct block_eraser *eraser = &flash->block_erasers[i]; |
| 99 | /* Check for duplicates (including (some) non-uniform ones). */ |
| 100 | if (eraser->eraseblocks[0].size == block_size && |
| 101 | eraser->block_erase == erasefn) { |
| 102 | msg_cdbg2(" Tried to add a duplicate block eraser: " |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 103 | "%d x %d B with opcode 0x%02x.\n", |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 104 | total_size/block_size, block_size, opcode); |
| 105 | return 1; |
| 106 | } |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 107 | if (eraser->eraseblocks[0].size != 0 || |
| 108 | eraser->block_erase != NULL) { |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 109 | msg_cspew(" Block Eraser %d is already occupied.\n", |
| 110 | i); |
| 111 | continue; |
| 112 | } |
| 113 | |
| 114 | eraser->block_erase = erasefn; |
| 115 | eraser->eraseblocks[0].size = block_size; |
| 116 | eraser->eraseblocks[0].count = total_size/block_size; |
| 117 | msg_cdbg2(" Block eraser %d: %d x %d B with opcode " |
| 118 | "0x%02x\n", i, total_size/block_size, block_size, |
| 119 | opcode); |
| 120 | return 0; |
| 121 | } |
| 122 | msg_cinfo("%s: Not enough space to store another eraser (i=%d)." |
| 123 | " Please report this at flashrom@flashrom.org\n", |
| 124 | __func__, i); |
| 125 | return 1; |
| 126 | } |
| 127 | |
| 128 | static int sfdp_fill_flash(struct flashctx *flash, uint8_t *buf, uint16_t len) |
| 129 | { |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 130 | uint8_t opcode_4k_erase = 0xFF; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 131 | uint32_t tmp32; |
| 132 | uint8_t tmp8; |
| 133 | uint32_t total_size; /* in bytes */ |
| 134 | uint32_t block_size; |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 135 | int j; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 136 | |
| 137 | msg_cdbg("Parsing JEDEC flash parameter table... "); |
| 138 | if (len != 9 * 4 && len != 4 * 4) { |
| 139 | msg_cdbg("%s: len out of spec\n", __func__); |
| 140 | return 1; |
| 141 | } |
| 142 | msg_cdbg2("\n"); |
| 143 | |
| 144 | /* 1. double word */ |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 145 | tmp32 = ((unsigned int)buf[(4 * 0) + 0]); |
| 146 | tmp32 |= ((unsigned int)buf[(4 * 0) + 1]) << 8; |
| 147 | tmp32 |= ((unsigned int)buf[(4 * 0) + 2]) << 16; |
| 148 | tmp32 |= ((unsigned int)buf[(4 * 0) + 3]) << 24; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 149 | |
| 150 | tmp8 = (tmp32 >> 17) & 0x3; |
| 151 | switch (tmp8) { |
| 152 | case 0x0: |
| 153 | msg_cdbg2(" 3-Byte only addressing.\n"); |
| 154 | break; |
| 155 | case 0x1: |
| 156 | msg_cdbg2(" 3-Byte (and optionally 4-Byte) addressing.\n"); |
| 157 | break; |
| 158 | case 0x2: |
| 159 | msg_cdbg(" 4-Byte only addressing (not supported by " |
| 160 | "flashrom).\n"); |
| 161 | return 1; |
| 162 | default: |
| 163 | msg_cdbg(" Required addressing mode (0x%x) not supported.\n", |
| 164 | tmp8); |
| 165 | return 1; |
| 166 | } |
| 167 | |
| 168 | msg_cdbg2(" Status register is "); |
| 169 | if (tmp32 & (1 << 3)) { |
| 170 | msg_cdbg2("volatile and writes to the status register have to " |
| 171 | "be enabled with "); |
| 172 | if (tmp32 & (1 << 4)) { |
| 173 | flash->feature_bits = FEATURE_WRSR_WREN; |
| 174 | msg_cdbg2("WREN (0x06).\n"); |
| 175 | } else { |
| 176 | flash->feature_bits = FEATURE_WRSR_EWSR; |
| 177 | msg_cdbg2("EWSR (0x50).\n"); |
| 178 | } |
| 179 | } else |
| 180 | msg_cdbg2("non-volatile and the standard does not allow " |
| 181 | "vendors to tell us whether EWSR/WREN is needed for " |
| 182 | "status register writes - assuming EWSR.\n"); |
| 183 | |
| 184 | msg_cdbg2(" Write chunk size is "); |
| 185 | if (tmp32 & (1 << 2)) { |
| 186 | msg_cdbg2("at least 64 B.\n"); |
| 187 | flash->page_size = 64; |
| 188 | flash->write = spi_chip_write_256; |
| 189 | } else { |
| 190 | msg_cdbg2("1 B only.\n"); |
| 191 | flash->page_size = 256; |
| 192 | flash->write = spi_chip_write_1; |
| 193 | } |
| 194 | |
| 195 | if ((tmp32 & 0x3) == 0x1) { |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 196 | opcode_4k_erase = (tmp32 >> 8) & 0xFF; |
| 197 | msg_cspew(" 4kB erase opcode is 0x%02x.\n", opcode_4k_erase); |
| 198 | /* add the eraser later, because we don't know total_size yet */ |
| 199 | } else |
| 200 | msg_cspew(" 4kB erase opcode is not defined.\n"); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 201 | |
| 202 | /* 2. double word */ |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 203 | tmp32 = ((unsigned int)buf[(4 * 1) + 0]); |
| 204 | tmp32 |= ((unsigned int)buf[(4 * 1) + 1]) << 8; |
| 205 | tmp32 |= ((unsigned int)buf[(4 * 1) + 2]) << 16; |
| 206 | tmp32 |= ((unsigned int)buf[(4 * 1) + 3]) << 24; |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 207 | |
| 208 | if (tmp32 & (1 << 31)) { |
| 209 | msg_cdbg("Flash chip size >= 4 Gb/512 MB not supported.\n"); |
| 210 | return 1; |
| 211 | } |
| 212 | total_size = ((tmp32 & 0x7FFFFFFF) + 1) / 8; |
| 213 | flash->total_size = total_size / 1024; |
| 214 | msg_cdbg2(" Flash chip size is %d kB.\n", flash->total_size); |
| 215 | if (total_size > (1 << 24)) { |
| 216 | msg_cdbg("Flash chip size is bigger than what 3-Byte addressing " |
| 217 | "can access.\n"); |
| 218 | return 1; |
| 219 | } |
| 220 | |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 221 | if (opcode_4k_erase != 0xFF) |
| 222 | sfdp_add_uniform_eraser(flash, opcode_4k_erase, 4 * 1024); |
| 223 | |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 224 | /* FIXME: double words 3-7 contain unused fast read information */ |
| 225 | |
| 226 | if (len == 4 * 4) { |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 227 | msg_cdbg(" It seems like this chip supports the preliminary " |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 228 | "Intel version of SFDP, skipping processing of double " |
| 229 | "words 3-9.\n"); |
| 230 | goto done; |
| 231 | } |
| 232 | |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 233 | /* 8. double word */ |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 234 | for (j = 0; j < 4; j++) { |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 235 | /* 7 double words from the start + 2 bytes for every eraser */ |
| 236 | tmp8 = buf[(4 * 7) + (j * 2)]; |
| 237 | msg_cspew(" Erase Sector Type %d Size: 0x%02x\n", j + 1, |
| 238 | tmp8); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 239 | if (tmp8 == 0) { |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 240 | msg_cspew(" Erase Sector Type %d is unused.\n", j); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 241 | continue; |
| 242 | } |
| 243 | if (tmp8 >= 31) { |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 244 | msg_cdbg2(" Block size of erase Sector Type %d (2^%d) " |
| 245 | "is too big for flashrom.\n", j, tmp8); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 246 | continue; |
| 247 | } |
| 248 | block_size = 1 << (tmp8); /* block_size = 2 ^ field */ |
| 249 | |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 250 | tmp8 = buf[(4 * 7) + (j * 2) + 1]; |
| 251 | msg_cspew(" Erase Sector Type %d Opcode: 0x%02x\n", j + 1, |
| 252 | tmp8); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 253 | sfdp_add_uniform_eraser(flash, tmp8, block_size); |
| 254 | } |
| 255 | |
| 256 | done: |
| 257 | msg_cdbg("done.\n"); |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | int probe_spi_sfdp(struct flashctx *flash) |
| 262 | { |
| 263 | int ret = 0; |
| 264 | uint8_t buf[8]; |
| 265 | uint32_t tmp32; |
| 266 | uint8_t nph; |
| 267 | /* need to limit the table loop by comparing i to uint8_t nph hence: */ |
| 268 | uint16_t i; |
| 269 | struct sfdp_tbl_hdr *hdrs; |
| 270 | uint8_t *hbuf; |
| 271 | uint8_t *tbuf; |
| 272 | |
| 273 | if (spi_sfdp_read_sfdp(flash, 0x00, buf, 4)) { |
| 274 | msg_cdbg("Receiving SFDP signature failed.\n"); |
| 275 | return 0; |
| 276 | } |
| 277 | tmp32 = buf[0]; |
| 278 | tmp32 |= ((unsigned int)buf[1]) << 8; |
| 279 | tmp32 |= ((unsigned int)buf[2]) << 16; |
| 280 | tmp32 |= ((unsigned int)buf[3]) << 24; |
| 281 | |
| 282 | if (tmp32 != 0x50444653) { |
| 283 | msg_cdbg2("Signature = 0x%08x (should be 0x50444653)\n", tmp32); |
| 284 | msg_cdbg("No SFDP signature found.\n"); |
| 285 | return 0; |
| 286 | } |
| 287 | |
| 288 | if (spi_sfdp_read_sfdp(flash, 0x04, buf, 3)) { |
| 289 | msg_cdbg("Receiving SFDP revision and number of parameter " |
| 290 | "headers (NPH) failed. "); |
| 291 | return 0; |
| 292 | } |
| 293 | msg_cdbg2("SFDP revision = %d.%d\n", buf[1], buf[0]); |
| 294 | if (buf[1] != 0x01) { |
| 295 | msg_cdbg("The chip supports an unknown version of SFDP. " |
| 296 | "Aborting SFDP probe!\n"); |
| 297 | return 0; |
| 298 | } |
| 299 | nph = buf[2]; |
| 300 | msg_cdbg2("SFDP number of parameter headers is %d (NPH = %d).\n", |
| 301 | nph + 1, nph); |
| 302 | |
| 303 | /* Fetch all parameter headers, even if we don't use them all (yet). */ |
| 304 | hbuf = malloc((nph + 1) * 8); |
| 305 | hdrs = malloc((nph + 1) * sizeof(struct sfdp_tbl_hdr)); |
| 306 | if (hbuf == NULL || hdrs == NULL ) { |
| 307 | msg_gerr("Out of memory!\n"); |
| 308 | goto cleanup_hdrs; |
| 309 | } |
| 310 | if (spi_sfdp_read_sfdp(flash, 0x08, hbuf, (nph + 1) * 8)) { |
| 311 | msg_cdbg("Receiving SFDP parameter table headers failed.\n"); |
| 312 | goto cleanup_hdrs; |
| 313 | } |
| 314 | |
| 315 | for (i = 0; i <= nph; i++) { |
| 316 | uint16_t len; |
| 317 | hdrs[i].id = hbuf[(8 * i) + 0]; |
| 318 | hdrs[i].v_minor = hbuf[(8 * i) + 1]; |
| 319 | hdrs[i].v_major = hbuf[(8 * i) + 2]; |
| 320 | hdrs[i].len = hbuf[(8 * i) + 3]; |
| 321 | hdrs[i].ptp = hbuf[(8 * i) + 4]; |
| 322 | hdrs[i].ptp |= ((unsigned int)hbuf[(8 * i) + 5]) << 8; |
| 323 | hdrs[i].ptp |= ((unsigned int)hbuf[(8 * i) + 6]) << 16; |
| 324 | msg_cdbg2("\nSFDP parameter table header %d/%d:\n", i, nph); |
| 325 | msg_cdbg2(" ID 0x%02x, version %d.%d\n", hdrs[i].id, |
| 326 | hdrs[i].v_major, hdrs[i].v_minor); |
| 327 | len = hdrs[i].len * 4; |
| 328 | tmp32 = hdrs[i].ptp; |
| 329 | msg_cdbg2(" Length %d B, Parameter Table Pointer 0x%06x\n", |
| 330 | len, tmp32); |
| 331 | |
| 332 | if (tmp32 + len >= (1 << 24)) { |
| 333 | msg_cdbg("SFDP Parameter Table %d supposedly overflows " |
| 334 | "addressable SFDP area. This most\nprobably " |
| 335 | "indicates a corrupt SFDP parameter table " |
| 336 | "header. Skipping it.\n", i); |
| 337 | continue; |
| 338 | } |
| 339 | |
| 340 | tbuf = malloc(len); |
| 341 | if (tbuf == NULL) { |
| 342 | msg_gerr("Out of memory!\n"); |
| 343 | goto cleanup_hdrs; |
| 344 | } |
| 345 | if (spi_sfdp_read_sfdp(flash, tmp32, tbuf, len)){ |
| 346 | msg_cdbg("Fetching SFDP parameter table %d failed.\n", |
| 347 | i); |
| 348 | free(tbuf); |
| 349 | continue; |
| 350 | } |
| 351 | msg_cspew(" Parameter table contents:\n"); |
| 352 | for (tmp32 = 0; tmp32 < len; tmp32++) { |
| 353 | if ((tmp32 % 8) == 0) { |
| 354 | msg_cspew(" 0x%04x: ", tmp32); |
| 355 | } |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 356 | msg_cspew(" %02x", tbuf[tmp32]); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 357 | if ((tmp32 % 8) == 7) { |
| 358 | msg_cspew("\n"); |
| 359 | continue; |
| 360 | } |
| 361 | if ((tmp32 % 8) == 3) { |
| 362 | msg_cspew(" "); |
| 363 | continue; |
| 364 | } |
| 365 | } |
Stefan Tauner | 75adf32 | 2012-02-22 00:14:14 +0000 | [diff] [blame] | 366 | msg_cspew("\n"); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 367 | |
| 368 | if (i == 0) { /* Mandatory JEDEC SFDP parameter table */ |
| 369 | if (hdrs[i].id != 0) |
| 370 | msg_cdbg("ID of the mandatory JEDEC SFDP " |
| 371 | "parameter table is not 0 as demanded " |
| 372 | "by JESD216 (warning only).\n"); |
| 373 | |
| 374 | if (hdrs[i].v_major != 0x01) { |
| 375 | msg_cdbg("The chip contains an unknown " |
| 376 | "version of the JEDEC flash " |
| 377 | "parameters table, skipping it.\n"); |
| 378 | } else if (len != 9 * 4 && len != 4 * 4) { |
| 379 | msg_cdbg("Length of the mandatory JEDEC SFDP " |
| 380 | "parameter table is wrong (%d B), " |
| 381 | "skipping it.\n", len); |
| 382 | } else if (sfdp_fill_flash(flash, tbuf, len) == 0) |
| 383 | ret = 1; |
| 384 | } |
| 385 | free(tbuf); |
| 386 | } |
| 387 | |
| 388 | cleanup_hdrs: |
| 389 | free(hdrs); |
| 390 | free(hbuf); |
| 391 | return ret; |
| 392 | } |