init.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Port on Texas Instruments TMS320C6x architecture
  3. *
  4. * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
  5. * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/mm.h>
  12. #include <linux/swap.h>
  13. #include <linux/module.h>
  14. #include <linux/bootmem.h>
  15. #ifdef CONFIG_BLK_DEV_RAM
  16. #include <linux/blkdev.h>
  17. #endif
  18. #include <linux/initrd.h>
  19. #include <asm/sections.h>
  20. #include <asm/uaccess.h>
  21. /*
  22. * ZERO_PAGE is a special page that is used for zero-initialized
  23. * data and COW.
  24. */
  25. unsigned long empty_zero_page;
  26. EXPORT_SYMBOL(empty_zero_page);
  27. /*
  28. * paging_init() continues the virtual memory environment setup which
  29. * was begun by the code in arch/head.S.
  30. * The parameters are pointers to where to stick the starting and ending
  31. * addresses of available kernel virtual memory.
  32. */
  33. void __init paging_init(void)
  34. {
  35. struct pglist_data *pgdat = NODE_DATA(0);
  36. unsigned long zones_size[MAX_NR_ZONES] = {0, };
  37. empty_zero_page = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
  38. memset((void *)empty_zero_page, 0, PAGE_SIZE);
  39. /*
  40. * Set up user data space
  41. */
  42. set_fs(KERNEL_DS);
  43. /*
  44. * Define zones
  45. */
  46. zones_size[ZONE_NORMAL] = (memory_end - PAGE_OFFSET) >> PAGE_SHIFT;
  47. pgdat->node_zones[ZONE_NORMAL].zone_start_pfn =
  48. __pa(PAGE_OFFSET) >> PAGE_SHIFT;
  49. free_area_init(zones_size);
  50. }
  51. void __init mem_init(void)
  52. {
  53. int codek, datak;
  54. unsigned long tmp;
  55. unsigned long len = memory_end - memory_start;
  56. high_memory = (void *)(memory_end & PAGE_MASK);
  57. /* this will put all memory onto the freelists */
  58. free_all_bootmem();
  59. codek = (_etext - _stext) >> 10;
  60. datak = (_end - _sdata) >> 10;
  61. tmp = nr_free_pages() << PAGE_SHIFT;
  62. printk(KERN_INFO "Memory: %luk/%luk RAM (%dk kernel code, %dk data)\n",
  63. tmp >> 10, len >> 10, codek, datak);
  64. }
  65. #ifdef CONFIG_BLK_DEV_INITRD
  66. void __init free_initrd_mem(unsigned long start, unsigned long end)
  67. {
  68. free_reserved_area((void *)start, (void *)end, -1, "initrd");
  69. }
  70. #endif
  71. void __init free_initmem(void)
  72. {
  73. free_initmem_default(-1);
  74. }