[LinuxBIOS] flash_and_burn fixes.

Stefan Reinauer stepan at openbios.org
Sat Nov 12 16:43:50 CET 2005


Hi,

flash_and_burn does not compile in gcc 4 anymore since it comes
with -Werror. This makes sense since it is touching a very sensitive
part of a system :-)

Since gcc 4 warns a lot more about signed/unsigned pointer confusion
I changed major parts of flash_and_burn to use unsigned pointers only.
We are coping with data, so signedness is not interesting in the code.
In fact it might rather hurt.

I'll apply the patch to the repository shortly, when someone signs it
off. 

Other questions: 
 - Can we drop flash_on? The code seems included in flash_rom and it
   only works on old sis stuff anyways. We will not drop functionality 
   by dropping this extra binary.

 - Should we rename the utility to flash_and_burn or should we rename
   the directory to flash_rom? There's a lot of confusion since the
   utility and it's location in the source tree have different names.

Stefan


-------------- next part --------------
Index: LinuxBIOSv2/util/flash_and_burn/pm49fl004.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/pm49fl004.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/pm49fl004.c	(working copy)
@@ -34,7 +34,7 @@
 	int i;
 	int total_size = flash->total_size * 1024, page_size =
 		flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 	
 	printf("Programming Page: ");
 	for (i = 0; i < total_size / page_size; i++) {
Index: LinuxBIOSv2/util/flash_and_burn/sst39sf020.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/sst39sf020.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/sst39sf020.c	(working copy)
@@ -35,7 +35,7 @@
 #define AUTO_PG_ERASE1		0x20
 #define AUTO_PG_ERASE2		0xD0
 
-static __inline__ int erase_sector_39sf020(volatile char *bios,
+static __inline__ int erase_sector_39sf020(volatile unsigned char *bios,
 					   unsigned long address)
 {
 	*bios = AUTO_PG_ERASE1;
@@ -52,7 +52,7 @@
 	int i;
 	int total_size = flash->total_size * 1024, page_size =
 		flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	erase_chip_jedec(flash);
 
Index: LinuxBIOSv2/util/flash_and_burn/flash.h
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/flash.h	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/flash.h	(working copy)
@@ -9,7 +9,7 @@
 	int manufacture_id;
 	int model_id;
 
-	volatile char *virt_addr;
+	volatile unsigned char *virt_addr;
 	int total_size;
 	int page_size;
 
@@ -19,7 +19,7 @@
 	int (*read) (struct flashchip * flash, unsigned char *buf);
 
 	int fd_mem;
-	volatile char *virt_addr_2;
+	volatile unsigned char *virt_addr_2;
 };
 
 #define AMD_ID            0x01
Index: LinuxBIOSv2/util/flash_and_burn/jedec.h
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/jedec.h	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/jedec.h	(working copy)
@@ -12,7 +12,7 @@
 			      volatile unsigned char *dst,
 			      unsigned int page_size);
 
-extern __inline__ void toggle_ready_jedec(volatile char *dst)
+extern __inline__ void toggle_ready_jedec(volatile unsigned char *dst)
 {
 	unsigned int i = 0;
 	char tmp1, tmp2;
@@ -28,10 +28,10 @@
 	}
 }
 
-extern __inline__ void data_polling_jedec(volatile char *dst, char data)
+extern __inline__ void data_polling_jedec(volatile unsigned char *dst, unsigned char data)
 {
 	unsigned int i = 0;
-	char tmp;
+	unsigned char tmp;
 
 	data &= 0x80;
 
@@ -43,23 +43,23 @@
 	}
 }
 
-extern __inline__ void unprotect_jedec(volatile char *bios)
+extern __inline__ void unprotect_jedec(volatile unsigned char *bios)
 {
-	*(volatile char *) (bios + 0x5555) = 0xAA;
-	*(volatile char *) (bios + 0x2AAA) = 0x55;
-	*(volatile char *) (bios + 0x5555) = 0x80;
-	*(volatile char *) (bios + 0x5555) = 0xAA;
-	*(volatile char *) (bios + 0x2AAA) = 0x55;
-	*(volatile char *) (bios + 0x5555) = 0x20;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+	*(volatile unsigned char *) (bios + 0x5555) = 0x80;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+	*(volatile unsigned char *) (bios + 0x5555) = 0x20;
 
 	usleep(200);
 }
 
-extern __inline__ void protect_jedec(volatile char *bios)
+extern __inline__ void protect_jedec(volatile unsigned char *bios)
 {
-	*(volatile char *) (bios + 0x5555) = 0xAA;
-	*(volatile char *) (bios + 0x2AAA) = 0x55;
-	*(volatile char *) (bios + 0x5555) = 0xA0;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xA0;
 
 	usleep(200);
 }
Index: LinuxBIOSv2/util/flash_and_burn/sst28sf040.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/sst28sf040.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/sst28sf040.c	(working copy)
@@ -36,7 +36,7 @@
 #define RESET			0xFF
 #define READ_ID			0x90
 
-static __inline__ void protect_28sf040(volatile char *bios)
+static __inline__ void protect_28sf040(volatile unsigned char *bios)
 {
 	/* ask compiler not to optimize this */
 	volatile unsigned char tmp;
@@ -50,7 +50,7 @@
 	tmp = *(volatile unsigned char *) (bios + 0x040A);
 }
 
-static __inline__ void unprotect_28sf040(volatile char *bios)
+static __inline__ void unprotect_28sf040(volatile unsigned char *bios)
 {
 	/* ask compiler not to optimize this */
 	volatile unsigned char tmp;
@@ -64,7 +64,7 @@
 	tmp = *(volatile unsigned char *) (bios + 0x041A);
 }
 
-static __inline__ int erase_sector_28sf040(volatile char *bios,
+static __inline__ int erase_sector_28sf040(volatile unsigned char *bios,
 					   unsigned long address)
 {
 	*bios = AUTO_PG_ERASE1;
@@ -76,7 +76,7 @@
 	return (0);
 }
 
-static __inline__ int write_sector_28sf040(volatile char *bios,
+static __inline__ int write_sector_28sf040(volatile unsigned char *bios,
 					   unsigned char *src,
 					   volatile unsigned char *dst,
 					   unsigned int page_size)
@@ -103,7 +103,7 @@
 
 int probe_28sf040(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 	unsigned char id1, id2, tmp;
 
 	/* save the value at the beginning of the Flash */
@@ -132,7 +132,7 @@
 
 int erase_28sf040(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	unprotect_28sf040(bios);
 	*bios = CHIP_ERASE;
@@ -150,7 +150,7 @@
 	int i;
 	int total_size = flash->total_size * 1024, page_size =
 	    flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	unprotect_28sf040(bios);
 
Index: LinuxBIOSv2/util/flash_and_burn/w49f002u.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/w49f002u.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/w49f002u.c	(working copy)
@@ -37,7 +37,7 @@
 	int i;
 	int total_size = flash->total_size * 1024, page_size =
 		flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	erase_chip_jedec(flash);
 
Index: LinuxBIOSv2/util/flash_and_burn/am29f040b.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/am29f040b.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/am29f040b.c	(working copy)
@@ -28,7 +28,7 @@
 #include "flash.h"
 #include "jedec.h"
 
-static __inline__ int erase_sector_29f040b(volatile char *bios,
+static __inline__ int erase_sector_29f040b(volatile unsigned char *bios,
 					   unsigned long address)
 {
 	*(bios + 0x555) = 0xAA;
@@ -46,7 +46,7 @@
 	return (0);
 }
 
-static __inline__ int write_sector_29f040b(volatile char *bios,
+static __inline__ int write_sector_29f040b(volatile unsigned char *bios,
 					   unsigned char *src,
 					   volatile unsigned char *dst,
 					   unsigned int page_size)
@@ -116,7 +116,7 @@
 	int i;
 	int total_size = flash->total_size * 1024, page_size =
 	    flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	printf("Programming Page: ");
 	for (i = 0; i < total_size / page_size; i++) {
Index: LinuxBIOSv2/util/flash_and_burn/flash_rom.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/flash_rom.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/flash_rom.c	(working copy)
@@ -103,7 +103,7 @@
 struct flashchip *probe_flash(struct flashchip *flash)
 {
 	int fd_mem;
-	volatile char *bios;
+	volatile unsigned char *bios;
 	unsigned long size;
 
 	if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
@@ -146,11 +146,11 @@
 	return NULL;
 }
 
-int verify_flash(struct flashchip *flash, char *buf, int verbose)
+int verify_flash(struct flashchip *flash, unsigned char *buf, int verbose)
 {
 	int i;
 	int total_size = flash->total_size * 1024;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	printf("Verifying address: ");
 	for (i = 0; i < total_size; i++) {
@@ -189,7 +189,7 @@
 
 int main(int argc, char *argv[])
 {
-	char *buf;
+	unsigned char *buf;
 	unsigned long size;
 	FILE *image;
 	struct flashchip *flash;
@@ -275,7 +275,7 @@
 		return 0;
 	}
 	size = flash->total_size * 1024;
-	buf = (char *) calloc(size, sizeof(char));
+	buf = (unsigned char *) calloc(size, sizeof(char));
 
 	if (erase_it) {
 		printf("Erasing flash chip\n");
Index: LinuxBIOSv2/util/flash_and_burn/msys_doc.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/msys_doc.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/msys_doc.c	(working copy)
@@ -30,11 +30,11 @@
 
 
 
-static int doc_wait(volatile char *bios, int timeout);
-static unsigned char doc_read_chipid(volatile char *bios);
-static unsigned char doc_read_docstatus(volatile char *bios);
-static unsigned char doc_read_cdsncontrol(volatile char *bios);
-static void doc_write_cdsncontrol(volatile char *bios, unsigned char data);
+static int doc_wait(volatile unsigned char *bios, int timeout);
+static unsigned char doc_read_chipid(volatile unsigned char *bios);
+static unsigned char doc_read_docstatus(volatile unsigned char *bios);
+static unsigned char doc_read_cdsncontrol(volatile unsigned char *bios);
+static void doc_write_cdsncontrol(volatile unsigned char *bios, unsigned char data);
 
 
 
@@ -42,7 +42,7 @@
 
 int probe_md2802(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 	unsigned char chipid;
 #ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
 	unsigned char id_0x55, id_0xAA;
@@ -165,16 +165,16 @@
 
 int erase_md2802(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	return (1);
-	*(volatile char *) (bios + 0x5555) = 0xAA;
-	*(volatile char *) (bios + 0x2AAA) = 0x55;
-	*(volatile char *) (bios + 0x5555) = 0x80;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+	*(volatile unsigned char *) (bios + 0x5555) = 0x80;
 
-	*(volatile char *) (bios + 0x5555) = 0xAA;
-	*(volatile char *) (bios + 0x2AAA) = 0x55;
-	*(volatile char *) (bios + 0x5555) = 0x10;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+	*(volatile unsigned char *) (bios + 0x5555) = 0x10;
 }				/* int erase_md2802(struct flashchip *flash) */
 
 
@@ -216,7 +216,7 @@
 		0: ready
 		-1: timeout expired
 */
-static int doc_wait(volatile char *bios, int timeout)
+static int doc_wait(volatile unsigned char *bios, int timeout)
 {
 	int i = 20;
 
@@ -239,7 +239,7 @@
 
 
 
-static unsigned char doc_read_docstatus(volatile char *bios)
+static unsigned char doc_read_docstatus(volatile unsigned char *bios)
 {
 	doc_read(bios, CDSNSlowIO);
 	doc_read_2nop(bios);
@@ -249,7 +249,7 @@
 
 
 
-static unsigned char doc_read_chipid(volatile char *bios)
+static unsigned char doc_read_chipid(volatile unsigned char *bios)
 {
 	doc_read(bios, CDSNSlowIO);
 	doc_read_2nop(bios);
@@ -259,7 +259,7 @@
 
 
 
-static unsigned char doc_read_cdsncontrol(volatile char *bios)
+static unsigned char doc_read_cdsncontrol(volatile unsigned char *bios)
 {
 	unsigned char value;
 
@@ -275,7 +275,7 @@
 
 
 
-static void doc_write_cdsncontrol(volatile char *bios, unsigned char data)
+static void doc_write_cdsncontrol(volatile unsigned char *bios, unsigned char data)
 {
 	doc_write(data, bios, _CDSNControl);
 	doc_read_4nop(bios);
Index: LinuxBIOSv2/util/flash_and_burn/82802ab.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/82802ab.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/82802ab.c	(working copy)
@@ -161,7 +161,7 @@
 	return (0);
 }
 
-void write_page_82802ab(volatile char *bios, char *src, volatile char *dst,
+void write_page_82802ab(volatile unsigned char *bios, unsigned char *src, volatile unsigned char *dst,
 			int page_size)
 {
 	int i;
Index: LinuxBIOSv2/util/flash_and_burn/m29f400bt.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/m29f400bt.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/m29f400bt.c	(working copy)
@@ -29,21 +29,21 @@
 
 int probe_m29f400bt(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 	unsigned char id1, id2;
 
-	*(volatile char *) (bios + 0xAAA) = 0xAA;
-	*(volatile char *) (bios + 0x555) = 0x55;
-	*(volatile char *) (bios + 0xAAA) = 0x90;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x555) = 0x55;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0x90;
 
 	myusec_delay(10);
 
 	id1 = *(volatile unsigned char *) bios;
 	id2 = *(volatile unsigned char *) (bios + 0x02);
 
-	*(volatile char *) (bios + 0xAAA) = 0xAA;
-	*(volatile char *) (bios + 0x555) = 0x55;
-	*(volatile char *) (bios + 0xAAA) = 0xF0;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x555) = 0x55;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xF0;
 
 	myusec_delay(10);
 
@@ -58,15 +58,15 @@
 
 int erase_m29f400bt(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
-	*(volatile char *) (bios + 0xAAA) = 0xAA;
-	*(volatile char *) (bios + 0x555) = 0x55;
-	*(volatile char *) (bios + 0xAAA) = 0x80;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x555) = 0x55;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0x80;
 
-	*(volatile char *) (bios + 0xAAA) = 0xAA;
-	*(volatile char *) (bios + 0x555) = 0x55;
-	*(volatile char *) (bios + 0xAAA) = 0x10;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x555) = 0x55;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0x10;
 
 	myusec_delay(10);
 	toggle_ready_m29f400bt(bios);
@@ -74,16 +74,16 @@
 	return (0);
 }
 
-int block_erase_m29f400bt(volatile char *bios, volatile char *dst)
+int block_erase_m29f400bt(volatile unsigned char *bios, volatile unsigned char *dst)
 {
 
-	*(volatile char *) (bios + 0xAAA) = 0xAA;
-	*(volatile char *) (bios + 0x555) = 0x55;
-	*(volatile char *) (bios + 0xAAA) = 0x80;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x555) = 0x55;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0x80;
 
-	*(volatile char *) (bios + 0xAAA) = 0xAA;
-	*(volatile char *) (bios + 0x555) = 0x55;
-	//*(volatile char *) (bios + 0xAAA) = 0x10;
+	*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x555) = 0x55;
+	//*(volatile unsigned char *) (bios + 0xAAA) = 0x10;
 	*dst = 0x30;
 
 	myusec_delay(10);
@@ -97,7 +97,7 @@
 	int i;
 	int total_size = flash->total_size * 1024, page_size =
 	    flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	//erase_m29f400bt (flash);
 	printf("Programming Page:\n ");
@@ -154,7 +154,7 @@
 
 int write_linuxbios_m29f400bt(struct flashchip *flash, unsigned char *buf)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	printf("Programming Page:\n ");
 	/*********************************
Index: LinuxBIOSv2/util/flash_and_burn/mx29f002.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/mx29f002.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/mx29f002.c	(working copy)
@@ -32,7 +32,7 @@
 
 int probe_29f002(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 	unsigned char id1, id2;
 
 	*(bios + 0x5555) = 0xAA;
@@ -55,7 +55,7 @@
 
 int erase_29f002(struct flashchip *flash)
 {
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	*(bios + 0x555) = 0xF0;
 	*(bios + 0x555) = 0xAA;
@@ -88,8 +88,8 @@
 {
 	int i;
 	int total_size = flash->total_size * 1024;
-	volatile char *bios = flash->virt_addr;
-	volatile char *dst = bios;
+	volatile unsigned char *bios = flash->virt_addr;
+	volatile unsigned char *dst = bios;
 
 	*bios = 0xF0;
 	myusec_delay(10);
Index: LinuxBIOSv2/util/flash_and_burn/82802ab.h
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/82802ab.h	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/82802ab.h	(working copy)
@@ -5,10 +5,10 @@
 extern int erase_82802ab(struct flashchip *flash);
 extern int write_82802ab(struct flashchip *flash, unsigned char *buf);
 
-extern __inline__ void toggle_ready_82802ab(volatile char *dst)
+extern __inline__ void toggle_ready_82802ab(volatile unsigned char *dst)
 {
 	unsigned int i = 0;
-	char tmp1, tmp2;
+	unsigned char tmp1, tmp2;
 
 	tmp1 = *dst & 0x40;
 
@@ -21,10 +21,10 @@
 	}
 }
 
-extern __inline__ void data_polling_82802ab(volatile char *dst, char data)
+extern __inline__ void data_polling_82802ab(volatile unsigned char *dst, unsigned char data)
 {
 	unsigned int i = 0;
-	char tmp;
+	unsigned char tmp;
 
 	data &= 0x80;
 
@@ -36,11 +36,11 @@
 	}
 }
 
-extern __inline__ void protect_82802ab(volatile char *bios)
+extern __inline__ void protect_82802ab(volatile unsigned char *bios)
 {
-	*(volatile char *) (bios + 0x5555) = 0xAA;
-	*(volatile char *) (bios + 0x2AAA) = 0x55;
-	*(volatile char *) (bios + 0x5555) = 0xA0;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+	*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+	*(volatile unsigned char *) (bios + 0x5555) = 0xA0;
 
 	usleep(200);
 }
Index: LinuxBIOSv2/util/flash_and_burn/m29f400bt.h
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/m29f400bt.h	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/m29f400bt.h	(working copy)
@@ -5,15 +5,15 @@
 
 extern int probe_m29f400bt(struct flashchip *flash);
 extern int erase_m29f400bt(struct flashchip *flash);
-extern int block_erase_m29f400bt(volatile char *bios, volatile char *dst);
+extern int block_erase_m29f400bt(volatile unsigned char *bios, volatile unsigned char *dst);
 extern int write_m29f400bt(struct flashchip *flash, unsigned char *buf);
 extern int write_linuxbios_m29f400bt(struct flashchip *flash,
 				     unsigned char *buf);
 
-extern __inline__ void toggle_ready_m29f400bt(volatile char *dst)
+extern __inline__ void toggle_ready_m29f400bt(volatile unsigned char *dst)
 {
 	unsigned int i = 0;
-	char tmp1, tmp2;
+	unsigned char tmp1, tmp2;
 
 	tmp1 = *dst & 0x40;
 
@@ -26,11 +26,11 @@
 	}
 }
 
-extern __inline__ void data_polling_m29f400bt(volatile char *dst,
+extern __inline__ void data_polling_m29f400bt(volatile unsigned char *dst,
 					      unsigned char data)
 {
 	unsigned int i = 0;
-	char tmp;
+	unsigned char tmp;
 
 	data &= 0x80;
 
@@ -51,16 +51,16 @@
 	usleep(200);
 }
 
-extern __inline__ void write_page_m29f400bt(volatile char *bios, char *src,
-					    volatile char *dst,
+extern __inline__ void write_page_m29f400bt(volatile unsigned char *bios, unsigned char *src,
+					    volatile unsigned char *dst,
 					    int page_size)
 {
 	int i;
 
 	for (i = 0; i < page_size; i++) {
-		*(volatile char *) (bios + 0xAAA) = 0xAA;
-		*(volatile char *) (bios + 0x555) = 0x55;
-		*(volatile char *) (bios + 0xAAA) = 0xA0;
+		*(volatile unsigned char *) (bios + 0xAAA) = 0xAA;
+		*(volatile unsigned char *) (bios + 0x555) = 0x55;
+		*(volatile unsigned char *) (bios + 0xAAA) = 0xA0;
 
 		/* transfer data from source to destination */
 		*dst = *src;
@@ -69,7 +69,7 @@
 		toggle_ready_m29f400bt(dst);
 		printf
 		    ("Value in the flash at address %p = %#x, want %#x\n",
-		     (char *) (dst - bios), *dst, *src);
+		     (unsigned char *) (dst - bios), *dst, *src);
 		dst++;
 		src++;
 	}
Index: LinuxBIOSv2/util/flash_and_burn/sst49lf040.c
===================================================================
--- LinuxBIOSv2/util/flash_and_burn/sst49lf040.c	(revision 2084)
+++ LinuxBIOSv2/util/flash_and_burn/sst49lf040.c	(working copy)
@@ -35,7 +35,7 @@
         int i;
         int total_size = flash->total_size * 1024;
         int page_size = flash->page_size;
-        volatile char *bios = flash->virt_addr;
+        volatile unsigned char *bios = flash->virt_addr;
 
         for (i = 0; i < total_size / page_size; i++) {
 		/* Chip erase only works in parallel programming mode
@@ -50,7 +50,7 @@
 	int i;
 	int total_size = flash->total_size * 1024;
 	int page_size = flash->page_size;
-	volatile char *bios = flash->virt_addr;
+	volatile unsigned char *bios = flash->virt_addr;
 
 	printf("Programming Page: ");
 	for (i = 0; i < total_size / page_size; i++) {


More information about the coreboot mailing list