xref: /openbmc/linux/arch/sparc/include/asm/highmem.h (revision a439fe51a1f8eb087c22dd24d69cebae4a3addac)
1*a439fe51SSam Ravnborg /*
2*a439fe51SSam Ravnborg  * highmem.h: virtual kernel memory mappings for high memory
3*a439fe51SSam Ravnborg  *
4*a439fe51SSam Ravnborg  * Used in CONFIG_HIGHMEM systems for memory pages which
5*a439fe51SSam Ravnborg  * are not addressable by direct kernel virtual addresses.
6*a439fe51SSam Ravnborg  *
7*a439fe51SSam Ravnborg  * Copyright (C) 1999 Gerhard Wichert, Siemens AG
8*a439fe51SSam Ravnborg  *		      Gerhard.Wichert@pdb.siemens.de
9*a439fe51SSam Ravnborg  *
10*a439fe51SSam Ravnborg  *
11*a439fe51SSam Ravnborg  * Redesigned the x86 32-bit VM architecture to deal with
12*a439fe51SSam Ravnborg  * up to 16 Terrabyte physical memory. With current x86 CPUs
13*a439fe51SSam Ravnborg  * we now support up to 64 Gigabytes physical RAM.
14*a439fe51SSam Ravnborg  *
15*a439fe51SSam Ravnborg  * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
16*a439fe51SSam Ravnborg  */
17*a439fe51SSam Ravnborg 
18*a439fe51SSam Ravnborg #ifndef _ASM_HIGHMEM_H
19*a439fe51SSam Ravnborg #define _ASM_HIGHMEM_H
20*a439fe51SSam Ravnborg 
21*a439fe51SSam Ravnborg #ifdef __KERNEL__
22*a439fe51SSam Ravnborg 
23*a439fe51SSam Ravnborg #include <linux/interrupt.h>
24*a439fe51SSam Ravnborg #include <asm/fixmap.h>
25*a439fe51SSam Ravnborg #include <asm/vaddrs.h>
26*a439fe51SSam Ravnborg #include <asm/kmap_types.h>
27*a439fe51SSam Ravnborg #include <asm/pgtable.h>
28*a439fe51SSam Ravnborg 
29*a439fe51SSam Ravnborg /* declarations for highmem.c */
30*a439fe51SSam Ravnborg extern unsigned long highstart_pfn, highend_pfn;
31*a439fe51SSam Ravnborg 
32*a439fe51SSam Ravnborg extern pte_t *kmap_pte;
33*a439fe51SSam Ravnborg extern pgprot_t kmap_prot;
34*a439fe51SSam Ravnborg extern pte_t *pkmap_page_table;
35*a439fe51SSam Ravnborg 
36*a439fe51SSam Ravnborg extern void kmap_init(void) __init;
37*a439fe51SSam Ravnborg 
38*a439fe51SSam Ravnborg /*
39*a439fe51SSam Ravnborg  * Right now we initialize only a single pte table. It can be extended
40*a439fe51SSam Ravnborg  * easily, subsequent pte tables have to be allocated in one physical
41*a439fe51SSam Ravnborg  * chunk of RAM.  Currently the simplest way to do this is to align the
42*a439fe51SSam Ravnborg  * pkmap region on a pagetable boundary (4MB).
43*a439fe51SSam Ravnborg  */
44*a439fe51SSam Ravnborg #define LAST_PKMAP 1024
45*a439fe51SSam Ravnborg #define PKMAP_SIZE (LAST_PKMAP << PAGE_SHIFT)
46*a439fe51SSam Ravnborg #define PKMAP_BASE PMD_ALIGN(SRMMU_NOCACHE_VADDR + (SRMMU_MAX_NOCACHE_PAGES << PAGE_SHIFT))
47*a439fe51SSam Ravnborg 
48*a439fe51SSam Ravnborg #define LAST_PKMAP_MASK (LAST_PKMAP - 1)
49*a439fe51SSam Ravnborg #define PKMAP_NR(virt)  ((virt - PKMAP_BASE) >> PAGE_SHIFT)
50*a439fe51SSam Ravnborg #define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))
51*a439fe51SSam Ravnborg 
52*a439fe51SSam Ravnborg #define PKMAP_END (PKMAP_ADDR(LAST_PKMAP))
53*a439fe51SSam Ravnborg 
54*a439fe51SSam Ravnborg extern void *kmap_high(struct page *page);
55*a439fe51SSam Ravnborg extern void kunmap_high(struct page *page);
56*a439fe51SSam Ravnborg 
57*a439fe51SSam Ravnborg static inline void *kmap(struct page *page)
58*a439fe51SSam Ravnborg {
59*a439fe51SSam Ravnborg 	BUG_ON(in_interrupt());
60*a439fe51SSam Ravnborg 	if (!PageHighMem(page))
61*a439fe51SSam Ravnborg 		return page_address(page);
62*a439fe51SSam Ravnborg 	return kmap_high(page);
63*a439fe51SSam Ravnborg }
64*a439fe51SSam Ravnborg 
65*a439fe51SSam Ravnborg static inline void kunmap(struct page *page)
66*a439fe51SSam Ravnborg {
67*a439fe51SSam Ravnborg 	BUG_ON(in_interrupt());
68*a439fe51SSam Ravnborg 	if (!PageHighMem(page))
69*a439fe51SSam Ravnborg 		return;
70*a439fe51SSam Ravnborg 	kunmap_high(page);
71*a439fe51SSam Ravnborg }
72*a439fe51SSam Ravnborg 
73*a439fe51SSam Ravnborg extern void *kmap_atomic(struct page *page, enum km_type type);
74*a439fe51SSam Ravnborg extern void kunmap_atomic(void *kvaddr, enum km_type type);
75*a439fe51SSam Ravnborg extern struct page *kmap_atomic_to_page(void *vaddr);
76*a439fe51SSam Ravnborg 
77*a439fe51SSam Ravnborg #define flush_cache_kmaps()	flush_cache_all()
78*a439fe51SSam Ravnborg 
79*a439fe51SSam Ravnborg #endif /* __KERNEL__ */
80*a439fe51SSam Ravnborg 
81*a439fe51SSam Ravnborg #endif /* _ASM_HIGHMEM_H */
82