setup.c 5.5 KB

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