diff --git a/cores/arduino/mbed/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h b/cores/arduino/mbed/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h index 734109c4..48dc513e 100644 --- a/cores/arduino/mbed/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h +++ b/cores/arduino/mbed/components/802.15.4_RF/stm-s2lp-rf-driver/source/s2lpReg.h @@ -249,10 +249,14 @@ extern "C" { // PCKTCTRL2 #define PCKT_FIXVARLEN_FIELD 0x01 #define PCKT_VARIABLE_LEN (1 << 0) +#define PCKT_FCS_TYPE_FIELD 0x20 +#define PCKT_FCS_TYPE_4_OCTET (0 << 5) +#define PCKT_FCS_TYPE_2_OCTET (1 << 5) // PCKTCTRL1 #define PCKT_CRCMODE_FIELD 0xE0 #define PCKT_CRCMODE_0X1021 (3 << 5) +#define PCKT_CRCMODE_0x04C11DB7 (5 << 5) #define PCKT_TXSOURCE_FIELD 0x0C #define PCKT_TXSOURCE_NORMAL (0 << 2) #define PCKT_WHITENING_FIELD 0x10 diff --git a/cores/arduino/mbed/components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/inc/tfm_spm_signal_defs.h b/cores/arduino/mbed/components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/inc/tfm_spm_signal_defs.h new file mode 100644 index 00000000..e41c52d0 --- /dev/null +++ b/cores/arduino/mbed/components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/inc/tfm_spm_signal_defs.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2018-2019, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + */ + +/******************************************************************************* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT. + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * Template Version 1.0 + * Generated by tools/psa/generate_partition_code.py Version 1.1 + ******************************************************************************/ + +#ifndef __TFM_SPM_SIGNAL_DEFS_H__ +#define __TFM_SPM_SIGNAL_DEFS_H__ + +/*************************** Service Partitions *******************************/ +/* ----------------------------------------------------------------------------- + * ATTEST_SRV Signals + * -------------------------------------------------------------------------- */ +#define PSA_ATTEST_GET_TOKEN_POS (4UL) +#define PSA_ATTEST_GET_TOKEN (1UL << PSA_ATTEST_GET_TOKEN_POS) +#define PSA_ATTEST_GET_TOKEN_SIZE_POS (5UL) +#define PSA_ATTEST_GET_TOKEN_SIZE (1UL << PSA_ATTEST_GET_TOKEN_SIZE_POS) +#define PSA_ATTEST_INJECT_KEY_POS (6UL) +#define PSA_ATTEST_INJECT_KEY (1UL << PSA_ATTEST_INJECT_KEY_POS) + +/* ----------------------------------------------------------------------------- + * CRYPTO_SRV Signals + * -------------------------------------------------------------------------- */ +#define PSA_CRYPTO_INIT_POS (4UL) +#define PSA_CRYPTO_INIT (1UL << PSA_CRYPTO_INIT_POS) +#define PSA_MAC_POS (5UL) +#define PSA_MAC (1UL << PSA_MAC_POS) +#define PSA_HASH_POS (6UL) +#define PSA_HASH (1UL << PSA_HASH_POS) +#define PSA_ASYMMETRIC_POS (7UL) +#define PSA_ASYMMETRIC (1UL << PSA_ASYMMETRIC_POS) +#define PSA_SYMMETRIC_POS (8UL) +#define PSA_SYMMETRIC (1UL << PSA_SYMMETRIC_POS) +#define PSA_AEAD_POS (9UL) +#define PSA_AEAD (1UL << PSA_AEAD_POS) +#define PSA_KEY_MNG_POS (10UL) +#define PSA_KEY_MNG (1UL << PSA_KEY_MNG_POS) +#define PSA_RNG_POS (11UL) +#define PSA_RNG (1UL << PSA_RNG_POS) +#define PSA_CRYPTO_FREE_POS (12UL) +#define PSA_CRYPTO_FREE (1UL << PSA_CRYPTO_FREE_POS) +#define PSA_KEY_DERIVATION_POS (13UL) +#define PSA_KEY_DERIVATION (1UL << PSA_KEY_DERIVATION_POS) +#define PSA_ENTROPY_INJECT_POS (14UL) +#define PSA_ENTROPY_INJECT (1UL << PSA_ENTROPY_INJECT_POS) + +/* ----------------------------------------------------------------------------- + * PLATFORM Signals + * -------------------------------------------------------------------------- */ +#define PSA_PLATFORM_LC_GET_MSK_POS (4UL) +#define PSA_PLATFORM_LC_GET_MSK (1UL << PSA_PLATFORM_LC_GET_MSK_POS) +#define PSA_PLATFORM_LC_SET_MSK_POS (5UL) +#define PSA_PLATFORM_LC_SET_MSK (1UL << PSA_PLATFORM_LC_SET_MSK_POS) +#define PSA_PLATFORM_SYSTEM_RESET_MSK_POS (6UL) +#define PSA_PLATFORM_SYSTEM_RESET_MSK (1UL << PSA_PLATFORM_SYSTEM_RESET_MSK_POS) + +/* ----------------------------------------------------------------------------- + * ITS Signals + * -------------------------------------------------------------------------- */ +#define PSA_ITS_GET_MSK_POS (4UL) +#define PSA_ITS_GET_MSK (1UL << PSA_ITS_GET_MSK_POS) +#define PSA_ITS_SET_MSK_POS (5UL) +#define PSA_ITS_SET_MSK (1UL << PSA_ITS_SET_MSK_POS) +#define PSA_ITS_INFO_MSK_POS (6UL) +#define PSA_ITS_INFO_MSK (1UL << PSA_ITS_INFO_MSK_POS) +#define PSA_ITS_REMOVE_MSK_POS (7UL) +#define PSA_ITS_REMOVE_MSK (1UL << PSA_ITS_REMOVE_MSK_POS) +#define PSA_ITS_RESET_MSK_POS (8UL) +#define PSA_ITS_RESET_MSK (1UL << PSA_ITS_RESET_MSK_POS) + +/*************************** Test Partitions **********************************/ +#ifdef USE_PSA_TEST_PARTITIONS + +#ifdef USE_CRYPTO_ACL_TEST +/* ----------------------------------------------------------------------------- + * CRYPTO_ACL_TEST Signals + * -------------------------------------------------------------------------- */ +#define CRYPTO_GENERATE_KEY_MSK_POS (4UL) +#define CRYPTO_GENERATE_KEY_MSK (1UL << CRYPTO_GENERATE_KEY_MSK_POS) +#define CRYPTO_OPEN_KEY_MSK_POS (5UL) +#define CRYPTO_OPEN_KEY_MSK (1UL << CRYPTO_OPEN_KEY_MSK_POS) +#define CRYPTO_CLOSE_KEY_MSK_POS (6UL) +#define CRYPTO_CLOSE_KEY_MSK (1UL << CRYPTO_CLOSE_KEY_MSK_POS) +#define CRYPTO_DESTROY_KEY_MSK_POS (7UL) +#define CRYPTO_DESTROY_KEY_MSK (1UL << CRYPTO_DESTROY_KEY_MSK_POS) +#define CRYPTO_GET_KEY_ATTRIBUTES_MSK_POS (8UL) +#define CRYPTO_GET_KEY_ATTRIBUTES_MSK (1UL << CRYPTO_GET_KEY_ATTRIBUTES_MSK_POS) +#define CRYPTO_IMPORT_KEY_MSK_POS (9UL) +#define CRYPTO_IMPORT_KEY_MSK (1UL << CRYPTO_IMPORT_KEY_MSK_POS) +#endif // USE_CRYPTO_ACL_TEST + +#ifdef USE_CLIENT_TESTS_PART1 +/* ----------------------------------------------------------------------------- + * CLIENT_TESTS_PART1 Signals + * -------------------------------------------------------------------------- */ +#define PART1_ROT_SRV1_MSK_POS (4UL) +#define PART1_ROT_SRV1_MSK (1UL << PART1_ROT_SRV1_MSK_POS) +#define DROP_CONN_MSK_POS (5UL) +#define DROP_CONN_MSK (1UL << DROP_CONN_MSK_POS) +#define SECURE_CLIENTS_ONLY_MSK_POS (6UL) +#define SECURE_CLIENTS_ONLY_MSK (1UL << SECURE_CLIENTS_ONLY_MSK_POS) +#endif // USE_CLIENT_TESTS_PART1 + +#ifdef USE_SERVER_TESTS_PART1 +/* ----------------------------------------------------------------------------- + * SERVER_TESTS_PART1 Signals + * -------------------------------------------------------------------------- */ +#define CONTROL_MSK_POS (4UL) +#define CONTROL_MSK (1UL << CONTROL_MSK_POS) +#define TEST_MSK_POS (5UL) +#define TEST_MSK (1UL << TEST_MSK_POS) +#endif // USE_SERVER_TESTS_PART1 + +#ifdef USE_SERVER_TESTS_PART2 +/* ----------------------------------------------------------------------------- + * SERVER_TESTS_PART2 Signals + * -------------------------------------------------------------------------- */ +#define ROT_SRV_REVERSE_MSK_POS (4UL) +#define ROT_SRV_REVERSE_MSK (1UL << ROT_SRV_REVERSE_MSK_POS) +#define ROT_SRV_DB_TST_MSK_POS (5UL) +#define ROT_SRV_DB_TST_MSK (1UL << ROT_SRV_DB_TST_MSK_POS) +#endif // USE_SERVER_TESTS_PART2 + +#ifdef USE_SMOKE_TESTS_PART1 +/* ----------------------------------------------------------------------------- + * SMOKE_TESTS_PART1 Signals + * -------------------------------------------------------------------------- */ +#define ROT_SRV1_MSK_POS (4UL) +#define ROT_SRV1_MSK (1UL << ROT_SRV1_MSK_POS) +#endif // USE_SMOKE_TESTS_PART1 + +#endif // USE_PSA_TEST_PARTITIONS + +#endif // __TFM_SPM_SIGNAL_DEFS_H__ diff --git a/cores/arduino/mbed/components/TARGET_PSA/services/inc/autogen_sid.h b/cores/arduino/mbed/components/TARGET_PSA/services/inc/autogen_sid.h new file mode 100644 index 00000000..c4fecf5c --- /dev/null +++ b/cores/arduino/mbed/components/TARGET_PSA/services/inc/autogen_sid.h @@ -0,0 +1,110 @@ +/* Copyright (c) 2019 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +/******************************************************************************* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT. + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * Template Version 1.0 + * Generated by tools/psa/generate_partition_code.py Version 1.1 + ******************************************************************************/ + +/****************** Service Partitions ****************************************/ + +/* ----------------------------------------------------------------------------- + * ATTEST_SRV Service IDs + * -------------------------------------------------------------------------- */ + +#define PSA_ATTEST_GET_TOKEN_ID 0x00000F10 +#define PSA_ATTEST_GET_TOKEN_SIZE_ID 0x00000F11 +#define PSA_ATTEST_INJECT_KEY_ID 0x00000F12 + +/* ----------------------------------------------------------------------------- + * CRYPTO_SRV Service IDs + * -------------------------------------------------------------------------- */ + +#define PSA_CRYPTO_INIT_ID 0x00000F00 +#define PSA_MAC_ID 0x00000F01 +#define PSA_HASH_ID 0x00000F02 +#define PSA_ASYMMETRIC_ID 0x00000F03 +#define PSA_SYMMETRIC_ID 0x00000F04 +#define PSA_AEAD_ID 0x00000F05 +#define PSA_KEY_MNG_ID 0x00000F06 +#define PSA_RNG_ID 0x00000F07 +#define PSA_CRYPTO_FREE_ID 0x00000F08 +#define PSA_KEY_DERIVATION_ID 0x00000F09 +#define PSA_ENTROPY_ID 0x00000F0A + +/* ----------------------------------------------------------------------------- + * PLATFORM Service IDs + * -------------------------------------------------------------------------- */ + +#define PSA_PLATFORM_LC_GET 0x00011000 +#define PSA_PLATFORM_LC_SET 0x00011001 +#define PSA_PLATFORM_SYSTEM_RESET 0x00011002 + +/* ----------------------------------------------------------------------------- + * ITS Service IDs + * -------------------------------------------------------------------------- */ + +#define PSA_ITS_GET 0x00011A00 +#define PSA_ITS_SET 0x00011A01 +#define PSA_ITS_INFO 0x00011A02 +#define PSA_ITS_REMOVE 0x00011A03 +#define PSA_ITS_RESET 0x00011A04 + +/****************** Test Partitions *******************************************/ + +/* ----------------------------------------------------------------------------- + * CRYPTO_ACL_TEST Service IDs + * -------------------------------------------------------------------------- */ + +#define CRYPTO_GENERATE_KEY 0x00000201 +#define CRYPTO_OPEN_KEY 0x00000202 +#define CRYPTO_CLOSE_KEY 0x00000203 +#define CRYPTO_DESTROY_KEY 0x00000205 +#define CRYPTO_GET_KEY_ATTRIBUTES 0x00000206 +#define CRYPTO_IMPORT_KEY 0x00000208 + +/* ----------------------------------------------------------------------------- + * CLIENT_TESTS_PART1 Service IDs + * -------------------------------------------------------------------------- */ + +#define CLIENT_TESTS_PART1_ROT_SRV1 0x00001A05 +#define CLIENT_TESTS_PART1_DROP_CONN 0x00001A06 +#define CLIENT_TESTS_PART1_SECURE_CLIENTS_ONLY 0x00001A07 + +/* ----------------------------------------------------------------------------- + * SERVER_TESTS_PART1 Service IDs + * -------------------------------------------------------------------------- */ + +#define SERVER_TESTS_PART1_CONTROL 0x00001A01 +#define SERVER_TESTS_PART1_TEST 0x00001A02 + +/* ----------------------------------------------------------------------------- + * SERVER_TESTS_PART2 Service IDs + * -------------------------------------------------------------------------- */ + +#define SERVER_TESTS_PART2_ROT_SRV_REVERSE 0x00001A03 +#define SERVER_TESTS_PART2_ROT_SRV_DB_TST 0x00001A04 + +/* ----------------------------------------------------------------------------- + * SMOKE_TESTS_PART1 Service IDs + * -------------------------------------------------------------------------- */ + +#define SMOKE_TESTS_PART1_ROT_SRV1 0x00001A00 + diff --git a/cores/arduino/mbed/components/TARGET_PSA/services/inc/mbed_spm_partitions.h b/cores/arduino/mbed/components/TARGET_PSA/services/inc/mbed_spm_partitions.h new file mode 100644 index 00000000..5d9c137f --- /dev/null +++ b/cores/arduino/mbed/components/TARGET_PSA/services/inc/mbed_spm_partitions.h @@ -0,0 +1,307 @@ +/* Copyright (c) 2017-2019 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +/******************************************************************************* + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT. + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + * Template Version 1.0 + * Generated by tools/psa/generate_partition_code.py Version 1.1 + ******************************************************************************/ + +#ifndef __MBED_SPM_PARTITIONS_H___ +#define __MBED_SPM_PARTITIONS_H___ + + +/****************** Common definitions ****************************************/ + +/* PSA reserved event flags */ +#define PSA_RESERVED1_POS (1UL) +#define PSA_RESERVED1_MSK (1UL << PSA_RESERVED1_POS) + +#define PSA_RESERVED2_POS (2UL) +#define PSA_RESERVED2_MSK (1UL << PSA_RESERVED2_POS) + +/****************** Service Partitions ****************************************/ + +/* ----------------------------------------------------------------------------- + * ATTEST_SRV defines + * -------------------------------------------------------------------------- */ +#define ATTEST_SRV_ID 37 + +#define ATTEST_SRV_ROT_SRV_COUNT (3UL) +#define ATTEST_SRV_EXT_ROT_SRV_COUNT (7UL) + + +#define ATTEST_SRV_WAIT_ANY_IRQ_MSK (0) + +#define PSA_ATTEST_GET_TOKEN_POS (4UL) +#define PSA_ATTEST_GET_TOKEN (1UL << PSA_ATTEST_GET_TOKEN_POS) +#define PSA_ATTEST_GET_TOKEN_SIZE_POS (5UL) +#define PSA_ATTEST_GET_TOKEN_SIZE (1UL << PSA_ATTEST_GET_TOKEN_SIZE_POS) +#define PSA_ATTEST_INJECT_KEY_POS (6UL) +#define PSA_ATTEST_INJECT_KEY (1UL << PSA_ATTEST_INJECT_KEY_POS) + +#define ATTEST_SRV_WAIT_ANY_SID_MSK (\ + PSA_ATTEST_GET_TOKEN | \ + PSA_ATTEST_GET_TOKEN_SIZE | \ + PSA_ATTEST_INJECT_KEY) + + +/* ----------------------------------------------------------------------------- + * CRYPTO_SRV defines + * -------------------------------------------------------------------------- */ +#define CRYPTO_SRV_ID 35 + +#define CRYPTO_SRV_ROT_SRV_COUNT (11UL) +#define CRYPTO_SRV_EXT_ROT_SRV_COUNT (4UL) + + +#define CRYPTO_SRV_WAIT_ANY_IRQ_MSK (0) + +#define PSA_CRYPTO_INIT_POS (4UL) +#define PSA_CRYPTO_INIT (1UL << PSA_CRYPTO_INIT_POS) +#define PSA_MAC_POS (5UL) +#define PSA_MAC (1UL << PSA_MAC_POS) +#define PSA_HASH_POS (6UL) +#define PSA_HASH (1UL << PSA_HASH_POS) +#define PSA_ASYMMETRIC_POS (7UL) +#define PSA_ASYMMETRIC (1UL << PSA_ASYMMETRIC_POS) +#define PSA_SYMMETRIC_POS (8UL) +#define PSA_SYMMETRIC (1UL << PSA_SYMMETRIC_POS) +#define PSA_AEAD_POS (9UL) +#define PSA_AEAD (1UL << PSA_AEAD_POS) +#define PSA_KEY_MNG_POS (10UL) +#define PSA_KEY_MNG (1UL << PSA_KEY_MNG_POS) +#define PSA_RNG_POS (11UL) +#define PSA_RNG (1UL << PSA_RNG_POS) +#define PSA_CRYPTO_FREE_POS (12UL) +#define PSA_CRYPTO_FREE (1UL << PSA_CRYPTO_FREE_POS) +#define PSA_KEY_DERIVATION_POS (13UL) +#define PSA_KEY_DERIVATION (1UL << PSA_KEY_DERIVATION_POS) +#define PSA_ENTROPY_INJECT_POS (14UL) +#define PSA_ENTROPY_INJECT (1UL << PSA_ENTROPY_INJECT_POS) + +#define CRYPTO_SRV_WAIT_ANY_SID_MSK (\ + PSA_CRYPTO_INIT | \ + PSA_MAC | \ + PSA_HASH | \ + PSA_ASYMMETRIC | \ + PSA_SYMMETRIC | \ + PSA_AEAD | \ + PSA_KEY_MNG | \ + PSA_RNG | \ + PSA_CRYPTO_FREE | \ + PSA_KEY_DERIVATION | \ + PSA_ENTROPY_INJECT) + + +/* ----------------------------------------------------------------------------- + * PLATFORM defines + * -------------------------------------------------------------------------- */ +#define PLATFORM_ID 8 + +#define PLATFORM_ROT_SRV_COUNT (3UL) +#define PLATFORM_EXT_ROT_SRV_COUNT (1UL) + + +#define PLATFORM_WAIT_ANY_IRQ_MSK (0) + +#define PSA_PLATFORM_LC_GET_MSK_POS (4UL) +#define PSA_PLATFORM_LC_GET_MSK (1UL << PSA_PLATFORM_LC_GET_MSK_POS) +#define PSA_PLATFORM_LC_SET_MSK_POS (5UL) +#define PSA_PLATFORM_LC_SET_MSK (1UL << PSA_PLATFORM_LC_SET_MSK_POS) +#define PSA_PLATFORM_SYSTEM_RESET_MSK_POS (6UL) +#define PSA_PLATFORM_SYSTEM_RESET_MSK (1UL << PSA_PLATFORM_SYSTEM_RESET_MSK_POS) + +#define PLATFORM_WAIT_ANY_SID_MSK (\ + PSA_PLATFORM_LC_GET_MSK | \ + PSA_PLATFORM_LC_SET_MSK | \ + PSA_PLATFORM_SYSTEM_RESET_MSK) + + +/* ----------------------------------------------------------------------------- + * ITS defines + * -------------------------------------------------------------------------- */ +#define ITS_ID 10 + +#define ITS_ROT_SRV_COUNT (5UL) +#define ITS_EXT_ROT_SRV_COUNT (0UL) + + +#define ITS_WAIT_ANY_IRQ_MSK (0) + +#define PSA_ITS_GET_MSK_POS (4UL) +#define PSA_ITS_GET_MSK (1UL << PSA_ITS_GET_MSK_POS) +#define PSA_ITS_SET_MSK_POS (5UL) +#define PSA_ITS_SET_MSK (1UL << PSA_ITS_SET_MSK_POS) +#define PSA_ITS_INFO_MSK_POS (6UL) +#define PSA_ITS_INFO_MSK (1UL << PSA_ITS_INFO_MSK_POS) +#define PSA_ITS_REMOVE_MSK_POS (7UL) +#define PSA_ITS_REMOVE_MSK (1UL << PSA_ITS_REMOVE_MSK_POS) +#define PSA_ITS_RESET_MSK_POS (8UL) +#define PSA_ITS_RESET_MSK (1UL << PSA_ITS_RESET_MSK_POS) + +#define ITS_WAIT_ANY_SID_MSK (\ + PSA_ITS_GET_MSK | \ + PSA_ITS_SET_MSK | \ + PSA_ITS_INFO_MSK | \ + PSA_ITS_REMOVE_MSK | \ + PSA_ITS_RESET_MSK) + + + +/****************** Test Partitions *******************************************/ + +#ifdef USE_PSA_TEST_PARTITIONS + +#ifdef USE_CRYPTO_ACL_TEST +/* ----------------------------------------------------------------------------- + * CRYPTO_ACL_TEST defines + * -------------------------------------------------------------------------- */ +#define CRYPTO_ACL_TEST_ID 128 + +#define CRYPTO_ACL_TEST_ROT_SRV_COUNT (6UL) +#define CRYPTO_ACL_TEST_EXT_ROT_SRV_COUNT (1UL) + + +#define CRYPTO_ACL_TEST_WAIT_ANY_IRQ_MSK (0) + +#define CRYPTO_GENERATE_KEY_MSK_POS (4UL) +#define CRYPTO_GENERATE_KEY_MSK (1UL << CRYPTO_GENERATE_KEY_MSK_POS) +#define CRYPTO_OPEN_KEY_MSK_POS (5UL) +#define CRYPTO_OPEN_KEY_MSK (1UL << CRYPTO_OPEN_KEY_MSK_POS) +#define CRYPTO_CLOSE_KEY_MSK_POS (6UL) +#define CRYPTO_CLOSE_KEY_MSK (1UL << CRYPTO_CLOSE_KEY_MSK_POS) +#define CRYPTO_DESTROY_KEY_MSK_POS (7UL) +#define CRYPTO_DESTROY_KEY_MSK (1UL << CRYPTO_DESTROY_KEY_MSK_POS) +#define CRYPTO_GET_KEY_ATTRIBUTES_MSK_POS (8UL) +#define CRYPTO_GET_KEY_ATTRIBUTES_MSK (1UL << CRYPTO_GET_KEY_ATTRIBUTES_MSK_POS) +#define CRYPTO_IMPORT_KEY_MSK_POS (9UL) +#define CRYPTO_IMPORT_KEY_MSK (1UL << CRYPTO_IMPORT_KEY_MSK_POS) + +#define CRYPTO_ACL_TEST_WAIT_ANY_SID_MSK (\ + CRYPTO_GENERATE_KEY_MSK | \ + CRYPTO_OPEN_KEY_MSK | \ + CRYPTO_CLOSE_KEY_MSK | \ + CRYPTO_DESTROY_KEY_MSK | \ + CRYPTO_GET_KEY_ATTRIBUTES_MSK | \ + CRYPTO_IMPORT_KEY_MSK) + + +#endif // USE_CRYPTO_ACL_TEST + +#ifdef USE_CLIENT_TESTS_PART1 +/* ----------------------------------------------------------------------------- + * CLIENT_TESTS_PART1 defines + * -------------------------------------------------------------------------- */ +#define CLIENT_TESTS_PART1_ID 1 + +#define CLIENT_TESTS_PART1_ROT_SRV_COUNT (3UL) +#define CLIENT_TESTS_PART1_EXT_ROT_SRV_COUNT (0UL) + + +#define CLIENT_TESTS_PART1_WAIT_ANY_IRQ_MSK (0) + +#define PART1_ROT_SRV1_MSK_POS (4UL) +#define PART1_ROT_SRV1_MSK (1UL << PART1_ROT_SRV1_MSK_POS) +#define DROP_CONN_MSK_POS (5UL) +#define DROP_CONN_MSK (1UL << DROP_CONN_MSK_POS) +#define SECURE_CLIENTS_ONLY_MSK_POS (6UL) +#define SECURE_CLIENTS_ONLY_MSK (1UL << SECURE_CLIENTS_ONLY_MSK_POS) + +#define CLIENT_TESTS_PART1_WAIT_ANY_SID_MSK (\ + PART1_ROT_SRV1_MSK | \ + DROP_CONN_MSK | \ + SECURE_CLIENTS_ONLY_MSK) + + +#endif // USE_CLIENT_TESTS_PART1 + +#ifdef USE_SERVER_TESTS_PART1 +/* ----------------------------------------------------------------------------- + * SERVER_TESTS_PART1 defines + * -------------------------------------------------------------------------- */ +#define SERVER_TESTS_PART1_ID 2 + +#define SERVER_TESTS_PART1_ROT_SRV_COUNT (2UL) +#define SERVER_TESTS_PART1_EXT_ROT_SRV_COUNT (2UL) + + +#define SERVER_TESTS_PART1_WAIT_ANY_IRQ_MSK (0) + +#define CONTROL_MSK_POS (4UL) +#define CONTROL_MSK (1UL << CONTROL_MSK_POS) +#define TEST_MSK_POS (5UL) +#define TEST_MSK (1UL << TEST_MSK_POS) + +#define SERVER_TESTS_PART1_WAIT_ANY_SID_MSK (\ + CONTROL_MSK | \ + TEST_MSK) + + +#endif // USE_SERVER_TESTS_PART1 + +#ifdef USE_SERVER_TESTS_PART2 +/* ----------------------------------------------------------------------------- + * SERVER_TESTS_PART2 defines + * -------------------------------------------------------------------------- */ +#define SERVER_TESTS_PART2_ID 3 + +#define SERVER_TESTS_PART2_ROT_SRV_COUNT (2UL) +#define SERVER_TESTS_PART2_EXT_ROT_SRV_COUNT (0UL) + + +#define SERVER_TESTS_PART2_WAIT_ANY_IRQ_MSK (0) + +#define ROT_SRV_REVERSE_MSK_POS (4UL) +#define ROT_SRV_REVERSE_MSK (1UL << ROT_SRV_REVERSE_MSK_POS) +#define ROT_SRV_DB_TST_MSK_POS (5UL) +#define ROT_SRV_DB_TST_MSK (1UL << ROT_SRV_DB_TST_MSK_POS) + +#define SERVER_TESTS_PART2_WAIT_ANY_SID_MSK (\ + ROT_SRV_REVERSE_MSK | \ + ROT_SRV_DB_TST_MSK) + + +#endif // USE_SERVER_TESTS_PART2 + +#ifdef USE_SMOKE_TESTS_PART1 +/* ----------------------------------------------------------------------------- + * SMOKE_TESTS_PART1 defines + * -------------------------------------------------------------------------- */ +#define SMOKE_TESTS_PART1_ID 4 + +#define SMOKE_TESTS_PART1_ROT_SRV_COUNT (1UL) +#define SMOKE_TESTS_PART1_EXT_ROT_SRV_COUNT (0UL) + + +#define SMOKE_TESTS_PART1_WAIT_ANY_IRQ_MSK (0) + +#define ROT_SRV1_MSK_POS (4UL) +#define ROT_SRV1_MSK (1UL << ROT_SRV1_MSK_POS) + +#define SMOKE_TESTS_PART1_WAIT_ANY_SID_MSK (\ + ROT_SRV1_MSK) + + +#endif // USE_SMOKE_TESTS_PART1 + + +#endif // USE_PSA_TEST_PARTITIONS + +#endif // __MBED_SPM_PARTITIONS_H___ diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h index 9d0e7dbe..9bb4d825 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_DATAFLASH/DataFlashBlockDevice.h @@ -17,8 +17,11 @@ #ifndef MBED_DATAFLASH_BLOCK_DEVICE_H #define MBED_DATAFLASH_BLOCK_DEVICE_H -#include -#include "BlockDevice.h" +#include "platform/PlatformMutex.h" +#include "PinNames.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "drivers/SPI.h" +#include "drivers/DigitalOut.h" /** BlockDevice for DataFlash flash devices diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h index 5020f183..ec64c506 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_FLASHIAP/FlashIAPBlockDevice.h @@ -20,7 +20,7 @@ #if DEVICE_FLASH #include "FlashIAP.h" -#include "BlockDevice.h" +#include "features/storage/blockdevice/BlockDevice.h" #include "platform/mbed_toolchain.h" /** BlockDevice using the FlashIAP API diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h index dbaf71b5..4ba28667 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_I2CEE/I2CEEBlockDevice.h @@ -16,8 +16,8 @@ #ifndef MBED_I2CEEPROM_BLOCK_DEVICE_H #define MBED_I2CEEPROM_BLOCK_DEVICE_H -#include "BlockDevice.h" -#include "I2C.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "drivers/I2C.h" /** BlockDevice for I2C based flash device such as * Microchip's 24LC or ATMEL's AT24C ranges diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h index b009bd97..3a3dc712 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h @@ -16,8 +16,8 @@ #ifndef MBED_QSPIF_BLOCK_DEVICE_H #define MBED_QSPIF_BLOCK_DEVICE_H -#include "QSPI.h" -#include "BlockDevice.h" +#include "drivers/QSPI.h" +#include "features/storage/blockdevice/BlockDevice.h" /** Enum qspif standard error codes * @@ -27,11 +27,11 @@ enum qspif_bd_error { QSPIF_BD_ERROR_OK = 0, /*!< no error */ QSPIF_BD_ERROR_DEVICE_ERROR = BD_ERROR_DEVICE_ERROR, /*!< device specific error -4001 */ QSPIF_BD_ERROR_PARSING_FAILED = -4002, /* SFDP Parsing failed */ - QSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */ + QSPIF_BD_ERROR_READY_FAILED = -4003, /* Wait for Mem Ready failed */ QSPIF_BD_ERROR_WREN_FAILED = -4004, /* Write Enable Failed */ QSPIF_BD_ERROR_INVALID_ERASE_PARAMS = -4005, /* Erase command not on sector aligned addresses or exceeds device size */ - QSPIF_BD_ERROR_DEVICE_NOT_UNIQE = -4006, /* Only one instance per csel is allowed */ - QSPIF_BD_ERROR_DEVICE_MAX_EXCEED = -4007 /* Max active QSPIF devices exceeded */ + QSPIF_BD_ERROR_DEVICE_NOT_UNIQUE = -4006, /* Only one instance per csel is allowed */ + QSPIF_BD_ERROR_DEVICE_MAX_EXCEED = -4007 /* Max active QSPIF devices exceeded */ }; /** Enum qspif polarity mode @@ -234,33 +234,40 @@ class QSPIFBlockDevice : public mbed::BlockDevice { /********************************/ /* Calls to QSPI Driver APIs */ /********************************/ - // Send Program => Write command to Driver - qspi_status_t _qspi_send_program_command(unsigned int prog_instruction, const void *buffer, mbed::bd_addr_t addr, - mbed::bd_size_t *size); + // Send Program/Write command to Driver + qspi_status_t _qspi_send_program_command(mbed::qspi_inst_t prog_instruction, const void *buffer, + mbed::bd_addr_t addr, mbed::bd_size_t *size); // Send Read command to Driver - qspi_status_t _qspi_send_read_command(unsigned int read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size); + qspi_status_t _qspi_send_read_command(mbed::qspi_inst_t read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size); // Send Erase Instruction using command_transfer command to Driver - qspi_status_t _qspi_send_erase_command(unsigned int erase_instruction, mbed::bd_addr_t addr, mbed::bd_size_t size); + qspi_status_t _qspi_send_erase_command(mbed::qspi_inst_t erase_instruction, mbed::bd_addr_t addr, mbed::bd_size_t size); // Send Generic command_transfer command to Driver - qspi_status_t _qspi_send_general_command(unsigned int instruction_int, mbed::bd_addr_t addr, const char *tx_buffer, - size_t tx_length, const char *rx_buffer, size_t rx_length); + qspi_status_t _qspi_send_general_command(mbed::qspi_inst_t instruction_int, mbed::bd_addr_t addr, const char *tx_buffer, + mbed::bd_size_t tx_length, const char *rx_buffer, mbed::bd_size_t rx_length); - // Send Bus configure_format command to Driver - qspi_status_t _qspi_configure_format(qspi_bus_width_t inst_width, qspi_bus_width_t address_width, - qspi_address_size_t address_size, qspi_bus_width_t alt_width, qspi_alt_size_t alt_size, qspi_bus_width_t data_width, - int dummy_cycles); + // Send command to read from the SFDP table + qspi_status_t _qspi_send_read_sfdp_command(mbed::bd_addr_t addr, void *rx_buffer, mbed::bd_size_t rx_length); + + // Read the contents of status registers 1 and 2 into a buffer (buffer must have a length of 2) + qspi_status_t _qspi_read_status_registers(uint8_t *reg_buffer); + + // Set the contents of status registers 1 and 2 from a buffer (buffer must have a length of 2) + qspi_status_t _qspi_write_status_registers(uint8_t *reg_buffer); // Send set_frequency command to Driver qspi_status_t _qspi_set_frequency(int freq); + // Update the 4-byte addressing extension register with the MSB of the address if it is in use + qspi_status_t _qspi_update_4byte_ext_addr_reg(bd_addr_t addr); + /*********************************/ /* Flash Configuration Functions */ /*********************************/ - // Soft Reset Flash Memory - int _reset_flash_mem(); + // Clear the device's block protection + int _clear_block_protection(); // Configure Write Enable in Status Register int _set_write_enable(); @@ -269,7 +276,7 @@ class QSPIFBlockDevice : public mbed::BlockDevice { bool _is_mem_ready(); // Enable Fast Mode - for flash chips with low power default - int _enable_fast_mdoe(); + int _enable_fast_mode(); /****************************************/ /* SFDP Detection and Parsing Functions */ @@ -281,26 +288,33 @@ class QSPIFBlockDevice : public mbed::BlockDevice { // Parse and Detect required Basic Parameters from Table int _sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size); - // Parse and read information required by Regions Secotr Map + // Parse and read information required by Regions Sector Map int _sfdp_parse_sector_map_table(uint32_t sector_map_table_addr, size_t sector_map_table_size); + // Detect the soft reset protocol and reset - returns error if soft reset is not supported + int _sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param_table_ptr); + // Detect fastest read Bus mode supported by device - int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size, bool &set_quad_enable, - bool &is_qpi_mode, unsigned int &read_inst); + int _sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table_ptr, int basic_param_table_size, + bool &set_quad_enable, bool &is_qpi_mode); // Enable Quad mode if supported (1-1-4, 1-4-4, 4-4-4 bus modes) int _sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr); - // Enable QPI mode (4-4-4) is supported + // Enable QPI mode (4-4-4) int _sfdp_set_qpi_enabled(uint8_t *basic_param_table_ptr); // Set Page size for program int _sfdp_detect_page_size(uint8_t *basic_param_table_ptr, int basic_param_table_size); // Detect all supported erase types - int _sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param_table_ptr, int basic_param_table_size, - unsigned int &erase4k_inst, - unsigned int *erase_type_inst_arr, unsigned int *erase_type_size_arr); + int _sfdp_detect_erase_types_inst_and_size(uint8_t *basic_param_table_ptr, int basic_param_table_size); + + // Detect 4-byte addressing mode and enable it if supported + int _sfdp_detect_and_enable_4byte_addressing(uint8_t *basic_param_table_ptr, int basic_param_table_size); + + // Query vendor ID and handle special behavior that isn't covered by SFDP data + int _handle_vendor_quirks(); /***********************/ /* Utilities Functions */ @@ -313,6 +327,11 @@ class QSPIFBlockDevice : public mbed::BlockDevice { int _utils_iterate_next_largest_erase_type(uint8_t &bitfield, int size, int offset, int boundry); private: + enum qspif_clear_protection_method_t { + QSPIF_BP_ULBPR, // Issue global protection unlock instruction + QSPIF_BP_CLEAR_SR, // Clear protection bits in status register 1 + }; + // QSPI Driver Object mbed::QSPI _qspi; @@ -331,17 +350,32 @@ class QSPIFBlockDevice : public mbed::BlockDevice { PlatformMutex _mutex; // Command Instructions - unsigned int _read_instruction; - unsigned int _prog_instruction; - unsigned int _erase_instruction; - unsigned int _erase4k_inst; // Legacy 4K erase instruction (default 0x20h) - unsigned int _write_register_inst; // Write status/config register instruction may vary between chips - unsigned int _read_register_inst; // Read status/config register instruction may vary between chips + mbed::qspi_inst_t _read_instruction; + mbed::qspi_inst_t _legacy_erase_instruction; + + // Status register write/read instructions + unsigned int _num_status_registers; + mbed::qspi_inst_t _write_status_reg_2_inst; + mbed::qspi_inst_t _read_status_reg_2_inst; // If three registers, this instruction reads the latter two + + // Attempt to enable 4-byte addressing. True by default, but may be disabled for some vendors + bool _attempt_4_byte_addressing; + // 4-byte addressing extension register write instruction + mbed::qspi_inst_t _4byte_msb_reg_write_inst; // Up To 4 Erase Types are supported by SFDP (each with its own command Instruction and Size) - unsigned int _erase_type_inst_arr[MAX_NUM_OF_ERASE_TYPES]; + mbed::qspi_inst_t _erase_type_inst_arr[MAX_NUM_OF_ERASE_TYPES]; unsigned int _erase_type_size_arr[MAX_NUM_OF_ERASE_TYPES]; + // Quad mode enable status register and bit + int _quad_enable_register_idx; + int _quad_enable_bit; + + bool _needs_fast_mode; + + // Clear block protection + qspif_clear_protection_method_t _clear_protection_method; + // Sector Regions Map int _regions_count; //number of regions int _region_size_bytes[QSPIF_MAX_REGIONS]; //regions size in bytes @@ -357,9 +391,11 @@ class QSPIFBlockDevice : public mbed::BlockDevice { // Bus speed configuration qspi_bus_width_t _inst_width; //Bus width for Instruction phase qspi_bus_width_t _address_width; //Bus width for Address phase - qspi_address_size_t _address_size; // number of bytes for address + qspi_address_size_t _address_size; //Number of bits for address + qspi_alt_size_t _alt_size; //Number of bits for alt + bool _alt_enabled; //Whether alt is enabled + uint8_t _dummy_cycles; //Number of Dummy cycles required by Current Bus Mode qspi_bus_width_t _data_width; //Bus width for Data phase - int _dummy_and_mode_cycles; // Number of Dummy and Mode Bits required by Current Bus Mode uint32_t _init_ref_count; bool _is_initialized; diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h index f7dda1fe..53bf7d83 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_RSPIF/SPIFReducedBlockDevice.h @@ -16,9 +16,9 @@ #ifndef MBED_RSPIF_BLOCK_DEVICE_H #define MBED_RSPIF_BLOCK_DEVICE_H -#include "SPI.h" -#include "DigitalOut.h" -#include "BlockDevice.h" +#include "drivers/SPI.h" +#include "drivers/DigitalOut.h" +#include "features/storage/blockdevice/BlockDevice.h" /** Reduced BlockDevice for SPI based flash devices * *Should only be used by Boot Loader* diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h index 0a191941..8c15d934 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SD/SDBlockDevice.h @@ -20,8 +20,8 @@ /* If the target has no SPI support, then SD Card is not supported. */ #if DEVICE_SPI -#include "BlockDevice.h" -#include "drivers/SPI.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "drivers/SPIMaster.h" #include "drivers/Timer.h" #include "drivers/MbedCRC.h" #include "drivers/DigitalOut.h" diff --git a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h index c7ab3b39..821de04e 100644 --- a/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h +++ b/cores/arduino/mbed/components/storage/blockdevice/COMPONENT_SPIF/SPIFBlockDevice.h @@ -17,9 +17,9 @@ #define MBED_SPIF_BLOCK_DEVICE_H #include "platform/SingletonPtr.h" -#include "SPI.h" -#include "DigitalOut.h" -#include "BlockDevice.h" +#include "drivers/SPI.h" +#include "drivers/DigitalOut.h" +#include "features/storage/blockdevice/BlockDevice.h" /** Enum spif standard error codes * diff --git a/cores/arduino/mbed/drivers/AnalogIn.h b/cores/arduino/mbed/drivers/AnalogIn.h index 60637146..6f884920 100644 --- a/cores/arduino/mbed/drivers/AnalogIn.h +++ b/cores/arduino/mbed/drivers/AnalogIn.h @@ -28,7 +28,7 @@ namespace mbed { /** \defgroup mbed-os-public Public API */ -/** \addtogroup drivers-public-api Drivers +/** \defgroup drivers-public-api Drivers * \ingroup mbed-os-public */ diff --git a/cores/arduino/mbed/drivers/AnalogOut.h b/cores/arduino/mbed/drivers/AnalogOut.h index fee78fd9..2eaabefb 100644 --- a/cores/arduino/mbed/drivers/AnalogOut.h +++ b/cores/arduino/mbed/drivers/AnalogOut.h @@ -25,8 +25,6 @@ #include "platform/PlatformMutex.h" namespace mbed { -/** \addtogroup drivers-public-api */ - /** * \defgroup drivers_AnalogOut AnalogOut class * \ingroup drivers-public-api-gpio diff --git a/cores/arduino/mbed/drivers/Ethernet.h b/cores/arduino/mbed/drivers/Ethernet.h index e14be3a1..b1eb9c3e 100644 --- a/cores/arduino/mbed/drivers/Ethernet.h +++ b/cores/arduino/mbed/drivers/Ethernet.h @@ -23,9 +23,10 @@ #if DEVICE_ETHERNET || defined(DOXYGEN_ONLY) namespace mbed { -/** \ingroup mbed-os-public */ + /** \addtogroup drivers-public-api */ /** @{*/ + /** * \defgroup drivers_Ethernet Ethernet class * @{ diff --git a/cores/arduino/mbed/drivers/FlashIAP.h b/cores/arduino/mbed/drivers/FlashIAP.h index fdcda768..8797a34f 100644 --- a/cores/arduino/mbed/drivers/FlashIAP.h +++ b/cores/arduino/mbed/drivers/FlashIAP.h @@ -49,9 +49,9 @@ extern uint32_t Load$$LR$$LR_IROM1$$Limit[]; namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup drivers-public-api */ /** @{*/ + /** * \defgroup drivers_FlashIAP FlashIAP class * @{ @@ -63,8 +63,10 @@ namespace mbed { */ class FlashIAP : private NonCopyable { public: - FlashIAP(); - ~FlashIAP(); + constexpr FlashIAP() : _flash(), _page_buf(nullptr) + { + + } /** Initialize a flash IAP device * diff --git a/cores/arduino/mbed/drivers/I2CSlave.h b/cores/arduino/mbed/drivers/I2CSlave.h index e2d123a9..000d480f 100644 --- a/cores/arduino/mbed/drivers/I2CSlave.h +++ b/cores/arduino/mbed/drivers/I2CSlave.h @@ -25,7 +25,7 @@ namespace mbed { /** - * \addtogroup drivers_I2CSlave I2CSlave class + * \defgroup drivers_I2CSlave I2CSlave class * \ingroup drivers-public-api-i2c * @{ */ diff --git a/cores/arduino/mbed/drivers/LowPowerTimeout.h b/cores/arduino/mbed/drivers/LowPowerTimeout.h index 08137329..91c60b7c 100644 --- a/cores/arduino/mbed/drivers/LowPowerTimeout.h +++ b/cores/arduino/mbed/drivers/LowPowerTimeout.h @@ -27,7 +27,7 @@ namespace mbed { /** - * \addtogroup drivers_LowPowerTimeout LowPowerTimeout class + * \defgroup drivers_LowPowerTimeout LowPowerTimeout class * \ingroup drivers-public-api-ticker * @{ */ diff --git a/cores/arduino/mbed/drivers/LowPowerTimer.h b/cores/arduino/mbed/drivers/LowPowerTimer.h index df886c75..43560362 100644 --- a/cores/arduino/mbed/drivers/LowPowerTimer.h +++ b/cores/arduino/mbed/drivers/LowPowerTimer.h @@ -27,7 +27,7 @@ namespace mbed { /** - * \addtogroup drivers_LowPowerTimer LowPowerTimer class + * \defgroup drivers_LowPowerTimer LowPowerTimer class * \ingroup drivers-public-api-ticker * @{ */ diff --git a/cores/arduino/mbed/drivers/MbedCRC.h b/cores/arduino/mbed/drivers/MbedCRC.h index 18ac97ab..86d1ddd3 100644 --- a/cores/arduino/mbed/drivers/MbedCRC.h +++ b/cores/arduino/mbed/drivers/MbedCRC.h @@ -40,7 +40,6 @@ but we check for ( width < 8) before performing shift, so it should not be an is #endif namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup drivers-public-api */ /** @{*/ /** @@ -515,22 +514,19 @@ class MbedCRC { MBED_STATIC_ASSERT(width <= 32, "Max 32-bit CRC supported"); #if DEVICE_CRC - if (POLY_32BIT_REV_ANSI == polynomial) { - _crc_table = (uint32_t *)Table_CRC_32bit_Rev_ANSI; - _mode = TABLE; - return; - } - crc_mbed_config_t config; - config.polynomial = polynomial; - config.width = width; - config.initial_xor = _initial_value; - config.final_xor = _final_xor; - config.reflect_in = _reflect_data; - config.reflect_out = _reflect_remainder; - - if (hal_crc_is_supported(&config)) { - _mode = HARDWARE; - return; + if (POLY_32BIT_REV_ANSI != polynomial) { + crc_mbed_config_t config; + config.polynomial = polynomial; + config.width = width; + config.initial_xor = _initial_value; + config.final_xor = _final_xor; + config.reflect_in = _reflect_data; + config.reflect_out = _reflect_remainder; + + if (hal_crc_is_supported(&config)) { + _mode = HARDWARE; + return; + } } #endif diff --git a/cores/arduino/mbed/drivers/QSPI.h b/cores/arduino/mbed/drivers/QSPI.h index 4ab356a0..7b70d6ae 100644 --- a/cores/arduino/mbed/drivers/QSPI.h +++ b/cores/arduino/mbed/drivers/QSPI.h @@ -28,6 +28,8 @@ #define ONE_MHZ 1000000 +#define QSPI_NO_INST (-1) + namespace mbed { /** \defgroup drivers-public-api-spi SPI * \ingroup drivers-public-api @@ -39,6 +41,10 @@ namespace mbed { * @{ */ +/** Type representing a QSPI instruction + */ +typedef int qspi_inst_t; + /** A QSPI Driver, used for communicating with QSPI slave devices * * The default format is set to Quad-SPI(1-1-1), and a clock frequency of 1MHz @@ -106,7 +112,7 @@ class QSPI : private NonCopyable { * @param address_width Bus width used by address phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) * @param address_size Size in bits used by address phase(Valid values are QSPI_CFG_ADDR_SIZE_8, QSPI_CFG_ADDR_SIZE_16, QSPI_CFG_ADDR_SIZE_24, QSPI_CFG_ADDR_SIZE_32) * @param alt_width Bus width used by alt phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) - * @param alt_size Size in bits used by alt phase(Valid values are QSPI_CFG_ALT_SIZE_8, QSPI_CFG_ALT_SIZE_16, QSPI_CFG_ALT_SIZE_24, QSPI_CFG_ALT_SIZE_32) + * @param alt_size Size in bits used by alt phase (must be a multiple of the number of bus lines indicated in alt_width) * @param data_width Bus width used by data phase(Valid values are QSPI_CFG_BUS_SINGLE, QSPI_CFG_BUS_DUAL, QSPI_CFG_BUS_QUAD) * @param dummy_cycles Number of dummy clock cycles to be used after alt phase * @@ -151,7 +157,7 @@ class QSPI : private NonCopyable { /** Read from QSPI peripheral using custom read instruction, alt values * - * @param instruction Instruction value to be used in instruction phase + * @param instruction Instruction value to be used in instruction phase. Use QSPI_NO_INST to skip the instruction phase * @param alt Alt value to be used in Alternate-byte phase. Use -1 for ignoring Alternate-byte phase * @param address Address to be accessed in QSPI peripheral * @param rx_buffer Buffer for data to be read from the peripheral @@ -160,11 +166,11 @@ class QSPI : private NonCopyable { * @returns * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. */ - qspi_status_t read(int instruction, int alt, int address, char *rx_buffer, size_t *rx_length); + qspi_status_t read(qspi_inst_t instruction, int alt, int address, char *rx_buffer, size_t *rx_length); /** Write to QSPI peripheral using custom write instruction, alt values * - * @param instruction Instruction value to be used in instruction phase + * @param instruction Instruction value to be used in instruction phase. Use QSPI_NO_INST to skip the instruction phase * @param alt Alt value to be used in Alternate-byte phase. Use -1 for ignoring Alternate-byte phase * @param address Address to be accessed in QSPI peripheral * @param tx_buffer Buffer containing data to be sent to peripheral @@ -173,11 +179,11 @@ class QSPI : private NonCopyable { * @returns * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. */ - qspi_status_t write(int instruction, int alt, int address, const char *tx_buffer, size_t *tx_length); + qspi_status_t write(qspi_inst_t instruction, int alt, int address, const char *tx_buffer, size_t *tx_length); /** Perform a transaction to write to an address(a control register) and get the status results * - * @param instruction Instruction value to be used in instruction phase + * @param instruction Instruction value to be used in instruction phase. Use QSPI_NO_INST to skip the instruction phase * @param address Some instruction might require address. Use -1 if no address * @param tx_buffer Buffer containing data to be sent to peripheral * @param tx_length Pointer to a variable containing the length of data to be transmitted, and on return this variable will be updated with the actual number of bytes written @@ -187,7 +193,7 @@ class QSPI : private NonCopyable { * @returns * Returns QSPI_STATUS_SUCCESS on successful reads and QSPI_STATUS_ERROR on failed reads. */ - qspi_status_t command_transfer(int instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length); + qspi_status_t command_transfer(qspi_inst_t instruction, int address, const char *tx_buffer, size_t tx_length, const char *rx_buffer, size_t rx_length); #if !defined(DOXYGEN_ONLY) protected: @@ -227,7 +233,7 @@ class QSPI : private NonCopyable { /* * This function builds the qspi command struct to be send to Hal */ - inline void _build_qspi_command(int instruction, int address, int alt); + inline void _build_qspi_command(qspi_inst_t instruction, int address, int alt); #endif }; diff --git a/cores/arduino/mbed/drivers/ResetReason.h b/cores/arduino/mbed/drivers/ResetReason.h index 289b4b98..1ea1d3e6 100644 --- a/cores/arduino/mbed/drivers/ResetReason.h +++ b/cores/arduino/mbed/drivers/ResetReason.h @@ -22,9 +22,9 @@ #include "reset_reason_api.h" namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup drivers-public-api */ /** @{*/ + /** * \defgroup drivers_ResetReason ResetReason class * @{ diff --git a/cores/arduino/mbed/drivers/SPIMaster.h b/cores/arduino/mbed/drivers/SPIMaster.h index eaaabcee..c247b3ea 100644 --- a/cores/arduino/mbed/drivers/SPIMaster.h +++ b/cores/arduino/mbed/drivers/SPIMaster.h @@ -46,7 +46,7 @@ namespace mbed { /** - * \addtogroup drivers_SPI SPI class + * \defgroup drivers_SPI SPI class * \ingroup drivers-public-api-spi * @{ */ diff --git a/cores/arduino/mbed/drivers/Ticker.h b/cores/arduino/mbed/drivers/Ticker.h index b6c9dc9b..daa51489 100644 --- a/cores/arduino/mbed/drivers/Ticker.h +++ b/cores/arduino/mbed/drivers/Ticker.h @@ -26,7 +26,7 @@ namespace mbed { /** - * \addtogroup drivers_Ticker Ticker class + * \defgroup drivers_Ticker Ticker class * \ingroup drivers-public-api-ticker * @{ */ @@ -83,8 +83,12 @@ class Ticker : public TimerEvent, private NonCopyable { * @param func pointer to the function to be called * @param t the time between calls in seconds */ - template - MBED_FORCEINLINE void attach(F &&func, float t) +#if defined(__ICCARM__) + MBED_FORCEINLINE template +#else + template MBED_FORCEINLINE +#endif + void attach(F &&func, float t) { attach_us(std::forward(func), t * 1000000.0f); } diff --git a/cores/arduino/mbed/drivers/Timeout.h b/cores/arduino/mbed/drivers/Timeout.h index d4b63b37..bbf71c4c 100644 --- a/cores/arduino/mbed/drivers/Timeout.h +++ b/cores/arduino/mbed/drivers/Timeout.h @@ -22,7 +22,7 @@ namespace mbed { /** - * \addtogroup drivers_Timeout Timeout class + * \defgroup drivers_Timeout Timeout class * \ingroup drivers-public-api-ticker * @{ */ diff --git a/cores/arduino/mbed/drivers/Timer.h b/cores/arduino/mbed/drivers/Timer.h index 8ba20d6e..03474cc6 100644 --- a/cores/arduino/mbed/drivers/Timer.h +++ b/cores/arduino/mbed/drivers/Timer.h @@ -23,7 +23,7 @@ namespace mbed { /** - * \addtogroup drivers_Timer Timer class + * \defgroup drivers_Timer Timer class * \ingroup drivers-public-api-ticker * @{ */ diff --git a/cores/arduino/mbed/drivers/TimerEvent.h b/cores/arduino/mbed/drivers/TimerEvent.h index 1c47df0c..ff00ef3d 100644 --- a/cores/arduino/mbed/drivers/TimerEvent.h +++ b/cores/arduino/mbed/drivers/TimerEvent.h @@ -22,7 +22,7 @@ namespace mbed { /** - * \addtogroup drivers_TimerEvent TimerEvent class + * \defgroup drivers_TimerEvent TimerEvent class * \ingroup drivers-public-api-ticker * @{ */ diff --git a/cores/arduino/mbed/drivers/USBAudio.h b/cores/arduino/mbed/drivers/USBAudio.h index 6072afdf..58a84cd6 100644 --- a/cores/arduino/mbed/drivers/USBAudio.h +++ b/cores/arduino/mbed/drivers/USBAudio.h @@ -373,8 +373,8 @@ class USBAudio: protected USBDevice { usb_ep_t _episo_in; // tx endpoint // channel config in the configuration descriptor: master, left, right - uint8_t _channel_config_rx; - uint8_t _channel_config_tx; + uint16_t _channel_config_rx; + uint16_t _channel_config_tx; // configuration descriptor uint8_t _config_descriptor[183]; diff --git a/cores/arduino/mbed/drivers/USBMSD.h b/cores/arduino/mbed/drivers/USBMSD.h index 301ce491..b6e992ae 100644 --- a/cores/arduino/mbed/drivers/USBMSD.h +++ b/cores/arduino/mbed/drivers/USBMSD.h @@ -302,6 +302,7 @@ class USBMSD: public USBDevice { bool infoTransfer(void); void memoryRead(void); bool modeSense6(void); + bool modeSense10(void); void testUnitReady(void); bool requestSense(void); void memoryVerify(uint8_t *buf, uint16_t size); diff --git a/cores/arduino/mbed/drivers/internal/MIDIMessage.h b/cores/arduino/mbed/drivers/internal/MIDIMessage.h index 14b08a1e..5e417657 100644 --- a/cores/arduino/mbed/drivers/internal/MIDIMessage.h +++ b/cores/arduino/mbed/drivers/internal/MIDIMessage.h @@ -43,7 +43,7 @@ /** * \defgroup drivers_MIDIMessage MIDIMessage class - * \ingroup drivers-internal-usb + * \ingroup drivers-internal-api-usb * @{ */ diff --git a/cores/arduino/mbed/drivers/internal/TableCRC.h b/cores/arduino/mbed/drivers/internal/TableCRC.h index 4960bb47..18d2d0d8 100644 --- a/cores/arduino/mbed/drivers/internal/TableCRC.h +++ b/cores/arduino/mbed/drivers/internal/TableCRC.h @@ -22,7 +22,6 @@ namespace mbed { /** \addtogroup drivers-internal-api - * \ingroup mbed-os-internal * @{ */ diff --git a/cores/arduino/mbed/drivers/internal/USBDevice.h b/cores/arduino/mbed/drivers/internal/USBDevice.h index 8d8fcf44..bc9902e1 100644 --- a/cores/arduino/mbed/drivers/internal/USBDevice.h +++ b/cores/arduino/mbed/drivers/internal/USBDevice.h @@ -97,6 +97,11 @@ class USBDevice: public USBPhyEvents { * Power down this instance * * Disable interrupts and stop sending events. + * This method can be used for temporary power-saving; This call can allow + * USB to be temporarily disabled to permit power saving. + * However, it is up to the user to make sure all the + * transfers have concluded (for example when USB power is lost). + * USBDevice::connect can be used to resume USB operation. */ void deinit(); @@ -109,6 +114,8 @@ class USBDevice: public USBPhyEvents { /** * Connect a device + * This method can also be used to resume USB operation when USB power is + * detected after it was suspended via USBDevice::deinit. */ void connect(); diff --git a/cores/arduino/mbed/events/Event.h b/cores/arduino/mbed/events/Event.h index 73f43286..ef158824 100644 --- a/cores/arduino/mbed/events/Event.h +++ b/cores/arduino/mbed/events/Event.h @@ -21,8 +21,7 @@ #include "platform/mbed_assert.h" namespace events { -/** - * \addtogroup events-public-api Events +/** \defgroup events-public-api Events * \ingroup mbed-os-public * @{ */ diff --git a/cores/arduino/mbed/events/UserAllocatedEvent.h b/cores/arduino/mbed/events/UserAllocatedEvent.h index 71c4b700..26a2b5b9 100644 --- a/cores/arduino/mbed/events/UserAllocatedEvent.h +++ b/cores/arduino/mbed/events/UserAllocatedEvent.h @@ -23,8 +23,7 @@ namespace events { /** - * \addtogroup events-public-api Events - * \ingroup mbed-os-public + * \addtogroup events-public-api * @{ */ template @@ -215,6 +214,7 @@ class UserAllocatedEvent { */ void delay(int delay) { + MBED_ASSERT(!_post_ref); equeue_event_delay(&_e + 1, delay); } @@ -224,6 +224,7 @@ class UserAllocatedEvent { */ void period(int period) { + MBED_ASSERT(!_post_ref); equeue_event_period(&_e + 1, period); } diff --git a/cores/arduino/mbed/events/equeue.h b/cores/arduino/mbed/events/equeue.h index 7c3dfbea..5d452fc5 100644 --- a/cores/arduino/mbed/events/equeue.h +++ b/cores/arduino/mbed/events/equeue.h @@ -93,6 +93,9 @@ typedef struct equeue { // // If the event queue creation fails, equeue_create returns a negative, // platform-specific error code. +// +// If queues are chained, it is needed to unchain them first, before calling destroy, +// or call the destroy function on queues in order that chained queues are destroyed first. int equeue_create(equeue_t *queue, size_t size); int equeue_create_inplace(equeue_t *queue, size_t size, void *buffer); void equeue_destroy(equeue_t *queue); diff --git a/cores/arduino/mbed/events/mbed_shared_queues.h b/cores/arduino/mbed/events/mbed_shared_queues.h index acd83a6a..9be5ff16 100644 --- a/cores/arduino/mbed/events/mbed_shared_queues.h +++ b/cores/arduino/mbed/events/mbed_shared_queues.h @@ -19,7 +19,6 @@ #include "events/EventQueue.h" namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup events-public-api */ /** @{*/ diff --git a/cores/arduino/mbed/features/cellular/framework/API/CellularNetwork.h b/cores/arduino/mbed/features/cellular/framework/API/CellularNetwork.h index 357d8a0f..94734074 100644 --- a/cores/arduino/mbed/features/cellular/framework/API/CellularNetwork.h +++ b/cores/arduino/mbed/features/cellular/framework/API/CellularNetwork.h @@ -338,8 +338,8 @@ class CellularNetwork { /** Check if there is any PDP context active. If cid is given, then check is done only for that cid. * - * @param number_of_active_contexts If given then in return contains the number of active contexts - * @param cid If given then active contexts are checked only against this cid + * @param number_of_active_contexts If given then in return contains the number of all active contexts + * @param cid If given then check if the context with this cid is active * * @return true if any (or the given cid) context is active, false otherwise or in case of error */ diff --git a/cores/arduino/mbed/features/cellular/framework/AT/ATHandler.h b/cores/arduino/mbed/features/cellular/framework/AT/ATHandler.h index ce763de9..21be72bb 100644 --- a/cores/arduino/mbed/features/cellular/framework/AT/ATHandler.h +++ b/cores/arduino/mbed/features/cellular/framework/AT/ATHandler.h @@ -21,17 +21,12 @@ #include "platform/mbed_retarget.h" #include "events/EventQueue.h" -#include "PlatformMutex.h" #include "nsapi_types.h" #include "Callback.h" #include -namespace mbed { - -class FileHandle; - /** * If application calls associated FileHandle only from single thread context * then locking between AT command and response is not needed. However, @@ -40,6 +35,14 @@ class FileHandle; */ #define AT_HANDLER_MUTEX +#if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT +#include "ConditionVariable.h" +#endif + +namespace mbed { + +class FileHandle; + extern const char *OK; extern const char *CRLF; @@ -218,8 +221,9 @@ class ATHandler { protected: void event(); -#ifdef AT_HANDLER_MUTEX - PlatformMutex _fileHandleMutex; +#if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT + rtos::Mutex _fileHandleMutex; + rtos::ConditionVariable _oobCv; #endif FileHandle *_fileHandle; private: @@ -251,7 +255,6 @@ class ATHandler { uint16_t _at_send_delay; uint64_t _last_response_stop; - bool _oob_queued; int32_t _ref_count; bool _is_fh_usable; @@ -416,6 +419,14 @@ class ATHandler { */ ssize_t read_hex_string(char *str, size_t size); + /** Converts contained chars to their hex ascii value and writes the resulting string to the file handle + * For example: "AV" to "4156". + * + * @param str input buffer to be converted to hex ascii + * @param size of the input param str + */ + void write_hex_string(char *str, size_t size); + /** Reads as string and converts result to integer. Supports only non-negative integers. * * @return the non-negative integer or -1 in case of error. @@ -550,6 +561,8 @@ class ATHandler { // time when a command or an URC processing was started uint64_t _start_time; + // eventqueue event id + int _event_id; char _cmd_buffer[BUFF_SIZE]; diff --git a/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularBase.h b/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularBase.h index e50008a7..c4448142 100644 --- a/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularBase.h +++ b/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularBase.h @@ -60,7 +60,7 @@ class AT_CellularBase { PROPERTY_AT_CSDH, // 0 = not supported, 1 = supported. Show text mode AT command PROPERTY_IPV4_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4? PROPERTY_IPV6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV6? - PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support dual stack IPV4V6? + PROPERTY_IPV4V6_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support IPV4 and IPV6 simultaneously? PROPERTY_NON_IP_PDP_TYPE, // 0 = not supported, 1 = supported. Does modem support Non-IP? PROPERTY_AT_CGEREP, // 0 = not supported, 1 = supported. Does modem support AT command AT+CGEREP. diff --git a/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularContext.h b/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularContext.h index 43912727..5ccb5f20 100644 --- a/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularContext.h +++ b/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularContext.h @@ -119,8 +119,8 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase { void ciot_opt_cb(mbed::CellularNetwork::CIoT_Supported_Opt ciot_opt); virtual void do_connect_with_retry(); void do_disconnect(); + void set_cid(int cid); private: - bool _is_connected; ContextOperation _current_op; FileHandle *_fh; rtos::Semaphore _semaphore; @@ -130,6 +130,7 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase { char _found_apn[MAX_APN_LENGTH]; // flag indicating if CP was requested to be setup bool _cp_req; + bool _is_connected; }; } // namespace mbed diff --git a/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularStack.h b/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularStack.h index fd9adf28..2402289b 100644 --- a/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularStack.h +++ b/cores/arduino/mbed/features/cellular/framework/AT/AT_CellularStack.h @@ -20,6 +20,7 @@ #include "AT_CellularBase.h" #include "NetworkStack.h" +#include "PlatformMutex.h" namespace mbed { @@ -43,6 +44,14 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase { public: // NetworkStack virtual const char *get_ip_address(); + + /** + * Set PDP context ID for this stack + * + * @param cid value from AT+CGDCONT, where -1 is undefined + */ + void set_cid(int cid); + protected: // NetworkStack /** @@ -191,6 +200,11 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase { */ int find_socket_index(nsapi_socket_t handle); + /** + * Checks if send to address is valid and if current stack type supports sending to that address type + */ + bool is_addr_stack_compatible(const SocketAddress &addr); + // socket container CellularSocket **_socket; @@ -203,9 +217,12 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase { // PDP context id int _cid; - // stack type from PDP context + // stack type - initialised as PDP type and set accordingly after CGPADDR checked nsapi_ip_stack_t _stack_type; + // IP version of send to address + nsapi_version_t _ip_ver_sendto; + private: int get_socket_index_by_port(uint16_t port); diff --git a/cores/arduino/mbed/features/cellular/framework/common/CellularUtil.h b/cores/arduino/mbed/features/cellular/framework/common/CellularUtil.h index cfd7b50e..cfe0c86c 100644 --- a/cores/arduino/mbed/features/cellular/framework/common/CellularUtil.h +++ b/cores/arduino/mbed/features/cellular/framework/common/CellularUtil.h @@ -48,8 +48,9 @@ static const char hex_values[] = "0123456789ABCDEF"; * where ax are in decimal format. In this case, function converts decimals to hex with separated with colons. * * @param ip IP address that can be IPv4 or IPv6 in different formats from AT command +CGPADDR. Converted result uses same buffer. + * @return IP version of the address or NSAPI_UNSPEC if param ip empty or if IPv4 or IPv6 version could not be concluded. */ -void convert_ipv6(char *ip); +nsapi_version_t convert_ipv6(char *ip); /** Separates IP addresses from the given 'orig' string. 'orig' may contain zero, one or two IP addresses in various formats. * See AT command +CGPIAF from 3GPP TS 27.007 for details. Does also needed conversions for IPv6 addresses. diff --git a/cores/arduino/mbed/features/cellular/framework/device/CellularStateMachine.h b/cores/arduino/mbed/features/cellular/framework/device/CellularStateMachine.h index d31bf216..6fda9abe 100644 --- a/cores/arduino/mbed/features/cellular/framework/device/CellularStateMachine.h +++ b/cores/arduino/mbed/features/cellular/framework/device/CellularStateMachine.h @@ -22,9 +22,11 @@ #include "CellularCommon.h" #include "PlatformMutex.h" +#ifdef MBED_CONF_RTOS_PRESENT namespace rtos { class Thread; } +#endif namespace mbed { @@ -159,6 +161,12 @@ class CellularStateMachine { void send_event_cb(cellular_connection_status_t status); void change_timeout(const int &timeout); +private: + +#ifdef MBED_CONF_RTOS_PRESENT + rtos::Thread *_queue_thread; +#endif + CellularDevice &_cellularDevice; CellularState _state; CellularState _next_state; @@ -168,7 +176,6 @@ class CellularStateMachine { CellularNetwork &_network; events::EventQueue &_queue; - rtos::Thread *_queue_thread; const char *_sim_pin; int _retry_count; diff --git a/cores/arduino/mbed/features/frameworks/TARGET_PSA/val.h b/cores/arduino/mbed/features/frameworks/TARGET_PSA/val.h index 0989f49b..aa329bd3 100644 --- a/cores/arduino/mbed/features/frameworks/TARGET_PSA/val.h +++ b/cores/arduino/mbed/features/frameworks/TARGET_PSA/val.h @@ -169,9 +169,9 @@ /* enums */ typedef enum { - NONSECURE = 0x0, - SECURE = 0x1, -} security_t; + CALLER_NONSECURE = 0x0, + CALLER_SECURE = 0x1, +} caller_security_t; typedef enum { TEST_ISOLATION_L1 = 0x1, @@ -272,6 +272,6 @@ typedef struct { uint8_t status; } test_status_buffer_t; -typedef int32_t (*client_test_t)(security_t caller); +typedef int32_t (*client_test_t)(caller_security_t caller); typedef int32_t (*server_test_t)(void); #endif /* VAL_COMMON_H */ diff --git a/cores/arduino/mbed/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h b/cores/arduino/mbed/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h index 0562e4a8..c0cef6a8 100644 --- a/cores/arduino/mbed/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h +++ b/cores/arduino/mbed/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h @@ -48,15 +48,11 @@ extern "C" { #endif -#ifdef YOTTA_CFG #include #include #include -#else -#include "ns_types.h" -#endif - #include +#include #ifndef YOTTA_CFG_MBED_TRACE #define YOTTA_CFG_MBED_TRACE 0 diff --git a/cores/arduino/mbed/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_trace.h b/cores/arduino/mbed/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_trace.h index 206e2399..2219f8b8 100644 --- a/cores/arduino/mbed/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_trace.h +++ b/cores/arduino/mbed/features/frameworks/nanostack-libservice/mbed-client-libservice/ns_trace.h @@ -28,6 +28,7 @@ #define FEA_TRACE_SUPPORT #endif +#include "ns_types.h" #include "mbed-trace/mbed_trace.h" #endif /* NS_TRACE_H_ */ diff --git a/cores/arduino/mbed/features/lwipstack/LWIPStack.h b/cores/arduino/mbed/features/lwipstack/LWIPStack.h index 5e99126c..a5756645 100644 --- a/cores/arduino/mbed/features/lwipstack/LWIPStack.h +++ b/cores/arduino/mbed/features/lwipstack/LWIPStack.h @@ -101,6 +101,13 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable { */ virtual char *get_ip_address(char *buf, nsapi_size_t buflen); + /** Get the IPv6 link local address in SocketAddress representation + * + * @address SocketAddress representation of the link local IPv6 address + * @return NSAPI_ERROR_OK on success, or error code + */ + virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address); + /** Copies IP address of the name based network interface to user supplied buffer * * @param buf buffer to which IP address will be copied as "W:X:Y:Z" @@ -571,6 +578,7 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable { static const ip_addr_t *get_ip_addr(bool any_addr, const struct netif *netif); static const ip_addr_t *get_ipv4_addr(const struct netif *netif); static const ip_addr_t *get_ipv6_addr(const struct netif *netif); + static const ip_addr_t *get_ipv6_link_local_addr(const struct netif *netif); static void add_dns_addr(struct netif *lwip_netif, const char *interface_name); diff --git a/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/cc.h b/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/cc.h index afa13c91..2f19796d 100644 --- a/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/cc.h +++ b/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/cc.h @@ -1,40 +1,41 @@ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __CC_H__ -#define __CC_H__ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef __CC_H__ +#define __CC_H__ #include #include /* for size_t */ #include "mbed_toolchain.h" +#include "lwipopts.h" #ifdef __cplusplus extern "C" { @@ -48,8 +49,10 @@ extern "C" { #define BYTE_ORDER LITTLE_ENDIAN #endif +#ifndef LWIP_PROVIDE_ERRNO /* Use LWIP error codes */ #define LWIP_PROVIDE_ERRNO +#endif #if defined(__arm__) && defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050) /* Keil uVision4 tools */ @@ -58,7 +61,7 @@ extern "C" { #define PACK_STRUCT_END #define PACK_STRUCT_FIELD(fld) fld #define ALIGNED(n) __align(n) -#elif defined (__IAR_SYSTEMS_ICC__) +#elif defined (__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench tools */ #define PACK_STRUCT_BEGIN __packed #define PACK_STRUCT_STRUCT @@ -66,14 +69,14 @@ extern "C" { #define PACK_STRUCT_FIELD(fld) fld #define IAR_STR(a) #a #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##)) -#else +#else /* GCC tools (CodeSourcery) */ #define PACK_STRUCT_BEGIN #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) #define PACK_STRUCT_END #define PACK_STRUCT_FIELD(fld) fld #define ALIGNED(n) __attribute__((aligned (n))) -#endif +#endif /* Provide Thumb-2 routines for GCC to improve performance */ #if defined(TOOLCHAIN_GCC) && defined(__thumb2__) @@ -115,7 +118,7 @@ MBED_NORETURN void assert_printf(const char *msg, int line, const char *file); #define LWIP_PLATFORM_DIAG(vars) printf vars #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); } #endif // MBED_CONF_LWIP_USE_MBED_TRACE -#endif +#endif #if TRACE_TO_ASCII_HEX_DUMP #define TRACE_TO_ASCII_HEX_DUMPF(prefix, len, data) trace_to_ascii_hex_dump(prefix, len, data) @@ -180,4 +183,4 @@ SET_MEMP_SECTION(memp_memory_TCPIP_MSG_API_base); } #endif -#endif /* __CC_H__ */ +#endif /* __CC_H__ */ diff --git a/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/sys_arch.h b/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/sys_arch.h index 6a968db9..728da3ca 100644 --- a/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/sys_arch.h +++ b/cores/arduino/mbed/features/lwipstack/lwip-sys/arch/sys_arch.h @@ -46,7 +46,7 @@ typedef struct { } sys_mutex_t; // === MAIL BOX === -#define MB_SIZE 8 +#define MB_SIZE MBED_CONF_LWIP_MBOX_SIZE typedef struct { osEventFlagsId_t id; diff --git a/cores/arduino/mbed/features/lwipstack/lwip/src/include/lwip/lwip_errno.h b/cores/arduino/mbed/features/lwipstack/lwip/src/include/lwip/lwip_errno.h index 48d6b539..601fe9ba 100644 --- a/cores/arduino/mbed/features/lwipstack/lwip/src/include/lwip/lwip_errno.h +++ b/cores/arduino/mbed/features/lwipstack/lwip/src/include/lwip/lwip_errno.h @@ -44,6 +44,7 @@ extern "C" { #endif #ifdef LWIP_PROVIDE_ERRNO +#if LWIP_PROVIDE_ERRNO == 1 #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ @@ -177,6 +178,7 @@ extern "C" { extern int errno; #endif +#endif //LWIP_PROVIDE_ERRNO == 1 #else /* LWIP_PROVIDE_ERRNO */ /* Define LWIP_ERRNO_STDINCLUDE if you want to include here */ diff --git a/cores/arduino/mbed/features/lwipstack/lwipopts.h b/cores/arduino/mbed/features/lwipstack/lwipopts.h index fd2a4fab..4f720de3 100644 --- a/cores/arduino/mbed/features/lwipstack/lwipopts.h +++ b/cores/arduino/mbed/features/lwipstack/lwipopts.h @@ -25,23 +25,21 @@ #include #endif #include "nsapi_types.h" +#include "mbed_retarget.h" + // Operating System #define NO_SYS 0 -#if MBED_CONF_LWIP_IPV4_ENABLED -#define LWIP_IPV4 1 -#else -#define LWIP_IPV4 0 -#endif -#if MBED_CONF_LWIP_IPV6_ENABLED -#define LWIP_IPV6 1 -#else -#define LWIP_IPV6 0 -#endif #if !MBED_CONF_LWIP_IPV4_ENABLED && !MBED_CONF_LWIP_IPV6_ENABLED #error "Either IPv4 or IPv6 must be enabled." #endif +#define LWIP_IPV4 MBED_CONF_LWIP_IPV4_ENABLED + +#define LWIP_IPV6 MBED_CONF_LWIP_IPV6_ENABLED + +#define LWIP_PROVIDE_ERRNO 0 + // On dual stack configuration how long to wait for both or preferred stack // addresses before completing bring up. #if LWIP_IPV4 && LWIP_IPV6 @@ -57,25 +55,19 @@ #define BOTH_ADDR_TIMEOUT 0 #endif -// Configurable DHCP timeout. DHCP timeout can be configured for specific usecase requirement. -#ifdef MBED_CONF_LWIP_DHCP_TIMEOUT -#define DHCP_TIMEOUT (MBED_CONF_LWIP_DHCP_TIMEOUT) -#else -#define DHCP_TIMEOUT 60 -#endif + +#define DHCP_TIMEOUT MBED_CONF_LWIP_DHCP_TIMEOUT #define LINK_TIMEOUT 60 #define PREF_IPV4 1 #define PREF_IPV6 2 -#if MBED_CONF_LWIP_IP_VER_PREF == 4 -#define IP_VERSION_PREF PREF_IPV4 -#endif #if MBED_CONF_LWIP_IP_VER_PREF == 6 #define IP_VERSION_PREF PREF_IPV6 -#endif -#ifndef IP_VERSION_PREF +#elif MBED_CONF_LWIP_IP_VER_PREF == 4 +#define IP_VERSION_PREF PREF_IPV4 +#else #error "Either IPv4 or IPv6 must be preferred." #endif @@ -93,8 +85,9 @@ #define LWIP_RAW 0 #endif -#define TCPIP_MBOX_SIZE 8 -#define DEFAULT_TCP_RECVMBOX_SIZE 8 +#define MEMP_NUM_TCPIP_MSG_INPKT MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT +#define TCPIP_MBOX_SIZE MBED_CONF_LWIP_TCPIP_MBOX_SIZE +#define DEFAULT_TCP_RECVMBOX_SIZE MBED_CONF_LWIP_DEFAULT_TCP_RECVMBOX_SIZE #define DEFAULT_UDP_RECVMBOX_SIZE 8 #define DEFAULT_RAW_RECVMBOX_SIZE 8 #define DEFAULT_ACCEPTMBOX_SIZE 8 @@ -102,11 +95,6 @@ // Thread stacks use 8-byte alignment #define LWIP_ALIGN_UP(pos, align) ((pos) % (align) ? (pos) + ((align) - (pos) % (align)) : (pos)) -// Thread stack size for lwip tcpip thread -#ifndef MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE -#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 -#endif - #ifdef LWIP_DEBUG // For LWIP debug, double the stack #define TCPIP_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE*2, 8) @@ -120,11 +108,6 @@ // Thread priority (osPriorityNormal by default) #define TCPIP_THREAD_PRIO (MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY) -// Thread stack size for lwip system threads -#ifndef MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE -#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 -#endif - #ifdef LWIP_DEBUG #define DEFAULT_THREAD_STACKSIZE LWIP_ALIGN_UP(MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE*2, 8) #else @@ -143,43 +126,24 @@ #define LWIP_RAM_HEAP_POINTER lwip_ram_heap // Number of simultaneously queued TCP segments. -#ifdef MBED_CONF_LWIP_MEMP_NUM_TCP_SEG #define MEMP_NUM_TCP_SEG MBED_CONF_LWIP_MEMP_NUM_TCP_SEG -#endif // TCP Maximum segment size. -#ifdef MBED_CONF_LWIP_TCP_MSS #define TCP_MSS MBED_CONF_LWIP_TCP_MSS -#endif // TCP sender buffer space (bytes). -#ifdef MBED_CONF_LWIP_TCP_SND_BUF #define TCP_SND_BUF MBED_CONF_LWIP_TCP_SND_BUF -#endif // TCP sender buffer space (bytes). -#ifdef MBED_CONF_LWIP_TCP_WND #define TCP_WND MBED_CONF_LWIP_TCP_WND -#endif -#ifdef MBED_CONF_LWIP_TCP_MAXRTX #define TCP_MAXRTX MBED_CONF_LWIP_TCP_MAXRTX -#endif -#ifdef MBED_CONF_LWIP_TCP_SYNMAXRTX #define TCP_SYNMAXRTX MBED_CONF_LWIP_TCP_SYNMAXRTX -#endif // Number of pool pbufs. // Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) -#ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE -#undef PBUF_POOL_SIZE #define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE -#else -#ifndef PBUF_POOL_SIZE -#define PBUF_POOL_SIZE 5 -#endif -#endif #ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE #undef PBUF_POOL_BUFSIZE @@ -194,63 +158,38 @@ #endif #endif -#ifdef MBED_CONF_LWIP_MEM_SIZE -#undef MEM_SIZE #define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE -#endif // One tcp_pcb_listen is needed for each TCPServer. // Each requires 72 bytes of RAM. -#ifdef MBED_CONF_LWIP_TCP_SERVER_MAX #define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX -#else -#define MEMP_NUM_TCP_PCB_LISTEN 4 -#endif // One is tcp_pcb needed for each TCPSocket. // Each requires 196 bytes of RAM. -#ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX #define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX -#else -#define MEMP_NUM_TCP_PCB 4 -#endif // One udp_pcb is needed for each UDPSocket. // Each requires 84 bytes of RAM (total rounded to multiple of 512). -#ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX #define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX -#else -#define MEMP_NUM_UDP_PCB 4 -#endif // Number of non-pool pbufs. // Each requires 92 bytes of RAM. -#ifndef MEMP_NUM_PBUF -#define MEMP_NUM_PBUF 8 -#endif +#define MEMP_NUM_PBUF MBED_CONF_LWIP_NUM_PBUF // Each netbuf requires 64 bytes of RAM. -#ifndef MEMP_NUM_NETBUF -#define MEMP_NUM_NETBUF 8 -#endif +#define MEMP_NUM_NETBUF MBED_CONF_LWIP_NUM_NETBUF // One netconn is needed for each UDPSocket, TCPSocket or TCPServer. // Each requires 236 bytes of RAM (total rounded to multiple of 512). -#ifdef MBED_CONF_LWIP_SOCKET_MAX #define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX -#else -#define MEMP_NUM_NETCONN 4 -#endif #if MBED_CONF_LWIP_TCP_ENABLED #define LWIP_TCP 1 #define TCP_OVERSIZE 0 #define LWIP_TCP_KEEPALIVE 1 -#ifdef MBED_CONF_TCP_CLOSE_TIMEOUT -#define TCP_CLOSE_TIMEOUT MBED_CONF_TCP_CLOSE_TIMEOUT -#else -#define TCP_CLOSE_TIMEOUT 1000 -#endif + +#define TCP_CLOSE_TIMEOUT MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT + #else #define LWIP_TCP 0 #endif diff --git a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/check_config.h b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/check_config.h index 2a3be64f..1c93331a 100644 --- a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/check_config.h +++ b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/check_config.h @@ -130,11 +130,16 @@ #error "MBEDTLS_ECP_RESTARTABLE defined, but not MBEDTLS_ECDH_LEGACY_CONTEXT" #endif +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) && \ + defined(MBEDTLS_ECDH_LEGACY_CONTEXT) +#error "MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED defined, but MBEDTLS_ECDH_LEGACY_CONTEXT not disabled" +#endif + #if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C) #error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites" #endif -#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \ +#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \ !defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \ @@ -145,7 +150,9 @@ !defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \ !defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \ - !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) ) + !defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) && \ + !defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) ) ) #error "MBEDTLS_ECP_C defined, but not all prerequisites" #endif @@ -298,6 +305,14 @@ #error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_MEMORY_BACKTRACE) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#error "MBEDTLS_MEMORY_BACKTRACE defined, but not all prerequesites" +#endif + +#if defined(MBEDTLS_MEMORY_DEBUG) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#error "MBEDTLS_MEMORY_DEBUG defined, but not all prerequesites" +#endif + #if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM) #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites" #endif diff --git a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/config.h b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/config.h index 0b3610a4..f828368c 100644 --- a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/config.h +++ b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/config.h @@ -3592,6 +3592,15 @@ */ //#define MBEDTLS_PLATFORM_GMTIME_R_ALT +/** + * Enable the verified implementations of ECDH primitives from Project Everest + * (currently only Curve25519). This feature changes the layout of ECDH + * contexts and therefore is a compatibility break for applications that access + * fields of a mbedtls_ecdh_context structure directly. See also + * MBEDTLS_ECDH_LEGACY_CONTEXT in include/mbedtls/ecdh.h. + */ +//#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED + /* \} name SECTION: Customisation configuration options */ /* Target and application specific configurations diff --git a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/net_sockets.h b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/net_sockets.h index df42b450..adb589ee 100644 --- a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/net_sockets.h +++ b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/net_sockets.h @@ -257,6 +257,13 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, uint32_t timeout ); +/** + * \brief Closes down the connection and free associated data + * + * \param ctx The context to close + */ +void mbedtls_net_close( mbedtls_net_context *ctx ); + /** * \brief Gracefully shutdown the connection and free associated data * diff --git a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/ssl.h b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/ssl.h index 458857f6..655f59d3 100644 --- a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/ssl.h +++ b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/ssl.h @@ -970,7 +970,8 @@ struct mbedtls_ssl_config * tls_prf and random bytes. Should replace f_export_keys */ int (*f_export_keys_ext)( void *, const unsigned char *, const unsigned char *, size_t, size_t, size_t, - unsigned char[32], unsigned char[32], mbedtls_tls_prf_types ); + const unsigned char[32], const unsigned char[32], + mbedtls_tls_prf_types ); void *p_export_keys; /*!< context for key export callback */ #endif @@ -1925,8 +1926,8 @@ typedef int mbedtls_ssl_export_keys_ext_t( void *p_expkey, size_t maclen, size_t keylen, size_t ivlen, - unsigned char client_random[32], - unsigned char server_random[32], + const unsigned char client_random[32], + const unsigned char server_random[32], mbedtls_tls_prf_types tls_prf_type ); #endif /* MBEDTLS_SSL_EXPORT_KEYS */ diff --git a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/version.h b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/version.h index ea01f1d0..f78e40a5 100644 --- a/cores/arduino/mbed/features/mbedtls/inc/mbedtls/version.h +++ b/cores/arduino/mbed/features/mbedtls/inc/mbedtls/version.h @@ -39,7 +39,7 @@ * Major, Minor, Patchlevel */ #define MBEDTLS_VERSION_MAJOR 2 -#define MBEDTLS_VERSION_MINOR 18 +#define MBEDTLS_VERSION_MINOR 19 #define MBEDTLS_VERSION_PATCH 0 /** @@ -47,9 +47,9 @@ * MMNNPP00 * Major version | Minor version | Patch version */ -#define MBEDTLS_VERSION_NUMBER 0x02120000 -#define MBEDTLS_VERSION_STRING "2.18.0" -#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.18.0" +#define MBEDTLS_VERSION_NUMBER 0x02130000 +#define MBEDTLS_VERSION_STRING "2.19.0" +#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.19.0" #if defined(MBEDTLS_VERSION_C) diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bignum.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bignum.h index 0b26727f..2c5ace69 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bignum.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bignum.h @@ -129,7 +129,8 @@ defined(__ppc64__) || defined(__powerpc64__) || \ defined(__ia64__) || defined(__alpha__) || \ ( defined(__sparc__) && defined(__arch64__) ) || \ - defined(__s390x__) || defined(__mips64) ) + defined(__s390x__) || defined(__mips64) || \ + defined(__aarch64__) ) #if !defined(MBEDTLS_HAVE_INT64) #define MBEDTLS_HAVE_INT64 #endif /* MBEDTLS_HAVE_INT64 */ diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bn_mul.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bn_mul.h index f7cb0725..163869ae 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bn_mul.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/bn_mul.h @@ -198,6 +198,30 @@ #endif /* AMD64 */ +#if defined(__aarch64__) + +#define MULADDC_INIT \ + asm( + +#define MULADDC_CORE \ + "ldr x4, [%2], #8 \n\t" \ + "ldr x5, [%1] \n\t" \ + "mul x6, x4, %3 \n\t" \ + "umulh x7, x4, %3 \n\t" \ + "adds x5, x5, x6 \n\t" \ + "adc x7, x7, xzr \n\t" \ + "adds x5, x5, %0 \n\t" \ + "adc %0, x7, xzr \n\t" \ + "str x5, [%1], #8 \n\t" + +#define MULADDC_STOP \ + : "+r" (c), "+r" (d), "+r" (s) \ + : "r" (b) \ + : "x4", "x5", "x6", "x7", "cc" \ + ); + +#endif /* Aarch64 */ + #if defined(__mc68020__) || defined(__mcpu32__) #define MULADDC_INIT \ diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdh.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdh.h index d870a5bd..3948d7c9 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdh.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdh.h @@ -42,6 +42,11 @@ #include "mbedtls/ecp.h" +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) +#undef MBEDTLS_ECDH_LEGACY_CONTEXT +#include "everest/everest.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -66,6 +71,9 @@ typedef enum { MBEDTLS_ECDH_VARIANT_NONE = 0, /*!< Implementation not defined. */ MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0,/*!< The default Mbed TLS implementation */ +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) + MBEDTLS_ECDH_VARIANT_EVEREST /*!< Everest implementation */ +#endif } mbedtls_ecdh_variant; /** @@ -119,6 +127,9 @@ typedef struct mbedtls_ecdh_context union { mbedtls_ecdh_context_mbed mbed_ecdh; +#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) + mbedtls_ecdh_context_everest everest_ecdh; +#endif } ctx; /*!< Implementation-specific context. The context in use is specified by the \c var field. */ @@ -133,6 +144,15 @@ typedef struct mbedtls_ecdh_context } mbedtls_ecdh_context; +/** + * \brief Check whether a given group can be used for ECDH. + * + * \param gid The ECP group ID to check. + * + * \return \c 1 if the group can be used, \c 0 otherwise + */ +int mbedtls_ecdh_can_do( mbedtls_ecp_group_id gid ); + /** * \brief This function generates an ECDH keypair on an elliptic * curve. diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdsa.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdsa.h index effbb1ed..b009e734 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdsa.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecdsa.h @@ -125,6 +125,16 @@ typedef void mbedtls_ecdsa_restart_ctx; #endif /* MBEDTLS_ECP_RESTARTABLE */ +/** + * \brief This function checks whether a given group can be used + * for ECDSA. + * + * \param gid The ECP group ID to check. + * + * \return \c 1 if the group can be used, \c 0 otherwise + */ +int mbedtls_ecdsa_can_do( mbedtls_ecp_group_id gid ); + /** * \brief This function computes the ECDSA signature of a * previously-hashed message. @@ -166,6 +176,12 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #if defined(MBEDTLS_ECDSA_DETERMINISTIC) +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif /** * \brief This function computes the ECDSA signature of a * previously-hashed message, deterministic version. @@ -180,6 +196,19 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.3, step 5. * + * \warning Since the output of the internal RNG is always the same for + * the same key and message, this limits the efficiency of + * blinding and leaks information through side channels. For + * secure behavior use mbedtls_ecdsa_sign_det_ext() instead. + * + * (Optimally the blinding is a random value that is different + * on every execution. In this case the blinding is still + * random from the attackers perspective, but is the same on + * each execution. This means that this blinding does not + * prevent attackers from recovering secrets by combining + * several measurement traces, but may prevent some attacks + * that exploit relationships between secret data.) + * * \see ecp.h * * \param grp The context for the elliptic curve to use. @@ -204,7 +233,55 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, - mbedtls_md_type_t md_alg ); + mbedtls_md_type_t md_alg ) MBEDTLS_DEPRECATED; +#undef MBEDTLS_DEPRECATED +#endif /* MBEDTLS_DEPRECATED_REMOVED */ + +/** + * \brief This function computes the ECDSA signature of a + * previously-hashed message, deterministic version. + * + * For more information, see RFC-6979: Deterministic + * Usage of the Digital Signature Algorithm (DSA) and Elliptic + * Curve Digital Signature Algorithm (ECDSA). + * + * \note If the bitlength of the message hash is larger than the + * bitlength of the group order, then the hash is truncated as + * defined in Standards for Efficient Cryptography Group + * (SECG): SEC1 Elliptic Curve Cryptography, section + * 4.1.3, step 5. + * + * \see ecp.h + * + * \param grp The context for the elliptic curve to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param r The MPI context in which to store the first part + * the signature. This must be initialized. + * \param s The MPI context in which to store the second part + * the signature. This must be initialized. + * \param d The private signing key. This must be initialized + * and setup, for example through mbedtls_ecp_gen_privkey(). + * \param buf The hashed content to be signed. This must be a readable + * buffer of length \p blen Bytes. It may be \c NULL if + * \p blen is zero. + * \param blen The length of \p buf in Bytes. + * \param md_alg The hash algorithm used to hash the original data. + * \param f_rng_blind The RNG function used for blinding. This must not be + * \c NULL. + * \param p_rng_blind The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng doesn't need a context parameter. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX + * error code on failure. + */ +int mbedtls_ecdsa_sign_det_ext( mbedtls_ecp_group *grp, mbedtls_mpi *r, + mbedtls_mpi *s, const mbedtls_mpi *d, + const unsigned char *buf, size_t blen, + mbedtls_md_type_t md_alg, + int (*f_rng_blind)(void *, unsigned char *, size_t), + void *p_rng_blind ); #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ /** @@ -283,7 +360,8 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, * the signature written. Must not be \c NULL. * \param f_rng The RNG function. This must not be \c NULL if * #MBEDTLS_ECDSA_DETERMINISTIC is unset. Otherwise, - * it is unused and may be set to \c NULL. + * it is used only for blinding and may be set to \c NULL, but + * doing so is DEPRECATED. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't use a context. * diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecp.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecp.h index 6aa677ad..d04cc49b 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecp.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/mbedtls/ecp.h @@ -437,6 +437,12 @@ mbedtls_ecp_curve_type mbedtls_ecp_get_type( const mbedtls_ecp_group *grp ); * mbedtls_ecp_curve_info() for all supported curves in order * of preference. * + * \note This function returns information about all curves + * supported by the library. Some curves may not be + * supported for all algorithms. Call mbedtls_ecdh_can_do() + * or mbedtls_ecdsa_can_do() to check if a curve is + * supported for ECDH or ECDSA. + * * \return A statically allocated array. The last entry is 0. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ); @@ -446,6 +452,12 @@ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ); * identifiers of all supported curves in the order of * preference. * + * \note This function returns information about all curves + * supported by the library. Some curves may not be + * supported for all algorithms. Call mbedtls_ecdh_can_do() + * or mbedtls_ecdsa_can_do() to check if a curve is + * supported for ECDH or ECDSA. + * * \return A statically allocated array, * terminated with MBEDTLS_ECP_DP_NONE. */ diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto.h index 0d8cbfa1..d5e713e0 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto.h @@ -328,6 +328,12 @@ static size_t psa_get_key_bits(const psa_key_attributes_t *attributes); * \retval #PSA_ERROR_INVALID_HANDLE * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_get_key_attributes(psa_key_handle_t handle, psa_key_attributes_t *attributes); @@ -392,7 +398,12 @@ void psa_reset_key_attributes(psa_key_attributes_t *attributes); * define any way to create such a key, but it may be possible * through implementation-specific means. * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_open_key(psa_key_id_t id, psa_key_handle_t *handle); @@ -419,6 +430,11 @@ psa_status_t psa_open_key(psa_key_id_t id, * \retval #PSA_SUCCESS * \retval #PSA_ERROR_INVALID_HANDLE * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_close_key(psa_key_handle_t handle); @@ -487,6 +503,8 @@ psa_status_t psa_close_key(psa_key_handle_t handle); * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED * \retval #PSA_ERROR_BAD_STATE + * \p operation is either not initialized or is in use + * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize * results in this error code. @@ -602,7 +620,6 @@ psa_status_t psa_destroy_key(psa_key_handle_t handle); * * \retval #PSA_SUCCESS * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * The key does not have the #PSA_KEY_USAGE_EXPORT flag. * \retval #PSA_ERROR_NOT_SUPPORTED @@ -615,6 +632,8 @@ psa_status_t psa_destroy_key(psa_key_handle_t handle); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -671,7 +690,6 @@ psa_status_t psa_export_key(psa_key_handle_t handle, * * \retval #PSA_SUCCESS * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_INVALID_ARGUMENT * The key is neither a public key nor a key pair. * \retval #PSA_ERROR_NOT_SUPPORTED @@ -684,6 +702,8 @@ psa_status_t psa_export_key(psa_key_handle_t handle, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -771,7 +791,12 @@ psa_status_t psa_export_public_key(psa_key_handle_t handle, * \retval #PSA_ERROR_INSUFFICIENT_STORAGE * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_copy_key(psa_key_handle_t source_handle, const psa_key_attributes_t *attributes, @@ -802,10 +827,18 @@ psa_status_t psa_copy_key(psa_key_handle_t source_handle, * Success. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not a hash algorithm. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * \p hash_size is too small * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_compute(psa_algorithm_t alg, const uint8_t *input, @@ -831,10 +864,17 @@ psa_status_t psa_hash_compute(psa_algorithm_t alg, * differs from the expected hash. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not a hash algorithm. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * \p input_length or \p hash_length do not match the hash size for \p alg * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_compare(psa_algorithm_t alg, const uint8_t *input, @@ -921,7 +961,9 @@ static psa_hash_operation_t psa_hash_operation_init(void); * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_NOT_SUPPORTED - * \p alg is not supported or is not a hash algorithm. + * \p alg is not a supported hash algorithm. + * \retval #PSA_ERROR_INVALID_ARGUMENT + * \p alg is not a hash algorithm. * \retval #PSA_ERROR_BAD_STATE * The operation state is not valid (already set up and not * subsequently completed). @@ -929,6 +971,12 @@ static psa_hash_operation_t psa_hash_operation_init(void); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * \p operation is either not initialized or is in use + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg); @@ -951,6 +999,12 @@ psa_status_t psa_hash_setup(psa_hash_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, @@ -992,6 +1046,12 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, @@ -1028,6 +1088,12 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, @@ -1059,6 +1125,12 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_abort(psa_hash_operation_t *operation); @@ -1085,6 +1157,15 @@ psa_status_t psa_hash_abort(psa_hash_operation_t *operation); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_BAD_STATE + * The operation state is either not initialized or has already been setup. + * \retval #PSA_ERROR_BAD_STATE + * The operation state is either not initialized or has already been setup. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation); @@ -1123,10 +1204,14 @@ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, * \p handle is not compatible with \p alg. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not a MAC algorithm. + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * \p mac_size is too small * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * The key could not be retrieved from storage. * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -1165,6 +1250,12 @@ psa_status_t psa_mac_compute(psa_key_handle_t handle, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * The key could not be retrieved from storage. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_mac_verify(psa_key_handle_t handle, psa_algorithm_t alg, @@ -1258,7 +1349,6 @@ static psa_mac_operation_t psa_mac_operation_init(void); * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \p handle is not compatible with \p alg. @@ -1268,6 +1358,8 @@ static psa_mac_operation_t psa_mac_operation_init(void); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * The key could not be retrieved from storage. * \retval #PSA_ERROR_BAD_STATE * The operation state is not valid (already set up and not * subsequently completed). @@ -1318,7 +1410,6 @@ psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \c key is not compatible with \c alg. @@ -1328,6 +1419,8 @@ psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * The key could not be retrieved from storage * \retval #PSA_ERROR_BAD_STATE * The operation state is not valid (already set up and not * subsequently completed). @@ -1360,6 +1453,11 @@ psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_mac_update(psa_mac_operation_t *operation, const uint8_t *input, @@ -1402,6 +1500,11 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, uint8_t *mac, @@ -1438,6 +1541,11 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, const uint8_t *mac, @@ -1470,6 +1578,10 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_mac_abort(psa_mac_operation_t *operation); @@ -1512,6 +1624,11 @@ psa_status_t psa_mac_abort(psa_mac_operation_t *operation); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_encrypt(psa_key_handle_t handle, psa_algorithm_t alg, @@ -1552,7 +1669,12 @@ psa_status_t psa_cipher_encrypt(psa_key_handle_t handle, * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_decrypt(psa_key_handle_t handle, psa_algorithm_t alg, @@ -1648,7 +1770,6 @@ static psa_cipher_operation_t psa_cipher_operation_init(void); * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \p handle is not compatible with \p alg. @@ -1658,6 +1779,7 @@ static psa_cipher_operation_t psa_cipher_operation_init(void); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The operation state is not valid (already set up and not * subsequently completed). @@ -1710,7 +1832,6 @@ psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \p handle is not compatible with \p alg. @@ -1720,6 +1841,7 @@ psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The operation state is not valid (already set up and not * subsequently completed). @@ -1759,6 +1881,11 @@ psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, uint8_t *iv, @@ -1794,6 +1921,11 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const uint8_t *iv, @@ -1830,6 +1962,11 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, const uint8_t *input, @@ -1868,6 +2005,11 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, uint8_t *output, @@ -1901,6 +2043,10 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation); @@ -1941,16 +2087,18 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation); * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \p handle is not compatible with \p alg. * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not an AEAD algorithm. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * \p ciphertext_size is too small * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -1997,7 +2145,6 @@ psa_status_t psa_aead_encrypt(psa_key_handle_t handle, * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_INVALID_SIGNATURE * The ciphertext is not authentic. * \retval #PSA_ERROR_NOT_PERMITTED @@ -2006,9 +2153,12 @@ psa_status_t psa_aead_encrypt(psa_key_handle_t handle, * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not supported or is not an AEAD algorithm. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * \p plaintext_size or \p nonce_length is too small * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -2127,6 +2277,7 @@ static psa_aead_operation_t psa_aead_operation_init(void); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -2188,6 +2339,7 @@ psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -2225,6 +2377,11 @@ psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation, uint8_t *nonce, @@ -2259,6 +2416,11 @@ psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation, const uint8_t *nonce, @@ -2297,6 +2459,10 @@ psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, size_t ad_length, @@ -2339,6 +2505,11 @@ psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, const uint8_t *input, @@ -2411,6 +2582,11 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_update(psa_aead_operation_t *operation, const uint8_t *input, @@ -2480,6 +2656,11 @@ psa_status_t psa_aead_update(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_finish(psa_aead_operation_t *operation, uint8_t *ciphertext, @@ -2538,6 +2719,11 @@ psa_status_t psa_aead_finish(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_verify(psa_aead_operation_t *operation, uint8_t *plaintext, @@ -2573,6 +2759,10 @@ psa_status_t psa_aead_verify(psa_aead_operation_t *operation, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_aead_abort(psa_aead_operation_t *operation); @@ -2603,6 +2793,8 @@ psa_status_t psa_aead_abort(psa_aead_operation_t *operation); * that make up the returned signature value. * * \retval #PSA_SUCCESS + * \retval #PSA_ERROR_INVALID_HANDLE + * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p signature buffer is too small. You can * determine a sufficient buffer size by calling @@ -2615,6 +2807,7 @@ psa_status_t psa_aead_abort(psa_aead_operation_t *operation); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). @@ -2650,6 +2843,8 @@ psa_status_t psa_asymmetric_sign(psa_key_handle_t handle, * * \retval #PSA_SUCCESS * The signature is valid. + * \retval #PSA_ERROR_INVALID_HANDLE + * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_SIGNATURE * The calculation was perfomed successfully, but the passed * signature is not a valid signature. @@ -2659,6 +2854,7 @@ psa_status_t psa_asymmetric_sign(psa_key_handle_t handle, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -2700,6 +2896,8 @@ psa_status_t psa_asymmetric_verify(psa_key_handle_t handle, * that make up the returned output. * * \retval #PSA_SUCCESS + * \retval #PSA_ERROR_INVALID_HANDLE + * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p output buffer is too small. You can * determine a sufficient buffer size by calling @@ -2712,6 +2910,7 @@ psa_status_t psa_asymmetric_verify(psa_key_handle_t handle, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). @@ -2756,6 +2955,8 @@ psa_status_t psa_asymmetric_encrypt(psa_key_handle_t handle, * that make up the returned output. * * \retval #PSA_SUCCESS + * \retval #PSA_ERROR_INVALID_HANDLE + * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_BUFFER_TOO_SMALL * The size of the \p output buffer is too small. You can * determine a sufficient buffer size by calling @@ -2768,6 +2969,7 @@ psa_status_t psa_asymmetric_encrypt(psa_key_handle_t handle, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY * \retval #PSA_ERROR_INVALID_PADDING * \retval #PSA_ERROR_BAD_STATE @@ -2881,7 +3083,13 @@ static psa_key_derivation_operation_t psa_key_derivation_operation_init(void); * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE + * The operation state is either not initialized or has already been setup. + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_key_derivation_setup( psa_key_derivation_operation_t *operation, @@ -2897,8 +3105,15 @@ psa_status_t psa_key_derivation_setup( * \param[out] capacity On success, the capacity of the operation. * * \retval #PSA_SUCCESS - * \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid. + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_key_derivation_get_capacity( const psa_key_derivation_operation_t *operation, @@ -2920,7 +3135,14 @@ psa_status_t psa_key_derivation_get_capacity( * In this case, the operation object remains valid and its capacity * remains unchanged. * \retval #PSA_ERROR_BAD_STATE + * The operation state is not valid. * \retval #PSA_ERROR_COMMUNICATION_FAILURE + * \retval #PSA_ERROR_HARDWARE_FAILURE + * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_key_derivation_set_capacity( psa_key_derivation_operation_t *operation, @@ -2963,6 +3185,7 @@ psa_status_t psa_key_derivation_set_capacity( * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The value of \p step is not valid given the state of \p operation. * \retval #PSA_ERROR_BAD_STATE @@ -2999,7 +3222,6 @@ psa_status_t psa_key_derivation_input_bytes( * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \c step is not compatible with the operation's algorithm. @@ -3009,6 +3231,7 @@ psa_status_t psa_key_derivation_input_bytes( * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The value of \p step is not valid given the state of \p operation. * \retval #PSA_ERROR_BAD_STATE @@ -3061,7 +3284,6 @@ psa_status_t psa_key_derivation_input_key( * \retval #PSA_SUCCESS * Success. * \retval #PSA_ERROR_INVALID_HANDLE - * \retval #PSA_ERROR_DOES_NOT_EXIST * \retval #PSA_ERROR_NOT_PERMITTED * \retval #PSA_ERROR_INVALID_ARGUMENT * \c private_key is not compatible with \c alg, @@ -3073,6 +3295,11 @@ psa_status_t psa_key_derivation_input_key( * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_key_derivation_key_agreement( psa_key_derivation_operation_t *operation, @@ -3107,6 +3334,11 @@ psa_status_t psa_key_derivation_key_agreement( * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_key_derivation_output_bytes( psa_key_derivation_operation_t *operation, @@ -3224,6 +3456,7 @@ psa_status_t psa_key_derivation_output_bytes( * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize @@ -3255,6 +3488,10 @@ psa_status_t psa_key_derivation_output_key( * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_key_derivation_abort( psa_key_derivation_operation_t *operation); @@ -3295,12 +3532,19 @@ psa_status_t psa_key_derivation_abort( * \p private_key is not compatible with \p alg, * or \p peer_key is not valid for \p alg or not compatible with * \p private_key. + * \retval #PSA_ERROR_BUFFER_TOO_SMALL + * \p output_size is too small * \retval #PSA_ERROR_NOT_SUPPORTED * \p alg is not a supported key agreement algorithm. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_STORAGE_FAILURE + * \retval #PSA_ERROR_BAD_STATE + * The library has not been previously initialized by psa_crypto_init(). + * It is implementation-dependent whether a failure to initialize + * results in this error code. */ psa_status_t psa_raw_key_agreement(psa_algorithm_t alg, psa_key_handle_t private_key, @@ -3331,6 +3575,7 @@ psa_status_t psa_raw_key_agreement(psa_algorithm_t alg, * \retval #PSA_SUCCESS * \retval #PSA_ERROR_NOT_SUPPORTED * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY + * \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED @@ -3373,6 +3618,8 @@ psa_status_t psa_generate_random(uint8_t *output, * \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_CORRUPTION_DETECTED + * \retval #PSA_ERROR_INSUFFICIENT_STORAGE + * \retval #PSA_ERROR_STORAGE_FAILURE * \retval #PSA_ERROR_BAD_STATE * The library has not been previously initialized by psa_crypto_init(). * It is implementation-dependent whether a failure to initialize diff --git a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto_platform.h b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto_platform.h index 572f40cd..d85a719c 100644 --- a/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto_platform.h +++ b/cores/arduino/mbed/features/mbedtls/mbed-crypto/inc/psa/crypto_platform.h @@ -1,7 +1,7 @@ /** * \file psa/crypto_platform.h * - * \brief PSA cryptography module: Mbed TLS platfom definitions + * \brief PSA cryptography module: Mbed TLS platform definitions * * \note This file may not be included directly. Applications must * include psa/crypto.h. diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/dhcp_service_api.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/dhcp_service_api.h index 27315a55..e4759a59 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/dhcp_service_api.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/dhcp_service_api.h @@ -217,6 +217,16 @@ void dhcp_service_update_server_address(uint32_t msg_tr_id, uint8_t *server_addr */ void dhcp_service_req_remove(uint32_t msg_tr_id); +/** + * \brief Stops transactions for a messages (retransmissions). + * + * Clears off sending retransmissions for a particular message transaction by finding it via its message class pointer. + * + * \param msg_class_ptr The message class pointer. + * + */ +void dhcp_service_req_remove_all(void *msg_class_ptr); + /** * \brief Timer tick function for retransmissions. * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h index 6bdfc7ee..e4a018fc 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/sw_mac.h @@ -97,6 +97,14 @@ extern int ns_sw_mac_phy_statistics_start(struct mac_api_s *mac_api, struct phy_ */ extern uint32_t ns_sw_mac_read_current_timestamp(struct mac_api_s *mac_api); +/** + * @brief Enable or disable Frame counter per security key. SW MAC must be create before enable this feature! + * @param mac_api MAC instance. + * @param enable_feature True will allocate frame counter table for devices / key False will clear mode and free counter table. + * @return 0 on success, -1 on fail. + */ +extern int8_t ns_sw_mac_enable_frame_counter_per_key(struct mac_api_s *mac_api, bool enable_feature); + #ifdef __cplusplus } #endif diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h index 53c26ecd..a4d4d460 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/nanostack/ws_bbr_api.h @@ -120,4 +120,46 @@ int ws_bbr_node_keys_remove(int8_t interface_id, uint8_t *eui64); */ int ws_bbr_node_access_revoke_start(int8_t interface_id); +/** + * Set EAPOL node limit + * + * Border router stores EAPOL key information for each authenticated node. + * Sets the maximum number of EAPOL nodes stored by border router. If count + * of node's exceed the limit, border router deletes the node information + * starting from oldest node (node that has authenticated longest time + * ago), to make room for new nodes. When network keys are updated, nodes + * which have been removed from storage, must make full authentication again. + * Value for this parameter should be set to be more than maximum amount of + * nodes that are expected to be connected to border router. + * + * \param interface_id Network interface ID. + * \param limit Limit for nodes + * + * \return 0, Node limit set + * \return <0 Node limit set failed. + */ +int ws_bbr_eapol_node_limit_set(int8_t interface_id, uint16_t limit); + +/** + * Extended certificate validation + */ +#define BBR_CRT_EXT_VALID_NONE 0x00 /**< Do not make extended validations */ +#define BBR_CRT_EXT_VALID_WISUN 0x01 /**< Validate Wi-SUN specific fields */ + +/** + * Sets extended certificate validation setting + * + * Sets extended certificate validation setting on border router. Function can be used + * to set which fields on client certificate are validated. + * + * \param interface_id Network interface ID + * \param validation Extended Certificate validation setting + * BBR_CRT_EXT_VALID_NONE Do not make extended validations + * BBR_CRT_EXT_VALID_WISUN Validate Wi-SUN specific fields + * + * \return 0 Validation setting was set + * \return <0 Setting set failed + */ +int ws_bbr_ext_certificate_validation_set(int8_t interface_id, uint8_t validation); + #endif /* WS_BBR_API_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_helper.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_helper.h index 025df031..3cee0175 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_helper.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/MAC/mac_helper.h @@ -69,7 +69,7 @@ int8_t mac_helper_security_default_key_set(struct protocol_interface_info_entry int8_t mac_helper_security_default_recv_key_set(struct protocol_interface_info_entry *interface, const uint8_t *key, uint8_t id, uint8_t keyid_mode); -int8_t mac_helper_security_auto_request_key_index_set(struct protocol_interface_info_entry *interface, uint8_t id); +int8_t mac_helper_security_auto_request_key_index_set(struct protocol_interface_info_entry *interface, uint8_t key_attibute_index, uint8_t id); int8_t mac_helper_security_next_key_set(struct protocol_interface_info_entry *interface, uint8_t *key, uint8_t id, uint8_t keyid_mode); diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.h index 510f3d96..6a89708f 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common.h @@ -143,6 +143,5 @@ uint32_t ws_common_version_timeout_get(uint8_t config); #define ws_common_etx_validate(interface, neigh) ((void) 0) #define ws_common_negative_aro_mark(interface, eui64)(false) - #endif //HAVE_WS #endif //WS_COMMON_H_ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h index b5b97061..4be2964e 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_common_defines.h @@ -186,8 +186,7 @@ typedef struct ws_bs_ie { #define WS_FAN_VERSION_1_0 1 #define WS_NEIGHBOR_LINK_TIMEOUT 2200 -#define WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT 60 -#define WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT 15 +#define WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT 120 #define WS_NEIGHBOR_NUD_TIMEOUT WS_NEIGHBOR_LINK_TIMEOUT / 2 #define WS_NEIGBOR_ETX_SAMPLE_MAX 3 diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_config.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_config.h index 0d63c67c..ee05b7fb 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_config.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_config.h @@ -133,4 +133,12 @@ extern uint8_t DEVICE_MIN_SENS; #define FRAME_COUNTER_INCREMENT 1000 // How much frame counter is incremented on start up #define FRAME_COUNTER_STORE_THRESHOLD 800 // How much frame counter must increment before it is stored + +/* + * RPL Configuration parameters + */ +#define WS_MAX_DAO_RETRIES 3 // With 40s, 80s, 160s, 320s, 640s +#define WS_MAX_DAO_INITIAL_TIMEOUT 400 // With 40s initial value exponentially increasing +#define WS_MIN_DIO_MULTICAST_CONFIG_ADVERTISMENT_COUNT 10 // Define 10 multicast advertisment when learn config or learn config update + #endif /* WS_CONFIG_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc.h index 1104431e..33891f05 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_llc.h @@ -30,6 +30,7 @@ struct mlme_security_s; struct ws_hopping_schedule_s; struct ws_neighbor_class_entry; struct mac_neighbor_table_entry; +struct ws_neighbor_temp_class_s; /** @@ -73,10 +74,23 @@ typedef struct asynch_request_s { * @brief LLC neighbour info request parameters */ typedef struct llc_neighbour_req { - struct mac_neighbor_table_entry *neighbor; /**< Generic Link Layer Neighbor information entry. */ - struct ws_neighbor_class_entry *ws_neighbor; /**< Wi-sun Neighbor information entry. */ + struct mac_neighbor_table_entry *neighbor; /**< Generic Link Layer Neighbor information entry. */ + struct ws_neighbor_class_entry *ws_neighbor; /**< Wi-sun Neighbor information entry. */ } llc_neighbour_req_t; +/** + * Neighbor temporary structure for storage FHSS data before create a real Neighbour info + */ +typedef struct ws_neighbor_temp_class_s { + struct ws_neighbor_class_entry neigh_info_list; /*!< Allocated hopping info array*/ + uint8_t mac64[8]; + uint8_t mpduLinkQuality; + int8_t signal_dbm; + ns_list_link_t link; +} ws_neighbor_temp_class_t; + +typedef NS_LIST_HEAD(ws_neighbor_temp_class_t, link) ws_neighbor_temp_list_t; + /** * @brief ws_asynch_ind ws asynch data indication * @param interface Interface pointer @@ -99,12 +113,11 @@ typedef void ws_asynch_confirm(struct protocol_interface_info_entry *interface, * @param mac_64 Neighbor 64-bit address * @param neighbor_buffer Buffer where neighbor infor is buffered * @param request_new true if is possible to allocate new entry - * @param multicast true if packet is multicast * * @return true when neighbor info is available * @return false when no neighbor info */ -typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new, bool multicast); +typedef bool ws_neighbor_info_request(struct protocol_interface_info_entry *interface, const uint8_t *mac_64, llc_neighbour_req_t *neighbor_buffer, bool request_new); /** * @brief ws_llc_create ws LLC module create @@ -204,6 +217,8 @@ void ws_llc_set_pan_information_pointer(struct protocol_interface_info_entry *in */ void ws_llc_hopping_schedule_config(struct protocol_interface_info_entry *interface, struct ws_hopping_schedule_s *hopping_schedule); +ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64); +void ws_llc_free_multicast_temp_entry(struct protocol_interface_info_entry *interface, ws_neighbor_temp_class_t *neighbor); #endif /* WS_LLC_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_neighbor_class.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_neighbor_class.h index 7fa0c9b6..2a0cbe2c 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_neighbor_class.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_neighbor_class.h @@ -45,6 +45,7 @@ typedef struct ws_neighbor_class_s { uint8_t list_size; /*!< List size*/ } ws_neighbor_class_t; + /** * ws_neighbor_class_alloc a function for allocate giving list size * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_auth.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_auth.h index dec5eb69..5c0f35d9 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_auth.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_auth.h @@ -54,6 +54,28 @@ */ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr, sec_prot_gtk_keys_t *gtks, sec_prot_gtk_keys_t *next_gtks, const sec_prot_certs_t *certs, timer_settings_t *timer_settings); +/** + * ws_pae_auth_timing_adjust Adjust retries and timings of the security protocols + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_auth_timing_adjust(uint8_t timing); + /** * ws_pae_auth_addresses_set set relay addresses * @@ -146,6 +168,26 @@ int8_t ws_pae_auth_node_keys_remove(protocol_interface_info_entry_t *interface_p */ int8_t ws_pae_auth_node_access_revoke_start(protocol_interface_info_entry_t *interface_ptr); +/** + * ws_pae_auth_node_limit_set set node limit + * + * \param interface_ptr interface + * \param limit limit for nodes + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_auth_node_limit_set(protocol_interface_info_entry_t *interface_ptr, uint16_t limit); + +/** + * ws_pae_auth_forced_gc garbage cleanup call + * + * \param interface_ptr interface + * + */ +void ws_pae_auth_forced_gc(protocol_interface_info_entry_t *interface_ptr); + /** * ws_pae_auth_gtk_hash_set GTK hash set callback * @@ -190,6 +232,7 @@ void ws_pae_auth_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_ #else #define ws_pae_auth_init(interface_ptr, gtks, next_gtks, certs, timer_settings) 1 +#define ws_pae_auth_timing_adjust(timing) 1 #define ws_pae_auth_addresses_set(interface_ptr, local_port, remote_addr, remote_port) 1 #define ws_pae_auth_delete NULL #define ws_pae_auth_cb_register(interface_ptr, hash_set, nw_key_insert, nw_key_index_set) {(void) hash_set;} @@ -198,6 +241,8 @@ void ws_pae_auth_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_ #define ws_pae_auth_nw_key_index_update NULL #define ws_pae_auth_node_keys_remove(interface_ptr, eui64) -1 #define ws_pae_auth_node_access_revoke_start(interface_ptr) +#define ws_pae_auth_node_limit_set(interface_ptr, limit) +#define ws_pae_auth_forced_gc(interface_ptr) #define ws_pae_auth_fast_timer NULL #define ws_pae_auth_slow_timer NULL diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_controller.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_controller.h index 2f1b6ce0..717ca112 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_controller.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_controller.h @@ -45,6 +45,17 @@ int8_t ws_pae_controller_set_target(protocol_interface_info_entry_t *interface_p */ int8_t ws_pae_controller_authenticate(protocol_interface_info_entry_t *interface_ptr); +/** + * ws_pae_controller_bootstrap_done indicates to PAE controller that bootstrap is ready + * + * \param interface_ptr interface + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_bootstrap_done(protocol_interface_info_entry_t *interface_ptr); + /** * ws_pae_controller_authenticator_start start PAE authenticator * @@ -114,6 +125,28 @@ int8_t ws_pae_controller_stop(protocol_interface_info_entry_t *interface_ptr); */ int8_t ws_pae_controller_delete(protocol_interface_info_entry_t *interface_ptr); +/** + * ws_pae_controller_timing_adjust Adjust retries and timings of the security protocols + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_timing_adjust(uint8_t timing); + /** * ws_pae_controller_certificate_chain_set set certificate chain * @@ -125,6 +158,26 @@ int8_t ws_pae_controller_delete(protocol_interface_info_entry_t *interface_ptr); */ int8_t ws_pae_controller_certificate_chain_set(const arm_certificate_chain_entry_s *chain); +/** + * ws_pae_controller_own_certificate_add add own certificate to certificate chain + * + * \param cert own certificate + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_own_certificate_add(const arm_certificate_entry_s *cert); + +/** + * ws_pae_controller_own_certificates_remove removes own certificates + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_own_certificates_remove(void); + /** * ws_pae_controller_trusted_certificate_add add trusted certificate * @@ -147,6 +200,15 @@ int8_t ws_pae_controller_trusted_certificate_add(const arm_certificate_entry_s * */ int8_t ws_pae_controller_trusted_certificate_remove(const arm_certificate_entry_s *cert); +/** + * ws_pae_controller_trusted_certificates_remove removes trusted certificates + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_trusted_certificates_remove(void); + /** * ws_pae_controller_certificate_revocation_list_add add certification revocation list * @@ -293,6 +355,30 @@ int8_t ws_pae_controller_node_keys_remove(int8_t interface_id, uint8_t *eui_64); */ int8_t ws_pae_controller_node_access_revoke_start(int8_t interface_id); +/** + * ws_pae_controller_node_limit_set set node limit + * + * \param interface_id interface identifier + * \param limit limit for nodes + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_node_limit_set(int8_t interface_id, uint16_t limit); + +/** + * ws_pae_controller_ext_certificate_validation_set enable or disable extended certificate validation + * + * \param interface_ptr interface + * \param enabled true to enable extended validation, false to disable + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_controller_ext_certificate_validation_set(int8_t interface_id, bool enabled); + /** * ws_pae_controller_active_key_update update active key (test interface) * @@ -437,7 +523,6 @@ int8_t ws_pae_controller_cb_register(protocol_interface_info_entry_t *interface_ */ void ws_pae_controller_fast_timer(uint16_t ticks); - /** * ws_pae_controller_slow_timer PAE controller slow timer call * @@ -448,6 +533,14 @@ void ws_pae_controller_slow_timer(uint16_t seconds); struct nvm_tlv_entry *ws_pae_controller_nvm_tlv_get(protocol_interface_info_entry_t *interface_ptr); +/** + * ws_pae_controller_forced_gc PAE controller garbage cleanup callback + * + * \param full_gc Full cleanup (true for critical garbage cleanup) + * + */ +void ws_pae_controller_forced_gc(bool full_gc); + #else #define ws_pae_controller_set_target(interface_ptr, target_pan_id, target_dest_eui_64) @@ -470,6 +563,8 @@ struct nvm_tlv_entry *ws_pae_controller_nvm_tlv_get(protocol_interface_info_entr #define ws_pae_controller_cb_register(interface_ptr, completed, nw_key_set, nw_key_clear, nw_send_key_index_set, pan_ver_increment) 1 #define ws_pae_controller_nvm_tlv_get(interface_ptr) NULL +#define ws_pae_controller_forced_gc NULL + #endif #endif /* WS_PAE_CONTROLLER_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_lib.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_lib.h index 2569637d..69b4a7ae 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_lib.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_lib.h @@ -33,7 +33,7 @@ typedef NS_LIST_HEAD(kmp_entry_t, link) kmp_list_t; typedef struct { kmp_list_t kmp_list; /**< Ongoing KMP negotiations */ - kmp_addr_t addr; /**< EUI-64 (Relay IP address, Relay port) */ + kmp_addr_t addr; /**< EUI-64 (Relay IP address, Relay port) */ sec_prot_keys_t sec_keys; /**< Security keys */ uint32_t ticks; /**< Ticks */ uint16_t retry_ticks; /**< Retry ticks */ @@ -280,6 +280,18 @@ void ws_pae_lib_supp_list_to_active(supp_list_t *active_supp_list, supp_list_t * */ void ws_pae_lib_supp_list_to_inactive(supp_list_t *active_supp_list, supp_list_t *inactive_supp_list, supp_entry_t *entry); +/** + * ws_pae_lib_supp_list_purge purge inactive supplicants list + * + * \param active_supp_list list of active supplicants + * \param inactive_supp_list list of inactive supplicants + * \param max_number maximum number of supplicant entries, can be set to 0 in combination with max_purge + * to free list entries even when maximum number supplicant entries has not been reached + * \param max_purge maximum number of supplicants to purge in one call, 0 means not limited + * + */ +void ws_pae_lib_supp_list_purge(supp_list_t *active_supp_list, supp_list_t *inactive_supp_list, uint16_t max_number, uint8_t max_purge); + /** * ws_pae_lib_supp_list_kmp_count counts the number of KMPs of a certain type in a list of supplicants * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_supp.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_supp.h index 4d22d73f..24de962f 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_supp.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_supp.h @@ -57,6 +57,29 @@ int8_t ws_pae_supp_init(protocol_interface_info_entry_t *interface_ptr, const se */ int8_t ws_pae_supp_delete(protocol_interface_info_entry_t *interface_ptr); + +/** + * ws_pae_supp_timing_adjust Adjust retries and timings of the 4WH protocol + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_supp_timing_adjust(uint8_t timing); + /** * ws_pae_supp_fast_timer PAE supplicant fast timer call * @@ -159,6 +182,17 @@ int8_t ws_pae_supp_gtk_hash_update(protocol_interface_info_entry_t *interface_pt */ int8_t ws_pae_supp_nw_key_index_update(protocol_interface_info_entry_t *interface_ptr, uint8_t index); +/** + * ws_pae_supp_eapol_target_remove remove EAPOL target set using authentication start + * + * \param interface_ptr interface + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t ws_pae_supp_eapol_target_remove(protocol_interface_info_entry_t *interface_ptr); + /** * ws_pae_supp_nw_key_index_set network send key index set callback * @@ -204,6 +238,7 @@ void ws_pae_supp_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_ #define ws_pae_supp_init(interface_ptr, certs, timer_settings) 1 #define ws_pae_supp_delete NULL +#define ws_pae_supp_timing_adjust(timing) 1 #define ws_pae_supp_cb_register(interface_ptr, completed, nw_key_insert, nw_key_index_set) #define ws_pae_supp_nw_info_set(interface_ptr, pan_id, network_name) -1 #define ws_pae_supp_nw_key_valid(interface_ptr) -1 @@ -214,6 +249,7 @@ void ws_pae_supp_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_ #define ws_pae_supp_border_router_addr_read NULL #define ws_pae_supp_gtk_hash_update NULL #define ws_pae_supp_nw_key_index_update NULL +#define ws_pae_supp_eapol_target_remove(interface_ptr) #endif diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_defines.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_defines.h index 25a18844..119c2c2e 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_defines.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_defines.h @@ -148,24 +148,19 @@ typedef struct mac_mcps_data_conf_fail_s { typedef struct protocol_interface_rf_mac_setup { int8_t mac_interface_id; - bool macUpState; + bool macUpState: 1; bool shortAdressValid: 1; //Define Dynamic src address to mac16 when it is true bool beaconSrcAddressModeLong: 1; //This force beacon src to mac64 otherwise shortAdressValid will define type + bool secFrameCounterPerKey: 1; bool mac_extension_enabled: 1; bool mac_ack_tx_active: 1; bool mac_frame_pending: 1; - uint16_t mac_short_address; - uint16_t pan_id; - uint8_t mac64[8]; - uint16_t coord_short_address; - uint8_t coord_long_address[8]; /* MAC Capability Information */ bool macCapRxOnIdle: 1; bool macCapCordinator: 1; bool macCapAssocationPermit: 1; bool macCapBatteryPowered: 1; bool macCapSecrutityCapability: 1; - bool macProminousMode: 1; bool macGTSPermit: 1; bool mac_security_enabled: 1; @@ -173,7 +168,6 @@ typedef struct protocol_interface_rf_mac_setup { bool mac_security_bypass_unknow_device: 1; /* Load balancing need this feature */ bool macAcceptAnyBeacon: 1; - /* TX process Flag */ bool macTxProcessActive: 1; bool macTxRequestAck: 1; @@ -188,6 +182,12 @@ typedef struct protocol_interface_rf_mac_setup { bool scan_active: 1; bool rf_csma_extension_supported: 1; bool ack_tx_possible: 1; + uint16_t mac_short_address; + uint16_t pan_id; + uint8_t mac64[8]; + uint16_t coord_short_address; + uint8_t coord_long_address[8]; + /* CSMA Params */ unsigned macMinBE: 4; unsigned macMaxBE: 4; @@ -200,7 +200,6 @@ typedef struct protocol_interface_rf_mac_setup { uint8_t scan_duration; //Needed??? mac_scan_type_t scan_type; - uint8_t mac_channel; //uint8_t cca_failure; @@ -253,6 +252,7 @@ typedef struct protocol_interface_rf_mac_setup { struct mlme_device_descriptor_s *device_description_table; uint8_t device_description_table_size; struct mlme_key_descriptor_s *key_description_table; + void *key_device_frame_counter_list_buffer; uint8_t key_description_table_size; uint8_t key_lookup_list_size; uint8_t key_usage_list_size; diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.h index 90a0cbf7..de61fe8b 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mcps_sap.h @@ -140,4 +140,6 @@ int mcps_packet_ingress_rate_limit_by_memory(uint8_t free_heap_percentage); uint32_t mac_mcps_sap_get_phy_timestamp(struct protocol_interface_rf_mac_setup *rf_mac_setup); +void mcps_pending_packet_counter_update_check(struct protocol_interface_rf_mac_setup *rf_mac_setup, mac_pre_build_frame_t *buffer); + #endif /* MAC_IEEE802_15_4_MAC_MCPS_SAP_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mlme.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mlme.h index 76e0c0c3..fb251c80 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mlme.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_mlme.h @@ -65,11 +65,6 @@ int8_t mac_mlme_get_req(struct protocol_interface_rf_mac_setup *rf_mac_setup, st void mac_extended_mac_set(struct protocol_interface_rf_mac_setup *rf_mac_setup, const uint8_t *mac64); -uint32_t mac_mlme_framecounter_get(struct protocol_interface_rf_mac_setup *rf_mac_setup); - -void mac_mlme_framecounter_increment(struct protocol_interface_rf_mac_setup *rf_mac_setup); -void mac_mlme_framecounter_decrement(struct protocol_interface_rf_mac_setup *rf_mac_setup); - /** * MLME Poll Request * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_security_mib.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_security_mib.h index 05be16d5..9ca75cd5 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_security_mib.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/MAC/IEEE802_15_4/mac_security_mib.h @@ -25,21 +25,26 @@ struct mac_description_storage_size_s; typedef struct mlme_key_descriptor_s { mlme_key_id_lookup_descriptor_t *KeyIdLookupList; - uint8_t KeyIdLookupListEntries; mlme_key_device_descriptor_t *KeyDeviceList; + mlme_key_usage_descriptor_t *KeyUsageList; + uint32_t *KeyDeviceFrameCouterList; + uint32_t KeyFrameCounter; + uint8_t Key[16]; uint8_t KeyDeviceListSize; uint8_t KeyDeviceListEntries; - mlme_key_usage_descriptor_t *KeyUsageList; + uint8_t KeyIdLookupListEntries; uint8_t KeyUsageListEntries; uint8_t KeyUsageListSize; - uint8_t Key[16]; - bool unique_key_descriptor; + bool unique_key_descriptor: 1; + bool KeyFrameCounterPerKey: 1; } mlme_key_descriptor_t; int8_t mac_sec_mib_init(struct protocol_interface_rf_mac_setup *rf_mac_setup, struct mac_description_storage_size_s *storage_sizes); void mac_sec_mib_deinit(struct protocol_interface_rf_mac_setup *rf_mac_setup); +int8_t mac_sec_mib_frame_counter_per_key_set(struct protocol_interface_rf_mac_setup *rf_mac_setup, bool enabled); + int8_t mac_sec_mib_device_description_set(uint8_t atribute_index, mlme_device_descriptor_t *device_descriptor, struct protocol_interface_rf_mac_setup *rf_mac_setup); int8_t mac_sec_mib_key_description_set(uint8_t atribute_index, mlme_key_descriptor_entry_t *key_descriptor, struct protocol_interface_rf_mac_setup *rf_mac_setup); @@ -52,10 +57,24 @@ uint8_t mac_mib_device_descption_attribute_get_by_descriptor(struct protocol_int mlme_key_descriptor_t *mac_sec_key_description_get(struct protocol_interface_rf_mac_setup *rf_mac_setup, mlme_security_t *key_source, uint8_t address_mode, uint8_t *address_ptr, uint16_t pan_id); +mlme_key_descriptor_t *mac_sec_key_description_get_by_attribute(struct protocol_interface_rf_mac_setup *rf_mac_setup, uint8_t atribute_index); + mlme_key_device_descriptor_t *mac_sec_mib_key_device_description_list_update(mlme_key_descriptor_t *key_descpription_table); mlme_key_device_descriptor_t *mac_sec_mib_key_device_description_discover_from_list(mlme_key_descriptor_t *key_descpription_table, uint8_t device_descriptor_handle); void mac_sec_mib_device_description_blacklist(struct protocol_interface_rf_mac_setup *rf_mac_setup, uint8_t device_handle); +void mac_sec_mib_key_device_frame_counter_set(mlme_key_descriptor_t *key_descpription_table, mlme_device_descriptor_t *device_info, uint32_t frame_counter, uint8_t attribute_index); + +uint32_t mac_mib_key_device_frame_counter_get(mlme_key_descriptor_t *key_descpription_table, mlme_device_descriptor_t *device_info, uint8_t attribute_index); + +uint32_t mac_sec_mib_key_outgoing_frame_counter_get(struct protocol_interface_rf_mac_setup *rf_mac_setup, mlme_key_descriptor_t *key_descpription); + +void mac_sec_mib_key_outgoing_frame_counter_set(struct protocol_interface_rf_mac_setup *rf_mac_setup, mlme_key_descriptor_t *key_descpription, uint32_t value); + +void mac_sec_mib_key_outgoing_frame_counter_increment(struct protocol_interface_rf_mac_setup *rf_mac_setup, mlme_key_descriptor_t *key_descpription); + +void mac_sec_mib_key_outgoing_frame_counter_decrement(struct protocol_interface_rf_mac_setup *rf_mac_setup, mlme_key_descriptor_t *key_descpription); + #endif /* MAC_SECURITY_MIB_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_control.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_control.h index f9c1b39e..17290fdd 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_control.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_control.h @@ -42,6 +42,8 @@ typedef void rpl_domain_callback_t(rpl_event_t event, void *handle); typedef void rpl_prefix_callback_t(struct prefix_entry_t *prefix, void *handle, uint8_t *parent_link_local); +typedef bool rpl_new_parent_callback_t(uint8_t *ll_parent_address, void *handle); + typedef struct rpl_domain { NS_LIST_HEAD_INCOMPLETE(struct rpl_instance) instances; ns_list_link_t link; @@ -54,6 +56,7 @@ typedef struct rpl_domain { bool force_leaf; rpl_domain_callback_t *callback; rpl_prefix_callback_t *prefix_cb; + rpl_new_parent_callback_t *new_parent_add; void *cb_handle; } rpl_domain_t; @@ -142,7 +145,8 @@ rpl_domain_t *rpl_control_create_domain(void); void rpl_control_delete_domain(rpl_domain_t *domain); void rpl_control_set_domain_on_interface(struct protocol_interface_info_entry *cur, rpl_domain_t *domain, bool downstream); void rpl_control_remove_domain_from_interface(struct protocol_interface_info_entry *cur); -void rpl_control_set_callback(rpl_domain_t *domain, rpl_domain_callback_t callback, rpl_prefix_callback_t prefix_learn_cb, void *cb_handle); +void rpl_control_free_domain_instances_from_interface(struct protocol_interface_info_entry *cur); +void rpl_control_set_callback(rpl_domain_t *domain, rpl_domain_callback_t callback, rpl_prefix_callback_t prefix_learn_cb, rpl_new_parent_callback_t new_parent_add, void *cb_handle); /* Target publishing */ void rpl_control_publish_host_address(rpl_domain_t *domain, const uint8_t addr[16], uint32_t lifetime); @@ -153,6 +157,9 @@ uint16_t rpl_control_parent_candidate_list_size(struct protocol_interface_info_e void rpl_control_neighbor_delete(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]); /* Parent link confirmation API extension */ void rpl_control_request_parent_link_confirmation(bool requested); +void rpl_control_set_dio_multicast_min_config_advertisment_count(uint8_t min_count); +void rpl_control_set_dao_retry_count(uint8_t count); +void rpl_control_set_initial_dao_ack_wait(uint16_t timeout_in_ms); void rpl_control_register_address(struct protocol_interface_info_entry *interface, const uint8_t addr[16]); void rpl_control_address_register_done(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16], uint8_t status); @@ -175,6 +182,7 @@ uint16_t rpl_control_current_rank(const struct rpl_instance *instance); #define rpl_control_fast_timer(ticks) ((void) 0) #define rpl_control_slow_timer(seconds) ((void) 0) #define rpl_control_remove_domain_from_interface(cur) ((void) 0) +#define rpl_control_free_domain_instances_from_interface(cur) ((void) 0) #define rpl_control_register_address(interface, addr) ((void) 0) #define rpl_control_address_register_done(interface, ll_addr, status) ((void) 0) diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_policy.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_policy.h index dc1094e5..c51adc81 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_policy.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_policy.h @@ -27,11 +27,20 @@ bool rpl_policy_join_config(rpl_domain_t *domain, const rpl_dodag_conf_t *conf, bool rpl_policy_request_dao_acks(const rpl_domain_t *domain, uint8_t mop); uint16_t rpl_policy_initial_dao_ack_wait(const rpl_domain_t *domain, uint8_t mop); +void rpl_policy_set_initial_dao_ack_wait(uint16_t timeout_in_ms); + +void rpl_policy_set_dao_retry_count(uint8_t count); +int8_t rpl_policy_dao_retry_count(); + int8_t rpl_policy_srh_next_hop_interface(rpl_domain_t *domain, int8_t if_id, const uint8_t *next_hop); uint16_t rpl_policy_modify_downward_cost_to_root_neighbour(rpl_domain_t *domain, int8_t if_id, const uint8_t *next_hop, uint16_t cost); uint16_t rpl_policy_parent_selection_period(rpl_domain_t *domain); uint16_t rpl_policy_etx_hysteresis(rpl_domain_t *domain); +//Return Fixed point multiple which base 1.0 is 0x0100 +uint16_t rpl_policy_dio_validity_period(rpl_domain_t *domain); +//Fixed point must 1.0 is 0x0100 +void rpl_policy_set_dio_validity_period(rpl_domain_t *domain, uint16_t fixed_point); uint16_t rpl_policy_etx_change_parent_selection_delay(rpl_domain_t *domain); uint16_t rpl_policy_dio_parent_selection_delay(rpl_domain_t *domain); @@ -56,5 +65,7 @@ uint16_t rpl_policy_mrhof_parent_switch_threshold(const rpl_domain_t *domain); uint16_t rpl_policy_mrhof_max_rank_stretch_for_extra_parents(const rpl_domain_t *domain); bool rpl_policy_parent_confirmation_requested(void); void rpl_policy_set_parent_confirmation_request(bool confirmation_requested); +uint8_t rpl_policy_dio_multicast_config_advertisment_min_count(void); +void rpl_policy_set_dio_multicast_config_advertisment_min_count(uint8_t min_count); #endif /* RPL_POLICY_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_structures.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_structures.h index 107ff9b6..1d4dcc0c 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_structures.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/RPL/rpl_structures.h @@ -90,6 +90,7 @@ struct rpl_dodag { bool leaf: 1; /* We are a leaf in this DODAG (by policy) */ bool have_config: 1; /* We have the config */ bool used: 1; /* We have ever been a member of this DODAG? */ + uint8_t new_config_advertisment_count; /* We have advertiment new config at multicasti DIO */ NS_LIST_HEAD(rpl_dodag_version_t, link) versions; /* List of DODAG versions (newest first) */ prefix_list_t prefixes; /* Prefixes advertised in DIO PIOs */ rpl_dio_route_list_t routes; /* Routes advertised in DIO RIOs*/ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/kmp/kmp_api.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/kmp/kmp_api.h index cb19ec16..c690aa9e 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/kmp/kmp_api.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/kmp/kmp_api.h @@ -152,6 +152,16 @@ void kmp_api_delete(kmp_api_t *kmp); */ kmp_type_e kmp_api_type_get(kmp_api_t *kmp); +/** + * kmp_api_type_get get receive disabled status + * + * \param kmp instance + * + * \return true/false true when receiving has been disabled + * + */ +bool kmp_api_receive_disable(kmp_api_t *kmp); + /** * kmp_api_type_from_id_get get KMP type from KMP id * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/auth_eap_tls_sec_prot.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/auth_eap_tls_sec_prot.h index cbe29524..8c3e1185 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/auth_eap_tls_sec_prot.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/auth_eap_tls_sec_prot.h @@ -33,4 +33,26 @@ */ int8_t auth_eap_tls_sec_prot_register(kmp_service_t *service); +/** + * auth_eap_tls_sec_prot_timing_adjust Adjust retries and timings of the EAP-TLS protocol + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t auth_eap_tls_sec_prot_timing_adjust(uint8_t timing); + #endif /* AUTH_EAP_TLS_SEC_PROT_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot_lib.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot_lib.h index 0de960bb..285e617d 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot_lib.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot_lib.h @@ -72,6 +72,19 @@ extern const uint8_t eap_msg_trace[4][10]; */ int8_t eap_tls_sec_prot_lib_message_allocate(tls_data_t *data, uint8_t head_len, uint16_t len); +/** + * eap_tls_sec_prot_lib_message_realloc allocates larger message buffer and copies existing data to it + * + * \param data data buffer which length is increased + * \param head_len header length + * \param new_len new length for the buffer + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t eap_tls_sec_prot_lib_message_realloc(tls_data_t *data, uint8_t head_len, uint16_t new_len); + /** * eap_tls_sec_prot_lib_message_free free message buffer * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/supp_eap_tls_sec_prot.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/supp_eap_tls_sec_prot.h index 78ececd7..2b1dded5 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/supp_eap_tls_sec_prot.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/eap_tls_sec_prot/supp_eap_tls_sec_prot.h @@ -33,5 +33,27 @@ */ int8_t supp_eap_tls_sec_prot_register(kmp_service_t *service); +/** + * supp_eap_sec_prot_timing_adjust Adjust retries and timings of the 4WH protocol + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t supp_eap_sec_prot_timing_adjust(uint8_t timing); + #endif /* SUPP_EAP_TLS_SEC_PROT_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.h index efeab123..67b96a41 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.h @@ -34,4 +34,26 @@ */ int8_t auth_fwh_sec_prot_register(kmp_service_t *service); +/** + * auth_fwh_sec_prot_timing_adjust Adjust retries and timings of the 4WH protocol + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t auth_fwh_sec_prot_timing_adjust(uint8_t timing); + #endif /* AUTH_FWH_SEC_PROT_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.h index 2cb2284e..83696258 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.h @@ -34,4 +34,26 @@ */ int8_t supp_fwh_sec_prot_register(kmp_service_t *service); +/** + * supp_fwh_sec_prot_timing_adjust Adjust retries and timings of the 4WH protocol + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t supp_fwh_sec_prot_timing_adjust(uint8_t timing); + #endif /* SUPP_FWH_SEC_PROT_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/gkh_sec_prot/auth_gkh_sec_prot.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/gkh_sec_prot/auth_gkh_sec_prot.h index 2ec9829b..daf09a4c 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/gkh_sec_prot/auth_gkh_sec_prot.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/gkh_sec_prot/auth_gkh_sec_prot.h @@ -28,4 +28,26 @@ */ int8_t auth_gkh_sec_prot_register(kmp_service_t *service); +/** + * auth_gkh_sec_prot_timing_adjust Adjust retries and timings of the GKH protocol + * + * Timing value is a generic number between 0 to 32 that goes from fast and + * reactive network to low bandwidth and long latency. + * + * example value definitions: + * 0-8 very fast network + * 9-16 medium network + * 16-24 slow network + * 25-32 extremely slow network + * + * There is no need to have lots variations in every layer if protocol is not very active in any case. + * + * \param timing Timing value. + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t auth_gkh_sec_prot_timing_adjust(uint8_t timing); + #endif /* AUTH_GKH_SEC_PROT_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_certs.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_certs.h index 3c2ce3d1..e9a25ece 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_certs.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_certs.h @@ -58,6 +58,8 @@ typedef struct { cert_chain_entry_t own_cert_chain; /**< Own certificate chain */ cert_chain_list_t trusted_cert_chain_list; /**< Trusted certificate chain lists */ cert_revocat_lists_t cert_revocat_lists; /**< Certificate Revocation Lists */ + uint16_t own_cert_chain_len; /**< Own certificate chain certificates length */ + bool ext_cert_valid_enabled : 1; /**< Extended certificate validation enabled */ } sec_prot_certs_t; /** @@ -78,6 +80,37 @@ int8_t sec_prot_certs_init(sec_prot_certs_t *certs); */ void sec_prot_certs_delete(sec_prot_certs_t *certs); +/** + * sec_prot_certs_ext_certificate_validation_set enable or disable extended certificate validation + * + * \param certs certificate information + * \param enabled true to enable extended validation, false to disable + * + * \return < 0 failure + * \return >= 0 success + * + */ +int8_t sec_prot_certs_ext_certificate_validation_set(sec_prot_certs_t *certs, bool enabled); + +/** + * sec_prot_certs_ext_certificate_validation_get get extended certificate validation setting + * + * \param certs certificate information + * + * \return true/false enabled or not + * + */ +bool sec_prot_certs_ext_certificate_validation_get(const sec_prot_certs_t *certs); + +/** + * sec_prot_certs_own_cert_chain_len_get get length of own certificate chain + * + * \param certs certificate information + * + * \return length of all the certificates in the own certificate chain + */ +uint16_t sec_prot_certs_own_cert_chain_len_get(const sec_prot_certs_t *certs); + /** * sec_prot_certs_chain_entry_create allocate memory for certificate chain entry * @@ -123,6 +156,15 @@ int8_t sec_prot_certs_cert_set(cert_chain_entry_t *entry, uint8_t index, uint8_t */ uint8_t *sec_prot_certs_cert_get(const cert_chain_entry_t *entry, uint8_t index, uint16_t *cert_len); +/** + * sec_prot_certs_cert_chain_entry_len_get get length of certificate chain on cert chain entry + * + * \param entry certificate chain entry + * + * \return total length of all the certificates in the entry + */ +uint16_t sec_prot_certs_cert_chain_entry_len_get(const cert_chain_entry_t *entry); + /** * sec_prot_certs_priv_key_set set certificate (chain) private key * diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_lib.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_lib.h index 4786e49c..1ade05bd 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_lib.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/sec_prot_lib.h @@ -32,6 +32,7 @@ #define FWH_NONCE_LENGTH 32 #define EUI64_LEN 8 #define SEC_TOTAL_TIMEOUT 30 * 60 * 10 // 30 minutes +#define SEC_INIT_TIMEOUT 60 * 10 // 60 seconds #define SEC_FINISHED_TIMEOUT 5 * 10 // 5 seconds @@ -295,4 +296,12 @@ bool sec_prot_result_timeout_check(sec_prot_common_t *data); */ bool sec_prot_result_ok_check(sec_prot_common_t *data); +/** + * sec_prot_default_timeout_set sets default timeout for protocol + * + * \param data common data + * + */ +void sec_prot_default_timeout_set(sec_prot_common_t *data); + #endif /* SEC_PROT_LIB_H_ */ diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/tls_sec_prot/tls_sec_prot.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/tls_sec_prot/tls_sec_prot.h index 5ed9621e..129648e1 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/tls_sec_prot/tls_sec_prot.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/Security/protocols/tls_sec_prot/tls_sec_prot.h @@ -23,7 +23,13 @@ * */ -#define TLS_SEC_PROT_BUFFER_SIZE 1200 // Send buffer size (maximum size for a TLS data for a flight) +/* TLS send buffer size not including certificates. This should include e.g. on + * server: server hello, server key exchange, certificate request and server + * hello done. */ +#define TLS_SEC_PROT_SEND_BUFFER_SIZE 500 + +/* TLS send buffer size increment if it is detected that buffer is too small */ +#define TLS_SEC_PROT_SEND_BUFFER_SIZE_INCREMENT 1000 /** * client_tls_sec_prot_register register client TLS protocol to KMP service diff --git a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/libDHCPv6/libDHCPv6.h b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/libDHCPv6/libDHCPv6.h index 7cbf1cdd..e3cb6128 100644 --- a/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/libDHCPv6/libDHCPv6.h +++ b/cores/arduino/mbed/features/nanostack/sal-stack-nanostack/source/libDHCPv6/libDHCPv6.h @@ -235,6 +235,7 @@ dhcpv6_client_server_data_t *libdhcpv6_nonTemporal_entry_get_by_iaid(uint32_t ia dhcpv6_client_server_data_t *libdhcpv6_nonTemporal_entry_get_by_transactionId(uint32_t txId); dhcpv6_client_server_data_t *libdhcpv6_nonTemporal_entry_get_by_prefix(int8_t interfaceId, uint8_t *prefix); dhcpv6_client_server_data_t *libdhcpv6_nonTemporal_entry_get_by_instance(uint8_t instanceId); +dhcpv6_client_server_data_t *libdhcpv6_nonTemporal_validate_class_pointer(void *class_ptr); uint8_t libdhcpv6_nonTemporal_entry_get_unique_instance_id(void); diff --git a/cores/arduino/mbed/features/netsocket/EMACInterface.h b/cores/arduino/mbed/features/netsocket/EMACInterface.h index a2034191..d6f71c81 100644 --- a/cores/arduino/mbed/features/netsocket/EMACInterface.h +++ b/cores/arduino/mbed/features/netsocket/EMACInterface.h @@ -103,6 +103,13 @@ class EMACInterface : public virtual NetworkInterface { */ virtual const char *get_ip_address(); + /** Get the IPv6 link local address + * + * @address SocketAddress representation of the link local IPv6 address + * @return 0 on success, negative error code on failure + */ + virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address); + /** Get the local network mask * * @return Null-terminated representation of the local network mask diff --git a/cores/arduino/mbed/features/netsocket/ICMPSocket.h b/cores/arduino/mbed/features/netsocket/ICMPSocket.h new file mode 100644 index 00000000..6d3223d4 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/ICMPSocket.h @@ -0,0 +1,50 @@ +/** \addtogroup netsocket */ +/** @{*/ +/* ICMPSocket + * Copyright (c) 2015 ARM Limited + * + * 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 ICMPSOCKET_H +#define ICMPSOCKET_H + +#include "netsocket/InternetSocket.h" +#include "netsocket/InternetDatagramSocket.h" +#include "netsocket/NetworkStack.h" +#include "netsocket/NetworkInterface.h" +#include "rtos/EventFlags.h" + + +/** ICMP socket implementation. + */ +class ICMPSocket : public InternetDatagramSocket { +public: + /** Create an uninitialized socket. + * + * @note Must call open to initialize the socket on a network stack. + */ + ICMPSocket(); + +#if !defined(DOXYGEN_ONLY) + +protected: + virtual nsapi_protocol_t get_proto(); + +#endif //!defined(DOXYGEN_ONLY) +}; + + +#endif + +/** @}*/ diff --git a/cores/arduino/mbed/features/netsocket/InternetDatagramSocket.h b/cores/arduino/mbed/features/netsocket/InternetDatagramSocket.h new file mode 100644 index 00000000..019a215a --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/InternetDatagramSocket.h @@ -0,0 +1,177 @@ +/** \addtogroup netsocket */ +/** @{*/ +/* InternetDatagramSocket + * Copyright (c) 2015 ARM Limited + * + * 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 INTERNETDATAGRAMSOCKET_H +#define INTERNETDATAGRAMSOCKET_H + +#include "netsocket/InternetSocket.h" +#include "netsocket/NetworkStack.h" +#include "netsocket/NetworkInterface.h" +#include "rtos/EventFlags.h" + + +/** InternetDatagramSocket socket implementation. + */ +class InternetDatagramSocket : public InternetSocket { +public: + + /** Send data to the specified host and port. + * + * By default, sendto blocks until data is sent. If socket is set to + * nonblocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned + * immediately. + * + * @param host Domain name of the remote host or a dotted notation IP address. + * @param port Port of the remote host. + * @param data Buffer of data to send to the host. + * @param size Size of the buffer in bytes. + * @retval int Number of sent bytes on success. + * @retval NSAPI_ERROR_NO_SOCKET in case socket was not created correctly. + * @retval NSAPI_ERROR_WOULD_BLOCK in case non-blocking mode is enabled + * and send cannot be performed immediately. + * @retval int Other negative error codes for stack-related failures. + * See @ref NetworkStack::socket_send. + */ + virtual nsapi_size_or_error_t sendto(const char *host, uint16_t port, + const void *data, nsapi_size_t size); + + /** Send data to the specified address. + * + * By default, sendto blocks until data is sent. If socket is set to + * nonblocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned + * immediately. + * + * @param address The SocketAddress of the remote host. + * @param data Buffer of data to send to the host. + * @param size Size of the buffer in bytes. + * @retval NSAPI_ERROR_DNS_FAILURE in case the address parameter cannot + * be resolved. + * @retval NSAPI_ERROR_NO_SOCKET in case socket was not created correctly. + * @retval NSAPI_ERROR_WOULD_BLOCK in case non-blocking mode is enabled + * and send cannot be performed immediately. + * @retval int Other negative error codes for stack-related failures. + * See \ref NetworkStack::socket_send. + */ + virtual nsapi_size_or_error_t sendto(const SocketAddress &address, + const void *data, nsapi_size_t size); + + /** Receive a datagram and store the source address in address if it's not NULL. + * + * By default, recvfrom blocks until a datagram is received. If socket is set to + * nonblocking or times out with no datagram, NSAPI_ERROR_WOULD_BLOCK + * is returned. + * + * @note If the datagram is larger than the buffer, the excess data is silently discarded. + * + * @note If socket is connected, only packets coming from connected peer address + * are accepted. + * + * @note recvfrom() is allowed write to address and data buffers even if error occurs. + * + * @param address Destination for the source address or NULL. + * @param data Destination buffer for RAW data to be received from the host. + * @param size Size of the buffer in bytes. + * @retval int Number of received bytes on success. + * @retval NSAPI_ERROR_NO_SOCKET in case socket was not created correctly. + * @retval NSAPI_ERROR_WOULD_BLOCK in case non-blocking mode is enabled + * and send cannot be performed immediately. + * @retval int Other negative error codes for stack-related failures. + * See \ref NetworkStack::socket_recv. + */ + virtual nsapi_size_or_error_t recvfrom(SocketAddress *address, + void *data, nsapi_size_t size); + + /** Set the remote address for next send() call and filtering + * of incoming packets. To reset the address, zero initialized + * SocketAddress must be in the address parameter. + * + * @param address The SocketAddress of the remote host. + * @return NSAPI_ERROR_OK on success. + */ + virtual nsapi_error_t connect(const SocketAddress &address); + + /** Send a raw data to connected remote address. + * + * By default, send blocks until all data is sent. If socket is set to + * nonblocking or times out, a partial amount can be written. + * NSAPI_ERROR_WOULD_BLOCK is returned if no data was written. + * + * @note The socket must be connected to a remote host before send() call. + * + * @param data Buffer of data to send to the host. + * @param size Size of the buffer in bytes. + * @retval int Number of sent bytes on success. + * @retval NSAPI_ERROR_NO_SOCKET in case socket was not created correctly. + * @retval NSAPI_ERROR_WOULD_BLOCK in case non-blocking mode is enabled + * and send cannot be performed immediately. + * @retval int Other negative error codes for stack-related failures. + * See \ref NetworkStack::socket_send. + */ + virtual nsapi_size_or_error_t send(const void *data, nsapi_size_t size); + + /** Receive data from a socket. + * + * This is equivalent to calling recvfrom(NULL, data, size). + * + * By default, recv blocks until some data is received. If socket is set to + * nonblocking or times out, NSAPI_ERROR_WOULD_BLOCK can be returned to + * indicate no data. + * + * @note recv() is allowed write to data buffer even if error occurs. + * + * @param data Pointer to buffer for data received from the host. + * @param size Size of the buffer in bytes. + * @retval int Number of received bytes on success. + * @retval NSAPI_ERROR_NO_SOCKET in case socket was not created correctly. + * @retval NSAPI_ERROR_WOULD_BLOCK in case non-blocking mode is enabled + * and send cannot be performed immediately. + * @retval int Other negative error codes for stack-related failures. + * See \ref NetworkStack::socket_recv. + */ + virtual nsapi_size_or_error_t recv(void *data, nsapi_size_t size); + + /** Not implemented for InternetDatagramSocket. + * + * @param error Not used. + * @return NSAPI_ERROR_UNSUPPORTED + */ + virtual Socket *accept(nsapi_error_t *error = NULL); + + /** Not implemented for InternetDatagramSocket. + * + * @param backlog Not used. + * @return NSAPI_ERROR_UNSUPPORTED + */ + virtual nsapi_error_t listen(int backlog = 1); +#if !defined(DOXYGEN_ONLY) + +protected: + + /** Create an uninitialized socket. + * + * @note Must call open to initialize the socket on a network stack. + */ + InternetDatagramSocket() = default; + +#endif //!defined(DOXYGEN_ONLY) +}; + + +#endif + +/** @}*/ diff --git a/cores/arduino/mbed/features/netsocket/NetworkInterface.h b/cores/arduino/mbed/features/netsocket/NetworkInterface.h index 40724a9d..ef97733d 100644 --- a/cores/arduino/mbed/features/netsocket/NetworkInterface.h +++ b/cores/arduino/mbed/features/netsocket/NetworkInterface.h @@ -107,6 +107,13 @@ class NetworkInterface: public DNS { */ virtual const char *get_ip_address(); + /** Get the IPv6 link local address + * + * @address SocketAddress representation of the link local IPv6 address + * @return NSAPI_ERROR_OK on success, negative error code on failure + */ + virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address); + /** Get the local network mask. * * @return Null-terminated representation of the local network mask diff --git a/cores/arduino/mbed/features/netsocket/NetworkStack.h b/cores/arduino/mbed/features/netsocket/NetworkStack.h index a9cc6e5b..e7cd244e 100644 --- a/cores/arduino/mbed/features/netsocket/NetworkStack.h +++ b/cores/arduino/mbed/features/netsocket/NetworkStack.h @@ -48,6 +48,13 @@ class NetworkStack: public DNS { */ virtual const char *get_ip_address(); + /** Get the IPv6 link local address + * + * @address SocketAddress representation of the link local IPv6 address + * @return NSAPI_ERROR_OK on success, negative error code on failure + */ + virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address); + /** Get the local IP address on interface name * * @param interface_name Network interface_name diff --git a/cores/arduino/mbed/features/netsocket/OnboardNetworkStack.h b/cores/arduino/mbed/features/netsocket/OnboardNetworkStack.h index f68a6518..0a0c8430 100644 --- a/cores/arduino/mbed/features/netsocket/OnboardNetworkStack.h +++ b/cores/arduino/mbed/features/netsocket/OnboardNetworkStack.h @@ -119,6 +119,16 @@ class OnboardNetworkStack : public NetworkStack { virtual char *get_ip_address(char *buf, nsapi_size_t buflen) = 0; + /** Copies IPv6 link local address of the network interface in SocketAddress format + * + * @address SocketAddress representation of the link local IPv6 address + * @return NSAPI_ERROR_OK on success, negative error code on failure + */ + virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address) + { + return NSAPI_ERROR_UNSUPPORTED; + } + /** Copies IP address of the network interface to user supplied buffer * * @param buf buffer to which IP address will be copied as "W:X:Y:Z" diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac_config.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac_config.h index f8299a84..93d73f47 100644 --- a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac_config.h +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Arm Limited + * Copyright (c) 2019 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,11 +29,12 @@ */ #define SMSC9220_ETH_MTU_SIZE 1500U #define SMSC9220_ETH_IF_NAME "smsc9220" +#define SMSC9220_ETH_MAX_FRAME_SIZE 1522U /** \brief Defines for receiver thread */ #define FLAG_RX 1U #define LINK_STATUS_THREAD_PRIORITY (osPriorityNormal) -#define LINK_STATUS_THREAD_STACKSIZE 2048U +#define LINK_STATUS_THREAD_STACKSIZE 512U #define LINK_STATUS_TASK_PERIOD_MS 200U #define PHY_STATE_LINK_DOWN false #define PHY_STATE_LINK_UP true diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.h new file mode 100644 index 00000000..b11d0317 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2018-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_DHCP_SERVER_H +#define WHD_DHCP_SERVER_H + +#include "cy_result.h" +#include "cy_syslib.h" +#include "cynetwork_utils.h" +#include "UDPSocket.h" +#include "netsocket/NetworkInterface.h" +#include "netsocket/NetworkStack.h" +#include "rtos.h" + +/* DHCP data structure */ +typedef struct { + uint8_t Opcode; /* packet opcode type */ + uint8_t HwType; /* hardware addr type */ + uint8_t HwLen; /* hardware addr length */ + uint8_t Hops; /* gateway hops */ + uint32_t TransactionId; /* transaction ID */ + uint16_t SecsElapsed; /* seconds since boot began */ + uint16_t Flags; + uint32_t ClientIpAddr; /* client IP address */ + uint32_t YourIpAddr; /* 'your' IP address */ + uint32_t ServerIpAddr; /* server IP address */ + uint32_t GatewayIpAddr; /* gateway IP address */ + uint8_t ClientHwAddr[16]; /* client hardware address */ + uint8_t Legacy[192]; /* SName, File */ + uint32_t MagicCookie; + uint8_t Options[3]; /* options area */ + /* as of RFC2131 it is variable length */ +} dhcp_packet_t; + +#define DHCP_SUBNETMASK_OPTION_CODE (1) +#define DHCP_ROUTER_OPTION_CODE (3) +#define DHCP_DNS_SERVER_OPTION_CODE (6) +#define DHCP_HOST_NAME_OPTION_CODE (12) +#define DHCP_MTU_OPTION_CODE (26) +#define DHCP_REQUESTED_IP_ADDRESS_OPTION_CODE (50) +#define DHCP_LEASETIME_OPTION_CODE (51) +#define DHCP_MESSAGETYPE_OPTION_CODE (53) +#define DHCP_SERVER_IDENTIFIER_OPTION_CODE (54) +#define DHCP_PARAM_REQUEST_LIST_OPTION_CODE (55) +#define DHCP_WPAD_OPTION_CODE (252) +#define DHCP_END_OPTION_CODE (255) + +#define DHCP_IP_ADDRESS_CACHE_MAX (5) +#define ADDITIONAL_OPTION_BYTES (272) +#define DHCP_PACKET_SIZE (sizeof(dhcp_packet_t) + ADDITIONAL_OPTION_BYTES) + +/** DHCP thread could not be started */ +#define CY_DHCP_THREAD_CREATION_FAILED CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_BASE, 0) + +/** Error while trying to stop the DHCP server */ +#define CY_DHCP_STOP_FAILED CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_MIDDLEWARE_BASE, 1) + +/** + * Implementation of a DHCP sever + */ +class CyDhcpServer { +public: + /** + * Create a DHCP server. + */ + CyDhcpServer(NetworkStack *nstack, NetworkInterface *niface); + + /** + * Delete the DHCP server. + */ + virtual ~CyDhcpServer(); + + /** + * Start a DHCP server instance. + * @return CY_RSLT_SUCCESS on success otherwise error. + */ + cy_rslt_t start(void); + + /** + * Stop a DHCP server instance. + * @return CY_RSLT_SUCCESS on success otherwise error. + */ + cy_rslt_t stop(void); + +private: + NetworkStack *_nstack = NULL; + NetworkInterface *_niface = NULL; + UDPSocket _socket; + Thread _thread; + bool _running = false; + + cy_ip_addr_t _available_addr; + cy_ip_addr_t _server_addr; + cy_ip_addr_t _netmask; + + cy_mac_addr_t _mac_addr_cache[DHCP_IP_ADDRESS_CACHE_MAX]; + cy_ip_addr_t _ip_addr_cache[DHCP_IP_ADDRESS_CACHE_MAX]; + uint8_t _buff[DHCP_PACKET_SIZE]; + + static void threadWrapper(CyDhcpServer *obj); + void runServer(void); + + void setAddress(const cy_mac_addr_t &mac_id, const cy_ip_addr_t &addr); + bool lookupAddress(const cy_mac_addr_t &mac_id, cy_ip_addr_t &addr); + void freeAddress(const cy_mac_addr_t &mac_id); + + void handleDiscover(dhcp_packet_t *dhcp); + void handleRequest(dhcp_packet_t *dhcp); +}; + +#endif /* WHD_DHCP_SERVER_H */ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdAccessPoint.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdAccessPoint.h new file mode 100644 index 00000000..5ceaba62 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdAccessPoint.h @@ -0,0 +1,74 @@ +/* WHD Access Point Interface + * Copyright (c) 2017-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_ACCESS_POINT_H +#define WHD_ACCESS_POINT_H + +#include "netsocket/WiFiAccessPoint.h" +#include "whd_types.h" + +/* Enum for scan result type */ +enum scan_result_type { + SRES_TYPE_WIFI_ACCESS_POINT, + SRES_TYPE_WHD_ACCESS_POINT +}; + +/** WhdAccessPoint class + * + * Class that represents a Whd Access Point + * which contains additional Whd specific information + */ +class WhdAccessPoint : public WiFiAccessPoint { +public: + WhdAccessPoint() : WiFiAccessPoint() {}; + WhdAccessPoint(nsapi_wifi_ap_t ap, whd_bss_type_t bss_type, uint8_t *ie_ptr, uint32_t ie_len); + + /** Define move assignment and prevent copy-assignment + * + * Due to IE element data could have large memory footprint, + * only move assignment is allowed. + */ + WhdAccessPoint &operator=(WhdAccessPoint &&rhs); + WhdAccessPoint &operator=(const WhdAccessPoint &rhs) = delete; + + /** Get WHD access point's bss type + * + * @return The whd_bss_type_t of the access point + */ + whd_bss_type_t get_bss_type() const; + + /** Get WHD access point's IE data + * + * @return The pointer to ie data buffer + */ + uint8_t *get_ie_data() const; + + /** Get WHD access point's IE length + * + * @return The ie data length + */ + uint32_t get_ie_len() const; + + virtual ~WhdAccessPoint(); + +private: + whd_bss_type_t _bss_type; + uint8_t *_ie_ptr; /**< Pointer to received Beacon/Probe Response IE(Information Element) */ + uint32_t _ie_len; /**< Length of IE(Information Element) */ +}; + +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.h new file mode 100644 index 00000000..2bda49d1 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSTAInterface.h @@ -0,0 +1,254 @@ +/* WHD implementation of NetworkInterfaceAPI + * Copyright (c) 2017-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_STA_INTERFACE_H +#define WHD_STA_INTERFACE_H + +#include "netsocket/WiFiInterface.h" +#include "netsocket/EMACInterface.h" +#include "netsocket/OnboardNetworkStack.h" +#include "WhdAccessPoint.h" +#include "whd_emac.h" +#include "whd_interface.h" +#include "whd_types_int.h" + +struct ol_desc; + +/** WhdSTAInterface class + * Implementation of the NetworkStack for the WHD + */ +class WhdSTAInterface : public WiFiInterface, public EMACInterface { +public: + class OlmInterface { + public: + /** Get the default OLM interface. */ + static OlmInterface &get_default_instance(); + + OlmInterface(struct ol_desc *list = NULL) {} + + virtual int init_ols(void *whd, void *ip) + { + return 0; + } + virtual int sleep() + { + return 0; + } + virtual int wake() + { + return 0; + } + + virtual void deinit_ols(void) {} + }; + + WhdSTAInterface( + WHD_EMAC &emac = WHD_EMAC::get_instance(), + OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance(), + OlmInterface &olm = OlmInterface::get_default_instance(), + whd_interface_shared_info_t &shared = whd_iface_shared); + + static WhdSTAInterface *get_default_instance(); + + /* Turn on the wifi device*/ + void wifi_on(); + + /** Start the interface + * + * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. + * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. + * + * @return 0 on success, negative error code on failure + */ + nsapi_error_t connect(); + + /** Start the interface + * + * Attempts to connect to a WiFi network. + * + * @param ssid Name of the network to connect to + * @param pass Security passphrase to connect to the network + * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) + * @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED + * @return 0 on success, or error code on failure + */ + nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0); + + /** Stop the interface + * @return 0 on success, negative on failure + */ + nsapi_error_t disconnect(); + + /** Set the WiFi network credentials + * + * @param ssid Name of the network to connect to + * @param pass Security passphrase to connect to the network + * @param security Type of encryption for connection + * (defaults to NSAPI_SECURITY_NONE) + * @return 0 on success, or error code on failure + */ + nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE); + + /** Set the WiFi network channel - NOT SUPPORTED + * + * This function is not supported and will return NSAPI_ERROR_UNSUPPORTED + * + * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) + * @return Not supported, returns NSAPI_ERROR_UNSUPPORTED + */ + nsapi_error_t set_channel(uint8_t channel) + { + if (channel != 0) { + return NSAPI_ERROR_UNSUPPORTED; + } + + return 0; + } + + /** Set blocking status of interface. + * Nonblocking mode unsupported. + * + * @param blocking true if connect is blocking + * @return 0 on success, negative error code on failure + */ + nsapi_error_t set_blocking(bool blocking) + { + if (blocking) { + _blocking = blocking; + return NSAPI_ERROR_OK; + } else { + return NSAPI_ERROR_UNSUPPORTED; + } + } + + /** Gets the current radio signal strength for active connection + * + * @return Connection strength in dBm (negative value) + */ + int8_t get_rssi(); + + /** Scan for available networks in WiFiAccessPoint format + * + * This function will block. + * + * @param ap Pointer to allocated array of WiFiAccessPoint format for discovered AP + * @param count Size of allocated @a res array, or 0 to only count available AP + * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) + * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error + * see @a nsapi_error + */ + int scan(WiFiAccessPoint *res, unsigned count); + + /** Scan for available networks in WhdAccessPoint format + * + * This function will block. + * + * @param ap Pointer to allocated array of WhdAccessPoint format for discovered AP + * @param count Size of allocated @a res array, or 0 to only count available AP + * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) + * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error + * see @a nsapi_error + */ + int scan_whd(WhdAccessPoint *res, unsigned count); + + /* is interface connected, if yes return WICED_SUCCESS else WICED_NOT_CONNECTED */ + int is_interface_connected(); + + /* get bssid of the AP if success return WICED_SUCCESS else WICED_ERROR */ + int get_bssid(uint8_t *bssid); + + /* print WHD log (this routine will malloc/free a buffer + * You need to enable printing with WHD_LOGGING_BUFFER_ENABLE + */ + int whd_log_print(void); + + /* read WHD log */ + int whd_log_read(char *buffer, int buffer_size); + + /* Get EDCF AC params */ + nsapi_error_t wifi_get_ac_params_sta(void *ac_param); + + /* get iovar value */ + int wifi_get_iovar_value(const char *iovar, uint32_t *value); + + /* set iovar value */ + int wifi_set_iovar_value(const char *iovar, uint32_t value); + + /* set ioctl value */ + int wifi_set_ioctl_value(uint32_t ioctl, uint32_t value) ; + + /* get WHD ifp value */ + int wifi_get_ifp(whd_interface_t *ifp); + + /* set wifi interface up */ + int wifi_set_up(void); + + /* set wifi interface down */ + int wifi_set_down(void); + + /* set wifi coex configuration */ + int wifi_set_coex_config(whd_coex_config_t *coex_config); + + /** Set Offload Manager Information + * NOTE: Only allowed while disconnected + * + * @param olm Offload Manager info structure + * @return true if completed successfully + * false if Interface is connected + */ + int set_olm(OlmInterface *olm) + { + if (get_connection_status() == NSAPI_STATUS_DISCONNECTED) { + _olm = olm; + return true; + } + return false; + } + + /** Network stack is suspended + * + * @return 0 if successful + */ + int net_suspended() + { + int ret = _olm->sleep(); + return ret; + } + + /** Network stack is resuming + * + * @return 0 if successful + */ + int net_resuming() + { + int ret = _olm->wake(); + return ret; + } + +protected: + int internal_scan(WiFiAccessPoint *aps, unsigned count, scan_result_type sres_type); + +private: + char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */ + char _pass[64]; /* The longest allowed passphrase + 1 */ + nsapi_security_t _security; + WHD_EMAC &_whd_emac; + OlmInterface *_olm; + whd_interface_shared_info_t &_iface_shared; +}; + +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSoftAPInterface.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSoftAPInterface.h new file mode 100644 index 00000000..ced7c04f --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/WhdSoftAPInterface.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2018-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_SOFTAP_INTERFACE_H +#define WHD_SOFTAP_INTERFACE_H + +#include "netsocket/EMACInterface.h" +#include "netsocket/OnboardNetworkStack.h" +#include "whd_emac.h" +#include "CyDhcpServer.h" +#include "whd_interface.h" +#include + +/** + * Vendor IE details + */ +typedef struct { + uint8_t oui[WIFI_IE_OUI_LENGTH]; /**< Unique identifier for the IE */ + uint8_t subtype; /**< Sub-type of the IE */ + void *data; /**< Pointer to IE data */ + uint16_t length; /**< IE data length */ + uint16_t which_packets; /**< Mask of the packet in which this IE details to be included */ +} whd_custom_ie_info_t; + + + +/** WhdSoftAPInterface class + * Implementation of the SoftAPInterface for the Whd + */ +class WhdSoftAPInterface : public EMACInterface { +public: + /** Construct SoftAP interface + * @return pointer to default WhdSoftAPInterface instance + */ + WhdSoftAPInterface(WHD_EMAC &emac = WHD_EMAC::get_instance(WHD_AP_ROLE), + OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance(), + whd_interface_shared_info_t &shared = whd_iface_shared); + + /** Get the default WhdSoftAPInterface instance. + * @return pointer to default WhdSoftAPInterface instance + */ + static WhdSoftAPInterface *get_default_instance(); + + /** Set static IP address for SoftAP + * + * Configures the static IP address of SoftAP + * Requires that the network is stopped. + * + * @param ip_address Null-terminated representation of the local IP address + * @param netmask Null-terminated representation of the local network mask + * @param gateway Null-terminated representation of the local gateway + * @return 0 on success, negative error code on failure + * int set_network(const char *ip_address, const char *netmask, const char *gateway); + */ + + /** Start a SoftAP + * + * @param ssid Name of the SoftAP to create + * @param pass Security passphrase for connection to SoftAP + * @param security Type of encryption for connection + * @param channel Channel for SoftAP + * @param start_dhcp_server Start dhcp server for connection + * @param whd_custom_ie Optional Custom IE + * @param ap_sta_concur Enable STA+AP concurrency mode + * + * @return 0 on success, or error code on failure + * see @a nsapi_error + */ + int start(const char *ssid, const char *pass, nsapi_security_t security, uint8_t channel, + bool start_dhcp_server = true, const whd_custom_ie_info_t *ie_info = NULL, bool ap_sta_concur = false); + + /** + * Remove Wi-Fi custom IE + * + * @param[in] ie_info : Pointer to the structure which contains custom IE information + * + * @return 0 on success, or error code on failure + * see @a nsapi_error + */ + int remove_custom_ie(const whd_custom_ie_info_t *ie_info); + + /** Stop the Software Access Point + * + * @return 0 on success, or error code on failure + * see @a nsapi_error + */ + int stop(void); + + /** + * Gets information about associated clients. + * + * @note Only applicable if softAP interface is up + * + * @param[out] client_list_buffer : pointer to a buffer that will be populated with a variable length structure defined by @ref whd_maclist_t + * @param[in] buffer_length : length of the buffer + * + * @return 0 on success, or error code on failure + * see @a nsapi_error + */ + int get_associated_client_list(void *client_list_buffer, uint16_t buffer_length); + + + /** + * Register soft AP event handler + * + * @param[in] softap_event_handler : A function pointer to the event handler + * + * @return 0 on success, or error code on failure + * see @a nsapi_error + */ + int register_event_handler(whd_event_handler_t softap_event_handler); + + /** + * Unregister soft AP event handler + * + * @return 0 on success, or error code on failure + * see @a nsapi_error + */ + int unregister_event_handler(void); + + /** Set blocking status of interface. + * Nonblocking mode unsupported. + * + * @param blocking true if connect is blocking + * @return 0 on success, negative error code on failure + */ + nsapi_error_t set_blocking(bool blocking) + { + if (blocking) { + _blocking = blocking; + return NSAPI_ERROR_OK; + } else { + return NSAPI_ERROR_UNSUPPORTED; + } + } + +protected: + WHD_EMAC &_whd_emac; + std::unique_ptr _dhcp_server; + whd_interface_shared_info_t &_iface_shared; +}; + +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/emac_eapol.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/emac_eapol.h new file mode 100644 index 00000000..52340659 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/emac_eapol.h @@ -0,0 +1,65 @@ +/* + * Copyright 2019 Cypress Semiconductor Corporation + * SPDX-License-Identifier: Apache-2.0 + * + * 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 INCLUDED_EMAC_EAPOL_H_ +#define INCLUDED_EMAC_EAPOL_H_ + +#include "whd.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/****************************************************** + * Macros + ******************************************************/ + +/****************************************************** + * Constants + ******************************************************/ +#define EAPOL_PACKET_TYPE (0x888E) + +/****************************************************** + * Enumerations + ******************************************************/ + +/****************************************************** + * Type Definitions + ******************************************************/ + +typedef whd_buffer_t whd_eapol_packet_t; + +typedef void (*eapol_packet_handler_t)(whd_interface_t interface, whd_buffer_t buffer); + +/****************************************************** + * Structures + ******************************************************/ + +/****************************************************** + * Global Variables + ******************************************************/ + +/****************************************************** + * Function Declarations + ******************************************************/ +whd_result_t emac_register_eapol_packet_handler(eapol_packet_handler_t eapol_packet_handler); +void emac_unregister_eapol_packet_handler(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* ifndef INCLUDED_EMAC_EAPOL_H_ */ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/whd_emac.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/whd_emac.h new file mode 100644 index 00000000..d50486e6 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/whd_emac.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2018-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_EMAC_H_ +#define WHD_EMAC_H_ + +#include "EMAC.h" +#include "EMACInterface.h" +#include "WiFiInterface.h" +#include "whd_int.h" + +#include "rtos/Semaphore.h" +#include "rtos/Mutex.h" + +class WHD_EMAC : public EMAC { +public: + WHD_EMAC(whd_interface_role_t itype = WHD_STA_ROLE, const uint8_t *mac_addr = NULL); + + static WHD_EMAC &get_instance(whd_interface_role_t role = WHD_STA_ROLE, const uint8_t *mac_addr = NULL); + + /** + * Return maximum transmission unit + * + * @return MTU in bytes + */ + virtual uint32_t get_mtu_size() const; + + /** + * Gets memory buffer alignment preference + * + * Gets preferred memory buffer alignment of the Emac device. IP stack may or may not + * align link out memory buffer chains using the alignment. + * + * @return Memory alignment requirement in bytes + */ + virtual uint32_t get_align_preference() const; + + /** + * Return interface name + * + * @param name Pointer to where the name should be written + * @param size Maximum number of character to copy + */ + virtual void get_ifname(char *name, uint8_t size) const; + + /** + * Returns size of the underlying interface HW address size. + * + * @return HW address size in bytes + */ + virtual uint8_t get_hwaddr_size() const; + + /** + * Return interface-supplied HW address + * + * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size + * + * HW address need not be provided if this interface does not have its own HW + * address configuration; stack will choose address from central system + * configuration if the function returns false and does not write to addr. + * + * @param addr HW address for underlying interface + * @return true if HW address is available + */ + virtual bool get_hwaddr(uint8_t *addr) const; + + /** + * Set HW address for interface + * + * Provided address has to be of correct size, see @a get_hwaddr_size + * + * Called to set the MAC address to actually use - if @a get_hwaddr is provided + * the stack would normally use that, but it could be overridden, eg for test + * purposes. + * + * @param addr Address to be set + */ + virtual void set_hwaddr(const uint8_t *addr); + + /** + * Sends the packet over the link + * + * That can not be called from an interrupt context. + * + * @param buf Packet to be send + * @return True if the packet was send successfully, False otherwise + */ + virtual bool link_out(emac_mem_buf_t *buf); + + /** + * Initializes the HW + * + * @return True on success, False in case of an error. + */ + virtual bool power_up(); + + /** + * Deinitializes the HW + * + */ + virtual void power_down(); + + /** + * Sets a callback that needs to be called for packets received for that interface + * + * @param input_cb Function to be register as a callback + */ + virtual void set_link_input_cb(emac_link_input_cb_t input_cb); + + /** + * Sets a callback that needs to be called on link status changes for given interface + * + * @param state_cb Function to be register as a callback + */ + virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); + + /** Add device to a multicast group + * + * @param address A multicast group hardware address + */ + virtual void add_multicast_group(const uint8_t *address); + + /** Remove device from a multicast group + * + * @param address A multicast group hardware address + */ + virtual void remove_multicast_group(const uint8_t *address); + + /** Request reception of all multicast packets + * + * @param all True to receive all multicasts + * False to receive only multicasts addressed to specified groups + */ + virtual void set_all_multicast(bool all); + + /** Sets memory manager that is used to handle memory buffers + * + * @param mem_mngr Pointer to memory manager + */ + virtual void set_memory_manager(EMACMemoryManager &mem_mngr); + + /** Set callback to receive EMAC activity events + * + * @param activity_cb The callback for activity events + */ + virtual void set_activity_cb(mbed::Callback activity_cb); + + emac_link_input_cb_t emac_link_input_cb = NULL; /**< Callback for incoming data */ + emac_link_state_change_cb_t emac_link_state_cb = NULL; + EMACMemoryManager *memory_manager; + bool powered_up = false; + bool link_state = false; + bool ap_sta_concur = false; + whd_interface_role_t interface_type; + whd_driver_t drvp = NULL; + whd_interface_t ifp = NULL; + whd_mac_t unicast_addr; + whd_mac_t multicast_addr; + mbed::Callback activity_cb; +}; + +#endif /* WHD_EMAC_H_ */ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/whd_interface.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/whd_interface.h new file mode 100644 index 00000000..73dbe301 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/whd_interface.h @@ -0,0 +1,51 @@ +/* WHD implementation of NetworkInterfaceAPI + * Copyright (c) 2017-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_INTERFACE_H +#define WHD_INTERFACE_H + +#include "rtos/Mutex.h" +#include "OnboardNetworkStack.h" + +/** WhdSTAInterface class + * Shared information + */ +#define IF_STATUS_ALL_IF_DOWN 0x0 +#define IF_STATUS_STA_UP 0x1 +#define IF_STATUS_SOFT_AP_UP 0x2 + +enum whd_default_interface_config +{ + DEFAULT_IF_NOT_SET, + DEFAULT_IF_STA, + DEFAULT_IF_SOFT_AP +}; + +struct whd_interface_shared_info_t { + rtos::Mutex mutex; + whd_default_interface_config default_if_cfg; + uint32_t if_status_flags; + OnboardNetworkStack::Interface *iface_sta; + OnboardNetworkStack::Interface *iface_softap; + whd_interface_shared_info_t() : default_if_cfg(DEFAULT_IF_NOT_SET), if_status_flags(IF_STATUS_ALL_IF_DOWN), + iface_sta(NULL), iface_softap(NULL) + {} +}; + +extern whd_interface_shared_info_t whd_iface_shared; + +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/network/whd_network.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/network/whd_network.h new file mode 100644 index 00000000..7d7e48fb --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/network/whd_network.h @@ -0,0 +1,135 @@ +/* mbed Microcontroller Library + * Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WICED_NETWORK_H +#define WICED_NETWORK_H +#include "w_dtls_types.h" +#include "wiced_result.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/****************************************************** + * Macros + ******************************************************/ + +#define IP_HANDLE(interface) (wiced_ip_handle[(interface) & 3]) + +/****************************************************** + * Constants + ******************************************************/ + +#define WICED_MAXIMUM_NUMBER_OF_SOCKETS_WITH_CALLBACKS (1) +#define WICED_MAXIMUM_NUMBER_OF_SERVER_SOCKETS (1) + +#define SIZE_OF_ARP_ENTRY sizeof(1) + +#define IP_STACK_SIZE (2 * 1024) +#define ARP_CACHE_SIZE (6 * SIZE_OF_ARP_ENTRY) +#define DHCP_STACK_SIZE (1024) +#define WICED_PKT_SIZE (1500) +#define WICED_ANY_PORT (0) + +/****************************************************** + * Enumerations + ******************************************************/ + +typedef enum { + WICED_SOCKET_ERROR +} wiced_socket_state_t; + +/****************************************************** + * Type Definitions + ******************************************************/ +typedef struct { + uint8_t *payload; + uint16_t len; + uint16_t pktstart; +} wiced_packet_t; + + +//typedef NOOS_DUMMY wiced_tls_context_type_t; +//typedef NOOS_DUMMY wiced_tls_context_t; +//typedef NOOS_DUMMY wiced_tls_session_t; +//typedef NOOS_DUMMY wiced_tls_certificate_t; +//typedef NOOS_DUMMY wiced_tls_endpoint_type_t; +typedef void *NOOS_TCP_SOCKET; + +/****************************************************** + * Structures + ******************************************************/ + +typedef struct wiced_tcp_socket_struct wiced_tcp_socket_t; +typedef struct wiced_udp_socket_struct wiced_udp_socket_t; + +typedef wiced_result_t (*wiced_tcp_socket_callback_t)(wiced_tcp_socket_t *socket, void *arg); +typedef wiced_result_t (*wiced_udp_socket_callback_t)(wiced_udp_socket_t *socket, void *arg); + +struct wiced_udp_socket_struct { + wiced_dtls_context_t *dtls_context; + struct { + wiced_tcp_socket_callback_t disconnect; + wiced_tcp_socket_callback_t receive; + wiced_tcp_socket_callback_t connect; + } callbacks; + void *callback_arg; +}; + +struct wiced_tcp_socket_struct { + NOOS_TCP_SOCKET socket; + wiced_tls_context_t *tls_context; + wiced_bool_t context_malloced; + struct { + wiced_tcp_socket_callback_t disconnect; + wiced_tcp_socket_callback_t receive; + wiced_tcp_socket_callback_t connect; + } callbacks; + void *callback_arg; +}; + +typedef struct { + wiced_tcp_socket_t socket[WICED_MAXIMUM_NUMBER_OF_SERVER_SOCKETS]; + int interface; + uint16_t port; + wiced_tls_identity_t *tls_identity; +} wiced_tcp_server_t; + +/****************************************************** + * Global Variables + ******************************************************/ +typedef struct { + int dummy; +} NOOS_IP; +typedef struct { + int dummy; +} NOOS_PACKET_POOL; +/* + * Note: These objects are for internal use only! + */ +extern NOOS_IP wiced_ip_handle [3]; +extern NOOS_PACKET_POOL wiced_packet_pools [2]; /* 0=TX, 1=RX */ + +/****************************************************** + * Function Declarations + ******************************************************/ + + +#ifdef __cplusplus +} /*extern "C" */ +#endif +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/utils/cynetwork_utils.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/utils/cynetwork_utils.h new file mode 100644 index 00000000..0a7bdc07 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/utils/cynetwork_utils.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 + +#include +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef MIN +extern int MIN(/*@sef@*/ int x, /*@sef@*/ int y); /* LINT : This tells lint that the parameter must be side-effect free. i.e. evaluation does not change any values (since it is being evaulated more than once */ +#define MIN(x,y) ((x) < (y) ? (x) : (y)) +#endif /* ifndef MIN */ + +#define FX_IPTYPE_IPV4 (0) +#define FX_IPTYPE_IPV6 (1) + +typedef union { + uint32_t addr; + uint8_t addrs[4]; +} cy_ip_addr_v4_t; + +typedef struct { + uint32_t addr[4]; +} cy_ip_addr_v6_t; + +typedef struct { + uint8_t type; + union { + cy_ip_addr_v4_t addrv4; + cy_ip_addr_v6_t addrv6; + }; +} cy_ip_addr_t; + +/** + * Structure for storing a MAC address (Wi-Fi Media Access Control address). + */ +typedef struct { + uint8_t octet[6]; /**< Unique 6-byte MAC address */ +} cy_mac_addr_t; + +/** + * Converts a unsigned long int to a decimal string + * + * @param value[in] : The unsigned long to be converted + * @param output[out] : The buffer which will receive the decimal string + * @param min_length[in] : the minimum number of characters to output (zero padding will apply if required). + * @param max_length[in] : the maximum number of characters to output (up to 10 ). There must be space for terminating NULL. + * + * @note: A terminating NULL is added. Wnsure that there is space in the buffer for this. + * + * @return the number of characters returned (excluding terminating null) + * + */ +uint8_t unsigned_to_decimal_string(uint32_t value, char *output, uint8_t min_length, uint8_t max_length); + +/** + * Convert a IPv4 address to a string + * + * @note: String is 16 bytes including terminating null + * + * @param[out] buffer : Buffer which will recieve the IPv4 string + * @param[in] ipv4_address : IPv4 address to convert + */ +void ipv4_to_string(char buffer[16], uint32_t ipv4_address); + +/** + * Convert a IPv4 address to a string + * + * @note: String is 16 bytes including terminating null + * + * @param[in] buffer : Buffer which has the IPv4 string + * @return ipv4_address (0 on failure) + */ +uint32_t string_to_ipv4(const char *buffer); + +#if defined(__cplusplus) +} +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F2/stm32xx_emac_config.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F2/stm32xx_emac_config.h new file mode 100644 index 00000000..bb5c55b1 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F2/stm32xx_emac_config.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 STM32XX_EMAC_CONFIG_H__ +#define STM32XX_EMAC_CONFIG_H__ + +#define ETH_IP_VERSION_V1 + +#define THREAD_STACKSIZE 512 + +#endif // #define STM32XX_EMAC_CONFIG_H__ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F4/TARGET_MODULE_UBLOX_ODIN_W2/wifi_emac/wifi_emac.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F4/TARGET_MODULE_UBLOX_ODIN_W2/wifi_emac/wifi_emac.h new file mode 100644 index 00000000..22e68baa --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F4/TARGET_MODULE_UBLOX_ODIN_W2/wifi_emac/wifi_emac.h @@ -0,0 +1,144 @@ +/* Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WIFI_EMAC_H_ +#define WIFI_EMAC_H_ + +#include "EMAC.h" +#include "cb_wlan_target_data.h" +#include "cb_wlan.h" + +class OdinWiFiEMAC : public EMAC { +public: + OdinWiFiEMAC(); + + static OdinWiFiEMAC &get_instance(); + + /** + * Return maximum transmission unit + * + * @return MTU in bytes + */ + virtual uint32_t get_mtu_size() const; + + /** + * Return interface name + * + * @param name Pointer to where the name should be written + * @param size Maximum number of character to copy + */ + virtual void get_ifname(char *name, uint8_t size) const; + + /** + * Returns size of the underlying interface HW address size. + * + * @return HW address size in bytes + */ + virtual uint8_t get_hwaddr_size() const; + + /** + * Return interface-supplied HW address + * + * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size + * + * HW address need not be provided if this interface does not have its own HW + * address configuration; stack will choose address from central system + * configuration if the function returns false and does not write to addr. + * + * @param addr HW address for underlying interface + * @return true if HW address is available + */ + virtual bool get_hwaddr(uint8_t *addr) const; + + /** + * Set HW address for interface + * + * Provided address has to be of correct size, see @a get_hwaddr_size + * + * Called to set the MAC address to actually use - if @a get_hwaddr is provided + * the stack would normally use that, but it could be overridden, eg for test + * purposes. + * + * @param addr Address to be set + */ + virtual void set_hwaddr(const uint8_t *addr); + + /** + * Sends the packet over the link + * + * That can not be called from an interrupt context. + * + * @param buf Packet to be send + * @return True if the packet was send successfully, False otherwise + */ + virtual bool link_out(emac_mem_buf_t *buf); + + /** + * Initializes the HW + * + * @return True on success, False in case of an error. + */ + virtual bool power_up(); + + /** + * Deinitializes the HW + * + */ + virtual void power_down(); + + /** + * Sets a callback that needs to be called for packets received for that interface + * + * @param input_cb Function to be register as a callback + */ + virtual void set_link_input_cb(emac_link_input_cb_t input_cb); + + /** + * Sets a callback that needs to be called on link status changes for given interface + * + * @param state_cb Function to be register as a callback + */ + virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); + + /** Sets memory manager that is used to handle memory buffers + * + * @param mem_mngr Pointer to memory manager + */ + virtual void set_memory_manager(EMACMemoryManager &mem_mngr); + + virtual uint32_t get_align_preference() const; + virtual void add_multicast_group(const uint8_t *address); + virtual void remove_multicast_group(const uint8_t *address); + virtual void set_all_multicast(bool all); + +private: + + emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */ + emac_link_state_change_cb_t emac_link_state_cb; /**< Link state change callback */ + EMACMemoryManager *memory_manager; + + friend cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame); + friend cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame); + friend cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size); + friend void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame); + friend cb_uint32 handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame); + + friend void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data); + friend void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo); + friend void send_wlan_packet(void *buf); +}; + +#endif /* WIFI_EMAC_H_ */ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F4/stm32xx_emac_config.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F4/stm32xx_emac_config.h new file mode 100644 index 00000000..bb5c55b1 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F4/stm32xx_emac_config.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 STM32XX_EMAC_CONFIG_H__ +#define STM32XX_EMAC_CONFIG_H__ + +#define ETH_IP_VERSION_V1 + +#define THREAD_STACKSIZE 512 + +#endif // #define STM32XX_EMAC_CONFIG_H__ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F7/stm32xx_emac_config.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F7/stm32xx_emac_config.h new file mode 100644 index 00000000..bb5c55b1 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32F7/stm32xx_emac_config.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 STM32XX_EMAC_CONFIG_H__ +#define STM32XX_EMAC_CONFIG_H__ + +#define ETH_IP_VERSION_V1 + +#define THREAD_STACKSIZE 512 + +#endif // #define STM32XX_EMAC_CONFIG_H__ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32H7/lan8742/lan8742.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32H7/lan8742/lan8742.h new file mode 100644 index 00000000..c3a096cf --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32H7/lan8742/lan8742.h @@ -0,0 +1,466 @@ +/** + ****************************************************************************** + * @file lan8742.h + * @author MCD Application Team + * @version V1.0.0 + * @date 08-March-2017 + * @brief This file contains all the functions prototypes for the + * lan8742.c PHY driver. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __LAN8742_H +#define __LAN8742_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include + +/** @addtogroup BSP + * @{ + */ + +/** @addtogroup Component + * @{ + */ + +/** @defgroup LAN8742 + * @{ + */ +/* Exported constants --------------------------------------------------------*/ +/** @defgroup LAN8742_Exported_Constants LAN8742 Exported Constants + * @{ + */ + +/** @defgroup LAN8742_Registers_Mapping LAN8742 Registers Mapping + * @{ + */ +#define LAN8742_BCR ((uint16_t)0x0000U) +#define LAN8742_BSR ((uint16_t)0x0001U) +#define LAN8742_PHYI1R ((uint16_t)0x0002U) +#define LAN8742_PHYI2R ((uint16_t)0x0003U) +#define LAN8742_ANAR ((uint16_t)0x0004U) +#define LAN8742_ANLPAR ((uint16_t)0x0005U) +#define LAN8742_ANER ((uint16_t)0x0006U) +#define LAN8742_ANNPTR ((uint16_t)0x0007U) +#define LAN8742_ANNPRR ((uint16_t)0x0008U) +#define LAN8742_MMDACR ((uint16_t)0x000DU) +#define LAN8742_MMDAADR ((uint16_t)0x000EU) +#define LAN8742_ENCTR ((uint16_t)0x0010U) +#define LAN8742_MCSR ((uint16_t)0x0011U) +#define LAN8742_SMR ((uint16_t)0x0012U) +#define LAN8742_TPDCR ((uint16_t)0x0018U) +#define LAN8742_TCSR ((uint16_t)0x0019U) +#define LAN8742_SECR ((uint16_t)0x001AU) +#define LAN8742_SCSIR ((uint16_t)0x001BU) +#define LAN8742_CLR ((uint16_t)0x001CU) +#define LAN8742_ISFR ((uint16_t)0x001DU) +#define LAN8742_IMR ((uint16_t)0x001EU) +#define LAN8742_PHYSCSR ((uint16_t)0x001FU) +/** + * @} + */ + +/** @defgroup LAN8742_BCR_Bit_Definition LAN8742 BCR Bit Definition + * @{ + */ +#define LAN8742_BCR_SOFT_RESET ((uint16_t)0x8000U) +#define LAN8742_BCR_LOOPBACK ((uint16_t)0x4000U) +#define LAN8742_BCR_SPEED_SELECT ((uint16_t)0x2000U) +#define LAN8742_BCR_AUTONEGO_EN ((uint16_t)0x1000U) +#define LAN8742_BCR_POWER_DOWN ((uint16_t)0x0800U) +#define LAN8742_BCR_ISOLATE ((uint16_t)0x0400U) +#define LAN8742_BCR_RESTART_AUTONEGO ((uint16_t)0x0200U) +#define LAN8742_BCR_DUPLEX_MODE ((uint16_t)0x0100U) +/** + * @} + */ + +/** @defgroup LAN8742_BSR_Bit_Definition LAN8742 BSR Bit Definition + * @{ + */ +#define LAN8742_BSR_100BASE_T4 ((uint16_t)0x8000U) +#define LAN8742_BSR_100BASE_TX_FD ((uint16_t)0x4000U) +#define LAN8742_BSR_100BASE_TX_HD ((uint16_t)0x2000U) +#define LAN8742_BSR_10BASE_T_FD ((uint16_t)0x1000U) +#define LAN8742_BSR_10BASE_T_HD ((uint16_t)0x0800U) +#define LAN8742_BSR_100BASE_T2_FD ((uint16_t)0x0400U) +#define LAN8742_BSR_100BASE_T2_HD ((uint16_t)0x0200U) +#define LAN8742_BSR_EXTENDED_STATUS ((uint16_t)0x0100U) +#define LAN8742_BSR_AUTONEGO_CPLT ((uint16_t)0x0020U) +#define LAN8742_BSR_REMOTE_FAULT ((uint16_t)0x0010U) +#define LAN8742_BSR_AUTONEGO_ABILITY ((uint16_t)0x0008U) +#define LAN8742_BSR_LINK_STATUS ((uint16_t)0x0004U) +#define LAN8742_BSR_JABBER_DETECT ((uint16_t)0x0002U) +#define LAN8742_BSR_EXTENDED_CAP ((uint16_t)0x0001U) +/** + * @} + */ + +/** @defgroup LAN8742_PHYI1R_Bit_Definition LAN8742 PHYI1R Bit Definition + * @{ + */ +#define LAN8742_PHYI1R_OUI_3_18 ((uint16_t)0xFFFFU) +/** + * @} + */ + +/** @defgroup LAN8742_PHYI2R_Bit_Definition LAN8742 PHYI2R Bit Definition + * @{ + */ +#define LAN8742_PHYI2R_OUI_19_24 ((uint16_t)0xFC00U) +#define LAN8742_PHYI2R_MODEL_NBR ((uint16_t)0x03F0U) +#define LAN8742_PHYI2R_REVISION_NBR ((uint16_t)0x000FU) +/** + * @} + */ + +/** @defgroup LAN8742_ANAR_Bit_Definition LAN8742 ANAR Bit Definition + * @{ + */ +#define LAN8742_ANAR_NEXT_PAGE ((uint16_t)0x8000U) +#define LAN8742_ANAR_REMOTE_FAULT ((uint16_t)0x2000U) +#define LAN8742_ANAR_PAUSE_OPERATION ((uint16_t)0x0C00U) +#define LAN8742_ANAR_PO_NOPAUSE ((uint16_t)0x0000U) +#define LAN8742_ANAR_PO_SYMMETRIC_PAUSE ((uint16_t)0x0400U) +#define LAN8742_ANAR_PO_ASYMMETRIC_PAUSE ((uint16_t)0x0800U) +#define LAN8742_ANAR_PO_ADVERTISE_SUPPORT ((uint16_t)0x0C00U) +#define LAN8742_ANAR_100BASE_TX_FD ((uint16_t)0x0100U) +#define LAN8742_ANAR_100BASE_TX ((uint16_t)0x0080U) +#define LAN8742_ANAR_10BASE_T_FD ((uint16_t)0x0040U) +#define LAN8742_ANAR_10BASE_T ((uint16_t)0x0020U) +#define LAN8742_ANAR_SELECTOR_FIELD ((uint16_t)0x000FU) +/** + * @} + */ + +/** @defgroup LAN8742_ANLPAR_Bit_Definition LAN8742 ANLPAR Bit Definition + * @{ + */ +#define LAN8742_ANLPAR_NEXT_PAGE ((uint16_t)0x8000U) +#define LAN8742_ANLPAR_REMOTE_FAULT ((uint16_t)0x2000U) +#define LAN8742_ANLPAR_PAUSE_OPERATION ((uint16_t)0x0C00U) +#define LAN8742_ANLPAR_PO_NOPAUSE ((uint16_t)0x0000U) +#define LAN8742_ANLPAR_PO_SYMMETRIC_PAUSE ((uint16_t)0x0400U) +#define LAN8742_ANLPAR_PO_ASYMMETRIC_PAUSE ((uint16_t)0x0800U) +#define LAN8742_ANLPAR_PO_ADVERTISE_SUPPORT ((uint16_t)0x0C00U) +#define LAN8742_ANLPAR_100BASE_TX_FD ((uint16_t)0x0100U) +#define LAN8742_ANLPAR_100BASE_TX ((uint16_t)0x0080U) +#define LAN8742_ANLPAR_10BASE_T_FD ((uint16_t)0x0040U) +#define LAN8742_ANLPAR_10BASE_T ((uint16_t)0x0020U) +#define LAN8742_ANLPAR_SELECTOR_FIELD ((uint16_t)0x000FU) +/** + * @} + */ + +/** @defgroup LAN8742_ANER_Bit_Definition LAN8742 ANER Bit Definition + * @{ + */ +#define LAN8742_ANER_RX_NP_LOCATION_ABLE ((uint16_t)0x0040U) +#define LAN8742_ANER_RX_NP_STORAGE_LOCATION ((uint16_t)0x0020U) +#define LAN8742_ANER_PARALLEL_DETECT_FAULT ((uint16_t)0x0010U) +#define LAN8742_ANER_LP_NP_ABLE ((uint16_t)0x0008U) +#define LAN8742_ANER_NP_ABLE ((uint16_t)0x0004U) +#define LAN8742_ANER_PAGE_RECEIVED ((uint16_t)0x0002U) +#define LAN8742_ANER_LP_AUTONEG_ABLE ((uint16_t)0x0001U) +/** + * @} + */ + +/** @defgroup LAN8742_ANNPTR_Bit_Definition LAN8742 ANNPTR Bit Definition + * @{ + */ +#define LAN8742_ANNPTR_NEXT_PAGE ((uint16_t)0x8000U) +#define LAN8742_ANNPTR_MESSAGE_PAGE ((uint16_t)0x2000U) +#define LAN8742_ANNPTR_ACK2 ((uint16_t)0x1000U) +#define LAN8742_ANNPTR_TOGGLE ((uint16_t)0x0800U) +#define LAN8742_ANNPTR_MESSAGGE_CODE ((uint16_t)0x07FFU) +/** + * @} + */ + +/** @defgroup LAN8742_ANNPRR_Bit_Definition LAN8742 ANNPRR Bit Definition + * @{ + */ +#define LAN8742_ANNPTR_NEXT_PAGE ((uint16_t)0x8000U) +#define LAN8742_ANNPRR_ACK ((uint16_t)0x4000U) +#define LAN8742_ANNPRR_MESSAGE_PAGE ((uint16_t)0x2000U) +#define LAN8742_ANNPRR_ACK2 ((uint16_t)0x1000U) +#define LAN8742_ANNPRR_TOGGLE ((uint16_t)0x0800U) +#define LAN8742_ANNPRR_MESSAGGE_CODE ((uint16_t)0x07FFU) +/** + * @} + */ + +/** @defgroup LAN8742_MMDACR_Bit_Definition LAN8742 MMDACR Bit Definition + * @{ + */ +#define LAN8742_MMDACR_MMD_FUNCTION ((uint16_t)0xC000U) +#define LAN8742_MMDACR_MMD_FUNCTION_ADDR ((uint16_t)0x0000U) +#define LAN8742_MMDACR_MMD_FUNCTION_DATA ((uint16_t)0x4000U) +#define LAN8742_MMDACR_MMD_DEV_ADDR ((uint16_t)0x001FU) +/** + * @} + */ + +/** @defgroup LAN8742_ENCTR_Bit_Definition LAN8742 ENCTR Bit Definition + * @{ + */ +#define LAN8742_ENCTR_TX_ENABLE ((uint16_t)0x8000U) +#define LAN8742_ENCTR_TX_TIMER ((uint16_t)0x6000U) +#define LAN8742_ENCTR_TX_TIMER_1S ((uint16_t)0x0000U) +#define LAN8742_ENCTR_TX_TIMER_768MS ((uint16_t)0x2000U) +#define LAN8742_ENCTR_TX_TIMER_512MS ((uint16_t)0x4000U) +#define LAN8742_ENCTR_TX_TIMER_265MS ((uint16_t)0x6000U) +#define LAN8742_ENCTR_RX_ENABLE ((uint16_t)0x1000U) +#define LAN8742_ENCTR_RX_MAX_INTERVAL ((uint16_t)0x0C00U) +#define LAN8742_ENCTR_RX_MAX_INTERVAL_64MS ((uint16_t)0x0000U) +#define LAN8742_ENCTR_RX_MAX_INTERVAL_256MS ((uint16_t)0x0400U) +#define LAN8742_ENCTR_RX_MAX_INTERVAL_512MS ((uint16_t)0x0800U) +#define LAN8742_ENCTR_RX_MAX_INTERVAL_1S ((uint16_t)0x0C00U) +#define LAN8742_ENCTR_EX_CROSS_OVER ((uint16_t)0x0002U) +#define LAN8742_ENCTR_EX_MANUAL_CROSS_OVER ((uint16_t)0x0001U) +/** + * @} + */ + +/** @defgroup LAN8742_MCSR_Bit_Definition LAN8742 MCSR Bit Definition + * @{ + */ +#define LAN8742_MCSR_EDPWRDOWN ((uint16_t)0x2000U) +#define LAN8742_MCSR_FARLOOPBACK ((uint16_t)0x0200U) +#define LAN8742_MCSR_ALTINT ((uint16_t)0x0040U) +#define LAN8742_MCSR_ENERGYON ((uint16_t)0x0002U) +/** + * @} + */ + +/** @defgroup LAN8742_SMR_Bit_Definition LAN8742 SMR Bit Definition + * @{ + */ +#define LAN8742_SMR_MODE ((uint16_t)0x00E0U) +#define LAN8742_SMR_PHY_ADDR ((uint16_t)0x001FU) +/** + * @} + */ + +/** @defgroup LAN8742_TPDCR_Bit_Definition LAN8742 TPDCR Bit Definition + * @{ + */ +#define LAN8742_TPDCR_DELAY_IN ((uint16_t)0x8000U) +#define LAN8742_TPDCR_LINE_BREAK_COUNTER ((uint16_t)0x7000U) +#define LAN8742_TPDCR_PATTERN_HIGH ((uint16_t)0x0FC0U) +#define LAN8742_TPDCR_PATTERN_LOW ((uint16_t)0x003FU) +/** + * @} + */ + +/** @defgroup LAN8742_TCSR_Bit_Definition LAN8742 TCSR Bit Definition + * @{ + */ +#define LAN8742_TCSR_TDR_ENABLE ((uint16_t)0x8000U) +#define LAN8742_TCSR_TDR_AD_FILTER_ENABLE ((uint16_t)0x4000U) +#define LAN8742_TCSR_TDR_CH_CABLE_TYPE ((uint16_t)0x0600U) +#define LAN8742_TCSR_TDR_CH_CABLE_DEFAULT ((uint16_t)0x0000U) +#define LAN8742_TCSR_TDR_CH_CABLE_SHORTED ((uint16_t)0x0200U) +#define LAN8742_TCSR_TDR_CH_CABLE_OPEN ((uint16_t)0x0400U) +#define LAN8742_TCSR_TDR_CH_CABLE_MATCH ((uint16_t)0x0600U) +#define LAN8742_TCSR_TDR_CH_STATUS ((uint16_t)0x0100U) +#define LAN8742_TCSR_TDR_CH_LENGTH ((uint16_t)0x00FFU) +/** + * @} + */ + +/** @defgroup LAN8742_SCSIR_Bit_Definition LAN8742 SCSIR Bit Definition + * @{ + */ +#define LAN8742_SCSIR_AUTO_MDIX_ENABLE ((uint16_t)0x8000U) +#define LAN8742_SCSIR_CHANNEL_SELECT ((uint16_t)0x2000U) +#define LAN8742_SCSIR_SQE_DISABLE ((uint16_t)0x0800U) +#define LAN8742_SCSIR_XPOLALITY ((uint16_t)0x0010U) +/** + * @} + */ + +/** @defgroup LAN8742_CLR_Bit_Definition LAN8742 CLR Bit Definition + * @{ + */ +#define LAN8742_CLR_CABLE_LENGTH ((uint16_t)0xF000U) +/** + * @} + */ + +/** @defgroup LAN8742_IMR_ISFR_Bit_Definition LAN8742 IMR ISFR Bit Definition + * @{ + */ +#define LAN8742_INT_8 ((uint16_t)0x0100U) +#define LAN8742_INT_7 ((uint16_t)0x0080U) +#define LAN8742_INT_6 ((uint16_t)0x0040U) +#define LAN8742_INT_5 ((uint16_t)0x0020U) +#define LAN8742_INT_4 ((uint16_t)0x0010U) +#define LAN8742_INT_3 ((uint16_t)0x0008U) +#define LAN8742_INT_2 ((uint16_t)0x0004U) +#define LAN8742_INT_1 ((uint16_t)0x0002U) +/** + * @} + */ + +/** @defgroup LAN8742_PHYSCSR_Bit_Definition LAN8742 PHYSCSR Bit Definition + * @{ + */ +#define LAN8742_PHYSCSR_AUTONEGO_DONE ((uint16_t)0x1000U) +#define LAN8742_PHYSCSR_HCDSPEEDMASK ((uint16_t)0x001CU) +#define LAN8742_PHYSCSR_10BT_HD ((uint16_t)0x0004U) +#define LAN8742_PHYSCSR_10BT_FD ((uint16_t)0x0014U) +#define LAN8742_PHYSCSR_100BTX_HD ((uint16_t)0x0008U) +#define LAN8742_PHYSCSR_100BTX_FD ((uint16_t)0x0018U) +/** + * @} + */ + +/** @defgroup LAN8742_Status LAN8742 Status + * @{ + */ + +#define LAN8742_STATUS_READ_ERROR ((int32_t)-5) +#define LAN8742_STATUS_WRITE_ERROR ((int32_t)-4) +#define LAN8742_STATUS_ADDRESS_ERROR ((int32_t)-3) +#define LAN8742_STATUS_RESET_TIMEOUT ((int32_t)-2) +#define LAN8742_STATUS_ERROR ((int32_t)-1) +#define LAN8742_STATUS_OK ((int32_t) 0) +#define LAN8742_STATUS_LINK_DOWN ((int32_t) 1) +#define LAN8742_STATUS_100MBITS_FULLDUPLEX ((int32_t) 2) +#define LAN8742_STATUS_100MBITS_HALFDUPLEX ((int32_t) 3) +#define LAN8742_STATUS_10MBITS_FULLDUPLEX ((int32_t) 4) +#define LAN8742_STATUS_10MBITS_HALFDUPLEX ((int32_t) 5) +#define LAN8742_STATUS_AUTONEGO_NOTDONE ((int32_t) 6) +/** + * @} + */ + +/** @defgroup LAN8742_IT_Flags LAN8742 IT Flags + * @{ + */ +#define LAN8742_WOL_IT LAN8742_INT_8 +#define LAN8742_ENERGYON_IT LAN8742_INT_7 +#define LAN8742_AUTONEGO_COMPLETE_IT LAN8742_INT_6 +#define LAN8742_REMOTE_FAULT_IT LAN8742_INT_5 +#define LAN8742_LINK_DOWN_IT LAN8742_INT_4 +#define LAN8742_AUTONEGO_LP_ACK_IT LAN8742_INT_3 +#define LAN8742_PARALLEL_DETECTION_FAULT_IT LAN8742_INT_2 +#define LAN8742_AUTONEGO_PAGE_RECEIVED_IT LAN8742_INT_1 +/** + * @} + */ + +/** + * @} + */ + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup LAN8742_Exported_Types LAN8742 Exported Types + * @{ + */ +typedef int32_t (*lan8742_Init_Func) (void); +typedef int32_t (*lan8742_DeInit_Func) (void); +typedef int32_t (*lan8742_ReadReg_Func) (uint32_t, uint32_t, uint32_t *); +typedef int32_t (*lan8742_WriteReg_Func) (uint32_t, uint32_t, uint32_t); +typedef int32_t (*lan8742_GetTick_Func) (void); + +typedef struct +{ + lan8742_Init_Func Init; + lan8742_DeInit_Func DeInit; + lan8742_WriteReg_Func WriteReg; + lan8742_ReadReg_Func ReadReg; + lan8742_GetTick_Func GetTick; +} lan8742_IOCtx_t; + + +typedef struct +{ + uint32_t DevAddr; + uint32_t Is_Initialized; + lan8742_IOCtx_t IO; + void *pData; +}lan8742_Object_t; +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup LAN8742_Exported_Functions LAN8742 Exported Functions + * @{ + */ +int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx); +int32_t LAN8742_Init(lan8742_Object_t *pObj); +int32_t LAN8742_DeInit(lan8742_Object_t *pObj); +int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj); +int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj); +int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj); +int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj); +int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState); +int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj); +int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj); +int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt); +int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt); +int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt); +int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt); +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif /* __LAN8742_H */ + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32H7/stm32xx_emac_config.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32H7/stm32xx_emac_config.h new file mode 100644 index 00000000..601fdf23 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/TARGET_STM32H7/stm32xx_emac_config.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2017 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 STM32XX_EMAC_CONFIG_H__ +#define STM32XX_EMAC_CONFIG_H__ + +#define ETH_IP_VERSION_V2 + +#define THREAD_STACKSIZE 512 + +#endif // #define STM32XX_EMAC_CONFIG_H__ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.h new file mode 100644 index 00000000..f846b45e --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.h @@ -0,0 +1,179 @@ +/* Copyright (c) 2017 ARM Limited + * + * 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 STM32_EMAC_H_ +#define STM32_EMAC_H_ + +#include "EMAC.h" +#include "rtos/Mutex.h" + +class STM32_EMAC : public EMAC { +public: + STM32_EMAC(); + + static STM32_EMAC &get_instance(); + + /** + * Return maximum transmission unit + * + * @return MTU in bytes + */ + virtual uint32_t get_mtu_size() const; + + /** + * Gets memory buffer alignment preference + * + * Gets preferred memory buffer alignment of the Emac device. IP stack may or may not + * align link out memory buffer chains using the alignment. + * + * @return Memory alignment requirement in bytes + */ + virtual uint32_t get_align_preference() const; + + /** + * Return interface name + * + * @param name Pointer to where the name should be written + * @param size Maximum number of character to copy + */ + virtual void get_ifname(char *name, uint8_t size) const; + + /** + * Returns size of the underlying interface HW address size. + * + * @return HW address size in bytes + */ + virtual uint8_t get_hwaddr_size() const; + + /** + * Return interface-supplied HW address + * + * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size + * + * HW address need not be provided if this interface does not have its own HW + * address configuration; stack will choose address from central system + * configuration if the function returns false and does not write to addr. + * + * @param addr HW address for underlying interface + * @return true if HW address is available + */ + virtual bool get_hwaddr(uint8_t *addr) const; + + /** + * Set HW address for interface + * + * Provided address has to be of correct size, see @a get_hwaddr_size + * + * Called to set the MAC address to actually use - if @a get_hwaddr is provided + * the stack would normally use that, but it could be overridden, eg for test + * purposes. + * + * @param addr Address to be set + */ + virtual void set_hwaddr(const uint8_t *addr); + + /** + * Sends the packet over the link + * + * That can not be called from an interrupt context. + * + * @param buf Packet to be send + * @return True if the packet was send successfully, False otherwise + */ + virtual bool link_out(emac_mem_buf_t *buf); + + /** + * Initializes the HW + * + * @return True on success, False in case of an error. + */ + virtual bool power_up(); + + /** + * Deinitializes the HW + * + */ + virtual void power_down(); + + /** + * Sets a callback that needs to be called for packets received for that interface + * + * @param input_cb Function to be register as a callback + */ + virtual void set_link_input_cb(emac_link_input_cb_t input_cb); + + /** + * Sets a callback that needs to be called on link status changes for given interface + * + * @param state_cb Function to be register as a callback + */ + virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); + + /** Add device to a multicast group + * + * @param address A multicast group hardware address + */ + virtual void add_multicast_group(const uint8_t *address); + + /** Remove device from a multicast group + * + * @param address A multicast group hardware address + */ + virtual void remove_multicast_group(const uint8_t *address); + + /** Request reception of all multicast packets + * + * @param all True to receive all multicasts + * False to receive only multicasts addressed to specified groups + */ + virtual void set_all_multicast(bool all); + + /** Sets memory manager that is used to handle memory buffers + * + * @param mem_mngr Pointer to memory manager + */ + virtual void set_memory_manager(EMACMemoryManager &mem_mngr); + + // Called from driver functions + ETH_HandleTypeDef EthHandle; + osThreadId_t thread; /**< Processing thread */ + +private: + bool low_level_init_successful(); + void packet_rx(); + int low_level_input(emac_mem_buf_t **buf); + static void thread_function(void *pvParameters); + static void rmii_watchdog_thread_function(void *pvParameters); + void phy_task(); + void enable_interrupts(); + void disable_interrupts(); + + mbed_rtos_storage_thread_t thread_cb; +#if defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx)\ + || defined (STM32F779xx) + mbed_rtos_storage_thread_t rmii_watchdog_thread_cb; + osThreadId_t rmii_watchdog_thread; /**< Watchdog processing thread */ +#endif + rtos::Mutex TXLockMutex;/**< TX critical section mutex */ + rtos::Mutex RXLockMutex;/**< RX critical section mutex */ + emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */ + emac_link_state_change_cb_t emac_link_state_cb; /**< Link state change callback */ + EMACMemoryManager *memory_manager; /**< Memory manager */ + + uint32_t phy_status; + int phy_task_handle; /**< Handle for phy task event */ +}; + +#endif /* K64F_EMAC_H_ */ diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdAccessPoint.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdAccessPoint.h new file mode 100644 index 00000000..5ceaba62 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdAccessPoint.h @@ -0,0 +1,74 @@ +/* WHD Access Point Interface + * Copyright (c) 2017-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_ACCESS_POINT_H +#define WHD_ACCESS_POINT_H + +#include "netsocket/WiFiAccessPoint.h" +#include "whd_types.h" + +/* Enum for scan result type */ +enum scan_result_type { + SRES_TYPE_WIFI_ACCESS_POINT, + SRES_TYPE_WHD_ACCESS_POINT +}; + +/** WhdAccessPoint class + * + * Class that represents a Whd Access Point + * which contains additional Whd specific information + */ +class WhdAccessPoint : public WiFiAccessPoint { +public: + WhdAccessPoint() : WiFiAccessPoint() {}; + WhdAccessPoint(nsapi_wifi_ap_t ap, whd_bss_type_t bss_type, uint8_t *ie_ptr, uint32_t ie_len); + + /** Define move assignment and prevent copy-assignment + * + * Due to IE element data could have large memory footprint, + * only move assignment is allowed. + */ + WhdAccessPoint &operator=(WhdAccessPoint &&rhs); + WhdAccessPoint &operator=(const WhdAccessPoint &rhs) = delete; + + /** Get WHD access point's bss type + * + * @return The whd_bss_type_t of the access point + */ + whd_bss_type_t get_bss_type() const; + + /** Get WHD access point's IE data + * + * @return The pointer to ie data buffer + */ + uint8_t *get_ie_data() const; + + /** Get WHD access point's IE length + * + * @return The ie data length + */ + uint32_t get_ie_len() const; + + virtual ~WhdAccessPoint(); + +private: + whd_bss_type_t _bss_type; + uint8_t *_ie_ptr; /**< Pointer to received Beacon/Probe Response IE(Information Element) */ + uint32_t _ie_len; /**< Length of IE(Information Element) */ +}; + +#endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSTAInterface.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSTAInterface.h index 8224a7e9..2bda49d1 100644 --- a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSTAInterface.h +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSTAInterface.h @@ -21,7 +21,9 @@ #include "netsocket/WiFiInterface.h" #include "netsocket/EMACInterface.h" #include "netsocket/OnboardNetworkStack.h" +#include "WhdAccessPoint.h" #include "whd_emac.h" +#include "whd_interface.h" #include "whd_types_int.h" struct ol_desc; @@ -31,7 +33,6 @@ struct ol_desc; */ class WhdSTAInterface : public WiFiInterface, public EMACInterface { public: - class OlmInterface { public: /** Get the default OLM interface. */ @@ -58,7 +59,8 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface { WhdSTAInterface( WHD_EMAC &emac = WHD_EMAC::get_instance(), OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance(), - OlmInterface &olm = OlmInterface::get_default_instance()); + OlmInterface &olm = OlmInterface::get_default_instance(), + whd_interface_shared_info_t &shared = whd_iface_shared); static WhdSTAInterface *get_default_instance(); @@ -117,17 +119,33 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface { return 0; } + /** Set blocking status of interface. + * Nonblocking mode unsupported. + * + * @param blocking true if connect is blocking + * @return 0 on success, negative error code on failure + */ + nsapi_error_t set_blocking(bool blocking) + { + if (blocking) { + _blocking = blocking; + return NSAPI_ERROR_OK; + } else { + return NSAPI_ERROR_UNSUPPORTED; + } + } + /** Gets the current radio signal strength for active connection * * @return Connection strength in dBm (negative value) */ int8_t get_rssi(); - /** Scan for available networks + /** Scan for available networks in WiFiAccessPoint format * * This function will block. * - * @param ap Pointer to allocated array to store discovered AP + * @param ap Pointer to allocated array of WiFiAccessPoint format for discovered AP * @param count Size of allocated @a res array, or 0 to only count available AP * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error @@ -135,6 +153,18 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface { */ int scan(WiFiAccessPoint *res, unsigned count); + /** Scan for available networks in WhdAccessPoint format + * + * This function will block. + * + * @param ap Pointer to allocated array of WhdAccessPoint format for discovered AP + * @param count Size of allocated @a res array, or 0 to only count available AP + * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0) + * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error + * see @a nsapi_error + */ + int scan_whd(WhdAccessPoint *res, unsigned count); + /* is interface connected, if yes return WICED_SUCCESS else WICED_NOT_CONNECTED */ int is_interface_connected(); @@ -208,13 +238,17 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface { int ret = _olm->wake(); return ret; } -private: +protected: + int internal_scan(WiFiAccessPoint *aps, unsigned count, scan_result_type sres_type); + +private: char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */ char _pass[64]; /* The longest allowed passphrase + 1 */ nsapi_security_t _security; WHD_EMAC &_whd_emac; OlmInterface *_olm; + whd_interface_shared_info_t &_iface_shared; }; #endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSoftAPInterface.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSoftAPInterface.h index 68914aa9..ced7c04f 100644 --- a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSoftAPInterface.h +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSoftAPInterface.h @@ -23,6 +23,7 @@ #include "netsocket/OnboardNetworkStack.h" #include "whd_emac.h" #include "CyDhcpServer.h" +#include "whd_interface.h" #include /** @@ -47,7 +48,8 @@ class WhdSoftAPInterface : public EMACInterface { * @return pointer to default WhdSoftAPInterface instance */ WhdSoftAPInterface(WHD_EMAC &emac = WHD_EMAC::get_instance(WHD_AP_ROLE), - OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()); + OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance(), + whd_interface_shared_info_t &shared = whd_iface_shared); /** Get the default WhdSoftAPInterface instance. * @return pointer to default WhdSoftAPInterface instance @@ -131,10 +133,26 @@ class WhdSoftAPInterface : public EMACInterface { */ int unregister_event_handler(void); + /** Set blocking status of interface. + * Nonblocking mode unsupported. + * + * @param blocking true if connect is blocking + * @return 0 on success, negative error code on failure + */ + nsapi_error_t set_blocking(bool blocking) + { + if (blocking) { + _blocking = blocking; + return NSAPI_ERROR_OK; + } else { + return NSAPI_ERROR_UNSUPPORTED; + } + } protected: WHD_EMAC &_whd_emac; std::unique_ptr _dhcp_server; + whd_interface_shared_info_t &_iface_shared; }; #endif diff --git a/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/whd_interface.h b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/whd_interface.h new file mode 100644 index 00000000..73dbe301 --- /dev/null +++ b/cores/arduino/mbed/features/netsocket/emac-drivers/TARGET_WHD/interface/whd_interface.h @@ -0,0 +1,51 @@ +/* WHD implementation of NetworkInterfaceAPI + * Copyright (c) 2017-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 WHD_INTERFACE_H +#define WHD_INTERFACE_H + +#include "rtos/Mutex.h" +#include "OnboardNetworkStack.h" + +/** WhdSTAInterface class + * Shared information + */ +#define IF_STATUS_ALL_IF_DOWN 0x0 +#define IF_STATUS_STA_UP 0x1 +#define IF_STATUS_SOFT_AP_UP 0x2 + +enum whd_default_interface_config +{ + DEFAULT_IF_NOT_SET, + DEFAULT_IF_STA, + DEFAULT_IF_SOFT_AP +}; + +struct whd_interface_shared_info_t { + rtos::Mutex mutex; + whd_default_interface_config default_if_cfg; + uint32_t if_status_flags; + OnboardNetworkStack::Interface *iface_sta; + OnboardNetworkStack::Interface *iface_softap; + whd_interface_shared_info_t() : default_if_cfg(DEFAULT_IF_NOT_SET), if_status_flags(IF_STATUS_ALL_IF_DOWN), + iface_sta(NULL), iface_softap(NULL) + {} +}; + +extern whd_interface_shared_info_t whd_iface_shared; + +#endif diff --git a/cores/arduino/mbed/features/netsocket/ppp/include/ppp_opts.h b/cores/arduino/mbed/features/netsocket/ppp/include/ppp_opts.h index 8a2a35e3..ffa4fd93 100644 --- a/cores/arduino/mbed/features/netsocket/ppp/include/ppp_opts.h +++ b/cores/arduino/mbed/features/netsocket/ppp/include/ppp_opts.h @@ -71,7 +71,9 @@ #define PPP_DNS 1 // Used as maximum size for output buffer, to restrict the memory manager get_pool_alloc_unit() +#ifndef PBUF_POOL_BUFSIZE #define PBUF_POOL_BUFSIZE 536 + 40 +#endif #endif // PPP_SUPPORT diff --git a/cores/arduino/mbed/features/nfc/controllers/PN512SPITransportDriver.h b/cores/arduino/mbed/features/nfc/controllers/PN512SPITransportDriver.h index 99a7ab95..fb0ab186 100644 --- a/cores/arduino/mbed/features/nfc/controllers/PN512SPITransportDriver.h +++ b/cores/arduino/mbed/features/nfc/controllers/PN512SPITransportDriver.h @@ -23,7 +23,7 @@ #include "platform/nfc_transport.h" #include "PN512TransportDriver.h" -#include "drivers/SPI.h" +#include "drivers/SPIMaster.h" #include "drivers/DigitalOut.h" #include "drivers/InterruptIn.h" diff --git a/cores/arduino/mbed/features/storage/filesystem/Dir.h b/cores/arduino/mbed/features/storage/filesystem/Dir.h index 4e933bfa..6592c0fa 100644 --- a/cores/arduino/mbed/features/storage/filesystem/Dir.h +++ b/cores/arduino/mbed/features/storage/filesystem/Dir.h @@ -17,7 +17,7 @@ #ifndef DIR_H #define DIR_H -#include "filesystem/FileSystem.h" +#include "features/storage/filesystem/FileSystem.h" #include "platform/DirHandle.h" namespace mbed { diff --git a/cores/arduino/mbed/features/storage/filesystem/File.h b/cores/arduino/mbed/features/storage/filesystem/File.h index 349c5926..b3f151f8 100644 --- a/cores/arduino/mbed/features/storage/filesystem/File.h +++ b/cores/arduino/mbed/features/storage/filesystem/File.h @@ -17,7 +17,7 @@ #ifndef FILE_H #define FILE_H -#include "filesystem/FileSystem.h" +#include "features/storage/filesystem/FileSystem.h" #include "platform/FileHandle.h" namespace mbed { diff --git a/cores/arduino/mbed/features/storage/filesystem/FileSystem.h b/cores/arduino/mbed/features/storage/filesystem/FileSystem.h index 1b90b7ec..7096810c 100644 --- a/cores/arduino/mbed/features/storage/filesystem/FileSystem.h +++ b/cores/arduino/mbed/features/storage/filesystem/FileSystem.h @@ -23,7 +23,7 @@ #include "platform/FileHandle.h" #include "platform/DirHandle.h" #include "platform/FileSystemLike.h" -#include "BlockDevice.h" +#include "features/storage/blockdevice/BlockDevice.h" namespace mbed { /** \addtogroup file system */ diff --git a/cores/arduino/mbed/features/storage/filesystem/fat/FATFileSystem.h b/cores/arduino/mbed/features/storage/filesystem/fat/FATFileSystem.h index 9bc7b045..b5177063 100644 --- a/cores/arduino/mbed/features/storage/filesystem/fat/FATFileSystem.h +++ b/cores/arduino/mbed/features/storage/filesystem/fat/FATFileSystem.h @@ -26,12 +26,12 @@ #ifndef MBED_FATFILESYSTEM_H #define MBED_FATFILESYSTEM_H -#include "FileSystem.h" -#include "BlockDevice.h" +#include "features/storage/filesystem/FileSystem.h" +#include "features/storage/blockdevice/BlockDevice.h" #include "FileHandle.h" -#include "ff.h" #include #include "PlatformMutex.h" +#include "features/storage/filesystem/fat/ChaN/ff.h" namespace mbed { diff --git a/cores/arduino/mbed/features/storage/filesystem/littlefs/LittleFileSystem.h b/cores/arduino/mbed/features/storage/filesystem/littlefs/LittleFileSystem.h index c4fdaaee..8e34c794 100644 --- a/cores/arduino/mbed/features/storage/filesystem/littlefs/LittleFileSystem.h +++ b/cores/arduino/mbed/features/storage/filesystem/littlefs/LittleFileSystem.h @@ -20,10 +20,10 @@ #ifndef MBED_LFSFILESYSTEM_H #define MBED_LFSFILESYSTEM_H -#include "FileSystem.h" -#include "BlockDevice.h" -#include "PlatformMutex.h" -#include "lfs.h" +#include "features/storage/filesystem/FileSystem.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "platform/PlatformMutex.h" +#include "features/storage/filesystem/littlefs/littlefs/lfs.h" namespace mbed { diff --git a/cores/arduino/mbed/features/storage/filesystem/littlefs/littlefs/lfs.h b/cores/arduino/mbed/features/storage/filesystem/littlefs/littlefs/lfs.h index f0c5839b..58ba9548 100644 --- a/cores/arduino/mbed/features/storage/filesystem/littlefs/littlefs/lfs.h +++ b/cores/arduino/mbed/features/storage/filesystem/littlefs/littlefs/lfs.h @@ -21,7 +21,7 @@ extern "C" // Software library version // Major (top-nibble), incremented on backwards incompatible changes // Minor (bottom-nibble), incremented on feature additions -#define LFS_VERSION 0x00010006 +#define LFS_VERSION 0x00010007 #define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16)) #define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0)) @@ -49,6 +49,11 @@ typedef uint32_t lfs_block_t; #define LFS_NAME_MAX 255 #endif +// Max file size in bytes +#ifndef LFS_FILE_MAX +#define LFS_FILE_MAX 2147483647 +#endif + // Possible error codes, these are negative to allow // valid positive return values enum lfs_error { @@ -61,6 +66,7 @@ enum lfs_error { LFS_ERR_ISDIR = -21, // Entry is a dir LFS_ERR_NOTEMPTY = -39, // Dir is not empty LFS_ERR_BADF = -9, // Bad file number + LFS_ERR_FBIG = -27, // File too large LFS_ERR_INVAL = -22, // Invalid parameter LFS_ERR_NOSPC = -28, // No space left on device LFS_ERR_NOMEM = -12, // No more memory available @@ -280,6 +286,7 @@ typedef struct lfs { lfs_free_t free; bool deorphaned; + bool moving; } lfs_t; diff --git a/cores/arduino/mbed/features/storage/filesystem/mbed_filesystem.h b/cores/arduino/mbed/features/storage/filesystem/mbed_filesystem.h index c002498a..5ea5b724 100644 --- a/cores/arduino/mbed/features/storage/filesystem/mbed_filesystem.h +++ b/cores/arduino/mbed/features/storage/filesystem/mbed_filesystem.h @@ -23,16 +23,15 @@ #include "platform/platform.h" // FileSystem classes -#include "filesystem/FileSystem.h" -#include "filesystem/File.h" -#include "filesystem/Dir.h" +#include "features/storage/filesystem/FileSystem.h" +#include "features/storage/filesystem/File.h" +#include "features/storage/filesystem/Dir.h" // BlockDevice classes -#include "BlockDevice.h" -#include "BlockDevice.h" -#include "ChainingBlockDevice.h" -#include "SlicingBlockDevice.h" -#include "HeapBlockDevice.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "features/storage/blockdevice/ChainingBlockDevice.h" +#include "features/storage/blockdevice/SlicingBlockDevice.h" +#include "features/storage/blockdevice/HeapBlockDevice.h" /** @}*/ #endif diff --git a/cores/arduino/mbed/features/storage/kvstore/filesystemstore/FileSystemStore.h b/cores/arduino/mbed/features/storage/kvstore/filesystemstore/FileSystemStore.h index 2ea9590e..a9e32aa6 100644 --- a/cores/arduino/mbed/features/storage/kvstore/filesystemstore/FileSystemStore.h +++ b/cores/arduino/mbed/features/storage/kvstore/filesystemstore/FileSystemStore.h @@ -18,8 +18,8 @@ #ifndef MBED_FILE_SYSTEM_STORE_H #define MBED_FILE_SYSTEM_STORE_H -#include "KVStore.h" -#include "FileSystem.h" +#include "features/storage/kvstore/include/KVStore.h" +#include "features/storage/filesystem/FileSystem.h" namespace mbed { diff --git a/cores/arduino/mbed/features/storage/kvstore/kv_map/KVMap.h b/cores/arduino/mbed/features/storage/kvstore/kv_map/KVMap.h index 14acbe15..d45731ee 100644 --- a/cores/arduino/mbed/features/storage/kvstore/kv_map/KVMap.h +++ b/cores/arduino/mbed/features/storage/kvstore/kv_map/KVMap.h @@ -16,11 +16,11 @@ #ifndef _KV_MAP #define _KV_MAP -#include "KVStore.h" +#include "features/storage/kvstore/include/KVStore.h" #include "platform/PlatformMutex.h" #include "platform/SingletonPtr.h" -#include "BlockDevice.h" -#include "FileSystem.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "features/storage/filesystem/FileSystem.h" namespace mbed { diff --git a/cores/arduino/mbed/features/storage/kvstore/securestore/SecureStore.h b/cores/arduino/mbed/features/storage/kvstore/securestore/SecureStore.h index 2dbda2dd..c08eeff8 100644 --- a/cores/arduino/mbed/features/storage/kvstore/securestore/SecureStore.h +++ b/cores/arduino/mbed/features/storage/kvstore/securestore/SecureStore.h @@ -23,7 +23,7 @@ #include MBEDTLS_CONFIG_FILE #endif -#include "DeviceKey.h" +#include "features/device_key/source/DeviceKey.h" #define SECURESTORE_ENABLED 1 diff --git a/cores/arduino/mbed/features/storage/kvstore/tdbstore/TDBStore.h b/cores/arduino/mbed/features/storage/kvstore/tdbstore/TDBStore.h index 727ad7c7..e2a40d6e 100644 --- a/cores/arduino/mbed/features/storage/kvstore/tdbstore/TDBStore.h +++ b/cores/arduino/mbed/features/storage/kvstore/tdbstore/TDBStore.h @@ -19,9 +19,9 @@ #include #include -#include "KVStore.h" -#include "BlockDevice.h" -#include "BufferedBlockDevice.h" +#include "features/storage/kvstore/include/KVStore.h" +#include "features/storage/blockdevice/BlockDevice.h" +#include "features/storage/blockdevice/BufferedBlockDevice.h" #include "PlatformMutex.h" namespace mbed { diff --git a/cores/arduino/mbed/hal/pinmap.h b/cores/arduino/mbed/hal/pinmap.h index b2a8d560..4fc0ec37 100644 --- a/cores/arduino/mbed/hal/pinmap.h +++ b/cores/arduino/mbed/hal/pinmap.h @@ -22,6 +22,7 @@ #include "PinNames.h" #include +#include #ifdef __cplusplus extern "C" { diff --git a/cores/arduino/mbed/hal/qspi_api.h b/cores/arduino/mbed/hal/qspi_api.h index 8464c2d6..2d7d65b0 100644 --- a/cores/arduino/mbed/hal/qspi_api.h +++ b/cores/arduino/mbed/hal/qspi_api.h @@ -60,12 +60,14 @@ typedef enum qspi_address_size { /** Alternative size in bits */ -typedef enum qspi_alt_size { - QSPI_CFG_ALT_SIZE_8, - QSPI_CFG_ALT_SIZE_16, - QSPI_CFG_ALT_SIZE_24, - QSPI_CFG_ALT_SIZE_32, -} qspi_alt_size_t; +typedef uint8_t qspi_alt_size_t; + +// The following defines are provided for backwards compatibilty. New code should explicitly +// specify the required number of alt bits. +#define QSPI_CFG_ALT_SIZE_8 8u +#define QSPI_CFG_ALT_SIZE_16 16u +#define QSPI_CFG_ALT_SIZE_24 24u +#define QSPI_CFG_ALT_SIZE_32 32u /** QSPI command * diff --git a/cores/arduino/mbed/platform/ATCmdParser.h b/cores/arduino/mbed/platform/ATCmdParser.h index f183cb64..c48235f7 100644 --- a/cores/arduino/mbed/platform/ATCmdParser.h +++ b/cores/arduino/mbed/platform/ATCmdParser.h @@ -27,8 +27,6 @@ #include "platform/FileHandle.h" namespace mbed { - -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api Platform */ /** @{*/ /** @@ -94,7 +92,7 @@ class ATCmdParser : private NonCopyable { */ ATCmdParser(FileHandle *fh, const char *output_delimiter = "\r", int buffer_size = 256, int timeout = 8000, bool debug = false) - : _fh(fh), _buffer_size(buffer_size), _oob_cb_count(0), _in_prev(0), _oobs(NULL) + : _fh(fh), _buffer_size(buffer_size), _oob_cb_count(0), _in_prev(0), _aborted(false), _oobs(NULL) { _buffer = new char[buffer_size]; set_timeout(timeout); @@ -273,6 +271,9 @@ class ATCmdParser : private NonCopyable { /** * Direct scanf on underlying stream + * This function does not itself match whitespace in its format string, so \n is not significant to it. + * It should be used only when certain string is needed or format ends with certain character, otherwise + * it will fill the output with one character. * @see scanf * * @param format Format string to pass to scanf diff --git a/cores/arduino/mbed/platform/CThunk.h b/cores/arduino/mbed/platform/CThunk.h index 6e350c67..2c9c751b 100644 --- a/cores/arduino/mbed/platform/CThunk.h +++ b/cores/arduino/mbed/platform/CThunk.h @@ -1,18 +1,4 @@ -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_CThunk CThunk class - * @{ - */ -/* General C++ Object Thunking class - * - * - allows direct callbacks to non-static C++ class functions - * - keeps track for the corresponding class instance - * - supports an optional context parameter for the called function - * - ideally suited for class object receiving interrupts (NVIC_SetVector) - * - * Copyright (c) 2014-2019 ARM Limited +/* Copyright (c) 2014-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +14,15 @@ * limitations under the License. */ + +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_CThunk CThunk class + * @{ + */ + /* General C++ Object Thunking class * * - allows direct callbacks to non-static C++ class functions diff --git a/cores/arduino/mbed/platform/Callback.h b/cores/arduino/mbed/platform/Callback.h index 78f299ae..58b06853 100644 --- a/cores/arduino/mbed/platform/Callback.h +++ b/cores/arduino/mbed/platform/Callback.h @@ -24,7 +24,6 @@ #include "platform/mbed_toolchain.h" namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/CircularBuffer.h b/cores/arduino/mbed/platform/CircularBuffer.h index d5d862a3..76782302 100644 --- a/cores/arduino/mbed/platform/CircularBuffer.h +++ b/cores/arduino/mbed/platform/CircularBuffer.h @@ -51,7 +51,6 @@ struct is_unsigned { }; }; -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/CriticalSectionLock.h b/cores/arduino/mbed/platform/CriticalSectionLock.h index 2d2291d8..e1e66f7a 100644 --- a/cores/arduino/mbed/platform/CriticalSectionLock.h +++ b/cores/arduino/mbed/platform/CriticalSectionLock.h @@ -21,8 +21,6 @@ #include "platform/mbed_toolchain.h" namespace mbed { - -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/DeepSleepLock.h b/cores/arduino/mbed/platform/DeepSleepLock.h index 6211f2d7..c4841aa4 100644 --- a/cores/arduino/mbed/platform/DeepSleepLock.h +++ b/cores/arduino/mbed/platform/DeepSleepLock.h @@ -21,8 +21,6 @@ #include namespace mbed { - -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/DirHandle.h b/cores/arduino/mbed/platform/DirHandle.h index 60b9e08d..3607af09 100644 --- a/cores/arduino/mbed/platform/DirHandle.h +++ b/cores/arduino/mbed/platform/DirHandle.h @@ -22,7 +22,6 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/FunctionPointer.h b/cores/arduino/mbed/platform/FunctionPointer.h index e3fb94fe..7111b8d1 100644 --- a/cores/arduino/mbed/platform/FunctionPointer.h +++ b/cores/arduino/mbed/platform/FunctionPointer.h @@ -23,7 +23,6 @@ #include namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/LocalFileSystem.h b/cores/arduino/mbed/platform/LocalFileSystem.h index 0061ef9f..4ee6b6a1 100644 --- a/cores/arduino/mbed/platform/LocalFileSystem.h +++ b/cores/arduino/mbed/platform/LocalFileSystem.h @@ -26,7 +26,6 @@ #include "platform/NonCopyable.h" namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/NonCopyable.h b/cores/arduino/mbed/platform/NonCopyable.h index 4d78e834..144ca025 100644 --- a/cores/arduino/mbed/platform/NonCopyable.h +++ b/cores/arduino/mbed/platform/NonCopyable.h @@ -24,9 +24,9 @@ namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_NonCopyable NonCopyable class * @{ @@ -172,11 +172,11 @@ class NonCopyable { /** * Disallow construction of NonCopyable objects from outside of its hierarchy. */ - NonCopyable() { } + NonCopyable() = default; /** * Disallow destruction of NonCopyable objects from outside of its hierarchy. */ - ~NonCopyable() { } + ~NonCopyable() = default; #if (!defined(MBED_DEBUG) && (MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR == 0)) /** diff --git a/cores/arduino/mbed/platform/PlatformMutex.h b/cores/arduino/mbed/platform/PlatformMutex.h index 7f26c800..d2e94e5b 100644 --- a/cores/arduino/mbed/platform/PlatformMutex.h +++ b/cores/arduino/mbed/platform/PlatformMutex.h @@ -19,7 +19,6 @@ #include "platform/NonCopyable.h" -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ diff --git a/cores/arduino/mbed/platform/ScopedLock.h b/cores/arduino/mbed/platform/ScopedLock.h index e1ddf3bf..b2e664d5 100644 --- a/cores/arduino/mbed/platform/ScopedLock.h +++ b/cores/arduino/mbed/platform/ScopedLock.h @@ -21,9 +21,9 @@ namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_ScopedLock ScopedLock functions * @{ diff --git a/cores/arduino/mbed/platform/ScopedRamExecutionLock.h b/cores/arduino/mbed/platform/ScopedRamExecutionLock.h index 72e1874c..abbf106c 100644 --- a/cores/arduino/mbed/platform/ScopedRamExecutionLock.h +++ b/cores/arduino/mbed/platform/ScopedRamExecutionLock.h @@ -21,7 +21,6 @@ namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ diff --git a/cores/arduino/mbed/platform/ScopedRomWriteLock.h b/cores/arduino/mbed/platform/ScopedRomWriteLock.h index 4e39382d..ad1b52e2 100644 --- a/cores/arduino/mbed/platform/ScopedRomWriteLock.h +++ b/cores/arduino/mbed/platform/ScopedRomWriteLock.h @@ -21,7 +21,6 @@ namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ diff --git a/cores/arduino/mbed/platform/SingletonPtr.h b/cores/arduino/mbed/platform/SingletonPtr.h index a71e0873..790287d9 100644 --- a/cores/arduino/mbed/platform/SingletonPtr.h +++ b/cores/arduino/mbed/platform/SingletonPtr.h @@ -1,11 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_SingletonPtr SingletonPtr class - * @{ - */ /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -38,6 +30,14 @@ extern osMutexId_t singleton_mutex_id; #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_SingletonPtr SingletonPtr class + * @{ + */ + /** Lock the singleton mutex * * This function is typically used to provide diff --git a/cores/arduino/mbed/platform/Span.h b/cores/arduino/mbed/platform/Span.h index 889cddc3..c5bac9d6 100644 --- a/cores/arduino/mbed/platform/Span.h +++ b/cores/arduino/mbed/platform/Span.h @@ -26,9 +26,9 @@ namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_Span Span class * @{ diff --git a/cores/arduino/mbed/platform/Stream.h b/cores/arduino/mbed/platform/Stream.h index ef03d71a..b25783f3 100644 --- a/cores/arduino/mbed/platform/Stream.h +++ b/cores/arduino/mbed/platform/Stream.h @@ -25,9 +25,9 @@ #include namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_Stream Stream class * @{ diff --git a/cores/arduino/mbed/platform/Transaction.h b/cores/arduino/mbed/platform/Transaction.h index 8b30ef49..1d8d4cd0 100644 --- a/cores/arduino/mbed/platform/Transaction.h +++ b/cores/arduino/mbed/platform/Transaction.h @@ -20,9 +20,9 @@ #include "platform/platform.h" namespace mbed { -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_Transaction Transaction class * @{ diff --git a/cores/arduino/mbed/platform/internal/CThunkBase.h b/cores/arduino/mbed/platform/internal/CThunkBase.h index ef0f3266..212ff446 100644 --- a/cores/arduino/mbed/platform/internal/CThunkBase.h +++ b/cores/arduino/mbed/platform/internal/CThunkBase.h @@ -18,7 +18,7 @@ #ifndef __CTHUNK_BASE_H__ #define __CTHUNK_BASE_H__ -/** \addtogroup platform-internal-api Platform +/** \defgroup platform-internal-api Platform * \ingroup mbed-os-internal */ diff --git a/cores/arduino/mbed/platform/mbed_assert.h b/cores/arduino/mbed/platform/mbed_assert.h index f43aa8b4..ae011e36 100644 --- a/cores/arduino/mbed/platform/mbed_assert.h +++ b/cores/arduino/mbed/platform/mbed_assert.h @@ -1,11 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_Assert Assert macros - * @{ - */ /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -31,6 +23,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_Assert Assert macros + * @{ + */ + /** Internal mbed assert function which is invoked when MBED_ASSERT macro fails. * This function is active only if NDEBUG is not defined prior to including this * assert header file. diff --git a/cores/arduino/mbed/platform/mbed_atomic.h b/cores/arduino/mbed/platform/mbed_atomic.h index ca9f8df7..28e2cb2f 100644 --- a/cores/arduino/mbed/platform/mbed_atomic.h +++ b/cores/arduino/mbed/platform/mbed_atomic.h @@ -26,7 +26,6 @@ #include #include "platform/mbed_toolchain.h" -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ diff --git a/cores/arduino/mbed/platform/mbed_critical.h b/cores/arduino/mbed/platform/mbed_critical.h index f1a152ef..92137948 100644 --- a/cores/arduino/mbed/platform/mbed_critical.h +++ b/cores/arduino/mbed/platform/mbed_critical.h @@ -1,4 +1,3 @@ - /* * Copyright (c) 2015-2019, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 @@ -25,7 +24,6 @@ extern "C" { #endif -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ /** diff --git a/cores/arduino/mbed/platform/mbed_debug.h b/cores/arduino/mbed/platform/mbed_debug.h index cfa52bfe..ed5e60d5 100644 --- a/cores/arduino/mbed/platform/mbed_debug.h +++ b/cores/arduino/mbed/platform/mbed_debug.h @@ -1,12 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_debug Debug functions - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -35,6 +26,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_debug Debug functions + * @{ + */ + static inline void debug(const char *format, ...) MBED_PRINTF(1, 2); static inline void debug_if(int condition, const char *format, ...) MBED_PRINTF(2, 3); diff --git a/cores/arduino/mbed/platform/mbed_error.h b/cores/arduino/mbed/platform/mbed_error.h index 7a1f7012..9ba86b27 100644 --- a/cores/arduino/mbed/platform/mbed_error.h +++ b/cores/arduino/mbed/platform/mbed_error.h @@ -1,10 +1,3 @@ -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_error Error functions - * @{ - */ /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -32,6 +25,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_error Error functions + * @{ + */ + /** Define this macro to include filenames in error context. For release builds, do not include filename to save memory. * MBED_PLATFORM_CONF_ERROR_FILENAME_CAPTURE_ENABLED */ diff --git a/cores/arduino/mbed/platform/mbed_interface.h b/cores/arduino/mbed/platform/mbed_interface.h index 44c1f262..279eca72 100644 --- a/cores/arduino/mbed/platform/mbed_interface.h +++ b/cores/arduino/mbed/platform/mbed_interface.h @@ -1,12 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_interface Network interface and other utility functions - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -31,6 +22,14 @@ #include "platform/mbed_toolchain.h" #include "device.h" +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_interface Network interface and other utility functions + * @{ + */ + /* Mbed interface mac address * if MBED_MAC_ADD_x are zero, interface uid sets mac address, * otherwise MAC_ADD_x are used. diff --git a/cores/arduino/mbed/platform/mbed_mem_trace.h b/cores/arduino/mbed/platform/mbed_mem_trace.h index 12e2c104..2c5bc40d 100644 --- a/cores/arduino/mbed/platform/mbed_mem_trace.h +++ b/cores/arduino/mbed/platform/mbed_mem_trace.h @@ -1,8 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -30,6 +25,9 @@ extern "C" { #include #include +/** \addtogroup platform-public-api */ +/** @{*/ + /** * enum Memory operation types for tracer */ diff --git a/cores/arduino/mbed/platform/mbed_mktime.h b/cores/arduino/mbed/platform/mbed_mktime.h index 21448eaa..0a748c29 100644 --- a/cores/arduino/mbed/platform/mbed_mktime.h +++ b/cores/arduino/mbed/platform/mbed_mktime.h @@ -1,7 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ /* mbed Microcontroller Library * Copyright (c) 2017-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -30,6 +26,9 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + /** * \defgroup platform_mktime mktime functions * @{ diff --git a/cores/arduino/mbed/platform/mbed_mpu_mgmt.h b/cores/arduino/mbed/platform/mbed_mpu_mgmt.h index c3a1cc96..34f28916 100644 --- a/cores/arduino/mbed/platform/mbed_mpu_mgmt.h +++ b/cores/arduino/mbed/platform/mbed_mpu_mgmt.h @@ -1,11 +1,3 @@ -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_mpu_mgmt MPU management functions - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * @@ -30,6 +22,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_mpu_mgmt MPU management functions + * @{ + */ + #if (DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU) || defined(DOXYGEN_ONLY) #define mbed_mpu_manager_init() mbed_mpu_init() diff --git a/cores/arduino/mbed/platform/mbed_poll.h b/cores/arduino/mbed/platform/mbed_poll.h index e293f77e..04a71c46 100644 --- a/cores/arduino/mbed/platform/mbed_poll.h +++ b/cores/arduino/mbed/platform/mbed_poll.h @@ -27,9 +27,9 @@ namespace mbed { class FileHandle; -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_poll poll functions * @{ diff --git a/cores/arduino/mbed/platform/mbed_power_mgmt.h b/cores/arduino/mbed/platform/mbed_power_mgmt.h index dc476ffa..86d57d16 100644 --- a/cores/arduino/mbed/platform/mbed_power_mgmt.h +++ b/cores/arduino/mbed/platform/mbed_power_mgmt.h @@ -1,11 +1,3 @@ -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_power_mgmt Power management functions - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -34,6 +26,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_power_mgmt Power management functions + * @{ + */ + /** * @defgroup hal_sleep_manager Sleep manager API * The sleep manager provides API to automatically select sleep mode. diff --git a/cores/arduino/mbed/platform/mbed_preprocessor.h b/cores/arduino/mbed/platform/mbed_preprocessor.h index 1b5607ef..f7be2f1d 100644 --- a/cores/arduino/mbed/platform/mbed_preprocessor.h +++ b/cores/arduino/mbed/platform/mbed_preprocessor.h @@ -1,11 +1,3 @@ -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_preprocessor preprocessor macros - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -25,6 +17,13 @@ #ifndef MBED_PREPROCESSOR_H #define MBED_PREPROCESSOR_H +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_preprocessor preprocessor macros + * @{ + */ /** MBED_CONCAT * Concatenate tokens together diff --git a/cores/arduino/mbed/platform/mbed_retarget.h b/cores/arduino/mbed/platform/mbed_retarget.h index f8aac6e9..c5058280 100644 --- a/cores/arduino/mbed/platform/mbed_retarget.h +++ b/cores/arduino/mbed/platform/mbed_retarget.h @@ -79,9 +79,9 @@ typedef unsigned int gid_t; ///< Group ID #include -/** \ingroup mbed-os-public */ /** \addtogroup platform-public-api */ /** @{*/ + /** * \defgroup platform_retarget Retarget functions * @{ diff --git a/cores/arduino/mbed/platform/mbed_rtc_time.h b/cores/arduino/mbed/platform/mbed_rtc_time.h index 935ff8d3..c5ec07bb 100644 --- a/cores/arduino/mbed/platform/mbed_rtc_time.h +++ b/cores/arduino/mbed/platform/mbed_rtc_time.h @@ -1,11 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_rtc_time rtc_time functions - * @{ - */ /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -23,12 +15,23 @@ * limitations under the License. */ +#ifndef __MBED_RTC_TIME_H__ +#define __MBED_RTC_TIME_H__ + #include #ifdef __cplusplus extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_rtc_time rtc_time functions + * @{ + */ + /* Timeval definition for non GCC_ARM toolchains */ #if !defined(__GNUC__) || defined(__CC_ARM) || defined(__clang__) struct timeval { @@ -129,3 +132,5 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz); /** @}*/ /** @}*/ + +#endif /* __MBED_RTC_TIME_H__ */ diff --git a/cores/arduino/mbed/platform/mbed_stats.h b/cores/arduino/mbed/platform/mbed_stats.h index 8bb80568..f331c655 100644 --- a/cores/arduino/mbed/platform/mbed_stats.h +++ b/cores/arduino/mbed/platform/mbed_stats.h @@ -1,11 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_stats stats functions - * @{ - */ /* mbed Microcontroller Library * Copyright (c) 2016-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -32,6 +24,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_stats stats functions + * @{ + */ + #ifdef MBED_ALL_STATS_ENABLED #ifndef MBED_SYS_STATS_ENABLED diff --git a/cores/arduino/mbed/platform/mbed_thread.h b/cores/arduino/mbed/platform/mbed_thread.h index 6968ebd6..8b9fff1e 100644 --- a/cores/arduino/mbed/platform/mbed_thread.h +++ b/cores/arduino/mbed/platform/mbed_thread.h @@ -22,6 +22,12 @@ extern "C" { #endif +/** + * \defgroup mbed_thread Mbed Thread + * \ingroup platform-public-api + * @{ + */ + /** Generic thread functions. * * These are C versions of functions provided in C++ via rtos::Thread and rtos::ThisThread @@ -59,6 +65,8 @@ void thread_sleep_for(uint32_t millisec); */ void thread_sleep_until(uint64_t millisec); +/** @}*/ + #ifdef __cplusplus } #endif diff --git a/cores/arduino/mbed/platform/mbed_toolchain.h b/cores/arduino/mbed/platform/mbed_toolchain.h index 04752ba4..cd60336c 100644 --- a/cores/arduino/mbed/platform/mbed_toolchain.h +++ b/cores/arduino/mbed/platform/mbed_toolchain.h @@ -1,12 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_toolchain Toolchain functions - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -37,6 +28,13 @@ #warning "This compiler is not yet supported." #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_toolchain Toolchain functions + * @{ + */ // Attributes diff --git a/cores/arduino/mbed/platform/mbed_version.h b/cores/arduino/mbed/platform/mbed_version.h index bbbdc855..2a1ec9c8 100644 --- a/cores/arduino/mbed/platform/mbed_version.h +++ b/cores/arduino/mbed/platform/mbed_version.h @@ -1,11 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_version Version macros - * @{ - */ /* mbed Microcontroller Library * Copyright (c) 2018-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -26,6 +18,14 @@ #ifndef MBED_VERSION_H #define MBED_VERSION_H +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_version Version macros + * @{ + */ + /** MBED_MAJOR_VERSION * Mbed OS major version * @@ -45,7 +45,7 @@ * * @note 99 is default value for development version (master branch) */ -#define MBED_PATCH_VERSION 0 +#define MBED_PATCH_VERSION 2 #define MBED_ENCODE_VERSION(major, minor, patch) ((major)*10000 + (minor)*100 + (patch)) diff --git a/cores/arduino/mbed/platform/mbed_wait_api.h b/cores/arduino/mbed/platform/mbed_wait_api.h index edf5075f..d86a5d48 100644 --- a/cores/arduino/mbed/platform/mbed_wait_api.h +++ b/cores/arduino/mbed/platform/mbed_wait_api.h @@ -1,12 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ -/** - * \defgroup platform_wait_api wait_api functions - * @{ - */ - /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -34,6 +25,14 @@ extern "C" { #endif +/** \addtogroup platform-public-api */ +/** @{*/ + +/** + * \defgroup platform_wait_api wait_api functions + * @{ + */ + /** Generic wait functions. * * These provide simple NOP type wait capabilities. diff --git a/cores/arduino/mbed/platform/platform.h b/cores/arduino/mbed/platform/platform.h index da2431ab..3268c7c5 100644 --- a/cores/arduino/mbed/platform/platform.h +++ b/cores/arduino/mbed/platform/platform.h @@ -29,4 +29,8 @@ #include "PinNames.h" #include "PeripheralNames.h" +/** \defgroup platform-public-api Platform + * \ingroup mbed-os-public + */ + #endif diff --git a/cores/arduino/mbed/platform/source/SysTimer.h b/cores/arduino/mbed/platform/source/SysTimer.h new file mode 100644 index 00000000..3098a8e6 --- /dev/null +++ b/cores/arduino/mbed/platform/source/SysTimer.h @@ -0,0 +1,243 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * 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 MBED_SYS_TIMER_H +#define MBED_SYS_TIMER_H + +#include "platform/NonCopyable.h" +#include "platform/mbed_atomic.h" +#include "drivers/TimerEvent.h" +#include "cmsis.h" + +extern "C" { +#if defined(TARGET_CORTEX_A) +#include "irq_ctrl.h" +#endif +} + +namespace mbed { +namespace internal { + +/** + * \defgroup mbed_SysTimer SysTimer class + * \ingroup platform-internal-api + * @{ + */ + +/** + * The SysTimer class is used to provide timing for system suspension, and + * the idle loop in TICKLESS mode. + * + * Template for speed for testing - only one instance will be used normally. + * + * @note SysTimer is not the part of Mbed API. + */ +template +class SysTimer: private mbed::TimerEvent, private mbed::NonCopyable > { +public: + + /** + * Default constructor uses LPTICKER if available (so the timer will + * continue to run in deep sleep), else USTICKER. + */ + SysTimer(); + + SysTimer(const ticker_data_t *data); + + ~SysTimer(); + + /** + * Get the interrupt number for the tick + * + * @return interrupt number + */ +#if TARGET_CORTEX_A + static IRQn_ID_t get_irq_number(); +#elif TARGET_CORTEX_M + static IRQn_Type get_irq_number(); +#endif + + /** + * Set the wake time + * + * Schedules an interrupt to cause wake-up in time for the event. Interrupt + * may be arranged early to account for latency. If the time has already + * passed, no interrupt will be scheduled. + * + * This is called from outside a critical section, as it is known to be + * a slow operation. + * + * If the wake time is already set, this is a no-op. But that check is racy, + * which means wake_time_set() should be rechecked after taking a critical + * section. + * + * As a side-effect, this clears the unacknowledged tick count - the caller + * is expected to use update_and_get_tick() after the suspend operation. + * + * @param at Wake up tick + * @warning If the ticker tick is already scheduled it needs to be cancelled first! + */ + void set_wake_time(uint64_t at); + + /** + * Check whether the wake time has passed + * + * This is a fast operation, based on checking whether the wake interrupt + * has run. + * + * @return true if the specified wake tick has passed + */ + bool wake_time_passed() const + { + return core_util_atomic_load_bool(&_wake_time_passed); + } + + /** + * Check whether wake timer is active + * + * @return true if the wake timer is active. + */ + bool wake_time_set() const + { + return core_util_atomic_load_bool(&_wake_time_set); + } + + /** + * Cancel any pending wake + */ + void cancel_wake(); + + /** + * Schedule an os tick to fire + * + * Ticks will be rescheduled automatically every tick until cancel_tick is called. + * + * A tick will be fired immediately if there are any unacknowledged ticks. + * + * @warning If a tick is already scheduled it needs to be cancelled first! + */ + void start_tick(); + + /** + * Acknowledge an os tick + * + * This will queue another os tick immediately if the os is running slow + */ + void acknowledge_tick(); + + /** + * Prevent any more scheduled ticks from triggering + * + * If called from OS tick context, there may be remaining unacknowledged ticks. + */ + void cancel_tick(); + + /** + * Check whether ticker is active + * + * Each time the tick interrupt fires, it is automatically rescheduled, + * so this will remain true once the tick is started, except during + * processing. + * + * @return true if the ticker is active. + */ + bool ticking() const + { + return core_util_atomic_load_bool(&_ticking); + } + + /** + * Check unacknowledged ticks + * + * Returns the count of how many times the OS timer has been queued minus + * the number of times is has been acknowledged. + * + * get_tick() - unacknowledged_ticks() should equal the OS's tick count, + * although such a calculation is not atomic if the ticker is currently running. + * + * @return number of unacknowledged ticks + */ + int unacknowledged_ticks() const + { + return core_util_atomic_load_u8(&_unacknowledged_ticks); + } + + /** Get the current tick count + * + * This count is updated by the ticker interrupt, if the ticker interrupt + * is running. It the ticker interrupt is not running, update_and_get_tick() + * should be used instead. + * + * This indicates how many ticks have been generated by the tick interrupt. + * The os_timer should equal this number minus the number of unacknowledged ticks. + * + * @return The number of ticks since timer creation. + */ + uint64_t get_tick() const; + + /** Update and get the current tick count + * + * This is a slow operation that reads the timer and adjusts for elapsed time. + * Can only be used when the ticker is not running, as there is no IRQ + * synchronization. + * + * This clears the unacknowledged tick counter - the caller is assumed to update + * their timer based on this return. + * + * @return The number of ticks since timer creation. + */ + uint64_t update_and_get_tick(); + + /** + * Returns time since last tick + * + * @return Relative time in microseconds + */ + us_timestamp_t get_time_since_tick() const; + + /** + * Get the time + * + * Returns the instantaneous precision time from underlying timer. + * This is a slow operation so should not be called from critical sections. + * + * @return Current time in microseconds + */ + us_timestamp_t get_time() const; + +protected: + virtual void handler(); + void _increment_tick(); + void _schedule_tick(); + uint64_t _elapsed_ticks() const; + static void _set_irq_pending(); + static void _clear_irq_pending(); + us_timestamp_t _time_us; + uint64_t _tick; + uint8_t _unacknowledged_ticks; + bool _wake_time_set; + bool _wake_time_passed; + bool _wake_early; + bool _ticking; + bool _deep_sleep_locked; +}; + +/** @} */ + +} +} + +#endif diff --git a/cores/arduino/mbed/platform/source/mbed_os_timer.h b/cores/arduino/mbed/platform/source/mbed_os_timer.h new file mode 100644 index 00000000..a765e911 --- /dev/null +++ b/cores/arduino/mbed/platform/source/mbed_os_timer.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2006-2019, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * 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 MBED_MBED_SLEEP_TIMER_H +#define MBED_MBED_SLEEP_TIMER_H + +#include "platform/source/SysTimer.h" + +#if MBED_CONF_RTOS_PRESENT +extern "C" { +#include "rtx_lib.h" +} +#endif + +namespace mbed { +namespace internal { + +#if MBED_CONF_RTOS_PRESENT +#define OS_TICK_US (1000000 / OS_TICK_FREQ) +#else +#define OS_TICK_US 1000 +#endif +typedef SysTimer OsTimer; + +/* A SysTimer is used to provide the timed sleep - this provides access to share it for + * other use, such as ticks. If accessed this way, it must not be in use when a sleep function below is called. + */ +extern OsTimer *os_timer; +OsTimer *init_os_timer(); + +/* -1 is effectively "sleep forever" */ +uint64_t do_timed_sleep_absolute(uint64_t wake_time, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL); + +#if MBED_CONF_RTOS_PRESENT +/* Maximum sleep time is 2^32-1 ticks; timer is always set to achieve this */ +/* Assumes that ticker has been in use prior to call, so restricted to RTOS use */ +uint32_t do_timed_sleep_relative(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL); +#else + +void do_untimed_sleep(bool (*wake_predicate)(void *), void *wake_predicate_handle = NULL); + +/* (uint32_t)-1 delay is sleep forever */ + +void do_timed_sleep_relative_or_forever(uint32_t wake_delay, bool (*wake_predicate)(void *) = NULL, void *wake_predicate_handle = NULL); + +#endif + +} +} + +#endif diff --git a/cores/arduino/mbed/platform/toolchain.h b/cores/arduino/mbed/platform/toolchain.h index c69c9811..6e3c2a88 100644 --- a/cores/arduino/mbed/platform/toolchain.h +++ b/cores/arduino/mbed/platform/toolchain.h @@ -1,7 +1,3 @@ - -/** \ingroup mbed-os-public */ -/** \addtogroup platform-public-api */ -/** @{*/ /* mbed Microcontroller Library * Copyright (c) 2006-2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 @@ -26,5 +22,3 @@ #include "platform/mbed_toolchain.h" #endif - -/** @}*/ diff --git a/cores/arduino/mbed/rtos/ConditionVariable.h b/cores/arduino/mbed/rtos/ConditionVariable.h index 7bd46049..f76b16df 100644 --- a/cores/arduino/mbed/rtos/ConditionVariable.h +++ b/cores/arduino/mbed/rtos/ConditionVariable.h @@ -32,8 +32,7 @@ #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) namespace rtos { -/** \ingroup mbed-os-public */ -/** \addtogroup rtos-public-api RTOS */ +/** \addtogroup rtos-public-api */ /** @{*/ struct Waiter; diff --git a/cores/arduino/mbed/rtos/EventFlags.h b/cores/arduino/mbed/rtos/EventFlags.h index b18a70e9..6ab38272 100644 --- a/cores/arduino/mbed/rtos/EventFlags.h +++ b/cores/arduino/mbed/rtos/EventFlags.h @@ -31,9 +31,9 @@ #include "platform/NonCopyable.h" namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_EventFlags EventFlags class * @{ diff --git a/cores/arduino/mbed/rtos/Kernel.h b/cores/arduino/mbed/rtos/Kernel.h index b5a4ad40..57a86f7e 100644 --- a/cores/arduino/mbed/rtos/Kernel.h +++ b/cores/arduino/mbed/rtos/Kernel.h @@ -26,7 +26,6 @@ #include "rtos/mbed_rtos_types.h" namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ @@ -62,5 +61,6 @@ void attach_thread_terminate_hook(void (*fptr)(osThreadId_t id)); } // namespace Kernel /** @}*/ + } // namespace rtos #endif diff --git a/cores/arduino/mbed/rtos/Mail.h b/cores/arduino/mbed/rtos/Mail.h index a747a9e6..494aa595 100644 --- a/cores/arduino/mbed/rtos/Mail.h +++ b/cores/arduino/mbed/rtos/Mail.h @@ -41,9 +41,9 @@ using namespace rtos; #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_Mail Mail class * @{ diff --git a/cores/arduino/mbed/rtos/MemoryPool.h b/cores/arduino/mbed/rtos/MemoryPool.h index 595734b9..0f29b7c6 100644 --- a/cores/arduino/mbed/rtos/MemoryPool.h +++ b/cores/arduino/mbed/rtos/MemoryPool.h @@ -35,9 +35,9 @@ #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_MemoryPool MemoryPool class * @{ @@ -193,7 +193,6 @@ class MemoryPool : private mbed::NonCopyable > { }; /** @}*/ /** @}*/ - } #endif #endif diff --git a/cores/arduino/mbed/rtos/Mutex.h b/cores/arduino/mbed/rtos/Mutex.h index 34d5f58a..5a8761c6 100644 --- a/cores/arduino/mbed/rtos/Mutex.h +++ b/cores/arduino/mbed/rtos/Mutex.h @@ -32,7 +32,6 @@ #include "platform/mbed_toolchain.h" namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ diff --git a/cores/arduino/mbed/rtos/Queue.h b/cores/arduino/mbed/rtos/Queue.h index 156db29d..4f98b1c3 100644 --- a/cores/arduino/mbed/rtos/Queue.h +++ b/cores/arduino/mbed/rtos/Queue.h @@ -31,9 +31,9 @@ #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_Queue Queue class * @{ diff --git a/cores/arduino/mbed/rtos/RtosTimer.h b/cores/arduino/mbed/rtos/RtosTimer.h index 3628722e..9b11a418 100644 --- a/cores/arduino/mbed/rtos/RtosTimer.h +++ b/cores/arduino/mbed/rtos/RtosTimer.h @@ -33,9 +33,9 @@ #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_RtosTimer RtosTimer class * @{ diff --git a/cores/arduino/mbed/rtos/Semaphore.h b/cores/arduino/mbed/rtos/Semaphore.h index f3dba32e..11246e59 100644 --- a/cores/arduino/mbed/rtos/Semaphore.h +++ b/cores/arduino/mbed/rtos/Semaphore.h @@ -30,9 +30,9 @@ #include "platform/NonCopyable.h" namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_Semaphore Semaphore class * @{ diff --git a/cores/arduino/mbed/rtos/ThisThread.h b/cores/arduino/mbed/rtos/ThisThread.h index f4dbc4ac..abda8026 100644 --- a/cores/arduino/mbed/rtos/ThisThread.h +++ b/cores/arduino/mbed/rtos/ThisThread.h @@ -26,9 +26,9 @@ #include "rtos/mbed_rtos_types.h" namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_ThisThread ThisThread namespace * @{ @@ -185,7 +185,11 @@ const char *get_name(); /** @}*/ /** @}*/ + namespace internal { +/** \addtogroup rtos-internal-api */ +/** @{*/ + struct flags_check_capture { uint32_t *flags; uint32_t options; @@ -197,5 +201,6 @@ struct flags_check_capture { bool non_rtos_check_flags(void *handle); } +/** @}*/ } #endif diff --git a/cores/arduino/mbed/rtos/Thread.h b/cores/arduino/mbed/rtos/Thread.h index 3d90b76e..edffa257 100644 --- a/cores/arduino/mbed/rtos/Thread.h +++ b/cores/arduino/mbed/rtos/Thread.h @@ -35,9 +35,9 @@ #if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST) namespace rtos { -/** \ingroup mbed-os-public */ /** \addtogroup rtos-public-api */ /** @{*/ + /** * \defgroup rtos_Thread Thread class * @{ diff --git a/cores/arduino/mbed/rtos/mbed_rtos_storage.h b/cores/arduino/mbed/rtos/mbed_rtos_storage.h index 58eb8f40..750725dc 100644 --- a/cores/arduino/mbed/rtos/mbed_rtos_storage.h +++ b/cores/arduino/mbed/rtos/mbed_rtos_storage.h @@ -24,5 +24,3 @@ #endif #endif - -/** @}*/ diff --git a/cores/arduino/mbed/rtos/mbed_rtos_types.h b/cores/arduino/mbed/rtos/mbed_rtos_types.h index 3584b6de..eaf5da0e 100644 --- a/cores/arduino/mbed/rtos/mbed_rtos_types.h +++ b/cores/arduino/mbed/rtos/mbed_rtos_types.h @@ -25,6 +25,9 @@ extern "C" { #endif +/** \addtogroup rtos-public-api */ +/** @{*/ + /* Minimal definitions for bare metal form of RTOS */ // Timeout value. @@ -65,6 +68,8 @@ typedef void *osThreadId_t; // \return thread flags after setting or error code if highest bit set. uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags); +/** @}*/ + #ifdef __cplusplus } #endif @@ -72,5 +77,4 @@ uint32_t osThreadFlagsSet(osThreadId_t thread_id, uint32_t flags); #endif - #endif /* RTOS_TYPES_H_ */ diff --git a/cores/arduino/mbed/rtos/rtos.h b/cores/arduino/mbed/rtos/rtos.h index 22bc2318..7987712a 100644 --- a/cores/arduino/mbed/rtos/rtos.h +++ b/cores/arduino/mbed/rtos/rtos.h @@ -36,12 +36,13 @@ #include "rtos/EventFlags.h" #include "rtos/ConditionVariable.h" -/** \ingroup mbed-os-public */ -/** \addtogroup rtos-public-api */ -/** @{*/ + +/** \defgroup rtos-public-api RTOS + * \ingroup mbed-os-public + */ + #ifndef MBED_NO_GLOBAL_USING_DIRECTIVE using namespace rtos; #endif -/** @}*/ #endif diff --git a/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_boot.h b/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_boot.h index 1be08b59..e7be74f1 100644 --- a/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_boot.h +++ b/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_boot.h @@ -25,7 +25,6 @@ extern "C" { #include "mbed_rtx.h" -/** \ingroup mbed-os-internal */ /** \addtogroup rtos-internal-api */ /** @{*/ diff --git a/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_rtx_conf.h b/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_rtx_conf.h index 1679b171..e7c68925 100644 --- a/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_rtx_conf.h +++ b/cores/arduino/mbed/rtos/source/TARGET_CORTEX/mbed_rtx_conf.h @@ -82,7 +82,9 @@ // Provide Mbed-specific instead. #define RTX_NO_MULTITHREAD_CLIB // LIBSPACE default value set for ARMCC +#ifndef OS_THREAD_LIBSPACE_NUM #define OS_THREAD_LIBSPACE_NUM 4 +#endif #define OS_IDLE_THREAD_NAME "rtx_idle" #define OS_TIMER_THREAD_NAME "rtx_timer" diff --git a/cores/arduino/mbed/rtos/source/TARGET_CORTEX/rtx5/RTX/Config/RTX_Config.h b/cores/arduino/mbed/rtos/source/TARGET_CORTEX/rtx5/RTX/Config/RTX_Config.h index 3021efbc..0e4f9b78 100644 --- a/cores/arduino/mbed/rtos/source/TARGET_CORTEX/rtx5/RTX/Config/RTX_Config.h +++ b/cores/arduino/mbed/rtos/source/TARGET_CORTEX/rtx5/RTX/Config/RTX_Config.h @@ -568,7 +568,9 @@ // Number of Threads which use standard C/C++ library libspace // (when thread specific memory allocation is not used). #if (OS_THREAD_OBJ_MEM == 0) +#ifndef OS_THREAD_LIBSPACE_NUM #define OS_THREAD_LIBSPACE_NUM 4 +#endif #else #define OS_THREAD_LIBSPACE_NUM OS_THREAD_NUM #endif diff --git a/cores/arduino/mbed/rtos/source/rtos_handlers.h b/cores/arduino/mbed/rtos/source/rtos_handlers.h index 62b7d545..15e1b7a3 100644 --- a/cores/arduino/mbed/rtos/source/rtos_handlers.h +++ b/cores/arduino/mbed/rtos/source/rtos_handlers.h @@ -28,12 +28,13 @@ extern "C" { #endif -/** \ingroup mbed-os-internal */ -/** \addtogroup rtos-internal-api RTOS */ -/** @{*/ +/** \defgroup rtos-internal-api RTOS + * \ingroup mbed-os-internal + */ /** * \defgroup rtos_handlers RTOS hook functions + * \ingroup rtos-internal-api * @{ */ /** @@ -43,7 +44,6 @@ extern "C" { */ void rtos_attach_thread_terminate_hook(void (*fptr)(osThreadId_t id)); /** @}*/ -/** @}*/ #ifdef __cplusplus } diff --git a/cores/arduino/mbed/rtos/source/rtos_idle.h b/cores/arduino/mbed/rtos/source/rtos_idle.h index 447f68a9..b0c2984b 100644 --- a/cores/arduino/mbed/rtos/source/rtos_idle.h +++ b/cores/arduino/mbed/rtos/source/rtos_idle.h @@ -28,8 +28,6 @@ extern "C" { #endif - -/** \ingroup mbed-os-internal */ /** \addtogroup rtos-internal-api */ /** @{*/ diff --git a/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h b/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h index 4a00de82..aa4ad766 100644 --- a/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h +++ b/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h @@ -1866,7 +1866,7 @@ #endif // NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins #ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS -#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4 #endif // NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority @@ -4451,6 +4451,18 @@ #define NRFX_WDT_CONFIG_LOG_LEVEL 3 #endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver. +//========================================================== + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 1 +#endif + + // NRFX_WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. // <0=> Default diff --git a/patches/0004-Cordio-set-WSF_MS_PER_TICK-default-as-10.patch b/patches/0004-Cordio-set-WSF_MS_PER_TICK-default-as-10.patch new file mode 100644 index 00000000..4806f13c --- /dev/null +++ b/patches/0004-Cordio-set-WSF_MS_PER_TICK-default-as-10.patch @@ -0,0 +1,31 @@ +From ed8c98c69e1866450591532e28c1a6421a231630 Mon Sep 17 00:00:00 2001 +From: Martino Facchin +Date: Mon, 2 Dec 2019 10:55:07 +0100 +Subject: [PATCH] Cordio: set WSF_MS_PER_TICK default as 10 + +--- + features/FEATURE_BLE/targets/TARGET_CORDIO/mbed_lib.json | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/features/FEATURE_BLE/targets/TARGET_CORDIO/mbed_lib.json b/features/FEATURE_BLE/targets/TARGET_CORDIO/mbed_lib.json +index 165b63f15e..39a3ae2643 100644 +--- a/features/FEATURE_BLE/targets/TARGET_CORDIO/mbed_lib.json ++++ b/features/FEATURE_BLE/targets/TARGET_CORDIO/mbed_lib.json +@@ -1,6 +1,6 @@ + { + "name": "cordio", +- "macros": [ "WSF_MS_PER_TICK=1" ], ++ "macros": [ "WSF_MS_PER_TICK=10" ], + "config": { + "max-connections": { + "help": "Maximum number of connections", +@@ -65,4 +65,4 @@ + "macro_name": "SEC_CCM_CFG" + } + } +-} +\ No newline at end of file ++} +-- +2.24.0 + diff --git a/variants/ARDUINO_NANO33BLE/cflags.txt b/variants/ARDUINO_NANO33BLE/cflags.txt index dc790c33..dfa1f768 100644 --- a/variants/ARDUINO_NANO33BLE/cflags.txt +++ b/variants/ARDUINO_NANO33BLE/cflags.txt @@ -1,6 +1,10 @@ -std=gnu11 -DAPPLICATION_ADDR=0x10000 -DAPPLICATION_SIZE=0xf0000 +-DMBED_RAM_SIZE=0x40000 +-DMBED_RAM_START=0x20000000 +-DMBED_ROM_SIZE=0x100000 +-DMBED_ROM_START=0x0 -DMBED_TRAP_ERRORS_ENABLED=1 -Os -Wall diff --git a/variants/ARDUINO_NANO33BLE/cxxflags.txt b/variants/ARDUINO_NANO33BLE/cxxflags.txt index 50472c79..84d778b3 100644 --- a/variants/ARDUINO_NANO33BLE/cxxflags.txt +++ b/variants/ARDUINO_NANO33BLE/cxxflags.txt @@ -3,6 +3,10 @@ -std=gnu++14 -DAPPLICATION_ADDR=0x10000 -DAPPLICATION_SIZE=0xf0000 +-DMBED_RAM_SIZE=0x40000 +-DMBED_RAM_START=0x20000000 +-DMBED_ROM_SIZE=0x100000 +-DMBED_ROM_START=0x0 -DMBED_TRAP_ERRORS_ENABLED=1 -Os -Wall diff --git a/variants/ARDUINO_NANO33BLE/defines.txt b/variants/ARDUINO_NANO33BLE/defines.txt index 757fe404..415ba004 100644 --- a/variants/ARDUINO_NANO33BLE/defines.txt +++ b/variants/ARDUINO_NANO33BLE/defines.txt @@ -36,13 +36,14 @@ -DFEATURE_STORAGE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1568118004.1384244 +-DMBED_BUILD_TIMESTAMP=1575279460.2487955 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBED_TICKLESS -DMBEDTLS_CONFIG_HW_SUPPORT -DNRF52840_XXAA --DNRF52_ERRATA_20 +-DNRF52_PAN_20 +-DSWI_DISABLE0 -DTARGET_ARDUINO_NANO33BLE -DTARGET_CORDIO -DTARGET_CORDIO_LL @@ -66,4 +67,4 @@ -DTOOLCHAIN_GCC_ARM -DWSF_MAX_HANDLERS=10 -DMBED_NO_GLOBAL_USING_DIRECTIVE=1 --DUSE_ARDUINO_PINOUT +-DUSE_ARDUINO_PINOUT \ No newline at end of file diff --git a/variants/ARDUINO_NANO33BLE/ldflags.txt b/variants/ARDUINO_NANO33BLE/ldflags.txt index 68f6636d..ab5dce2c 100644 --- a/variants/ARDUINO_NANO33BLE/ldflags.txt +++ b/variants/ARDUINO_NANO33BLE/ldflags.txt @@ -1,6 +1,10 @@ -DMBED_APP_SIZE=0xf0000 -DMBED_APP_START=0x10000 -DMBED_BOOT_STACK_SIZE=2048 +-DMBED_RAM_SIZE=0x40000 +-DMBED_RAM_START=0x20000000 +-DMBED_ROM_SIZE=0x100000 +-DMBED_ROM_START=0x0 -Wl,--gc-sections -Wl,--wrap,_calloc_r -Wl,--wrap,_free_r diff --git a/variants/ARDUINO_NANO33BLE/libs/libmbed.a b/variants/ARDUINO_NANO33BLE/libs/libmbed.a index 970fd198..cb433e94 100644 Binary files a/variants/ARDUINO_NANO33BLE/libs/libmbed.a and b/variants/ARDUINO_NANO33BLE/libs/libmbed.a differ diff --git a/variants/ARDUINO_NANO33BLE/mbed_config.h b/variants/ARDUINO_NANO33BLE/mbed_config.h index 8594c94b..2fba1c56 100644 --- a/variants/ARDUINO_NANO33BLE/mbed_config.h +++ b/variants/ARDUINO_NANO33BLE/mbed_config.h @@ -125,25 +125,39 @@ #define MBED_CONF_LWIP_ADDR_TIMEOUT 5 // set by library:lwip #define MBED_CONF_LWIP_ADDR_TIMEOUT_MODE 1 // set by library:lwip #define MBED_CONF_LWIP_DEBUG_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_DEFAULT_TCP_RECVMBOX_SIZE 8 // set by library:lwip #define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 // set by library:lwip +#define MBED_CONF_LWIP_DHCP_TIMEOUT 60 // set by library:lwip #define MBED_CONF_LWIP_ENABLE_PPP_TRACE 0 // set by library:lwip #define MBED_CONF_LWIP_ETHERNET_ENABLED 1 // set by library:lwip #define MBED_CONF_LWIP_IPV4_ENABLED 1 // set by library:lwip #define MBED_CONF_LWIP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_IP_VER_PREF 4 // set by library:lwip #define MBED_CONF_LWIP_L3IP_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_MBOX_SIZE 8 // set by library:lwip +#define MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT 8 // set by library:lwip +#define MBED_CONF_LWIP_MEMP_NUM_TCP_SEG 16 // set by library:lwip +#define MBED_CONF_LWIP_MEM_SIZE 1600 // set by library:lwip +#define MBED_CONF_LWIP_NUM_NETBUF 8 // set by library:lwip +#define MBED_CONF_LWIP_NUM_PBUF 8 // set by library:lwip +#define MBED_CONF_LWIP_PBUF_POOL_SIZE 5 // set by library:lwip #define MBED_CONF_LWIP_PPP_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_IPV4_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip #define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_TCPIP_MBOX_SIZE 8 // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip #define MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT 1000 // set by library:lwip #define MBED_CONF_LWIP_TCP_ENABLED 1 // set by library:lwip #define MBED_CONF_LWIP_TCP_MAXRTX 6 // set by library:lwip +#define MBED_CONF_LWIP_TCP_MSS 536 // set by library:lwip #define MBED_CONF_LWIP_TCP_SERVER_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_TCP_SND_BUF (2 * TCP_MSS) // set by library:lwip #define MBED_CONF_LWIP_TCP_SOCKET_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_TCP_SYNMAXRTX 6 // set by library:lwip +#define MBED_CONF_LWIP_TCP_WND (4 * TCP_MSS) // set by library:lwip #define MBED_CONF_LWIP_UDP_SOCKET_MAX 4 // set by library:lwip #define MBED_CONF_LWIP_USE_MBED_TRACE 0 // set by library:lwip #define MBED_CONF_MBED_MESH_API_6LOWPAN_ND_CHANNEL 0 // set by library:mbed-mesh-api @@ -192,8 +206,6 @@ #define MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG 0 // set by target:MCU_NRF52840 #define MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL 16 // set by target:MCU_NRF52840 #define MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC NRF_LF_SRC_XTAL // set by target:MCU_NRF52840 -#define MBED_CONF_NORDIC_UART_0_FIFO_SIZE 32 // set by library:nordic -#define MBED_CONF_NORDIC_UART_1_FIFO_SIZE 32 // set by library:nordic #define MBED_CONF_NSAPI_DEFAULT_MESH_TYPE THREAD // set by library:nsapi #define MBED_CONF_NSAPI_DEFAULT_STACK LWIP // set by library:nsapi #define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi @@ -216,7 +228,7 @@ #define MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR 0 // set by library:platform #define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16 // set by library:platform #define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT 1 // set by library:platform -#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 1 // set by library:platform +#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 0 // set by library:platform #define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6 // set by library:platform #define MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER 0 // set by library:platform #define MBED_CONF_PLATFORM_STDIO_BAUD_RATE 115200 // set by application[*] @@ -290,6 +302,8 @@ #define MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT 0 // set by target:Target #define MBED_CONF_TARGET_MPU_ROM_END 0x1fffffff // set by target:MCU_NRF52840 #define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER 0 // set by target:Target +#define MBED_CONF_TARGET_UART_0_FIFO_SIZE 32 // set by target:MCU_NRF52840 +#define MBED_CONF_TARGET_UART_1_FIFO_SIZE 32 // set by target:MCU_NRF52840 #define MBED_CONF_TELIT_HE910_BAUDRATE 115200 // set by library:TELIT_HE910 #define MBED_CONF_TELIT_HE910_PROVIDE_DEFAULT 0 // set by library:TELIT_HE910 #define MBED_CONF_TELIT_ME910_BAUDRATE 115200 // set by library:TELIT_ME910 @@ -331,9 +345,8 @@ #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 8 // defined by application #define NSAPI_PPP_AVAILABLE (MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED) // defined by library:ppp #define NS_USE_EXTERNAL_MBED_TLS // defined by library:nanostack -#define SWI_DISABLE0 // defined by library:nordic #define UNITY_INCLUDE_CONFIG_H // defined by library:utest -#define WSF_MS_PER_TICK 1 // defined by library:cordio +#define WSF_MS_PER_TICK 10 // defined by library:cordio #define _RTE_ // defined by library:rtos #endif