blob: 32c3d248868e27c152932c7e9baf98410a1b3128 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#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>
Jon Smirl894673e2006-07-10 04:44:13 -070018#include <linux/screen_info.h>
Mikael Starvik7cf32ca2005-07-27 11:44:38 -070019#include <linux/utsname.h>
Dave Hansen22a98352006-03-27 01:16:04 -080020#include <linux/pfn.h>
Jesper Nilsson60dead52008-01-28 16:39:00 +010021#include <linux/cpu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/setup.h>
David Howellsb1a154d2012-03-28 18:30:02 +010023#include <arch/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25/*
26 * Setup options
27 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070028struct screen_info screen_info;
29
30extern int root_mountflags;
31extern char _etext, _edata, _end;
32
Alon Bar-Lev87e1f9c2007-02-12 00:54:09 -080033char __initdata cris_command_line[COMMAND_LINE_SIZE] = { 0, };
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35extern const unsigned long text_start, edata; /* set by the linker script */
36extern unsigned long dram_start, dram_end;
37
38extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
39
Jesper Nilsson60dead52008-01-28 16:39:00 +010040static struct cpu cpu_devices[NR_CPUS];
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042extern 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.
Jesper Nilsson60dead52008-01-28 16:39:00 +010051 * It really starts at c0004000 to make room for some special pages -
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 * the start address is text_start. The kernel data ends at _end. After
53 * this the ROM filesystem is appended (if there is any).
Jesper Nilsson60dead52008-01-28 16:39:00 +010054 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 * Between this address and dram_end, we have RAM pages usable to the
56 * boot code and the system.
57 *
58 */
59
Jesper Nilsson60dead52008-01-28 16:39:00 +010060void __init setup_arch(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
62 extern void init_etrax_debug(void);
63 unsigned long bootmap_size;
64 unsigned long start_pfn, max_pfn;
65 unsigned long memory_start;
66
Jesper Nilsson60dead52008-01-28 16:39:00 +010067 /* register an initial console printing routine for printk's */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69 init_etrax_debug();
70
71 /* we should really poll for DRAM size! */
72
73 high_memory = &dram_end;
74
75 if(romfs_in_flash || !romfs_length) {
76 /* if we have the romfs in flash, or if there is no rom filesystem,
77 * our free area starts directly after the BSS
78 */
79 memory_start = (unsigned long) &_end;
80 } else {
81 /* otherwise the free area starts after the ROM filesystem */
82 printk("ROM fs in RAM, size %lu bytes\n", romfs_length);
83 memory_start = romfs_start + romfs_length;
84 }
85
86 /* process 1's initial memory region is the kernel code/data */
87
88 init_mm.start_code = (unsigned long) &text_start;
89 init_mm.end_code = (unsigned long) &_etext;
90 init_mm.end_data = (unsigned long) &_edata;
91 init_mm.brk = (unsigned long) &_end;
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 /* min_low_pfn points to the start of DRAM, start_pfn points
94 * to the first DRAM pages after the kernel, and max_low_pfn
95 * to the end of DRAM.
96 */
97
98 /*
99 * partially used pages are not usable - thus
100 * we are rounding upwards:
101 */
102
103 start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */
104 max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
105
106 /*
107 * Initialize the boot-time allocator (start, end)
108 *
109 * We give it access to all our DRAM, but we could as well just have
110 * given it a small slice. No point in doing that though, unless we
111 * have non-contiguous memory and want the boot-stuff to be in, say,
112 * the smallest area.
113 *
114 * It will put a bitmap of the allocated pages in the beginning
115 * of the range we give it, but it won't mark the bitmaps pages
116 * as reserved. We have to do that ourselves below.
117 *
118 * We need to use init_bootmem_node instead of init_bootmem
119 * because our map starts at a quite high address (min_low_pfn).
120 */
121
122 max_low_pfn = max_pfn;
123 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
124
125 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
Jesper Nilsson60dead52008-01-28 16:39:00 +0100126 min_low_pfn,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 max_low_pfn);
128
129 /* And free all memory not belonging to the kernel (addr, size) */
130
131 free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
132
133 /*
134 * Reserve the bootmem bitmap itself as well. We do this in two
135 * steps (first step was init_bootmem()) because this catches
136 * the (very unlikely) case of us accidentally initializing the
137 * bootmem allocator with an invalid RAM area.
138 *
139 * Arguments are start, size
140 */
141
Bernhard Walle72a7fe32008-02-07 00:15:17 -0800142 reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144 /* paging_init() sets up the MMU and marks all pages as reserved */
145
146 paging_init();
147
Mikael Starvik7cf32ca2005-07-27 11:44:38 -0700148 *cmdline_p = cris_command_line;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150#ifdef CONFIG_ETRAX_CMDLINE
Mikael Starvik7cf32ca2005-07-27 11:44:38 -0700151 if (!strcmp(cris_command_line, "")) {
152 strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
153 cris_command_line[COMMAND_LINE_SIZE - 1] = '\0';
154 }
155#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
157 /* Save command line for future references. */
Alon Bar-Lev87e1f9c2007-02-12 00:54:09 -0800158 memcpy(boot_command_line, cris_command_line, COMMAND_LINE_SIZE);
159 boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161 /* give credit for the CRIS port */
162 show_etrax_copyright();
Mikael Starvik7cf32ca2005-07-27 11:44:38 -0700163
164 /* Setup utsname */
Serge E. Hallyn96b644b2006-10-02 02:18:13 -0700165 strcpy(init_utsname()->machine, cris_machine_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166}
167
168static void *c_start(struct seq_file *m, loff_t *pos)
169{
Rusty Russell3e7be3f2009-03-16 14:11:46 +1030170 return *pos < nr_cpu_ids ? (void *)(int)(*pos + 1) : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171}
172
173static void *c_next(struct seq_file *m, void *v, loff_t *pos)
174{
175 ++*pos;
Mikael Starvik7cf32ca2005-07-27 11:44:38 -0700176 return c_start(m, pos);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177}
178
179static void c_stop(struct seq_file *m, void *v)
180{
181}
182
183extern int show_cpuinfo(struct seq_file *m, void *v);
184
Jesper Nilsson60dead52008-01-28 16:39:00 +0100185const struct seq_operations cpuinfo_op = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 .start = c_start,
187 .next = c_next,
188 .stop = c_stop,
189 .show = show_cpuinfo,
190};
191
Jesper Nilsson60dead52008-01-28 16:39:00 +0100192static int __init topology_init(void)
193{
194 int i;
195
196 for_each_possible_cpu(i) {
197 return register_cpu(&cpu_devices[i], i);
198 }
199
200 return 0;
201}
202
203subsys_initcall(topology_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204