summaryrefslogtreecommitdiff
path: root/libcpu/risc-v/t-head/c908/plic.h
blob: 94f00eacdb86e40ea9cb4d25e9ac91b325bf0be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-10-19     JasonHu      first version
 * 2023-04-22     flyingcys    add C906_PLIC_PHY_ADDR macro judge
 */

#ifndef __RISCV64_PLIC_H__
#define __RISCV64_PLIC_H__

#include <interrupt.h>

#ifndef C908_PLIC_PHY_ADDR
#define C908_PLIC_PHY_ADDR              (0xF00000000UL)
#endif
#define C908_PLIC_NR_EXT_IRQS           (IRQ_MAX_NR)
#define C908_NR_CPUS                    (NR_CPUS)

/* M and S mode context. */
#define C908_NR_CONTEXT                 (2)

#define MAX_DEVICES                     1024
#define MAX_CONTEXTS                    15872

/*
 *  Each interrupt source has a priority register associated with it.
 *  We always hardwire it to one in Linux.
 */
#define PRIORITY_BASE                   0
#define PRIORITY_PER_ID                 4

/*
 *  Each hart context has a vector of interrupt enable bits associated with it.
 *  There's one bit for each interrupt source.
 */
#define ENABLE_BASE                     0x2000
#define ENABLE_PER_HART                 0x80

/*
 *  Each hart context has a set of control registers associated with it.  Right
 *  now there's only two: a source priority threshold over which the hart will
 *  take an interrupt, and a register to claim interrupts.
 */
#define CONTEXT_BASE                    0x200000
#define CONTEXT_PER_HART                0x1000
#define CONTEXT_THRESHOLD               0x00
#define CONTEXT_CLAIM                   0x04

void plic_init(void);
void plic_enable_irq(int irqno);
void plic_disable_irq(int irqno);
// tell PLIC that we've served this IRQ
void plic_complete(int irq);
void plic_handle_irq(void);

#endif