1/* ********************************************************************* 2 * Broadcom Common Firmware Environment (CFE) 3 * 4 * Physical Memory (arena) manager File: ppc_arena.c 5 * 6 * This module describes the physical memory available to the 7 * firmware. 8 * 9 * Author: Mitch Lichtenberg 10 * 11 ********************************************************************* 12 * 13 * Copyright 2000,2001,2002,2003 14 * Broadcom Corporation. All rights reserved. 15 * 16 * This software is furnished under license and may be used and 17 * copied only in accordance with the following terms and 18 * conditions. Subject to these conditions, you may download, 19 * copy, install, use, modify and distribute modified or unmodified 20 * copies of this software in source and/or binary form. No title 21 * or ownership is transferred hereby. 22 * 23 * 1) Any source code used, modified or distributed must reproduce 24 * and retain this copyright notice and list of conditions 25 * as they appear in the source file. 26 * 27 * 2) No right is granted to use any trade name, trademark, or 28 * logo of Broadcom Corporation. The "Broadcom Corporation" 29 * name may not be used to endorse or promote products derived 30 * from this software without the prior written permission of 31 * Broadcom Corporation. 32 * 33 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 34 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 36 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 37 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 38 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 41 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 43 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 45 * THE POSSIBILITY OF SUCH DAMAGE. 46 ********************************************************************* */ 47 48#include "cfe.h" 49#include "cfe_mem.h" 50#include "lib_arena.h" 51 52#include "initdata.h" 53 54#define _NOPROTOS_ 55#include "cfe_boot.h" 56#undef _NOPROTOS_ 57 58/* ********************************************************************* 59 * Constants 60 ********************************************************************* */ 61 62 63#define MEG (1024*1024) 64#define KB 1024 65#define PAGESIZE 4096 66#define CFE_BOOTAREA_SIZE (256*KB) 67#define CFE_BOOTAREA_ADDR 0x20000000 68 69 70/* ********************************************************************* 71 * Globals 72 ********************************************************************* */ 73 74extern arena_t cfe_arena; 75 76void cfe_bootarea_init(void); 77void ppc_arena_init(void); 78 79 80/* ********************************************************************* 81 * CFE_BOOTAREA_INIT() 82 * 83 * Initialize the page table and map our boot program area. 84 * 85 * Input parameters: 86 * nothing 87 * 88 * Return value: 89 * nothing 90 ********************************************************************* */ 91 92void cfe_bootarea_init(void) 93{ 94 95} 96 97 98/* ********************************************************************* 99 * ppc_arena_init() 100 * 101 * Create the initial map of physical memory 102 * 103 * Input parameters: 104 * nothing 105 * 106 * Return value: 107 * nothing 108 ********************************************************************* */ 109 110void ppc_arena_init(void) 111{ 112 uint64_t memamt; 113 114 arena_init(&cfe_arena,0x0,0x100000000ULL); 115 116#if 0 117 /* 118 * Mark the ranges from the SB1250's memory map 119 */ 120 121 ARENA_RANGE(0x0000000000,0x000FFFFFFF,MEMTYPE_DRAM_NOTINSTALLED); 122 ARENA_RANGE(0x0080000000,0x009FFFFFFF,MEMTYPE_DRAM_NOTINSTALLED); 123 ARENA_RANGE(0x00C0000000,0x00CFFFFFFF,MEMTYPE_DRAM_NOTINSTALLED); 124 ARENA_RANGE(0x0100000000,0x7FFFFFFFFF,MEMTYPE_DRAM_NOTINSTALLED); 125 /* 126 * Mark LDT and PCI regions 127 */ 128 129 ARENA_RANGE(0x0040000000,0x005FFFFFFF,MEMTYPE_LDT_PCI); 130 ARENA_RANGE(0x0060000000,0x007FFFFFFF,MEMTYPE_LDT_PCI); 131 132 ARENA_RANGE(0x00D8000000,0x00DFFFFFFF,MEMTYPE_LDT_PCI); 133 134 ARENA_RANGE(0x00F8000000,0x00FFFFFFFF,MEMTYPE_LDT_PCI); 135 ARENA_RANGE(0xF800000000,0xF9FFFFFFFF,MEMTYPE_LDT_PCI); 136 137 ARENA_RANGE(0xFD00000000,0xFFFFFFFFFF,MEMTYPE_LDT_PCI); 138 139 /* 140 * System IO registers 141 */ 142 143 ARENA_RANGE(0x0010000000,0x001002FFFF,MEMTYPE_IOREGISTERS); 144#endif 145 146 /* 147 * Now, fix up the map with what is known about *this* system. 148 * 149 * Do each 256MB chunk. 150 */ 151 152 memamt = ((int64_t) mem_totalsize) << 20; 153 arena_markrange(&cfe_arena,0x00000000,memamt,MEMTYPE_DRAM_AVAILABLE,NULL); 154 155#if 0 156 memleft = ((int64_t) mem_totalsize) << 20; 157 158 memamt = (memleft > mem256) ? mem256 : memleft; 159 160 arena_markrange(&cfe_arena,0x00000000,memamt,MEMTYPE_DRAM_AVAILABLE,NULL); 161 memleft -= memamt; 162 163 if (memleft) { 164 memamt = (memleft > mem256*2) ? mem256*2 : memleft; 165 arena_markrange(&cfe_arena,0x80000000,memamt,MEMTYPE_DRAM_AVAILABLE,NULL); 166 memleft -= memamt; 167 } 168 169 if (memleft) { 170 memamt = (memleft > mem256) ? mem256 : memleft; 171 arena_markrange(&cfe_arena,0xC0000000,memamt,MEMTYPE_DRAM_AVAILABLE,NULL); 172 memleft -= memamt; 173 } 174 175 if (memleft) { 176 arena_markrange(&cfe_arena,0x100000000,memleft,MEMTYPE_DRAM_AVAILABLE,NULL); 177 } 178 179 180 /* 181 * Do the boot ROM 182 */ 183 184 arena_markrange(&cfe_arena,0x1FC00000,2*1024*1024,MEMTYPE_BOOTROM,NULL); 185#endif 186 187} 188 189 190