• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/arch/tile/include/asm/
1/*
2 * Copyright (C) 1998 Ingo Molnar
3 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 *
5 *   This program is free software; you can redistribute it and/or
6 *   modify it under the terms of the GNU General Public License
7 *   as published by the Free Software Foundation, version 2.
8 *
9 *   This program is distributed in the hope that it will be useful, but
10 *   WITHOUT ANY WARRANTY; without even the implied warranty of
11 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 *   NON INFRINGEMENT.  See the GNU General Public License for
13 *   more details.
14 */
15
16#ifndef _ASM_TILE_FIXMAP_H
17#define _ASM_TILE_FIXMAP_H
18
19#include <asm/page.h>
20
21#ifndef __ASSEMBLY__
22#include <linux/kernel.h>
23#ifdef CONFIG_HIGHMEM
24#include <linux/threads.h>
25#include <asm/kmap_types.h>
26#endif
27
28#define __fix_to_virt(x)	(FIXADDR_TOP - ((x) << PAGE_SHIFT))
29#define __virt_to_fix(x)	((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
30
31/*
32 * Here we define all the compile-time 'special' virtual
33 * addresses. The point is to have a constant address at
34 * compile time, but to set the physical address only
35 * in the boot process. We allocate these special addresses
36 * from the end of supervisor virtual memory backwards.
37 * Also this lets us do fail-safe vmalloc(), we
38 * can guarantee that these special addresses and
39 * vmalloc()-ed addresses never overlap.
40 *
41 * these 'compile-time allocated' memory buffers are
42 * fixed-size 4k pages. (or larger if used with an increment
43 * higher than 1) use fixmap_set(idx,phys) to associate
44 * physical memory with fixmap indices.
45 *
46 * TLB entries of such buffers will not be flushed across
47 * task switches.
48 *
49 * We don't bother with a FIX_HOLE since above the fixmaps
50 * is unmapped memory in any case.
51 */
52enum fixed_addresses {
53#ifdef CONFIG_HIGHMEM
54	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
55	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
56#endif
57	__end_of_permanent_fixed_addresses,
58
59	/*
60	 * Temporary boot-time mappings, used before ioremap() is functional.
61	 * Not currently needed by the Tile architecture.
62	 */
63#define NR_FIX_BTMAPS	0
64#if NR_FIX_BTMAPS
65	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
66	FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
67	__end_of_fixed_addresses
68#else
69	__end_of_fixed_addresses = __end_of_permanent_fixed_addresses
70#endif
71};
72
73extern void __set_fixmap(enum fixed_addresses idx,
74			 unsigned long phys, pgprot_t flags);
75
76#define set_fixmap(idx, phys) \
77		__set_fixmap(idx, phys, PAGE_KERNEL)
78/*
79 * Some hardware wants to get fixmapped without caching.
80 */
81#define set_fixmap_nocache(idx, phys) \
82		__set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
83
84#define clear_fixmap(idx) \
85		__set_fixmap(idx, 0, __pgprot(0))
86
87#define __FIXADDR_SIZE	(__end_of_permanent_fixed_addresses << PAGE_SHIFT)
88#define __FIXADDR_BOOT_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
89#define FIXADDR_START		(FIXADDR_TOP + PAGE_SIZE - __FIXADDR_SIZE)
90#define FIXADDR_BOOT_START	(FIXADDR_TOP + PAGE_SIZE - __FIXADDR_BOOT_SIZE)
91
92extern void __this_fixmap_does_not_exist(void);
93
94/*
95 * 'index to address' translation. If anyone tries to use the idx
96 * directly without tranlation, we catch the bug with a NULL-deference
97 * kernel oops. Illegal ranges of incoming indices are caught too.
98 */
99static __always_inline unsigned long fix_to_virt(const unsigned int idx)
100{
101	/*
102	 * this branch gets completely eliminated after inlining,
103	 * except when someone tries to use fixaddr indices in an
104	 * illegal way. (such as mixing up address types or using
105	 * out-of-range indices).
106	 *
107	 * If it doesn't get removed, the linker will complain
108	 * loudly with a reasonably clear error message..
109	 */
110	if (idx >= __end_of_fixed_addresses)
111		__this_fixmap_does_not_exist();
112
113	return __fix_to_virt(idx);
114}
115
116static inline unsigned long virt_to_fix(const unsigned long vaddr)
117{
118	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
119	return __virt_to_fix(vaddr);
120}
121
122#endif /* !__ASSEMBLY__ */
123
124#endif /* _ASM_TILE_FIXMAP_H */
125