mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 06:23:18 +02:00
Refine physical address mapping of flash chips
- Create distinct functions for mapping and unmapping for flash chips. - Map only when needed: map before probing and unmap immediately after it. Map again when a single chip was probed successfully before taking any actual actions and clean up afterwards. - Map special function chip registers centrally together with flash space instead of within (some) probing methods after successful probes. - Save the used base addresses of the mappings in struct flashctx as well. - Do not try to (un)map the zero-sized chip definitions that are merely hacks. This also fixes the printing of wrong warnings for these chip definitions introduced in r1765. Corresponding to flashrom svn r1847. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
17
flash.h
17
flash.h
@ -48,9 +48,9 @@ typedef uintptr_t chipaddr;
|
||||
/* Types and macros regarding the maximum flash space size supported by generic code. */
|
||||
typedef uint32_t chipoff_t; /* Able to store any addressable offset within a supported flash memory. */
|
||||
typedef uint32_t chipsize_t; /* Able to store the number of bytes of any supported flash memory. */
|
||||
#define FL_MAX_CHIPADDR_BITS (24)
|
||||
#define FL_MAX_CHIPADDR ((chipoff_t)(1ULL<<FL_MAX_CHIPADDR_BITS)-1)
|
||||
#define PRIxCHIPADDR "06"PRIx32
|
||||
#define FL_MAX_CHIPOFF_BITS (24)
|
||||
#define FL_MAX_CHIPOFF ((chipoff_t)(1ULL<<FL_MAX_CHIPOFF_BITS)-1)
|
||||
#define PRIxCHIPOFF "06"PRIx32
|
||||
#define PRIuCHIPSIZE PRIu32
|
||||
|
||||
int register_shutdown(int (*function) (void *data), void *data);
|
||||
@ -209,8 +209,14 @@ struct flashchip {
|
||||
|
||||
struct flashctx {
|
||||
struct flashchip *chip;
|
||||
/* FIXME: The memory mappings should be saved in a more structured way. */
|
||||
/* The physical_* fields store the respective addresses in the physical address space of the CPU. */
|
||||
uintptr_t physical_memory;
|
||||
/* The virtual_* fields store where the respective physical address is mapped into flashrom's address
|
||||
* space. A value equivalent to (chipaddr)ERROR_PTR indicates an invalid mapping (or none at all). */
|
||||
chipaddr virtual_memory;
|
||||
/* Some flash devices have an additional register space. */
|
||||
/* Some flash devices have an additional register space; semantics are like above. */
|
||||
uintptr_t physical_registers;
|
||||
chipaddr virtual_registers;
|
||||
struct registered_master *mst;
|
||||
};
|
||||
@ -252,7 +258,8 @@ void tolower_string(char *str);
|
||||
/* flashrom.c */
|
||||
extern const char flashrom_version[];
|
||||
extern const char *chip_to_probe;
|
||||
void map_flash_registers(struct flashctx *flash);
|
||||
int map_flash(struct flashctx *flash);
|
||||
void unmap_flash(struct flashctx *flash);
|
||||
int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int erase_flash(struct flashctx *flash);
|
||||
int probe_flash(struct registered_master *mst, int startchip, struct flashctx *fill_flash, int force);
|
||||
|
Reference in New Issue
Block a user