setup.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. #include <linux/bootmem.h>
  26. #include <linux/initrd.h>
  27. #include <linux/ioport.h>
  28. #include <linux/memblock.h>
  29. #include <linux/mm.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/screen_info.h>
  32. #include <asm-generic/sections.h>
  33. #include <asm/setup.h>
  34. struct screen_info screen_info;
  35. unsigned long kernelsp;
  36. static char command_line[COMMAND_LINE_SIZE];
  37. static struct resource code_resource = { .name = "Kernel code",};
  38. static struct resource data_resource = { .name = "Kernel data",};
  39. static void __init bootmem_init(void)
  40. {
  41. unsigned long start_pfn, bootmap_size;
  42. unsigned long size = initrd_end - initrd_start;
  43. start_pfn = PFN_UP(__pa(&_end));
  44. min_low_pfn = PFN_UP(MEMORY_START);
  45. max_low_pfn = PFN_UP(MEMORY_START + MEMORY_SIZE);
  46. max_mapnr = max_low_pfn - min_low_pfn;
  47. /* Initialize the boot-time allocator with low memory only. */
  48. bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
  49. min_low_pfn, max_low_pfn);
  50. memblock_add_node(PFN_PHYS(min_low_pfn),
  51. PFN_PHYS(max_low_pfn - min_low_pfn), 0);
  52. free_bootmem(PFN_PHYS(start_pfn),
  53. (max_low_pfn - start_pfn) << PAGE_SHIFT);
  54. memory_present(0, start_pfn, max_low_pfn);
  55. /* Reserve space for the bootmem bitmap. */
  56. reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);
  57. if (size == 0) {
  58. printk(KERN_INFO "Initrd not found or empty");
  59. goto disable;
  60. }
  61. if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
  62. printk(KERN_ERR "Initrd extends beyond end of memory");
  63. goto disable;
  64. }
  65. /* Reserve space for the initrd bitmap. */
  66. reserve_bootmem(__pa(initrd_start), size, BOOTMEM_DEFAULT);
  67. initrd_below_start_ok = 1;
  68. pr_info("Initial ramdisk at: 0x%lx (%lu bytes)\n",
  69. initrd_start, size);
  70. return;
  71. disable:
  72. printk(KERN_CONT " - disabling initrd\n");
  73. initrd_start = 0;
  74. initrd_end = 0;
  75. }
  76. static void __init resource_init(void)
  77. {
  78. struct resource *res;
  79. code_resource.start = __pa(&_text);
  80. code_resource.end = __pa(&_etext) - 1;
  81. data_resource.start = __pa(&_etext);
  82. data_resource.end = __pa(&_edata) - 1;
  83. res = alloc_bootmem(sizeof(struct resource));
  84. res->name = "System RAM";
  85. res->start = MEMORY_START;
  86. res->end = MEMORY_START + MEMORY_SIZE - 1;
  87. res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
  88. request_resource(&iomem_resource, res);
  89. request_resource(res, &code_resource);
  90. request_resource(res, &data_resource);
  91. }
  92. void __init setup_arch(char **cmdline_p)
  93. {
  94. randomize_va_space = 0;
  95. *cmdline_p = command_line;
  96. cpu_cache_init();
  97. tlb_init();
  98. bootmem_init();
  99. paging_init();
  100. resource_init();
  101. }
  102. static int show_cpuinfo(struct seq_file *m, void *v)
  103. {
  104. unsigned long n = (unsigned long) v - 1;
  105. seq_printf(m, "processor\t\t: %ld\n", n);
  106. seq_printf(m, "\n");
  107. return 0;
  108. }
  109. static void *c_start(struct seq_file *m, loff_t *pos)
  110. {
  111. unsigned long i = *pos;
  112. return i < 1 ? (void *) (i + 1) : NULL;
  113. }
  114. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  115. {
  116. ++*pos;
  117. return c_start(m, pos);
  118. }
  119. static void c_stop(struct seq_file *m, void *v)
  120. {
  121. }
  122. const struct seq_operations cpuinfo_op = {
  123. .start = c_start,
  124. .next = c_next,
  125. .stop = c_stop,
  126. .show = show_cpuinfo,
  127. };
  128. static int __init topology_init(void)
  129. {
  130. return 0;
  131. }
  132. subsys_initcall(topology_init);