1/* $Id: setup.c,v 1.1.1.1 2008/10/15 03:26:01 james26_jang 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#include <linux/seq_file.h> 30 31#include <asm/segment.h> 32#include <asm/system.h> 33#include <asm/smp.h> 34#include <asm/pgtable.h> 35#include <asm/types.h> 36#include <asm/svinto.h> 37 38/* 39 * Setup options 40 */ 41struct drive_info_struct { char dummy[32]; } drive_info; 42struct screen_info screen_info; 43 44unsigned char aux_device_present; 45 46extern int root_mountflags; 47extern char _etext, _edata, _end; 48 49#define COMMAND_LINE_SIZE 256 50 51static char command_line[COMMAND_LINE_SIZE] = { 0, }; 52 char saved_command_line[COMMAND_LINE_SIZE]; 53 54extern const unsigned long text_start, edata; /* set by the linker script */ 55 56extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */ 57 58/* This mainly sets up the memory area, and can be really confusing. 59 * 60 * The physical DRAM is virtually mapped into dram_start to dram_end 61 * (usually c0000000 to c0000000 + DRAM size). The physical address is 62 * given by the macro __pa(). 63 * 64 * In this DRAM, the kernel code and data is loaded, in the beginning. 65 * It really starts at c0004000 to make room for some special pages - 66 * the start address is text_start. The kernel data ends at _end. After 67 * this the ROM filesystem is appended (if there is any). 68 * 69 * Between this address and dram_end, we have RAM pages usable to the 70 * boot code and the system. 71 * 72 */ 73 74void __init 75setup_arch(char **cmdline_p) 76{ 77 extern void init_etrax_debug(void); 78 unsigned long bootmap_size; 79 unsigned long start_pfn, max_pfn; 80 unsigned long memory_start; 81 82 /* register an initial console printing routine for printk's */ 83 84 init_etrax_debug(); 85 86 /* we should really poll for DRAM size! */ 87 88 high_memory = &dram_end; 89 90 if(romfs_in_flash || !romfs_length) { 91 /* if we have the romfs in flash, or if there is no rom filesystem, 92 * our free area starts directly after the BSS 93 */ 94 memory_start = (unsigned long) &_end; 95 } else { 96 /* otherwise the free area starts after the ROM filesystem */ 97 printk("ROM fs in RAM, size %lu bytes\n", romfs_length); 98 memory_start = romfs_start + romfs_length; 99 } 100 101 /* process 1's initial memory region is the kernel code/data */ 102 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; 107 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) 111 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. 115 */ 116 117 /* 118 * partially used pages are not usable - thus 119 * we are rounding upwards: 120 */ 121 122 start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */ 123 max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */ 124 125 /* 126 * Initialize the boot-time allocator (start, end) 127 * 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, 131 * the smallest area. 132 * 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. 136 * 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). 139 */ 140 141 max_low_pfn = max_pfn; 142 min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT; 143 144 bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, 145 min_low_pfn, 146 max_low_pfn); 147 148 /* And free all memory not belonging to the kernel (addr, size) */ 149 150 free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn)); 151 152 /* 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. 157 * 158 * Arguments are start, size 159 */ 160 161 reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size); 162 163 /* paging_init() sets up the MMU and marks all pages as reserved */ 164 165 paging_init(); 166 167 /* We dont use a command line yet, so just re-initialize it without 168 saving anything that might be there. */ 169 170 *cmdline_p = command_line; 171 172 strncpy(command_line, "root=", COMMAND_LINE_SIZE); 173 strncpy(command_line+5, CONFIG_ETRAX_ROOT_DEVICE, 174 COMMAND_LINE_SIZE-5); 175 176 /* Save command line copy for /proc/cmdline */ 177 178 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 179 saved_command_line[COMMAND_LINE_SIZE-1] = '\0'; 180 181 /* give credit for the CRIS port */ 182 183 printk("Linux/CRIS port on ETRAX 100LX (c) 2001, 2002 Axis Communications AB\n"); 184 185} 186 187#ifdef CONFIG_PROC_FS 188#define HAS_FPU 0x0001 189#define HAS_MMU 0x0002 190#define HAS_ETHERNET100 0x0004 191#define HAS_TOKENRING 0x0008 192#define HAS_SCSI 0x0010 193#define HAS_ATA 0x0020 194#define HAS_USB 0x0040 195#define HAS_IRQ_BUG 0x0080 196#define HAS_MMU_BUG 0x0100 197 198static struct cpu_info { 199 char *model; 200 unsigned short cache; 201 unsigned short flags; 202} cpu_info[] = { 203 /* The first four models will never ever run this code and are 204 only here for display. */ 205 { "ETRAX 1", 0, 0 }, 206 { "ETRAX 2", 0, 0 }, 207 { "ETRAX 3", 0, HAS_TOKENRING }, 208 { "ETRAX 4", 0, HAS_TOKENRING | HAS_SCSI }, 209 { "Unknown", 0, 0 }, 210 { "Unknown", 0, 0 }, 211 { "Unknown", 0, 0 }, 212 { "Simulator", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA }, 213 { "ETRAX 100", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_IRQ_BUG }, 214 { "ETRAX 100", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA }, 215 { "ETRAX 100LX", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB | HAS_MMU | HAS_MMU_BUG }, 216 { "ETRAX 100LX v2", 8, HAS_ETHERNET100 | HAS_SCSI | HAS_ATA | HAS_USB | HAS_MMU }, 217 { "Unknown", 0, 0 } /* This entry MUST be the last */ 218}; 219 220static int show_cpuinfo(struct seq_file *m, void *v) 221{ 222 unsigned long revision; 223 struct cpu_info *info; 224 225 /* read the version register in the CPU and print some stuff */ 226 227 revision = rdvr(); 228 229 if (revision >= sizeof cpu_info/sizeof *cpu_info) 230 info = &cpu_info[sizeof cpu_info/sizeof *cpu_info - 1]; 231 else 232 info = &cpu_info[revision]; 233 234 return seq_printf(m, 235 "cpu\t\t: CRIS\n" 236 "cpu revision\t: %lu\n" 237 "cpu model\t: %s\n" 238 "cache size\t: %d kB\n" 239 "fpu\t\t: %s\n" 240 "mmu\t\t: %s\n" 241 "mmu DMA bug\t: %s\n" 242 "ethernet\t: %s Mbps\n" 243 "token ring\t: %s\n" 244 "scsi\t\t: %s\n" 245 "ata\t\t: %s\n" 246 "usb\t\t: %s\n" 247 "bogomips\t: %lu.%02lu\n", 248 249 revision, 250 info->model, 251 info->cache, 252 info->flags & HAS_FPU ? "yes" : "no", 253 info->flags & HAS_MMU ? "yes" : "no", 254 info->flags & HAS_MMU_BUG ? "yes" : "no", 255 info->flags & HAS_ETHERNET100 ? "10/100" : "10", 256 info->flags & HAS_TOKENRING ? "4/16 Mbps" : "no", 257 info->flags & HAS_SCSI ? "yes" : "no", 258 info->flags & HAS_ATA ? "yes" : "no", 259 info->flags & HAS_USB ? "yes" : "no", 260 (loops_per_jiffy * HZ + 500) / 500000, 261 ((loops_per_jiffy * HZ + 500) / 5000) % 100); 262} 263 264static void *c_start(struct seq_file *m, loff_t *pos) 265{ 266 /* We only got one CPU... */ 267 return *pos < 1 ? (void *)1 : NULL; 268} 269 270static void *c_next(struct seq_file *m, void *v, loff_t *pos) 271{ 272 ++*pos; 273 return NULL; 274} 275 276static void c_stop(struct seq_file *m, void *v) 277{ 278} 279 280struct seq_operations cpuinfo_op = { 281 start: c_start, 282 next: c_next, 283 stop: c_stop, 284 show: show_cpuinfo, 285}; 286 287#endif /* CONFIG_PROC_FS */ 288