setup.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. *
  3. * linux/arch/cris/kernel/setup.c
  4. *
  5. * Copyright (C) 1995 Linus Torvalds
  6. * Copyright (c) 2001 Axis Communications AB
  7. */
  8. /*
  9. * This file handles the architecture-dependent parts of initialization
  10. */
  11. #include <linux/init.h>
  12. #include <linux/mm.h>
  13. #include <linux/bootmem.h>
  14. #include <asm/pgtable.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/screen_info.h>
  17. #include <linux/utsname.h>
  18. #include <linux/pfn.h>
  19. #include <linux/cpu.h>
  20. #include <linux/of.h>
  21. #include <linux/of_fdt.h>
  22. #include <linux/of_platform.h>
  23. #include <asm/setup.h>
  24. #include <arch/system.h>
  25. /*
  26. * Setup options
  27. */
  28. struct screen_info screen_info;
  29. extern int root_mountflags;
  30. extern char _etext, _edata, _end;
  31. char __initdata cris_command_line[COMMAND_LINE_SIZE] = { 0, };
  32. extern const unsigned long text_start, edata; /* set by the linker script */
  33. extern unsigned long dram_start, dram_end;
  34. extern unsigned long romfs_start, romfs_length, romfs_in_flash; /* from head.S */
  35. static struct cpu cpu_devices[NR_CPUS];
  36. extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */
  37. /* This mainly sets up the memory area, and can be really confusing.
  38. *
  39. * The physical DRAM is virtually mapped into dram_start to dram_end
  40. * (usually c0000000 to c0000000 + DRAM size). The physical address is
  41. * given by the macro __pa().
  42. *
  43. * In this DRAM, the kernel code and data is loaded, in the beginning.
  44. * It really starts at c0004000 to make room for some special pages -
  45. * the start address is text_start. The kernel data ends at _end. After
  46. * this the ROM filesystem is appended (if there is any).
  47. *
  48. * Between this address and dram_end, we have RAM pages usable to the
  49. * boot code and the system.
  50. *
  51. */
  52. void __init setup_arch(char **cmdline_p)
  53. {
  54. extern void init_etrax_debug(void);
  55. unsigned long bootmap_size;
  56. unsigned long start_pfn, max_pfn;
  57. unsigned long memory_start;
  58. #ifdef CONFIG_OF
  59. early_init_dt_scan(__dtb_start);
  60. #endif
  61. /* register an initial console printing routine for printk's */
  62. init_etrax_debug();
  63. /* we should really poll for DRAM size! */
  64. high_memory = &dram_end;
  65. if(romfs_in_flash || !romfs_length) {
  66. /* if we have the romfs in flash, or if there is no rom filesystem,
  67. * our free area starts directly after the BSS
  68. */
  69. memory_start = (unsigned long) &_end;
  70. } else {
  71. /* otherwise the free area starts after the ROM filesystem */
  72. printk("ROM fs in RAM, size %lu bytes\n", romfs_length);
  73. memory_start = romfs_start + romfs_length;
  74. }
  75. /* process 1's initial memory region is the kernel code/data */
  76. init_mm.start_code = (unsigned long) &text_start;
  77. init_mm.end_code = (unsigned long) &_etext;
  78. init_mm.end_data = (unsigned long) &_edata;
  79. init_mm.brk = (unsigned long) &_end;
  80. /* min_low_pfn points to the start of DRAM, start_pfn points
  81. * to the first DRAM pages after the kernel, and max_low_pfn
  82. * to the end of DRAM.
  83. */
  84. /*
  85. * partially used pages are not usable - thus
  86. * we are rounding upwards:
  87. */
  88. start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */
  89. max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
  90. /*
  91. * Initialize the boot-time allocator (start, end)
  92. *
  93. * We give it access to all our DRAM, but we could as well just have
  94. * given it a small slice. No point in doing that though, unless we
  95. * have non-contiguous memory and want the boot-stuff to be in, say,
  96. * the smallest area.
  97. *
  98. * It will put a bitmap of the allocated pages in the beginning
  99. * of the range we give it, but it won't mark the bitmaps pages
  100. * as reserved. We have to do that ourselves below.
  101. *
  102. * We need to use init_bootmem_node instead of init_bootmem
  103. * because our map starts at a quite high address (min_low_pfn).
  104. */
  105. max_low_pfn = max_pfn;
  106. min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
  107. bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
  108. min_low_pfn,
  109. max_low_pfn);
  110. /* And free all memory not belonging to the kernel (addr, size) */
  111. free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
  112. /*
  113. * Reserve the bootmem bitmap itself as well. We do this in two
  114. * steps (first step was init_bootmem()) because this catches
  115. * the (very unlikely) case of us accidentally initializing the
  116. * bootmem allocator with an invalid RAM area.
  117. *
  118. * Arguments are start, size
  119. */
  120. reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size, BOOTMEM_DEFAULT);
  121. unflatten_and_copy_device_tree();
  122. /* paging_init() sets up the MMU and marks all pages as reserved */
  123. paging_init();
  124. *cmdline_p = cris_command_line;
  125. #ifdef CONFIG_ETRAX_CMDLINE
  126. if (!strcmp(cris_command_line, "")) {
  127. strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
  128. cris_command_line[COMMAND_LINE_SIZE - 1] = '\0';
  129. }
  130. #endif
  131. /* Save command line for future references. */
  132. memcpy(boot_command_line, cris_command_line, COMMAND_LINE_SIZE);
  133. boot_command_line[COMMAND_LINE_SIZE - 1] = '\0';
  134. /* give credit for the CRIS port */
  135. show_etrax_copyright();
  136. /* Setup utsname */
  137. strcpy(init_utsname()->machine, cris_machine_name);
  138. }
  139. #ifdef CONFIG_PROC_FS
  140. static void *c_start(struct seq_file *m, loff_t *pos)
  141. {
  142. return *pos < nr_cpu_ids ? (void *)(int)(*pos + 1) : NULL;
  143. }
  144. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  145. {
  146. ++*pos;
  147. return c_start(m, pos);
  148. }
  149. static void c_stop(struct seq_file *m, void *v)
  150. {
  151. }
  152. extern int show_cpuinfo(struct seq_file *m, void *v);
  153. const struct seq_operations cpuinfo_op = {
  154. .start = c_start,
  155. .next = c_next,
  156. .stop = c_stop,
  157. .show = show_cpuinfo,
  158. };
  159. #endif /* CONFIG_PROC_FS */
  160. static int __init topology_init(void)
  161. {
  162. int i;
  163. for_each_possible_cpu(i) {
  164. return register_cpu(&cpu_devices[i], i);
  165. }
  166. return 0;
  167. }
  168. subsys_initcall(topology_init);
  169. static int __init cris_of_init(void)
  170. {
  171. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  172. return 0;
  173. }
  174. core_initcall(cris_of_init);