setup.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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/config.h>
  12. #include <linux/init.h>
  13. #include <linux/mm.h>
  14. #include <linux/bootmem.h>
  15. #include <asm/pgtable.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/tty.h>
  18. #include <linux/utsname.h>
  19. #include <asm/setup.h>
  20. /*
  21. * Setup options
  22. */
  23. struct drive_info_struct { char dummy[32]; } drive_info;
  24. struct screen_info screen_info;
  25. extern int root_mountflags;
  26. extern char _etext, _edata, _end;
  27. char 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. extern void show_etrax_copyright(void); /* arch-vX/kernel/setup.c */
  32. /* This mainly sets up the memory area, and can be really confusing.
  33. *
  34. * The physical DRAM is virtually mapped into dram_start to dram_end
  35. * (usually c0000000 to c0000000 + DRAM size). The physical address is
  36. * given by the macro __pa().
  37. *
  38. * In this DRAM, the kernel code and data is loaded, in the beginning.
  39. * It really starts at c0004000 to make room for some special pages -
  40. * the start address is text_start. The kernel data ends at _end. After
  41. * this the ROM filesystem is appended (if there is any).
  42. *
  43. * Between this address and dram_end, we have RAM pages usable to the
  44. * boot code and the system.
  45. *
  46. */
  47. void __init
  48. 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. #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
  74. #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
  75. #define PFN_PHYS(x) ((x) << PAGE_SHIFT)
  76. /* min_low_pfn points to the start of DRAM, start_pfn points
  77. * to the first DRAM pages after the kernel, and max_low_pfn
  78. * to the end of DRAM.
  79. */
  80. /*
  81. * partially used pages are not usable - thus
  82. * we are rounding upwards:
  83. */
  84. start_pfn = PFN_UP(memory_start); /* usually c0000000 + kernel + romfs */
  85. max_pfn = PFN_DOWN((unsigned long)high_memory); /* usually c0000000 + dram size */
  86. /*
  87. * Initialize the boot-time allocator (start, end)
  88. *
  89. * We give it access to all our DRAM, but we could as well just have
  90. * given it a small slice. No point in doing that though, unless we
  91. * have non-contiguous memory and want the boot-stuff to be in, say,
  92. * the smallest area.
  93. *
  94. * It will put a bitmap of the allocated pages in the beginning
  95. * of the range we give it, but it won't mark the bitmaps pages
  96. * as reserved. We have to do that ourselves below.
  97. *
  98. * We need to use init_bootmem_node instead of init_bootmem
  99. * because our map starts at a quite high address (min_low_pfn).
  100. */
  101. max_low_pfn = max_pfn;
  102. min_low_pfn = PAGE_OFFSET >> PAGE_SHIFT;
  103. bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
  104. min_low_pfn,
  105. max_low_pfn);
  106. /* And free all memory not belonging to the kernel (addr, size) */
  107. free_bootmem(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn - start_pfn));
  108. /*
  109. * Reserve the bootmem bitmap itself as well. We do this in two
  110. * steps (first step was init_bootmem()) because this catches
  111. * the (very unlikely) case of us accidentally initializing the
  112. * bootmem allocator with an invalid RAM area.
  113. *
  114. * Arguments are start, size
  115. */
  116. reserve_bootmem(PFN_PHYS(start_pfn), bootmap_size);
  117. /* paging_init() sets up the MMU and marks all pages as reserved */
  118. paging_init();
  119. *cmdline_p = cris_command_line;
  120. #ifdef CONFIG_ETRAX_CMDLINE
  121. if (!strcmp(cris_command_line, "")) {
  122. strlcpy(cris_command_line, CONFIG_ETRAX_CMDLINE, COMMAND_LINE_SIZE);
  123. cris_command_line[COMMAND_LINE_SIZE - 1] = '\0';
  124. }
  125. #endif
  126. /* Save command line for future references. */
  127. memcpy(saved_command_line, cris_command_line, COMMAND_LINE_SIZE);
  128. saved_command_line[COMMAND_LINE_SIZE - 1] = '\0';
  129. /* give credit for the CRIS port */
  130. show_etrax_copyright();
  131. /* Setup utsname */
  132. strcpy(system_utsname.machine, cris_machine_name);
  133. }
  134. static void *c_start(struct seq_file *m, loff_t *pos)
  135. {
  136. return *pos < NR_CPUS ? (void *)(int)(*pos + 1): NULL;
  137. }
  138. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  139. {
  140. ++*pos;
  141. return c_start(m, pos);
  142. }
  143. static void c_stop(struct seq_file *m, void *v)
  144. {
  145. }
  146. extern int show_cpuinfo(struct seq_file *m, void *v);
  147. struct seq_operations cpuinfo_op = {
  148. .start = c_start,
  149. .next = c_next,
  150. .stop = c_stop,
  151. .show = show_cpuinfo,
  152. };