Initial version

This commit is contained in:
2019-06-28 23:08:36 +02:00
commit 4d8973e20b
2426 changed files with 948029 additions and 0 deletions

View File

@ -0,0 +1,56 @@
/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
Copyright (c) 2014-2015 Datalight, Inc.
All Rights Reserved Worldwide.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; use version 2 of the License.
This program is distributed in the hope that it will be useful,
but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Businesses and individuals that for commercial or other reasons cannot
comply with the terms of the GPLv2 license may obtain a commercial license
before incorporating Reliance Edge into proprietary software for
distribution in any form. Visit http://www.datalight.com/reliance-edge for
more information.
*/
/** @file
@brief Implements assertion handling.
*/
#include <redfs.h>
#if REDCONF_ASSERTS == 1
#include <redosdeviations.h>
/** @brief Invoke the native assertion handler.
@param pszFileName Null-terminated string containing the name of the file
where the assertion fired.
@param ulLineNum Line number in @p pszFileName where the assertion
fired.
*/
void RedOsAssertFail(
const char *pszFileName,
uint32_t ulLineNum)
{
#if REDCONF_OUTPUT == 1
IGNORE_ERRORS(PRINT_ASSERT(pszFileName, ulLineNum));
#endif
while(true)
{
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,79 @@
/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
Copyright (c) 2014-2015 Datalight, Inc.
All Rights Reserved Worldwide.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; use version 2 of the License.
This program is distributed in the hope that it will be useful,
but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Businesses and individuals that for commercial or other reasons cannot
comply with the terms of the GPLv2 license may obtain a commercial license
before incorporating Reliance Edge into proprietary software for
distribution in any form. Visit http://www.datalight.com/reliance-edge for
more information.
*/
/** @file
@brief Implements real-time clock functions.
*/
#include <redfs.h>
/** @brief Initialize the real time clock.
The behavior of calling this function when the RTC is already initialized
is undefined.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
*/
REDSTATUS RedOsClockInit(void)
{
return 0;
}
/** @brief Uninitialize the real time clock.
The behavior of calling this function when the RTC is not initialized is
undefined.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
*/
REDSTATUS RedOsClockUninit(void)
{
return 0;
}
/** @brief Get the date/time.
The behavior of calling this function when the RTC is not initialized is
undefined.
@return The number of seconds since January 1, 1970 excluding leap seconds
(in other words, standard Unix time). If the resolution or epoch
of the RTC is different than this, the implementation must convert
it to the expected representation.
*/
uint32_t RedOsClockGetTime(void)
{
/* FreeRTOS does not provide an RTC abstraction since most of the systems
it targets have no RTC hardware. If your hardware includes an RTC that
you would like to use, this function must be customized.
*/
return 0;
}

View File

@ -0,0 +1,134 @@
/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
Copyright (c) 2014-2015 Datalight, Inc.
All Rights Reserved Worldwide.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; use version 2 of the License.
This program is distributed in the hope that it will be useful,
but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Businesses and individuals that for commercial or other reasons cannot
comply with the terms of the GPLv2 license may obtain a commercial license
before incorporating Reliance Edge into proprietary software for
distribution in any form. Visit http://www.datalight.com/reliance-edge for
more information.
*/
/** @file
@brief Implements a synchronization object to provide mutual exclusion.
*/
#include <FreeRTOS.h>
#include <semphr.h>
#include <redfs.h>
#include <redosdeviations.h>
#if REDCONF_TASK_COUNT > 1U
static SemaphoreHandle_t xMutex;
#if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1)
static StaticSemaphore_t xMutexBuffer;
#endif
/** @brief Initialize the mutex.
After initialization, the mutex is in the released state.
The behavior of calling this function when the mutex is still initialized
is undefined.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
*/
REDSTATUS RedOsMutexInit(void)
{
REDSTATUS ret = 0;
#if defined(configSUPPORT_STATIC_ALLOCATION) && (configSUPPORT_STATIC_ALLOCATION == 1)
xMutex = xSemaphoreCreateMutexStatic(&xMutexBuffer);
if(xMutex == NULL)
{
/* The only error case for xSemaphoreCreateMutexStatic is that the mutex
buffer parameter is NULL, which is not the case.
*/
REDERROR();
ret = -RED_EINVAL;
}
#else
xMutex = xSemaphoreCreateMutex();
if(xMutex == NULL)
{
ret = -RED_ENOMEM;
}
#endif
return ret;
}
/** @brief Uninitialize the mutex.
The behavior of calling this function when the mutex is not initialized is
undefined; likewise, the behavior of uninitializing the mutex when it is
in the acquired state is undefined.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
*/
REDSTATUS RedOsMutexUninit(void)
{
vSemaphoreDelete(xMutex);
xMutex = NULL;
return 0;
}
/** @brief Acquire the mutex.
The behavior of calling this function when the mutex is not initialized is
undefined; likewise, the behavior of recursively acquiring the mutex is
undefined.
*/
void RedOsMutexAcquire(void)
{
while(xSemaphoreTake(xMutex, portMAX_DELAY) != pdTRUE)
{
}
}
/** @brief Release the mutex.
The behavior is undefined in the following cases:
- Releasing the mutex when the mutex is not initialized.
- Releasing the mutex when it is not in the acquired state.
- Releasing the mutex from a task or thread other than the one which
acquired the mutex.
*/
void RedOsMutexRelease(void)
{
BaseType_t xSuccess;
xSuccess = xSemaphoreGive(xMutex);
REDASSERT(xSuccess == pdTRUE);
IGNORE_ERRORS(xSuccess);
}
#endif

View File

@ -0,0 +1,70 @@
/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
Copyright (c) 2014-2015 Datalight, Inc.
All Rights Reserved Worldwide.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; use version 2 of the License.
This program is distributed in the hope that it will be useful,
but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Businesses and individuals that for commercial or other reasons cannot
comply with the terms of the GPLv2 license may obtain a commercial license
before incorporating Reliance Edge into proprietary software for
distribution in any form. Visit http://www.datalight.com/reliance-edge for
more information.
*/
/** @file
@brief Implements outputting a character string.
*/
#include <redfs.h>
#if REDCONF_OUTPUT == 1
#include <redosdeviations.h>
/** @brief Write a string to a user-visible output location.
Write a null-terminated string to the serial port, console, terminal, or
other display device, such that the text is visible to the user.
@param pszString A null-terminated string.
*/
void RedOsOutputString(
const char *pszString)
{
if(pszString == NULL)
{
REDERROR();
}
else
{
uint32_t ulIdx = 0U;
while(pszString[ulIdx] != '\0')
{
OUTPUT_CHARACTER(pszString[ulIdx]);
/* Serial output often requires a \r to print newlines correctly.
*/
if(pszString[ulIdx] == '\n')
{
OUTPUT_CHARACTER('\r');
}
ulIdx++;
}
}
}
#endif

View File

@ -0,0 +1,68 @@
/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
Copyright (c) 2014-2015 Datalight, Inc.
All Rights Reserved Worldwide.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; use version 2 of the License.
This program is distributed in the hope that it will be useful,
but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Businesses and individuals that for commercial or other reasons cannot
comply with the terms of the GPLv2 license may obtain a commercial license
before incorporating Reliance Edge into proprietary software for
distribution in any form. Visit http://www.datalight.com/reliance-edge for
more information.
*/
/** @file
@brief Implements task functions.
*/
#include <FreeRTOS.h>
#include <task.h>
#include <redfs.h>
#if (REDCONF_TASK_COUNT > 1U) && (REDCONF_API_POSIX == 1)
#include <redosdeviations.h>
#if INCLUDE_xTaskGetCurrentTaskHandle != 1
#error "INCLUDE_xTaskGetCurrentTaskHandle must be 1 when REDCONF_TASK_COUNT > 1 and REDCONF_API_POSIX == 1"
#endif
/** @brief Get the current task ID.
This task ID must be unique for all tasks using the file system.
@return The task ID. Must not be 0.
*/
uint32_t RedOsTaskId(void)
{
/* Simply casting the xTaskGetCurrentTaskHandle() return value results in
warnings from some compilers, so use variables.
*/
TaskHandle_t xTask = xTaskGetCurrentTaskHandle();
uintptr_t taskptr = CAST_TASK_PTR_TO_UINTPTR(xTask);
uint32_t ulTaskPtr = (uint32_t)taskptr;
/* Assert no information was lost casting from uintptr_t to uint32_t.
*/
REDASSERT(ulTaskPtr == taskptr);
/* NULL is a valid task handle in FreeRTOS, so add one to all task IDs.
*/
REDASSERT((ulTaskPtr + 1U) != 0U);
return ulTaskPtr + 1U;
}
#endif

View File

@ -0,0 +1,109 @@
/* ----> DO NOT REMOVE THE FOLLOWING NOTICE <----
Copyright (c) 2014-2015 Datalight, Inc.
All Rights Reserved Worldwide.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; use version 2 of the License.
This program is distributed in the hope that it will be useful,
but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Businesses and individuals that for commercial or other reasons cannot
comply with the terms of the GPLv2 license may obtain a commercial license
before incorporating Reliance Edge into proprietary software for
distribution in any form. Visit http://www.datalight.com/reliance-edge for
more information.
*/
/** @file
@brief Implements timestamp functions.
The functionality implemented herein is not needed for the file system
driver, only to provide accurate results with performance tests.
*/
#include <FreeRTOS.h>
#include <task.h>
#include <redfs.h>
/* configTICK_RATE_HZ is almost always 100, 250, 500, or 1000. If
1000000U % configTICK_RATE_HZ != 0, then RedOsTimePassed() will be a
little inaccurate.
*/
#define MICROSECS_PER_TICK (1000000U / configTICK_RATE_HZ)
/** @brief Initialize the timestamp service.
The behavior of invoking this function when timestamps are already
initialized is undefined.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
@retval -RED_ENOSYS The timestamp service has not been implemented.
*/
REDSTATUS RedOsTimestampInit(void)
{
return 0;
}
/** @brief Uninitialize the timestamp service.
The behavior of invoking this function when timestamps are not initialized
is undefined.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
*/
REDSTATUS RedOsTimestampUninit(void)
{
return 0;
}
/** @brief Retrieve a timestamp.
The behavior of invoking this function when timestamps are not initialized
is undefined
@return A timestamp which can later be passed to RedOsTimePassed() to
determine the amount of time which passed between the two calls.
*/
REDTIMESTAMP RedOsTimestamp(void)
{
return xTaskGetTickCount();
}
/** @brief Determine how much time has passed since a timestamp was retrieved.
The behavior of invoking this function when timestamps are not initialized
is undefined.
@param tsSince A timestamp acquired earlier via RedOsTimestamp().
@return The number of microseconds which have passed since @p tsSince.
*/
uint64_t RedOsTimePassed(
REDTIMESTAMP tsSince)
{
/* This works even if the tick count has wrapped around, provided it has
only wrapped around once.
*/
uint32_t ulTicksPassed = (uint32_t)xTaskGetTickCount() - tsSince;
uint64_t ullMicrosecs = (uint64_t)ulTicksPassed * MICROSECS_PER_TICK;
return ullMicrosecs;
}