File: /usr/src/linux/arch/cris/kernel/setup.c
1 /* $Id: setup.c,v 1.18 2001/06/28 04:47:16 hp Exp $
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/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/mm.h>
17 #include <linux/stddef.h>
18 #include <linux/unistd.h>
19 #include <linux/ptrace.h>
20 #include <linux/slab.h>
21 #include <linux/user.h>
22 #include <linux/a.out.h>
23 #include <linux/tty.h>
24 #include <linux/ioport.h>
25 #include <linux/delay.h>
26 #include <linux/config.h>
27 #include <linux/init.h>
28 #include <linux/bootmem.h>
29
30 #include <asm/segment.h>
31 #include <asm/system.h>
32 #include <asm/smp.h>
33 #include <asm/types.h>
34 #include <asm/svinto.h>
35
36 /*
37 * Setup options
38 */
39 struct drive_info_struct { char dummy[32]; } drive_info;
40 struct screen_info screen_info;
41
42 unsigned char aux_device_present;
43
44 extern int root_mountflags;
45 extern char _etext, _edata, _end;
46
47 #define COMMAND_LINE_SIZE 256
48
49 static char command_line[COMMAND_LINE_SIZE] = { 0, };
50 char saved_command_line[COMMAND_LINE_SIZE];
51
52 extern const unsigned long text_start, edata; /* set by the linker script */
53
54 extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
55
56 /* This mainly sets up the memory area, and can be really confusing.
57 *
58 * The physical DRAM is virtually mapped into dram_start to dram_end
59 * (usually c0000000 to c0000000 + DRAM size). The physical address is
60 * given by the macro __pa().
61 *
62 * In this DRAM, the kernel code and data is loaded, in the beginning.
63 * It really starts at c0004000 to make room for some special pages -
64 * the start address is text_start. The kernel data ends at _end. After
65 * this the ROM filesystem is appended (if there is any).
66 *
67 * Between this address and dram_end, we have RAM pages usable to the
68 * boot code and the system.
69 *
70 */
71
72 void __init
73 setup_arch(char **cmdline_p)
74 {
75 unsigned long bootmap_size;
76 unsigned long start_pfn, max_pfn;
77 unsigned long memory_start;
78 extern void console_print_etrax(const char *b);
79
80 /* register an initial console printing routine for printk's */
81
82 init_etrax_debug();
83
84 /* we should really poll for DRAM size! */
85
86 high_memory = &dram_end;
87
88 if(romfs_in_flash || !romfs_length) {
89 /* if we have the romfs in flash, or if there is no rom filesystem,
90 * our free area starts directly after the BSS
91 */
92 memory_start = (unsigned long) &_end;
93 } else {
94 /* otherwise the free area starts after the ROM filesystem */
95 printk("ROM fs in RAM, size %d bytes\n", romfs_length);
96 memory_start = romfs_start + romfs_length;
97 }
98
99 /* process 1's initial memory region is the kernel code/data */
100
101 init_mm.start_code = (unsigned long) &text_start;
102 init_mm.end_code = (unsigned long) &_etext;
103 init_mm.end_data = (unsigned long) &_edata;
104 init_mm.brk = (unsigned long) &_end;
105
106 #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
107 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
108 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
109
110 /* min_low_pfn points to the start of DRAM, start_pfn points
111 * to the first DRAM pages after the kernel, and max_low_pfn
112 * to the end of DRAM.
113 */
114
115 /*
116 * partially used pages are not usable - thus
117 * we are rounding upwards:
118 */
119
120 start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */
121 max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
122
123 /*
124 * Initialize the boot-time allocator (start, end)
125 *
126 * We give it access to all our DRAM, but we could as well just have
127 * given it a small slice. No point in doing that though, unless we
128 * have non-contiguous memory and want the boot-stuff to be in, say,
129 * the smallest area.
130 *
131 * It will put a bitmap of the allocated pages in the beginning
132 * of the range we give it, but it won't mark the bitmaps pages
133 * as reserved. We have to do that ourselves below.
134 *
135 * We need to use init_bootmem_node instead of init_bootmem
136 * because our map starts at a quite high address (min_low_pfn).
137 */
138
139 max_low_pfn = max_pfn;
140 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
141
142 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
143 min_low_pfn,
144 max_low_pfn);
145
146 /* And free all memory not belonging to the kernel (addr, size) */
147
148 free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
149
150 /*
151 * Reserve the bootmem bitmap itself as well. We do this in two
152 * steps (first step was init_bootmem()) because this catches
153 * the (very unlikely) case of us accidentally initializing the
154 * bootmem allocator with an invalid RAM area.
155 *
156 * Arguments are start, size
157 */
158
159 reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size);
160
161 /* paging_init() sets up the MMU and marks all pages as reserved */
162
163 paging_init();
164
165 /* We dont use a command line yet, so just re-initialize it without
166 saving anything that might be there. */
167
168 *cmdline_p = command_line;
169 strcpy(command_line, "root=/dev/rom"); /* use the appended romdisk as root */
170
171 /* give credit for the CRIS port */
172
173 printk("Linux/CRIS port on ETRAX 100LX (c) 2001 Axis Communications AB\n");
174
175 }
176
177 #ifdef CONFIG_PROC_FS
178 #define HAS_FPU 0x0001
179 #define HAS_MMU 0x0002
180 #define HAS_ETHERNET100 0x0004
181 #define HAS_TOKENRING 0x0008
182 #define HAS_SCSI 0x0010
183 #define HAS_ATA 0x0020
184 #define HAS_USB 0x0040
185 #define HAS_IRQ_BUG 0x0080
186 #define HAS_MMU_BUG 0x0100
187
188 static struct cpu_info {
189 char *model;
190 unsigned short cache;
191 unsigned short flags;
192 } cpu_info[] = {
193 /* The first four models will never ever run this code and are
194 only here for display. */
195 { "ETRAX 1", 0, 0 },
196 { "ETRAX 2", 0, 0 },
197 { "ETRAX 3", 0, HAS_TOKENRING },
198 { "ETRAX 4", 0, HAS_TOKENRING | HAS_SCSI },
199 { "Unknown", 0, 0 },
200 { "Unknown", 0, 0 },
201 { "Unknown", 0, 0 },
202 { "Simulator", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA },
203 { "ETRAX 100", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_IRQ_BUG },
204 { "ETRAX 100", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA },
205 { "ETRAX 100LX", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB | HAS_MMU | HAS_MMU_BUG },
206 { "ETRAX 100LX v2", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB | HAS_MMU },
207 { "Unknown", 0, 0 },
208 };
209
210 /*
211 * BUFFER is PAGE_SIZE bytes long.
212 */
213 int get_cpuinfo(char *buffer)
214 {
215 int revision;
216 #ifndef CONFIG_SVINTO_SIM
217 unsigned char tmp;
218
219 __asm__ volatile ("move vr,%0" : "=rm" (tmp));
220 revision = tmp;
221 #else
222 /* Fake a revision for the simulator */
223 revision = 7;
224 #endif
225
226 return sprintf(buffer,
227 "cpu\t\t: CRIS\n"
228 "cpu revision\t: %d\n"
229 "cpu model\t: %s\n"
230 "cache size\t: %d kB\n"
231 "fpu\t\t: %s\n"
232 "mmu\t\t: %s\n"
233 "mmu DMA bug\t: %s\n"
234 "ethernet\t: %s Mbps\n"
235 "token ring\t: %s\n"
236 "scsi\t\t: %s\n"
237 "ata\t\t: %s\n"
238 "usb\t\t: %s\n"
239 "bogomips\t: %lu.%02lu\n",
240
241 revision,
242 cpu_info[revision].model,
243 cpu_info[revision].cache,
244 cpu_info[revision].flags & HAS_FPU ? "yes" : "no",
245 cpu_info[revision].flags & HAS_MMU ? "yes" : "no",
246 cpu_info[revision].flags & HAS_MMU_BUG ? "yes" : "no",
247 cpu_info[revision].flags & HAS_ETHERNET100 ? "10/100" : "10",
248 cpu_info[revision].flags & HAS_TOKENRING ? "4/16 Mbps" : "no",
249 cpu_info[revision].flags & HAS_SCSI ? "yes" : "no",
250 cpu_info[revision].flags & HAS_ATA ? "yes" : "no",
251 cpu_info[revision].flags & HAS_USB ? "yes" : "no",
252 (loops_per_jiffy * HZ + 500) / 500000,
253 ((loops_per_jiffy * HZ + 500) / 5000) % 100);
254 }
255 #endif /* CONFIG_PROC_FS */
256