rtuTemperatureHumidityDataOperation.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * linux/arch/arm/mm/init.c
  3. *
  4. * Copyright (C) 1995-2005 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/errno.h>
  12. #include <linux/swap.h>
  13. #include <linux/init.h>
  14. #include <linux/bootmem.h>
  15. #include <linux/mman.h>
  16. #include <linux/export.h>
  17. #include <linux/nodemask.h>
  18. #include <linux/initrd.h>
  19. #include <linux/of_fdt.h>
  20. #include <linux/highmem.h>
  21. #include <linux/gfp.h>
  22. #include <linux/memblock.h>
  23. #include <linux/dma-contiguous.h>
  24. #include <linux/sizes.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/memblock.h>
  27. #include <asm/prom.h>
  28. #include <asm/sections.h>
  29. #include <asm/setup.h>
  30. #include <asm/tlb.h>
  31. #include <asm/fixmap.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include "mm.h"
  35. static unsigned long phys_initrd_start __initdata = 0;
  36. static unsigned long phys_initrd_size __initdata = 0;
  37. static int __init early_initrd(char *p)
  38. {
  39. unsigned long start, size;
  40. char *endp;
  41. start = memparse(p, &endp);
  42. if (*endp == ',') {
  43. size = memparse(endp + 1, NULL);
  44. phys_initrd_start = start;
  45. phys_initrd_size = size;
  46. }
  47. return 0;
  48. }
  49. early_param("initrd", early_initrd);
  50. static int __init parse_tag_initrd(const struct tag *tag)
  51. {
  52. printk(KERN_WARNING "ATAG_INITRD is deprecated; "
  53. "please update your bootloader.\n");
  54. phys_initrd_start = __virt_to_phys(tag->u.initrd.start);
  55. phys_initrd_size = tag->u.initrd.size;
  56. return 0;
  57. }
  58. __tagtable(ATAG_INITRD, parse_tag_initrd);
  59. static int __init parse_tag_initrd2(const struct tag *tag)
  60. {
  61. phys_initrd_start = tag->u.initrd.start;
  62. phys_initrd_size = tag->u.initrd.size;
  63. return 0;
  64. }
  65. __tagtable(ATAG_INITRD2, parse_tag_initrd2);
  66. #ifdef CONFIG_OF_FLATTREE
  67. void __init early_init_dt_setup_initrd_arch(unsigned long start, unsigned long end)
  68. {
  69. phys_initrd_start = start;
  70. phys_initrd_size = end - start;
  71. }
  72. #endif /* CONFIG_OF_FLATTREE */
  73. /*
  74. * This keeps memory configuration data used by a couple memory
  75. * initialization functions, as well as show_mem() for the skipping
  76. * of holes in the memory map. It is populated by arm_add_memory().
  77. */
  78. struct meminfo meminfo;
  79. void show_mem(unsigned int filter)
  80. {
  81. int free = 0, total = 0, reserved = 0;
  82. int shared = 0, cached = 0, slab = 0, i;
  83. struct meminfo * mi = &meminfo;
  84. printk("Mem-info:\n");
  85. show_free_areas(filter);
  86. for_each_bank (i, mi) {
  87. struct membank *bank = &mi->bank[i];
  88. unsigned int pfn1, pfn2;
  89. struct page *page, *end;
  90. pfn1 = bank_pfn_start(bank);
  91. pfn2 = bank_pfn_end(bank);
  92. page = pfn_to_page(pfn1);
  93. end = pfn_to_page(pfn2 - 1) + 1;
  94. do {
  95. total++;
  96. if (PageReserved(page))
  97. reserved++;
  98. else if (PageSwapCache(page))
  99. cached++;
  100. else if (PageSlab(page))
  101. slab++;
  102. else if (!page_count(page))
  103. free++;
  104. else
  105. shared += page_count(page) - 1;
  106. page++;
  107. } while (page < end);
  108. }
  109. printk("%d pages of RAM\n", total);
  110. printk("%d free pages\n", free);
  111. printk("%d reserved pages\n", reserved);
  112. printk("%d slab pages\n", slab);
  113. printk("%d pages shared\n", shared);
  114. printk("%d pages swap cached\n", cached);
  115. }
  116. static void __init find_limits(unsigned long *min, unsigned long *max_low,
  117. unsigned long *max_high)
  118. {
  119. struct meminfo *mi = &meminfo;
  120. int i;
  121. /* This assumes the meminfo array is properly sorted */
  122. *min = bank_pfn_start(&mi->bank[0]);
  123. for_each_bank (i, mi)
  124. if (mi->bank[i].highmem)
  125. break;
  126. *max_low = bank_pfn_end(&mi->bank[i - 1]);
  127. *max_high = bank_pfn_end(&mi->bank[mi->nr_banks - 1]);
  128. }
  129. static void __init arm_bootmem_init(unsigned long start_pfn,
  130. unsigned long end_pfn)
  131. {
  132. struct memblock_region *reg;
  133. unsigned int boot_pages;
  134. phys_addr_t bitmap;
  135. pg_data_t *pgdat;
  136. /*
  137. * Allocate the bootmem bitmap page. This must be in a region
  138. * of memory which has already been mapped.
  139. */
  140. boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
  141. bitmap = memblock_alloc_base(boot_pages << PAGE_SHIFT, L1_CACHE_BYTES,
  142. __pfn_to_phys(end_pfn));
  143. /*
  144. * Initialise the bootmem allocator, handing the
  145. * memory banks over to bootmem.
  146. */
  147. node_set_online(0);
  148. pgdat = NODE_DATA(0);
  149. init_bootmem_node(pgdat, __phys_to_pfn(bitmap), start_pfn, end_pfn);
  150. /* Free the lowmem regions from memblock into bootmem. */
  151. for_each_memblock(memory, reg) {
  152. unsigned long start = memblock_region_memory_base_pfn(reg);
  153. unsigned long end = memblock_region_memory_end_pfn(reg);
  154. if (end >= end_pfn)
  155. end = end_pfn;
  156. if (start >= end)
  157. break;
  158. free_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT);