fixed 32bit v.s. 64bit long int arithematics
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1434 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
698f23db22
commit
26b237ee18
|
@ -115,8 +115,7 @@ struct flashchip * probe_flash(struct flashchip * flash)
|
||||||
flash->total_size * 1024, (unsigned long)size);
|
flash->total_size * 1024, (unsigned long)size);
|
||||||
}
|
}
|
||||||
bios = mmap (0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
bios = mmap (0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||||
//fd_mem, (off_t) (0x100000000-size));
|
fd_mem, (off_t) (0xffffffff - size + 1));
|
||||||
fd_mem, (off_t) (0xffffffff-size+1));
|
|
||||||
if (bios == MAP_FAILED) {
|
if (bios == MAP_FAILED) {
|
||||||
perror("Error MMAP /dev/mem");
|
perror("Error MMAP /dev/mem");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -126,7 +125,7 @@ struct flashchip * probe_flash(struct flashchip * flash)
|
||||||
|
|
||||||
if (flash->probe(flash) == 1) {
|
if (flash->probe(flash) == 1) {
|
||||||
printf ("%s found at physical address: 0x%lx\n",
|
printf ("%s found at physical address: 0x%lx\n",
|
||||||
flash->name, (0 - size));
|
flash->name, (0xffffffff - size + 1));
|
||||||
return flash;
|
return flash;
|
||||||
}
|
}
|
||||||
munmap ((void *) bios, size);
|
munmap ((void *) bios, size);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#define AUTO_PG_ERASE1 0x20
|
#define AUTO_PG_ERASE1 0x20
|
||||||
#define AUTO_PG_ERASE2 0xD0
|
#define AUTO_PG_ERASE2 0xD0
|
||||||
#define AUTO_PGRM 0x10
|
#define AUTO_PGRM 0x10
|
||||||
#define CHIP_ERASE 0x30
|
#define CHIP_ERASE 0x30
|
||||||
#define RESET 0xFF
|
#define RESET 0xFF
|
||||||
#define READ_ID 0x90
|
#define READ_ID 0x90
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
* Reference:
|
* Reference:
|
||||||
* 4 MEgabit (512K x 8) SuperFlash EEPROM, SST28SF040 data sheet
|
* 4 MEgabit (512K x 8) SuperFlash EEPROM, SST28SF040 data sheet
|
||||||
*
|
*
|
||||||
|
* ToDo: Consilidated to standard JEDEC code.
|
||||||
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,34 +39,6 @@
|
||||||
#define RESET 0xFF
|
#define RESET 0xFF
|
||||||
#define READ_ID 0x90
|
#define READ_ID 0x90
|
||||||
|
|
||||||
static __inline__ void protect_39sf020 (volatile char * bios)
|
|
||||||
{
|
|
||||||
/* ask compiler not to optimize this */
|
|
||||||
volatile unsigned char tmp;
|
|
||||||
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x1823);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x1820);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x1822);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x0418);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x041B);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x0419);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x040A);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline__ void unprotect_39sf020 (volatile char * bios)
|
|
||||||
{
|
|
||||||
/* ask compiler not to optimize this */
|
|
||||||
volatile unsigned char tmp;
|
|
||||||
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x1823);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x1820);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x1822);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x0418);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x041B);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x0419);
|
|
||||||
tmp = *(volatile unsigned char *) (bios + 0x041A);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline__ int erase_sector_39sf020 (volatile char * bios, unsigned long address)
|
static __inline__ int erase_sector_39sf020 (volatile char * bios, unsigned long address)
|
||||||
{
|
{
|
||||||
*bios = AUTO_PG_ERASE1;
|
*bios = AUTO_PG_ERASE1;
|
||||||
|
@ -77,9 +51,9 @@ static __inline__ int erase_sector_39sf020 (volatile char * bios, unsigned long
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int write_sector_39sf020(volatile char * bios,
|
static __inline__ int write_sector_39sf020(volatile char * bios,
|
||||||
unsigned char * src,
|
unsigned char * src,
|
||||||
volatile unsigned char * dst,
|
volatile unsigned char * dst,
|
||||||
unsigned int page_size)
|
unsigned int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
volatile char *Temp;
|
volatile char *Temp;
|
||||||
|
@ -177,8 +151,8 @@ int write_39sf020 (struct flashchip * flash, unsigned char * buf)
|
||||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char * bios = flash->virt_addr;
|
||||||
|
|
||||||
// unprotect_39sf020 (bios);
|
|
||||||
erase_39sf020(flash);
|
erase_39sf020(flash);
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf ("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size/page_size; i++) {
|
||||||
/* erase the page before programming */
|
/* erase the page before programming */
|
||||||
|
@ -193,7 +167,5 @@ int write_39sf020 (struct flashchip * flash, unsigned char * buf)
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
// protect_39sf020 (bios);
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
* Reference:
|
* Reference:
|
||||||
* 4 MEgabit (512K x 8) SuperFlash EEPROM, SST49lF040 data sheet
|
* 4 MEgabit (512K x 8) SuperFlash EEPROM, SST49lF040 data sheet
|
||||||
*
|
*
|
||||||
|
* ToDo: Consilidated to standard JEDEC code.
|
||||||
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -59,7 +61,7 @@ static int erase_sector_49lf040 (volatile char * bios, unsigned int page)
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + page; /* set up address to be the current sector */
|
Temp = bios + page; /* set up address to be the current sector */
|
||||||
*Temp = 0x30; /* write data 0x30 to the address */
|
*Temp = 0x30; /* write data 0x30 to the address */
|
||||||
myusec_delay(25000);
|
myusec_delay(50000);
|
||||||
|
|
||||||
/* wait for Toggle bit ready */
|
/* wait for Toggle bit ready */
|
||||||
toggle_ready_jedec(bios);
|
toggle_ready_jedec(bios);
|
||||||
|
|
|
@ -17,17 +17,14 @@ void myusec_calibrate_delay()
|
||||||
unsigned long timeusec;
|
unsigned long timeusec;
|
||||||
struct timeval start, end;
|
struct timeval start, end;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
void myusec_delay(int time);
|
|
||||||
|
|
||||||
printf("Setting up microsecond timing loop\n");
|
printf("Setting up microsecond timing loop\n");
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
//fprintf(stderr, "Try %d\n", count);
|
|
||||||
gettimeofday(&start, 0);
|
gettimeofday(&start, 0);
|
||||||
myusec_delay(count);
|
myusec_delay(count);
|
||||||
gettimeofday(&end, 0);
|
gettimeofday(&end, 0);
|
||||||
timeusec = 1000000 * (end.tv_sec - start.tv_sec ) +
|
timeusec = 1000000 * (end.tv_sec - start.tv_sec ) +
|
||||||
(end.tv_usec - start.tv_usec);
|
(end.tv_usec - start.tv_usec);
|
||||||
//fprintf(stderr, "timeusec is %d\n", timeusec);
|
|
||||||
count *= 2;
|
count *= 2;
|
||||||
if (timeusec < 1000000/4)
|
if (timeusec < 1000000/4)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
* Reference:
|
* Reference:
|
||||||
* W49F002U data sheet
|
* W49F002U data sheet
|
||||||
*
|
*
|
||||||
|
* ToDo: Consilidated to standard JEDEC code.
|
||||||
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -80,7 +82,6 @@ int write_49f002 (struct flashchip * flash, unsigned char * buf)
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char * bios = flash->virt_addr;
|
||||||
volatile char * dst = bios;
|
volatile char * dst = bios;
|
||||||
|
|
||||||
myusec_delay(10);
|
|
||||||
erase_49f002(flash);
|
erase_49f002(flash);
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf ("Programming Page: ");
|
||||||
|
|
Loading…
Reference in New Issue