source: trunk/opaque.c @ 1475

Revision 1475, 2.1 KB checked in by hailfinger, 5 months ago (diff)

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@…>

Line 
1/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2011 Carl-Daniel Hailfinger
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/*
21 * Contains the opaque programmer framework.
22 * An opaque programmer is a programmer which does not provide direct access
23 * to the flash chip and which abstracts all flash chip properties into a
24 * programmer specific interface.
25 */
26
27#include <stdint.h>
28#include "flash.h"
29#include "flashchips.h"
30#include "chipdrivers.h"
31#include "programmer.h"
32
33int probe_opaque(struct flashctx *flash)
34{
35        return flash->pgm->opaque.probe(flash);
36}
37
38int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
39{
40        return flash->pgm->opaque.read(flash, buf, start, len);
41}
42
43int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
44{
45        return flash->pgm->opaque.write(flash, buf, start, len);
46}
47
48int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen)
49{
50        return flash->pgm->opaque.erase(flash, blockaddr, blocklen);
51}
52
53int register_opaque_programmer(const struct opaque_programmer *pgm)
54{
55        struct registered_programmer rpgm;
56
57        if (!pgm->probe || !pgm->read || !pgm->write || !pgm->erase) {
58                msg_perr("%s called with incomplete programmer definition. "
59                         "Please report a bug at flashrom@flashrom.org\n",
60                         __func__);
61                return ERROR_FLASHROM_BUG;
62        }
63        rpgm.buses_supported = BUS_PROG;
64        rpgm.opaque = *pgm;
65        return register_programmer(&rpgm);
66}
Note: See TracBrowser for help on using the repository browser.