mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-04 07:00:39 +01:00 
			
		
		
		
	Tyan update to work with new CPU Config
Corresponding to flashrom svn r26 and coreboot v2 svn r1693.
This commit is contained in:
		
							
								
								
									
										70
									
								
								flash_rom.c
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								flash_rom.c
									
									
									
									
									
								
							@@ -3,6 +3,8 @@
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright 2000 Silicon Integrated System Corporation
 | 
			
		||||
 * Copyright 2004 Tyan Corp
 | 
			
		||||
 *	yhlu yhlu@tyan.com add exclude start and end option
 | 
			
		||||
 *
 | 
			
		||||
 *	This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *	it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -49,6 +51,7 @@
 | 
			
		||||
#include "sst_fwhub.h"
 | 
			
		||||
 | 
			
		||||
struct flashchip flashchips[] = {
 | 
			
		||||
#if 1
 | 
			
		||||
	{"Am29F040B",	AMD_ID, 	AM_29F040B,	NULL, 512, 64 * 1024,
 | 
			
		||||
	 probe_29f040b, erase_29f040b,	write_29f040b,	NULL},
 | 
			
		||||
	{"At29C040A",	ATMEL_ID,	AT_29C040A,	NULL, 512, 256,
 | 
			
		||||
@@ -75,8 +78,10 @@ struct flashchip flashchips[] = {
 | 
			
		||||
	 probe_jedec,	erase_chip_jedec, write_49lf040,NULL},
 | 
			
		||||
	{"SST49LF008A", SST_ID,		SST_49LF008A, 	NULL, 1024, 4096,
 | 
			
		||||
	 probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, NULL},
 | 
			
		||||
#endif
 | 
			
		||||
	{"Pm49FL004",	PMC_ID,		PMC_49FL004,	NULL, 512, 64 * 1024,
 | 
			
		||||
	 probe_jedec,	erase_chip_jedec, write_49fl004,NULL},
 | 
			
		||||
#if 1
 | 
			
		||||
	{"W29C011",	WINBOND_ID,	W_29C011,	NULL, 128, 128,
 | 
			
		||||
	 probe_jedec,	erase_chip_jedec, write_jedec,	NULL},
 | 
			
		||||
	{"W29C020C", 	WINBOND_ID, 	W_29C020C,	NULL, 256, 128,
 | 
			
		||||
@@ -93,6 +98,7 @@ struct flashchip flashchips[] = {
 | 
			
		||||
	 MSYSTEMS_ID, MSYSTEMS_MD2802,
 | 
			
		||||
	 NULL, 8, 8 * 1024,
 | 
			
		||||
	 probe_md2802, erase_md2802, write_md2802, read_md2802},
 | 
			
		||||
#endif
 | 
			
		||||
	{NULL,}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -171,16 +177,20 @@ int verify_flash(struct flashchip *flash, char *buf, int verbose)
 | 
			
		||||
 | 
			
		||||
void usage(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	printf("usage: %s [-rwv] [-c chipname][file]\n", name);
 | 
			
		||||
	printf("usage: %s [-rwv] [-c chipname] [-s exclude_start] [-e exclude_end] [file]\n", name);
 | 
			
		||||
	printf("-r: read flash and save into file\n"
 | 
			
		||||
	       "-w: write file into flash (default when file is specified)\n"
 | 
			
		||||
	       "-v: verify flash against file\n"
 | 
			
		||||
	       "-c: probe only for specified flash chip\n"
 | 
			
		||||
	       "-s: exclude start position\n"
 | 
			
		||||
	       "-e: exclude end postion\n"
 | 
			
		||||
	       " If no file is specified, then all that happens\n"
 | 
			
		||||
	       " is that flash info is dumped\n");
 | 
			
		||||
	exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int exclude_start_page, exclude_end_page;
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	char *buf;
 | 
			
		||||
@@ -191,9 +201,34 @@ int main(int argc, char *argv[])
 | 
			
		||||
	int read_it = 0, write_it = 0, verify_it = 0, verbose = 0;
 | 
			
		||||
	char *filename = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        unsigned int exclude_start_position=0, exclude_end_position=0; // [x,y)
 | 
			
		||||
	char *tempstr=NULL;
 | 
			
		||||
#if 0
 | 
			
		||||
 | 
			
		||||
#if 1
 | 
			
		||||
	/* Keep fallback image */
 | 
			
		||||
	exclude_start_position = 0x60000;
 | 
			
		||||
	exclude_end_position = 0x80000;
 | 
			
		||||
#else 
 | 
			
		||||
	/* Keep DMI etc. */
 | 
			
		||||
        exclude_start_position = 0x60000;
 | 
			
		||||
        exclude_end_position = 0x70000;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (argc > 1) {
 | 
			
		||||
		/* Yes, print them. */
 | 
			
		||||
		int i;
 | 
			
		||||
		printf ("The arguments are:\n");
 | 
			
		||||
		for (i = 1; i < argc; ++i)
 | 
			
		||||
			printf ("%s\n", argv[i]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	setbuf(stdout, NULL);
 | 
			
		||||
 | 
			
		||||
	while ((opt = getopt(argc, argv, "rwvVc:")) != EOF) {
 | 
			
		||||
	while ((opt = getopt(argc, argv, "rwvVc:s:e:")) != EOF) {
 | 
			
		||||
		switch (opt) {
 | 
			
		||||
		case 'r':
 | 
			
		||||
			read_it = 1;
 | 
			
		||||
@@ -210,11 +245,22 @@ int main(int argc, char *argv[])
 | 
			
		||||
		case 'V':
 | 
			
		||||
			verbose = 1;
 | 
			
		||||
			break;
 | 
			
		||||
		case 's':
 | 
			
		||||
			tempstr = strdup(optarg);
 | 
			
		||||
			sscanf(tempstr,"%x",&exclude_start_position);
 | 
			
		||||
			break;
 | 
			
		||||
		case 'e':
 | 
			
		||||
                        tempstr = strdup(optarg);
 | 
			
		||||
                        sscanf(tempstr,"%x",&exclude_end_position);
 | 
			
		||||
                        break;
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
			usage(argv[0]);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (read_it && write_it) {
 | 
			
		||||
		printf("-r and -w are mutually exclusive\n");
 | 
			
		||||
		usage(argv[0]);
 | 
			
		||||
@@ -239,7 +285,8 @@ int main(int argc, char *argv[])
 | 
			
		||||
 | 
			
		||||
	printf("Part is %s\n", flash->name);
 | 
			
		||||
	if (!filename) {
 | 
			
		||||
		printf("OK, only ENABLING flash write, but NOT FLASHING\n");
 | 
			
		||||
		printf
 | 
			
		||||
		    ("OK, only ENABLING flash write, but NOT FLASHING\n");
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	size = flash->total_size * 1024;
 | 
			
		||||
@@ -255,6 +302,10 @@ int main(int argc, char *argv[])
 | 
			
		||||
			memcpy(buf, (const char *) flash->virt_addr, size);
 | 
			
		||||
		else
 | 
			
		||||
			flash->read(flash, buf);
 | 
			
		||||
 | 
			
		||||
	        if(exclude_end_position - exclude_start_position > 0)  
 | 
			
		||||
	                memset(buf+exclude_start_position, 0, exclude_end_position-exclude_start_position);
 | 
			
		||||
 | 
			
		||||
		fwrite(buf, sizeof(char), size, image);
 | 
			
		||||
		fclose(image);
 | 
			
		||||
		printf("done\n");
 | 
			
		||||
@@ -267,8 +318,19 @@ int main(int argc, char *argv[])
 | 
			
		||||
		fclose(image);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (write_it || (!read_it && !verify_it))
 | 
			
		||||
	if(exclude_end_position - exclude_start_position > 0) 
 | 
			
		||||
        	memcpy(buf+exclude_start_position, (const char *) flash->virt_addr+exclude_start_position, 
 | 
			
		||||
			exclude_end_position-exclude_start_position);
 | 
			
		||||
        
 | 
			
		||||
        exclude_start_page = exclude_start_position/flash->page_size;
 | 
			
		||||
        if((exclude_start_position%flash->page_size) != 0) { 
 | 
			
		||||
                exclude_start_page++;
 | 
			
		||||
        }       
 | 
			
		||||
        exclude_end_page = exclude_end_position/flash->page_size;
 | 
			
		||||
 | 
			
		||||
	if (write_it || (!read_it && !verify_it)) {
 | 
			
		||||
		flash->write(flash, buf);
 | 
			
		||||
	}	
 | 
			
		||||
	if (verify_it)
 | 
			
		||||
		verify_flash(flash, buf, verbose);
 | 
			
		||||
	return 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright 2004 Tyan Corporation
 | 
			
		||||
 *	yhlu yhlu@tyan.com add exclude range
 | 
			
		||||
 *
 | 
			
		||||
 *	This program is free software; you can redistribute it and/or modify
 | 
			
		||||
 *	it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -55,15 +56,21 @@ static __inline__ int erase_block_49fl004(volatile unsigned char *bios,
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
extern int exclude_start_page, exclude_end_page;
 | 
			
		||||
 | 
			
		||||
int write_49fl004(struct flashchip *flash, unsigned char *buf)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	int total_size = flash->total_size * 1024, page_size =
 | 
			
		||||
	    flash->page_size;
 | 
			
		||||
	volatile char *bios = flash->virt_addr;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	printf("Programming Page: ");
 | 
			
		||||
	for (i = 0; i < total_size / page_size; i++) {
 | 
			
		||||
		if( (i>=exclude_start_page) && (i<exclude_end_page)) 	
 | 
			
		||||
			continue;
 | 
			
		||||
		
 | 
			
		||||
		/* erase the page before programming */
 | 
			
		||||
		erase_block_49fl004(bios, i * page_size);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user