Skip to content

Zephyr-embARC_MLI internal review #2

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

Open
wants to merge 6 commits into
base: siyuan-embarc_mli_v2.0-base_tempo
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
15 changes: 15 additions & 0 deletions boards/arc/em_starterkit/arc_mpu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ static struct arc_mpu_region mpu_regions[] = {
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif

#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0
/* Region XCCM */
MPU_REGION_ENTRY("XCCM",
DT_REG_ADDR(DT_INST(0, arc_xccm)),
DT_REG_SIZE(DT_INST(0, arc_xccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0
/* Region YCCM */
MPU_REGION_ENTRY("YCCM",
DT_REG_ADDR(DT_INST(0, arc_yccm)),
DT_REG_SIZE(DT_INST(0, arc_yccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif

#if DT_REG_SIZE(DT_INST(0, mmio_sram)) > 0
/* Region DDR RAM */
MPU_REGION_ENTRY("DDR RAM",
Expand Down
10 changes: 10 additions & 0 deletions boards/arc/em_starterkit/em_starterkit.dts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
compatible = "arc,dccm";
reg = <0x80000000 DT_SIZE_K(128)>;
};

xccm@c0000000 {
compatible = "arc,xccm";
reg = <0xc0000000 DT_SIZE_K(8)>;
};

yccm@e0000000 {
compatible = "arc,yccm";
reg = <0xe0000000 DT_SIZE_K(8)>;
};
};

&uart1 {
Expand Down
10 changes: 10 additions & 0 deletions boards/arc/em_starterkit/em_starterkit_em11d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
compatible = "arc,dccm";
reg = <0x80000000 DT_SIZE_K(64)>;
};

xccm@e0000000 {
compatible = "arc,xccm";
reg = <0xc0000000 DT_SIZE_K(8)>;
};

yccm@e0000000 {
compatible = "arc,yccm";
reg = <0xe0000000 DT_SIZE_K(8)>;
};
};

&uart1 {
Expand Down
14 changes: 14 additions & 0 deletions boards/arc/emsdp/arc_mpu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ static struct arc_mpu_region mpu_regions[] = {
DT_REG_ADDR(DT_INST(0, arc_dccm)),
DT_REG_SIZE(DT_INST(0, arc_dccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
/* Region XCCM */
#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0
MPU_REGION_ENTRY("XCCM",
DT_REG_ADDR(DT_INST(0, arc_xccm)),
DT_REG_SIZE(DT_INST(0, arc_xccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
/* Region YCCM */
#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0
MPU_REGION_ENTRY("YCCM",
DT_REG_ADDR(DT_INST(0, arc_yccm)),
DT_REG_SIZE(DT_INST(0, arc_yccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
/* Region DDR RAM */
MPU_REGION_ENTRY("SRAM",
DT_REG_ADDR(DT_INST(0, mmio_sram)),
Expand Down
11 changes: 11 additions & 0 deletions boards/arc/emsdp/emsdp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/dts-v1/;

#include <synopsys/emsdp.dtsi>
#include <mem.h>
#include "board.dtsi"

/ {
Expand All @@ -22,6 +23,16 @@
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};

xccm@c0000000 {
compatible = "arc,xccm";
reg = <0xc0000000 DT_SIZE_K(16)>;
};

yccm@e0000000 {
compatible = "arc,yccm";
reg = <0xe0000000 DT_SIZE_K(16)>;
};
};

&uart0 {
Expand Down
11 changes: 11 additions & 0 deletions boards/arc/emsdp/emsdp_em9d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/dts-v1/;

#include <synopsys/emsdp.dtsi>
#include <mem.h>
#include "board.dtsi"

/ {
Expand All @@ -22,6 +23,16 @@
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};

xccm@c0000000 {
compatible = "arc,xccm";
reg = <0xc0000000 DT_SIZE_K(16)>;
};

yccm@e0000000 {
compatible = "arc,yccm";
reg = <0xe0000000 DT_SIZE_K(16)>;
};
};

&uart0 {
Expand Down
14 changes: 14 additions & 0 deletions boards/arc/iotdk/arc_mpu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ static struct arc_mpu_region mpu_regions[] = {
DT_REG_ADDR(DT_INST(0, arc_dccm)),
DT_REG_SIZE(DT_INST(0, arc_dccm)),
REGION_KERNEL_RAM_ATTR),
/* Region XCCM */
#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0
MPU_REGION_ENTRY("XCCM",
DT_REG_ADDR(DT_INST(0, arc_xccm)),
DT_REG_SIZE(DT_INST(0, arc_xccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
/* Region YCCM */
#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0
MPU_REGION_ENTRY("YCCM",
DT_REG_ADDR(DT_INST(0, arc_yccm)),
DT_REG_SIZE(DT_INST(0, arc_yccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
/* Region DDR RAM */
MPU_REGION_ENTRY("SRAM",
CONFIG_SRAM_BASE_ADDRESS,
Expand Down
11 changes: 11 additions & 0 deletions boards/arc/iotdk/iotdk.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/dts-v1/;

#include <synopsys/arc_iot.dtsi>
#include <mem.h>
#include "board.dtsi"

/ {
Expand All @@ -23,6 +24,16 @@
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};

xccm@c0000000 {
compatible = "arc,xccm";
reg = <0xc0000000 DT_SIZE_K(32)>;
};

yccm@e0000000 {
compatible = "arc,yccm";
reg = <0xe0000000 DT_SIZE_K(32)>;
};
};

&cpu0 {
Expand Down
15 changes: 14 additions & 1 deletion boards/arc/nsim/arc_mpu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ static struct arc_mpu_region mpu_regions[] = {
DT_REG_SIZE(DT_INST(0, arc_dccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif

#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0
/* Region XCCM */
MPU_REGION_ENTRY("XCCM",
DT_REG_ADDR(DT_INST(0, arc_xccm)),
DT_REG_SIZE(DT_INST(0, arc_xccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0
/* Region YCCM */
MPU_REGION_ENTRY("YCCM",
DT_REG_ADDR(DT_INST(0, arc_yccm)),
DT_REG_SIZE(DT_INST(0, arc_yccm)),
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
#endif
/*
* Region peripheral is shared by secure world and normal world by default,
* no need a static mpu entry. If some peripherals belong to secure world,
Expand Down
46 changes: 44 additions & 2 deletions boards/arc/nsim/nsim.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,41 @@
*/

/dts-v1/;

#include "skeleton.dtsi"
#include <mem.h>
#include "skeleton.dtsi"


#ifndef ICCM_ADDR
#define ICCM_ADDR 0
#endif

#ifndef ICCM_SIZE
#define ICCM_SIZE DT_SIZE_K(1024)
#endif

#ifndef DCCM_ADDR
#define DCCM_ADDR 80000000
#endif

#ifndef DCCM_SIZE
#define DCCM_SIZE DT_SIZE_K(1024)
#endif

#ifndef XCCM_ADDR
#define XCCM_ADDR c0000000
#endif

#ifndef YCCM_ADDR
#define YCCM_ADDR e0000000
#endif

#ifndef XCCM_SIZE
#define XCCM_SIZE DT_SIZE_K(64)
#endif

#ifndef YCCM_SIZE
#define YCCM_SIZE DT_SIZE_K(64)
#endif

/ {
cpus {
Expand Down Expand Up @@ -36,4 +68,14 @@
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};

xccm@c0000000 {
compatible = "arc,xccm";
reg = <DT_ADDR(XCCM_ADDR) XCCM_SIZE>;
};

yccm@e0000000 {
compatible = "arc,yccm";
reg = <DT_ADDR(YCCM_ADDR) YCCM_SIZE>;
};
};
5 changes: 3 additions & 2 deletions boards/arc/nsim/support/mdb_em.args
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
-Xagu_wb_depth=4
-Xagu_accord
-Xxy
-Xxy_config=dccm_y
-Xxy_size=8K
-Xxy_config=dccm_x_y
-Xxy_size=64K
-Xxy_interleave
-Xxy_x_base=0xc0000000
-Xxy_y_base=0xe0000000
-Xfpus_div
-Xfpu_mac
Expand Down
5 changes: 3 additions & 2 deletions boards/arc/nsim/support/nsim_em.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
nsim_isa_agu_wb_depth=4
nsim_isa_agu_accord=1
nsim_isa_xy=1
nsim_isa_xy_config=dccm_y
nsim_isa_xy_size=8K
nsim_isa_xy_config=dccm_x_y
nsim_isa_xy_size=64K
nsim_isa_xy_interleave=1
nsim_isa_xy_x_base=0xc0000000
nsim_isa_xy_y_base=0xe0000000
nsim_isa_fpus_div_option=1
nsim_isa_fpu_mac_option=1
Expand Down
12 changes: 12 additions & 0 deletions dts/bindings/arc/arc,xccm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2017, synopsy
# SPDX-License-Identifier: Apache-2.0

description: ARC XCCM

compatible: "arc,xccm"

include: base.yaml

properties:
reg:
required: true
12 changes: 12 additions & 0 deletions dts/bindings/arc/arc,yccm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2017, synopsy
# SPDX-License-Identifier: Apache-2.0

description: ARC YCCM

compatible: "arc,yccm"

include: base.yaml

properties:
reg:
required: true
9 changes: 9 additions & 0 deletions include/zephyr/arch/arc/v2/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ MEMORY {
#endif
#ifdef DCCM_START
DCCM (rw) : ORIGIN = DCCM_START, LENGTH = DCCM_SIZE
#endif
#ifdef XCCM_START
XCCM (rw) : ORIGIN = XCCM_START, LENGTH = XCCM_SIZE
#endif
#ifdef YCCM_START
YCCM (rw) : ORIGIN = YCCM_START, LENGTH = YCCM_SIZE
#endif
/* Used by and documented in include/linker/intlist.ld */
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
Expand Down Expand Up @@ -173,6 +179,9 @@ SECTIONS {

GROUP_START(DATA_REGION)

#ifdef CONFIG_EMBARC_MLI
#include "linker/../../../modules/embarc_mli/embarc_mli.ld"
#endif
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,) {

/* when XIP, .text is in ROM, but vector table must be at start of .data */
Expand Down
17 changes: 17 additions & 0 deletions include/zephyr/arch/arc/v2/xy_mem.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2022 Synopsys
*
* SPDX-License-Identifier: Apache-2.0
*/

#if DT_NODE_HAS_PROP(DT_INST(0, arc_xccm), reg) && \
(DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0)
#define XCCM_START DT_REG_ADDR(DT_INST(0, arc_xccm))
#define XCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_xccm))
#endif

#if DT_NODE_HAS_PROP(DT_INST(0, arc_yccm), reg) && \
(DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0)
#define YCCM_START DT_REG_ADDR(DT_INST(0, arc_yccm))
#define YCCM_SIZE DT_REG_SIZE(DT_INST(0, arc_yccm))
#endif
40 changes: 40 additions & 0 deletions modules/embarc_mli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2022 Synopsys
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_EMBARC_MLI) # Zephyr-sdk is unavailable, please use mwdt
if(DEFINED ENV{METAWARE_ROOT}) # If not to use prebuilt lib, add NOT
set(EMBARC_MLI_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
set(EMBARC_MLI_INCLUDE_DIR ${EMBARC_MLI_DIR}/include ${EMBARC_MLI_DIR}/include/api)
add_library(embarc_mli_lib STATIC IMPORTED GLOBAL)
set_target_properties(embarc_mli_lib PROPERTIES IMPORTED_LOCATION ${EMBARC_MLI_DIR}/prebuilt/libmli.a)
target_include_directories(embarc_mli_lib INTERFACE ${EMBARC_MLI_INCLUDE_DIR})
add_dependencies(zephyr_interface embarc_mli_lib)
zephyr_link_libraries(embarc_mli_lib)
else()
set(EMBARC_MLI_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
set(EMBARC_MLI_INCLUDE_DIR ${EMBARC_MLI_DIR}/include ${EMBARC_MLI_DIR}/include/api)
include(ExternalProject)
ExternalProject_Add(
embarc_mli_project # Name for custom target
PREFIX ${EMBARC_MLI_DIR} # Root dir for entire project
SOURCE_DIR ${EMBARC_MLI_DIR}
BINARY_DIR ${EMBARC_MLI_DIR}/lib/make # This particular build system is invoked from the root
CONFIGURE_COMMAND "" # Skip configuring the project, e.g. with autoconf
BUILD_COMMAND
gmake -C ${EMBARC_MLI_DIR}
TCF_FILE=${EMBARC_MLI_DIR}/hw/arcem.tcf
BUILD_DIR=${ZEPHYR_BINARY_DIR}/embarc_mli
LIBRARY_DIR=${ZEPHYR_BINARY_DIR}/embarc_mli/bin
JOBS=4
lib
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${ZEPHYR_BINARY_DIR}/embarc_mli/bin/libmli.a
)
# Create a wrapper CMake library that our app can link with
add_library(embarc_mli_lib STATIC IMPORTED GLOBAL)
set_target_properties(embarc_mli_lib PROPERTIES IMPORTED_LOCATION ${ZEPHYR_BINARY_DIR}/embarc_mli/bin/libmli.a)
target_include_directories(embarc_mli_lib INTERFACE ${EMBARC_MLI_INCLUDE_DIR})
add_dependencies(zephyr_interface embarc_mli_lib)
zephyr_link_libraries(embarc_mli_lib)
endif()
endif()
10 changes: 10 additions & 0 deletions modules/embarc_mli/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2022 Synopsys
# SPDX-License-Identifier: Apache-2.0

config ZEPHYR_EMBARC_MLI_MODULE
bool

config EMBARC_MLI
bool "embarc_mli Support"
help
This option enables the embarc_mli library.
Loading