linux/arch/cris/kernel/setup.c
<<
>>
Prefs
   1/*
   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/init.h>
  14#include <linux/mm.h>
  15#include <linux/bootmem.h>
  16#include <asm/pgtable.h>
  17#include <linux/seq_file.h>
  18#include <linux/screen_info.h>
  19#include <linux/utsname.h>
  20#include <linux/pfn.h>
  21#include <linux/cpu.h>
  22#include <linux/of.h>
  23#include <linux/of_fdt.h>
  24#include <asm/setup.h>
  25#include <arch/system.h>
  26
  27/*
  28 * Setup options
  29 */
  30struct screen_info screen_info;
  31
  32extern int root_mountflags;
  33extern char _etext, _edata, _end;
  34
  35char __initdata cris_command_line[COMMAND_LINE_SIZE] = { 0, };
  36
  37extern const unsigned long text_start, edata; /* set by the linker script */
  38extern unsigned long dram_start, dram_end;
  39
  40extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
  41
  42static struct cpu cpu_devices[NR_CPUS];
  43
  44extern void show_etrax_copyright(void);         /* arch-vX/kernel/setup.c */
  45
  46/* This mainly sets up the memory area, and can be really confusing.
  47 *
  48 * The physical DRAM is virtually mapped into dram_start to dram_end
  49 * (usually c0000000 to c0000000 + DRAM size). The physical address is
  50 * given by the macro __pa().
  51 *
  52 * In this DRAM, the kernel code and data is loaded, in the beginning.
  53 * It really starts at c0004000 to make room for some special pages -
  54 * the start address is text_start. The kernel data ends at _end. After
  55 * this the ROM filesystem is appended (if there is any).
  56 *
  57 * Between this address and dram_end, we have RAM pages usable to the
  58 * boot code and the system.
  59 *
  60 */
  61
  62void __init setup_arch(char **cmdline_p)
  63{
  64        extern void init_etrax_debug(void);
  65        unsigned long bootmap_size;
  66        unsigned long start_pfn, max_pfn;
  67        unsigned long memory_start;
  68
  69#ifdef CONFIG_OF
  70        early_init_dt_scan(__dtb_start);
  71#endif
  72
  73        /* register an initial console printing routine for printk's */
  74
  75        init_etrax_debug();
  76
  77        /* we should really poll for DRAM size! */
  78
  79        high_memory = &dram_end;
  80
  81        if(romfs_in_flash || !romfs_length) {
  82                /* if we have the romfs in flash, or if there is no rom filesystem,
  83                 * our free area starts directly after the BSS
  84                 */
  85                memory_start = (unsigned long) &_end;
  86        } else {
  87                /* otherwise the free area starts after the ROM filesystem */
  88                printk("ROM fs in RAM, size %lu bytes\n", romfs_length);
  89                memory_start = romfs_start + romfs_length;
  90        }
  91
  92        /* process 1's initial memory region is the kernel code/data */
  93
  94        init_mm.start_code = (unsigned long) &text_start;
  95        init_mm.end_code =   (unsigned long) &_etext;
  96        init_mm.end_data =   (unsigned long) &_edata;
  97        init_mm.brk =        (unsigned long) &_end;
  98
  99        /* min_low_pfn points to the start of DRAM, start_pfn points
 100         * to the first DRAM pages after the kernel, and max_low_pfn
 101         * to the end of DRAM.
 102         */
 103
 104        /*
 105         * partially used pages are not usable - thus
 106         * we are rounding upwards:
 107         */
 108
 109        start_pfn = PFN_UP(memory_start);  /* usually c0000000 + kernel + romfs */
 110        max_pfn =   PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
 111
 112        /*
 113         * Initialize the boot-time allocator (start, end)
 114         *
 115         * We give it access to all our DRAM, but we could as well just have
 116         * given it a small slice. No point in doing that though, unless we
 117         * have non-contiguous memory and want the boot-stuff to be in, say,
 118         * the smallest area.
 119         *
 120         * It will put a bitmap of the allocated pages in the beginning
 121         * of the range we give it, but it won't mark the bitmaps pages
 122         * as reserved. We have to do that ourselves below.
 123         *
 124         * We need to use init_bootmem_node instead of init_bootmem
 125         * because our map starts at a quite high address (min_low_pfn).
 126         */
 127
 128        max_low_pfn = max_pfn;
 129        min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
 130
 131        bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
 132                                         min_low_pfn,
 133                                         max_low_pfn);
 134
 135        /* And free all memory not belonging to the kernel (addr, size) */
 136
 137        free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
 138
 139        /*
 140         * Reserve the bootmem bitmap itself as well. We do this in two
 141         * steps (first step was init_bootmem()) because this catches
 142         * the (very unlikely) case of us accidentally initializing the
 143         * bootmem allocator with an invalid RAM area.
 144         *
 145         * Arguments are start, size
 146         */
 147
 148        reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);
 149
 150        unflatten_and_copy_device_tree();
 151
 152        /* paging_init() sets up the MMU and marks all pages as reserved */
 153
 154        paging_init();
 155
 156        *cmdline_p = cris_command_line;
 157
 158#ifdef CONFIG_ETRAX_CMDLINE
 159        if (!strcmp(cris_command_line, "")) {
 160                strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
 161                cris_command_line[COMMAND_LINE_SIZE - 1] = '\0';
 162        }
 163#endif
 164
 165        /* Save command line for future references. */
 166        memcpy(boot_command_line, cris_command_line, COMMAND_LINE_SIZE);
 167        boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';
 168
 169        /* give credit for the CRIS port */
 170        show_etrax_copyright();
 171
 172        /* Setup utsname */
 173        strcpy(init_utsname()->machine, cris_machine_name);
 174}
 175
 176#ifdef CONFIG_PROC_FS
 177static void *c_start(struct seq_file *m, loff_t *pos)
 178{
 179        return *pos < nr_cpu_ids ? (void *)(int)(*pos + 1) : NULL;
 180}
 181
 182static void *c_next(struct seq_file *m, void *v, loff_t *pos)
 183{
 184        ++*pos;
 185        return c_start(m, pos);
 186}
 187
 188static void c_stop(struct seq_file *m, void *v)
 189{
 190}
 191
 192extern int show_cpuinfo(struct seq_file *m, void *v);
 193
 194const struct seq_operations cpuinfo_op = {
 195        .start = c_start,
 196        .next  = c_next,
 197        .stop  = c_stop,
 198        .show  = show_cpuinfo,
 199};
 200#endif /* CONFIG_PROC_FS */
 201
 202static int __init topology_init(void)
 203{
 204        int i;
 205
 206        for_each_possible_cpu(i) {
 207                 return register_cpu(&cpu_devices[i], i);
 208        }
 209
 210        return 0;
 211}
 212
 213subsys_initcall(topology_init);
 214