1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-29 16:03:47 +02:00

Fix bug in r3790

If flashbase was set before probe_flash() it would only ever be used once, for
the very first flash chip probe.

Corresponding to flashrom svn r356 and coreboot v2 svn r3791.

Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Peter Stuge <peter@stuge.se>
This commit is contained in:
Peter Stuge 2008-12-03 21:39:56 +00:00
parent 9a6d1764a2
commit 73bdb92b5d

View File

@ -105,7 +105,7 @@ struct flashchip *probe_flash(struct flashchip *first_flash, int force)
{ {
volatile uint8_t *bios; volatile uint8_t *bios;
struct flashchip *flash; struct flashchip *flash;
unsigned long size; unsigned long base, size;
for (flash = first_flash; flash && flash->name; flash++) { for (flash = first_flash; flash && flash->name; flash++) {
if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0)
@ -133,11 +133,10 @@ struct flashchip *probe_flash(struct flashchip *first_flash, int force)
*/ */
size = getpagesize(); size = getpagesize();
} }
if (!flashbase)
flashbase = (0xffffffff - size + 1);
base = flashbase ? flashbase : (0xffffffff - size + 1);
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED, bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
fd_mem, (off_t) flashbase); fd_mem, (off_t) base);
if (bios == MAP_FAILED) { if (bios == MAP_FAILED) {
perror("Can't mmap memory using " MEM_DEV); perror("Can't mmap memory using " MEM_DEV);
exit(1); exit(1);
@ -162,7 +161,8 @@ notfound:
return NULL; return NULL;
printf("Found chip \"%s %s\" (%d KB) at physical address 0x%lx.\n", printf("Found chip \"%s %s\" (%d KB) at physical address 0x%lx.\n",
flash->vendor, flash->name, flash->total_size, flashbase); flash->vendor, flash->name, flash->total_size, base);
flashbase = base;
return flash; return flash;
} }