Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.29 153 lines 4.0 kB view raw
1/* 2 * highmem.h: virtual kernel memory mappings for high memory 3 * 4 * PowerPC version, stolen from the i386 version. 5 * 6 * Used in CONFIG_HIGHMEM systems for memory pages which 7 * are not addressable by direct kernel virtual addresses. 8 * 9 * Copyright (C) 1999 Gerhard Wichert, Siemens AG 10 * Gerhard.Wichert@pdb.siemens.de 11 * 12 * 13 * Redesigned the x86 32-bit VM architecture to deal with 14 * up to 16 Terrabyte physical memory. With current x86 CPUs 15 * we now support up to 64 Gigabytes physical RAM. 16 * 17 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com> 18 */ 19 20#ifndef _ASM_HIGHMEM_H 21#define _ASM_HIGHMEM_H 22 23#ifdef __KERNEL__ 24 25#include <linux/init.h> 26#include <linux/interrupt.h> 27#include <asm/kmap_types.h> 28#include <asm/tlbflush.h> 29#include <asm/page.h> 30#include <asm/fixmap.h> 31 32extern pte_t *kmap_pte; 33extern pgprot_t kmap_prot; 34extern pte_t *pkmap_page_table; 35 36/* 37 * Right now we initialize only a single pte table. It can be extended 38 * easily, subsequent pte tables have to be allocated in one physical 39 * chunk of RAM. 40 */ 41/* 42 * We use one full pte table with 4K pages. And with 16K/64K pages pte 43 * table covers enough memory (32MB and 512MB resp.) that both FIXMAP 44 * and PKMAP can be placed in single pte table. We use 1024 pages for 45 * PKMAP in case of 16K/64K pages. 46 */ 47#ifdef CONFIG_PPC_4K_PAGES 48#define PKMAP_ORDER PTE_SHIFT 49#else 50#define PKMAP_ORDER 10 51#endif 52#define LAST_PKMAP (1 << PKMAP_ORDER) 53#ifndef CONFIG_PPC_4K_PAGES 54#define PKMAP_BASE (FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1)) 55#else 56#define PKMAP_BASE ((FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK) 57#endif 58#define LAST_PKMAP_MASK (LAST_PKMAP-1) 59#define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) 60#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 61 62extern void *kmap_high(struct page *page); 63extern void kunmap_high(struct page *page); 64 65static inline void *kmap(struct page *page) 66{ 67 might_sleep(); 68 if (!PageHighMem(page)) 69 return page_address(page); 70 return kmap_high(page); 71} 72 73static inline void kunmap(struct page *page) 74{ 75 BUG_ON(in_interrupt()); 76 if (!PageHighMem(page)) 77 return; 78 kunmap_high(page); 79} 80 81/* 82 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap 83 * gives a more generic (and caching) interface. But kmap_atomic can 84 * be used in IRQ contexts, so in some (very limited) cases we need 85 * it. 86 */ 87static inline void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot) 88{ 89 unsigned int idx; 90 unsigned long vaddr; 91 92 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 93 pagefault_disable(); 94 if (!PageHighMem(page)) 95 return page_address(page); 96 97 idx = type + KM_TYPE_NR*smp_processor_id(); 98 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 99#ifdef CONFIG_DEBUG_HIGHMEM 100 BUG_ON(!pte_none(*(kmap_pte-idx))); 101#endif 102 __set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot)); 103 local_flush_tlb_page(NULL, vaddr); 104 105 return (void*) vaddr; 106} 107 108static inline void *kmap_atomic(struct page *page, enum km_type type) 109{ 110 return kmap_atomic_prot(page, type, kmap_prot); 111} 112 113static inline void kunmap_atomic(void *kvaddr, enum km_type type) 114{ 115#ifdef CONFIG_DEBUG_HIGHMEM 116 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 117 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 118 119 if (vaddr < __fix_to_virt(FIX_KMAP_END)) { 120 pagefault_enable(); 121 return; 122 } 123 124 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); 125 126 /* 127 * force other mappings to Oops if they'll try to access 128 * this pte without first remap it 129 */ 130 pte_clear(&init_mm, vaddr, kmap_pte-idx); 131 local_flush_tlb_page(NULL, vaddr); 132#endif 133 pagefault_enable(); 134} 135 136static inline struct page *kmap_atomic_to_page(void *ptr) 137{ 138 unsigned long idx, vaddr = (unsigned long) ptr; 139 pte_t *pte; 140 141 if (vaddr < FIXADDR_START) 142 return virt_to_page(ptr); 143 144 idx = virt_to_fix(vaddr); 145 pte = kmap_pte - (idx - FIX_KMAP_BEGIN); 146 return pte_page(*pte); 147} 148 149#define flush_cache_kmaps() flush_cache_all() 150 151#endif /* __KERNEL__ */ 152 153#endif /* _ASM_HIGHMEM_H */