2 * QEMU RISC-V PMP (Physical Memory Protection)
4 * Author: Daire McNamara, daire.mcnamara@emdalo.com
5 * Ivan Griffin, ivan.griffin@emdalo.com
7 * This provides a RISC-V Physical Memory Protection interface
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2 or later, as published by the Free Software Foundation.
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
33 PMP_AMATCH_OFF
, /* Null (off) */
34 PMP_AMATCH_TOR
, /* Top of Range */
35 PMP_AMATCH_NA4
, /* Naturally aligned four-byte region */
36 PMP_AMATCH_NAPOT
/* Naturally aligned power-of-two region */
41 MSECCFG_MMWP
= 1 << 1,
46 target_ulong addr_reg
;
56 pmp_entry_t pmp
[MAX_RISCV_PMPS
];
57 pmp_addr_t addr
[MAX_RISCV_PMPS
];
61 void pmpcfg_csr_write(CPURISCVState
*env
, uint32_t reg_index
,
63 target_ulong
pmpcfg_csr_read(CPURISCVState
*env
, uint32_t reg_index
);
65 void mseccfg_csr_write(CPURISCVState
*env
, target_ulong val
);
66 target_ulong
mseccfg_csr_read(CPURISCVState
*env
);
68 void pmpaddr_csr_write(CPURISCVState
*env
, uint32_t addr_index
,
70 target_ulong
pmpaddr_csr_read(CPURISCVState
*env
, uint32_t addr_index
);
71 bool pmp_hart_has_privs(CPURISCVState
*env
, target_ulong addr
,
72 target_ulong size
, pmp_priv_t privs
, pmp_priv_t
*allowed_privs
,
74 bool pmp_is_range_in_tlb(CPURISCVState
*env
, hwaddr tlb_sa
,
75 target_ulong
*tlb_size
);
76 void pmp_update_rule_addr(CPURISCVState
*env
, uint32_t pmp_index
);
77 void pmp_update_rule_nums(CPURISCVState
*env
);
78 uint32_t pmp_get_num_rules(CPURISCVState
*env
);
79 int pmp_priv_to_page_prot(pmp_priv_t pmp_priv
);
81 #define MSECCFG_MML_ISSET(env) get_field(env->mseccfg, MSECCFG_MML)
82 #define MSECCFG_MMWP_ISSET(env) get_field(env->mseccfg, MSECCFG_MMWP)
83 #define MSECCFG_RLB_ISSET(env) get_field(env->mseccfg, MSECCFG_RLB)