source: mainline/kernel/arch/mips32/include/mm/tlb.h@ a820bf7

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a820bf7 was d99c1d2, checked in by Martin Decky <martin@…>, 15 years ago

use [u]int{8|16|32|64}_t type definitions as detected by the autotool
replace direct usage of arch/types.h with typedefs.h

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Copyright (c) 2003-2004 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
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
15 * derived from this software without specific prior written permission.
16 *
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
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup mips32mm
30 * @{
31 */
32/** @file
33 */
34
35#ifndef KERN_mips32_TLB_H_
36#define KERN_mips32_TLB_H_
37
38#include <typedefs.h>
39#include <arch/mm/asid.h>
40#include <arch/exception.h>
41
42#define TLB_ENTRY_COUNT 48
43
44#define TLB_WIRED 1
45#define TLB_KSTACK_WIRED_INDEX 0
46
47#define TLB_PAGE_MASK_4K (0x000 << 13)
48#define TLB_PAGE_MASK_16K (0x003 << 13)
49#define TLB_PAGE_MASK_64K (0x00f << 13)
50#define TLB_PAGE_MASK_256K (0x03f << 13)
51#define TLB_PAGE_MASK_1M (0x0ff << 13)
52#define TLB_PAGE_MASK_4M (0x3ff << 13)
53#define TLB_PAGE_MASK_16M (0xfff << 13)
54
55#define PAGE_UNCACHED 2
56#define PAGE_CACHEABLE_EXC_WRITE 5
57
58typedef union {
59 struct {
60#ifdef __BE__
61 unsigned : 2; /* zero */
62 unsigned pfn : 24; /* frame number */
63 unsigned c : 3; /* cache coherency attribute */
64 unsigned d : 1; /* dirty/write-protect bit */
65 unsigned v : 1; /* valid bit */
66 unsigned g : 1; /* global bit */
67#else
68 unsigned g : 1; /* global bit */
69 unsigned v : 1; /* valid bit */
70 unsigned d : 1; /* dirty/write-protect bit */
71 unsigned c : 3; /* cache coherency attribute */
72 unsigned pfn : 24; /* frame number */
73 unsigned : 2; /* zero */
74#endif
75 } __attribute__ ((packed));
76 uint32_t value;
77} entry_lo_t;
78
79typedef union {
80 struct {
81#ifdef __BE__
82 unsigned vpn2 : 19;
83 unsigned : 5;
84 unsigned asid : 8;
85#else
86 unsigned asid : 8;
87 unsigned : 5;
88 unsigned vpn2 : 19;
89#endif
90 } __attribute__ ((packed));
91 uint32_t value;
92} entry_hi_t;
93
94typedef union {
95 struct {
96#ifdef __BE__
97 unsigned : 7;
98 unsigned mask : 12;
99 unsigned : 13;
100#else
101 unsigned : 13;
102 unsigned mask : 12;
103 unsigned : 7;
104#endif
105 } __attribute__ ((packed));
106 uint32_t value;
107} page_mask_t;
108
109typedef union {
110 struct {
111#ifdef __BE__
112 unsigned p : 1;
113 unsigned : 27;
114 unsigned index : 4;
115#else
116 unsigned index : 4;
117 unsigned : 27;
118 unsigned p : 1;
119#endif
120 } __attribute__ ((packed));
121 uint32_t value;
122} tlb_index_t;
123
124/** Probe TLB for Matching Entry
125 *
126 * Probe TLB for Matching Entry.
127 */
128static inline void tlbp(void)
129{
130 asm volatile ("tlbp\n\t");
131}
132
133
134/** Read Indexed TLB Entry
135 *
136 * Read Indexed TLB Entry.
137 */
138static inline void tlbr(void)
139{
140 asm volatile ("tlbr\n\t");
141}
142
143/** Write Indexed TLB Entry
144 *
145 * Write Indexed TLB Entry.
146 */
147static inline void tlbwi(void)
148{
149 asm volatile ("tlbwi\n\t");
150}
151
152/** Write Random TLB Entry
153 *
154 * Write Random TLB Entry.
155 */
156static inline void tlbwr(void)
157{
158 asm volatile ("tlbwr\n\t");
159}
160
161#define tlb_invalidate(asid) tlb_invalidate_asid(asid)
162
163extern void tlb_invalid(istate_t *istate);
164extern void tlb_refill(istate_t *istate);
165extern void tlb_modified(istate_t *istate);
166extern void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn);
167extern void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr);
168
169#endif
170
171/** @}
172 */
Note: See TracBrowser for help on using the repository browser.