summaryrefslogtreecommitdiffstats
path: root/opaque.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-12-20 00:19:29 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-12-20 00:19:29 +0000
commitc40cff7b86848f5b248d7fcf20f7d517b60c385d (patch)
tree7f9db61c7b4868e513c4702cfe57bb35ae695266 /opaque.c
parent8a3c60cdd0e5632173567923ae1927763e31e857 (diff)
downloadast2050-flashrom-c40cff7b86848f5b248d7fcf20f7d517b60c385d.zip
ast2050-flashrom-c40cff7b86848f5b248d7fcf20f7d517b60c385d.tar.gz
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. Corresponding to flashrom svn r1475. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'opaque.c')
-rw-r--r--opaque.c59
1 files changed, 13 insertions, 46 deletions
diff --git a/opaque.c b/opaque.c
index 43ddb07..6acaa63 100644
--- a/opaque.c
+++ b/opaque.c
@@ -30,70 +30,37 @@
#include "chipdrivers.h"
#include "programmer.h"
-const struct opaque_programmer opaque_programmer_none = {
- .max_data_read = MAX_DATA_UNSPECIFIED,
- .max_data_write = MAX_DATA_UNSPECIFIED,
- .probe = NULL,
- .read = NULL,
- .write = NULL,
- .erase = NULL,
-};
-
-const struct opaque_programmer *opaque_programmer = &opaque_programmer_none;
-
int probe_opaque(struct flashctx *flash)
{
- if (!opaque_programmer->probe) {
- msg_perr("%s called before register_opaque_programmer. "
- "Please report a bug at flashrom@flashrom.org\n",
- __func__);
- return 0;
- }
-
- return opaque_programmer->probe(flash);
+ return flash->pgm->opaque.probe(flash);
}
int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- if (!opaque_programmer->read) {
- msg_perr("%s called before register_opaque_programmer. "
- "Please report a bug at flashrom@flashrom.org\n",
- __func__);
- return 1;
- }
- return opaque_programmer->read(flash, buf, start, len);
+ return flash->pgm->opaque.read(flash, buf, start, len);
}
int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- if (!opaque_programmer->write) {
- msg_perr("%s called before register_opaque_programmer. "
- "Please report a bug at flashrom@flashrom.org\n",
- __func__);
- return 1;
- }
- return opaque_programmer->write(flash, buf, start, len);
+ return flash->pgm->opaque.write(flash, buf, start, len);
}
int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen)
{
- if (!opaque_programmer->erase) {
- msg_perr("%s called before register_opaque_programmer. "
- "Please report a bug at flashrom@flashrom.org\n",
- __func__);
- return 1;
- }
- return opaque_programmer->erase(flash, blockaddr, blocklen);
+ return flash->pgm->opaque.erase(flash, blockaddr, blocklen);
}
-void register_opaque_programmer(const struct opaque_programmer *pgm)
+int register_opaque_programmer(const struct opaque_programmer *pgm)
{
+ struct registered_programmer rpgm;
+
if (!pgm->probe || !pgm->read || !pgm->write || !pgm->erase) {
- msg_perr("%s called with one of probe/read/write/erase being "
- "NULL. Please report a bug at flashrom@flashrom.org\n",
+ msg_perr("%s called with incomplete programmer definition. "
+ "Please report a bug at flashrom@flashrom.org\n",
__func__);
- return;
+ return ERROR_FLASHROM_BUG;
}
- opaque_programmer = pgm;
- buses_supported |= BUS_PROG;
+ rpgm.buses_supported = BUS_PROG;
+ rpgm.opaque = *pgm;
+ return register_programmer(&rpgm);
}
OpenPOWER on IntegriCloud