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