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