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