2 * linux/arch/cris/kernel/setup.c
4 * Copyright (C) 1995 Linus Torvalds
5 * Copyright (c) 2001, 2002, 2003 Axis Communications AB
9 * This file handles the architecture-dependent parts of initialization
12 #include <linux/errno.h>
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
16 #include <linux/stddef.h>
17 #include <linux/unistd.h>
18 #include <linux/ptrace.h>
19 #include <linux/slab.h>
20 #include <linux/user.h>
21 #include <linux/a.out.h>
22 #include <linux/tty.h>
23 #include <linux/ioport.h>
24 #include <linux/delay.h>
25 #include <linux/config.h>
26 #include <linux/init.h>
27 #include <linux/bootmem.h>
28 #include <linux/seq_file.h>
30 #include <asm/segment.h>
31 #include <asm/system.h>
33 #include <asm/pgtable.h>
34 #include <asm/types.h>
35 #include <asm/svinto.h>
40 struct drive_info_struct { char dummy[32]; } drive_info;
41 struct screen_info screen_info;
43 unsigned char aux_device_present;
45 extern int root_mountflags;
46 extern char _etext, _edata, _end;
48 #define COMMAND_LINE_SIZE 256
50 static char command_line[COMMAND_LINE_SIZE] = { 0, };
51 char saved_command_line[COMMAND_LINE_SIZE];
53 extern const unsigned long text_start, edata; /* set by the linker script */
55 extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
57 /* This mainly sets up the memory area, and can be really confusing.
59 * The physical DRAM is virtually mapped into dram_start to dram_end
60 * (usually c0000000 to c0000000 + DRAM size). The physical address is
61 * given by the macro __pa().
63 * In this DRAM, the kernel code and data is loaded, in the beginning.
64 * It really starts at c0004000 to make room for some special pages -
65 * the start address is text_start. The kernel data ends at _end. After
66 * this the ROM filesystem is appended (if there is any).
68 * Between this address and dram_end, we have RAM pages usable to the
69 * boot code and the system.
74 setup_arch(char **cmdline_p)
76 extern void init_etrax_debug(void);
77 unsigned long bootmap_size;
78 unsigned long start_pfn, max_pfn;
79 unsigned long memory_start;
81 /* register an initial console printing routine for printk's */
85 /* we should really poll for DRAM size! */
87 high_memory = &dram_end;
89 if(romfs_in_flash || !romfs_length) {
90 /* if we have the romfs in flash, or if there is no rom filesystem,
91 * our free area starts directly after the BSS
93 memory_start = (unsigned long) &_end;
95 /* otherwise the free area starts after the ROM filesystem */
96 printk(KERN_INFO "ROM fs in RAM, size %lu bytes\n",
98 memory_start = romfs_start + romfs_length;
101 /* process 1's initial memory region is the kernel code/data */
103 init_mm.start_code = (unsigned long) &text_start;
104 init_mm.end_code = (unsigned long) &_etext;
105 init_mm.end_data = (unsigned long) &_edata;
106 init_mm.brk = (unsigned long) &_end;
108 #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
109 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
110 #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
112 /* min_low_pfn points to the start of DRAM, start_pfn points
113 * to the first DRAM pages after the kernel, and max_low_pfn
114 * to the end of DRAM.
118 * partially used pages are not usable - thus
119 * we are rounding upwards:
122 start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */
123 max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
126 * Initialize the boot-time allocator (start, end)
128 * We give it access to all our DRAM, but we could as well just have
129 * given it a small slice. No point in doing that though, unless we
130 * have non-contiguous memory and want the boot-stuff to be in, say,
133 * It will put a bitmap of the allocated pages in the beginning
134 * of the range we give it, but it won't mark the bitmaps pages
135 * as reserved. We have to do that ourselves below.
137 * We need to use init_bootmem_node instead of init_bootmem
138 * because our map starts at a quite high address (min_low_pfn).
141 max_low_pfn = max_pfn;
142 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
144 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
148 /* And free all memory not belonging to the kernel (addr, size) */
150 free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
153 * Reserve the bootmem bitmap itself as well. We do this in two
154 * steps (first step was init_bootmem()) because this catches
155 * the (very unlikely) case of us accidentally initializing the
156 * bootmem allocator with an invalid RAM area.
158 * Arguments are start, size
161 reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size);
163 /* paging_init() sets up the MMU and marks all pages as reserved */
167 /* We dont use a command line yet, so just re-initialize it without
168 saving anything that might be there. */
170 *cmdline_p = command_line;
172 #ifdef CONFIG_ETRAX_CMDLINE
173 strncpy(command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
174 #elif defined(CONFIG_ETRAX_ROOT_DEVICE)
175 strncpy(command_line, "root=", COMMAND_LINE_SIZE);
176 strncpy(command_line+5, CONFIG_ETRAX_ROOT_DEVICE,
177 COMMAND_LINE_SIZE-5);
179 command_line[COMMAND_LINE_SIZE - 1] = '\0';
181 /* Save command line copy for /proc/cmdline */
183 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
184 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
186 /* give credit for the CRIS port */
188 printk(KERN_INFO "Linux/CRIS port on ETRAX 100LX (c) 2001, 2002 Axis Communications AB\n");
192 #ifdef CONFIG_PROC_FS
193 #define HAS_FPU 0x0001
194 #define HAS_MMU 0x0002
195 #define HAS_ETHERNET100 0x0004
196 #define HAS_TOKENRING 0x0008
197 #define HAS_SCSI 0x0010
198 #define HAS_ATA 0x0020
199 #define HAS_USB 0x0040
200 #define HAS_IRQ_BUG 0x0080
201 #define HAS_MMU_BUG 0x0100
203 static struct cpu_info {
205 unsigned short cache;
206 unsigned short flags;
208 /* The first four models will never ever run this code and are
209 only here for display. */
212 { "ETRAX 3", 0, HAS_TOKENRING },
213 { "ETRAX 4", 0, HAS_TOKENRING | HAS_SCSI },
217 { "Simulator", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA },
218 { "ETRAX 100", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_IRQ_BUG },
219 { "ETRAX 100", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA },
220 { "ETRAX 100LX", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB | HAS_MMU | HAS_MMU_BUG },
221 { "ETRAX 100LX v2", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB | HAS_MMU },
222 { "Unknown", 0, 0 } /* This entry MUST be the last */
225 static int show_cpuinfo(struct seq_file *m, void *v)
227 unsigned long revision;
228 struct cpu_info *info;
230 /* read the version register in the CPU and print some stuff */
234 if (revision >= sizeof cpu_info/sizeof *cpu_info)
235 info = &cpu_info[sizeof cpu_info/sizeof *cpu_info - 1];
237 info = &cpu_info[revision];
242 "cpu revision\t: %lu\n"
244 "cache size\t: %d kB\n"
247 "mmu DMA bug\t: %s\n"
248 "ethernet\t: %s Mbps\n"
253 "bogomips\t: %lu.%02lu\n",
258 info->flags & HAS_FPU ? "yes" : "no",
259 info->flags & HAS_MMU ? "yes" : "no",
260 info->flags & HAS_MMU_BUG ? "yes" : "no",
261 info->flags & HAS_ETHERNET100 ? "10/100" : "10",
262 info->flags & HAS_TOKENRING ? "4/16 Mbps" : "no",
263 info->flags & HAS_SCSI ? "yes" : "no",
264 info->flags & HAS_ATA ? "yes" : "no",
265 info->flags & HAS_USB ? "yes" : "no",
266 (loops_per_jiffy * HZ + 500) / 500000,
267 ((loops_per_jiffy * HZ + 500) / 5000) % 100);
270 static void *c_start(struct seq_file *m, loff_t *pos)
272 /* We only got one CPU... */
273 return *pos < 1 ? (void *)1 : NULL;
276 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
282 static void c_stop(struct seq_file *m, void *v)
286 struct seq_operations cpuinfo_op = {
293 #endif /* CONFIG_PROC_FS */