Esp32 s3 support (#6341)

Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com>
Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com>
Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com>
Co-authored-by: Ivan Grokhotkov <ivan@espressif.com>
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
This commit is contained in:
Me No Dev
2022-03-28 12:09:41 +03:00
committed by GitHub
parent 3f79097d5f
commit 8ee5f0a11e
3774 changed files with 685773 additions and 19284 deletions

View File

@ -0,0 +1,29 @@
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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 _PERF_MON_H_
#define _PERF_MON_H_
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_log.h"
#include "xtensa_perfmon_access.h"
#include "xtensa_perfmon_masks.h"
#include "xtensa_perfmon_apis.h"
#include "xtensa/xt_perf_consts.h"
#endif // _PERF_MON_H_

View File

@ -0,0 +1,125 @@
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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 _PERF_MON_ACCESS_H_
#define _PERF_MON_ACCESS_H_
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "esp_log.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**@{*/
/**
* @brief Init Performance Monitoor
*
* Initialize performance monitor register with define values
*
* @param[in] id: performance counter number
* @param[in] select: select value from PMCTRLx register
* @param[in] mask: mask value from PMCTRLx register
* @param[in] kernelcnt: kernelcnt value from PMCTRLx register
* @param[in] tracelevel: tracelevel value from PMCTRLx register
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if one of the arguments is not correct
*/
esp_err_t xtensa_perfmon_init(int id, uint16_t select, uint16_t mask, int kernelcnt, int tracelevel);
/**@}*/
/**@{*/
/**
* @brief Reset PM counter
*
* Reset PM counter. Writes 0 to the PMx register.
*
* @param[in] id: performance counter number
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if id out of range
*/
esp_err_t xtensa_perfmon_reset(int id);
/**@}*/
/**@{*/
/**
* @brief Start PM counters
*
* Start all PM counters synchronously. Write 1 to the PGM register
*/
void xtensa_perfmon_start(void);
/**@}*/
/**@{*/
/**
* @brief Stop PM counters
*
* Stop all PM counters synchronously. Write 0 to the PGM register
*/
void xtensa_perfmon_stop(void);
/**@}*/
/**@{*/
/**
* @brief Read PM counter
*
* Read value of defined PM counter.
*
* @param[in] id: performance counter number
*
* @return
* - Performance counter value
*/
uint32_t xtensa_perfmon_value(int id);
/**@}*/
/**@{*/
/**
* @brief Read PM overflow state
*
* Read overflow value of defined PM counter.
*
* @param[in] id: performance counter number
*
* @return
* - ESP_OK if there is no overflow (overflow = 0)
* - ESP_FAIL if overflow occure (overflow = 1)
*/
esp_err_t xtensa_perfmon_overflow(int id);
/**@}*/
/**@{*/
/**
* @brief Dump PM values
*
* Dump all PM register to the console.
*
*/
void xtensa_perfmon_dump(void);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif // _PERF_MON_ACCESS_H_

View File

@ -0,0 +1,80 @@
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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 _xtensa_perfmon_apis_H_
#define _xtensa_perfmon_apis_H_
#include "xtensa_perfmon_access.h"
#include "xtensa_perfmon_masks.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Performance monitor configuration structure
*
* Structure to configure performance counter to measure dedicated function
*/
typedef struct xtensa_perfmon_config {
int repeat_count; /*!< how much times function will be called before the calback will be repeated */
float max_deviation; /*!< Difference between min and max counter number 0..1, 0 - no difference, 1 - not used */
void *call_params; /*!< This pointer will be passed to the call_function as a parameter */
void (*call_function)(void *params); /*!< pointer to the function that have to be called */
void (*callback)(void *params, uint32_t select, uint32_t mask, uint32_t value); /*!< pointer to the function that will be called with result parameters */
void *callback_params; /*!< parameter that will be passed to the callback */
int tracelevel; /*!< trace level for all counters.
In case of negative value, the filter will be ignored.
If it's >=0, then the perfmon will count only when interrupt level > tracelevel. It's useful to monitor interrupts. */
uint32_t counters_size;/*!< amount of counter in the list */
const uint32_t *select_mask; /*!< list of the select/mask parameters */
} xtensa_perfmon_config_t;
/**
* @brief Execute PM
*
* Execute performance counter for dedicated function with defined parameters
*
* @param[in] config: pointer to the configuration structure
*
* @return
* - ESP_OK if no errors
* - ESP_ERR_INVALID_ARG if one of the required parameters not defined
* - ESP_FAIL - counter overflow
*/
esp_err_t xtensa_perfmon_exec(const xtensa_perfmon_config_t *config);
/**
* @brief Dump PM results
*
* Callback to dump perfmon result to a FILE* stream specified in
* perfmon_config_t::callback_params. If callback_params is set to NULL, will print to stdout
*
* @param[in] params: used parameters passed from configuration (callback_params).
* This parameter expected as FILE* hanle, where data will be stored.
* If this parameter NULL, then data will be stored to the stdout.
* @param[in] select: select value for current counter
* @param[in] mask: mask value for current counter
* @param[in] value: counter value for current counter
*
*/
void xtensa_perfmon_view_cb(void *params, uint32_t select, uint32_t mask, uint32_t value);
#ifdef __cplusplus
}
#endif
#endif // _xtensa_perfmon_apis_H_

View File

@ -0,0 +1,74 @@
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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 _xtensa_perfmon_masks_H_
#define _xtensa_perfmon_masks_H_
#include <inttypes.h>
#include "xtensa/xt_perf_consts.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Description for select parameter
*
* Structure defines description for different select values for performance counters
*/
typedef struct xtensa_perfmon_select {
int select; /*!< Selected counter */
const char *description; /*!< Description for selected counter */
} xtensa_perfmon_select_t;
/**
* @brief Description for mask parameter
*
* Structure defines description for different select and mask values for performance counters
*/
typedef struct xtensa_perfmon_masks {
int select; /*!< Selected counter */
int mask; /*!< Selected mask for counter */
const char *description; /*!< Description for selected mask */
} xtensa_perfmon_masks_t;
// Maximum amount of performance counter events
#define MAX_PERFMON_EVENTS 119
/**
* @brief Select value description table
*
* Table contains description for different 'select' values for performance counter
*/
extern const xtensa_perfmon_select_t xtensa_perfmon_select_table[];
/**
* @brief Mask value description table
*
* Table contains description for different 'select' and 'mask' values for performance counter
*/
extern const xtensa_perfmon_masks_t xtensa_perfmon_masks_table[];
/**
* @brief All available counters
*
* Table contains all available counters
*/
extern const uint32_t xtensa_perfmon_select_mask_all[MAX_PERFMON_EVENTS * 2];
#ifdef __cplusplus
}
#endif
#endif // _xtensa_perfmon_masks_H_