⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flashdev.c

📁 MIPS处理器的bootloader,龙芯就是用的修改过的PMON2
💻 C
字号:
/*	$Id: flashdev.c,v 1.6 2003/05/21 09:15:49 pefo Exp $ *//* * Copyright (c) 2000 Opsycon AB  (www.opsycon.se) * Copyright (c) 2000 Rtmx, Inc   (www.rtmx.com) * Copyright (c) 2001 ipUnplugged AB  (www.ipunplugged.com) *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed for Rtmx, Inc by *	Opsycon Open System Consulting AB, Sweden. * 4. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */#include <stdio.h>#include <string.h>#include <stdlib.h>#include <machine/pio.h>#include <pmon.h>#include <pflash.h>#include <dev/pflash_tgt.h>#include "flash.h"#define __KB 1024#if NMOD_FLASH_AMD > 0int secsize_am29LV008bb[] = {16*__KB,  8*__KB,  8*__KB, 32*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 0};int secsize_am29LV008bt[] = {64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             32*__KB,  8*__KB,  8*__KB, 16*__KB, 0};int secsize_am29LV160bb[] = {16*__KB,  8*__KB,  8*__KB, 32*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB,                             64*__KB, 64*__KB, 64*__KB, 64*__KB, 64*__KB, 0};#endif /* NMOD_FLASH_AMD *//* *  Flash devices known by this code. */struct fl_device fl_known_dev[] = {#if NMOD_FLASH_AMD > 0	{ "Am29F040",	0x01, 0xa4, FL_PROTO_AMD, FL_CAP_DE,	512*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29F016",	0x01, 0xad, FL_PROTO_AMD, FL_CAP_DE,	2048*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29F032",	0x01, 0x41, FL_PROTO_AMD, FL_CAP_DE,	4096*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29LV040",	0x01, 0x4f, FL_PROTO_AMD, FL_CAP_DE,	512*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29LV017",	0x01, 0xc8, FL_PROTO_AMD, FL_CAP_DE,	2048*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29LV065",	0x01, 0xc8, FL_PROTO_AMD, FL_CAP_DE,	8192*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29LV065D",	0x01, 0x93, FL_PROTO_AMD, FL_CAP_DE,	8192*__KB, 64*__KB,  NULL, &fl_func_amd },	{ "Am29LV008BB", 0x01, 0x37, FL_PROTO_AMD, FL_CAP_DE,	1024*__KB, 64*__KB,  secsize_am29LV008bb, &fl_func_amd},	{ "Am29LV008BT", 0x01, 0x3E, FL_PROTO_AMD, FL_CAP_DE,	1024*__KB, 64*__KB,  secsize_am29LV008bt, &fl_func_amd},	{ "HY29LV160BB", 0xad, 0x49, FL_PROTO_AMD, FL_CAP_DE,	1024*__KB, 64*__KB,  secsize_am29LV160bb, &fl_func_amd},	{ "ST29F040",	0x20, 0xe2, FL_PROTO_AMD, FL_CAP_DE,	512*__KB, 64*__KB,  NULL, &fl_func_amd },#endif /* NMOD_FLASH_AMD */#if NMOD_FLASH_INTEL > 0	{ "i28F016SA",	0x89, 0xa0, FL_PROTO_INT, FL_CAP_A7,	  2048*__KB, 64*__KB,  NULL, &fl_func_int },	{ "i28F016",	0x89, 0xaa, FL_PROTO_INT,         0,	  2048*__KB, 64*__KB,  NULL, &fl_func_int },	{ "i28F320x",	0x89, 0x14, FL_PROTO_INT, FL_CAP_DE,	  4096*__KB, 64*__KB,  NULL, &fl_func_int },	{ "i28F640x",	0x89, 0x15, FL_PROTO_INT, FL_CAP_DE,	  8192*__KB, 64*__KB,  NULL, &fl_func_int },	{ "i28F320J3A",	0x89, 0x16, FL_PROTO_INT, FL_CAP_DE,	  32*128*__KB, 128*__KB, NULL, &fl_func_int },	{ "i28F640J3A",	0x89, 0x17, FL_PROTO_INT, FL_CAP_DE,	  64*128*__KB, 128*__KB, NULL, &fl_func_int },	{ "i28F128J3A",	0x89, 0x18, FL_PROTO_INT, FL_CAP_DE,	  128*128*__KB, 128*__KB, NULL, &fl_func_int },	{ "i28F160",	0xb0, 0xd0, FL_PROTO_INT, FL_CAP_DE,	  2048*__KB, 64*__KB,  NULL, &fl_func_int },	{ "i28F320",	0xb0, 0xd4, FL_PROTO_INT, FL_CAP_DE,	  4096*__KB, 64*__KB,  NULL, &fl_func_int },#endif /* NMOD_FLASH_INTEL */    { 0 },};#undef __KB

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -