Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 1 | /* |
| 2 | * arch/score/kernel/setup.c |
| 3 | * |
| 4 | * Score Processor version. |
| 5 | * |
| 6 | * Copyright (C) 2009 Sunplus Core Technology Co., Ltd. |
| 7 | * Chen Liqin <liqin.chen@sunplusct.com> |
| 8 | * Lennox Wu <lennox.wu@sunplusct.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, see the file COPYING, or write |
| 22 | * to the Free Software Foundation, Inc., |
| 23 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 24 | */ |
| 25 | |
| 26 | #include <linux/bootmem.h> |
| 27 | #include <linux/initrd.h> |
| 28 | #include <linux/ioport.h> |
Tejun Heo | a2bf79e | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 29 | #include <linux/memblock.h> |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 30 | #include <linux/mm.h> |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 31 | #include <linux/seq_file.h> |
| 32 | #include <linux/screen_info.h> |
| 33 | |
| 34 | #include <asm-generic/sections.h> |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 35 | #include <asm/setup.h> |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 36 | |
| 37 | struct screen_info screen_info; |
| 38 | unsigned long kernelsp; |
| 39 | |
| 40 | static char command_line[COMMAND_LINE_SIZE]; |
| 41 | static struct resource code_resource = { .name = "Kernel code",}; |
| 42 | static struct resource data_resource = { .name = "Kernel data",}; |
| 43 | |
| 44 | static void __init bootmem_init(void) |
| 45 | { |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 46 | unsigned long start_pfn, bootmap_size; |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 47 | unsigned long size = initrd_end - initrd_start; |
| 48 | |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 49 | start_pfn = PFN_UP(__pa(&_end)); |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 50 | |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 51 | min_low_pfn = PFN_UP(MEMORY_START); |
| 52 | max_low_pfn = PFN_UP(MEMORY_START + MEMORY_SIZE); |
Chen Liqin | 202b864 | 2009-11-18 13:28:13 +0800 | [diff] [blame] | 53 | max_mapnr = max_low_pfn - min_low_pfn; |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 54 | |
| 55 | /* Initialize the boot-time allocator with low memory only. */ |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 56 | bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 57 | min_low_pfn, max_low_pfn); |
Tejun Heo | a2bf79e | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 58 | memblock_add_node(PFN_PHYS(min_low_pfn), |
| 59 | PFN_PHYS(max_low_pfn - min_low_pfn), 0); |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 60 | |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 61 | free_bootmem(PFN_PHYS(start_pfn), |
| 62 | (max_low_pfn - start_pfn) << PAGE_SHIFT); |
| 63 | memory_present(0, start_pfn, max_low_pfn); |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 64 | |
| 65 | /* Reserve space for the bootmem bitmap. */ |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 66 | reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT); |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 67 | |
| 68 | if (size == 0) { |
| 69 | printk(KERN_INFO "Initrd not found or empty"); |
| 70 | goto disable; |
| 71 | } |
| 72 | |
| 73 | if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) { |
| 74 | printk(KERN_ERR "Initrd extends beyond end of memory"); |
| 75 | goto disable; |
| 76 | } |
| 77 | |
| 78 | /* Reserve space for the initrd bitmap. */ |
| 79 | reserve_bootmem(__pa(initrd_start), size, BOOTMEM_DEFAULT); |
| 80 | initrd_below_start_ok = 1; |
| 81 | |
| 82 | pr_info("Initial ramdisk at: 0x%lx (%lu bytes)\n", |
| 83 | initrd_start, size); |
| 84 | return; |
| 85 | disable: |
| 86 | printk(KERN_CONT " - disabling initrd\n"); |
| 87 | initrd_start = 0; |
| 88 | initrd_end = 0; |
| 89 | } |
| 90 | |
| 91 | static void __init resource_init(void) |
| 92 | { |
| 93 | struct resource *res; |
| 94 | |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 95 | code_resource.start = __pa(&_text); |
| 96 | code_resource.end = __pa(&_etext) - 1; |
| 97 | data_resource.start = __pa(&_etext); |
| 98 | data_resource.end = __pa(&_edata) - 1; |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 99 | |
| 100 | res = alloc_bootmem(sizeof(struct resource)); |
| 101 | res->name = "System RAM"; |
Chen Liqin | 324f40f | 2009-08-30 12:31:58 +0800 | [diff] [blame] | 102 | res->start = MEMORY_START; |
| 103 | res->end = MEMORY_START + MEMORY_SIZE - 1; |
Chen Liqin | 6bc9a39 | 2009-06-12 22:01:00 +0800 | [diff] [blame] | 104 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; |
| 105 | request_resource(&iomem_resource, res); |
| 106 | |
| 107 | request_resource(res, &code_resource); |
| 108 | request_resource(res, &data_resource); |
| 109 | } |
| 110 | |
| 111 | void __init setup_arch(char **cmdline_p) |
| 112 | { |
| 113 | randomize_va_space = 0; |
| 114 | *cmdline_p = command_line; |
| 115 | |
| 116 | cpu_cache_init(); |
| 117 | tlb_init(); |
| 118 | bootmem_init(); |
| 119 | paging_init(); |
| 120 | resource_init(); |
| 121 | } |
| 122 | |
| 123 | static int show_cpuinfo(struct seq_file *m, void *v) |
| 124 | { |
| 125 | unsigned long n = (unsigned long) v - 1; |
| 126 | |
| 127 | seq_printf(m, "processor\t\t: %ld\n", n); |
| 128 | seq_printf(m, "\n"); |
| 129 | |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | static void *c_start(struct seq_file *m, loff_t *pos) |
| 134 | { |
| 135 | unsigned long i = *pos; |
| 136 | |
| 137 | return i < 1 ? (void *) (i + 1) : NULL; |
| 138 | } |
| 139 | |
| 140 | static void *c_next(struct seq_file *m, void *v, loff_t *pos) |
| 141 | { |
| 142 | ++*pos; |
| 143 | return c_start(m, pos); |
| 144 | } |
| 145 | |
| 146 | static void c_stop(struct seq_file *m, void *v) |
| 147 | { |
| 148 | } |
| 149 | |
| 150 | const struct seq_operations cpuinfo_op = { |
| 151 | .start = c_start, |
| 152 | .next = c_next, |
| 153 | .stop = c_stop, |
| 154 | .show = show_cpuinfo, |
| 155 | }; |
| 156 | |
| 157 | static int __init topology_init(void) |
| 158 | { |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | subsys_initcall(topology_init); |