2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2000 AG Electronics Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <console/console.h>
25 #define ONEMEG 0x00100000
26 #define HALFMEG 0x00080000
28 unsigned long memory_base = 0;
29 unsigned long memory_top = 0;
30 unsigned long memory_size = 0;
32 //extern char __heap_end[];
33 extern unsigned mpc107_config_memory(void);
35 unsigned config_memory(unsigned offset)
37 //extern char __start[];
38 //extern char __bss_start[];
39 //unsigned rom_image = (unsigned) __start & 0xfff00000;
40 //unsigned physical = rom_image + offset;
41 //unsigned codesize = (unsigned) __bss_start - rom_image;
44 /* At this point, DBAT 0 is memory, 1 is variable, 2 is the rom image,
46 ppc_set_io_dbat_reloc(2, rom_image, physical, ONEMEG);
47 ppc_set_io_dbat (3, 0xf0000000, 0x10000000);
48 if ( rom_image != physical )
49 ppc_set_ibats_reloc(rom_image, physical, ONEMEG);
51 ppc_set_ibats(physical, ONEMEG);
53 printk_debug("bsp_init_memory...\n");
56 ppc_setup_cpu(1); /* icache enable = 1 */
59 memory_size = mpc107_config_memory();
61 /* If we have some working RAM, we copy the code and rodata into it.
62 * This allows us to reprogram the flash later. */
66 unsigned onemeg = memory_size - ONEMEG;
67 ppc_set_mem_dbat_reloc(1, onemeg, onemeg, ONEMEG);
68 memcpy((void *)onemeg, (void *)rom_image, codesize);
69 memset((void *)(onemeg + codesize), 0, ONEMEG - codesize);
70 ppc_set_ibats_reloc2(rom_image, physical, onemeg, ONEMEG);
71 ppc_set_mem_dbat_reloc(2, rom_image, onemeg, ONEMEG);
72 make_coherent((void *)onemeg, ONEMEG);
75 ppc_set_memory_dbat (memory_size);
78 //ppc_enable_dcache ();