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

📄 tgt_flash.c

📁 MIPS处理器的bootloader,龙芯就是用的修改过的PMON2
💻 C
字号:
/*	$Id: tgt_flash.c,v 1.3 2001/12/13 10:59:32 pefo Exp $ *//* * 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 Patrik Lindergren, by *	ipUnplugged 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 <sys/types.h>#include <stdio.h>#include <setjmp.h>#include <termio.h>#include <string.h>#include <machine/cpu.h>#include <machine/pio.h>#include <pflash.h>#include <dev/pflash_tgt.h>#include <include/palomarii.h>#include <pmon/dev/cpc700.h>#include <pmon/dev/cpc700_iic.h>#include <pmon.h>/* *  Flash programming support code. *//* *  Table of flash devices on target. See pflash_tgt.h. */struct fl_map tgt_fl_map_amd[] = {	TARGET_FLASH_DEVICES_AMD};struct fl_map tgt_fl_map_intel[] = {	TARGET_FLASH_DEVICES_INTEL};voidtgt_flashinit(){}struct fl_map *tgt_flashmap(){	if(inb(PALOMAR_RST_STAT) & PALOMAR_RST_BOOT) {		return(tgt_fl_map_amd);	}	else {		return(tgt_fl_map_intel);	}}voidtgt_flashwrite_disable(){	out32(CPC700_MEMCFGADDR, CPC700_FWEN);	out32(CPC700_MEMCFGADDR+4, in32(CPC700_MEMCFGADDR+4) & 0x3fffffff);}inttgt_flashwrite_enable(){	out32(CPC700_MEMCFGADDR, CPC700_FWEN);	out32(CPC700_MEMCFGADDR+4, in32(CPC700_MEMCFGADDR+4) | 0xc0000000);	return(1);}voidtgt_flashinfo(void *p, size_t *t){	struct fl_map *map;	map = fl_find_map(p);	if(map) {		*t = map->fl_map_size;	}	else {		*t = 0;	}}voidtgt_flashprogram(void *p, int size, void *s, int endian){	printf("Programming flash %p:%p into %p\n", s, size, p);	if(fl_erase_device(p, size, TRUE)) {		printf("Erase failed!\n");		return;	}	if(fl_program_device(p, s, size, TRUE)) {		printf("Programming failed!\n");	}}

⌨️ 快捷键说明

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