2 * arch/ubicom32/kernel/setup.c
3 * Ubicom32 architecture-dependent parts of system setup.
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>
15 * This file is part of the Ubicom32 Linux Kernel Port.
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.
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.
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/>.
31 * Ubicom32 implementation derived from (with many thanks):
37 #include <linux/kernel.h>
38 #include <linux/sched.h>
39 #include <linux/delay.h>
40 #include <linux/interrupt.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>
50 #include <asm/devtree.h>
51 #include <asm/setup.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>
61 unsigned long memory_start
;
62 EXPORT_SYMBOL(memory_start
);
64 unsigned long memory_end
;
65 EXPORT_SYMBOL(memory_end
);
67 static char __initdata command_line
[COMMAND_LINE_SIZE
];
68 #ifdef CONFIG_CMDLINE_BOOL
69 static char __initdata builtin_cmdline
[COMMAND_LINE_SIZE
] = CONFIG_CMDLINE
;
72 extern int _stext
, _etext
, _sdata
, _edata
, _sbss
, _ebss
, _end
;
76 * Setup the architecture dependent portions of the system.
78 void __init
setup_arch(char **cmdline_p
)
81 unsigned long ram_start
;
87 * Use the link for memory_start from the link and the processor
88 * node for memory_end.
90 memory_start
= PAGE_ALIGN(((unsigned long)&_end
));
91 processor_dram(&ram_start
, &memory_end
);
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;
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.
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.
107 strlcpy(boot_command_line
, (char *)(memory_end
- COMMAND_LINE_SIZE
), COMMAND_LINE_SIZE
);
109 #ifdef CONFIG_CMDLINE_BOOL
110 #ifdef CONFIG_CMDLINE_OVERRIDE
111 strlcpy(boot_command_line
, builtin_cmdline
, COMMAND_LINE_SIZE
);
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
);
122 strlcpy(command_line
, boot_command_line
, COMMAND_LINE_SIZE
);
123 *cmdline_p
= command_line
;
127 printk(KERN_INFO
"%s Processor, Ubicom, Inc. <www.ubicom.com>\n", CPU
);
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
);
140 if (strlen(*cmdline_p
))
141 printk(KERN_DEBUG
"Command line: '%s'\n", *cmdline_p
);
144 #if defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_DUMMY_CONSOLE)
145 conswitchp
= &dummy_con
;
149 * If we have a device tree, see if we have the nodes we need.
156 * From the arm initialization comment:
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.
162 * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
163 * the system, not the maximum PFN.
165 max_pfn
= max_low_pfn
= (memory_end
- PAGE_OFFSET
) >> PAGE_SHIFT
;
168 * Give all the memory to the bootmap allocator, tell it to put the
169 * boot mem_map at the start of memory.
171 bootmap_size
= init_bootmem_node(
173 memory_start
>> PAGE_SHIFT
, /* map goes here */
174 PAGE_OFFSET
>> PAGE_SHIFT
, /* 0 on coldfire */
175 memory_end
>> PAGE_SHIFT
);
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 :-)
180 free_bootmem(memory_start
, memory_end
- memory_start
);
181 reserve_bootmem(memory_start
, bootmap_size
, BOOTMEM_DEFAULT
);
184 * Get kmalloc into gear.
189 * Fix up the thread_info structure, indicate this is a mainline Linux
190 * thread and setup the sw_ksp().
192 sw_ksp
[thread_get_self()] = (unsigned int) current_thread_info();
193 thread_set_mainline(thread_get_self());