xref: /optee_os/core/arch/riscv/plat-virt/main.c (revision 0fc2d294569e3a9e95d6f768db33dfdd85b81738)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright 2022-2023 NXP
4  */
5 
6 #include <console.h>
7 #include <drivers/ns16550.h>
8 #include <drivers/plic.h>
9 #include <kernel/boot.h>
10 #include <kernel/tee_common_otp.h>
11 #include <platform_config.h>
12 
13 #ifdef CFG_16550_UART
14 static struct ns16550_data console_data __nex_bss;
15 register_phys_mem_pgdir(MEM_AREA_IO_NSEC, UART0_BASE, CORE_MMU_PGDIR_SIZE);
16 #endif
17 
18 register_ddr(DRAM_BASE, DRAM_SIZE);
19 
20 #ifdef CFG_RISCV_PLIC
21 void boot_primary_init_intc(void)
22 {
23 	plic_init(PLIC_BASE);
24 }
25 
26 void boot_secondary_init_intc(void)
27 {
28 	plic_hart_init();
29 }
30 #endif /* CFG_RISCV_PLIC */
31 
32 #ifdef CFG_16550_UART
33 void plat_console_init(void)
34 {
35 	ns16550_init(&console_data, UART0_BASE, IO_WIDTH_U8, 0);
36 	register_serial_console(&console_data.chip);
37 }
38 #endif
39 
40 void interrupt_main_handler(void)
41 {
42 	if (IS_ENABLED(CFG_RISCV_PLIC))
43 		plic_it_handle();
44 }
45