/*1*2* linux/arch/cris/kernel/setup.c3*4* Copyright (C) 1995 Linus Torvalds5* Copyright (c) 2001 Axis Communications AB6*/78/*9* This file handles the architecture-dependent parts of initialization10*/1112#include <linux/init.h>13#include <linux/mm.h>14#include <linux/bootmem.h>15#include <asm/pgtable.h>16#include <linux/seq_file.h>17#include <linux/screen_info.h>18#include <linux/utsname.h>19#include <linux/pfn.h>20#include <linux/cpu.h>21#include <asm/setup.h>2223/*24* Setup options25*/26struct screen_info screen_info;2728extern int root_mountflags;29extern char _etext, _edata, _end;3031char __initdata cris_command_line[COMMAND_LINE_SIZE] = { 0, };3233extern const unsigned long text_start, edata; /* set by the linker script */34extern unsigned long dram_start, dram_end;3536extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */3738static struct cpu cpu_devices[NR_CPUS];3940extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */4142/* This mainly sets up the memory area, and can be really confusing.43*44* The physical DRAM is virtually mapped into dram_start to dram_end45* (usually c0000000 to c0000000 + DRAM size). The physical address is46* given by the macro __pa().47*48* In this DRAM, the kernel code and data is loaded, in the beginning.49* It really starts at c0004000 to make room for some special pages -50* the start address is text_start. The kernel data ends at _end. After51* this the ROM filesystem is appended (if there is any).52*53* Between this address and dram_end, we have RAM pages usable to the54* boot code and the system.55*56*/5758void __init setup_arch(char **cmdline_p)59{60extern void init_etrax_debug(void);61unsigned long bootmap_size;62unsigned long start_pfn, max_pfn;63unsigned long memory_start;6465/* register an initial console printing routine for printk's */6667init_etrax_debug();6869/* we should really poll for DRAM size! */7071high_memory = &dram_end;7273if(romfs_in_flash || !romfs_length) {74/* if we have the romfs in flash, or if there is no rom filesystem,75* our free area starts directly after the BSS76*/77memory_start = (unsigned long) &_end;78} else {79/* otherwise the free area starts after the ROM filesystem */80printk("ROM fs in RAM, size %lu bytes\n", romfs_length);81memory_start = romfs_start + romfs_length;82}8384/* process 1's initial memory region is the kernel code/data */8586init_mm.start_code = (unsigned long) &text_start;87init_mm.end_code = (unsigned long) &_etext;88init_mm.end_data = (unsigned long) &_edata;89init_mm.brk = (unsigned long) &_end;9091/* min_low_pfn points to the start of DRAM, start_pfn points92* to the first DRAM pages after the kernel, and max_low_pfn93* to the end of DRAM.94*/9596/*97* partially used pages are not usable - thus98* we are rounding upwards:99*/100101start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */102max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */103104/*105* Initialize the boot-time allocator (start, end)106*107* We give it access to all our DRAM, but we could as well just have108* given it a small slice. No point in doing that though, unless we109* have non-contiguous memory and want the boot-stuff to be in, say,110* the smallest area.111*112* It will put a bitmap of the allocated pages in the beginning113* of the range we give it, but it won't mark the bitmaps pages114* as reserved. We have to do that ourselves below.115*116* We need to use init_bootmem_node instead of init_bootmem117* because our map starts at a quite high address (min_low_pfn).118*/119120max_low_pfn = max_pfn;121min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;122123bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,124min_low_pfn,125max_low_pfn);126127/* And free all memory not belonging to the kernel (addr, size) */128129free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));130131/*132* Reserve the bootmem bitmap itself as well. We do this in two133* steps (first step was init_bootmem()) because this catches134* the (very unlikely) case of us accidentally initializing the135* bootmem allocator with an invalid RAM area.136*137* Arguments are start, size138*/139140reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);141142/* paging_init() sets up the MMU and marks all pages as reserved */143144paging_init();145146*cmdline_p = cris_command_line;147148#ifdef CONFIG_ETRAX_CMDLINE149if (!strcmp(cris_command_line, "")) {150strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);151cris_command_line[COMMAND_LINE_SIZE - 1] = '\0';152}153#endif154155/* Save command line for future references. */156memcpy(boot_command_line, cris_command_line, COMMAND_LINE_SIZE);157boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';158159/* give credit for the CRIS port */160show_etrax_copyright();161162/* Setup utsname */163strcpy(init_utsname()->machine, cris_machine_name);164}165166static void *c_start(struct seq_file *m, loff_t *pos)167{168return *pos < nr_cpu_ids ? (void *)(int)(*pos + 1) : NULL;169}170171static void *c_next(struct seq_file *m, void *v, loff_t *pos)172{173++*pos;174return c_start(m, pos);175}176177static void c_stop(struct seq_file *m, void *v)178{179}180181extern int show_cpuinfo(struct seq_file *m, void *v);182183const struct seq_operations cpuinfo_op = {184.start = c_start,185.next = c_next,186.stop = c_stop,187.show = show_cpuinfo,188};189190static int __init topology_init(void)191{192int i;193194for_each_possible_cpu(i) {195return register_cpu(&cpu_devices[i], i);196}197198return 0;199}200201subsys_initcall(topology_init);202203204205