Changeset 1475 for trunk/flashrom.c


Ignore:
Timestamp:
Dec 20, 2011, 1:19:29 AM (3 years ago)
Author:
hailfinger
Message:

Have all programmer init functions register bus masters/programmers

All programmer types (Parallel, SPI, Opaque) now register themselves
into a generic programmer list and probing is now programmer-centric
instead of chip-centric.
Registering multiple SPI/... masters at the same time is now possible
without any problems. Handling multiple flash chips is still unchanged,
but now we have the infrastructure to deal with "dual BIOS" and "one
flash behind southbridge and one flash behind EC" sanely.

A nice side effect is that this patch kills quite a few global variables
and improves the situation for libflashrom.

Hint for developers:
struct {spi,par,opaque}_programmer now have a void *data pointer to
store any additional programmer-specific data, e.g. hardware
configuration info.

Note:
flashrom -f -c FOO -r forced_read.bin
does not work anymore. We have to find an architecturally clean way to
solve this.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Acked-by: Michael Karcher <flashrom@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/flashrom.c

    r1474 r1475  
    4747static char *programmer_param = NULL; 
    4848 
    49 /* Supported buses for the current programmer. */ 
    50 enum chipbustype buses_supported; 
    51  
    5249/* 
    5350 * Programmers supporting multiple buses can have differing size limits on 
     
    315312                .spi            = 0xffffffff, 
    316313        }; 
    317         buses_supported = BUS_NONE; 
    318314        /* Default to top aligned flash at 4 GB. */ 
    319315        flashbase = 0; 
     
    362358void chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr) 
    363359{ 
    364         par_programmer->chip_writeb(flash, val, addr); 
     360        flash->pgm->par.chip_writeb(flash, val, addr); 
    365361} 
    366362 
    367363void chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr) 
    368364{ 
    369         par_programmer->chip_writew(flash, val, addr); 
     365        flash->pgm->par.chip_writew(flash, val, addr); 
    370366} 
    371367 
    372368void chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr) 
    373369{ 
    374         par_programmer->chip_writel(flash, val, addr); 
     370        flash->pgm->par.chip_writel(flash, val, addr); 
    375371} 
    376372 
     
    378374                 size_t len) 
    379375{ 
    380         par_programmer->chip_writen(flash, buf, addr, len); 
     376        flash->pgm->par.chip_writen(flash, buf, addr, len); 
    381377} 
    382378 
    383379uint8_t chip_readb(const struct flashctx *flash, const chipaddr addr) 
    384380{ 
    385         return par_programmer->chip_readb(flash, addr); 
     381        return flash->pgm->par.chip_readb(flash, addr); 
    386382} 
    387383 
    388384uint16_t chip_readw(const struct flashctx *flash, const chipaddr addr) 
    389385{ 
    390         return par_programmer->chip_readw(flash, addr); 
     386        return flash->pgm->par.chip_readw(flash, addr); 
    391387} 
    392388 
    393389uint32_t chip_readl(const struct flashctx *flash, const chipaddr addr) 
    394390{ 
    395         return par_programmer->chip_readl(flash, addr); 
     391        return flash->pgm->par.chip_readl(flash, addr); 
    396392} 
    397393 
     
    399395                size_t len) 
    400396{ 
    401         par_programmer->chip_readn(flash, buf, addr, len); 
     397        flash->pgm->par.chip_readn(flash, buf, addr, len); 
    402398} 
    403399 
     
    943939} 
    944940 
    945 int probe_flash(int startchip, struct flashctx *fill_flash, int force) 
     941int probe_flash(struct registered_programmer *pgm, int startchip, 
     942                struct flashctx *fill_flash, int force) 
    946943{ 
    947944        const struct flashchip *flash; 
     
    955952                if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) 
    956953                        continue; 
    957                 buses_common = buses_supported & flash->bustype; 
    958                 if (!buses_common) { 
    959                         msg_gspew("Probing for %s %s, %d kB: skipped. ", 
    960                                  flash->vendor, flash->name, flash->total_size); 
    961                         tmp = flashbuses_to_text(buses_supported); 
    962                         msg_gspew("Host bus type %s ", tmp); 
    963                         free(tmp); 
    964                         tmp = flashbuses_to_text(flash->bustype); 
    965                         msg_gspew("and chip bus type %s are incompatible.", 
    966                                   tmp); 
    967                         free(tmp); 
    968                         msg_gspew("\n"); 
     954                buses_common = pgm->buses_supported & flash->bustype; 
     955                if (!buses_common) 
    969956                        continue; 
    970                 } 
    971957                msg_gdbg("Probing for %s %s, %d kB: ", 
    972958                             flash->vendor, flash->name, flash->total_size); 
     
    982968                /* Start filling in the dynamic data. */ 
    983969                memcpy(fill_flash, flash, sizeof(struct flashchip)); 
     970                fill_flash->pgm = pgm; 
    984971 
    985972                base = flashbase ? flashbase : (0xffffffff - size + 1); 
Note: See TracChangeset for help on using the changeset viewer.