2 * highmem.h: virtual kernel memory mappings for high memory
4 * Used in CONFIG_HIGHMEM systems for memory pages which
5 * are not addressable by direct kernel virtual addresses.
7 * Copyright (C) 1999 Gerhard Wichert, Siemens AG
8 * Gerhard.Wichert@pdb.siemens.de
11 * Redesigned the x86 32-bit VM architecture to deal with
12 * up to 16 Terabyte physical memory. With current x86 CPUs
13 * we now support up to 64 Gigabytes physical RAM.
15 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
18 #ifndef _ASM_HIGHMEM_H
19 #define _ASM_HIGHMEM_H
23 #include <linux/init.h>
24 #include <linux/interrupt.h>
25 #include <asm/kmap_types.h>
26 #include <asm/pgtable.h>
28 /* undef for production */
29 #define HIGHMEM_DEBUG 1
31 /* declarations for highmem.c */
32 extern unsigned long highstart_pfn, highend_pfn;
34 extern pte_t *kmap_pte;
35 extern pgprot_t kmap_prot;
36 extern pte_t *pkmap_page_table;
39 * Right now we initialize only a single pte table. It can be extended
40 * easily, subsequent pte tables have to be allocated in one physical
43 #define PKMAP_BASE (0xfe000000UL)
44 #define LAST_PKMAP 1024
45 #define LAST_PKMAP_MASK (LAST_PKMAP-1)
46 #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
47 #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
49 extern void * kmap_high(struct page *page, int nonblocking);
50 extern void kunmap_high(struct page *page);
52 static inline void *__kmap(struct page *page, int nonblocking)
56 if (page < highmem_start_page)
57 return page_address(page);
58 return kmap_high(page, nonblocking);
61 #define kmap(page) __kmap(page, 0)
62 #define kmap_nonblock(page) __kmap(page, 1)
64 static inline void kunmap(struct page *page)
68 if (page < highmem_start_page)
74 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
75 * gives a more generic (and caching) interface. But kmap_atomic can
76 * be used in IRQ contexts, so in some (very limited) cases we need
79 static inline void *kmap_atomic(struct page *page, enum km_type type)
81 enum fixed_addresses idx;
84 if (page < highmem_start_page)
85 return page_address(page);
87 idx = type + KM_TYPE_NR*smp_processor_id();
88 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
89 set_pte(kmap_pte-idx, mk_pte(page, kmap_prot));
90 local_flush_tlb_one(vaddr);
95 static inline void kunmap_atomic(void *kvaddr, enum km_type type)
99 #endif /* __KERNEL__ */
101 #endif /* _ASM_HIGHMEM_H */