init.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #include <linux/gfp.h>
  7. #include <linux/swap.h>
  8. #include <linux/bootmem.h>
  9. #include <linux/uaccess.h>
  10. #include <linux/export.h>
  11. #include <asm/bfin-global.h>
  12. #include <asm/pda.h>
  13. #include <asm/cplbinit.h>
  14. #include <asm/early_printk.h>
  15. #include "blackfin_sram.h"
  16. /*
  17. * ZERO_PAGE is a special page that is used for zero-initialized data and COW.
  18. * Let the bss do its zero-init magic so we don't have to do it ourselves.
  19. */
  20. char empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
  21. EXPORT_SYMBOL(empty_zero_page);
  22. #ifndef CONFIG_EXCEPTION_L1_SCRATCH
  23. #if defined CONFIG_SYSCALL_TAB_L1
  24. __attribute__((l1_data))
  25. #endif
  26. static unsigned long exception_stack[NR_CPUS][1024];
  27. #endif
  28. struct blackfin_pda cpu_pda[NR_CPUS];
  29. EXPORT_SYMBOL(cpu_pda);
  30. /*
  31. * paging_init() continues the virtual memory environment setup which
  32. * was begun by the code in arch/head.S.
  33. * The parameters are pointers to where to stick the starting and ending
  34. * addresses of available kernel virtual memory.
  35. */
  36. void __init paging_init(void)
  37. {
  38. /*
  39. * make sure start_mem is page aligned, otherwise bootmem and
  40. * page_alloc get different views of the world
  41. */
  42. unsigned long end_mem = memory_end & PAGE_MASK;
  43. unsigned long zones_size[MAX_NR_ZONES] = {
  44. [0] = 0,
  45. [ZONE_DMA] = (end_mem - CONFIG_PHY_RAM_BASE_ADDRESS) >> PAGE_SHIFT,
  46. [ZONE_NORMAL] = 0,
  47. #ifdef CONFIG_HIGHMEM
  48. [ZONE_HIGHMEM] = 0,
  49. #endif
  50. };
  51. /* Set up SFC/DFC registers (user data space) */
  52. set_fs(KERNEL_DS);
  53. pr_debug("free_area_init -> start_mem is %#lx virtual_end is %#lx\n",
  54. PAGE_ALIGN(memory_start), end_mem);
  55. free_area_init_node(0, zones_size,
  56. CONFIG_PHY_RAM_BASE_ADDRESS >> PAGE_SHIFT, NULL);
  57. }
  58. asmlinkage void __init init_pda(void)
  59. {
  60. unsigned int cpu = raw_smp_processor_id();
  61. early_shadow_stamp();
  62. /* Initialize the PDA fields holding references to other parts
  63. of the memory. The content of such memory is still
  64. undefined at the time of the call, we are only setting up
  65. valid pointers to it. */
  66. memset(&cpu_pda[cpu], 0, sizeof(cpu_pda[cpu]));
  67. #ifdef CONFIG_EXCEPTION_L1_SCRATCH
  68. cpu_pda[cpu].ex_stack = (unsigned long *)(L1_SCRATCH_START + \
  69. L1_SCRATCH_LENGTH);
  70. #else
  71. cpu_pda[cpu].ex_stack = exception_stack[cpu + 1];
  72. #endif
  73. #ifdef CONFIG_SMP
  74. cpu_pda[cpu].imask = 0x1f;
  75. #endif
  76. }
  77. void __init mem_init(void)
  78. {
  79. char buf[64];
  80. high_memory = (void *)(memory_end & PAGE_MASK);
  81. max_mapnr = MAP_NR(high_memory);
  82. printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", max_mapnr);
  83. /* This will put all low memory onto the freelists. */
  84. free_all_bootmem();
  85. snprintf(buf, sizeof(buf) - 1, "%uK DMA", DMA_UNCACHED_REGION >> 10);
  86. mem_init_print_info(buf);
  87. }
  88. #ifdef CONFIG_BLK_DEV_INITRD
  89. void __init free_initrd_mem(unsigned long start, unsigned long end)
  90. {
  91. #ifndef CONFIG_MPU
  92. free_reserved_area((void *)start, (void *)end, -1, "initrd");
  93. #endif
  94. }
  95. #endif
  96. void __init_refok free_initmem(void)
  97. {
  98. #if defined CONFIG_RAMKERNEL && !defined CONFIG_MPU
  99. free_initmem_default(-1);
  100. if (memory_start == (unsigned long)(&__init_end))
  101. memory_start = (unsigned long)(&__init_begin);
  102. #endif
  103. }