Subversion Repositories HelenOS

Rev

Rev 2089 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2089 Rev 2474
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   
29
/** @addtogroup mips32mm   
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#ifndef KERN_mips32_TLB_H_
35
#ifndef KERN_mips32_TLB_H_
36
#define KERN_mips32_TLB_H_
36
#define KERN_mips32_TLB_H_
37
 
37
 
38
#include <arch/exception.h>
38
#include <arch/exception.h>
39
 
39
 
40
#ifdef TLBCNT
40
#ifdef TLBCNT
41
#   define TLB_ENTRY_COUNT      TLBCNT
41
#   define TLB_ENTRY_COUNT      TLBCNT
42
#else
42
#else
43
#   define TLB_ENTRY_COUNT      48
43
#   define TLB_ENTRY_COUNT      48
44
#endif
44
#endif
45
 
45
 
46
#define TLB_WIRED       1
46
#define TLB_WIRED       1
47
#define TLB_KSTACK_WIRED_INDEX  0
47
#define TLB_KSTACK_WIRED_INDEX  0
48
 
48
 
49
#define TLB_PAGE_MASK_16K   (0x3<<13)
49
#define TLB_PAGE_MASK_16K   (0x3<<13)
50
 
50
 
51
#define PAGE_UNCACHED           2
51
#define PAGE_UNCACHED           2
52
#define PAGE_CACHEABLE_EXC_WRITE    5
52
#define PAGE_CACHEABLE_EXC_WRITE    5
53
 
53
 
54
typedef union {
54
typedef union {
55
    struct {
55
    struct {
56
#ifdef BIG_ENDIAN
56
#ifdef BIG_ENDIAN
57
        unsigned : 2;       /* zero */
57
        unsigned : 2;       /* zero */
58
        unsigned pfn : 24;  /* frame number */
58
        unsigned pfn : 24;  /* frame number */
59
        unsigned c : 3;     /* cache coherency attribute */
59
        unsigned c : 3;     /* cache coherency attribute */
60
        unsigned d : 1;     /* dirty/write-protect bit */
60
        unsigned d : 1;     /* dirty/write-protect bit */
61
        unsigned v : 1;     /* valid bit */
61
        unsigned v : 1;     /* valid bit */
62
        unsigned g : 1;     /* global bit */
62
        unsigned g : 1;     /* global bit */
63
#else
63
#else
64
        unsigned g : 1;     /* global bit */
64
        unsigned g : 1;     /* global bit */
65
        unsigned v : 1;     /* valid bit */
65
        unsigned v : 1;     /* valid bit */
66
        unsigned d : 1;     /* dirty/write-protect bit */
66
        unsigned d : 1;     /* dirty/write-protect bit */
67
        unsigned c : 3;     /* cache coherency attribute */
67
        unsigned c : 3;     /* cache coherency attribute */
68
        unsigned pfn : 24;  /* frame number */
68
        unsigned pfn : 24;  /* frame number */
69
        unsigned : 2;       /* zero */
69
        unsigned : 2;       /* zero */
70
#endif
70
#endif
71
    } __attribute__ ((packed));
71
    } __attribute__ ((packed));
72
    uint32_t value;
72
    uint32_t value;
73
} entry_lo_t;
73
} entry_lo_t;
74
 
74
 
75
typedef union {
75
typedef union {
76
    struct {
76
    struct {
77
#ifdef BIG_ENDIAN
77
#ifdef BIG_ENDIAN
78
        unsigned vpn2 : 19;
78
        unsigned vpn2 : 19;
79
        unsigned : 5;
79
        unsigned : 5;
80
        unsigned asid : 8;
80
        unsigned asid : 8;
81
#else
81
#else
82
        unsigned asid : 8;
82
        unsigned asid : 8;
83
        unsigned : 5;
83
        unsigned : 5;
84
        unsigned vpn2 : 19;
84
        unsigned vpn2 : 19;
85
#endif
85
#endif
86
    } __attribute__ ((packed));
86
    } __attribute__ ((packed));
87
    uint32_t value;
87
    uint32_t value;
88
} entry_hi_t;
88
} entry_hi_t;
89
 
89
 
90
typedef union {
90
typedef union {
91
    struct {
91
    struct {
92
#ifdef BIG_ENDIAN
92
#ifdef BIG_ENDIAN
93
        unsigned : 7;
93
        unsigned : 7;
94
        unsigned mask : 12;
94
        unsigned mask : 12;
95
        unsigned : 13;
95
        unsigned : 13;
96
#else
96
#else
97
        unsigned : 13;
97
        unsigned : 13;
98
        unsigned mask : 12;
98
        unsigned mask : 12;
99
        unsigned : 7;
99
        unsigned : 7;
100
#endif
100
#endif
101
    } __attribute__ ((packed));
101
    } __attribute__ ((packed));
102
    uint32_t value;
102
    uint32_t value;
103
} page_mask_t;
103
} page_mask_t;
104
 
104
 
105
typedef union {
105
typedef union {
106
    struct {
106
    struct {
107
#ifdef BIG_ENDIAN
107
#ifdef BIG_ENDIAN
108
        unsigned p : 1;
108
        unsigned p : 1;
109
        unsigned : 27;
109
        unsigned : 27;
110
        unsigned index : 4;
110
        unsigned index : 4;
111
#else
111
#else
112
        unsigned index : 4;
112
        unsigned index : 4;
113
        unsigned : 27;
113
        unsigned : 27;
114
        unsigned p : 1;
114
        unsigned p : 1;
115
#endif
115
#endif
116
    } __attribute__ ((packed));
116
    } __attribute__ ((packed));
117
    uint32_t value;
117
    uint32_t value;
118
} tlb_index_t;
118
} tlb_index_t;
119
 
119
 
120
/** Probe TLB for Matching Entry
120
/** Probe TLB for Matching Entry
121
 *
121
 *
122
 * Probe TLB for Matching Entry.
122
 * Probe TLB for Matching Entry.
123
 */
123
 */
124
static inline void tlbp(void)
124
static inline void tlbp(void)
125
{
125
{
126
    asm volatile ("tlbp\n\t");
126
    asm volatile ("tlbp\n\t");
127
}
127
}
128
 
128
 
129
 
129
 
130
/** Read Indexed TLB Entry
130
/** Read Indexed TLB Entry
131
 *
131
 *
132
 * Read Indexed TLB Entry.
132
 * Read Indexed TLB Entry.
133
 */
133
 */
134
static inline void tlbr(void)
134
static inline void tlbr(void)
135
{
135
{
136
    asm volatile ("tlbr\n\t");
136
    asm volatile ("tlbr\n\t");
137
}
137
}
138
 
138
 
139
/** Write Indexed TLB Entry
139
/** Write Indexed TLB Entry
140
 *
140
 *
141
 * Write Indexed TLB Entry.
141
 * Write Indexed TLB Entry.
142
 */
142
 */
143
static inline void tlbwi(void)
143
static inline void tlbwi(void)
144
{
144
{
145
    asm volatile ("tlbwi\n\t");
145
    asm volatile ("tlbwi\n\t");
146
}
146
}
147
 
147
 
148
/** Write Random TLB Entry
148
/** Write Random TLB Entry
149
 *
149
 *
150
 * Write Random TLB Entry.
150
 * Write Random TLB Entry.
151
 */
151
 */
152
static inline void tlbwr(void)
152
static inline void tlbwr(void)
153
{
153
{
154
    asm volatile ("tlbwr\n\t");
154
    asm volatile ("tlbwr\n\t");
155
}
155
}
156
 
156
 
157
#define tlb_invalidate(asid)    tlb_invalidate_asid(asid)
157
#define tlb_invalidate(asid)    tlb_invalidate_asid(asid)
158
 
158
 
159
extern void tlb_invalid(istate_t *istate);
159
extern void tlb_invalid(istate_t *istate);
160
extern void tlb_refill(istate_t *istate);
160
extern void tlb_refill(istate_t *istate);
161
extern void tlb_modified(istate_t *istate);
161
extern void tlb_modified(istate_t *istate);
162
 
162
 
163
#endif
163
#endif
164
 
164
 
165
/** @}
165
/** @}
166
 */
166
 */
167
 
167