Various enhancements.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15086 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-11-16 09:31:22 +00:00
parent d3892df86d
commit c594ce0242
4 changed files with 39 additions and 17 deletions

View File

@ -207,8 +207,10 @@
/* Restricted subsystems.*/
#undef CH_CFG_USE_MAILBOXES
#undef CH_CFG_USE_MEMCHECKS
#define CH_CFG_USE_MAILBOXES FALSE
#define CH_CFG_USE_MEMCHECKS FALSE
#endif /* CH_CUSTOMER_LIC_OSLIB == FALSE */

View File

@ -72,7 +72,7 @@ typedef struct {
extern "C" {
#endif
#if CH_CFG_USE_MEMCHECKS == TRUE
bool chMemIsAreaContainedX(const memory_region_t *mrp,
bool chMemIsAreaContainedX(const memory_region_t regions[],
const void *base,
size_t size);
bool chMemIsAreaWritableX(const void *p,
@ -90,14 +90,38 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
/**
* @brief Memory area check.
* @details Checks if specified area belongs to the specified region.
*
* @param[in] mrp pointer to an array of valid regions terminated with
* a zero element
* @param[in] base pointer to the area to be checked
* @param[in] size size of the area to be checked
* @return The test result.
* @retval false if the area is entirely contained within one of the
* specified regions.
* @retval true if the area check failed.
*
* @xclass
*/
static inline bool chMemIsAreaWithinX(const memory_region_t *mrp,
const void *base,
size_t size) {
uint8_t *start = (uint8_t *)base;
return (bool)((start >= mrp->base) && (start <= mrp->end) &&
(size <= (size_t)(mrp->end - start + 1U)));
}
#if CH_CFG_USE_MEMCHECKS == FALSE
/* Stub implementations for when the functionality is disabled, areas are
always reported as valid.*/
static inline bool chMemIsAreaContainedX(const memory_region_t *mrp,
static inline bool chMemIsAreaContainedX(const memory_region_t regions[],
const void *base,
size_t size) {
(void)mrp;
(void)regions;
(void)base;
(void)size;

View File

@ -74,11 +74,9 @@ CC_WEAK memory_region_t __ch_mem_readable_regions[] = {
/**
* @brief Memory area check.
* @details Checks if specified area belongs to one of the system-defined
* writable regions.
* @details Checks if specified area belongs to one of the specified regions.
*
* @param[in] mrp pointer to an array of valid regions terminated with
* a zero element
* @param[in] mrp array of valid regions terminated with a zero element
* @param[in] base pointer to the area to be checked
* @param[in] size size of the area to be checked
* @return The test result.
@ -88,23 +86,20 @@ CC_WEAK memory_region_t __ch_mem_readable_regions[] = {
*
* @xclass
*/
bool chMemIsAreaContainedX(const memory_region_t *mrp,
bool chMemIsAreaContainedX(const memory_region_t regions[],
const void *base,
size_t size) {
uint8_t *start;
const memory_region_t *mrp = &regions[0];
chDbgCheck(base != NULL);
start = (uint8_t *)base;
/* Scanning the array of the valid regions for a mismatch.*/
do {
if ((start >= mrp->base) && (start <= mrp->end) &&
(size <= (size_t)(mrp->base - start))) {
while (mrp->base != mrp->end) {
if (chMemIsAreaWithinX(mrp, base, size)) {
return true;
}
mrp++;
} while (mrp->base != mrp->end);
}
return false;
}
@ -112,7 +107,7 @@ bool chMemIsAreaContainedX(const memory_region_t *mrp,
/**
* @brief Memory writable area check.
* @details Checks if specified pointer belongs to one of the system-defined
* writable regions.
* writable regions and is aligned as specified.
* @note This function is only effective if @p CH_CFG_SYS_WRITABLE_REGIONS
* is defined, if it is not defined then just the alignment of
* the pointer is checked.
@ -145,7 +140,7 @@ bool chMemIsAreaWritableX(const void *p,
/**
* @brief Memory readable area check.
* @details Checks if specified pointer belongs to one of the system-defined
* readable regions.
* readable regions and is aligned as specified.
* @note This function is only effective if @p CH_CFG_SYS_READABLE_REGIONS
* is defined, if it is not defined then just the alignment of
* the pointer is checked.

View File

@ -74,6 +74,7 @@
*****************************************************************************
*** Next ***
- NEW: RT and NIL upgraded to support the enhanced OSLIB.
- NEW: Memory areas/pointers checker functions added to OSLIB.
- NEW: STM32G0B1 USBv2 driver.
- NEW: USBv1 driver optimization and removal of a potential race condition