w49f002u.c 1.45 KB
Newer Older
Andrew Ip's avatar
Andrew Ip committed
1
/*
2
 * This file is part of the flashrom project.
Andrew Ip's avatar
Andrew Ip committed
3
 *
4
 * Copyright (C) 2000 Silicon Integrated System Corporation
Andrew Ip's avatar
Andrew Ip committed
5
 *
6 7 8 9
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
Andrew Ip's avatar
Andrew Ip committed
10
 *
11 12 13 14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
15
 *
16 17 18
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
Andrew Ip's avatar
Andrew Ip committed
19 20
 */

Ronald G. Minnich's avatar
Ronald G. Minnich committed
21
#include <stdio.h>
Andrew Ip's avatar
Andrew Ip committed
22 23
#include "flash.h"

24
int write_49f002(struct flashchip *flash, uint8_t *buf)
Andrew Ip's avatar
Andrew Ip committed
25
{
26
	int i;
Uwe Hermann's avatar
Uwe Hermann committed
27 28
	int total_size = flash->total_size * 1024;
	int page_size = flash->page_size;
29
	volatile uint8_t *bios = flash->virtual_memory;
Andrew Ip's avatar
Andrew Ip committed
30

31
	erase_chip_jedec(flash);
32

33
	printf("Programming page: ");
34
	for (i = 0; i < total_size / page_size; i++) {
35
		printf("%04d at address: 0x%08x ", i, i * page_size);
36
		/* Byte-wise writing of 'page_size' bytes. */
37 38 39 40
		write_sector_jedec(bios, buf + i * page_size,
				   bios + i * page_size, page_size);
		printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
		fflush(stdout);
41 42
	}
	printf("\n");
Ronald G. Minnich's avatar
Ronald G. Minnich committed
43

Uwe Hermann's avatar
Uwe Hermann committed
44
	return 0;
Andrew Ip's avatar
Andrew Ip committed
45
}