Root/target/linux/ubicom32/files/arch/ubicom32/kernel/setup.c

1/*
2 * arch/ubicom32/kernel/setup.c
3 * Ubicom32 architecture-dependent parts of system setup.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 * Copyright (C) 1999-2007 Greg Ungerer (gerg@snapgear.com)
7 * Copyright (C) 1998,1999 D. Jeff Dionne <jeff@uClinux.org>
8 * Copyleft ()) 2000 James D. Schettine {james@telos-systems.com}
9 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
10 * Copyright (C) 1995 Hamish Macdonald
11 * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
12 * Copyright (C) 2001 Lineo, Inc. <www.lineo.com>
13 * 68VZ328 Fixes/support Evan Stawnyczy <e@lineo.ca>
14 *
15 * This file is part of the Ubicom32 Linux Kernel Port.
16 *
17 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
18 * it and/or modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation, either version 2 of the
20 * License, or (at your option) any later version.
21 *
22 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
23 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
24 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
25 * the GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with the Ubicom32 Linux Kernel Port. If not,
29 * see <http://www.gnu.org/licenses/>.
30 *
31 * Ubicom32 implementation derived from (with many thanks):
32 * arch/m68knommu
33 * arch/blackfin
34 * arch/parisc
35 */
36
37#include <linux/kernel.h>
38#include <linux/sched.h>
39#include <linux/delay.h>
40#include <linux/interrupt.h>
41#include <linux/fb.h>
42#include <linux/module.h>
43#include <linux/console.h>
44#include <linux/errno.h>
45#include <linux/string.h>
46#include <linux/bootmem.h>
47#include <linux/seq_file.h>
48#include <linux/init.h>
49
50#include <asm/devtree.h>
51#include <asm/setup.h>
52#include <asm/irq.h>
53#include <asm/machdep.h>
54#include <asm/pgtable.h>
55#include <asm/pgalloc.h>
56#include <asm/ubicom32-common.h>
57#include <asm/processor.h>
58#include <asm/bootargs.h>
59#include <asm/thread.h>
60
61unsigned long memory_start;
62EXPORT_SYMBOL(memory_start);
63
64unsigned long memory_end;
65EXPORT_SYMBOL(memory_end);
66
67static char __initdata command_line[COMMAND_LINE_SIZE];
68#ifdef CONFIG_CMDLINE_BOOL
69static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
70#endif
71
72extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
73
74/*
75 * setup_arch()
76 * Setup the architecture dependent portions of the system.
77 */
78void __init setup_arch(char **cmdline_p)
79{
80    int bootmap_size;
81    unsigned long ram_start;
82
83    processor_init();
84    bootargs_init();
85
86    /*
87     * Use the link for memory_start from the link and the processor
88     * node for memory_end.
89     */
90    memory_start = PAGE_ALIGN(((unsigned long)&_end));
91    processor_dram(&ram_start, &memory_end);
92
93    init_mm.start_code = (unsigned long) &_stext;
94    init_mm.end_code = (unsigned long) &_etext;
95    init_mm.end_data = (unsigned long) &_edata;
96    init_mm.brk = (unsigned long) 0;
97
98    /*
99     * bootexec copies the original default command line to end of memory.
100     * u-boot can modify it there (i.e. to enable network boot) and the
101     * kernel picks up the modified version.
102     *
103     * mainexec creates a `new default' command_line which is in the
104     * bootargs devnode. It is updated on every firmware update but
105     * not used at the moment.
106     */
107    strlcpy(boot_command_line, (char *)(memory_end - COMMAND_LINE_SIZE), COMMAND_LINE_SIZE);
108
109#ifdef CONFIG_CMDLINE_BOOL
110#ifdef CONFIG_CMDLINE_OVERRIDE
111    strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
112#else
113    if (builtin_cmdline[0]) {
114        /* append boot loader cmdline to builtin */
115        strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
116        strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
117        strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
118    }
119#endif
120#endif
121
122    strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
123    *cmdline_p = command_line;
124
125    parse_early_param();
126
127    printk(KERN_INFO "%s Processor, Ubicom, Inc. <www.ubicom.com>\n", CPU);
128
129#if defined(DEBUG)
130    printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
131        "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
132        (int) &_sdata, (int) &_edata,
133        (int) &_sbss, (int) &_ebss);
134    printk(KERN_DEBUG "MEMORY -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x\n ",
135        (int) &_ebss, (int) memory_start,
136        (int) memory_start, (int) memory_end);
137#endif
138
139#ifdef DEBUG
140    if (strlen(*cmdline_p))
141        printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
142#endif
143
144#if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
145    conswitchp = &dummy_con;
146#endif
147
148    /*
149     * If we have a device tree, see if we have the nodes we need.
150     */
151    if (devtree) {
152        devtree_print();
153    }
154
155    /*
156     * From the arm initialization comment:
157     *
158     * This doesn't seem to be used by the Linux memory manager any
159     * more, but is used by ll_rw_block. If we can get rid of it, we
160     * also get rid of some of the stuff above as well.
161     *
162     * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
163     * the system, not the maximum PFN.
164     */
165    max_pfn = max_low_pfn = (memory_end - PAGE_OFFSET) >> PAGE_SHIFT;
166
167    /*
168     * Give all the memory to the bootmap allocator, tell it to put the
169     * boot mem_map at the start of memory.
170     */
171    bootmap_size = init_bootmem_node(
172            NODE_DATA(0),
173            memory_start >> PAGE_SHIFT, /* map goes here */
174            PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
175            memory_end >> PAGE_SHIFT);
176    /*
177     * Free the usable memory, we have to make sure we do not free
178     * the bootmem bitmap so we then reserve it after freeing it :-)
179     */
180    free_bootmem(memory_start, memory_end - memory_start);
181    reserve_bootmem(memory_start, bootmap_size, BOOTMEM_DEFAULT);
182
183    /*
184     * Get kmalloc into gear.
185     */
186    paging_init();
187
188    /*
189     * Fix up the thread_info structure, indicate this is a mainline Linux
190     * thread and setup the sw_ksp().
191     */
192    sw_ksp[thread_get_self()] = (unsigned int) current_thread_info();
193    thread_set_mainline(thread_get_self());
194}
195

Archive Download this file



interactive