Changeset 1112 for trunk/programmer.h
- Timestamp:
- 07/28/10 00:41:39 (22 months ago)
- File:
-
- 1 copied
-
trunk/programmer.h (copied) (copied from trunk/flash.h) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/programmer.h
r1111 r1112 22 22 */ 23 23 24 #ifndef __FLASH_H__ 25 #define __FLASH_H__ 1 26 27 #include <stdint.h> 28 #include <stddef.h> 29 #include "hwaccess.h" 30 #ifdef _WIN32 31 #include <windows.h> 32 #undef min 33 #undef max 34 #endif 35 36 typedef unsigned long chipaddr; 24 #ifndef __PROGRAMMER_H__ 25 #define __PROGRAMMER_H__ 1 37 26 38 27 enum programmer { … … 114 103 extern const struct programmer_entry programmer_table[]; 115 104 116 int register_shutdown(void (*function) (void *data), void *data);117 118 105 int programmer_init(char *param); 119 106 int programmer_shutdown(void); 120 void *programmer_map_flash_region(const char *descr, unsigned long phys_addr,121 size_t len);122 void programmer_unmap_flash_region(void *virt_addr, size_t len);123 void chip_writeb(uint8_t val, chipaddr addr);124 void chip_writew(uint16_t val, chipaddr addr);125 void chip_writel(uint32_t val, chipaddr addr);126 void chip_writen(uint8_t *buf, chipaddr addr, size_t len);127 uint8_t chip_readb(const chipaddr addr);128 uint16_t chip_readw(const chipaddr addr);129 uint32_t chip_readl(const chipaddr addr);130 void chip_readn(uint8_t *buf, const chipaddr addr, size_t len);131 void programmer_delay(int usecs);132 107 133 108 enum bitbang_spi_master_type { … … 147 122 int (*get_miso) (void); 148 123 }; 149 150 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))151 152 enum chipbustype {153 CHIP_BUSTYPE_NONE = 0,154 CHIP_BUSTYPE_PARALLEL = 1 << 0,155 CHIP_BUSTYPE_LPC = 1 << 1,156 CHIP_BUSTYPE_FWH = 1 << 2,157 CHIP_BUSTYPE_SPI = 1 << 3,158 CHIP_BUSTYPE_NONSPI = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH,159 CHIP_BUSTYPE_UNKNOWN = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI,160 };161 162 /*163 * How many different contiguous runs of erase blocks with one size each do164 * we have for a given erase function?165 */166 #define NUM_ERASEREGIONS 5167 168 /*169 * How many different erase functions do we have per chip?170 */171 #define NUM_ERASEFUNCTIONS 5172 173 #define FEATURE_REGISTERMAP (1 << 0)174 #define FEATURE_BYTEWRITES (1 << 1)175 #define FEATURE_LONG_RESET (0 << 4)176 #define FEATURE_SHORT_RESET (1 << 4)177 #define FEATURE_EITHER_RESET FEATURE_LONG_RESET178 #define FEATURE_ADDR_FULL (0 << 2)179 #define FEATURE_ADDR_MASK (3 << 2)180 #define FEATURE_ADDR_2AA (1 << 2)181 #define FEATURE_ADDR_AAA (2 << 2)182 #define FEATURE_ADDR_SHIFTED (1 << 5)183 184 struct flashchip {185 const char *vendor;186 const char *name;187 188 enum chipbustype bustype;189 190 /*191 * With 32bit manufacture_id and model_id we can cover IDs up to192 * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's193 * Identification code.194 */195 uint32_t manufacture_id;196 uint32_t model_id;197 198 int total_size;199 int page_size;200 int feature_bits;201 202 /*203 * Indicate if flashrom has been tested with this flash chip and if204 * everything worked correctly.205 */206 uint32_t tested;207 208 int (*probe) (struct flashchip *flash);209 210 /* Delay after "enter/exit ID mode" commands in microseconds. */211 int probe_timing;212 213 /*214 * Erase blocks and associated erase function. Any chip erase function215 * is stored as chip-sized virtual block together with said function.216 */217 struct block_eraser {218 struct eraseblock{219 unsigned int size; /* Eraseblock size */220 unsigned int count; /* Number of contiguous blocks with that size */221 } eraseblocks[NUM_ERASEREGIONS];222 int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);223 } block_erasers[NUM_ERASEFUNCTIONS];224 225 int (*printlock) (struct flashchip *flash);226 int (*unlock) (struct flashchip *flash);227 int (*write) (struct flashchip *flash, uint8_t *buf);228 int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);229 230 /* Some flash devices have an additional register space. */231 chipaddr virtual_memory;232 chipaddr virtual_registers;233 };234 235 #define TEST_UNTESTED 0236 237 #define TEST_OK_PROBE (1 << 0)238 #define TEST_OK_READ (1 << 1)239 #define TEST_OK_ERASE (1 << 2)240 #define TEST_OK_WRITE (1 << 3)241 #define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ)242 #define TEST_OK_PRE (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE)243 #define TEST_OK_PRW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE)244 #define TEST_OK_PREW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE)245 #define TEST_OK_MASK 0x0f246 247 #define TEST_BAD_PROBE (1 << 4)248 #define TEST_BAD_READ (1 << 5)249 #define TEST_BAD_ERASE (1 << 6)250 #define TEST_BAD_WRITE (1 << 7)251 #define TEST_BAD_PREW (TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE)252 #define TEST_BAD_MASK 0xf0253 254 /* Timing used in probe routines. ZERO is -2 to differentiate between an unset255 * field and zero delay.256 *257 * SPI devices will always have zero delay and ignore this field.258 */259 #define TIMING_FIXME -1260 /* this is intentionally same value as fixme */261 #define TIMING_IGNORED -1262 #define TIMING_ZERO -2263 264 extern struct flashchip flashchips[];265 124 266 125 #if CONFIG_INTERNAL == 1 … … 320 179 extern const struct board_info boards_known[]; 321 180 extern const struct board_info laptops_known[]; 322 323 181 #endif 324 182 … … 330 188 #if NEED_PCI == 1 331 189 /* pcidev.c */ 332 333 190 extern uint32_t io_base_addr; 334 191 extern struct pci_access *pacc; … … 346 203 347 204 /* print.c */ 348 char *flashbuses_to_text(enum chipbustype bustype);349 void print_supported(void);350 205 #if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT >= 1 351 206 void print_supported_pcidevs(const struct pcidev_status *devs); 352 207 #endif 353 void print_supported_wiki(void);354 208 355 209 /* board_enable.c */ … … 575 429 576 430 /* flashrom.c */ 577 enum write_granularity {578 write_gran_1bit,579 write_gran_1byte,580 write_gran_256bytes,581 };582 extern enum chipbustype buses_supported;583 431 struct decode_sizes { 584 432 uint32_t parallel; … … 590 438 extern int programmer_may_write; 591 439 extern unsigned long flashbase; 592 extern int verbose;593 extern const char * const flashrom_version;594 extern char *chip_to_probe;595 void map_flash_registers(struct flashchip *flash);596 int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);597 int erase_flash(struct flashchip *flash);598 struct flashchip *probe_flash(struct flashchip *first_flash, int force);599 int read_flash_to_file(struct flashchip *flash, char *filename);600 440 void check_chip_supported(struct flashchip *flash); 601 441 int check_max_decode(enum chipbustype buses, uint32_t size); 602 int min(int a, int b);603 int max(int a, int b);604 char *extract_param(char **haystack, char *needle, char *delim);605 442 char *extract_programmer_param(char *param_name); 606 int check_erased_range(struct flashchip *flash, int start, int len);607 int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message);608 int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);609 char *strcat_realloc(char *dest, const char *src);610 void print_version(void);611 void print_banner(void);612 int selfcheck(void);613 int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it);614 615 #define OK 0616 #define NT 1 /* Not tested */617 618 /* Something happened that shouldn't happen, but we can go on */619 #define ERROR_NONFATAL 0x100620 621 /* cli_output.c */622 /* Let gcc and clang check for correct printf-style format strings. */623 int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3)));624 #define MSG_ERROR 0625 #define MSG_INFO 1626 #define MSG_DEBUG 2627 #define MSG_BARF 3628 #define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */629 #define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */630 #define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */631 #define msg_ginfo(...) print(MSG_INFO, __VA_ARGS__) /* general info */632 #define msg_pinfo(...) print(MSG_INFO, __VA_ARGS__) /* programmer info */633 #define msg_cinfo(...) print(MSG_INFO, __VA_ARGS__) /* chip info */634 #define msg_gdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* general debug */635 #define msg_pdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* programmer debug */636 #define msg_cdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* chip debug */637 #define msg_gspew(...) print(MSG_BARF, __VA_ARGS__) /* general debug barf */638 #define msg_pspew(...) print(MSG_BARF, __VA_ARGS__) /* programmer debug barf */639 #define msg_cspew(...) print(MSG_BARF, __VA_ARGS__) /* chip debug barf */640 641 /* cli_classic.c */642 int cli_classic(int argc, char *argv[]);643 443 644 444 /* layout.c */ 645 445 int show_id(uint8_t *bios, int size, int force); 646 int read_romlayout(char *name);647 int find_romentry(char *name);648 int handle_romentries(uint8_t *buffer, struct flashchip *flash);649 446 650 447 /* spi.c */ … … 679 476 }; 680 477 extern const int spi_programmer_count; 681 struct spi_command {682 unsigned int writecnt;683 unsigned int readcnt;684 const unsigned char *writearr;685 unsigned char *readarr;686 };687 478 struct spi_programmer { 688 479 int (*command)(unsigned int writecnt, unsigned int readcnt, … … 697 488 extern enum spi_controller spi_controller; 698 489 extern const struct spi_programmer spi_programmer[]; 699 int spi_send_command(unsigned int writecnt, unsigned int readcnt,700 const unsigned char *writearr, unsigned char *readarr);701 int spi_send_multicommand(struct spi_command *cmds);702 490 int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, 703 491 const unsigned char *writearr, unsigned char *readarr); 704 492 int default_spi_send_multicommand(struct spi_command *cmds); 705 uint32_t spi_get_valid_read_addr(void);706 493 707 494 /* ichspi.c */ … … 769 556 int serialport_read(unsigned char *buf, unsigned int readcnt); 770 557 771 #endif /* !__ FLASH_H__ */558 #endif /* !__PROGRAMMER_H__ */
Note: See TracChangeset
for help on using the changeset viewer.
