git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16252 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2023-05-22 07:21:54 +00:00
parent 8ef44cc115
commit eda1f21145
7 changed files with 10 additions and 526 deletions

View File

@ -11,12 +11,13 @@
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.protocol" value="remote"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value="${workspace_loc:/SB-APP-LS/build/ls.elf}"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value="${workspace_loc:/SB-APP-MSH/build/msh-ram/msh.elf}"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value="20060000"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="true"/>
@ -34,6 +35,7 @@
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC"/>
</listAttribute>

View File

@ -11,12 +11,13 @@
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.protocol" value="remote"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value="${workspace_loc:/SB-APP-LS/build/ls.elf}"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value="${workspace_loc:/SB-APP-MSH/build/msh-ram/msh.elf}"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value="20060000"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="true"/>
@ -34,6 +35,7 @@
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/RT-STM32L4R9-DISCOVERY-RAM_SB_HOST_DYNAMIC"/>
</listAttribute>

View File

@ -1,172 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
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.
*/
/**
* @file oop_base_object.h
* @brief Base object.
* @details This header defines a base class that is the root class of
* the ChibiOS Object Model.
*
* @addtogroup OOP_BASE_OBJECT
* @details ChibiOS uses concepts of Object Oriented Programming even if
* it is written in C. Things like simple inheritance, multiple
* inheritance and interfaces are used through the system.
* This module defines a "base object" class that is the ancestor
* of all classes in the system.<br>
* Class types are denoted by a "_c" suffix, classes contain a
* virtual methods table and data encapsulated into a normal C
* structure.<br>
* Interfaces are denoted by a "_i" suffix, interfaces just have
* a virtual methods table as single member of their C structure.<br>
* The first field of a VMT is the offset between the container
* object and the VMT pointer.<br>
* Multiple inheritance is implemented by composing a class
* structure with the structures of implemented classes or
* interfaces.<br>
* Example:
* <code>
* // Defining a counter interface.
* typedef struct {
* const struct __counter_interface_vmt *vmt;
* } counter_interface_i;
*
* // Defining a beans interface.
* typedef struct {
* const struct __beans_interface_vmt *vmt;
* } beans_interface_i;
*
* // Definition of a class myclass_c implementing interfaces
* // counter_interface_i and beans_interface_i.
* typedef struct {
* const struct __myclass_vmt *vmt;
* // Fields of myclass.
* counter_interface_i counter;
* beans_interface_i beans;
* } myclass_c;
* </code>
* @{
*/
#ifndef OOP_BASE_OBJECT_H
#define OOP_BASE_OBJECT_H
#include "ccportab.h"
#include "osal.h"
/**
* @brief Type of a base object class.
* @details This class represents a generic object including a virtual
* methods table (VMT).
* @note This class is compatible with the legacy HAL @p BaseObject class.
*/
typedef struct base_object base_object_c;
/**
* @brief @p base_object_c specific methods.
* @note This object defines no methods.
*/
#define __base_object_methods \
/* Instance offset, used for multiple inheritance, normally zero. It
represents the offset between the current object and the container
object*/ \
size_t instance_offset;
/**
* @brief @p base_object_c specific data.
* @note This object defines no data.
*/
#define __base_object_data
/**
* @brief @p base_object_c virtual methods table.
*/
struct __base_object_vmt {
__base_object_methods
};
/**
* @brief Structure representing a base object class.
*/
struct base_object {
/**
* @brief Virtual Methods Table.
*/
const struct __base_object_vmt *vmt;
__base_object_data
};
/**
* @name Methods implementations
* @{
*/
/**
* @brief Object creation implementation.
*
* @param[in] ip Pointer to a @p base_object_c structure to be
* initialized.
* @param[in] vmt VMT pointer for the new object.
* @return A new reference to the object.
*/
CC_FORCE_INLINE
static inline void *__base_object_objinit_impl(void *ip, const void *vmt) {
base_object_c *objp = (base_object_c *)ip;
objp->vmt = (struct __base_object_vmt *)vmt;
return ip;
}
/**
* @brief Object finalization implementation.
*
* @param[in] ip Pointer to a @p base_object_c structure to be
* disposed.
*/
CC_FORCE_INLINE
static inline void __base_object_dispose_impl(void *ip) {
(void) ip;
/* Nothing.*/
}
/** @} */
/**
* @name OOP Utility macros
* @{
*/
/**
* @brief Returns the object instance pointer starting from an interface
* pointer.
* @details Because multiple inheritance, an object can be composed by
* multiple interfaces and/or classes (its ancestors).<br>
* This function returns the pointer to the base object starting
* from a pointer to any of its composing classes or interfaces.<br>
* This is done by leveraging the offset field into each VMT table.
*
* @param[in] c The class type of the object.
* @param[in] ip A pointer to one of the object composing classes or
* interfaces.
* @return A pointer to an object of type @p type implementing
* the interface @p ip.
*/
#define oopGetInstance(c, ip) \
(c)(((size_t)(ip)) - (ip)->vmt->instance_offset)
/** @} */
#endif /* OOP_BASE_OBJECT_H */
/** @} */

View File

@ -1,186 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
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.
*/
/**
* @file oop_referenced_object.h
* @brief Base class for objects with a reference counter.
* @details This header defines a base class for classes requiring a
* a reference counter and a disposing mechanism.
*
* @addtogroup OOP_REFERENCED_OBJECT
* @details Base class for objects that implement a reference counter and
* are disposed when the number of references reaches zero.
* This class extends @p base_object_c class.
* @{
*/
#ifndef OOP_REFERENCED_OBJECT_H
#define OOP_REFERENCED_OBJECT_H
#include "oop_base_object.h"
/**
* @brief Type of a referenced object class.
*/
typedef struct referenced_object referenced_object_c;
/**
* @brief @p referenced_object_c specific methods.
* @note This object defines no methods.
*/
#define __referenced_object_methods \
__base_object_methods \
void *(*addref)(void *ip); \
unsigned (*release)(void *ip);
/**
* @brief @p referenced_object_c specific data.
*/
#define __referenced_object_data \
__base_object_data \
unsigned references;
/**
* @brief @p referenced_object_c virtual methods table.
*/
struct __referenced_object_vmt { \
__referenced_object_methods \
};
/**
* @brief Structure representing a referenced object class.
*/
struct referenced_object {
/**
* @brief Virtual Methods Table.
*/
const struct __referenced_object_vmt *vmt;
__referenced_object_data
};
/**
* @name Methods implementations
* @{
*/
/**
* @brief Object creation implementation.
*
* @param[in] ip Pointer to a @p referenced_object_c structure to be
* initialized.
* @param[in] vmt VMT pointer for the new object.
* @return A new reference to the object.
*/
CC_FORCE_INLINE
static inline void *__referenced_object_objinit_impl(void *ip, const void *vmt) {
referenced_object_c *objp = (referenced_object_c *)ip;
__base_object_objinit_impl(ip, vmt);
objp->references = 1U;
return ip;
}
/**
* @brief Object finalization implementation.
*
* @param[in] ip Pointer to a @p referenced_object_c structure to be
* disposed.
*/
CC_FORCE_INLINE
static inline void __referenced_object_dispose_impl(void *ip) {
__base_object_dispose_impl(ip);
/* Nothing.*/
}
/**
* @brief New reference creation implementation.
*
* @param[in] ip A reference to the object.
* @return A new reference to the object.
*/
CC_FORCE_INLINE
static inline void *__referenced_object_addref_impl(void *ip) {
referenced_object_c *objp = (referenced_object_c *)ip;
objp->references++;
return ip;
}
/**
* @brief References get implementation.
*
* @param[in] ip A reference to the object.
* @return Remaining references.
*/
CC_FORCE_INLINE
static inline unsigned __referenced_object_getref_impl(void *ip) {
referenced_object_c *objp = (referenced_object_c *)ip;
return objp->references;
}
/**
* @brief Reference release implementation.
*
* @param[in] ip A reference to the object.
* @return The number of references left.
*/
CC_FORCE_INLINE
static inline unsigned __referenced_object_release_impl(void *ip) {
referenced_object_c *objp = (referenced_object_c *)ip;
osalDbgAssert(objp->references > 0U, "zero references");
if (--objp->references == 0U) {
__referenced_object_dispose_impl(ip);
}
return objp->references;
}
/** @} */
/**
* @brief New reference creation.
*
* @param[in] ip A reference to the object.
* @return A new reference to the object.
*/
CC_FORCE_INLINE
static inline referenced_object_c *roAddRef(void *ip) {
referenced_object_c *objp = (referenced_object_c *)ip;
return objp->vmt->addref(ip);
}
/**
* @brief Reference release.
*
* @param[in] ip A reference to the object.
* @return The number of references left.
*/
CC_FORCE_INLINE
static inline unsigned roRelease(void *ip) {
referenced_object_c *objp = (referenced_object_c *)ip;
return objp->vmt->release(ip);
}
#endif /* OOP_REFERENCED_OBJECT_H */
/** @} */

View File

@ -1,162 +0,0 @@
/*
ChibiOS - Copyright (C) 2006..2021 Giovanni Di Sirio
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.
*/
/**
* @file oop_synchronized_object.h
* @brief Base class for objects supporting synchronization.
* @details This header defines a base class for classes requiring a
* synchronization mechanism.
*
* @addtogroup OOP_SYNCHRONIZED_OBJECT
* @details Base class for objects that require a synchronization mechanism.
* This class extends @p base_object_c class.
* @{
*/
#ifndef OOP_SYNCHRONIZED_OBJECT_H
#define OOP_SYNCHRONIZED_OBJECT_H
#include "osal.h"
#include "oop_synchronized_object.h"
/**
* @brief Type of a synchronized object class.
*/
typedef struct synchronized_object synchronized_object_c;
/**
* @brief @p synchronized_object_c specific methods.
* @note This object defines no methods.
*/
#define __synchronized_object_methods \
__base_object_methods
/**
* @brief @p synchronized_object_c specific data.
*/
#define __synchronized_object_data \
__base_object_data \
mutex_t mutex;
/**
* @brief @p synchronized_object_c virtual methods table.
*/
struct __synchronized_object_vmt { \
__synchronized_object_methods \
};
/**
* @brief Structure representing a synchronized object class.
*/
struct synchronized_object {
/**
* @brief Virtual Methods Table.
*/
const struct __synchronized_object_vmt *vmt;
__synchronized_object_data
};
/**
* @name Methods implementations
* @{
*/
/**
* @brief Object creation implementation.
*
* @param[in] ip Pointer to a @p synchronized_object_c structure to be
* initialized.
* @param[in] vmt VMT pointer for the new object.
* @return A new reference to the object.
*/
CC_FORCE_INLINE
static inline void *__synchronized_object_objinit_impl(void *ip, const void *vmt) {
synchronized_object_c *objp = (synchronized_object_c *)ip;
__base_object_objinit_impl(ip, vmt);
osalMutexObjectInit(&objp->mutex);
return ip;
}
/**
* @brief Object finalization implementation.
*
* @param[in] ip Pointer to a @p synchronized_object_c structure to be
* disposed.
*/
CC_FORCE_INLINE
static inline void __synchronized_object_dispose_impl(void *ip) {
__base_object_dispose_impl(ip);
/* Nothing.*/
/* TODO add RT objects disposing when available.*/
}
/**
* @brief Object lock implementation.
*
* @param[in] ip Pointer to a @p synchronized_object_c structure to be
* locked.
*/
CC_FORCE_INLINE
static inline void __synchronized_object_lock_impl(void *ip) {
synchronized_object_c *objp = (synchronized_object_c *)ip;
osalMutexLock(&objp->mutex);
}
/**
* @brief Object unlock implementation.
*
* @param[in] ip Pointer to a @p synchronized_object_c structure to be
* unlocked.
*/
CC_FORCE_INLINE
static inline void __synchronized_object_unlock_impl(void *ip) {
synchronized_object_c *objp = (synchronized_object_c *)ip;
osalMutexUnlock(&objp->mutex);
}
/** @} */
/**
* @brief Object lock.
*
* @param[in] ip Pointer to a @p synchronized_object_c structure to be
* locked.
*/
CC_FORCE_INLINE
static inline void soLock(synchronized_object_c *sop) {
__synchronized_object_lock_impl(sop);
}
/**
* @brief Object unlock.
*
* @param[in] ip Pointer to a @p synchronized_object_c structure to be
* unlocked.
*/
CC_FORCE_INLINE
static inline void soUnlock(synchronized_object_c *sop) {
__synchronized_object_unlock_impl(sop);
}
#endif /* OOP_SYNCHRONIZED_OBJECT_H */
/** @} */

View File

@ -192,8 +192,8 @@ size_t path_add_separator(char *dst, size_t size) {
size_t path_add_extension(char *dst, const char *ext, size_t size) {
size_t dn, en;
dn = strnlen(dst, size - 1U);
en = strnlen(ext, size - 1U);
dn = strlen(dst);
en = strlen(ext);
if ((dn < en) || (strcmp(dst + dn - en, ext) != 0)) {
if (dn + en >= size) {
return 0U;

View File

@ -188,8 +188,8 @@ size_t vfs_path_add_separator(char *dst, size_t size) {
size_t vfs_path_add_extension(char *dst, const char *ext, size_t size) {
size_t dn, en;
dn = strnlen(dst, size - 1U);
en = strnlen(ext, size - 1U);
dn = strlen(dst);
en = strlen(ext);
if ((dn < en) || (strcmp(dst + dn - en, ext) != 0)) {
if (dn + en >= size) {
return 0U;