os/linux-2.6-tag--devboard-R2_10-4/arch/cris/kernel/setup.c

Go to the documentation of this file.
00001 /*
00002  *
00003  *  linux/arch/cris/kernel/setup.c
00004  *
00005  *  Copyright (C) 1995  Linus Torvalds
00006  *  Copyright (c) 2001  Axis Communications AB
00007  */
00008 
00009 /*
00010  * This file handles the architecture-dependent parts of initialization
00011  */
00012 
00013 #include <linux/init.h>
00014 #include <linux/mm.h>
00015 #include <linux/bootmem.h>
00016 #include <asm/pgtable.h>
00017 #include <linux/seq_file.h>
00018 #include <linux/screen_info.h>
00019 #include <linux/utsname.h>
00020 #include <linux/pfn.h>
00021 #include <linux/cpu.h>
00022 #include <asm/setup.h>
00023 
00024 /*
00025  * Setup options
00026  */
00027 struct screen_info screen_info;
00028 
00029 extern int root_mountflags;
00030 extern char _etext, _edata, _end;
00031 
00032 char cris_command_line[COMMAND_LINE_SIZE] = { 0, };
00033 
00034 extern const unsigned long text_start, edata; /* set by the linker script */
00035 extern unsigned long dram_start, dram_end;
00036 
00037 extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
00038 
00039 static struct cpu cpu_devices[NR_CPUS];
00040 
00041 extern void show_etrax_copyright(void);         /* arch-vX/kernel/setup.c */
00042 
00043 /* This mainly sets up the memory area, and can be really confusing.
00044  *
00045  * The physical DRAM is virtually mapped into dram_start to dram_end
00046  * (usually c0000000 to c0000000 + DRAM size). The physical address is
00047  * given by the macro __pa().
00048  *
00049  * In this DRAM, the kernel code and data is loaded, in the beginning.
00050  * It really starts at c0004000 to make room for some special pages - 
00051  * the start address is text_start. The kernel data ends at _end. After
00052  * this the ROM filesystem is appended (if there is any).
00053  * 
00054  * Between this address and dram_end, we have RAM pages usable to the
00055  * boot code and the system.
00056  *
00057  */
00058 
00059 void __init 
00060 setup_arch(char **cmdline_p)
00061 {
00062         extern void init_etrax_debug(void);
00063         unsigned long bootmap_size;
00064         unsigned long start_pfn, max_pfn;
00065         unsigned long memory_start;
00066 
00067         /* register an initial console printing routine for printk's */
00068 
00069         init_etrax_debug();
00070 
00071         /* we should really poll for DRAM size! */
00072 
00073         high_memory = &dram_end;
00074 
00075         if(romfs_in_flash || !romfs_length) {
00076                 /* if we have the romfs in flash, or if there is no rom filesystem,
00077                  * our free area starts directly after the BSS
00078                  */
00079                 memory_start = (unsigned long) &_end;
00080         } else {
00081                 /* otherwise the free area starts after the ROM filesystem */
00082                 printk("ROM fs in RAM, size %lu bytes\n", romfs_length);
00083                 memory_start = romfs_start + romfs_length;
00084         }
00085 
00086         /* process 1's initial memory region is the kernel code/data */
00087 
00088         init_mm.start_code = (unsigned long) &text_start;
00089         init_mm.end_code =   (unsigned long) &_etext;
00090         init_mm.end_data =   (unsigned long) &_edata;
00091         init_mm.brk =        (unsigned long) &_end;
00092 
00093         /* min_low_pfn points to the start of DRAM, start_pfn points
00094          * to the first DRAM pages after the kernel, and max_low_pfn
00095          * to the end of DRAM.
00096          */
00097 
00098         /*
00099          * partially used pages are not usable - thus
00100          * we are rounding upwards:
00101          */
00102 
00103         start_pfn = PFN_UP(memory_start);  /* usually c0000000 + kernel + romfs */
00104         max_pfn =   PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
00105 
00106         /*
00107          * Initialize the boot-time allocator (start, end)
00108          *
00109          * We give it access to all our DRAM, but we could as well just have
00110          * given it a small slice. No point in doing that though, unless we
00111          * have non-contiguous memory and want the boot-stuff to be in, say,
00112          * the smallest area.
00113          *
00114          * It will put a bitmap of the allocated pages in the beginning
00115          * of the range we give it, but it won't mark the bitmaps pages
00116          * as reserved. We have to do that ourselves below.
00117          *
00118          * We need to use init_bootmem_node instead of init_bootmem
00119          * because our map starts at a quite high address (min_low_pfn).
00120          */
00121 
00122         max_low_pfn = max_pfn;
00123         min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
00124 
00125         bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
00126                                          min_low_pfn, 
00127                                          max_low_pfn);
00128 
00129         /* And free all memory not belonging to the kernel (addr, size) */
00130 
00131         free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
00132 
00133         /*
00134          * Reserve the bootmem bitmap itself as well. We do this in two
00135          * steps (first step was init_bootmem()) because this catches
00136          * the (very unlikely) case of us accidentally initializing the
00137          * bootmem allocator with an invalid RAM area.
00138          *
00139          * Arguments are start, size
00140          */
00141 
00142         reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size);
00143 
00144         /* paging_init() sets up the MMU and marks all pages as reserved */
00145 
00146         paging_init();
00147 
00148         /* look for command line in memory */
00149         //#define CMDLINE_MAGIC 0x87109563
00150         #define CMDLINE_MAGIC   0x63951087
00151         unsigned char *cmdline_ram = (unsigned char *)0xC0004000;
00152         unsigned long *ul_cmdline_ram = (unsigned long *)0xC0004000;
00153 //      printk("____________________________________________________________\n");
00154 //      printk("==>> stamp in memory is: 0x%02X, 0x%02X, 0x%02X, 0x%02X\n", cmdline_ram[0], cmdline_ram[1], cmdline_ram[2], cmdline_ram[3]);
00155         if(ul_cmdline_ram[0] == CMDLINE_MAGIC) {
00156                 printk("command line found: \"%s\"\n", &cmdline_ram[4]);
00157                 strcpy(cris_command_line, &cmdline_ram[4]);
00158         } else {
00159 //              printk("magic is: 0x%08X; stamp in memory is: 0x%08X\n", CMDLINE_MAGIC, ul_cmdline_ram[0]);
00160         }
00161         cmdline_ram[0] = 0x00;
00162         cmdline_ram[1] = 0x00;
00163         cmdline_ram[2] = 0x00;
00164         cmdline_ram[3] = 0x00;
00165 
00166         *cmdline_p = cris_command_line;
00167 
00168 #ifdef CONFIG_ETRAX_CMDLINE
00169         if (!strcmp(cris_command_line, "")) {
00170                 strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
00171                 cris_command_line[COMMAND_LINE_SIZE - 1] = '\0';
00172         }
00173 #endif
00174 
00175         /* Save command line for future references. */
00176         memcpy(saved_command_line, cris_command_line, COMMAND_LINE_SIZE);
00177         saved_command_line[COMMAND_LINE_SIZE - 1] = '\0';
00178 
00179         /* give credit for the CRIS port */
00180         show_etrax_copyright();
00181 
00182         /* Setup utsname */
00183         strcpy(init_utsname()->machine, cris_machine_name);
00184 }
00185 
00186 static void *c_start(struct seq_file *m, loff_t *pos)
00187 {
00188         return *pos < NR_CPUS ? (void *)(int)(*pos + 1): NULL;
00189 }
00190 
00191 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
00192 {
00193         ++*pos;
00194         return c_start(m, pos);
00195 }
00196 
00197 static void c_stop(struct seq_file *m, void *v)
00198 {
00199 }
00200 
00201 extern int show_cpuinfo(struct seq_file *m, void *v);
00202 
00203 struct seq_operations cpuinfo_op = {
00204         .start = c_start,
00205         .next  = c_next,
00206         .stop  = c_stop,
00207         .show  = show_cpuinfo,
00208 };
00209 
00210 static int __init topology_init(void)
00211 {
00212         int i;
00213         
00214         for_each_possible_cpu(i) {
00215                  return register_cpu(&cpu_devices[i], i);
00216         }
00217 }
00218 
00219 subsys_initcall(topology_init);
00220 

Generated on Fri Nov 28 00:06:23 2008 for elphel by  doxygen 1.5.1