2007-06-14 21:54:47 +00:00
|
|
|
/*
|
|
|
|
* BRIEF MODULE DESCRIPTION
|
|
|
|
* PROM library initialisation code, assuming a version of
|
|
|
|
* pmon is the boot code.
|
|
|
|
*
|
|
|
|
* Copyright 2000,2001 MontaVista Software Inc.
|
|
|
|
* Author: MontaVista Software, Inc.
|
|
|
|
* ppopov@mvista.com or source@mvista.com
|
|
|
|
*
|
|
|
|
* This file was derived from Carsten Langgaard's
|
|
|
|
* arch/mips/mips-boards/xx files.
|
|
|
|
*
|
|
|
|
* Carsten Langgaard, carstenl@mips.com
|
|
|
|
* Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 SOFTWARE IS PROVIDED ``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.
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/mm.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2007-06-14 21:54:47 +00:00
|
|
|
|
|
|
|
#include <asm/addrspace.h>
|
|
|
|
#include <asm/bootinfo.h>
|
|
|
|
#include <asm-generic/sections.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
|
|
|
|
#include <msp_prom.h>
|
|
|
|
#include <msp_regs.h>
|
|
|
|
|
|
|
|
/* global PROM environment variables and pointers */
|
|
|
|
int prom_argc;
|
|
|
|
char **prom_argv, **prom_envp;
|
|
|
|
int *prom_vec;
|
|
|
|
|
|
|
|
/* debug flag */
|
|
|
|
int init_debug = 1;
|
|
|
|
|
|
|
|
/* memory blocks */
|
|
|
|
struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];
|
|
|
|
|
|
|
|
/* default feature sets */
|
|
|
|
static char msp_default_features[] =
|
|
|
|
#if defined(CONFIG_PMC_MSP4200_EVAL) \
|
|
|
|
|| defined(CONFIG_PMC_MSP4200_GW)
|
|
|
|
"ERER";
|
|
|
|
#elif defined(CONFIG_PMC_MSP7120_EVAL) \
|
|
|
|
|| defined(CONFIG_PMC_MSP7120_GW)
|
|
|
|
"EMEMSP";
|
|
|
|
#elif defined(CONFIG_PMC_MSP7120_FPGA)
|
|
|
|
"EMEM";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* conversion functions */
|
|
|
|
static inline unsigned char str2hexnum(unsigned char c)
|
|
|
|
{
|
|
|
|
if (c >= '0' && c <= '9')
|
|
|
|
return c - '0';
|
|
|
|
if (c >= 'a' && c <= 'f')
|
|
|
|
return c - 'a' + 10;
|
|
|
|
return 0; /* foo */
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int str2eaddr(unsigned char *ea, unsigned char *str)
|
|
|
|
{
|
|
|
|
int index = 0;
|
|
|
|
unsigned char num = 0;
|
|
|
|
|
|
|
|
while (*str != '\0') {
|
|
|
|
if ((*str == '.') || (*str == ':')) {
|
|
|
|
ea[index++] = num;
|
|
|
|
num = 0;
|
|
|
|
str++;
|
|
|
|
} else {
|
|
|
|
num = num << 4;
|
|
|
|
num |= str2hexnum(*str++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == 5) {
|
|
|
|
ea[index++] = num;
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(str2eaddr);
|
|
|
|
|
|
|
|
static inline unsigned long str2hex(unsigned char *str)
|
|
|
|
{
|
|
|
|
int value = 0;
|
|
|
|
|
|
|
|
while (*str) {
|
|
|
|
value = value << 4;
|
|
|
|
value |= str2hexnum(*str++);
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* function to query the system information */
|
|
|
|
const char *get_system_type(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_PMC_MSP4200_EVAL)
|
|
|
|
return "PMC-Sierra MSP4200 Eval Board";
|
|
|
|
#elif defined(CONFIG_PMC_MSP4200_GW)
|
|
|
|
return "PMC-Sierra MSP4200 VoIP Gateway";
|
|
|
|
#elif defined(CONFIG_PMC_MSP7120_EVAL)
|
|
|
|
return "PMC-Sierra MSP7120 Eval Board";
|
|
|
|
#elif defined(CONFIG_PMC_MSP7120_GW)
|
|
|
|
return "PMC-Sierra MSP7120 Residential Gateway";
|
|
|
|
#elif defined(CONFIG_PMC_MSP7120_FPGA)
|
|
|
|
return "PMC-Sierra MSP7120 FPGA";
|
|
|
|
#else
|
|
|
|
#error "What is the type of *your* MSP?"
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_ethernet_addr(char *ethaddr_name, char *ethernet_addr)
|
|
|
|
{
|
|
|
|
char *ethaddr_str;
|
|
|
|
|
|
|
|
ethaddr_str = prom_getenv(ethaddr_name);
|
|
|
|
if (!ethaddr_str) {
|
|
|
|
printk(KERN_WARNING "%s not set in boot prom\n", ethaddr_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str2eaddr(ethernet_addr, ethaddr_str) == -1) {
|
|
|
|
printk(KERN_WARNING "%s badly formatted-<%s>\n",
|
|
|
|
ethaddr_name, ethaddr_str);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (init_debug > 1) {
|
|
|
|
int i;
|
|
|
|
printk(KERN_DEBUG "get_ethernet_addr: for %s ", ethaddr_name);
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
printk(KERN_DEBUG "%02x:",
|
|
|
|
(unsigned char)*(ethernet_addr+i));
|
|
|
|
printk(KERN_DEBUG "%02x\n", *(ethernet_addr+i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(get_ethernet_addr);
|
|
|
|
|
|
|
|
static char *get_features(void)
|
|
|
|
{
|
|
|
|
char *feature = prom_getenv(FEATURES);
|
|
|
|
|
|
|
|
if (feature == NULL) {
|
|
|
|
/* default features based on MACHINE_TYPE */
|
|
|
|
feature = msp_default_features;
|
|
|
|
}
|
|
|
|
|
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char test_feature(char c)
|
|
|
|
{
|
|
|
|
char *feature = get_features();
|
|
|
|
|
|
|
|
while (*feature) {
|
|
|
|
if (*feature++ == c)
|
|
|
|
return *feature;
|
|
|
|
feature++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FEATURE_NOEXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long get_deviceid(void)
|
|
|
|
{
|
|
|
|
char *deviceid = prom_getenv(DEVICEID);
|
|
|
|
|
|
|
|
if (deviceid == NULL)
|
|
|
|
return *DEV_ID_REG;
|
|
|
|
else
|
|
|
|
return str2hex(deviceid);
|
|
|
|
}
|
|
|
|
|
|
|
|
char identify_pci(void)
|
|
|
|
{
|
|
|
|
return test_feature(PCI_KEY);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_pci);
|
|
|
|
|
|
|
|
char identify_pcimux(void)
|
|
|
|
{
|
|
|
|
return test_feature(PCIMUX_KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
char identify_sec(void)
|
|
|
|
{
|
|
|
|
return test_feature(SEC_KEY);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_sec);
|
|
|
|
|
|
|
|
char identify_spad(void)
|
|
|
|
{
|
|
|
|
return test_feature(SPAD_KEY);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_spad);
|
|
|
|
|
|
|
|
char identify_tdm(void)
|
|
|
|
{
|
|
|
|
return test_feature(TDM_KEY);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_tdm);
|
|
|
|
|
|
|
|
char identify_zsp(void)
|
|
|
|
{
|
|
|
|
return test_feature(ZSP_KEY);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_zsp);
|
|
|
|
|
|
|
|
static char identify_enetfeature(char key, unsigned long interface_num)
|
|
|
|
{
|
|
|
|
char *feature = get_features();
|
|
|
|
|
|
|
|
while (*feature) {
|
|
|
|
if (*feature++ == key && interface_num-- == 0)
|
|
|
|
return *feature;
|
|
|
|
feature++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FEATURE_NOEXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
char identify_enet(unsigned long interface_num)
|
|
|
|
{
|
|
|
|
return identify_enetfeature(ENET_KEY, interface_num);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_enet);
|
|
|
|
|
|
|
|
char identify_enetTxD(unsigned long interface_num)
|
|
|
|
{
|
|
|
|
return identify_enetfeature(ENETTXD_KEY, interface_num);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_enetTxD);
|
|
|
|
|
|
|
|
unsigned long identify_family(void)
|
|
|
|
{
|
|
|
|
unsigned long deviceid;
|
|
|
|
|
|
|
|
deviceid = get_deviceid();
|
|
|
|
|
|
|
|
return deviceid & CPU_DEVID_FAMILY;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_family);
|
|
|
|
|
|
|
|
unsigned long identify_revision(void)
|
|
|
|
{
|
|
|
|
unsigned long deviceid;
|
|
|
|
|
|
|
|
deviceid = get_deviceid();
|
|
|
|
|
|
|
|
return deviceid & CPU_DEVID_REVISION;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(identify_revision);
|
|
|
|
|
|
|
|
/* PROM environment functions */
|
|
|
|
char *prom_getenv(char *env_name)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Return a pointer to the given environment variable. prom_envp
|
|
|
|
* points to a null terminated array of pointers to variables.
|
|
|
|
* Environment variables are stored in the form of "memsize=64"
|
|
|
|
*/
|
|
|
|
|
|
|
|
char **var = prom_envp;
|
|
|
|
int i = strlen(env_name);
|
|
|
|
|
|
|
|
while (*var) {
|
|
|
|
if (strncmp(env_name, *var, i) == 0) {
|
|
|
|
return (*var + strlen(env_name) + 1);
|
|
|
|
}
|
|
|
|
var++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PROM commandline functions */
|
|
|
|
void __init prom_init_cmdline(void)
|
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
int actr;
|
|
|
|
|
|
|
|
actr = 1; /* Always ignore argv[0] */
|
|
|
|
|
|
|
|
cp = &(arcs_cmdline[0]);
|
|
|
|
while (actr < prom_argc) {
|
|
|
|
strcpy(cp, prom_argv[actr]);
|
|
|
|
cp += strlen(prom_argv[actr]);
|
|
|
|
*cp++ = ' ';
|
|
|
|
actr++;
|
|
|
|
}
|
|
|
|
if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
|
|
|
|
--cp;
|
|
|
|
*cp = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memory allocation functions */
|
|
|
|
static int __init prom_memtype_classify(unsigned int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case yamon_free:
|
|
|
|
return BOOT_MEM_RAM;
|
|
|
|
case yamon_prom:
|
|
|
|
return BOOT_MEM_ROM_DATA;
|
|
|
|
default:
|
|
|
|
return BOOT_MEM_RESERVED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init prom_meminit(void)
|
|
|
|
{
|
|
|
|
struct prom_pmemblock *p;
|
|
|
|
|
|
|
|
p = prom_getmdesc();
|
|
|
|
|
|
|
|
while (p->size) {
|
|
|
|
long type;
|
|
|
|
unsigned long base, size;
|
|
|
|
|
|
|
|
type = prom_memtype_classify(p->type);
|
|
|
|
base = p->base;
|
|
|
|
size = p->size;
|
|
|
|
|
|
|
|
add_memory_region(base, size, type);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init prom_free_prom_memory(void)
|
|
|
|
{
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
char **envp;
|
|
|
|
char *ptr;
|
|
|
|
int len = 0;
|
|
|
|
int i;
|
|
|
|
unsigned long addr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* preserve environment variables and command line from pmon/bbload
|
|
|
|
* first preserve the command line
|
|
|
|
*/
|
|
|
|
for (argc = 0; argc < prom_argc; argc++) {
|
|
|
|
len += sizeof(char *); /* length of pointer */
|
|
|
|
len += strlen(prom_argv[argc]) + 1; /* length of string */
|
|
|
|
}
|
|
|
|
len += sizeof(char *); /* plus length of null pointer */
|
|
|
|
|
|
|
|
argv = kmalloc(len, GFP_KERNEL);
|
|
|
|
ptr = (char *) &argv[prom_argc + 1]; /* strings follow array */
|
|
|
|
|
|
|
|
for (argc = 0; argc < prom_argc; argc++) {
|
|
|
|
argv[argc] = ptr;
|
|
|
|
strcpy(ptr, prom_argv[argc]);
|
|
|
|
ptr += strlen(prom_argv[argc]) + 1;
|
|
|
|
}
|
|
|
|
argv[prom_argc] = NULL; /* end array with null pointer */
|
|
|
|
prom_argv = argv;
|
|
|
|
|
|
|
|
/* next preserve the environment variables */
|
|
|
|
len = 0;
|
|
|
|
i = 0;
|
|
|
|
for (envp = prom_envp; *envp != NULL; envp++) {
|
|
|
|
i++; /* count number of environment variables */
|
|
|
|
len += sizeof(char *); /* length of pointer */
|
|
|
|
len += strlen(*envp) + 1; /* length of string */
|
|
|
|
}
|
|
|
|
len += sizeof(char *); /* plus length of null pointer */
|
|
|
|
|
|
|
|
envp = kmalloc(len, GFP_KERNEL);
|
|
|
|
ptr = (char *) &envp[i+1];
|
|
|
|
|
|
|
|
for (argc = 0; argc < i; argc++) {
|
|
|
|
envp[argc] = ptr;
|
|
|
|
strcpy(ptr, prom_envp[argc]);
|
|
|
|
ptr += strlen(prom_envp[argc]) + 1;
|
|
|
|
}
|
|
|
|
envp[i] = NULL; /* end array with null pointer */
|
|
|
|
prom_envp = envp;
|
|
|
|
|
|
|
|
for (i = 0; i < boot_mem_map.nr_map; i++) {
|
|
|
|
if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
addr = boot_mem_map.map[i].addr;
|
|
|
|
free_init_pages("prom memory",
|
|
|
|
addr, addr + boot_mem_map.map[i].size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct prom_pmemblock *__init prom_getmdesc(void)
|
|
|
|
{
|
|
|
|
static char memsz_env[] __initdata = "memsize";
|
|
|
|
static char heaptop_env[] __initdata = "heaptop";
|
|
|
|
char *str;
|
|
|
|
unsigned int memsize;
|
|
|
|
unsigned int heaptop;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
str = prom_getenv(memsz_env);
|
|
|
|
if (!str) {
|
|
|
|
ppfinit("memsize not set in boot prom, "
|
|
|
|
"set to default (32Mb)\n");
|
|
|
|
memsize = 0x02000000;
|
|
|
|
} else {
|
|
|
|
memsize = simple_strtol(str, NULL, 0);
|
|
|
|
|
|
|
|
if (memsize == 0) {
|
|
|
|
/* if memsize is a bad size, use reasonable default */
|
|
|
|
memsize = 0x02000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert to physical address (removing caching bits, etc) */
|
|
|
|
memsize = CPHYSADDR(memsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
str = prom_getenv(heaptop_env);
|
|
|
|
if (!str) {
|
|
|
|
heaptop = CPHYSADDR((u32)&_text);
|
|
|
|
ppfinit("heaptop not set in boot prom, "
|
|
|
|
"set to default 0x%08x\n", heaptop);
|
|
|
|
} else {
|
|
|
|
heaptop = simple_strtol(str, NULL, 16);
|
|
|
|
if (heaptop == 0) {
|
|
|
|
/* heaptop conversion bad, might have 0xValue */
|
|
|
|
heaptop = simple_strtol(str, NULL, 0);
|
|
|
|
|
|
|
|
if (heaptop == 0) {
|
|
|
|
/* heaptop still bad, use reasonable default */
|
|
|
|
heaptop = CPHYSADDR((u32)&_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert to physical address (removing caching bits, etc) */
|
|
|
|
heaptop = CPHYSADDR((u32)heaptop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the base region */
|
|
|
|
i = 0;
|
|
|
|
mdesc[i].type = BOOT_MEM_RESERVED;
|
|
|
|
mdesc[i].base = 0x00000000;
|
|
|
|
mdesc[i].size = PAGE_ALIGN(0x300 + 0x80);
|
|
|
|
/* jtag interrupt vector + sizeof vector */
|
|
|
|
|
|
|
|
/* PMON data */
|
|
|
|
if (heaptop > mdesc[i].base + mdesc[i].size) {
|
|
|
|
i++; /* 1 */
|
|
|
|
mdesc[i].type = BOOT_MEM_ROM_DATA;
|
|
|
|
mdesc[i].base = mdesc[i-1].base + mdesc[i-1].size;
|
|
|
|
mdesc[i].size = heaptop - mdesc[i].base;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* end of PMON data to start of kernel -- probably zero .. */
|
|
|
|
if (heaptop != CPHYSADDR((u32)_text)) {
|
|
|
|
i++; /* 2 */
|
|
|
|
mdesc[i].type = BOOT_MEM_RAM;
|
|
|
|
mdesc[i].base = heaptop;
|
|
|
|
mdesc[i].size = CPHYSADDR((u32)_text) - mdesc[i].base;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* kernel proper */
|
|
|
|
i++; /* 3 */
|
|
|
|
mdesc[i].type = BOOT_MEM_RESERVED;
|
|
|
|
mdesc[i].base = CPHYSADDR((u32)_text);
|
2009-04-28 23:00:27 +00:00
|
|
|
mdesc[i].size = CPHYSADDR(PAGE_ALIGN((u32)_end)) - mdesc[i].base;
|
2007-06-14 21:54:47 +00:00
|
|
|
|
|
|
|
/* Remainder of RAM -- under memsize */
|
|
|
|
i++; /* 5 */
|
|
|
|
mdesc[i].type = yamon_free;
|
|
|
|
mdesc[i].base = mdesc[i-1].base + mdesc[i-1].size;
|
|
|
|
mdesc[i].size = memsize - mdesc[i].base;
|
|
|
|
|
|
|
|
return &mdesc[0];
|
|
|
|
}
|