Compare commits
62 Commits
v2.7.3
...
v2.6-branc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a814fc0fd | ||
|
|
69f162f6c9 | ||
|
|
86cd2c84c3 | ||
|
|
b590a4f64a | ||
|
|
05d334baa0 | ||
|
|
c388f1a17e | ||
|
|
42cd204d3a | ||
|
|
707162ce93 | ||
|
|
42d7e71206 | ||
|
|
2d6322d74a | ||
|
|
25771e6928 | ||
|
|
92e36185e8 | ||
|
|
68d33e3834 | ||
|
|
7f3abab9bf | ||
|
|
533dcaf374 | ||
|
|
ea55ebfa74 | ||
|
|
95bb8841b8 | ||
|
|
1f8c53dfaf | ||
|
|
7bb7454a00 | ||
|
|
25fd176014 | ||
|
|
e1cde092ac | ||
|
|
244049bd71 | ||
|
|
5dae0c1bf0 | ||
|
|
5666e4d525 | ||
|
|
91a78866ca | ||
|
|
0afddb2341 | ||
|
|
9bcf9b6a53 | ||
|
|
2595cce714 | ||
|
|
18d314e750 | ||
|
|
c8755e0b46 | ||
|
|
a4d35f0a3e | ||
|
|
7094aaee55 | ||
|
|
585c03a0b6 | ||
|
|
cacb0a4e59 | ||
|
|
78ab750540 | ||
|
|
d9df404d47 | ||
|
|
8e80955511 | ||
|
|
99dc33faaf | ||
|
|
02fbe652a5 | ||
|
|
80b406d784 | ||
|
|
837ab4a915 | ||
|
|
0943608550 | ||
|
|
3c56e0df0b | ||
|
|
b0cb7412b9 | ||
|
|
80e1b785dc | ||
|
|
e72a327107 | ||
|
|
1cf1d75d3f | ||
|
|
e43afd10f7 | ||
|
|
6d9b318dca | ||
|
|
d4d362d081 | ||
|
|
d0dca15734 | ||
|
|
218e438f3e | ||
|
|
f66d0cea06 | ||
|
|
d5a1a22b1a | ||
|
|
c77f8fae83 | ||
|
|
3ec1caa504 | ||
|
|
a221f358eb | ||
|
|
f5a6110b4a | ||
|
|
1d6106fd5e | ||
|
|
4b87e90167 | ||
|
|
1d4d16b748 | ||
|
|
4a564cdef0 |
29
.github/workflows/bsim-publish.yaml
vendored
Normal file
29
.github/workflows/bsim-publish.yaml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Publish Bluetooth Tests Results
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Bluetooth Tests"]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
bluetooth-test-results:
|
||||
name: "Publish Bluetooth Test Results"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.conclusion != 'skipped'
|
||||
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: bluetooth-tests.yaml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- name: Publish Bluetooth Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
||||
with:
|
||||
check_name: Bluetooth Test Results
|
||||
comment_mode: off
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
event_file: event/event.json
|
||||
event_name: ${{ github.event.workflow_run.event }}
|
||||
files: "bluetooth-test-results/**/bsim_results.xml"
|
||||
32
.github/workflows/bsim.yaml
vendored
32
.github/workflows/bsim.yaml
vendored
@@ -1,7 +1,7 @@
|
||||
name: Bluetooth Tests
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
paths:
|
||||
- "west.yml"
|
||||
- "subsys/bluetooth/**"
|
||||
@@ -39,9 +39,6 @@ jobs:
|
||||
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: west setup
|
||||
run: |
|
||||
@@ -60,26 +57,13 @@ jobs:
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Bluetooth Test Results
|
||||
name: bluetooth-test-results
|
||||
path: ./bsim_bt_out/bsim_results.xml
|
||||
|
||||
publish-test-results:
|
||||
name: "Publish Unit Tests Results"
|
||||
needs: bsim-build
|
||||
runs-on: ubuntu-20.04
|
||||
# the build-and-test job might be skipped, we don't need to run this job then
|
||||
if: success() || failure()
|
||||
|
||||
steps:
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
- name: Upload Event Details
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Publish Unit Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v1.12
|
||||
with:
|
||||
check_name: Bluetooth Test Results
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: "**/bsim_results.xml"
|
||||
comment_on_pr: false
|
||||
name: event
|
||||
path: |
|
||||
${{ github.event_path }}
|
||||
|
||||
1
.github/workflows/clang.yaml
vendored
1
.github/workflows/clang.yaml
vendored
@@ -38,6 +38,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: west setup
|
||||
run: |
|
||||
|
||||
1
.github/workflows/manifest.yml
vendored
1
.github/workflows/manifest.yml
vendored
@@ -15,6 +15,7 @@ jobs:
|
||||
path: zephyrproject/zephyr
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Manifest
|
||||
uses: zephyrproject-rtos/action-manifest@v1.1.0
|
||||
|
||||
3
VERSION
3
VERSION
@@ -1,4 +1,5 @@
|
||||
VERSION_MAJOR = 2
|
||||
VERSION_MINOR = 6
|
||||
PATCHLEVEL = 0
|
||||
PATCHLEVEL = 1
|
||||
VERSION_TWEAK = 0
|
||||
EXTRAVERSION = rc2
|
||||
|
||||
@@ -252,6 +252,7 @@ config CODE_DENSITY
|
||||
|
||||
config ARC_HAS_ACCL_REGS
|
||||
bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)"
|
||||
default y if CPU_HS3X
|
||||
default y if FPU
|
||||
help
|
||||
Depending on the configuration, CPU can contain accumulator reg-pair
|
||||
|
||||
@@ -170,4 +170,12 @@ config X86_USE_THREAD_LOCAL_STORAGE
|
||||
help
|
||||
Internal config to enable thread local storage.
|
||||
|
||||
config X86_MFENCE_INSTRUCTION_SUPPORTED
|
||||
bool "X86 MFENCE instruction supported"
|
||||
default y
|
||||
depends on CACHE_MANAGEMENT
|
||||
help
|
||||
Set n to disable the use of MFENCE instruction in arch_dcache_flush()
|
||||
for X86 CPUs have CLFLUSH instruction but no MFENCE
|
||||
|
||||
endif # !X86_64
|
||||
|
||||
@@ -50,8 +50,11 @@ static void find_rsdp(void)
|
||||
bda_seg = 0x040e + zero_page_base;
|
||||
uint64_t *search = (void *)(long)(((int)*(uint16_t *)bda_seg) << 4);
|
||||
|
||||
/* Might be nothing there, check before we inspect */
|
||||
if (search != NULL) {
|
||||
/* Might be nothing there, check before we inspect.
|
||||
* Note that EBDA usually is in 0x80000 to 0x100000.
|
||||
*/
|
||||
if ((POINTER_TO_UINT(search) >= 0x80000UL) &&
|
||||
(POINTER_TO_UINT(search) < 0x100000UL)) {
|
||||
for (int i = 0; i < 1024/8; i++) {
|
||||
if (search[i] == ACPI_RSDP_SIGNATURE) {
|
||||
rsdp = (void *)&search[i];
|
||||
|
||||
@@ -33,20 +33,24 @@ static void arch_dcache_flush(void *start_addr, size_t size)
|
||||
{
|
||||
size_t line_size = sys_cache_data_line_size_get();
|
||||
uintptr_t start = (uintptr_t)start_addr;
|
||||
uintptr_t end;
|
||||
uintptr_t end = start + size;
|
||||
|
||||
if (line_size == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
size = ROUND_UP(size, line_size);
|
||||
end = start + size;
|
||||
end = ROUND_UP(end, line_size);
|
||||
|
||||
for (; start < end; start += line_size) {
|
||||
__asm__ volatile("clflush %0;\n\t" : : "m"(start));
|
||||
__asm__ volatile("clflush %0;\n\t" :
|
||||
"+m"(*(volatile char *)start));
|
||||
}
|
||||
|
||||
__asm__ volatile("mfence;\n\t");
|
||||
#if defined(CONFIG_X86_MFENCE_INSTRUCTION_SUPPORTED)
|
||||
__asm__ volatile("mfence;\n\t":::"memory");
|
||||
#else
|
||||
__asm__ volatile("lock; addl $0,-4(%%esp);\n\t":::"memory", "cc");
|
||||
#endif
|
||||
}
|
||||
|
||||
int arch_dcache_range(void *addr, size_t size, int op)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Copyright (c) 2019 Intel Corp.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
|
||||
# We rely on GAS for assembling, so don't use the integrated assembler
|
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-no-integrated-as>)
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
|
||||
@@ -12,7 +12,8 @@ endif()
|
||||
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "i386")
|
||||
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-i386")
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
|
||||
zephyr_compile_options(-Qunused-arguments)
|
||||
|
||||
zephyr_cc_option(
|
||||
|
||||
@@ -92,6 +92,20 @@ uintptr_t __abi efi_entry(void *img_handle, struct efi_system_table *sys_tab)
|
||||
for (int j = 0; j < bytes; j++) {
|
||||
dst[j] = src[j];
|
||||
}
|
||||
|
||||
/* Page-aligned blocks below 1M are the .locore
|
||||
* section, which has a jump in its first bytes for
|
||||
* the benefit of 32 bit entry. Those have to be
|
||||
* written over with NOP instructions. (See comment
|
||||
* about OUTRAGEOUS HACK in locore.S) before Zephyr
|
||||
* starts, because the very first thing it does is
|
||||
* install its own page table that disallows writes.
|
||||
*/
|
||||
if (((long)dst & 0xfff) == 0 && dst < (uint8_t *)0x100000L) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
dst[i] = 0x90; /* 0x90 == 1-byte NOP */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *code = (void *)zefi_entry;
|
||||
|
||||
@@ -602,6 +602,11 @@ endif()
|
||||
include(${ZEPHYR_BASE}/cmake/target_toolchain.cmake)
|
||||
|
||||
project(Zephyr-Kernel VERSION ${PROJECT_VERSION})
|
||||
|
||||
# Add .S file extension suffix into CMAKE_ASM_SOURCE_FILE_EXTENSIONS,
|
||||
# because clang from OneApi can't recongnize them as asm files on
|
||||
# windows now.
|
||||
list(APPEND CMAKE_ASM_SOURCE_FILE_EXTENSIONS "S")
|
||||
enable_language(C CXX ASM)
|
||||
# The setup / configuration of the toolchain itself and the configuration of
|
||||
# supported compilation flags are now split, as this allows to use the toolchain
|
||||
|
||||
@@ -7,7 +7,10 @@ endif()
|
||||
|
||||
find_program(CMAKE_AR llvm-ar ${find_program_clang_args} )
|
||||
find_program(CMAKE_NM llvm-nm ${find_program_clang_args} )
|
||||
find_program(CMAKE_OBJDUMP llvm-objdump ${find_program_clang_args} )
|
||||
# In OneApi installation directory on Windows, there is no llvm-objdump
|
||||
# binary, so would better use objdump from system environment both
|
||||
# on Linux and Windows.
|
||||
find_program(CMAKE_OBJDUMP objdump ${find_program_binutils_args})
|
||||
find_program(CMAKE_RANLIB llvm-ranlib ${find_program_clang_args} )
|
||||
find_program(CMAKE_OBJCOPY llvm-objcopy ${find_program_binutils_args})
|
||||
find_program(CMAKE_READELF readelf ${find_program_binutils_args})
|
||||
|
||||
@@ -69,7 +69,7 @@ if(NOT "${ARCH}" STREQUAL "posix")
|
||||
list(APPEND TOOLCHAIN_LIBS gcc)
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
|
||||
list(APPEND CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
|
||||
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
||||
|
||||
endif()
|
||||
|
||||
@@ -167,6 +167,10 @@ set_compiler_property(PROPERTY freestanding -ffreestanding)
|
||||
# Flag to enable debugging
|
||||
set_compiler_property(PROPERTY debug -g)
|
||||
|
||||
# GCC 11 by default emits DWARF version 5 which cannot be parsed by
|
||||
# pyelftools. Can be removed once pyelftools supports v5.
|
||||
check_set_compiler_property(APPEND PROPERTY debug -gdwarf-4)
|
||||
|
||||
set_compiler_property(PROPERTY no_common -fno-common)
|
||||
|
||||
# GCC compiler flags for imacros. The specific header must be appended by user.
|
||||
|
||||
@@ -61,23 +61,21 @@ elseif("${ARCH}" STREQUAL "sparc")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/target_sparc.cmake)
|
||||
endif()
|
||||
|
||||
if(NOT no_libgcc)
|
||||
# This libgcc code is partially duplicated in compiler/*/target.cmake
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
|
||||
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
# This libgcc code is partially duplicated in compiler/*/target.cmake
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
|
||||
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
assert_exists(LIBGCC_FILE_NAME)
|
||||
assert_exists(LIBGCC_FILE_NAME)
|
||||
|
||||
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
|
||||
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
|
||||
|
||||
assert_exists(LIBGCC_DIR)
|
||||
assert_exists(LIBGCC_DIR)
|
||||
|
||||
LIST(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
|
||||
LIST(APPEND TOOLCHAIN_LIBS gcc)
|
||||
endif()
|
||||
LIST(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
|
||||
LIST(APPEND TOOLCHAIN_LIBS gcc)
|
||||
|
||||
if(SYSROOT_DIR)
|
||||
# The toolchain has specified a sysroot dir that we can use to set
|
||||
|
||||
@@ -18,21 +18,6 @@ else()
|
||||
endif()
|
||||
find_program(CMAKE_CXX_COMPILER ${cplusplus_compiler} CACHE INTERNAL " " FORCE)
|
||||
|
||||
# The x32 version of libgcc is usually not available (can't trust gcc
|
||||
# -mx32 --print-libgcc-file-name) so don't fail to build for something
|
||||
# that is currently not needed. See comments in compiler/gcc/target.cmake
|
||||
if (CONFIG_X86)
|
||||
# Convert to list as cmake Modules/*.cmake do it
|
||||
STRING(REGEX REPLACE " +" ";" PRINT_LIBGCC_ARGS "${CMAKE_C_FLAGS}")
|
||||
# This libgcc code is partially duplicated in compiler/*/target.cmake
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} "${PRINT_LIBGCC_ARGS}" --print-libgcc-file-name
|
||||
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
assert_exists(LIBGCC_FILE_NAME)
|
||||
endif()
|
||||
|
||||
set(NOSTDINC "")
|
||||
|
||||
# Note that NOSYSDEF_CFLAG may be an empty string, and
|
||||
|
||||
@@ -13,14 +13,16 @@ endif()
|
||||
|
||||
set_ifndef(LINKERFLAGPREFIX -Wl)
|
||||
|
||||
if(CONFIG_EXCEPTIONS)
|
||||
# When building with C++ Exceptions, it is important that crtbegin and crtend
|
||||
# are linked at specific locations.
|
||||
# The location is so important that we cannot let this be controlled by normal
|
||||
# link libraries, instead we must control the link command specifically as
|
||||
# part of toolchain.
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE
|
||||
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${LIBGCC_DIR}/crtbegin.o <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${LIBGCC_DIR}/crtend.o")
|
||||
if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "host")
|
||||
if(CONFIG_EXCEPTIONS)
|
||||
# When building with C++ Exceptions, it is important that crtbegin and crtend
|
||||
# are linked at specific locations.
|
||||
# The location is so important that we cannot let this be controlled by normal
|
||||
# link libraries, instead we must control the link command specifically as
|
||||
# part of toolchain.
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE
|
||||
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${LIBGCC_DIR}/crtbegin.o <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${LIBGCC_DIR}/crtend.o")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Run $LINKER_SCRIPT file through the C preprocessor, producing ${linker_script_gen}
|
||||
|
||||
@@ -6,14 +6,15 @@ else()
|
||||
set_ifndef(ONEAPI_TOOLCHAIN_PATH "$ENV{ONEAPI_TOOLCHAIN_PATH}")
|
||||
endif()
|
||||
|
||||
# the default oneApi installation path is related to os
|
||||
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} system)
|
||||
if(ONEAPI_TOOLCHAIN_PATH)
|
||||
set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/linux/bin/)
|
||||
set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/${system}/bin/)
|
||||
set(ONEAPI_PYTHON_PATH ${ONEAPI_TOOLCHAIN_PATH}/intelpython/latest/bin)
|
||||
endif()
|
||||
|
||||
set(ONEAPI_TOOLCHAIN_PATH ${ONEAPI_TOOLCHAIN_PATH} CACHE PATH "oneApi install directory")
|
||||
|
||||
set(COMPILER icx)
|
||||
set(LINKER lld)
|
||||
set(BINTOOLS oneApi)
|
||||
|
||||
@@ -23,8 +24,23 @@ else()
|
||||
set(triple i686-pc-none-elf)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
if(system STREQUAL "linux")
|
||||
set(COMPILER icx)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
|
||||
# icx compiler of oneApi will invoke clang-cl on windows,
|
||||
# this is not supported in zephyr now, so change to use
|
||||
# clang directly.
|
||||
# and the clang from oneApi can't recognize those cross
|
||||
# compiling target variables of cmake, so used other
|
||||
# cmake functions to pass them to clang.
|
||||
elseif(system STREQUAL "windows")
|
||||
set(COMPILER clang)
|
||||
list(APPEND CMAKE_REQUIRED_FLAGS --target=${triple})
|
||||
add_compile_options(--target=${triple})
|
||||
add_link_options(--target=${triple})
|
||||
endif()
|
||||
|
||||
message(STATUS "Found toolchain: host (clang/ld)")
|
||||
|
||||
@@ -1013,6 +1013,8 @@ gpio_dt_spec``, then use it like this:
|
||||
|
||||
#include <drivers/gpio.h>
|
||||
|
||||
#define ZEPHYR_USER_NODE DT_PATH(zephyr_user)
|
||||
|
||||
const struct gpio_dt_spec signal =
|
||||
GPIO_DT_SPEC_GET(ZEPHYR_USER_NODE, signal_gpios);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ current :ref:`stability level <api_lifecycle>`.
|
||||
* - :ref:`devicetree_api`
|
||||
- Experimental
|
||||
- 2.2
|
||||
- 2.4
|
||||
- 2.6
|
||||
|
||||
* - :ref:`disk_access_api`
|
||||
- Stable
|
||||
|
||||
@@ -2,6 +2,29 @@
|
||||
|
||||
.. _zephyr_2.6:
|
||||
|
||||
|
||||
.. _zephyr_2.6.1:
|
||||
|
||||
Zephyr 2.6.1
|
||||
#############
|
||||
|
||||
This is a maintenance release with the following fixes.
|
||||
|
||||
Security Vulnerability Related
|
||||
******************************
|
||||
|
||||
The following security vulnerabilities (CVEs) were addressed in this
|
||||
release:
|
||||
|
||||
More detailed information can be found in:
|
||||
https://docs.zephyrproject.org/latest/security/vulnerabilities.html
|
||||
|
||||
Issues Fixed
|
||||
************
|
||||
|
||||
|
||||
.. _zephyr_2.6.0:
|
||||
|
||||
Zephyr 2.6.0
|
||||
############
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <bluetooth/hci.h>
|
||||
#include <drivers/bluetooth/hci_driver.h>
|
||||
#include "bluetooth/addr.h"
|
||||
#include <drivers/clock_control/stm32_clock_control.h>
|
||||
|
||||
#include "app_conf.h"
|
||||
#include "stm32_wpan_common.h"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#define RCC_CALC_FLASH_FREQ __LL_RCC_CALC_HCLK3_FREQ
|
||||
#define GET_CURRENT_FLASH_PRESCALER LL_RCC_GetAHB3Prescaler
|
||||
#else
|
||||
#define RCC_CALC_FLASH_FREQ __LL_RCC_CALC_HCLK1_FREQ
|
||||
#define RCC_CALC_FLASH_FREQ __LL_RCC_CALC_HCLK_FREQ
|
||||
#define GET_CURRENT_FLASH_PRESCALER LL_RCC_GetAHBPrescaler
|
||||
#endif
|
||||
|
||||
|
||||
@@ -48,6 +48,11 @@ void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
|
||||
*/
|
||||
void config_enable_default_clocks(void)
|
||||
{
|
||||
#ifdef LL_APB1_GRP1_PERIPH_PWR
|
||||
/* Enable the power interface clock */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
||||
#endif
|
||||
|
||||
#if STM32_LSE_CLOCK
|
||||
/* LSE belongs to the back-up domain, enable access.*/
|
||||
|
||||
@@ -57,11 +62,6 @@ void config_enable_default_clocks(void)
|
||||
#endif
|
||||
z_stm32_hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
|
||||
|
||||
#ifdef LL_APB1_GRP1_PERIPH_PWR
|
||||
/* Enable the power interface clock */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
||||
#endif
|
||||
|
||||
/* Set the DBP bit in the Power control register 1 (PWR_CR1) */
|
||||
LL_PWR_EnableBkUpAccess();
|
||||
while (!LL_PWR_IsEnabledBkUpAccess()) {
|
||||
|
||||
@@ -415,7 +415,7 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
||||
|
||||
switch (ctrl_command) {
|
||||
case DEVICE_PM_SET_POWER_STATE:
|
||||
case PM_DEVICE_STATE_SET:
|
||||
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||
st7789v_exit_sleep(data);
|
||||
data->pm_state = PM_DEVICE_STATE_ACTIVE;
|
||||
|
||||
@@ -210,11 +210,13 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
|
||||
const void *data, unsigned int len)
|
||||
{
|
||||
int i, rc = 0;
|
||||
const flash_prg_t *values = (const flash_prg_t *)data;
|
||||
flash_prg_t value;
|
||||
|
||||
for (i = 0; i < len / sizeof(flash_prg_t); i++) {
|
||||
rc = write_value(dev, offset + i * sizeof(flash_prg_t),
|
||||
values[i]);
|
||||
memcpy(&value,
|
||||
(const uint8_t *)data + i * sizeof(flash_prg_t),
|
||||
sizeof(flash_prg_t));
|
||||
rc = write_value(dev, offset + i * sizeof(flash_prg_t), value);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
#include <errno.h>
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <sys/sys_io.h>
|
||||
#include <soc.h>
|
||||
|
||||
#include "gpio_utils.h"
|
||||
|
||||
#define XEC_GPIO_EDGE_DLY_COUNT 4
|
||||
|
||||
#define GPIO_IN_BASE(config) \
|
||||
((__IO uint32_t *)(GPIO_PARIN_BASE + (config->port_num << 2)))
|
||||
|
||||
@@ -211,6 +214,10 @@ static int gpio_xec_pin_interrupt_configure(const struct device *dev,
|
||||
*/
|
||||
current_pcr1 = config->pcr1_base + pin;
|
||||
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
|
||||
/* delay for HW to synchronize after it ungates its clock */
|
||||
for (int i = 0; i < XEC_GPIO_EDGE_DLY_COUNT; i++) {
|
||||
(void)*current_pcr1;
|
||||
}
|
||||
|
||||
if (mode != GPIO_INT_MODE_DISABLED) {
|
||||
/* We enable the interrupts in the EC aggregator so that the
|
||||
|
||||
@@ -82,7 +82,7 @@ config HPET_TIMER
|
||||
depends on X86
|
||||
select IOAPIC if X86
|
||||
select LOAPIC if X86
|
||||
select TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
|
||||
imply TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
|
||||
select TICKLESS_CAPABLE
|
||||
help
|
||||
This option selects High Precision Event Timer (HPET) as a
|
||||
|
||||
@@ -13,40 +13,233 @@
|
||||
|
||||
#include <dt-bindings/interrupt-controller/intel-ioapic.h>
|
||||
|
||||
#include <soc.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief HPET (High Precision Event Timers) driver
|
||||
*
|
||||
* HPET hardware contains a number of timers which can be used by
|
||||
* the operating system, where the number of timers is implementation
|
||||
* specific. The timers are implemented as a single up-counter with
|
||||
* a set of comparators where the counter increases monotonically.
|
||||
* Each timer has a match register and a comparator, and can generate
|
||||
* an interrupt when the value in the match register equals the value of
|
||||
* the free running counter. Some of these timers can be enabled to
|
||||
* generate periodic interrupt.
|
||||
*
|
||||
* The HPET registers are usually mapped to memory space on x86
|
||||
* hardware. If this is not the case, custom register access functions
|
||||
* can be used by defining macro HPET_USE_CUSTOM_REG_ACCESS_FUNCS in
|
||||
* soc.h, and implementing necessary initialization and access
|
||||
* functions as described below.
|
||||
*
|
||||
* HPET_COUNTER_CLK_PERIOD can be overridden in soc.h if
|
||||
* COUNTER_CLK_PERIOD is not in femtoseconds (1e-15 sec).
|
||||
*
|
||||
* HPET_CMP_MIN_DELAY can be overridden in soc.h to better match
|
||||
* the frequency of the timers. Default is 1000 where the value
|
||||
* written to the comparator must be 1000 larger than the current
|
||||
* main counter value.
|
||||
*/
|
||||
|
||||
/* General Configuration register */
|
||||
#define GCONF_ENABLE BIT(0)
|
||||
#define GCONF_LR BIT(1) /* legacy interrupt routing, */
|
||||
/* disables PIT */
|
||||
|
||||
/* General Interrupt Status register */
|
||||
#define TIMER0_INT_STS BIT(0)
|
||||
|
||||
/* Timer Configuration and Capabilities register */
|
||||
#define TIMER_CONF_INT_LEVEL BIT(1)
|
||||
#define TIMER_CONF_INT_ENABLE BIT(2)
|
||||
#define TIMER_CONF_PERIODIC BIT(3)
|
||||
#define TIMER_CONF_VAL_SET BIT(6)
|
||||
#define TIMER_CONF_MODE32 BIT(8)
|
||||
#define TIMER_CONF_FSB_EN BIT(14) /* FSB interrupt delivery */
|
||||
/* enable */
|
||||
|
||||
/*
|
||||
* The following MMIO initialization and register access functions
|
||||
* should work on generic x86 hardware. If the targeted SoC requires
|
||||
* special handling of HPET registers, these functions will need to be
|
||||
* implemented in the SoC layer by first defining the macro
|
||||
* HPET_USE_CUSTOM_REG_ACCESS_FUNCS in soc.h to signal such intent.
|
||||
*
|
||||
* This is a list of functions which must be implemented in the SoC
|
||||
* layer:
|
||||
* void hpet_mmio_init(void)
|
||||
* uint32_t hpet_counter_get(void)
|
||||
* uint32_t hpet_counter_clk_period_get(void)
|
||||
* uint32_t hpet_gconf_get(void)
|
||||
* void hpet_gconf_set(uint32_t val)
|
||||
* void hpet_int_sts_set(uint32_t val)
|
||||
* uint32_t hpet_timer_conf_get(void)
|
||||
* void hpet_timer_conf_set(uint32_t val)
|
||||
* void hpet_timer_comparator_set(uint32_t val)
|
||||
*/
|
||||
#ifndef HPET_USE_CUSTOM_REG_ACCESS_FUNCS
|
||||
DEVICE_MMIO_TOPLEVEL_STATIC(hpet_regs, DT_DRV_INST(0));
|
||||
|
||||
#define HPET_REG32(off) (*(volatile uint32_t *)(long) \
|
||||
(DEVICE_MMIO_TOPLEVEL_GET(hpet_regs) + (off)))
|
||||
#define HPET_REG_ADDR(off) \
|
||||
((mm_reg_t)(DEVICE_MMIO_TOPLEVEL_GET(hpet_regs) + (off)))
|
||||
|
||||
#define CLK_PERIOD_REG HPET_REG32(0x04) /* High dword of caps reg */
|
||||
#define GENERAL_CONF_REG HPET_REG32(0x10)
|
||||
#define INTR_STATUS_REG HPET_REG32(0x20)
|
||||
#define MAIN_COUNTER_REG HPET_REG32(0xf0)
|
||||
#define TIMER0_CONF_REG HPET_REG32(0x100)
|
||||
#define TIMER0_COMPARATOR_REG HPET_REG32(0x108)
|
||||
/* High dword of General Capabilities and ID register */
|
||||
#define CLK_PERIOD_REG HPET_REG_ADDR(0x04)
|
||||
|
||||
/* GENERAL_CONF_REG bits */
|
||||
#define GCONF_ENABLE BIT(0)
|
||||
#define GCONF_LR BIT(1) /* legacy interrupt routing, disables PIT */
|
||||
/* General Configuration register */
|
||||
#define GCONF_REG HPET_REG_ADDR(0x10)
|
||||
|
||||
/* INTR_STATUS_REG bits */
|
||||
#define TIMER0_INT_STS BIT(0)
|
||||
/* General Interrupt Status register */
|
||||
#define INTR_STATUS_REG HPET_REG_ADDR(0x20)
|
||||
|
||||
/* TIMERn_CONF_REG bits */
|
||||
#define TCONF_INT_LEVEL BIT(1)
|
||||
#define TCONF_INT_ENABLE BIT(2)
|
||||
#define TCONF_PERIODIC BIT(3)
|
||||
#define TCONF_VAL_SET BIT(6)
|
||||
#define TCONF_MODE32 BIT(8)
|
||||
#define TCONF_FSB_EN BIT(14) /* FSB interrupt delivery enable */
|
||||
/* Main Counter Register */
|
||||
#define MAIN_COUNTER_REG HPET_REG_ADDR(0xf0)
|
||||
|
||||
#define MIN_DELAY 1000
|
||||
/* Timer 0 Configuration and Capabilities register */
|
||||
#define TIMER0_CONF_REG HPET_REG_ADDR(0x100)
|
||||
|
||||
/* Timer 0 Comparator Register */
|
||||
#define TIMER0_COMPARATOR_REG HPET_REG_ADDR(0x108)
|
||||
|
||||
/**
|
||||
* @brief Setup memory mappings needed to access HPET registers.
|
||||
*
|
||||
* This is called in sys_clock_driver_init() to setup any memory
|
||||
* mappings needed to access HPET registers.
|
||||
*/
|
||||
static inline void hpet_mmio_init(void)
|
||||
{
|
||||
DEVICE_MMIO_TOPLEVEL_MAP(hpet_regs, K_MEM_CACHE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the value of the main counter.
|
||||
*
|
||||
* @return Value of Main Counter
|
||||
*/
|
||||
static inline uint32_t hpet_counter_get(void)
|
||||
{
|
||||
return sys_read32(MAIN_COUNTER_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get COUNTER_CLK_PERIOD
|
||||
*
|
||||
* Read and return the COUNTER_CLK_PERIOD, which is the high
|
||||
* 32-bit of the General Capabilities and ID Register. This can
|
||||
* be used to calculate the frequency of the main counter.
|
||||
*
|
||||
* Usually the period is in femtoseconds. If this is not
|
||||
* the case, define HPET_COUNTER_CLK_PERIOD in soc.h so
|
||||
* it can be used to calculate frequency.
|
||||
*
|
||||
* @return COUNTER_CLK_PERIOD
|
||||
*/
|
||||
static inline uint32_t hpet_counter_clk_period_get(void)
|
||||
{
|
||||
return sys_read32(CLK_PERIOD_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the value of the General Configuration Register
|
||||
*
|
||||
* @return Value of the General Configuration Register
|
||||
*/
|
||||
static inline uint32_t hpet_gconf_get(void)
|
||||
{
|
||||
return sys_read32(GCONF_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write to General Configuration Register
|
||||
*
|
||||
* @param val Value to be written to the register
|
||||
*/
|
||||
static inline void hpet_gconf_set(uint32_t val)
|
||||
{
|
||||
sys_write32(val, GCONF_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write to General Interrupt Status Register
|
||||
*
|
||||
* This is used to acknowledge and clear interrupt bits.
|
||||
*
|
||||
* @param val Value to be written to the register
|
||||
*/
|
||||
static inline void hpet_int_sts_set(uint32_t val)
|
||||
{
|
||||
sys_write32(val, INTR_STATUS_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the value of the Timer Configuration Register
|
||||
*
|
||||
* This reads and returns the value of the Timer Configuration
|
||||
* Register of Timer #0.
|
||||
*
|
||||
* @return Value of the Timer Configuration Register
|
||||
*/
|
||||
static inline uint32_t hpet_timer_conf_get(void)
|
||||
{
|
||||
return sys_read32(TIMER0_CONF_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write to the Timer Configuration Register
|
||||
*
|
||||
* This writes the specified value to the Timer Configuration
|
||||
* Register of Timer #0.
|
||||
*
|
||||
* @param val Value to be written to the register
|
||||
*/
|
||||
static inline void hpet_timer_conf_set(uint32_t val)
|
||||
{
|
||||
sys_write32(val, TIMER0_CONF_REG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write to the Timer Comparator Value Register
|
||||
*
|
||||
* This writes the specified value to the Timer Comparator
|
||||
* Value Register of Timer #0.
|
||||
*
|
||||
* @param val Value to be written to the register
|
||||
*/
|
||||
static inline void hpet_timer_comparator_set(uint32_t val)
|
||||
{
|
||||
sys_write32(val, TIMER0_COMPARATOR_REG);
|
||||
}
|
||||
#endif /* HPET_USE_CUSTOM_REG_ACCESS_FUNCS */
|
||||
|
||||
#ifndef HPET_COUNTER_CLK_PERIOD
|
||||
/* COUNTER_CLK_PERIOD (CLK_PERIOD_REG) is in femtoseconds (1e-15 sec) */
|
||||
#define HPET_COUNTER_CLK_PERIOD (1000000000000000ULL)
|
||||
#endif
|
||||
|
||||
#ifndef HPET_CMP_MIN_DELAY
|
||||
/* Minimal delay for comparator before the next timer event */
|
||||
#define HPET_CMP_MIN_DELAY (1000)
|
||||
#endif
|
||||
|
||||
#define MAX_TICKS 0x7FFFFFFFUL
|
||||
|
||||
static __pinned_bss struct k_spinlock lock;
|
||||
static __pinned_bss unsigned int max_ticks;
|
||||
static __pinned_bss unsigned int cyc_per_tick;
|
||||
static __pinned_bss unsigned int last_count;
|
||||
|
||||
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
|
||||
static __pinned_bss unsigned int cyc_per_tick;
|
||||
static __pinned_bss unsigned int max_ticks;
|
||||
#else
|
||||
#define cyc_per_tick \
|
||||
(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC)
|
||||
|
||||
#define max_ticks \
|
||||
((MAX_TICKS - cyc_per_tick) / cyc_per_tick)
|
||||
#endif /* CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME */
|
||||
|
||||
__isr
|
||||
static void hpet_isr(const void *arg)
|
||||
{
|
||||
@@ -54,7 +247,7 @@ static void hpet_isr(const void *arg)
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
|
||||
uint32_t now = MAIN_COUNTER_REG;
|
||||
uint32_t now = hpet_counter_get();
|
||||
|
||||
#if ((DT_INST_IRQ(0, sense) & IRQ_TYPE_LEVEL) == IRQ_TYPE_LEVEL)
|
||||
/*
|
||||
@@ -62,7 +255,7 @@ static void hpet_isr(const void *arg)
|
||||
* When edge trigger is selected, spec says only 0 can
|
||||
* be written.
|
||||
*/
|
||||
INTR_STATUS_REG = TIMER0_INT_STS;
|
||||
hpet_int_sts_set(TIMER0_INT_STS);
|
||||
#endif
|
||||
|
||||
if (IS_ENABLED(CONFIG_SMP) &&
|
||||
@@ -85,10 +278,10 @@ static void hpet_isr(const void *arg)
|
||||
if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) {
|
||||
uint32_t next = last_count + cyc_per_tick;
|
||||
|
||||
if ((int32_t)(next - now) < MIN_DELAY) {
|
||||
if ((int32_t)(next - now) < HPET_CMP_MIN_DELAY) {
|
||||
next += cyc_per_tick;
|
||||
}
|
||||
TIMER0_COMPARATOR_REG = next;
|
||||
hpet_timer_comparator_set(next);
|
||||
}
|
||||
|
||||
k_spin_unlock(&lock, key);
|
||||
@@ -98,26 +291,30 @@ static void hpet_isr(const void *arg)
|
||||
__pinned_func
|
||||
static void set_timer0_irq(unsigned int irq)
|
||||
{
|
||||
uint32_t val = hpet_timer_conf_get();
|
||||
|
||||
/* 5-bit IRQ field starting at bit 9 */
|
||||
uint32_t val = (TIMER0_CONF_REG & ~(0x1f << 9)) | ((irq & 0x1f) << 9);
|
||||
val = (val & ~(0x1f << 9)) | ((irq & 0x1f) << 9);
|
||||
|
||||
#if ((DT_INST_IRQ(0, sense) & IRQ_TYPE_LEVEL) == IRQ_TYPE_LEVEL)
|
||||
/* Level trigger */
|
||||
val |= TCONF_INT_LEVEL;
|
||||
val |= TIMER_CONF_INT_LEVEL;
|
||||
#endif
|
||||
|
||||
TIMER0_CONF_REG = val;
|
||||
hpet_timer_conf_set(val);
|
||||
}
|
||||
|
||||
__boot_func
|
||||
int sys_clock_driver_init(const struct device *dev)
|
||||
{
|
||||
extern int z_clock_hw_cycles_per_sec;
|
||||
uint32_t hz;
|
||||
uint32_t hz, reg;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
ARG_UNUSED(hz);
|
||||
ARG_UNUSED(z_clock_hw_cycles_per_sec);
|
||||
|
||||
DEVICE_MMIO_TOPLEVEL_MAP(hpet_regs, K_MEM_CACHE_NONE);
|
||||
hpet_mmio_init();
|
||||
|
||||
IRQ_CONNECT(DT_INST_IRQN(0),
|
||||
DT_INST_IRQ(0, priority),
|
||||
@@ -125,27 +322,34 @@ int sys_clock_driver_init(const struct device *dev)
|
||||
set_timer0_irq(DT_INST_IRQN(0));
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
|
||||
/* CLK_PERIOD_REG is in femtoseconds (1e-15 sec) */
|
||||
hz = (uint32_t)(1000000000000000ULL / CLK_PERIOD_REG);
|
||||
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
|
||||
hz = (uint32_t)(HPET_COUNTER_CLK_PERIOD / hpet_counter_clk_period_get());
|
||||
z_clock_hw_cycles_per_sec = hz;
|
||||
cyc_per_tick = hz / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
|
||||
|
||||
max_ticks = (MAX_TICKS - cyc_per_tick) / cyc_per_tick;
|
||||
#endif
|
||||
|
||||
last_count = hpet_counter_get();
|
||||
|
||||
/* Note: we set the legacy routing bit, because otherwise
|
||||
* nothing in Zephyr disables the PIT which then fires
|
||||
* interrupts into the same IRQ. But that means we're then
|
||||
* forced to use IRQ2 contra the way the kconfig IRQ selection
|
||||
* is supposed to work. Should fix this.
|
||||
*/
|
||||
GENERAL_CONF_REG |= GCONF_LR | GCONF_ENABLE;
|
||||
TIMER0_CONF_REG &= ~TCONF_PERIODIC;
|
||||
TIMER0_CONF_REG &= ~TCONF_FSB_EN;
|
||||
TIMER0_CONF_REG |= TCONF_MODE32;
|
||||
reg = hpet_gconf_get();
|
||||
reg |= GCONF_LR | GCONF_ENABLE;
|
||||
hpet_gconf_set(reg);
|
||||
|
||||
max_ticks = (0x7fffffff - cyc_per_tick) / cyc_per_tick;
|
||||
last_count = MAIN_COUNTER_REG;
|
||||
reg = hpet_timer_conf_get();
|
||||
reg &= ~TIMER_CONF_PERIODIC;
|
||||
reg &= ~TIMER_CONF_FSB_EN;
|
||||
reg |= TIMER_CONF_MODE32;
|
||||
reg |= TIMER_CONF_INT_ENABLE;
|
||||
hpet_timer_conf_set(reg);
|
||||
|
||||
TIMER0_CONF_REG |= TCONF_INT_ENABLE;
|
||||
TIMER0_COMPARATOR_REG = MAIN_COUNTER_REG + cyc_per_tick;
|
||||
hpet_timer_comparator_set(last_count + cyc_per_tick);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -165,8 +369,12 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
|
||||
ARG_UNUSED(idle);
|
||||
|
||||
#if defined(CONFIG_TICKLESS_KERNEL)
|
||||
uint32_t reg;
|
||||
|
||||
if (ticks == K_TICKS_FOREVER && idle) {
|
||||
GENERAL_CONF_REG &= ~GCONF_ENABLE;
|
||||
reg = hpet_gconf_get();
|
||||
reg &= ~GCONF_ENABLE;
|
||||
hpet_gconf_set(reg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,7 +382,7 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
|
||||
ticks = CLAMP(ticks - 1, 0, (int32_t)max_ticks);
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
uint32_t now = MAIN_COUNTER_REG, cyc, adj;
|
||||
uint32_t now = hpet_counter_get(), cyc, adj;
|
||||
uint32_t max_cyc = max_ticks * cyc_per_tick;
|
||||
|
||||
/* Round up to next tick boundary. */
|
||||
@@ -188,11 +396,11 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
|
||||
cyc = (cyc / cyc_per_tick) * cyc_per_tick;
|
||||
cyc += last_count;
|
||||
|
||||
if ((cyc - now) < MIN_DELAY) {
|
||||
if ((cyc - now) < HPET_CMP_MIN_DELAY) {
|
||||
cyc += cyc_per_tick;
|
||||
}
|
||||
|
||||
TIMER0_COMPARATOR_REG = cyc;
|
||||
hpet_timer_comparator_set(cyc);
|
||||
k_spin_unlock(&lock, key);
|
||||
#endif
|
||||
}
|
||||
@@ -205,7 +413,7 @@ uint32_t sys_clock_elapsed(void)
|
||||
}
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
uint32_t ret = (MAIN_COUNTER_REG - last_count) / cyc_per_tick;
|
||||
uint32_t ret = (hpet_counter_get() - last_count) / cyc_per_tick;
|
||||
|
||||
k_spin_unlock(&lock, key);
|
||||
return ret;
|
||||
@@ -214,11 +422,15 @@ uint32_t sys_clock_elapsed(void)
|
||||
__pinned_func
|
||||
uint32_t sys_clock_cycle_get_32(void)
|
||||
{
|
||||
return MAIN_COUNTER_REG;
|
||||
return hpet_counter_get();
|
||||
}
|
||||
|
||||
__pinned_func
|
||||
void sys_clock_idle_exit(void)
|
||||
{
|
||||
GENERAL_CONF_REG |= GCONF_ENABLE;
|
||||
uint32_t reg;
|
||||
|
||||
reg = hpet_gconf_get();
|
||||
reg |= GCONF_ENABLE;
|
||||
hpet_gconf_set(reg);
|
||||
}
|
||||
|
||||
@@ -36,4 +36,5 @@
|
||||
dmamux1: dmamux@40020800 {
|
||||
dma-channels = <7>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -154,7 +154,7 @@ static ALWAYS_INLINE uint32_t sys_read32(mm_reg_t addr)
|
||||
static ALWAYS_INLINE void sys_set_bit(mem_addr_t addr, unsigned int bit)
|
||||
{
|
||||
__asm__ volatile("btsl %1, %0"
|
||||
: "+m" (*(volatile uint32_t *) (addr))
|
||||
: "+m" (*(volatile uint8_t *) (addr))
|
||||
: "Ir" (bit)
|
||||
: "memory");
|
||||
}
|
||||
@@ -162,7 +162,7 @@ static ALWAYS_INLINE void sys_set_bit(mem_addr_t addr, unsigned int bit)
|
||||
static ALWAYS_INLINE void sys_clear_bit(mem_addr_t addr, unsigned int bit)
|
||||
{
|
||||
__asm__ volatile("btrl %1, %0"
|
||||
: "+m" (*(volatile uint32_t *) (addr))
|
||||
: "+m" (*(volatile uint8_t *) (addr))
|
||||
: "Ir" (bit));
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ static ALWAYS_INLINE int sys_test_bit(mem_addr_t addr, unsigned int bit)
|
||||
|
||||
__asm__ volatile("btl %2, %1;"
|
||||
"sbb %0, %0"
|
||||
: "=r" (ret), "+m" (*(volatile uint32_t *) (addr))
|
||||
: "=r" (ret), "+m" (*(volatile uint8_t *) (addr))
|
||||
: "Ir" (bit));
|
||||
|
||||
return ret;
|
||||
@@ -185,7 +185,7 @@ static ALWAYS_INLINE int sys_test_and_set_bit(mem_addr_t addr,
|
||||
|
||||
__asm__ volatile("btsl %2, %1;"
|
||||
"sbb %0, %0"
|
||||
: "=r" (ret), "+m" (*(volatile uint32_t *) (addr))
|
||||
: "=r" (ret), "+m" (*(volatile uint8_t *) (addr))
|
||||
: "Ir" (bit));
|
||||
|
||||
return ret;
|
||||
@@ -198,7 +198,7 @@ static ALWAYS_INLINE int sys_test_and_clear_bit(mem_addr_t addr,
|
||||
|
||||
__asm__ volatile("btrl %2, %1;"
|
||||
"sbb %0, %0"
|
||||
: "=r" (ret), "+m" (*(volatile uint32_t *) (addr))
|
||||
: "=r" (ret), "+m" (*(volatile uint8_t *) (addr))
|
||||
: "Ir" (bit));
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -360,11 +360,14 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
|
||||
.offset = offsetof(struct_, \
|
||||
len_field_), \
|
||||
{ \
|
||||
.object = { \
|
||||
.sub_descr = \
|
||||
.array = { \
|
||||
.element_descr = \
|
||||
elem_descr_, \
|
||||
.sub_descr_len = \
|
||||
elem_descr_len_, \
|
||||
.n_elements = \
|
||||
1 + \
|
||||
ZERO_OR_COMPILE_ERROR( \
|
||||
elem_descr_len_ == 1 \
|
||||
), \
|
||||
}, \
|
||||
}, \
|
||||
} }, \
|
||||
|
||||
@@ -104,6 +104,9 @@ static inline char *z_stack_ptr_align(char *ptr)
|
||||
#define Z_KERNEL_STACK_OBJ_ALIGN ARCH_STACK_PTR_ALIGN
|
||||
#endif
|
||||
|
||||
#define Z_KERNEL_STACK_LEN(size) \
|
||||
ROUND_UP(Z_KERNEL_STACK_SIZE_ADJUST(size), Z_KERNEL_STACK_OBJ_ALIGN)
|
||||
|
||||
/**
|
||||
* @brief Obtain an extern reference to a stack
|
||||
*
|
||||
@@ -119,6 +122,36 @@ static inline char *z_stack_ptr_align(char *ptr)
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @def K_KERNEL_STACK_ARRAY_EXTERN
|
||||
* @brief Obtain an extern reference to a stack array
|
||||
*
|
||||
* This macro properly brings the symbol of a stack array declared
|
||||
* elsewhere into scope.
|
||||
*
|
||||
* @param sym Thread stack symbol name
|
||||
* @param nmemb Number of stacks to declare
|
||||
* @param size Size of the stack memory region
|
||||
*/
|
||||
#define K_KERNEL_STACK_ARRAY_EXTERN(sym, nmemb, size) \
|
||||
extern struct z_thread_stack_element \
|
||||
sym[nmemb][Z_KERNEL_STACK_LEN(size)]
|
||||
|
||||
/**
|
||||
* @def K_KERNEL_PINNED_STACK_ARRAY_EXTERN
|
||||
* @brief Obtain an extern reference to a pinned stack array
|
||||
*
|
||||
* This macro properly brings the symbol of a pinned stack array
|
||||
* declared elsewhere into scope.
|
||||
*
|
||||
* @param sym Thread stack symbol name
|
||||
* @param nmemb Number of stacks to declare
|
||||
* @param size Size of the stack memory region
|
||||
*/
|
||||
#define K_KERNEL_PINNED_STACK_ARRAY_EXTERN(sym, nmemb, size) \
|
||||
extern struct z_thread_stack_element \
|
||||
sym[nmemb][Z_KERNEL_STACK_LEN(size)]
|
||||
|
||||
/**
|
||||
* @def Z_KERNEL_STACK_DEFINE_IN
|
||||
* @brief Define a toplevel kernel stack memory region in specified section
|
||||
@@ -204,9 +237,6 @@ static inline char *z_stack_ptr_align(char *ptr)
|
||||
Z_KERNEL_STACK_DEFINE_IN(sym, size, __kstackmem)
|
||||
#endif
|
||||
|
||||
#define Z_KERNEL_STACK_LEN(size) \
|
||||
ROUND_UP(Z_KERNEL_STACK_SIZE_ADJUST(size), Z_KERNEL_STACK_OBJ_ALIGN)
|
||||
|
||||
/**
|
||||
* @def K_KERNEL_STACK_ARRAY_DEFINE
|
||||
* @brief Define a toplevel array of kernel stack memory regions
|
||||
@@ -272,6 +302,7 @@ static inline char *Z_KERNEL_STACK_BUFFER(k_thread_stack_t *sym)
|
||||
#define K_THREAD_STACK_MEMBER K_KERNEL_STACK_MEMBER
|
||||
#define Z_THREAD_STACK_BUFFER Z_KERNEL_STACK_BUFFER
|
||||
#define K_THREAD_STACK_EXTERN K_KERNEL_STACK_EXTERN
|
||||
#define K_THREAD_STACK_ARRAY_EXTERN K_KERNEL_STACK_ARRAY_EXTERN
|
||||
#else
|
||||
/**
|
||||
* @def K_THREAD_STACK_RESERVED
|
||||
@@ -371,6 +402,20 @@ static inline char *Z_KERNEL_STACK_BUFFER(k_thread_stack_t *sym)
|
||||
*/
|
||||
#define K_THREAD_STACK_EXTERN(sym) extern k_thread_stack_t sym[]
|
||||
|
||||
/**
|
||||
* @brief Obtain an extern reference to a thread stack array
|
||||
*
|
||||
* This macro properly brings the symbol of a stack array declared
|
||||
* elsewhere into scope.
|
||||
*
|
||||
* @param sym Thread stack symbol name
|
||||
* @param nmemb Number of stacks to declare
|
||||
* @param size Size of the stack memory region
|
||||
*/
|
||||
#define K_THREAD_STACK_ARRAY_EXTERN(sym, nmemb, size) \
|
||||
extern struct z_thread_stack_element \
|
||||
sym[nmemb][K_THREAD_STACK_LEN(size)]
|
||||
|
||||
/**
|
||||
* @addtogroup thread_stack_api
|
||||
* @{
|
||||
|
||||
@@ -11,17 +11,6 @@
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
#if defined (CONFIG_EXCEPTIONS)
|
||||
SECTION_PROLOGUE(.eh_frame_hdr,,)
|
||||
{
|
||||
*(.eh_frame_hdr)
|
||||
}
|
||||
|
||||
SECTION_PROLOGUE(.eh_frame,,)
|
||||
{
|
||||
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .eh_frame)))
|
||||
KEEP (*(SORT_NONE(.eh_frame)))
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
SECTION_PROLOGUE(.tm_clone_table,,)
|
||||
{
|
||||
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .tm_clone_table)))
|
||||
|
||||
@@ -9,4 +9,18 @@
|
||||
{
|
||||
*(.gcc_except_table .gcc_except_table.*)
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_EXCEPTIONS)
|
||||
SECTION_PROLOGUE(.eh_frame_hdr,,)
|
||||
{
|
||||
*(.eh_frame_hdr)
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_PROLOGUE(.eh_frame,,)
|
||||
{
|
||||
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .eh_frame)))
|
||||
KEEP (*(SORT_NONE(.eh_frame)))
|
||||
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
#endif /* CONFIG_EXCEPTIONS */
|
||||
|
||||
#endif /* CONFIG_CPLUSPLUS */
|
||||
|
||||
@@ -354,6 +354,9 @@ struct mqtt_sec_config {
|
||||
* May be NULL to skip hostname verification.
|
||||
*/
|
||||
const char *hostname;
|
||||
|
||||
/** Indicates the preference for copying certificates to the heap. */
|
||||
int cert_nocopy;
|
||||
};
|
||||
|
||||
/** @brief MQTT transport type. */
|
||||
|
||||
@@ -139,6 +139,12 @@ struct zsock_pollfd {
|
||||
#define TLS_DTLS_HANDSHAKE_TIMEOUT_MIN 8
|
||||
#define TLS_DTLS_HANDSHAKE_TIMEOUT_MAX 9
|
||||
|
||||
/** Socket option for preventing certificates from being copied to the mbedTLS
|
||||
* heap if possible. The option is only effective for DER certificates and is
|
||||
* ignored for PEM certificates.
|
||||
*/
|
||||
#define TLS_CERT_NOCOPY 10
|
||||
|
||||
/** @} */
|
||||
|
||||
/* Valid values for TLS_PEER_VERIFY option */
|
||||
@@ -150,6 +156,10 @@ struct zsock_pollfd {
|
||||
#define TLS_DTLS_ROLE_CLIENT 0 /**< Client role in a DTLS session. */
|
||||
#define TLS_DTLS_ROLE_SERVER 1 /**< Server role in a DTLS session. */
|
||||
|
||||
/* Valid values for TLS_CERT_NOCOPY option */
|
||||
#define TLS_CERT_NOCOPY_NONE 0 /**< Cert duplicated in heap */
|
||||
#define TLS_CERT_NOCOPY_OPTIONAL 1 /**< Cert not copied in heap if DER */
|
||||
|
||||
struct zsock_addrinfo {
|
||||
struct zsock_addrinfo *ai_next;
|
||||
int ai_flags;
|
||||
|
||||
@@ -152,7 +152,7 @@ extern struct k_thread z_main_thread;
|
||||
#ifdef CONFIG_MULTITHREADING
|
||||
extern struct k_thread z_idle_threads[CONFIG_MP_NUM_CPUS];
|
||||
#endif
|
||||
extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
|
||||
K_KERNEL_PINNED_STACK_ARRAY_EXTERN(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
|
||||
CONFIG_ISR_STACK_SIZE);
|
||||
|
||||
#ifdef CONFIG_GEN_PRIV_STACKS
|
||||
|
||||
@@ -26,7 +26,7 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
|
||||
K_APPMEM_PARTITION_DEFINE(z_malloc_partition);
|
||||
#define POOL_SECTION K_APP_DMEM_SECTION(z_malloc_partition)
|
||||
#else
|
||||
#define POOL_SECTION .data
|
||||
#define POOL_SECTION .bss
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#define HEAP_BYTES CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE
|
||||
|
||||
@@ -174,20 +174,40 @@ start:
|
||||
uint_value_type d;
|
||||
|
||||
if (length_mod == 'z') {
|
||||
d = va_arg(ap, ssize_t);
|
||||
} else if (length_mod == 'l') {
|
||||
d = va_arg(ap, long);
|
||||
} else if (length_mod == 'L') {
|
||||
long long lld = va_arg(ap, long long);
|
||||
|
||||
if (sizeof(int_value_type) < 8U &&
|
||||
lld != (int_value_type) lld) {
|
||||
data = "ERR";
|
||||
data_len = 3;
|
||||
precision = 0;
|
||||
break;
|
||||
if (*fmt == 'u') {
|
||||
d = va_arg(ap, size_t);
|
||||
} else {
|
||||
d = va_arg(ap, ssize_t);
|
||||
}
|
||||
} else if (length_mod == 'l') {
|
||||
if (*fmt == 'u') {
|
||||
d = va_arg(ap, unsigned long);
|
||||
} else {
|
||||
d = va_arg(ap, long);
|
||||
}
|
||||
} else if (length_mod == 'L') {
|
||||
if (*fmt == 'u') {
|
||||
unsigned long long llu =
|
||||
va_arg(ap, unsigned long long);
|
||||
|
||||
if (llu != (uint_value_type) llu) {
|
||||
data = "ERR";
|
||||
data_len = 3;
|
||||
precision = 0;
|
||||
break;
|
||||
}
|
||||
d = (uint_value_type) llu;
|
||||
} else {
|
||||
long long lld = va_arg(ap, long long);
|
||||
|
||||
if (lld != (int_value_type) lld) {
|
||||
data = "ERR";
|
||||
data_len = 3;
|
||||
precision = 0;
|
||||
break;
|
||||
}
|
||||
d = (int_value_type) lld;
|
||||
}
|
||||
d = (uint_value_type) lld;
|
||||
} else if (*fmt == 'u') {
|
||||
d = va_arg(ap, unsigned int);
|
||||
} else {
|
||||
@@ -229,7 +249,16 @@ start:
|
||||
} else if (length_mod == 'l') {
|
||||
x = va_arg(ap, unsigned long);
|
||||
} else if (length_mod == 'L') {
|
||||
x = va_arg(ap, unsigned long long);
|
||||
unsigned long long llx =
|
||||
va_arg(ap, unsigned long long);
|
||||
|
||||
if (llx != (uint_value_type) llx) {
|
||||
data = "ERR";
|
||||
data_len = 3;
|
||||
precision = 0;
|
||||
break;
|
||||
}
|
||||
x = (uint_value_type) llx;
|
||||
} else {
|
||||
x = va_arg(ap, unsigned int);
|
||||
}
|
||||
|
||||
@@ -509,12 +509,18 @@ static int arr_parse(struct json_obj *obj,
|
||||
{
|
||||
ptrdiff_t elem_size = get_elem_size(elem_descr);
|
||||
void *last_elem = (char *)field + elem_size * max_elements;
|
||||
size_t *elements = (size_t *)((char *)val + elem_descr->offset);
|
||||
size_t *elements = NULL;
|
||||
struct token value;
|
||||
|
||||
if (val) {
|
||||
elements = (size_t *)((char *)val + elem_descr->offset);
|
||||
}
|
||||
|
||||
__ASSERT_NO_MSG(elem_size > 0);
|
||||
|
||||
*elements = 0;
|
||||
if (elements) {
|
||||
*elements = 0;
|
||||
}
|
||||
|
||||
while (!arr_next(obj, &value)) {
|
||||
if (value.type == JSON_TOK_LIST_END) {
|
||||
@@ -525,11 +531,13 @@ static int arr_parse(struct json_obj *obj,
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
if (decode_value(obj, elem_descr, &value, field, val) < 0) {
|
||||
if (decode_value(obj, elem_descr, &value, field, NULL) < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(*elements)++;
|
||||
if (elements) {
|
||||
(*elements)++;
|
||||
}
|
||||
field = (char *)field + elem_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,17 +10,28 @@ if(CONFIG_PERCEPIO_TRACERECORDER)
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_PERCEPIO_TRACERECORDER
|
||||
${TRACERECORDER_DIR}/kernelports/Zephyr/trcKernelPort.c
|
||||
${TRACERECORDER_DIR}/trcInternalBuffer.c
|
||||
${TRACERECORDER_DIR}/trcStreamingRecorder.c
|
||||
${TRACERECORDER_DIR}/extras/SDK/trcSDK.c
|
||||
)
|
||||
|
||||
if(CONFIG_PERCEPIO_RECORDER_TRC_RECORDER_STREAM_PORT_RTT)
|
||||
zephyr_library_sources(
|
||||
${TRACERECORDER_DIR}/streamports/Jlink_RTT/trcStreamingPort.c
|
||||
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Jlink_RTT/trcStreamingPort.c
|
||||
)
|
||||
|
||||
zephyr_include_directories(
|
||||
${TRACERECORDER_DIR}/streamports/Jlink_RTT/include/
|
||||
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Jlink_RTT/include/
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_PERCEPIO_RECORDER_TRC_RECORDER_STREAM_PORT_ITM)
|
||||
zephyr_library_sources(
|
||||
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/ARM_ITM/trcStreamingPort.c
|
||||
)
|
||||
|
||||
zephyr_include_directories(
|
||||
${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/ARM_ITM/include/
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ envlist=py3
|
||||
deps =
|
||||
setuptools-scm
|
||||
pytest
|
||||
types-PyYAML
|
||||
mypy
|
||||
setenv =
|
||||
TOXTEMPDIR={envtmpdir}
|
||||
|
||||
@@ -86,6 +86,7 @@ syscall_template = """
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -27,7 +27,7 @@ anytree
|
||||
intelhex
|
||||
|
||||
# it's west
|
||||
west>=0.10.1
|
||||
west==0.11.1
|
||||
|
||||
# used for windows based 'menuconfig'
|
||||
# "win32" is used for 64-bit Windows as well
|
||||
|
||||
@@ -17,6 +17,7 @@ config SOC_OPENISA_RV32M1_RISCV32
|
||||
select CLOCK_CONTROL
|
||||
select HAS_RV32M1_FTFX
|
||||
select HAS_FLASH_LOAD_OFFSET
|
||||
select BUILD_OUTPUT_HEX
|
||||
help
|
||||
Enable support for OpenISA RV32M1 RISC-V processors. Choose
|
||||
this option to target the RI5CY or ZERO-RISCY core. This
|
||||
|
||||
@@ -146,9 +146,7 @@ void soc_interrupt_init(void)
|
||||
(void)(EVENT_UNIT->EVTPENDCLEAR); /* Ensures write has finished. */
|
||||
|
||||
if (IS_ENABLED(CONFIG_MULTI_LEVEL_INTERRUPTS)) {
|
||||
dev_intmux = device_get_binding(
|
||||
DT_LABEL(DT_INST(0, openisa_rv32m1_intmux)));
|
||||
__ASSERT(dev_intmux, "no INTMUX device found");
|
||||
dev_intmux = DEVICE_DT_GET(DT_INST(0, openisa_rv32m1_intmux));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -312,11 +312,20 @@ static struct {
|
||||
* Increasing this by times the max. simultaneous connection count will permit
|
||||
* simultaneous parallel PHY update or Connection Update procedures amongst
|
||||
* active connections.
|
||||
* Minimum node rx of 2 that can be reserved happens when local central
|
||||
* initiated PHY Update reserves 2 node rx, one for PHY update complete and
|
||||
* another for Data Length Update complete notification. Otherwise, a
|
||||
* peripheral only needs 1 additional node rx to generate Data Length Update
|
||||
* complete when PHY Update completes; node rx for PHY update complete is
|
||||
* reserved as the received PHY Update Ind PDU.
|
||||
*/
|
||||
#if defined(CONFIG_BT_CTLR_PHY) && defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
#define LL_PDU_RX_CNT 3
|
||||
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_CTLR_PHY) && \
|
||||
defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
#define LL_PDU_RX_CNT (2 * (CONFIG_BT_CTLR_LLCP_CONN))
|
||||
#elif defined(CONFIG_BT_CONN)
|
||||
#define LL_PDU_RX_CNT (CONFIG_BT_CTLR_LLCP_CONN)
|
||||
#else
|
||||
#define LL_PDU_RX_CNT 2
|
||||
#define LL_PDU_RX_CNT 0
|
||||
#endif
|
||||
|
||||
/* No. of node rx for LLL to ULL.
|
||||
@@ -1997,7 +2006,7 @@ static inline void rx_alloc(uint8_t max)
|
||||
max = mem_link_rx.quota_pdu;
|
||||
}
|
||||
|
||||
while ((max--) && MFIFO_ENQUEUE_IDX_GET(pdu_rx_free, &idx)) {
|
||||
while (max && MFIFO_ENQUEUE_IDX_GET(pdu_rx_free, &idx)) {
|
||||
memq_link_t *link;
|
||||
struct node_rx_hdr *rx;
|
||||
|
||||
@@ -2017,6 +2026,8 @@ static inline void rx_alloc(uint8_t max)
|
||||
MFIFO_BY_IDX_ENQUEUE(pdu_rx_free, idx, rx);
|
||||
|
||||
ll_rx_link_inc_quota(-1);
|
||||
|
||||
max--;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
|
||||
@@ -4017,12 +4017,12 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
|
||||
rx->hdr.link->mem = conn->llcp_rx;
|
||||
conn->llcp_rx = rx;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
/* reserve rx node for DLE event generation */
|
||||
rx = ll_pdu_rx_alloc();
|
||||
rx->hdr.link->mem = conn->llcp_rx;
|
||||
conn->llcp_rx = rx;
|
||||
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH)) {
|
||||
rx = ll_pdu_rx_alloc();
|
||||
rx->hdr.link->mem = conn->llcp_rx;
|
||||
conn->llcp_rx = rx;
|
||||
}
|
||||
}
|
||||
|
||||
/* place the phy update ind packet as next in
|
||||
@@ -4047,6 +4047,21 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
|
||||
struct node_rx_pdu *rx;
|
||||
uint8_t old_tx, old_rx;
|
||||
|
||||
/* Acquire additional rx node for Data length notification as
|
||||
* a peripheral.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
|
||||
IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH) &&
|
||||
conn->lll.role) {
|
||||
rx = ll_pdu_rx_alloc();
|
||||
if (!rx) {
|
||||
return;
|
||||
}
|
||||
|
||||
rx->hdr.link->mem = conn->llcp_rx;
|
||||
conn->llcp_rx = rx;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL) && defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
if (conn->lll.role && (conn->slave.llcp_type != LLCP_NONE)) {
|
||||
/* Local peripheral initiated PHY update completed while
|
||||
@@ -4107,8 +4122,11 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
|
||||
/* enqueue rx node towards Thread */
|
||||
ll_rx_put(rx->hdr.link, rx);
|
||||
|
||||
/* Release rx node that was reserved for Data Length
|
||||
* notification.
|
||||
*/
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH)) {
|
||||
/* get the DLE rx node reserved for ULL->LL */
|
||||
/* Get the DLE rx node reserved for ULL->LL */
|
||||
rx = conn->llcp_rx;
|
||||
LL_ASSERT(rx && rx->hdr.link);
|
||||
conn->llcp_rx = rx->hdr.link->mem;
|
||||
@@ -5454,23 +5472,27 @@ static inline uint8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link,
|
||||
conn->llcp.phy_upd_ind.instant = instant;
|
||||
conn->llcp.phy_upd_ind.initiate = 0U;
|
||||
|
||||
/* Reserve the Rx-ed PHY Update Indication PDU in the connection
|
||||
* context, by appending to the LLCP node rx list. We do not mark it
|
||||
* for release in ULL, i.e., by returning *rx as NULL.
|
||||
* PHY Update notification to HCI layer will use node rx from this
|
||||
* list when at the instant.
|
||||
* If data length update is supported in the Controller, then, at the
|
||||
* instant we attempt to acquire an additional free node rx for Data
|
||||
* Length Update notification.
|
||||
*/
|
||||
link->mem = conn->llcp_rx;
|
||||
(*rx)->hdr.link = link;
|
||||
conn->llcp_rx = *rx;
|
||||
*rx = NULL;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
/* reserve rx node for DLE event generation */
|
||||
struct node_rx_pdu *rx_dle = ll_pdu_rx_alloc();
|
||||
|
||||
LL_ASSERT(rx_dle);
|
||||
rx_dle->hdr.link->mem = conn->llcp_rx;
|
||||
conn->llcp_rx = rx_dle;
|
||||
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
|
||||
|
||||
/* Transition to PHY Update Ind received state and wait for the
|
||||
* instant.
|
||||
*/
|
||||
conn->llcp_type = LLCP_PHY_UPD;
|
||||
conn->llcp_ack -= 2U;
|
||||
|
||||
/* Enforce packet timing restrictions until the instant */
|
||||
if (conn->llcp.phy_upd_ind.tx) {
|
||||
conn->lll.phy_tx_time = conn->llcp.phy_upd_ind.tx;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
#include "common/log.h"
|
||||
#include "hal/debug.h"
|
||||
|
||||
static void invalid_release(struct ull_hdr *hdr, struct lll_conn *lll,
|
||||
memq_link_t *link, struct node_rx_hdr *rx);
|
||||
static void ticker_op_stop_adv_cb(uint32_t status, void *param);
|
||||
static void ticker_op_cb(uint32_t status, void *param);
|
||||
static void ticker_update_latency_cancel_op_cb(uint32_t ticker_status,
|
||||
@@ -112,10 +114,8 @@ void ull_slave_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
|
||||
/* Do not connect twice to the same peer */
|
||||
if (ull_conn_peer_connected(own_addr_type, own_addr,
|
||||
peer_addr_type, peer_id_addr)) {
|
||||
rx->type = NODE_RX_TYPE_RELEASE;
|
||||
invalid_release(&adv->ull, lll, link, rx);
|
||||
|
||||
ll_rx_put(link, rx);
|
||||
ll_rx_sched();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,34 +136,7 @@ void ull_slave_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
|
||||
lll->interval = sys_le16_to_cpu(pdu_adv->connect_ind.interval);
|
||||
if ((lll->data_chan_count < 2) || (lll->data_chan_hop < 5) ||
|
||||
(lll->data_chan_hop > 16) || !lll->interval) {
|
||||
lll->slave.initiated = 0U;
|
||||
|
||||
/* Mark for buffer for release */
|
||||
rx->type = NODE_RX_TYPE_RELEASE;
|
||||
|
||||
/* Release CSA#2 related node rx too */
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) {
|
||||
struct node_rx_pdu *rx_csa;
|
||||
|
||||
/* pick the rx node instance stored within the
|
||||
* connection rx node.
|
||||
*/
|
||||
rx_csa = (void *)ftr->extra;
|
||||
|
||||
/* Enqueue the connection event to be release */
|
||||
ll_rx_put(link, rx);
|
||||
|
||||
/* Use the rx node for CSA event */
|
||||
rx = (void *)rx_csa;
|
||||
link = rx->link;
|
||||
|
||||
/* Mark for buffer for release */
|
||||
rx->type = NODE_RX_TYPE_RELEASE;
|
||||
}
|
||||
|
||||
/* Enqueue connection or CSA event to be release */
|
||||
ll_rx_put(link, rx);
|
||||
ll_rx_sched();
|
||||
invalid_release(&adv->ull, lll, link, rx);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -578,6 +551,43 @@ uint8_t ll_start_enc_req_send(uint16_t handle, uint8_t error_code,
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_LE_ENC */
|
||||
|
||||
static void invalid_release(struct ull_hdr *hdr, struct lll_conn *lll,
|
||||
memq_link_t *link, struct node_rx_hdr *rx)
|
||||
{
|
||||
/* Reset the advertising disabled callback */
|
||||
hdr->disabled_cb = NULL;
|
||||
|
||||
/* Let the advertiser continue with connectable advertising */
|
||||
lll->slave.initiated = 0U;
|
||||
|
||||
/* Mark for buffer for release */
|
||||
rx->type = NODE_RX_TYPE_RELEASE;
|
||||
|
||||
/* Release CSA#2 related node rx too */
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) {
|
||||
struct node_rx_pdu *rx_csa;
|
||||
|
||||
/* pick the rx node instance stored within the
|
||||
* connection rx node.
|
||||
*/
|
||||
rx_csa = rx->rx_ftr.extra;
|
||||
|
||||
/* Enqueue the connection event to be release */
|
||||
ll_rx_put(link, rx);
|
||||
|
||||
/* Use the rx node for CSA event */
|
||||
rx = (void *)rx_csa;
|
||||
link = rx->link;
|
||||
|
||||
/* Mark for buffer for release */
|
||||
rx->type = NODE_RX_TYPE_RELEASE;
|
||||
}
|
||||
|
||||
/* Enqueue connection or CSA event to be release */
|
||||
ll_rx_put(link, rx);
|
||||
ll_rx_sched();
|
||||
}
|
||||
|
||||
static void ticker_op_stop_adv_cb(uint32_t status, void *param)
|
||||
{
|
||||
LL_ASSERT(status != TICKER_STATUS_FAILURE ||
|
||||
|
||||
@@ -872,6 +872,8 @@ static void l2cap_chan_tx_process(struct k_work *work)
|
||||
if (sent < 0) {
|
||||
if (sent == -EAGAIN) {
|
||||
ch->tx_buf = buf;
|
||||
} else {
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ if LIB_CPLUSPLUS
|
||||
|
||||
config EXCEPTIONS
|
||||
bool "Enable C++ exceptions support"
|
||||
depends on !NEWLIB_LIBC_NANO
|
||||
help
|
||||
This option enables support of C++ exceptions.
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ struct z_page_frame *k_mem_paging_eviction_select(bool *dirty_ptr)
|
||||
unsigned int last_prec = 4U;
|
||||
struct z_page_frame *last_pf = NULL, *pf;
|
||||
bool accessed;
|
||||
bool last_dirty = false;
|
||||
bool dirty = false;
|
||||
uintptr_t flags, phys;
|
||||
|
||||
@@ -71,18 +72,20 @@ struct z_page_frame *k_mem_paging_eviction_select(bool *dirty_ptr)
|
||||
if (prec == 0) {
|
||||
/* If we find a not accessed, clean page we're done */
|
||||
last_pf = pf;
|
||||
last_dirty = dirty;
|
||||
break;
|
||||
}
|
||||
|
||||
if (prec < last_prec) {
|
||||
last_prec = prec;
|
||||
last_pf = pf;
|
||||
last_dirty = dirty;
|
||||
}
|
||||
}
|
||||
/* Shouldn't ever happen unless every page is pinned */
|
||||
__ASSERT(last_pf != NULL, "no page to evict");
|
||||
|
||||
*dirty_ptr = dirty;
|
||||
*dirty_ptr = last_dirty;
|
||||
|
||||
return last_pf;
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ static int check_log_file_exist(int num)
|
||||
while (true) {
|
||||
rc = fs_readdir(&dir, &ent);
|
||||
if (rc < 0) {
|
||||
(void) fs_closedir(&dir);
|
||||
return -EIO;
|
||||
rc = -EIO;
|
||||
goto close_dir;
|
||||
}
|
||||
if (ent.name[0] == 0) {
|
||||
break;
|
||||
@@ -129,13 +129,17 @@ static int check_log_file_exist(int num)
|
||||
rc = get_log_file_id(&ent);
|
||||
|
||||
if (rc == num) {
|
||||
return 1;
|
||||
rc = 1;
|
||||
goto close_dir;
|
||||
}
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
|
||||
close_dir:
|
||||
(void) fs_closedir(&dir);
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int write_log_to_file(uint8_t *data, size_t length, void *ctx)
|
||||
|
||||
@@ -1913,7 +1913,8 @@ next_state:
|
||||
break;
|
||||
case TCP_FIN_WAIT_2:
|
||||
if (th && (FL(&fl, ==, FIN, th_seq(th) == conn->ack) ||
|
||||
FL(&fl, ==, FIN | ACK, th_seq(th) == conn->ack))) {
|
||||
FL(&fl, ==, FIN | ACK, th_seq(th) == conn->ack) ||
|
||||
FL(&fl, ==, FIN | PSH | ACK, th_seq(th) == conn->ack))) {
|
||||
/* Received FIN on FIN_WAIT_2, so cancel the timer */
|
||||
k_work_cancel_delayable(&conn->fin_timer);
|
||||
|
||||
|
||||
@@ -78,6 +78,15 @@ int mqtt_client_tls_connect(struct mqtt_client *client)
|
||||
}
|
||||
}
|
||||
|
||||
if (tls_config->cert_nocopy != TLS_CERT_NOCOPY_NONE) {
|
||||
ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS,
|
||||
TLS_CERT_NOCOPY, &tls_config->cert_nocopy,
|
||||
sizeof(tls_config->cert_nocopy));
|
||||
if (ret < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
size_t peer_addr_size = sizeof(struct sockaddr_in6);
|
||||
|
||||
if (broker->sa_family == AF_INET) {
|
||||
|
||||
@@ -113,6 +113,11 @@ __net_socket struct tls_context {
|
||||
/** Peer verification level. */
|
||||
int8_t verify_level;
|
||||
|
||||
/** Indicating on whether DER certificates should not be copied
|
||||
* to the heap.
|
||||
*/
|
||||
int8_t cert_nocopy;
|
||||
|
||||
/** DTLS role, client by default. */
|
||||
int8_t role;
|
||||
|
||||
@@ -679,12 +684,30 @@ static int tls_rx(void *ctx, unsigned char *buf, size_t len)
|
||||
return received;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
static bool crt_is_pem(const unsigned char *buf, size_t buflen)
|
||||
{
|
||||
return (buflen != 0 && buf[buflen - 1] == '\0' &&
|
||||
strstr((const char *)buf, "-----BEGIN CERTIFICATE-----") != NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int tls_add_ca_certificate(struct tls_context *tls,
|
||||
struct tls_credential *ca_cert)
|
||||
{
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
int err = mbedtls_x509_crt_parse(&tls->ca_chain,
|
||||
ca_cert->buf, ca_cert->len);
|
||||
int err;
|
||||
|
||||
if (tls->options.cert_nocopy == TLS_CERT_NOCOPY_NONE ||
|
||||
crt_is_pem(ca_cert->buf, ca_cert->len)) {
|
||||
err = mbedtls_x509_crt_parse(&tls->ca_chain, ca_cert->buf,
|
||||
ca_cert->len);
|
||||
} else {
|
||||
err = mbedtls_x509_crt_parse_der_nocopy(&tls->ca_chain,
|
||||
ca_cert->buf,
|
||||
ca_cert->len);
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -704,29 +727,59 @@ static void tls_set_ca_chain(struct tls_context *tls)
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
}
|
||||
|
||||
static int tls_set_own_cert(struct tls_context *tls,
|
||||
struct tls_credential *own_cert,
|
||||
struct tls_credential *priv_key)
|
||||
static int tls_add_own_cert(struct tls_context *tls,
|
||||
struct tls_credential *own_cert)
|
||||
{
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
int err = mbedtls_x509_crt_parse(&tls->own_cert,
|
||||
own_cert->buf, own_cert->len);
|
||||
int err;
|
||||
|
||||
if (tls->options.cert_nocopy == TLS_CERT_NOCOPY_NONE ||
|
||||
crt_is_pem(own_cert->buf, own_cert->len)) {
|
||||
err = mbedtls_x509_crt_parse(&tls->own_cert,
|
||||
own_cert->buf, own_cert->len);
|
||||
} else {
|
||||
err = mbedtls_x509_crt_parse_der_nocopy(&tls->own_cert,
|
||||
own_cert->buf,
|
||||
own_cert->len);
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int tls_set_own_cert(struct tls_context *tls)
|
||||
{
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
int err = mbedtls_ssl_conf_own_cert(&tls->config, &tls->own_cert,
|
||||
&tls->priv_key);
|
||||
if (err != 0) {
|
||||
err = -ENOMEM;
|
||||
}
|
||||
|
||||
return err;
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int tls_set_private_key(struct tls_context *tls,
|
||||
struct tls_credential *priv_key)
|
||||
{
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
int err;
|
||||
|
||||
err = mbedtls_pk_parse_key(&tls->priv_key, priv_key->buf,
|
||||
priv_key->len, NULL, 0);
|
||||
if (err != 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = mbedtls_ssl_conf_own_cert(&tls->config, &tls->own_cert,
|
||||
&tls->priv_key);
|
||||
if (err != 0) {
|
||||
err = -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
@@ -760,21 +813,11 @@ static int tls_set_credential(struct tls_context *tls,
|
||||
return tls_add_ca_certificate(tls, cred);
|
||||
|
||||
case TLS_CREDENTIAL_SERVER_CERTIFICATE:
|
||||
{
|
||||
struct tls_credential *priv_key =
|
||||
credential_get(cred->tag, TLS_CREDENTIAL_PRIVATE_KEY);
|
||||
if (!priv_key) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return tls_set_own_cert(tls, cred, priv_key);
|
||||
}
|
||||
return tls_add_own_cert(tls, cred);
|
||||
|
||||
case TLS_CREDENTIAL_PRIVATE_KEY:
|
||||
/* Ignore private key - it will be used together
|
||||
* with public certificate
|
||||
*/
|
||||
break;
|
||||
return tls_set_private_key(tls, cred);
|
||||
break;
|
||||
|
||||
case TLS_CREDENTIAL_PSK:
|
||||
{
|
||||
@@ -805,7 +848,7 @@ static int tls_mbedtls_set_credentials(struct tls_context *tls)
|
||||
struct tls_credential *cred;
|
||||
sec_tag_t tag;
|
||||
int i, err = 0;
|
||||
bool tag_found, ca_cert_present = false;
|
||||
bool tag_found, ca_cert_present = false, own_cert_present = false;
|
||||
|
||||
credentials_lock();
|
||||
|
||||
@@ -824,6 +867,8 @@ static int tls_mbedtls_set_credentials(struct tls_context *tls)
|
||||
|
||||
if (cred->type == TLS_CREDENTIAL_CA_CERTIFICATE) {
|
||||
ca_cert_present = true;
|
||||
} else if (cred->type == TLS_CREDENTIAL_SERVER_CERTIFICATE) {
|
||||
own_cert_present = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,8 +881,13 @@ static int tls_mbedtls_set_credentials(struct tls_context *tls)
|
||||
exit:
|
||||
credentials_unlock();
|
||||
|
||||
if (err == 0 && ca_cert_present) {
|
||||
tls_set_ca_chain(tls);
|
||||
if (err == 0) {
|
||||
if (ca_cert_present) {
|
||||
tls_set_ca_chain(tls);
|
||||
}
|
||||
if (own_cert_present) {
|
||||
err = tls_set_own_cert(tls);
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -1312,6 +1362,31 @@ static int tls_opt_peer_verify_set(struct tls_context *context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tls_opt_cert_nocopy_set(struct tls_context *context,
|
||||
const void *optval, socklen_t optlen)
|
||||
{
|
||||
int *cert_nocopy;
|
||||
|
||||
if (!optval) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (optlen != sizeof(int)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cert_nocopy = (int *)optval;
|
||||
|
||||
if (*cert_nocopy != TLS_CERT_NOCOPY_NONE &&
|
||||
*cert_nocopy != TLS_CERT_NOCOPY_OPTIONAL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
context->options.cert_nocopy = *cert_nocopy;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tls_opt_dtls_role_set(struct tls_context *context,
|
||||
const void *optval, socklen_t optlen)
|
||||
{
|
||||
@@ -2340,6 +2415,10 @@ int ztls_setsockopt_ctx(struct tls_context *ctx, int level, int optname,
|
||||
err = tls_opt_peer_verify_set(ctx, optval, optlen);
|
||||
break;
|
||||
|
||||
case TLS_CERT_NOCOPY:
|
||||
err = tls_opt_cert_nocopy_set(ctx, optval, optlen);
|
||||
break;
|
||||
|
||||
case TLS_DTLS_ROLE:
|
||||
err = tls_opt_dtls_role_set(ctx, optval, optlen);
|
||||
break;
|
||||
|
||||
@@ -15,27 +15,30 @@ This benchmark measures the latency of selected kernel capabilities, including:
|
||||
* Time it takes to resume a suspended thread
|
||||
* Time it takes to create a new thread (without starting it)
|
||||
* Time it takes to start a newly created thread
|
||||
* Measure average time to alloc memory from heap then free that memory
|
||||
|
||||
|
||||
Sample output of the benchmark::
|
||||
|
||||
*** Booting Zephyr OS build zephyr-v2.3.0-2257-g0f420483db07 ***
|
||||
*** Booting Zephyr OS build zephyr-v2.6.0-1119-g378a1e082ac5 ***
|
||||
START - Time Measurement
|
||||
Timing results: Clock frequency: 120 MHz
|
||||
Average thread context switch using yield : 420 cycles , 3502 ns
|
||||
Average context switch time between threads (coop) : 429 cycles , 3583 ns
|
||||
Switch from ISR back to interrupted thread : 670 cycles , 5583 ns
|
||||
Time from ISR to executing a different thread : 570 cycles , 4750 ns
|
||||
Time to create a thread (without start) : 360 cycles , 3000 ns
|
||||
Time to start a thread : 545 cycles , 4541 ns
|
||||
Time to suspend a thread : 605 cycles , 5041 ns
|
||||
Time to resume a thread : 660 cycles , 5500 ns
|
||||
Time to abort a thread (not running) : 495 cycles , 4125 ns
|
||||
Average semaphore signal time : 195 cycles , 1626 ns
|
||||
Average semaphore test time : 62 cycles , 518 ns
|
||||
Semaphore take time (context switch) : 695 cycles , 5791 ns
|
||||
Semaphore give time (context switch) : 845 cycles , 7041 ns
|
||||
Average time to lock a mutex : 79 cycles , 659 ns
|
||||
Average time to unlock a mutex : 370 cycles , 3085 ns
|
||||
Timing results: Clock frequency: 1000 MHz
|
||||
Average thread context switch using yield : 9060 cycles , 9060 ns
|
||||
Average context switch time between threads (coop) : 9503 cycles , 9503 ns
|
||||
Switch from ISR back to interrupted thread : 14208 cycles , 14208 ns
|
||||
Time from ISR to executing a different thread : 9664 cycles , 9664 ns
|
||||
Time to create a thread (without start) : 3968 cycles , 3968 ns
|
||||
Time to start a thread : 12064 cycles , 12064 ns
|
||||
Time to suspend a thread : 12640 cycles , 12640 ns
|
||||
Time to resume a thread : 12096 cycles , 12096 ns
|
||||
Time to abort a thread (not running) : 2208 cycles , 2208 ns
|
||||
Average semaphore signal time : 8928 cycles , 8928 ns
|
||||
Average semaphore test time : 2048 cycles , 2048 ns
|
||||
Semaphore take time (context switch) : 13472 cycles , 13472 ns
|
||||
Semaphore give time (context switch) : 18400 cycles , 18400 ns
|
||||
Average time to lock a mutex : 3072 cycles , 3072 ns
|
||||
Average time to unlock a mutex : 9251 cycles , 9251 ns
|
||||
Average time for heap malloc : 13056 cycles , 13056 ns
|
||||
Average time for heap free : 7776 cycles , 7776 ns
|
||||
===================================================================
|
||||
PROJECT EXECUTION SUCCESSFUL
|
||||
|
||||
@@ -22,3 +22,5 @@ CONFIG_PM=n
|
||||
# Can only run under 1 CPU
|
||||
CONFIG_MP_NUM_CPUS=1
|
||||
CONFIG_TIMING_FUNCTIONS=y
|
||||
|
||||
CONFIG_HEAP_MEM_POOL_SIZE=2048
|
||||
|
||||
54
tests/benchmarks/latency_measure/src/heap_malloc_free.c
Normal file
54
tests/benchmarks/latency_measure/src/heap_malloc_free.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <timing/timing.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define TEST_COUNT 100
|
||||
#define TEST_SIZE 10
|
||||
|
||||
void heap_malloc_free(void)
|
||||
{
|
||||
timing_t heap_malloc_start_time = 0U;
|
||||
timing_t heap_malloc_end_time = 0U;
|
||||
|
||||
timing_t heap_free_start_time = 0U;
|
||||
timing_t heap_free_end_time = 0U;
|
||||
|
||||
uint32_t count = 0U;
|
||||
uint32_t sum_malloc = 0U;
|
||||
uint32_t sum_free = 0U;
|
||||
|
||||
timing_start();
|
||||
|
||||
while (count != TEST_COUNT) {
|
||||
heap_malloc_start_time = timing_counter_get();
|
||||
void *allocated_mem = k_malloc(TEST_SIZE);
|
||||
|
||||
heap_malloc_end_time = timing_counter_get();
|
||||
if (allocated_mem == NULL) {
|
||||
printk("Failed to alloc memory from heap "
|
||||
"at count %d\n", count);
|
||||
break;
|
||||
}
|
||||
|
||||
heap_free_start_time = timing_counter_get();
|
||||
k_free(allocated_mem);
|
||||
heap_free_end_time = timing_counter_get();
|
||||
|
||||
sum_malloc += timing_cycles_get(&heap_malloc_start_time,
|
||||
&heap_malloc_end_time);
|
||||
sum_free += timing_cycles_get(&heap_free_start_time,
|
||||
&heap_free_end_time);
|
||||
count++;
|
||||
}
|
||||
|
||||
PRINT_STATS_AVG("Average time for heap malloc", sum_malloc, count);
|
||||
PRINT_STATS_AVG("Average time for heap free", sum_free, count);
|
||||
|
||||
timing_stop();
|
||||
}
|
||||
@@ -27,6 +27,7 @@ extern int coop_ctx_switch(void);
|
||||
extern int sema_test(void);
|
||||
extern int sema_context_switch(void);
|
||||
extern int suspend_resume(void);
|
||||
extern void heap_malloc_free(void);
|
||||
|
||||
void test_thread(void *arg1, void *arg2, void *arg3)
|
||||
{
|
||||
@@ -57,6 +58,8 @@ void test_thread(void *arg1, void *arg2, void *arg3)
|
||||
|
||||
mutex_lock_unlock();
|
||||
|
||||
heap_malloc_free();
|
||||
|
||||
TC_END_REPORT(error_count);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <tc_util.h>
|
||||
#include <sys/bitarray.h>
|
||||
#include <sys/util.h>
|
||||
#include <toolchain.h>
|
||||
|
||||
#ifdef CONFIG_BIG_ENDIAN
|
||||
#define BIT_INDEX(bit) ((3 - ((bit >> 3) & 0x3)) + 4*(bit >> 5))
|
||||
@@ -338,13 +337,29 @@ void alloc_and_free_predefined(void)
|
||||
"sys_bitarray_free() failed bits comparison");
|
||||
}
|
||||
|
||||
static inline size_t count_bits(uint32_t val)
|
||||
{
|
||||
/* Implements Brian Kernighan’s Algorithm
|
||||
* to count bits.
|
||||
*/
|
||||
|
||||
size_t cnt = 0;
|
||||
|
||||
while (val != 0) {
|
||||
val = val & (val - 1);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
size_t get_bitarray_popcnt(sys_bitarray_t *ba)
|
||||
{
|
||||
size_t popcnt = 0;
|
||||
unsigned int idx;
|
||||
|
||||
for (idx = 0; idx < ba->num_bundles; idx++) {
|
||||
popcnt += popcount(ba->bundles[idx]);
|
||||
popcnt += count_bits(ba->bundles[idx]);
|
||||
}
|
||||
|
||||
return popcnt;
|
||||
|
||||
@@ -51,7 +51,7 @@ char *expected = "22 113 10000 32768 40000 22\n"
|
||||
"42 42 42 42\n"
|
||||
"42 42 0042 00000042\n"
|
||||
"255 42 abcdef 42\n"
|
||||
"ERR -1 4294967295 ffffffff\n"
|
||||
"ERR -1 ERR ERR\n"
|
||||
"0xcafebabe 0xbeef 0x2a\n"
|
||||
;
|
||||
#endif
|
||||
|
||||
@@ -362,7 +362,7 @@ void test_kobject_release_from_user(void)
|
||||
*/
|
||||
void test_kobject_release_null(void)
|
||||
{
|
||||
int dummy;
|
||||
int dummy = 0;
|
||||
|
||||
k_object_release(&dummy);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#define STACK_SIZE (640 + CONFIG_TEST_EXTRA_STACKSIZE)
|
||||
|
||||
K_THREAD_STACK_EXTERN(tstack);
|
||||
extern K_THREAD_STACK_ARRAY_DEFINE(tstacks, MAX_NUM_THREAD, STACK_SIZE);
|
||||
K_THREAD_STACK_ARRAY_EXTERN(tstacks, MAX_NUM_THREAD, STACK_SIZE);
|
||||
extern struct k_thread user_thread;
|
||||
extern struct k_sem user_sem;
|
||||
|
||||
|
||||
@@ -232,8 +232,20 @@ static void test_json_decoding_array_array(void)
|
||||
&obj_array_array_ts);
|
||||
|
||||
zassert_equal(ret, 1, "Encoding array of object returned no errors");
|
||||
zassert_equal(obj_array_array_ts.objects_array_len, 3, "Array has correct number of items");
|
||||
|
||||
zassert_true(!strcmp(obj_array_array_ts.objects_array[0].objects.name,
|
||||
"Simón Bolívar"), "String decoded correctly");
|
||||
zassert_equal(obj_array_array_ts.objects_array[0].objects.height, 168,
|
||||
"Simón Bolívar height decoded correctly");
|
||||
|
||||
zassert_true(!strcmp(obj_array_array_ts.objects_array[1].objects.name,
|
||||
"Pelé"), "String decoded correctly");
|
||||
zassert_equal(obj_array_array_ts.objects_array[1].objects.height, 173,
|
||||
"Pelé height decoded correctly");
|
||||
|
||||
zassert_true(!strcmp(obj_array_array_ts.objects_array[2].objects.name,
|
||||
"Usain Bolt"), "String decoded correctly");
|
||||
zassert_equal(obj_array_array_ts.objects_array[2].objects.height, 195,
|
||||
"Usain Bolt height decoded correctly");
|
||||
}
|
||||
|
||||
@@ -3,14 +3,17 @@ common:
|
||||
integration_platforms:
|
||||
- mps2_an385
|
||||
tests:
|
||||
cpp.libcxx:
|
||||
cpp.libcxx.newlib:
|
||||
toolchain_exclude: xcc
|
||||
min_flash: 54
|
||||
tags: cpp
|
||||
cpp.libcxx.exceptions:
|
||||
extra_configs:
|
||||
- CONFIG_NEWLIB_LIBC_NANO=n
|
||||
- CONFIG_EXCEPTIONS=y
|
||||
cpp.libcxx.newlib_nano:
|
||||
toolchain_exclude: xcc
|
||||
min_flash: 54
|
||||
tags: cpp
|
||||
timeout: 30
|
||||
extra_configs:
|
||||
- CONFIG_EXCEPTIONS=y
|
||||
- CONFIG_NEWLIB_LIBC_NANO=y
|
||||
|
||||
@@ -502,6 +502,7 @@ static void test_d_length(void)
|
||||
int max = 1876543210;
|
||||
long long svll = 123LL << 48;
|
||||
long long svll2 = -2LL;
|
||||
unsigned long long uvll = 4000000000LLU;
|
||||
int rc;
|
||||
|
||||
TEST_PRF(&rc, "%d/%d", min, max);
|
||||
@@ -518,22 +519,22 @@ static void test_d_length(void)
|
||||
PRF_CHECK("46/-22", rc);
|
||||
}
|
||||
|
||||
TEST_PRF(&rc, "%ld/%ld", (long)min, (long)max);
|
||||
TEST_PRF(&rc, "%ld/%ld/%lu/", (long)min, (long)max, 4000000000UL);
|
||||
if (IS_ENABLED(CONFIG_CBPRINTF_FULL_INTEGRAL)
|
||||
|| (sizeof(long) <= 4)
|
||||
|| IS_ENABLED(CONFIG_CBPRINTF_NANO)) {
|
||||
PRF_CHECK("-1234567890/1876543210", rc);
|
||||
PRF_CHECK("-1234567890/1876543210/4000000000/", rc);
|
||||
} else {
|
||||
PRF_CHECK("%ld/%ld", rc);
|
||||
PRF_CHECK("%ld/%ld/%lu/", rc);
|
||||
}
|
||||
|
||||
TEST_PRF(&rc, "/%lld/%lld/%lld/", svll, -svll, svll2);
|
||||
TEST_PRF(&rc, "/%lld/%lld/%lld/%llu/", svll, -svll, svll2, uvll);
|
||||
if (IS_ENABLED(CONFIG_CBPRINTF_FULL_INTEGRAL)) {
|
||||
PRF_CHECK("/34621422135410688/-34621422135410688/-2/", rc);
|
||||
PRF_CHECK("/34621422135410688/-34621422135410688/-2/4000000000/", rc);
|
||||
} else if (IS_ENABLED(CONFIG_CBPRINTF_COMPLETE)) {
|
||||
PRF_CHECK("/%lld/%lld/%lld/", rc);
|
||||
PRF_CHECK("/%lld/%lld/%lld/%llu/", rc);
|
||||
} else if (IS_ENABLED(CONFIG_CBPRINTF_NANO)) {
|
||||
PRF_CHECK("/ERR/ERR/-2/", rc);
|
||||
PRF_CHECK("/ERR/ERR/-2/4000000000/", rc);
|
||||
} else {
|
||||
zassert_true(false, "Missed case!");
|
||||
}
|
||||
|
||||
2
west.yml
2
west.yml
@@ -134,7 +134,7 @@ manifest:
|
||||
revision: a47e326ca772ddd14cc3b9d4ca30a9ab44ecca16
|
||||
- name: TraceRecorderSource
|
||||
path: modules/debug/TraceRecorder
|
||||
revision: d9889883abb4657d71e15ff055517a9b032f8212
|
||||
revision: 5b5f8d7adbf0e93a09087e8f5708f0eebb8b25bf
|
||||
- name: hal_xtensa
|
||||
revision: 2f04b615cd5ad3a1b8abef33f9bdd10cc1990ed6
|
||||
path: modules/hal/xtensa
|
||||
|
||||
Reference in New Issue
Block a user