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

📄 memory.c

📁 针对于sa1100的bootloader。blob2.04是一个功能比较强大的bootloader
💻 C
字号:
/* * memory.c: memory test routines for the blob bootloader * * Copyright (C) 2001  Erik Mouw (J.A.K.Mouw@its.tudelft.nl) * * 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. * * 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. * * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */#ident "$Id: memory.c,v 1.2 2001/08/06 22:44:52 erikm Exp $"#ifdef HAVE_CONFIG_H# include "config.h"#endif#include "main.h"#include "memory.h"#include "serial.h"/* test in 1MB chunks */#define TEST_BLOCK_SIZE (1024 * 1024)/* from testmem2.S */extern int testram(u32 addr);memory_area_t memory_map[NUM_MEM_AREAS];void get_memory_map(void){	u32 addr;	int i;	/* init */	for(i = 0; i < NUM_MEM_AREAS; i++)		memory_map[i].used = 0;	/* first write a 0 to all memory locations */	for(addr = MEMORY_START; addr < MEMORY_END; addr += TEST_BLOCK_SIZE)		* (u32 *)addr = 0;	/* scan memory in blocks */	i = 0;	for(addr = MEMORY_START; addr < MEMORY_END; addr += TEST_BLOCK_SIZE) {		if(testram(addr) == 0) {			/* yes, memory */			if(* (u32 *)addr != 0) { /* alias? */#ifdef BLOB_DEBUG				SerialOutputString("Detected alias at 0x");				SerialOutputHex(addr);				SerialOutputString(", aliased from 0x");				SerialOutputHex(* (u32 *)addr);				SerialOutputByte('\n');#endif				if(memory_map[i].used)					i++;				continue;			}			/* not an alias, write the current address */			* (u32 *)addr = addr;#ifdef BLOB_DEBUG						SerialOutputString("Detected memory at 0x");			SerialOutputHex(addr);			SerialOutputByte('\n');#endif			/* does this start a new block? */			if(memory_map[i].used == 0) {				memory_map[i].start = addr;				memory_map[i].len = TEST_BLOCK_SIZE;				memory_map[i].used = 1;			} else {				memory_map[i].len += TEST_BLOCK_SIZE;			}		} else {			/* no memory here */			if(memory_map[i].used == 1)				i++;		}	}	SerialOutputString("Memory map:\n");	for(i = 0; i < NUM_MEM_AREAS; i++) {		if(memory_map[i].used) {			SerialOutputString("  0x");			SerialOutputHex(memory_map[i].len);			SerialOutputString(" @ 0x");			SerialOutputHex(memory_map[i].start);			SerialOutputString(" (");			SerialOutputDec(memory_map[i].len / (1024 * 1024));			SerialOutputString(" MB)\n");		}	}}

⌨️ 快捷键说明

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