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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 119b46e was 2b95d13, checked in by Jakub Jermar <jakub@…>, 13 years ago

Merge mainline changes.

  • Property mode set to 100644
File size: 4.5 KB
RevLine 
[f761f1eb]1/*
[df4ed85]2 * Copyright (c) 2003-2004 Jakub Jermar
[f761f1eb]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
[e2d97d7]29/** @addtogroup mips32mm
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[06e1e95]35#ifndef KERN_mips32_TLB_H_
36#define KERN_mips32_TLB_H_
[f761f1eb]37
[edebc15c]38#include <typedefs.h>
39#include <arch/mm/asid.h>
[909c6e3]40#include <arch/exception.h>
[7a0359b]41#include <trace.h>
[909c6e3]42
[ba5cff5]43#if defined(PROCESSOR_R4000)
[e2d97d7]44#define TLB_ENTRY_COUNT 48
[d704d7f]45#define TLB_INDEX_BITS 6
[ba5cff5]46#elif defined(PROCESSOR_4Kc)
47#define TLB_ENTRY_COUNT 16
[d704d7f]48#define TLB_INDEX_BITS 4
[ba5cff5]49#else
50#error Please define TLB_ENTRY_COUNT for the target processor.
51#endif
[ce031f0]52
[192a23f0]53#define TLB_WIRED 0
[ce031f0]54
[e2d97d7]55#define TLB_PAGE_MASK_4K (0x000 << 13)
56#define TLB_PAGE_MASK_16K (0x003 << 13)
57#define TLB_PAGE_MASK_64K (0x00f << 13)
58#define TLB_PAGE_MASK_256K (0x03f << 13)
59#define TLB_PAGE_MASK_1M (0x0ff << 13)
60#define TLB_PAGE_MASK_4M (0x3ff << 13)
61#define TLB_PAGE_MASK_16M (0xfff << 13)
[ce031f0]62
[e2d97d7]63#define PAGE_UNCACHED 2
64#define PAGE_CACHEABLE_EXC_WRITE 5
[a1a03f9]65
[b3f8fb7]66typedef union {
[cc205f1]67 struct {
[aac12264]68#ifdef __BE__
[e2d97d7]69 unsigned : 2; /* zero */
70 unsigned pfn : 24; /* frame number */
71 unsigned c : 3; /* cache coherency attribute */
72 unsigned d : 1; /* dirty/write-protect bit */
73 unsigned v : 1; /* valid bit */
74 unsigned g : 1; /* global bit */
[f15fe51]75#else
[e2d97d7]76 unsigned g : 1; /* global bit */
77 unsigned v : 1; /* valid bit */
78 unsigned d : 1; /* dirty/write-protect bit */
79 unsigned c : 3; /* cache coherency attribute */
80 unsigned pfn : 24; /* frame number */
81 unsigned : 2; /* zero */
[f15fe51]82#endif
[cc205f1]83 } __attribute__ ((packed));
[7f1c620]84 uint32_t value;
[b3f8fb7]85} entry_lo_t;
86
87typedef union {
[cc205f1]88 struct {
[aac12264]89#ifdef __BE__
[f15fe51]90 unsigned vpn2 : 19;
91 unsigned : 5;
92 unsigned asid : 8;
93#else
[cc205f1]94 unsigned asid : 8;
95 unsigned : 5;
96 unsigned vpn2 : 19;
[f15fe51]97#endif
[cc205f1]98 } __attribute__ ((packed));
[7f1c620]99 uint32_t value;
[b3f8fb7]100} entry_hi_t;
[cc205f1]101
[b3f8fb7]102typedef union {
[cc205f1]103 struct {
[aac12264]104#ifdef __BE__
[f15fe51]105 unsigned : 7;
106 unsigned mask : 12;
107 unsigned : 13;
108#else
[cc205f1]109 unsigned : 13;
110 unsigned mask : 12;
111 unsigned : 7;
[f15fe51]112#endif
[cc205f1]113 } __attribute__ ((packed));
[7f1c620]114 uint32_t value;
[b3f8fb7]115} page_mask_t;
[cc205f1]116
[b3f8fb7]117typedef union {
[cc205f1]118 struct {
[aac12264]119#ifdef __BE__
[f15fe51]120 unsigned p : 1;
[d704d7f]121 unsigned : 32 - TLB_INDEX_BITS - 1;
122 unsigned index : TLB_INDEX_BITS;
[f15fe51]123#else
[d704d7f]124 unsigned index : TLB_INDEX_BITS;
125 unsigned : 32 - TLB_INDEX_BITS - 1;
[cc205f1]126 unsigned p : 1;
[f15fe51]127#endif
[cc205f1]128 } __attribute__ ((packed));
[7f1c620]129 uint32_t value;
[b3f8fb7]130} tlb_index_t;
[cc205f1]131
[38a1a84]132/** Probe TLB for Matching Entry
133 *
134 * Probe TLB for Matching Entry.
135 */
[7a0359b]136NO_TRACE static inline void tlbp(void)
[38a1a84]137{
[e7b7be3f]138 asm volatile ("tlbp\n\t");
[38a1a84]139}
140
[a1a03f9]141
[ce031f0]142/** Read Indexed TLB Entry
143 *
144 * Read Indexed TLB Entry.
145 */
[7a0359b]146NO_TRACE static inline void tlbr(void)
[ce031f0]147{
[e7b7be3f]148 asm volatile ("tlbr\n\t");
[ce031f0]149}
150
151/** Write Indexed TLB Entry
152 *
153 * Write Indexed TLB Entry.
154 */
[7a0359b]155NO_TRACE static inline void tlbwi(void)
[ce031f0]156{
[e7b7be3f]157 asm volatile ("tlbwi\n\t");
[ce031f0]158}
159
160/** Write Random TLB Entry
161 *
162 * Write Random TLB Entry.
163 */
[7a0359b]164NO_TRACE static inline void tlbwr(void)
[ce031f0]165{
[e7b7be3f]166 asm volatile ("tlbwr\n\t");
[ce031f0]167}
168
[e2d97d7]169#define tlb_invalidate(asid) tlb_invalidate_asid(asid)
[dd14cced]170
[25d7709]171extern void tlb_invalid(istate_t *istate);
172extern void tlb_refill(istate_t *istate);
173extern void tlb_modified(istate_t *istate);
[edebc15c]174extern void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn);
175extern void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr);
[f761f1eb]176
177#endif
[b45c443]178
[2f40fe4]179/** @}
[b45c443]180 */
Note: See TracBrowser for help on using the repository browser.