1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#define MMU_R_PID 0
21#define MMU_R_ZPR 1
22#define MMU_R_TLBX 2
23#define MMU_R_TLBLO 3
24#define MMU_R_TLBHI 4
25#define MMU_R_TLBSX 5
26
27#define RAM_DATA 1
28#define RAM_TAG 0
29
30
31#define TLB_EPN_MASK 0xFFFFFC00
32#define TLB_PAGESZ_MASK 0x00000380
33#define TLB_PAGESZ(x) (((x) & 0x7) << 7)
34#define PAGESZ_1K 0
35#define PAGESZ_4K 1
36#define PAGESZ_16K 2
37#define PAGESZ_64K 3
38#define PAGESZ_256K 4
39#define PAGESZ_1M 5
40#define PAGESZ_4M 6
41#define PAGESZ_16M 7
42#define TLB_VALID 0x00000040
43
44
45#define TLB_RPN_MASK 0xFFFFFC00
46#define TLB_PERM_MASK 0x00000300
47#define TLB_EX 0x00000200
48#define TLB_WR 0x00000100
49#define TLB_ZSEL_MASK 0x000000F0
50#define TLB_ZSEL(x) (((x) & 0xF) << 4)
51#define TLB_ATTR_MASK 0x0000000F
52#define TLB_W 0x00000008
53#define TLB_I 0x00000004
54#define TLB_M 0x00000002
55#define TLB_G 0x00000001
56
57#define TLB_ENTRIES 64
58
59struct microblaze_mmu
60{
61
62 uint32_t rams[2][TLB_ENTRIES];
63
64 uint8_t tids[TLB_ENTRIES];
65
66 uint32_t regs[8];
67
68 int c_mmu;
69 int c_mmu_tlb_access;
70 int c_mmu_zones;
71};
72
73struct microblaze_mmu_lookup
74{
75 uint32_t paddr;
76 uint32_t vaddr;
77 unsigned int size;
78 unsigned int idx;
79 int prot;
80 enum {
81 ERR_PROT, ERR_MISS, ERR_HIT
82 } err;
83};
84
85void mmu_flip_um(CPUMBState *env, unsigned int um);
86unsigned int mmu_translate(struct microblaze_mmu *mmu,
87 struct microblaze_mmu_lookup *lu,
88 target_ulong vaddr, int rw, int mmu_idx);
89uint32_t mmu_read(CPUMBState *env, uint32_t rn);
90void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v);
91void mmu_init(struct microblaze_mmu *mmu);
92