Subversion Repositories HelenOS-historic

Rev

Rev 958 | Rev 1769 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 958 Rev 1702
1
/*
1
/*
2
 * Copyright (C) 2003-2004 Jakub Jermar
2
 * Copyright (C) 2003-2004 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
-
 
29
 /** @addtogroup mips32mm  
-
 
30
 * @{
-
 
31
 */
-
 
32
/** @file
-
 
33
 */
-
 
34
 
29
#ifndef __mips32_TLB_H__
35
#ifndef __mips32_TLB_H__
30
#define __mips32_TLB_H__
36
#define __mips32_TLB_H__
31
 
37
 
32
#include <arch/exception.h>
38
#include <arch/exception.h>
33
#include <typedefs.h>
39
#include <typedefs.h>
34
 
40
 
35
#ifdef TLBCNT
41
#ifdef TLBCNT
36
#   define TLB_ENTRY_COUNT      TLBCNT
42
#   define TLB_ENTRY_COUNT      TLBCNT
37
#else
43
#else
38
#   define TLB_ENTRY_COUNT      48
44
#   define TLB_ENTRY_COUNT      48
39
#endif
45
#endif
40
 
46
 
41
#define TLB_WIRED       1
47
#define TLB_WIRED       1
42
#define TLB_KSTACK_WIRED_INDEX  0
48
#define TLB_KSTACK_WIRED_INDEX  0
43
 
49
 
44
#define TLB_PAGE_MASK_16K   (0x3<<13)
50
#define TLB_PAGE_MASK_16K   (0x3<<13)
45
 
51
 
46
#define PAGE_UNCACHED           2
52
#define PAGE_UNCACHED           2
47
#define PAGE_CACHEABLE_EXC_WRITE    5
53
#define PAGE_CACHEABLE_EXC_WRITE    5
48
 
54
 
49
typedef union entry_lo entry_lo_t;
55
typedef union entry_lo entry_lo_t;
50
typedef union entry_hi entry_hi_t;
56
typedef union entry_hi entry_hi_t;
51
typedef union page_mask page_mask_t;
57
typedef union page_mask page_mask_t;
52
typedef union index tlb_index_t;
58
typedef union index tlb_index_t;
53
 
59
 
54
union entry_lo {
60
union entry_lo {
55
    struct {
61
    struct {
56
#ifdef BIG_ENDIAN
62
#ifdef BIG_ENDIAN
57
        unsigned : 2;       /* zero */
63
        unsigned : 2;       /* zero */
58
        unsigned pfn : 24;  /* frame number */
64
        unsigned pfn : 24;  /* frame number */
59
        unsigned c : 3;     /* cache coherency attribute */
65
        unsigned c : 3;     /* cache coherency attribute */
60
        unsigned d : 1;     /* dirty/write-protect bit */
66
        unsigned d : 1;     /* dirty/write-protect bit */
61
        unsigned v : 1;     /* valid bit */
67
        unsigned v : 1;     /* valid bit */
62
        unsigned g : 1;     /* global bit */
68
        unsigned g : 1;     /* global bit */
63
#else
69
#else
64
        unsigned g : 1;     /* global bit */
70
        unsigned g : 1;     /* global bit */
65
        unsigned v : 1;     /* valid bit */
71
        unsigned v : 1;     /* valid bit */
66
        unsigned d : 1;     /* dirty/write-protect bit */
72
        unsigned d : 1;     /* dirty/write-protect bit */
67
        unsigned c : 3;     /* cache coherency attribute */
73
        unsigned c : 3;     /* cache coherency attribute */
68
        unsigned pfn : 24;  /* frame number */
74
        unsigned pfn : 24;  /* frame number */
69
        unsigned : 2;       /* zero */
75
        unsigned : 2;       /* zero */
70
#endif
76
#endif
71
    } __attribute__ ((packed));
77
    } __attribute__ ((packed));
72
    __u32 value;
78
    __u32 value;
73
};
79
};
74
 
80
 
75
/** Page Table Entry. */
81
/** Page Table Entry. */
76
struct pte {
82
struct pte {
77
    unsigned g : 1;         /**< Global bit. */
83
    unsigned g : 1;         /**< Global bit. */
78
    unsigned p : 1;         /**< Present bit. */
84
    unsigned p : 1;         /**< Present bit. */
79
    unsigned d : 1;         /**< Dirty bit. */
85
    unsigned d : 1;         /**< Dirty bit. */
80
    unsigned cacheable : 1;     /**< Cacheable bit. */
86
    unsigned cacheable : 1;     /**< Cacheable bit. */
81
    unsigned : 1;           /**< Unused. */
87
    unsigned : 1;           /**< Unused. */
82
    unsigned soft_valid : 1;    /**< Valid content even if not present. */
88
    unsigned soft_valid : 1;    /**< Valid content even if not present. */
83
    unsigned pfn : 24;      /**< Physical frame number. */
89
    unsigned pfn : 24;      /**< Physical frame number. */
84
    unsigned w : 1;         /**< Page writable bit. */
90
    unsigned w : 1;         /**< Page writable bit. */
85
    unsigned a : 1;         /**< Accessed bit. */
91
    unsigned a : 1;         /**< Accessed bit. */
86
};
92
};
87
 
93
 
88
union entry_hi {
94
union entry_hi {
89
    struct {
95
    struct {
90
#ifdef BIG_ENDIAN
96
#ifdef BIG_ENDIAN
91
        unsigned vpn2 : 19;
97
        unsigned vpn2 : 19;
92
        unsigned : 5;
98
        unsigned : 5;
93
        unsigned asid : 8;
99
        unsigned asid : 8;
94
#else
100
#else
95
        unsigned asid : 8;
101
        unsigned asid : 8;
96
        unsigned : 5;
102
        unsigned : 5;
97
        unsigned vpn2 : 19;
103
        unsigned vpn2 : 19;
98
#endif
104
#endif
99
    } __attribute__ ((packed));
105
    } __attribute__ ((packed));
100
    __u32 value;
106
    __u32 value;
101
};
107
};
102
 
108
 
103
union page_mask {
109
union page_mask {
104
    struct {
110
    struct {
105
#ifdef BIG_ENDIAN
111
#ifdef BIG_ENDIAN
106
        unsigned : 7;
112
        unsigned : 7;
107
        unsigned mask : 12;
113
        unsigned mask : 12;
108
        unsigned : 13;
114
        unsigned : 13;
109
#else
115
#else
110
        unsigned : 13;
116
        unsigned : 13;
111
        unsigned mask : 12;
117
        unsigned mask : 12;
112
        unsigned : 7;
118
        unsigned : 7;
113
#endif
119
#endif
114
    } __attribute__ ((packed));
120
    } __attribute__ ((packed));
115
    __u32 value;
121
    __u32 value;
116
};
122
};
117
 
123
 
118
union index {
124
union index {
119
    struct {
125
    struct {
120
#ifdef BIG_ENDIAN
126
#ifdef BIG_ENDIAN
121
        unsigned p : 1;
127
        unsigned p : 1;
122
        unsigned : 27;
128
        unsigned : 27;
123
        unsigned index : 4;
129
        unsigned index : 4;
124
#else
130
#else
125
        unsigned index : 4;
131
        unsigned index : 4;
126
        unsigned : 27;
132
        unsigned : 27;
127
        unsigned p : 1;
133
        unsigned p : 1;
128
#endif
134
#endif
129
    } __attribute__ ((packed));
135
    } __attribute__ ((packed));
130
    __u32 value;
136
    __u32 value;
131
};
137
};
132
 
138
 
133
/** Probe TLB for Matching Entry
139
/** Probe TLB for Matching Entry
134
 *
140
 *
135
 * Probe TLB for Matching Entry.
141
 * Probe TLB for Matching Entry.
136
 */
142
 */
137
static inline void tlbp(void)
143
static inline void tlbp(void)
138
{
144
{
139
    __asm__ volatile ("tlbp\n\t");
145
    __asm__ volatile ("tlbp\n\t");
140
}
146
}
141
 
147
 
142
 
148
 
143
/** Read Indexed TLB Entry
149
/** Read Indexed TLB Entry
144
 *
150
 *
145
 * Read Indexed TLB Entry.
151
 * Read Indexed TLB Entry.
146
 */
152
 */
147
static inline void tlbr(void)
153
static inline void tlbr(void)
148
{
154
{
149
    __asm__ volatile ("tlbr\n\t");
155
    __asm__ volatile ("tlbr\n\t");
150
}
156
}
151
 
157
 
152
/** Write Indexed TLB Entry
158
/** Write Indexed TLB Entry
153
 *
159
 *
154
 * Write Indexed TLB Entry.
160
 * Write Indexed TLB Entry.
155
 */
161
 */
156
static inline void tlbwi(void)
162
static inline void tlbwi(void)
157
{
163
{
158
    __asm__ volatile ("tlbwi\n\t");
164
    __asm__ volatile ("tlbwi\n\t");
159
}
165
}
160
 
166
 
161
/** Write Random TLB Entry
167
/** Write Random TLB Entry
162
 *
168
 *
163
 * Write Random TLB Entry.
169
 * Write Random TLB Entry.
164
 */
170
 */
165
static inline void tlbwr(void)
171
static inline void tlbwr(void)
166
{
172
{
167
    __asm__ volatile ("tlbwr\n\t");
173
    __asm__ volatile ("tlbwr\n\t");
168
}
174
}
169
 
175
 
170
#define tlb_invalidate(asid)    tlb_invalidate_asid(asid)
176
#define tlb_invalidate(asid)    tlb_invalidate_asid(asid)
171
 
177
 
172
extern void tlb_invalid(istate_t *istate);
178
extern void tlb_invalid(istate_t *istate);
173
extern void tlb_refill(istate_t *istate);
179
extern void tlb_refill(istate_t *istate);
174
extern void tlb_modified(istate_t *istate);
180
extern void tlb_modified(istate_t *istate);
175
 
181
 
176
#endif
182
#endif
-
 
183
 
-
 
184
 /** @}
-
 
185
 */
-
 
186
 
177
 
187