2009-05-20 22:08:24 +04:00
|
|
|
/*
|
|
|
|
* Microblaze MMU emulation for qemu.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Edgar E. Iglesias
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-23 15:18:21 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2009-05-20 22:08:24 +04:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-07-17 00:47:01 +04:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2009-05-20 22:08:24 +04:00
|
|
|
*/
|
|
|
|
|
2019-06-04 21:16:18 +03:00
|
|
|
#ifndef TARGET_MICROBLAZE_MMU_H
|
|
|
|
#define TARGET_MICROBLAZE_MMU_H
|
|
|
|
|
2022-02-07 14:44:46 +03:00
|
|
|
#include "cpu.h"
|
|
|
|
|
2009-05-20 22:08:24 +04:00
|
|
|
#define MMU_R_PID 0
|
|
|
|
#define MMU_R_ZPR 1
|
|
|
|
#define MMU_R_TLBX 2
|
|
|
|
#define MMU_R_TLBLO 3
|
|
|
|
#define MMU_R_TLBHI 4
|
|
|
|
#define MMU_R_TLBSX 5
|
|
|
|
|
|
|
|
#define RAM_DATA 1
|
|
|
|
#define RAM_TAG 0
|
|
|
|
|
|
|
|
/* Tag portion */
|
2018-04-16 22:03:01 +03:00
|
|
|
#define TLB_EPN_MASK MAKE_64BIT_MASK(10, 64 - 10)
|
2009-05-20 22:08:24 +04:00
|
|
|
#define TLB_PAGESZ_MASK 0x00000380
|
|
|
|
#define TLB_PAGESZ(x) (((x) & 0x7) << 7)
|
|
|
|
#define PAGESZ_1K 0
|
|
|
|
#define PAGESZ_4K 1
|
|
|
|
#define PAGESZ_16K 2
|
|
|
|
#define PAGESZ_64K 3
|
|
|
|
#define PAGESZ_256K 4
|
|
|
|
#define PAGESZ_1M 5
|
|
|
|
#define PAGESZ_4M 6
|
|
|
|
#define PAGESZ_16M 7
|
|
|
|
#define TLB_VALID 0x00000040 /* Entry is valid */
|
|
|
|
|
|
|
|
/* Data portion */
|
2018-04-16 22:03:01 +03:00
|
|
|
#define TLB_RPN_MASK MAKE_64BIT_MASK(10, 64 - 10)
|
2009-05-20 22:08:24 +04:00
|
|
|
#define TLB_PERM_MASK 0x00000300
|
|
|
|
#define TLB_EX 0x00000200 /* Instruction execution allowed */
|
|
|
|
#define TLB_WR 0x00000100 /* Writes permitted */
|
|
|
|
#define TLB_ZSEL_MASK 0x000000F0
|
|
|
|
#define TLB_ZSEL(x) (((x) & 0xF) << 4)
|
|
|
|
#define TLB_ATTR_MASK 0x0000000F
|
|
|
|
#define TLB_W 0x00000008 /* Caching is write-through */
|
|
|
|
#define TLB_I 0x00000004 /* Caching is inhibited */
|
|
|
|
#define TLB_M 0x00000002 /* Memory is coherent */
|
|
|
|
#define TLB_G 0x00000001 /* Memory is guarded from prefetch */
|
|
|
|
|
2018-04-16 00:18:49 +03:00
|
|
|
/* TLBX */
|
|
|
|
#define R_TBLX_MISS_SHIFT 31
|
|
|
|
#define R_TBLX_MISS_MASK (1U << R_TBLX_MISS_SHIFT)
|
|
|
|
|
2009-05-20 22:08:24 +04:00
|
|
|
#define TLB_ENTRIES 64
|
|
|
|
|
2020-09-03 09:18:35 +03:00
|
|
|
typedef struct {
|
2009-05-20 22:08:24 +04:00
|
|
|
/* Data and tag brams. */
|
2018-04-16 22:03:01 +03:00
|
|
|
uint64_t rams[2][TLB_ENTRIES];
|
2009-05-20 22:08:24 +04:00
|
|
|
/* We keep a separate ram for the tids to avoid the 48 bit tag width. */
|
|
|
|
uint8_t tids[TLB_ENTRIES];
|
|
|
|
/* Control flops. */
|
2018-04-16 00:25:58 +03:00
|
|
|
uint32_t regs[3];
|
2020-09-03 09:18:35 +03:00
|
|
|
} MicroBlazeMMU;
|
2009-05-20 22:08:24 +04:00
|
|
|
|
2020-09-03 09:18:35 +03:00
|
|
|
typedef struct {
|
2009-05-20 22:08:24 +04:00
|
|
|
uint32_t paddr;
|
|
|
|
uint32_t vaddr;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int idx;
|
|
|
|
int prot;
|
|
|
|
enum {
|
|
|
|
ERR_PROT, ERR_MISS, ERR_HIT
|
|
|
|
} err;
|
2020-09-03 09:18:35 +03:00
|
|
|
} MicroBlazeMMULookup;
|
2009-05-20 22:08:24 +04:00
|
|
|
|
2020-09-04 21:31:57 +03:00
|
|
|
unsigned int mmu_translate(MicroBlazeCPU *cpu, MicroBlazeMMULookup *lu,
|
2021-01-22 03:18:54 +03:00
|
|
|
target_ulong vaddr, MMUAccessType rw, int mmu_idx);
|
2018-04-16 22:25:01 +03:00
|
|
|
uint32_t mmu_read(CPUMBState *env, bool ea, uint32_t rn);
|
|
|
|
void mmu_write(CPUMBState *env, bool ea, uint32_t rn, uint32_t v);
|
2020-09-03 09:18:35 +03:00
|
|
|
void mmu_init(MicroBlazeMMU *mmu);
|
2019-06-04 21:16:18 +03:00
|
|
|
|
|
|
|
#endif
|