setup.c 5.2 KB

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