diff options
author | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2012-12-26 19:51:23 +0000 |
---|---|---|
committer | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2012-12-26 19:51:23 +0000 |
commit | a5e3700df83e583d8e64eb0b3c4187afc6812c15 (patch) | |
tree | 5414f347772370cab4297954d82cf059683f5fe5 | |
parent | 5b0792e14de89d53c66db272f40dc51e9ef7b751 (diff) | |
download | flashrom-a5e3700df83e583d8e64eb0b3c4187afc6812c15.tar.gz |
Add general programmer sanity checks.
And remove the completely unused vendor field.
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1630 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r-- | flashrom.c | 29 | ||||
-rw-r--r-- | programmer.h | 4 |
2 files changed, 29 insertions, 4 deletions
@@ -1557,8 +1557,9 @@ void print_banner(void) int selfcheck(void) { - int ret = 0; const struct flashchip *chip; + int i; + int ret = 0; /* Safety check. Instead of aborting after the first error, check * if more errors exist. @@ -1567,6 +1568,32 @@ int selfcheck(void) msg_gerr("Programmer table miscompilation!\n"); ret = 1; } + for (i = 0; i < PROGRAMMER_INVALID; i++) { + const struct programmer_entry p = programmer_table[i]; + if (p.name == NULL) { + msg_gerr("All programmers need a valid name, but the one with index %d does not!\n", i); + ret = 1; + /* This might hide other problems with this programmer, but allows for better error + * messages below without jumping through hoops. */ + continue; + } + if (p.init == NULL) { + msg_gerr("Programmer %s does not have a valid init function!\n", p.name); + ret = 1; + } + if (p.delay == NULL) { + msg_gerr("Programmer %s does not have a valid delay function!\n", p.name); + ret = 1; + } + if (p.map_flash_region == NULL) { + msg_gerr("Programmer %s does not have a valid map_flash_region function!\n", p.name); + ret = 1; + } + if (p.unmap_flash_region == NULL) { + msg_gerr("Programmer %s does not have a valid unmap_flash_region function!\n", p.name); + ret = 1; + } + } /* It would be favorable if we could also check for correct termination * of the following arrays, but we don't know their sizes in here... * For 'flashchips' we check the first element to be non-null. In the diff --git a/programmer.h b/programmer.h index dedec67..1510e2f 100644 --- a/programmer.h +++ b/programmer.h @@ -91,13 +91,11 @@ enum programmer { }; struct programmer_entry { - const char *vendor; const char *name; int (*init) (void); - void *(*map_flash_region) (const char *descr, unsigned long phys_addr, - size_t len); + void *(*map_flash_region) (const char *descr, unsigned long phys_addr, size_t len); void (*unmap_flash_region) (void *virt_addr, size_t len); void (*delay) (int usecs); |