OpenCores
URL https://opencores.org/ocsvn/or1k_soc_on_altera_embedded_dev_kit/or1k_soc_on_altera_embedded_dev_kit/trunk

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [linux-2.6/] [linux-2.6.24/] [include/] [asm-or32/] [fixmap.h] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 xianfeng
/*
2
 * fixmap.h: compile-time virtual memory allocation
3
 *
4
 * This file is subject to the terms and conditions of the GNU General Public
5
 * License.  See the file "COPYING" in the main directory of this archive
6
 * for more details.
7
 *
8
 * Copyright (C) 1998 Ingo Molnar
9
 *
10
 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
11
 */
12
 
13
#ifndef _ASM_FIXMAP_H
14
#define _ASM_FIXMAP_H
15
 
16
 
17
/* used by vmalloc.c, vsyscall.lds.S.
18
 *
19
 * Leave one empty page between vmalloc'ed areas and
20
 * the start of the fixmap.
21
 */
22
#define __FIXADDR_TOP   0xffffe000
23
 
24
#ifndef __ASSEMBLY__
25
#include <linux/kernel.h>
26
#include <asm/page.h>
27
#ifdef CONFIG_HIGHMEM
28
#include <linux/threads.h>
29
#include <asm/kmap_types.h>
30
#endif
31
 
32
/*
33
 * Here we define all the compile-time 'special' virtual
34
 * addresses. The point is to have a constant address at
35
 * compile time, but to set the physical address only
36
 * in the boot process. We allocate these special addresses
37
 * from the end of virtual memory (0xfffff000) backwards.
38
 * Also this lets us do fail-safe vmalloc(), we
39
 * can guarantee that these special addresses and
40
 * vmalloc()-ed addresses never overlap.
41
 *
42
 * these 'compile-time allocated' memory buffers are
43
 * fixed-size 4k pages. (or larger if used with an increment
44
 * highger than 1) use fixmap_set(idx,phys) to associate
45
 * physical memory with fixmap indices.
46
 *
47
 * TLB entries of such buffers will not be flushed across
48
 * task switches.
49
 */
50
enum fixed_addresses {
51
        FIX_HOLE,
52
        FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
53
        FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
54
        __end_of_permanent_fixed_addresses,
55
        /* temporary boot-time mappings, used before ioremap() is functional */
56
#define NR_FIX_BTMAPS   16
57
        FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
58
        FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
59
        FIX_WP_TEST,
60
        __end_of_fixed_addresses
61
};
62
 
63
extern void __set_fixmap (enum fixed_addresses idx,
64
                                        unsigned long phys, pgprot_t flags);
65
 
66
#define set_fixmap(idx, phys) \
67
                __set_fixmap(idx, phys, PAGE_KERNEL)
68
/*
69
 * Some hardware wants to get fixmapped without caching.
70
 */
71
#define set_fixmap_nocache(idx, phys) \
72
                __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
73
 
74
#define clear_fixmap(idx) \
75
                __set_fixmap(idx, 0, __pgprot(0))
76
 
77
#define FIXADDR_TOP     ((unsigned long)__FIXADDR_TOP)
78
 
79
#define __FIXADDR_SIZE  (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
80
#define __FIXADDR_BOOT_SIZE     (__end_of_fixed_addresses << PAGE_SHIFT)
81
#define FIXADDR_START           (FIXADDR_TOP - __FIXADDR_SIZE)
82
#define FIXADDR_BOOT_START      (FIXADDR_TOP - __FIXADDR_BOOT_SIZE)
83
 
84
#define __fix_to_virt(x)        (FIXADDR_TOP - ((x) << PAGE_SHIFT))
85
#define __virt_to_fix(x)        ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
86
 
87
/*
88
 * This is the range that is readable by user mode, and things
89
 * acting like user mode such as get_user_pages.
90
 */
91
#define FIXADDR_USER_START      (__fix_to_virt(FIX_VSYSCALL))
92
#define FIXADDR_USER_END        (FIXADDR_USER_START + PAGE_SIZE)
93
 
94
 
95
/*
96
 * 'index to address' translation. If anyone tries to use the idx
97
 * directly without tranlation, we catch the bug with a NULL-deference
98
 * kernel oops. Illegal ranges of incoming indices are caught too.
99
 */
100
static __always_inline unsigned long fix_to_virt(const unsigned int idx)
101
{
102
        /*
103
         * this branch gets completely eliminated after inlining,
104
         * except when someone tries to use fixaddr indices in an
105
         * illegal way. (such as mixing up address types or using
106
         * out-of-range indices).
107
         *
108
         * If it doesn't get removed, the linker will complain
109
         * loudly with a reasonably clear error message..
110
         */
111
        if (idx >= __end_of_fixed_addresses)
112
                BUG();
113
 
114
        return __fix_to_virt(idx);
115
}
116
 
117
static inline unsigned long virt_to_fix(const unsigned long vaddr)
118
{
119
        BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_BOOT_START);
120
        return __virt_to_fix(vaddr);
121
}
122
 
123
#endif /* !__ASSEMBLY__ */
124
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.