]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | ||
1da177e4 LT |
13 | #include <linux/init.h> |
14 | #include <linux/mm.h> | |
15 | #include <linux/bootmem.h> | |
16 | #include <asm/pgtable.h> | |
17 | #include <linux/seq_file.h> | |
18 | #include <linux/tty.h> | |
7cf32cad | 19 | #include <linux/utsname.h> |
22a9835c | 20 | #include <linux/pfn.h> |
1da177e4 LT |
21 | |
22 | #include <asm/setup.h> | |
23 | ||
24 | /* | |
25 | * Setup options | |
26 | */ | |
1da177e4 LT |
27 | struct screen_info screen_info; |
28 | ||
29 | extern int root_mountflags; | |
30 | extern char _etext, _edata, _end; | |
31 | ||
7cf32cad | 32 | char cris_command_line[COMMAND_LINE_SIZE] = { 0, }; |
1da177e4 LT |
33 | |
34 | extern const unsigned long text_start, edata; /* set by the linker script */ | |
35 | extern unsigned long dram_start, dram_end; | |
36 | ||
37 | extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */ | |
38 | ||
39 | extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */ | |
40 | ||
41 | /* This mainly sets up the memory area, and can be really confusing. | |
42 | * | |
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(). | |
46 | * | |
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). | |
51 | * | |
52 | * Between this address and dram_end, we have RAM pages usable to the | |
53 | * boot code and the system. | |
54 | * | |
55 | */ | |
56 | ||
57 | void __init | |
58 | setup_arch(char **cmdline_p) | |
59 | { | |
60 | extern void init_etrax_debug(void); | |
61 | unsigned long bootmap_size; | |
62 | unsigned long start_pfn, max_pfn; | |
63 | unsigned long memory_start; | |
64 | ||
65 | /* register an initial console printing routine for printk's */ | |
66 | ||
67 | init_etrax_debug(); | |
68 | ||
69 | /* we should really poll for DRAM size! */ | |
70 | ||
71 | high_memory = &dram_end; | |
72 | ||
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 | |
76 | */ | |
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; | |
82 | } | |
83 | ||
84 | /* process 1's initial memory region is the kernel code/data */ | |
85 | ||
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; | |
90 | ||
1da177e4 LT |
91 | /* min_low_pfn points to the start of DRAM, start_pfn points |
92 | * to the first DRAM pages after the kernel, and max_low_pfn | |
93 | * to the end of DRAM. | |
94 | */ | |
95 | ||
96 | /* | |
97 | * partially used pages are not usable - thus | |
98 | * we are rounding upwards: | |
99 | */ | |
100 | ||
101 | start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */ | |
102 | max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */ | |
103 | ||
104 | /* | |
105 | * Initialize the boot-time allocator (start, end) | |
106 | * | |
107 | * We give it access to all our DRAM, but we could as well just have | |
108 | * given it a small slice. No point in doing that though, unless we | |
109 | * have non-contiguous memory and want the boot-stuff to be in, say, | |
110 | * the smallest area. | |
111 | * | |
112 | * It will put a bitmap of the allocated pages in the beginning | |
113 | * of the range we give it, but it won't mark the bitmaps pages | |
114 | * as reserved. We have to do that ourselves below. | |
115 | * | |
116 | * We need to use init_bootmem_node instead of init_bootmem | |
117 | * because our map starts at a quite high address (min_low_pfn). | |
118 | */ | |
119 | ||
120 | max_low_pfn = max_pfn; | |
121 | min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT; | |
122 | ||
123 | bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, | |
124 | min_low_pfn, | |
125 | max_low_pfn); | |
126 | ||
127 | /* And free all memory not belonging to the kernel (addr, size) */ | |
128 | ||
129 | free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn)); | |
130 | ||
131 | /* | |
132 | * Reserve the bootmem bitmap itself as well. We do this in two | |
133 | * steps (first step was init_bootmem()) because this catches | |
134 | * the (very unlikely) case of us accidentally initializing the | |
135 | * bootmem allocator with an invalid RAM area. | |
136 | * | |
137 | * Arguments are start, size | |
138 | */ | |
139 | ||
140 | reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size); | |
141 | ||
142 | /* paging_init() sets up the MMU and marks all pages as reserved */ | |
143 | ||
144 | paging_init(); | |
145 | ||
7cf32cad | 146 | *cmdline_p = cris_command_line; |
1da177e4 LT |
147 | |
148 | #ifdef CONFIG_ETRAX_CMDLINE | |
7cf32cad MS |
149 | if (!strcmp(cris_command_line, "")) { |
150 | strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE); | |
151 | cris_command_line[COMMAND_LINE_SIZE - 1] = '\0'; | |
152 | } | |
153 | #endif | |
1da177e4 LT |
154 | |
155 | /* Save command line for future references. */ | |
7cf32cad | 156 | memcpy(saved_command_line, cris_command_line, COMMAND_LINE_SIZE); |
1da177e4 | 157 | saved_command_line[COMMAND_LINE_SIZE - 1] = '\0'; |
1da177e4 LT |
158 | |
159 | /* give credit for the CRIS port */ | |
160 | show_etrax_copyright(); | |
7cf32cad MS |
161 | |
162 | /* Setup utsname */ | |
163 | strcpy(system_utsname.machine, cris_machine_name); | |
1da177e4 LT |
164 | } |
165 | ||
166 | static void *c_start(struct seq_file *m, loff_t *pos) | |
167 | { | |
7cf32cad | 168 | return *pos < NR_CPUS ? (void *)(int)(*pos + 1): NULL; |
1da177e4 LT |
169 | } |
170 | ||
171 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) | |
172 | { | |
173 | ++*pos; | |
7cf32cad | 174 | return c_start(m, pos); |
1da177e4 LT |
175 | } |
176 | ||
177 | static void c_stop(struct seq_file *m, void *v) | |
178 | { | |
179 | } | |
180 | ||
181 | extern int show_cpuinfo(struct seq_file *m, void *v); | |
182 | ||
183 | struct seq_operations cpuinfo_op = { | |
184 | .start = c_start, | |
185 | .next = c_next, | |
186 | .stop = c_stop, | |
187 | .show = show_cpuinfo, | |
188 | }; | |
189 | ||
190 |