/arch/ppc/mm/init.c

https://bitbucket.org/evzijst/gittest · C · 667 lines · 460 code · 87 blank · 120 comment · 87 complexity · 6613a9b8db558b61620963b3ceb2030c MD5 · raw file

  1. /*
  2. * PowerPC version
  3. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  4. *
  5. * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
  6. * and Cort Dougan (PReP) (cort@cs.nmt.edu)
  7. * Copyright (C) 1996 Paul Mackerras
  8. * Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
  9. * PPC44x/36-bit changes by Matt Porter (mporter@mvista.com)
  10. *
  11. * Derived from "arch/i386/mm/init.c"
  12. * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version
  17. * 2 of the License, or (at your option) any later version.
  18. *
  19. */
  20. #include <linux/config.h>
  21. #include <linux/module.h>
  22. #include <linux/sched.h>
  23. #include <linux/kernel.h>
  24. #include <linux/errno.h>
  25. #include <linux/string.h>
  26. #include <linux/types.h>
  27. #include <linux/mm.h>
  28. #include <linux/stddef.h>
  29. #include <linux/init.h>
  30. #include <linux/bootmem.h>
  31. #include <linux/highmem.h>
  32. #include <linux/initrd.h>
  33. #include <linux/pagemap.h>
  34. #include <asm/pgalloc.h>
  35. #include <asm/prom.h>
  36. #include <asm/io.h>
  37. #include <asm/mmu_context.h>
  38. #include <asm/pgtable.h>
  39. #include <asm/mmu.h>
  40. #include <asm/smp.h>
  41. #include <asm/machdep.h>
  42. #include <asm/btext.h>
  43. #include <asm/tlb.h>
  44. #include <asm/bootinfo.h>
  45. #include "mem_pieces.h"
  46. #include "mmu_decl.h"
  47. #if defined(CONFIG_KERNEL_START_BOOL) || defined(CONFIG_LOWMEM_SIZE_BOOL)
  48. /* The ammount of lowmem must be within 0xF0000000 - KERNELBASE. */
  49. #if (CONFIG_LOWMEM_SIZE > (0xF0000000 - KERNELBASE))
  50. #error "You must adjust CONFIG_LOWMEM_SIZE or CONFIG_START_KERNEL"
  51. #endif
  52. #endif
  53. #define MAX_LOW_MEM CONFIG_LOWMEM_SIZE
  54. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  55. unsigned long total_memory;
  56. unsigned long total_lowmem;
  57. unsigned long ppc_memstart;
  58. unsigned long ppc_memoffset = PAGE_OFFSET;
  59. int mem_init_done;
  60. int init_bootmem_done;
  61. int boot_mapsize;
  62. #ifdef CONFIG_PPC_PMAC
  63. unsigned long agp_special_page;
  64. #endif
  65. extern char _end[];
  66. extern char etext[], _stext[];
  67. extern char __init_begin, __init_end;
  68. extern char __prep_begin, __prep_end;
  69. extern char __chrp_begin, __chrp_end;
  70. extern char __pmac_begin, __pmac_end;
  71. extern char __openfirmware_begin, __openfirmware_end;
  72. #ifdef CONFIG_HIGHMEM
  73. pte_t *kmap_pte;
  74. pgprot_t kmap_prot;
  75. EXPORT_SYMBOL(kmap_prot);
  76. EXPORT_SYMBOL(kmap_pte);
  77. #endif
  78. void MMU_init(void);
  79. void set_phys_avail(unsigned long total_ram);
  80. /* XXX should be in current.h -- paulus */
  81. extern struct task_struct *current_set[NR_CPUS];
  82. char *klimit = _end;
  83. struct mem_pieces phys_avail;
  84. extern char *sysmap;
  85. extern unsigned long sysmap_size;
  86. /*
  87. * this tells the system to map all of ram with the segregs
  88. * (i.e. page tables) instead of the bats.
  89. * -- Cort
  90. */
  91. int __map_without_bats;
  92. int __map_without_ltlbs;
  93. /* max amount of RAM to use */
  94. unsigned long __max_memory;
  95. /* max amount of low RAM to map in */
  96. unsigned long __max_low_memory = MAX_LOW_MEM;
  97. void show_mem(void)
  98. {
  99. int i,free = 0,total = 0,reserved = 0;
  100. int shared = 0, cached = 0;
  101. int highmem = 0;
  102. printk("Mem-info:\n");
  103. show_free_areas();
  104. printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
  105. i = max_mapnr;
  106. while (i-- > 0) {
  107. total++;
  108. if (PageHighMem(mem_map+i))
  109. highmem++;
  110. if (PageReserved(mem_map+i))
  111. reserved++;
  112. else if (PageSwapCache(mem_map+i))
  113. cached++;
  114. else if (!page_count(mem_map+i))
  115. free++;
  116. else
  117. shared += page_count(mem_map+i) - 1;
  118. }
  119. printk("%d pages of RAM\n",total);
  120. printk("%d pages of HIGHMEM\n", highmem);
  121. printk("%d free pages\n",free);
  122. printk("%d reserved pages\n",reserved);
  123. printk("%d pages shared\n",shared);
  124. printk("%d pages swap cached\n",cached);
  125. }
  126. /* Free up now-unused memory */
  127. static void free_sec(unsigned long start, unsigned long end, const char *name)
  128. {
  129. unsigned long cnt = 0;
  130. while (start < end) {
  131. ClearPageReserved(virt_to_page(start));
  132. set_page_count(virt_to_page(start), 1);
  133. free_page(start);
  134. cnt++;
  135. start += PAGE_SIZE;
  136. }
  137. if (cnt) {
  138. printk(" %ldk %s", cnt << (PAGE_SHIFT - 10), name);
  139. totalram_pages += cnt;
  140. }
  141. }
  142. void free_initmem(void)
  143. {
  144. #define FREESEC(TYPE) \
  145. free_sec((unsigned long)(&__ ## TYPE ## _begin), \
  146. (unsigned long)(&__ ## TYPE ## _end), \
  147. #TYPE);
  148. printk ("Freeing unused kernel memory:");
  149. FREESEC(init);
  150. if (_machine != _MACH_Pmac)
  151. FREESEC(pmac);
  152. if (_machine != _MACH_chrp)
  153. FREESEC(chrp);
  154. if (_machine != _MACH_prep)
  155. FREESEC(prep);
  156. if (!have_of)
  157. FREESEC(openfirmware);
  158. printk("\n");
  159. #undef FREESEC
  160. }
  161. #ifdef CONFIG_BLK_DEV_INITRD
  162. void free_initrd_mem(unsigned long start, unsigned long end)
  163. {
  164. printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
  165. for (; start < end; start += PAGE_SIZE) {
  166. ClearPageReserved(virt_to_page(start));
  167. set_page_count(virt_to_page(start), 1);
  168. free_page(start);
  169. totalram_pages++;
  170. }
  171. }
  172. #endif
  173. /*
  174. * Check for command-line options that affect what MMU_init will do.
  175. */
  176. void MMU_setup(void)
  177. {
  178. /* Check for nobats option (used in mapin_ram). */
  179. if (strstr(cmd_line, "nobats")) {
  180. __map_without_bats = 1;
  181. }
  182. if (strstr(cmd_line, "noltlbs")) {
  183. __map_without_ltlbs = 1;
  184. }
  185. /* Look for mem= option on command line */
  186. if (strstr(cmd_line, "mem=")) {
  187. char *p, *q;
  188. unsigned long maxmem = 0;
  189. for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
  190. q = p + 4;
  191. if (p > cmd_line && p[-1] != ' ')
  192. continue;
  193. maxmem = simple_strtoul(q, &q, 0);
  194. if (*q == 'k' || *q == 'K') {
  195. maxmem <<= 10;
  196. ++q;
  197. } else if (*q == 'm' || *q == 'M') {
  198. maxmem <<= 20;
  199. ++q;
  200. }
  201. }
  202. __max_memory = maxmem;
  203. }
  204. }
  205. /*
  206. * MMU_init sets up the basic memory mappings for the kernel,
  207. * including both RAM and possibly some I/O regions,
  208. * and sets up the page tables and the MMU hardware ready to go.
  209. */
  210. void __init MMU_init(void)
  211. {
  212. if (ppc_md.progress)
  213. ppc_md.progress("MMU:enter", 0x111);
  214. /* parse args from command line */
  215. MMU_setup();
  216. /*
  217. * Figure out how much memory we have, how much
  218. * is lowmem, and how much is highmem. If we were
  219. * passed the total memory size from the bootloader,
  220. * just use it.
  221. */
  222. if (boot_mem_size)
  223. total_memory = boot_mem_size;
  224. else
  225. total_memory = ppc_md.find_end_of_memory();
  226. if (__max_memory && total_memory > __max_memory)
  227. total_memory = __max_memory;
  228. total_lowmem = total_memory;
  229. #ifdef CONFIG_FSL_BOOKE
  230. /* Freescale Book-E parts expect lowmem to be mapped by fixed TLB
  231. * entries, so we need to adjust lowmem to match the amount we can map
  232. * in the fixed entries */
  233. adjust_total_lowmem();
  234. #endif /* CONFIG_FSL_BOOKE */
  235. if (total_lowmem > __max_low_memory) {
  236. total_lowmem = __max_low_memory;
  237. #ifndef CONFIG_HIGHMEM
  238. total_memory = total_lowmem;
  239. #endif /* CONFIG_HIGHMEM */
  240. }
  241. set_phys_avail(total_lowmem);
  242. /* Initialize the MMU hardware */
  243. if (ppc_md.progress)
  244. ppc_md.progress("MMU:hw init", 0x300);
  245. MMU_init_hw();
  246. /* Map in all of RAM starting at KERNELBASE */
  247. if (ppc_md.progress)
  248. ppc_md.progress("MMU:mapin", 0x301);
  249. mapin_ram();
  250. #ifdef CONFIG_HIGHMEM
  251. ioremap_base = PKMAP_BASE;
  252. #else
  253. ioremap_base = 0xfe000000UL; /* for now, could be 0xfffff000 */
  254. #endif /* CONFIG_HIGHMEM */
  255. ioremap_bot = ioremap_base;
  256. /* Map in I/O resources */
  257. if (ppc_md.progress)
  258. ppc_md.progress("MMU:setio", 0x302);
  259. if (ppc_md.setup_io_mappings)
  260. ppc_md.setup_io_mappings();
  261. /* Initialize the context management stuff */
  262. mmu_context_init();
  263. if (ppc_md.progress)
  264. ppc_md.progress("MMU:exit", 0x211);
  265. #ifdef CONFIG_BOOTX_TEXT
  266. /* By default, we are no longer mapped */
  267. boot_text_mapped = 0;
  268. /* Must be done last, or ppc_md.progress will die. */
  269. map_boot_text();
  270. #endif
  271. }
  272. /* This is only called until mem_init is done. */
  273. void __init *early_get_page(void)
  274. {
  275. void *p;
  276. if (init_bootmem_done) {
  277. p = alloc_bootmem_pages(PAGE_SIZE);
  278. } else {
  279. p = mem_pieces_find(PAGE_SIZE, PAGE_SIZE);
  280. }
  281. return p;
  282. }
  283. /*
  284. * Initialize the bootmem system and give it all the memory we
  285. * have available.
  286. */
  287. void __init do_init_bootmem(void)
  288. {
  289. unsigned long start, size;
  290. int i;
  291. /*
  292. * Find an area to use for the bootmem bitmap.
  293. * We look for the first area which is at least
  294. * 128kB in length (128kB is enough for a bitmap
  295. * for 4GB of memory, using 4kB pages), plus 1 page
  296. * (in case the address isn't page-aligned).
  297. */
  298. start = 0;
  299. size = 0;
  300. for (i = 0; i < phys_avail.n_regions; ++i) {
  301. unsigned long a = phys_avail.regions[i].address;
  302. unsigned long s = phys_avail.regions[i].size;
  303. if (s <= size)
  304. continue;
  305. start = a;
  306. size = s;
  307. if (s >= 33 * PAGE_SIZE)
  308. break;
  309. }
  310. start = PAGE_ALIGN(start);
  311. min_low_pfn = start >> PAGE_SHIFT;
  312. max_low_pfn = (PPC_MEMSTART + total_lowmem) >> PAGE_SHIFT;
  313. max_pfn = (PPC_MEMSTART + total_memory) >> PAGE_SHIFT;
  314. boot_mapsize = init_bootmem_node(&contig_page_data, min_low_pfn,
  315. PPC_MEMSTART >> PAGE_SHIFT,
  316. max_low_pfn);
  317. /* remove the bootmem bitmap from the available memory */
  318. mem_pieces_remove(&phys_avail, start, boot_mapsize, 1);
  319. /* add everything in phys_avail into the bootmem map */
  320. for (i = 0; i < phys_avail.n_regions; ++i)
  321. free_bootmem(phys_avail.regions[i].address,
  322. phys_avail.regions[i].size);
  323. init_bootmem_done = 1;
  324. }
  325. /*
  326. * paging_init() sets up the page tables - in fact we've already done this.
  327. */
  328. void __init paging_init(void)
  329. {
  330. unsigned long zones_size[MAX_NR_ZONES], i;
  331. #ifdef CONFIG_HIGHMEM
  332. map_page(PKMAP_BASE, 0, 0); /* XXX gross */
  333. pkmap_page_table = pte_offset_kernel(pmd_offset(pgd_offset_k
  334. (PKMAP_BASE), PKMAP_BASE), PKMAP_BASE);
  335. map_page(KMAP_FIX_BEGIN, 0, 0); /* XXX gross */
  336. kmap_pte = pte_offset_kernel(pmd_offset(pgd_offset_k
  337. (KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN);
  338. kmap_prot = PAGE_KERNEL;
  339. #endif /* CONFIG_HIGHMEM */
  340. /*
  341. * All pages are DMA-able so we put them all in the DMA zone.
  342. */
  343. zones_size[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
  344. for (i = 1; i < MAX_NR_ZONES; i++)
  345. zones_size[i] = 0;
  346. #ifdef CONFIG_HIGHMEM
  347. zones_size[ZONE_HIGHMEM] = (total_memory - total_lowmem) >> PAGE_SHIFT;
  348. #endif /* CONFIG_HIGHMEM */
  349. free_area_init(zones_size);
  350. }
  351. void __init mem_init(void)
  352. {
  353. unsigned long addr;
  354. int codepages = 0;
  355. int datapages = 0;
  356. int initpages = 0;
  357. #ifdef CONFIG_HIGHMEM
  358. unsigned long highmem_mapnr;
  359. highmem_mapnr = total_lowmem >> PAGE_SHIFT;
  360. #endif /* CONFIG_HIGHMEM */
  361. max_mapnr = total_memory >> PAGE_SHIFT;
  362. high_memory = (void *) __va(PPC_MEMSTART + total_lowmem);
  363. num_physpages = max_mapnr; /* RAM is assumed contiguous */
  364. totalram_pages += free_all_bootmem();
  365. #ifdef CONFIG_BLK_DEV_INITRD
  366. /* if we are booted from BootX with an initial ramdisk,
  367. make sure the ramdisk pages aren't reserved. */
  368. if (initrd_start) {
  369. for (addr = initrd_start; addr < initrd_end; addr += PAGE_SIZE)
  370. ClearPageReserved(virt_to_page(addr));
  371. }
  372. #endif /* CONFIG_BLK_DEV_INITRD */
  373. #ifdef CONFIG_PPC_OF
  374. /* mark the RTAS pages as reserved */
  375. if ( rtas_data )
  376. for (addr = (ulong)__va(rtas_data);
  377. addr < PAGE_ALIGN((ulong)__va(rtas_data)+rtas_size) ;
  378. addr += PAGE_SIZE)
  379. SetPageReserved(virt_to_page(addr));
  380. #endif
  381. #ifdef CONFIG_PPC_PMAC
  382. if (agp_special_page)
  383. SetPageReserved(virt_to_page(agp_special_page));
  384. #endif
  385. if ( sysmap )
  386. for (addr = (unsigned long)sysmap;
  387. addr < PAGE_ALIGN((unsigned long)sysmap+sysmap_size) ;
  388. addr += PAGE_SIZE)
  389. SetPageReserved(virt_to_page(addr));
  390. for (addr = PAGE_OFFSET; addr < (unsigned long)high_memory;
  391. addr += PAGE_SIZE) {
  392. if (!PageReserved(virt_to_page(addr)))
  393. continue;
  394. if (addr < (ulong) etext)
  395. codepages++;
  396. else if (addr >= (unsigned long)&__init_begin
  397. && addr < (unsigned long)&__init_end)
  398. initpages++;
  399. else if (addr < (ulong) klimit)
  400. datapages++;
  401. }
  402. #ifdef CONFIG_HIGHMEM
  403. {
  404. unsigned long pfn;
  405. for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
  406. struct page *page = mem_map + pfn;
  407. ClearPageReserved(page);
  408. set_bit(PG_highmem, &page->flags);
  409. set_page_count(page, 1);
  410. __free_page(page);
  411. totalhigh_pages++;
  412. }
  413. totalram_pages += totalhigh_pages;
  414. }
  415. #endif /* CONFIG_HIGHMEM */
  416. printk("Memory: %luk available (%dk kernel code, %dk data, %dk init, %ldk highmem)\n",
  417. (unsigned long)nr_free_pages()<< (PAGE_SHIFT-10),
  418. codepages<< (PAGE_SHIFT-10), datapages<< (PAGE_SHIFT-10),
  419. initpages<< (PAGE_SHIFT-10),
  420. (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
  421. if (sysmap)
  422. printk("System.map loaded at 0x%08x for debugger, size: %ld bytes\n",
  423. (unsigned int)sysmap, sysmap_size);
  424. #ifdef CONFIG_PPC_PMAC
  425. if (agp_special_page)
  426. printk(KERN_INFO "AGP special page: 0x%08lx\n", agp_special_page);
  427. #endif
  428. mem_init_done = 1;
  429. }
  430. /*
  431. * Set phys_avail to the amount of physical memory,
  432. * less the kernel text/data/bss.
  433. */
  434. void __init
  435. set_phys_avail(unsigned long total_memory)
  436. {
  437. unsigned long kstart, ksize;
  438. /*
  439. * Initially, available physical memory is equivalent to all
  440. * physical memory.
  441. */
  442. phys_avail.regions[0].address = PPC_MEMSTART;
  443. phys_avail.regions[0].size = total_memory;
  444. phys_avail.n_regions = 1;
  445. /*
  446. * Map out the kernel text/data/bss from the available physical
  447. * memory.
  448. */
  449. kstart = __pa(_stext); /* should be 0 */
  450. ksize = PAGE_ALIGN(klimit - _stext);
  451. mem_pieces_remove(&phys_avail, kstart, ksize, 0);
  452. mem_pieces_remove(&phys_avail, 0, 0x4000, 0);
  453. #if defined(CONFIG_BLK_DEV_INITRD)
  454. /* Remove the init RAM disk from the available memory. */
  455. if (initrd_start) {
  456. mem_pieces_remove(&phys_avail, __pa(initrd_start),
  457. initrd_end - initrd_start, 1);
  458. }
  459. #endif /* CONFIG_BLK_DEV_INITRD */
  460. #ifdef CONFIG_PPC_OF
  461. /* remove the RTAS pages from the available memory */
  462. if (rtas_data)
  463. mem_pieces_remove(&phys_avail, rtas_data, rtas_size, 1);
  464. #endif
  465. /* remove the sysmap pages from the available memory */
  466. if (sysmap)
  467. mem_pieces_remove(&phys_avail, __pa(sysmap), sysmap_size, 1);
  468. #ifdef CONFIG_PPC_PMAC
  469. /* Because of some uninorth weirdness, we need a page of
  470. * memory as high as possible (it must be outside of the
  471. * bus address seen as the AGP aperture). It will be used
  472. * by the r128 DRM driver
  473. *
  474. * FIXME: We need to make sure that page doesn't overlap any of the\
  475. * above. This could be done by improving mem_pieces_find to be able
  476. * to do a backward search from the end of the list.
  477. */
  478. if (_machine == _MACH_Pmac && find_devices("uni-north-agp")) {
  479. agp_special_page = (total_memory - PAGE_SIZE);
  480. mem_pieces_remove(&phys_avail, agp_special_page, PAGE_SIZE, 0);
  481. agp_special_page = (unsigned long)__va(agp_special_page);
  482. }
  483. #endif /* CONFIG_PPC_PMAC */
  484. }
  485. /* Mark some memory as reserved by removing it from phys_avail. */
  486. void __init reserve_phys_mem(unsigned long start, unsigned long size)
  487. {
  488. mem_pieces_remove(&phys_avail, start, size, 1);
  489. }
  490. /*
  491. * This is called when a page has been modified by the kernel.
  492. * It just marks the page as not i-cache clean. We do the i-cache
  493. * flush later when the page is given to a user process, if necessary.
  494. */
  495. void flush_dcache_page(struct page *page)
  496. {
  497. clear_bit(PG_arch_1, &page->flags);
  498. }
  499. void flush_dcache_icache_page(struct page *page)
  500. {
  501. #ifdef CONFIG_BOOKE
  502. __flush_dcache_icache(kmap(page));
  503. kunmap(page);
  504. #else
  505. __flush_dcache_icache_phys(page_to_pfn(page) << PAGE_SHIFT);
  506. #endif
  507. }
  508. void clear_user_page(void *page, unsigned long vaddr, struct page *pg)
  509. {
  510. clear_page(page);
  511. clear_bit(PG_arch_1, &pg->flags);
  512. }
  513. void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
  514. struct page *pg)
  515. {
  516. copy_page(vto, vfrom);
  517. clear_bit(PG_arch_1, &pg->flags);
  518. }
  519. void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
  520. unsigned long addr, int len)
  521. {
  522. unsigned long maddr;
  523. maddr = (unsigned long) kmap(page) + (addr & ~PAGE_MASK);
  524. flush_icache_range(maddr, maddr + len);
  525. kunmap(page);
  526. }
  527. /*
  528. * This is called at the end of handling a user page fault, when the
  529. * fault has been handled by updating a PTE in the linux page tables.
  530. * We use it to preload an HPTE into the hash table corresponding to
  531. * the updated linux PTE.
  532. */
  533. void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
  534. pte_t pte)
  535. {
  536. /* handle i-cache coherency */
  537. unsigned long pfn = pte_pfn(pte);
  538. if (pfn_valid(pfn)) {
  539. struct page *page = pfn_to_page(pfn);
  540. if (!PageReserved(page)
  541. && !test_bit(PG_arch_1, &page->flags)) {
  542. if (vma->vm_mm == current->active_mm)
  543. __flush_dcache_icache((void *) address);
  544. else
  545. flush_dcache_icache_page(page);
  546. set_bit(PG_arch_1, &page->flags);
  547. }
  548. }
  549. #ifdef CONFIG_PPC_STD_MMU
  550. /* We only want HPTEs for linux PTEs that have _PAGE_ACCESSED set */
  551. if (Hash != 0 && pte_young(pte)) {
  552. struct mm_struct *mm;
  553. pmd_t *pmd;
  554. mm = (address < TASK_SIZE)? vma->vm_mm: &init_mm;
  555. pmd = pmd_offset(pgd_offset(mm, address), address);
  556. if (!pmd_none(*pmd))
  557. add_hash_page(mm->context, address, pmd_val(*pmd));
  558. }
  559. #endif
  560. }
  561. /*
  562. * This is called by /dev/mem to know if a given address has to
  563. * be mapped non-cacheable or not
  564. */
  565. int page_is_ram(unsigned long pfn)
  566. {
  567. unsigned long paddr = (pfn << PAGE_SHIFT);
  568. return paddr < __pa(high_memory);
  569. }
  570. pgprot_t phys_mem_access_prot(struct file *file, unsigned long addr,
  571. unsigned long size, pgprot_t vma_prot)
  572. {
  573. if (ppc_md.phys_mem_access_prot)
  574. return ppc_md.phys_mem_access_prot(file, addr, size, vma_prot);
  575. if (!page_is_ram(addr >> PAGE_SHIFT))
  576. vma_prot = __pgprot(pgprot_val(vma_prot)
  577. | _PAGE_GUARDED | _PAGE_NO_CACHE);
  578. return vma_prot;
  579. }
  580. EXPORT_SYMBOL(phys_mem_access_prot);