1 /* Copyright 2000 AG Electronics Ltd. */
2 /* This code is distributed without warranty under the GPL v2 (see COPYING) */
7 #include <console/console.h>
9 #define ONEMEG 0x00100000
10 #define HALFMEG 0x00080000
12 unsigned long memory_base = 0;
13 unsigned long memory_top = 0;
14 unsigned long memory_size = 0;
16 //extern char __heap_end[];
17 extern unsigned mpc107_config_memory(void);
19 unsigned config_memory(unsigned offset)
21 //extern char __start[];
22 //extern char __bss_start[];
23 //unsigned rom_image = (unsigned) __start & 0xfff00000;
24 //unsigned physical = rom_image + offset;
25 //unsigned codesize = (unsigned) __bss_start - rom_image;
28 /* At this point, DBAT 0 is memory, 1 is variable, 2 is the rom image,
30 ppc_set_io_dbat_reloc(2, rom_image, physical, ONEMEG);
31 ppc_set_io_dbat (3, 0xf0000000, 0x10000000);
32 if ( rom_image != physical )
33 ppc_set_ibats_reloc(rom_image, physical, ONEMEG);
35 ppc_set_ibats(physical, ONEMEG);
37 printk_debug("bsp_init_memory...\n");
40 ppc_setup_cpu(1); /* icache enable = 1 */
43 memory_size = mpc107_config_memory();
45 /* If we have some working RAM, we copy the code and rodata into it.
46 * This allows us to reprogram the flash later. */
50 unsigned onemeg = memory_size - ONEMEG;
51 ppc_set_mem_dbat_reloc(1, onemeg, onemeg, ONEMEG);
52 memcpy((void *)onemeg, (void *)rom_image, codesize);
53 memset((void *)(onemeg + codesize), 0, ONEMEG - codesize);
54 ppc_set_ibats_reloc2(rom_image, physical, onemeg, ONEMEG);
55 ppc_set_mem_dbat_reloc(2, rom_image, onemeg, ONEMEG);
56 make_coherent((void *)onemeg, ONEMEG);
59 ppc_set_memory_dbat (memory_size);
62 //ppc_enable_dcache ();