| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* highmem.h: virtual kernel memory mappings for high memory
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * Written by David Howells (dhowells@redhat.com) | 
					
						
							|  |  |  |  * - Derived from include/asm-i386/highmem.h | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-02-03 15:54:28 +02:00
										 |  |  |  * See Documentation/frv/mmu-layout.txt for more information. | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version | 
					
						
							|  |  |  |  * 2 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _ASM_HIGHMEM_H
 | 
					
						
							|  |  |  | #define _ASM_HIGHMEM_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __KERNEL__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							| 
									
										
										
										
											2009-03-31 15:23:25 -07:00
										 |  |  | #include <linux/highmem.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #include <asm/mem-layout.h>
 | 
					
						
							|  |  |  | #include <asm/spr-regs.h>
 | 
					
						
							|  |  |  | #include <asm/mb-regs.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define NR_TLB_LINES		64	/* number of lines in the TLB */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __ASSEMBLY__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							|  |  |  | #include <asm/kmap_types.h>
 | 
					
						
							|  |  |  | #include <asm/pgtable.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef CONFIG_DEBUG_HIGHMEM
 | 
					
						
							|  |  |  | #define HIGHMEM_DEBUG 1
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define HIGHMEM_DEBUG 0
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* declarations for highmem.c */ | 
					
						
							|  |  |  | extern unsigned long highstart_pfn, highend_pfn; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define kmap_prot PAGE_KERNEL
 | 
					
						
							|  |  |  | #define kmap_pte ______kmap_pte_in_TLB
 | 
					
						
							|  |  |  | extern pte_t *pkmap_page_table; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define flush_cache_kmaps()  do { } while (0)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Right now we initialize only a single pte table. It can be extended | 
					
						
							|  |  |  |  * easily, subsequent pte tables have to be allocated in one physical | 
					
						
							|  |  |  |  * chunk of RAM. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define LAST_PKMAP	PTRS_PER_PTE
 | 
					
						
							|  |  |  | #define LAST_PKMAP_MASK	(LAST_PKMAP - 1)
 | 
					
						
							|  |  |  | #define PKMAP_NR(virt)	((virt - PKMAP_BASE) >> PAGE_SHIFT)
 | 
					
						
							|  |  |  | #define PKMAP_ADDR(nr)	(PKMAP_BASE + ((nr) << PAGE_SHIFT))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void *kmap_high(struct page *page); | 
					
						
							|  |  |  | extern void kunmap_high(struct page *page); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void *kmap(struct page *page); | 
					
						
							|  |  |  | extern void kunmap(struct page *page); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern struct page *kmap_atomic_to_page(void *ptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* !__ASSEMBLY__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap | 
					
						
							|  |  |  |  * gives a more generic (and caching) interface. But kmap_atomic can | 
					
						
							|  |  |  |  * be used in IRQ contexts, so in some (very limited) cases we need | 
					
						
							|  |  |  |  * it. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define KMAP_ATOMIC_CACHE_DAMR		8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __ASSEMBLY__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | #define __kmap_atomic_primary(cached, paddr, ampr)						\
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | ({												\ | 
					
						
							|  |  |  | 	unsigned long damlr, dampr;								\ | 
					
						
							|  |  |  | 												\ | 
					
						
							|  |  |  | 	dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V;		\ | 
					
						
							|  |  |  | 												\ | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | 	if (!cached)										\ | 
					
						
							| 
									
										
										
										
											2006-10-16 14:10:49 +01:00
										 |  |  | 		asm volatile("movgs %0,dampr"#ampr :: "r"(dampr) : "memory");			\ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	else											\ | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | 		/* cache flush page attachment point */						\ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 		asm volatile("movgs %0,iampr"#ampr"\n"						\ | 
					
						
							|  |  |  | 			     "movgs %0,dampr"#ampr"\n"						\ | 
					
						
							| 
									
										
										
										
											2006-10-16 14:10:49 +01:00
										 |  |  | 			     :: "r"(dampr) : "memory"						\ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 			     );									\ | 
					
						
							|  |  |  | 												\ | 
					
						
							|  |  |  | 	asm("movsg damlr"#ampr",%0" : "=r"(damlr));						\ | 
					
						
							|  |  |  | 												\ | 
					
						
							|  |  |  | 	/*printk("DAMR"#ampr": PRIM sl=%d L=%08lx P=%08lx\n", type, damlr, dampr);*/		\ | 
					
						
							|  |  |  | 												\ | 
					
						
							|  |  |  | 	(void *) damlr;										\ | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define __kmap_atomic_secondary(slot, paddr)							  \
 | 
					
						
							|  |  |  | ({												  \ | 
					
						
							|  |  |  | 	unsigned long damlr = KMAP_ATOMIC_SECONDARY_FRAME + (slot) * PAGE_SIZE;			  \ | 
					
						
							|  |  |  | 	unsigned long dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \ | 
					
						
							|  |  |  | 												  \ | 
					
						
							|  |  |  | 	asm volatile("movgs %0,tplr \n"								  \ | 
					
						
							|  |  |  | 		     "movgs %1,tppr \n"								  \ | 
					
						
							|  |  |  | 		     "tlbpr %0,gr0,#2,#1"							  \ | 
					
						
							| 
									
										
										
										
											2006-10-16 14:10:49 +01:00
										 |  |  | 		     : : "r"(damlr), "r"(dampr) : "memory");					  \ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 												  \ | 
					
						
							|  |  |  | 	/*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/			  \ | 
					
						
							|  |  |  | 												  \ | 
					
						
							|  |  |  | 	(void *) damlr;										  \ | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | static inline void *kmap_atomic_primary(struct page *page) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	unsigned long paddr; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-06 20:32:20 -08:00
										 |  |  | 	pagefault_disable(); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	paddr = page_to_phys(page); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  |         return __kmap_atomic_primary(1, paddr, 2); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | #define __kunmap_atomic_primary(cached, ampr)				\
 | 
					
						
							| 
									
										
										
										
											2006-10-16 14:10:49 +01:00
										 |  |  | do {									\ | 
					
						
							|  |  |  | 	asm volatile("movgs gr0,dampr"#ampr"\n" ::: "memory");		\ | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | 	if (cached)							\ | 
					
						
							| 
									
										
										
										
											2006-10-16 14:10:49 +01:00
										 |  |  | 		asm volatile("movgs gr0,iampr"#ampr"\n" ::: "memory");	\ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } while(0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-16 14:10:49 +01:00
										 |  |  | #define __kunmap_atomic_secondary(slot, vaddr)				\
 | 
					
						
							|  |  |  | do {									\ | 
					
						
							|  |  |  | 	asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory");	\ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } while(0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  | static inline void kunmap_atomic_primary(void *kvaddr) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-27 13:02:49 +08:00
										 |  |  |         __kunmap_atomic_primary(1, 2); | 
					
						
							| 
									
										
										
										
											2006-12-06 20:32:20 -08:00
										 |  |  | 	pagefault_enable(); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-26 10:53:39 +08:00
										 |  |  | void *kmap_atomic(struct page *page); | 
					
						
							| 
									
										
										
										
											2010-10-26 14:21:51 -07:00
										 |  |  | void __kunmap_atomic(void *kvaddr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif /* !__ASSEMBLY__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* __KERNEL__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* _ASM_HIGHMEM_H */
 |