Linux-2.6.12-rc2
[linux-2.6/kvm.git] / arch / cris / kernel / setup.c
blob6ec2671078bf4a3f5b27d92f79eec0aab4f2a2c1
1 /*
3 * linux/arch/cris/kernel/setup.c
5 * Copyright (C) 1995 Linus Torvalds
6 * Copyright (c) 2001 Axis Communications AB
7 */
9 /*
10 * This file handles the architecture-dependent parts of initialization
13 #include <linux/config.h>
14 #include <linux/init.h>
15 #include <linux/mm.h>
16 #include <linux/bootmem.h>
17 #include <asm/pgtable.h>
18 #include <linux/seq_file.h>
19 #include <linux/tty.h>
21 #include <asm/setup.h>
24 * Setup options
26 struct drive_info_struct { char dummy[32]; } drive_info;
27 struct screen_info screen_info;
29 extern int root_mountflags;
30 extern char _etext, _edata, _end;
32 static char command_line[COMMAND_LINE_SIZE] = { 0, };
34 extern const unsigned long text_start, edata; /* set by the linker script */
35 extern unsigned long dram_start, dram_end;
37 extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
39 extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */
41 /* This mainly sets up the memory area, and can be really confusing.
43 * The physical DRAM is virtually mapped into dram_start to dram_end
44 * (usually c0000000 to c0000000 + DRAM size). The physical address is
45 * given by the macro __pa().
47 * In this DRAM, the kernel code and data is loaded, in the beginning.
48 * It really starts at c0004000 to make room for some special pages -
49 * the start address is text_start. The kernel data ends at _end. After
50 * this the ROM filesystem is appended (if there is any).
52 * Between this address and dram_end, we have RAM pages usable to the
53 * boot code and the system.
57 void __init
58 setup_arch(char **cmdline_p)
60 extern void init_etrax_debug(void);
61 unsigned long bootmap_size;
62 unsigned long start_pfn, max_pfn;
63 unsigned long memory_start;
65 /* register an initial console printing routine for printk's */
67 init_etrax_debug();
69 /* we should really poll for DRAM size! */
71 high_memory = &dram_end;
73 if(romfs_in_flash || !romfs_length) {
74 /* if we have the romfs in flash, or if there is no rom filesystem,
75 * our free area starts directly after the BSS
77 memory_start = (unsigned long) &_end;
78 } else {
79 /* otherwise the free area starts after the ROM filesystem */
80 printk("ROM fs in RAM, size %lu bytes\n", romfs_length);
81 memory_start = romfs_start + romfs_length;
84 /* process 1's initial memory region is the kernel code/data */
86 init_mm.start_code = (unsigned long) &text_start;
87 init_mm.end_code = (unsigned long) &_etext;
88 init_mm.end_data = (unsigned long) &_edata;
89 init_mm.brk = (unsigned long) &_end;
91 #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
92 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
93 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
95 /* min_low_pfn points to the start of DRAM, start_pfn points
96 * to the first DRAM pages after the kernel, and max_low_pfn
97 * to the end of DRAM.
101 * partially used pages are not usable - thus
102 * we are rounding upwards:
105 start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */
106 max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
109 * Initialize the boot-time allocator (start, end)
111 * We give it access to all our DRAM, but we could as well just have
112 * given it a small slice. No point in doing that though, unless we
113 * have non-contiguous memory and want the boot-stuff to be in, say,
114 * the smallest area.
116 * It will put a bitmap of the allocated pages in the beginning
117 * of the range we give it, but it won't mark the bitmaps pages
118 * as reserved. We have to do that ourselves below.
120 * We need to use init_bootmem_node instead of init_bootmem
121 * because our map starts at a quite high address (min_low_pfn).
124 max_low_pfn = max_pfn;
125 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
127 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
128 min_low_pfn,
129 max_low_pfn);
131 /* And free all memory not belonging to the kernel (addr, size) */
133 free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
136 * Reserve the bootmem bitmap itself as well. We do this in two
137 * steps (first step was init_bootmem()) because this catches
138 * the (very unlikely) case of us accidentally initializing the
139 * bootmem allocator with an invalid RAM area.
141 * Arguments are start, size
144 reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size);
146 /* paging_init() sets up the MMU and marks all pages as reserved */
148 paging_init();
150 /* We don't use a command line yet, so just re-initialize it without
151 saving anything that might be there. */
153 *cmdline_p = command_line;
155 #ifdef CONFIG_ETRAX_CMDLINE
156 strlcpy(command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
157 command_line[COMMAND_LINE_SIZE - 1] = '\0';
159 /* Save command line for future references. */
160 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
161 saved_command_line[COMMAND_LINE_SIZE - 1] = '\0';
162 #endif
164 /* give credit for the CRIS port */
165 show_etrax_copyright();
168 static void *c_start(struct seq_file *m, loff_t *pos)
170 /* We only got one CPU... */
171 return *pos < 1 ? (void *)1 : NULL;
174 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
176 ++*pos;
177 return NULL;
180 static void c_stop(struct seq_file *m, void *v)
184 extern int show_cpuinfo(struct seq_file *m, void *v);
186 struct seq_operations cpuinfo_op = {
187 .start = c_start,
188 .next = c_next,
189 .stop = c_stop,
190 .show = show_cpuinfo,