2018-03-02 13:31:13 +01:00
|
|
|
/*
|
|
|
|
* SiFive PLIC (Platform Level Interrupt Controller) interface
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 SiFive, Inc.
|
|
|
|
*
|
|
|
|
* This provides a RISC-V PLIC device
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2 or later, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_SIFIVE_PLIC_H
|
|
|
|
#define HW_SIFIVE_PLIC_H
|
|
|
|
|
2019-08-12 07:23:31 +02:00
|
|
|
#include "hw/sysbus.h"
|
2020-08-31 23:07:30 +02:00
|
|
|
#include "qom/object.h"
|
2018-03-02 13:31:13 +01:00
|
|
|
|
|
|
|
#define TYPE_SIFIVE_PLIC "riscv.sifive.plic"
|
|
|
|
|
2020-08-31 23:07:30 +02:00
|
|
|
typedef struct SiFivePLICState SiFivePLICState;
|
2020-08-31 23:07:33 +02:00
|
|
|
DECLARE_INSTANCE_CHECKER(SiFivePLICState, SIFIVE_PLIC,
|
|
|
|
TYPE_SIFIVE_PLIC)
|
2018-03-02 13:31:13 +01:00
|
|
|
|
|
|
|
typedef enum PLICMode {
|
|
|
|
PLICMode_U,
|
|
|
|
PLICMode_S,
|
|
|
|
PLICMode_H,
|
|
|
|
PLICMode_M
|
|
|
|
} PLICMode;
|
|
|
|
|
|
|
|
typedef struct PLICAddr {
|
|
|
|
uint32_t addrid;
|
|
|
|
uint32_t hartid;
|
|
|
|
PLICMode mode;
|
|
|
|
} PLICAddr;
|
|
|
|
|
2020-08-31 23:07:30 +02:00
|
|
|
struct SiFivePLICState {
|
2018-03-02 13:31:13 +01:00
|
|
|
/*< private >*/
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
MemoryRegion mmio;
|
|
|
|
uint32_t num_addrs;
|
2020-05-15 06:55:33 +02:00
|
|
|
uint32_t num_harts;
|
2018-03-02 13:31:13 +01:00
|
|
|
uint32_t bitfield_words;
|
2020-10-26 12:55:30 +01:00
|
|
|
uint32_t num_enables;
|
2018-03-02 13:31:13 +01:00
|
|
|
PLICAddr *addr_config;
|
|
|
|
uint32_t *source_priority;
|
|
|
|
uint32_t *target_priority;
|
|
|
|
uint32_t *pending;
|
|
|
|
uint32_t *claimed;
|
|
|
|
uint32_t *enable;
|
|
|
|
|
|
|
|
/* config */
|
|
|
|
char *hart_config;
|
2020-05-15 06:55:33 +02:00
|
|
|
uint32_t hartid_base;
|
2018-03-02 13:31:13 +01:00
|
|
|
uint32_t num_sources;
|
|
|
|
uint32_t num_priorities;
|
|
|
|
uint32_t priority_base;
|
|
|
|
uint32_t pending_base;
|
|
|
|
uint32_t enable_base;
|
|
|
|
uint32_t enable_stride;
|
|
|
|
uint32_t context_base;
|
|
|
|
uint32_t context_stride;
|
|
|
|
uint32_t aperture_size;
|
2020-08-31 23:07:30 +02:00
|
|
|
};
|
2018-03-02 13:31:13 +01:00
|
|
|
|
|
|
|
DeviceState *sifive_plic_create(hwaddr addr, char *hart_config,
|
2020-05-15 06:55:33 +02:00
|
|
|
uint32_t hartid_base, uint32_t num_sources,
|
|
|
|
uint32_t num_priorities, uint32_t priority_base,
|
|
|
|
uint32_t pending_base, uint32_t enable_base,
|
|
|
|
uint32_t enable_stride, uint32_t context_base,
|
|
|
|
uint32_t context_stride, uint32_t aperture_size);
|
2018-03-02 13:31:13 +01:00
|
|
|
|
|
|
|
#endif
|