Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dts): add some empty devices node #812

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ SRCS-$(CONFIG_HAS_AUDIO) += src/device/audio.c
SRCS-$(CONFIG_HAS_DISK) += src/device/disk.c
SRCS-$(CONFIG_HAS_SDCARD) += src/device/sdcard.c
SRCS-$(CONFIG_HAS_FLASH) += src/device/flash.c
SRCS-$(CONFIG_HAS_IMSIC_M) += src/device/imsic_m.c
SRCS-$(CONFIG_HAS_IMSIC_S) += src/device/imsic_s.c
SRCS-$(CONFIG_HAS_APLIC_M) += src/device/aplic_m.c
SRCS-$(CONFIG_HAS_APLIC_S) += src/device/aplic_s.c

DIRS-y += src/profiling

Expand Down
11 changes: 10 additions & 1 deletion configs/riscv64-xs_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ CONFIG_TDATA1_MCONTROL6=y
# CONFIG_TDATA1_ETRIGGER is not set
CONFIG_TRIGGER_NUM=4
# CONFIG_SDTRIG_EXTRA is not set
# CONFIG_RV_AIA is not set
CONFIG_RV_AIA=y
CONFIG_RV_IMSIC=y
CONFIG_RV_SSTC=y
CONFIG_RV_SMRNMI=y
CONFIG_RV_SMDBLTRP=y
Expand Down Expand Up @@ -155,6 +156,14 @@ CONFIG_UARTLITE_ASSERT_FOUR=y
# CONFIG_HAS_UART_SNPS is not set
CONFIG_HAS_PLIC=y
CONFIG_PLIC_ADDRESS=0x3c000000
CONFIG_HAS_IMSIC_M=y
CONFIG_IMSIC_M_ADDRESS=0x3a800000
CONFIG_HAS_IMSIC_S=y
CONFIG_IMSIC_S_ADDRESS=0x3b000000
CONFIG_HAS_APLIC_M=y
CONFIG_APLIC_M_ADDRESS=0x31100000
CONFIG_HAS_APLIC_S=y
CONFIG_APLIC_S_ADDRESS=0x31120000
# CONFIG_HAS_TIMER is not set
CONFIG_RTC_PORT=0x48
CONFIG_RTC_MMIO=0xa1000048
Expand Down
44 changes: 44 additions & 0 deletions src/device/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,50 @@ config PLIC_ADDRESS
default 0x3c000000
endif

menuconfig HAS_IMSIC_M
depends on !SHARE
bool "Enable IMSIC_M"
default n

if HAS_IMSIC_M
config IMSIC_M_ADDRESS
hex "base address of IMSIC_M"
default 0x3a800000
endif

menuconfig HAS_IMSIC_S
depends on !SHARE
bool "Enable IMSIC_S"
default n

if HAS_IMSIC_S
config IMSIC_S_ADDRESS
hex "base address of IMSIC_S"
default 0x3b000000
endif

menuconfig HAS_APLIC_M
depends on !SHARE
bool "Enable APLIC_M"
default n

if HAS_APLIC_M
config APLIC_M_ADDRESS
hex "base address of APLIC_M"
default 0x31100000
endif

menuconfig HAS_APLIC_S
depends on !SHARE
bool "Enable APLIC_S"
default n

if HAS_APLIC_S
config APLIC_S_ADDRESS
hex "base address of APLIC_S"
default 0x31120000
endif

menuconfig HAS_TIMER
depends on !SHARE
bool "Enable timer"
Expand Down
15 changes: 15 additions & 0 deletions src/device/aplic_m.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <utils.h>
#include <device/map.h>

uint8_t *aplic_m_base = NULL;
#define APLIC_M_SIZE (0x8000)

static void aplic_m_io_handler(uint32_t offset, int len, bool is_write) {
// Fake aplic_m handler, empty now
return;
}

void init_aplic_m(const char *flash_img) {
aplic_m_base = new_space(APLIC_M_SIZE);
add_mmio_map("aplic_m", CONFIG_APLIC_M_ADDRESS, aplic_m_base, APLIC_M_SIZE, aplic_m_io_handler);
}
15 changes: 15 additions & 0 deletions src/device/aplic_s.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <utils.h>
#include <device/map.h>

uint8_t *aplic_s_base = NULL;
#define APLIC_S_SIZE (0x8000)

static void aplic_s_io_handler(uint32_t offset, int len, bool is_write) {
// Fake aplic_s handler, empty now
return;
}

void init_aplic_s(const char *flash_img) {
aplic_s_base = new_space(APLIC_S_SIZE);
add_mmio_map("aplic_s", CONFIG_APLIC_S_ADDRESS, aplic_s_base, APLIC_S_SIZE, aplic_s_io_handler);
}
8 changes: 8 additions & 0 deletions src/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ void init_disk();
void init_sdcard();
void init_flash();
void load_flash_contents(const char *);
void init_imsic_m();
void init_imsic_s();
void init_aplic_m();
void init_aplic_s();

void send_key(uint8_t, bool);
void vga_update_screen();
Expand Down Expand Up @@ -99,6 +103,10 @@ void init_device() {
IFDEF(CONFIG_HAS_DISK, init_disk());
IFDEF(CONFIG_HAS_SDCARD, init_sdcard());
IFDEF(CONFIG_HAS_FLASH, init_flash());
IFDEF(CONFIG_HAS_IMSIC_M, init_imsic_m());
IFDEF(CONFIG_HAS_IMSIC_S, init_imsic_s());
IFDEF(CONFIG_HAS_APLIC_M, init_aplic_m());
IFDEF(CONFIG_HAS_APLIC_S, init_aplic_s());

// host alarm for device and timer update.
add_alarm_handle(set_device_update_flag);
Expand Down
15 changes: 15 additions & 0 deletions src/device/imsic_m.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <utils.h>
#include <device/map.h>

uint8_t *imsic_m_base = NULL;
#define IMSIC_M_SIZE (0x10000)

static void imsic_m_io_handler(uint32_t offset, int len, bool is_write) {
// Fake imsic_m handler, empty now
return;
}

void init_imsic_m(const char *flash_img) {
imsic_m_base = new_space(IMSIC_M_SIZE);
add_mmio_map("imsic_m", CONFIG_IMSIC_M_ADDRESS, imsic_m_base, IMSIC_M_SIZE, imsic_m_io_handler);
}
15 changes: 15 additions & 0 deletions src/device/imsic_s.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <utils.h>
#include <device/map.h>

uint8_t *imsic_s_base = NULL;
#define IMSIC_S_SIZE (0x80000)

static void imsic_s_io_handler(uint32_t offset, int len, bool is_write) {
// Fake imsic_s handler, empty now
return;
}

void init_imsic_s(const char *flash_img) {
imsic_s_base = new_space(IMSIC_S_SIZE);
add_mmio_map("imsic_s", CONFIG_IMSIC_S_ADDRESS, imsic_s_base, IMSIC_S_SIZE, imsic_s_io_handler);
}