setup.c 5.5 KB

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