From c104a54ff3015a2885efec24f941ac0d17f120a8 Mon Sep 17 00:00:00 2001 From: Andy Liu Date: Sat, 21 May 2022 23:09:19 +0800 Subject: [PATCH] add initial code Signed-off-by: Andy Liu --- BUILD.gn | 27 ++++ Kconfig.liteos_m.boards | 17 +++ Kconfig.liteos_m.defconfig.boards | 16 +++ b91_devkit/BUILD.gn | 22 ++++ b91_devkit/Kconfig.liteos_m.board | 18 +++ b91_devkit/Kconfig.liteos_m.defconfig.board | 21 +++ b91_devkit/b91_devkit_defconfig | 18 +++ b91_devkit/liteos_m/BUILD.gn | 20 +++ b91_devkit/liteos_m/config.gni | 69 ++++++++++ b91_devkit/liteos_m/include/app_config.h | 31 +++++ b91_devkit/liteos_m/include/board_config.h | 39 ++++++ b91_devkit/liteos_m/include/memmap_config.h | 40 ++++++ b91_devkit/liteos_m/include/target_config.h | 120 ++++++++++++++++++ .../liteos_common_include/riscv_hal.h | 43 +++++++ .../liteos_m/liteos_common_include/soc.h | 39 ++++++ drivers/BUILD.gn | 21 +++ hcs/BUILD.gn | 26 ++++ hcs/b91_devkit.hcs | 19 +++ 18 files changed, 606 insertions(+) create mode 100755 BUILD.gn create mode 100755 Kconfig.liteos_m.boards create mode 100755 Kconfig.liteos_m.defconfig.boards create mode 100755 b91_devkit/BUILD.gn create mode 100755 b91_devkit/Kconfig.liteos_m.board create mode 100755 b91_devkit/Kconfig.liteos_m.defconfig.board create mode 100755 b91_devkit/b91_devkit_defconfig create mode 100755 b91_devkit/liteos_m/BUILD.gn create mode 100755 b91_devkit/liteos_m/config.gni create mode 100755 b91_devkit/liteos_m/include/app_config.h create mode 100755 b91_devkit/liteos_m/include/board_config.h create mode 100755 b91_devkit/liteos_m/include/memmap_config.h create mode 100755 b91_devkit/liteos_m/include/target_config.h create mode 100755 b91_devkit/liteos_m/liteos_common_include/riscv_hal.h create mode 100755 b91_devkit/liteos_m/liteos_common_include/soc.h create mode 100755 drivers/BUILD.gn create mode 100755 hcs/BUILD.gn create mode 100755 hcs/b91_devkit.hcs diff --git a/BUILD.gn b/BUILD.gn new file mode 100755 index 0000000..df95d79 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (ohos_kernel_type == "liteos_m") { + import("//kernel/liteos_m/liteos.gni") + module_name = get_path_info(rebase_path("."), "name") + module_group(module_name) { + modules = [ + "b91_devkit", + "drivers", + "hcs", + ] + } +} + diff --git a/Kconfig.liteos_m.boards b/Kconfig.liteos_m.boards new file mode 100755 index 0000000..cf62ece --- /dev/null +++ b/Kconfig.liteos_m.boards @@ -0,0 +1,17 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +orsource "*/Kconfig.liteos_m.board" + diff --git a/Kconfig.liteos_m.defconfig.boards b/Kconfig.liteos_m.defconfig.boards new file mode 100755 index 0000000..26a67eb --- /dev/null +++ b/Kconfig.liteos_m.defconfig.boards @@ -0,0 +1,16 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +orsource "*/Kconfig.liteos_m.defconfig.board" diff --git a/b91_devkit/BUILD.gn b/b91_devkit/BUILD.gn new file mode 100755 index 0000000..6755025 --- /dev/null +++ b/b91_devkit/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (ohos_kernel_type == "liteos_m") { + import("//kernel/liteos_m/liteos.gni") + module_name = get_path_info(rebase_path("."), "name") + module_group(module_name) { + modules = [ "liteos_m" ] + } +} diff --git a/b91_devkit/Kconfig.liteos_m.board b/b91_devkit/Kconfig.liteos_m.board new file mode 100755 index 0000000..4eff888 --- /dev/null +++ b/b91_devkit/Kconfig.liteos_m.board @@ -0,0 +1,18 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config BOARD_B91_DEVKIT + bool "Select Board B91 Devkit" + depends on SOC_B91 diff --git a/b91_devkit/Kconfig.liteos_m.defconfig.board b/b91_devkit/Kconfig.liteos_m.defconfig.board new file mode 100755 index 0000000..9fdfff3 --- /dev/null +++ b/b91_devkit/Kconfig.liteos_m.defconfig.board @@ -0,0 +1,21 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if BOARD_B91_DEVKIT +config BOARD + string + default "b91_devkit" +endif # BOARD_B91_DEVKIT + diff --git a/b91_devkit/b91_devkit_defconfig b/b91_devkit/b91_devkit_defconfig new file mode 100755 index 0000000..42aac4e --- /dev/null +++ b/b91_devkit/b91_devkit_defconfig @@ -0,0 +1,18 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOSCFG_BOARD_B91_DEVKIT=y +LOSCFG_SOC_SERIES_B91=y +LOSCFG_SOC_B91=y diff --git a/b91_devkit/liteos_m/BUILD.gn b/b91_devkit/liteos_m/BUILD.gn new file mode 100755 index 0000000..9b0763b --- /dev/null +++ b/b91_devkit/liteos_m/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//kernel/liteos_m/liteos.gni") + +module_name = get_path_info(rebase_path("."), "name") +kernel_module(module_name) { +} diff --git a/b91_devkit/liteos_m/config.gni b/b91_devkit/liteos_m/config.gni new file mode 100755 index 0000000..fe46bf4 --- /dev/null +++ b/b91_devkit/liteos_m/config.gni @@ -0,0 +1,69 @@ +# Kernel type, e.g. "linux", "liteos_a", "liteos_m". +kernel_type = "liteos_m" + +# Kernel version. +kernel_version = "3.0.0" + +# Board CPU type, e.g. "cortex-a7", "riscv32". +board_cpu = "" + +# Board arch, e.g. "armv7-a", "rv32imac". +board_arch = "rv32imafc" + +# Toolchain name used for system compiling. +# E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf. +# Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain. +board_toolchain = "riscv32-elf" + +use_board_toolchain = true + +# The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc. +board_toolchain_path = getenv("TELINK_RISCV_TOOLCHAIN") + +# Compiler prefix. +board_toolchain_prefix = "riscv32-elf-" + +# Compiler type, "gcc" or "clang". +board_toolchain_type = "gcc" + +# Board related common compile flags. +board_cflags = [ + "-mcmodel=medium", + "-mcpu=d25f", + "-mext-dsp", + "-mabi=ilp32f", + "-ffunction-sections", + "-fdata-sections", + "-std=c99", +] + +board_asmflags = [ + "-mcmodel=medium", + "-mcpu=d25f", + "-mext-dsp", + "-mabi=ilp32f", + "-fdata-sections", +] + +board_cxx_flags = board_cflags + +board_ld_flags = [ + "-nostartfiles", + "-fuse-ld=bfd", + "-specs=nosys.specs", +] + +# Board related headfiles search path. +board_include_dirs = [ + rebase_path("include"), + rebase_path("liteos_common_include"), +] + +# Board adapter dir for OHOS components. +board_adapter_dir = "//device/soc/telink/b91/adapter" + +# Sysroot path. +board_configed_sysroot = "" + +# Board storage type, it used for file system generation. +storage_type = "" diff --git a/b91_devkit/liteos_m/include/app_config.h b/b91_devkit/liteos_m/include/app_config.h new file mode 100755 index 0000000..caf4bdf --- /dev/null +++ b/b91_devkit/liteos_m/include/app_config.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +#pragma once + + +#define MASTER_MAX_NUM 4 +#define SLAVE_MAX_NUM 4 + +///////////////////////// Feature Configuration//////////////////////////////////////////////// +#define FLASH_SIZE_CONFIG FLASH_SIZE_2M //very important, user need confirm !!! + +///////////////////////// DEBUG Configuration //////////////////////////////////////////////// +#define UART_PRINT_DEBUG_ENABLE 1 //printf + +#include "../common/default_config.h" diff --git a/b91_devkit/liteos_m/include/board_config.h b/b91_devkit/liteos_m/include/board_config.h new file mode 100755 index 0000000..93b595e --- /dev/null +++ b/b91_devkit/liteos_m/include/board_config.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +#ifndef BOARD_CONFIG_H +#define BOARD_CONFIG_H + +#include + +#define LED_BLUE_HDF 0 +#define LED_GREEN_HDF 1 +#define LED_WHITE_HDF 2 +#define LED_RED_HDF 3 + +#define SW1_2_GPIO GPIO_PC2 +#define SW3_4_GPIO GPIO_PC0 +#define SW1_3_GPIO GPIO_PC3 +#define SW2_4_GPIO GPIO_PC1 + +#define SW1_2_GPIO_HDF 6 +#define SW3_4_GPIO_HDF 4 +#define SW1_3_GPIO_HDF 7 +#define SW2_4_GPIO_HDF 5 + +#endif // BOARD_CONFIG_H diff --git a/b91_devkit/liteos_m/include/memmap_config.h b/b91_devkit/liteos_m/include/memmap_config.h new file mode 100755 index 0000000..f3dad67 --- /dev/null +++ b/b91_devkit/liteos_m/include/memmap_config.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +#ifndef _MEMMAP_CONFIG_H +#define _MEMMAP_CONFIG_H + +#include "los_compiler.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +extern UINT8 __los_heap_addr_start__[]; +extern UINT8 __los_heap_addr_end__[]; +extern UINT8 __los_heap_size__[]; + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _MEMMAP_CONFIG_H */ diff --git a/b91_devkit/liteos_m/include/target_config.h b/b91_devkit/liteos_m/include/target_config.h new file mode 100755 index 0000000..a573732 --- /dev/null +++ b/b91_devkit/liteos_m/include/target_config.h @@ -0,0 +1,120 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +/**@defgroup los_config System configuration items + * @ingroup kernel + */ + +#ifndef _TARGET_CONFIG_H +#define _TARGET_CONFIG_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#include "soc.h" +#include "memmap_config.h" + +/*============================================================================= + System clock module configuration +=============================================================================*/ +#define OS_SYS_CLOCK (32000) +#define LOSCFG_BASE_CORE_TICK_PER_SECOND (1000UL) +#define LOSCFG_BASE_CORE_TICK_HW_TIME 0 +#define LOSCFG_BASE_CORE_TICK_WTIMER 1 +/*============================================================================= + Hardware interrupt module configuration +=============================================================================*/ +#define LOSCFG_PLATFORM_HWI 1 +#define LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT 0 +#define LOSCFG_PLATFORM_HWI_LIMIT OS_HWI_MAX_NUM +#define LOSCFG_PLATFORM_HWI_WITH_ARG 1 +/*============================================================================= + Task module configuration +=============================================================================*/ +#define LOSCFG_BASE_CORE_TSK_LIMIT 12 +#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (2048) +#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (4096) +#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (1024) +#define LOSCFG_BASE_CORE_TIMESLICE 1 +#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 100000 +#define LOSCFG_BASE_CORE_TICK_RESPONSE_MAX 0xFFFFFFFFFFFFFFF +/*============================================================================= + Semaphore module configuration +=============================================================================*/ +#define LOSCFG_BASE_IPC_SEM 1 +#define LOSCFG_BASE_IPC_SEM_LIMIT 48 +/*============================================================================= + Mutex module configuration +=============================================================================*/ +#define LOSCFG_BASE_IPC_MUX 1 +#define LOSCFG_BASE_IPC_MUX_LIMIT 32 +/*============================================================================= + Queue module configuration +=============================================================================*/ +#define LOSCFG_BASE_IPC_QUEUE 1 +#define LOSCFG_BASE_IPC_QUEUE_LIMIT 16 +/*============================================================================= + Software timer module configuration +=============================================================================*/ +#define LOSCFG_BASE_CORE_SWTMR 1 +#define LOSCFG_BASE_CORE_SWTMR_ALIGN 1 +#define LOSCFG_BASE_CORE_SWTMR_LIMIT 6 +/*============================================================================= + Memory module configuration +=============================================================================*/ +#define LOSCFG_SYS_HEAP_SIZE OS_SYS_MEM_SIZE +#define LOSCFG_SYS_EXTERNAL_HEAP 1 +#define OS_SYS_MEM_SIZE ((UINT32)(__los_heap_size__)) +#define LOSCFG_SYS_HEAP_ADDR (VOID *)(__los_heap_addr_start__) +#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0 +#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 1 +#define LOSCFG_MEM_MUL_POOL 0 +#define OS_SYS_MEM_NUM 20 +#define LOSCFG_KERNEL_MEM_SLAB 0 +/*============================================================================= + Exception module configuration +=============================================================================*/ +#define LOSCFG_PLATFORM_EXC 0 +/* ============================================================================= + printf module configuration +============================================================================= */ +#define LOSCFG_KERNEL_PRINTF 1 +/* ============================================================================= + enable backtrace +============================================================================= */ +#define LOSCFG_BACKTRACE_TYPE 0 +#define LOSCFG_BACKTRACE_DEPTH 15 + +#define LOSCFG_FAMILY_B91 1 + +#define LOSCFG_TELINK_B91_CPU_FREQ 48000000 +#define LOSCFG_POWER_MODE_LDO_1P4_LDO_1P8 1 +#define LOSCFG_VBAT_TYPE_MAX_VALUE_GREATER_THAN_3V6 1 + + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + +#endif /* _TARGET_CONFIG_H */ diff --git a/b91_devkit/liteos_m/liteos_common_include/riscv_hal.h b/b91_devkit/liteos_m/liteos_common_include/riscv_hal.h new file mode 100755 index 0000000..8bfdbef --- /dev/null +++ b/b91_devkit/liteos_m/liteos_common_include/riscv_hal.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +#ifndef _RISCV_HAL_H +#define _RISCV_HAL_H + +#include "los_compiler.h" +#include "los_context.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +extern VOID HalIrqDisable(UINT32 vector); +extern VOID HalIrqEnable(UINT32 vector); +extern VOID HalSetLocalInterPri(UINT32 vector, UINT16 prior); +// +// extern VOID HalClockInit(OS_TICK_HANDLER handler, UINT32 period); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif + +#endif /* _RISCV_HAL_H */ diff --git a/b91_devkit/liteos_m/liteos_common_include/soc.h b/b91_devkit/liteos_m/liteos_common_include/soc.h new file mode 100755 index 0000000..15b650c --- /dev/null +++ b/b91_devkit/liteos_m/liteos_common_include/soc.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +#ifndef _SOC_H +#define _SOC_H +#include "soc_common.h" + +/* + * Get the response interrupt number via mcause. + * id = mcause & MCAUSE_INT_ID_MASK + */ +#define MCAUSE_INT_ID_MASK 0x7FFFFFF +#define MTIMERCMP 0xE6000008 +#define MTIMER 0xE6000000 + +#define RISCV_SYS_MAX_IRQ 11 + +/* + * Because of strange implementation of los_interrupt.c in kernel sum of + * (RISCV_SYS_MAX_IRQ + RISCV_PLIC_VECTOR_CNT) should be at least 25 + */ +#define RISCV_PLIC_VECTOR_CNT 14 + +#endif diff --git a/drivers/BUILD.gn b/drivers/BUILD.gn new file mode 100755 index 0000000..bedf31c --- /dev/null +++ b/drivers/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (ohos_kernel_type == "liteos_m") { + import("//kernel/liteos_m/liteos.gni") + module_name = get_path_info(rebase_path("."), "name") + kernel_module(module_name) { + } +} diff --git a/hcs/BUILD.gn b/hcs/BUILD.gn new file mode 100755 index 0000000..9e7866c --- /dev/null +++ b/hcs/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (ohos_kernel_type == "liteos_m") { + import("//drivers/adapter/khdf/liteos_m/hdf.gni") + module_name = get_path_info(rebase_path("."), "name") + hdf_driver(module_name) { + hcs_sources = [ "b91_devkit.hcs" ] + visibility += [ + "$device_path", + ".", + ] + } +} diff --git a/hcs/b91_devkit.hcs b/hcs/b91_devkit.hcs new file mode 100755 index 0000000..66c4610 --- /dev/null +++ b/hcs/b91_devkit.hcs @@ -0,0 +1,19 @@ +/****************************************************************************** + * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *****************************************************************************/ + +#include "../../../soc/telink/b91/hcs/hdf.hcs"