Skip to content

Commit f5f1aea

Browse files
committed
Fix the PLIC Interrupt Controller for SG2000
1 parent 4cee796 commit f5f1aea

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

arch/risc-v/src/bl808/bl808_irq.c

-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
void up_irqinitialize(void)
4848
{
49-
#ifdef TODO ////
5049
uintptr_t claim;
5150

5251
/* Disable S-Mode interrupts */
@@ -101,7 +100,6 @@ void up_irqinitialize(void)
101100

102101
up_irq_enable();
103102
#endif
104-
#endif //// TODO
105103
}
106104

107105
/****************************************************************************
@@ -114,7 +112,6 @@ void up_irqinitialize(void)
114112

115113
void up_disable_irq(int irq)
116114
{
117-
#ifdef TODO ////
118115
int extirq;
119116

120117
if (irq == RISCV_IRQ_SOFT)
@@ -145,7 +142,6 @@ void up_disable_irq(int irq)
145142
PANIC();
146143
}
147144
}
148-
#endif //// TODO
149145
}
150146

151147
/****************************************************************************
@@ -158,7 +154,6 @@ void up_disable_irq(int irq)
158154

159155
void up_enable_irq(int irq)
160156
{
161-
#ifdef TODO ////
162157
int extirq;
163158

164159
if (irq == RISCV_IRQ_SOFT)
@@ -189,7 +184,6 @@ void up_enable_irq(int irq)
189184
PANIC();
190185
}
191186
}
192-
#endif //// TODO
193187
}
194188

195189
irqstate_t up_irq_enable(void)

arch/risc-v/src/bl808/bl808_irq_dispatch.c

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151

5252
void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs)
5353
{
54-
#ifdef TODO ////
5554
int irq = (vector >> RV_IRQ_MASK) | (vector & 0xf);
5655

5756
/* Firstly, check if the irq is machine external interrupt */
@@ -81,6 +80,5 @@ void *riscv_dispatch_irq(uintptr_t vector, uintptr_t *regs)
8180
putreg32(irq - RISCV_IRQ_EXT, BL808_PLIC_CLAIM);
8281
}
8382

84-
#endif //// TODO
8583
return regs;
8684
}

arch/risc-v/src/bl808/bl808_mm_init.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,23 @@
5252
#define MMU_IO_BASE (0x00000000ul)
5353
#define MMU_IO_SIZE (0x40000000ul)
5454

55-
//// TODO: #define MMU_INT_BASE (0xe0000000ul)
56-
//// TODO: #define MMU_INT_SIZE (0x10000000ul)
55+
#define MMU_INT_BASE (0x70000000ul)
56+
#define MMU_INT_SIZE (0x10000000ul)
5757

5858
/* Physical and virtual addresses to page tables (vaddr = paddr mapping) */
5959

6060
#define PGT_L1_PBASE (uintptr_t)&m_l1_pgtable
6161
#define PGT_L2_PBASE (uintptr_t)&m_l2_pgtable
62-
//// TODO: #define PGT_L2_INT_PBASE (uintptr_t)&m_l2_int_pgtable
62+
#define PGT_L2_INT_PBASE (uintptr_t)&m_l2_int_pgtable
6363
#define PGT_L3_PBASE (uintptr_t)&m_l3_pgtable
6464
#define PGT_L1_VBASE PGT_L1_PBASE
6565
#define PGT_L2_VBASE PGT_L2_PBASE
66-
//// TODO: #define PGT_L2_INT_VBASE PGT_L2_INT_PBASE
66+
#define PGT_L2_INT_VBASE PGT_L2_INT_PBASE
6767
#define PGT_L3_VBASE PGT_L3_PBASE
6868

6969
#define PGT_L1_SIZE (512) /* Enough to map 512 GiB */
7070
#define PGT_L2_SIZE (512) /* Enough to map 1 GiB */
71-
//// TODO: #define PGT_L2_INT_SIZE (512) /* Enough to map 1 GiB */
71+
#define PGT_L2_INT_SIZE (512) /* Enough to map 1 GiB */
7272
#define PGT_L3_SIZE (1024) /* Enough to map 4 MiB (2MiB x 2) */
7373

7474
#define SLAB_COUNT (sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE)
@@ -98,7 +98,7 @@ typedef struct pgalloc_slab_s pgalloc_slab_t;
9898

9999
static size_t m_l1_pgtable[PGT_L1_SIZE] locate_data(".pgtables");
100100
static size_t m_l2_pgtable[PGT_L2_SIZE] locate_data(".pgtables");
101-
//// TODO: static size_t m_l2_int_pgtable[PGT_L2_INT_SIZE] locate_data(".pgtables");
101+
static size_t m_l2_int_pgtable[PGT_L2_INT_SIZE] locate_data(".pgtables");
102102
static size_t m_l3_pgtable[PGT_L3_SIZE] locate_data(".pgtables");
103103

104104
/* Kernel mappings (L1 base) */
@@ -244,7 +244,6 @@ void bl808_kernel_mappings(void)
244244
mmu_ln_map_region(1, PGT_L1_VBASE, MMU_IO_BASE, MMU_IO_BASE,
245245
MMU_IO_SIZE, MMU_THEAD_IO_FLAGS);
246246

247-
#ifdef TODO ////
248247
/* Map the PLIC with L2 page table */
249248

250249
binfo("map PLIC with L2 page table\n");
@@ -255,7 +254,6 @@ void bl808_kernel_mappings(void)
255254

256255
binfo("connect the L1 and PLIC L2 page tables\n");
257256
mmu_ln_setentry(1, PGT_L1_VBASE, PGT_L2_INT_PBASE, MMU_INT_BASE, PTE_G);
258-
#endif //// TODO
259257

260258
/* Map the kernel text and data for L2/L3 */
261259

arch/risc-v/src/bl808/hardware/bl808_memorymap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
/* Register Base Address ****************************************************/
2929

3030
//// TODO: #define BL808_UART3_BASE 0x30002000ul
31-
//// TODO: #define BL808_PLIC_BASE 0xe0000000ul
31+
#define BL808_PLIC_BASE 0x70000000ul
3232

3333
#endif /* __ARCH_RISCV_SRC_BL808_HARDWARE_BL808_MEMORYMAP_H */

drivers/serial/uart_16550.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,6 @@ static inline void u16550_serialout(FAR struct u16550_s *priv, int offset,
648648

649649
static int u16550_wait(FAR struct u16550_s *priv)
650650
{
651-
return OK; //// TODO
652-
#ifdef TODO ////
653651
int i;
654652

655653
for (i = 0; i < UART_TIMEOUT_MS; i++)
@@ -666,7 +664,6 @@ static int u16550_wait(FAR struct u16550_s *priv)
666664

667665
_err("UART timeout\n");
668666
return ERROR;
669-
#endif //// TODO
670667
}
671668
#endif /* CONFIG_16550_WAIT_LCR */
672669

@@ -748,7 +745,6 @@ static inline uint32_t u16550_divisor(FAR struct u16550_s *priv)
748745

749746
static int u16550_setup(FAR struct uart_dev_s *dev)
750747
{
751-
#ifdef TODO ////
752748
#ifndef CONFIG_16550_SUPRESS_CONFIG
753749
FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv;
754750
uint16_t div;
@@ -822,11 +818,13 @@ static int u16550_setup(FAR struct uart_dev_s *dev)
822818

823819
u16550_serialout(priv, UART_LCR_OFFSET, (lcr | UART_LCR_DLAB));
824820

821+
#ifdef TODO ////
825822
/* Set the BAUD divisor */
826823

827824
div = u16550_divisor(priv);
828825
u16550_serialout(priv, UART_DLM_OFFSET, div >> 8);
829826
u16550_serialout(priv, UART_DLL_OFFSET, div & 0xff);
827+
#endif //// TODO
830828

831829
#ifdef CONFIG_16550_WAIT_LCR
832830
/* Wait till UART is not busy before setting LCR */
@@ -873,7 +871,6 @@ static int u16550_setup(FAR struct uart_dev_s *dev)
873871
#endif
874872

875873
#endif
876-
#endif //// TODO
877874
return OK;
878875
}
879876

0 commit comments

Comments
 (0)