GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / mips / dec / prom / memory.c
blobf4cb9e7e3e77349b2ee2f739a0ce55ea98b5be56
1 /*
2 * memory.c: memory initialisation code.
4 * Copyright (C) 1998 Harald Koerfgen, Frieder Streffer and Paul M. Antoine
5 * Copyright (C) 2000, 2002 Maciej W. Rozycki
6 */
7 #include <linux/init.h>
8 #include <linux/kernel.h>
9 #include <linux/mm.h>
10 #include <linux/bootmem.h>
11 #include <linux/types.h>
13 #include <asm/addrspace.h>
14 #include <asm/bootinfo.h>
15 #include <asm/dec/machtype.h>
16 #include <asm/dec/prom.h>
17 #include <asm/page.h>
18 #include <asm/sections.h>
21 volatile unsigned long mem_err; /* So we know an error occurred */
24 * Probe memory in 4MB chunks, waiting for an error to tell us we've fallen
25 * off the end of real memory. Only suitable for the 2100/3100's (PMAX).
28 #define CHUNK_SIZE 0x400000
30 static inline void pmax_setup_memory_region(void)
32 volatile unsigned char *memory_page, dummy;
33 char old_handler[0x80];
34 extern char genexcept_early;
36 /* Install exception handler */
37 memcpy(&old_handler, (void *)(CKSEG0 + 0x80), 0x80);
38 memcpy((void *)(CKSEG0 + 0x80), &genexcept_early, 0x80);
40 for (memory_page = (unsigned char *)CKSEG1 + CHUNK_SIZE;
41 mem_err == 0 && memory_page < (unsigned char *)CKSEG1 + 0x1e00000;
42 memory_page += CHUNK_SIZE) {
43 dummy = *memory_page;
45 memcpy((void *)(CKSEG0 + 0x80), &old_handler, 0x80);
47 add_memory_region(0, (unsigned long)memory_page - CKSEG1 - CHUNK_SIZE,
48 BOOT_MEM_RAM);
52 * Use the REX prom calls to get hold of the memory bitmap, and thence
53 * determine memory size.
55 static inline void rex_setup_memory_region(void)
57 int i, bitmap_size;
58 unsigned long mem_start = 0, mem_size = 0;
59 memmap *bm;
61 /* some free 64k */
62 bm = (memmap *)CKSEG0ADDR(0x28000);
64 bitmap_size = rex_getbitmap(bm);
66 for (i = 0; i < bitmap_size; i++) {
67 if (bm->bitmap[i] == 0xff)
68 mem_size += (8 * bm->pagesize);
69 else if (!mem_size)
70 mem_start += (8 * bm->pagesize);
71 else {
72 add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
73 mem_start += mem_size + (8 * bm->pagesize);
74 mem_size = 0;
77 if (mem_size)
78 add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
81 void __init prom_meminit(u32 magic)
83 if (!prom_is_rex(magic))
84 pmax_setup_memory_region();
85 else
86 rex_setup_memory_region();
89 void __init prom_free_prom_memory(void)
91 unsigned long end;
94 * Free everything below the kernel itself but leave
95 * the first page reserved for the exception handlers.
98 #if defined(CONFIG_DECLANCE) || defined(CONFIG_DECLANCE_MODULE)
99 if (IOASIC)
100 end = __pa(&_text) - 0x00020000;
101 else
102 #endif
103 end = __pa(&_text);
105 free_init_pages("unused PROM memory", PAGE_SIZE, end);