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

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

physical memory detection in MSIM (discontinous regions supported)
remove Sgi Indy (ARC) support — it was unmaintaned, untested for years and without uspace support

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