mirror of https://github.com/ARMmbed/mbed-os.git
platform: astyle update
parent
483427a285
commit
ffcb6ecfb5
|
@ -79,7 +79,7 @@ void ATCmdParser::flush()
|
|||
int ATCmdParser::write(const char *data, int size)
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < size; i++) {
|
||||
for (; i < size; i++) {
|
||||
if (putc(data[i]) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ int ATCmdParser::write(const char *data, int size)
|
|||
int ATCmdParser::read(char *data, int size)
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < size; i++) {
|
||||
for (; i < size; i++) {
|
||||
int c = getc();
|
||||
if (c < 0) {
|
||||
return -1;
|
||||
|
@ -110,7 +110,7 @@ int ATCmdParser::vprintf(const char *format, va_list args)
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
for ( ; _buffer[i]; i++) {
|
||||
for (; _buffer[i]; i++) {
|
||||
if (putc(_buffer[i]) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
|||
int offset = 0;
|
||||
|
||||
while (format[i]) {
|
||||
if (format[i] == '%' && format[i+1] != '%' && format[i+1] != '*') {
|
||||
if (format[i] == '%' && format[i + 1] != '%' && format[i + 1] != '*') {
|
||||
_buffer[offset++] = '%';
|
||||
_buffer[offset++] = '*';
|
||||
i++;
|
||||
|
@ -155,7 +155,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
|||
|
||||
while (true) {
|
||||
// Ran out of space
|
||||
if (j+1 >= _buffer_size - offset) {
|
||||
if (j + 1 >= _buffer_size - offset) {
|
||||
return false;
|
||||
}
|
||||
// Receive next character
|
||||
|
@ -168,12 +168,12 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
|||
|
||||
// Check for match
|
||||
int count = -1;
|
||||
sscanf(_buffer+offset, _buffer, &count);
|
||||
sscanf(_buffer + offset, _buffer, &count);
|
||||
|
||||
// We only succeed if all characters in the response are matched
|
||||
if (count == j) {
|
||||
// Store the found results
|
||||
vsscanf(_buffer+offset, format, args);
|
||||
vsscanf(_buffer + offset, format, args);
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
@ -220,14 +220,14 @@ restart:
|
|||
bool whole_line_wanted = false;
|
||||
|
||||
while (response[i]) {
|
||||
if (response[i] == '%' && response[i+1] != '%' && response[i+1] != '*') {
|
||||
if (response[i] == '%' && response[i + 1] != '%' && response[i + 1] != '*') {
|
||||
_buffer[offset++] = '%';
|
||||
_buffer[offset++] = '*';
|
||||
i++;
|
||||
} else {
|
||||
_buffer[offset++] = response[i++];
|
||||
// Find linebreaks, taking care not to be fooled if they're in a %[^\n] conversion specification
|
||||
if (response[i - 1] == '\n' && !(i >= 3 && response[i-3] == '[' && response[i-2] == '^')) {
|
||||
if (response[i - 1] == '\n' && !(i >= 3 && response[i - 3] == '[' && response[i - 2] == '^')) {
|
||||
whole_line_wanted = true;
|
||||
break;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ restart:
|
|||
// Check for oob data
|
||||
for (struct oob *oob = _oobs; oob; oob = oob->next) {
|
||||
if ((unsigned)j == oob->len && memcmp(
|
||||
oob->prefix, _buffer+offset, oob->len) == 0) {
|
||||
oob->prefix, _buffer + offset, oob->len) == 0) {
|
||||
debug_if(_dbg_on, "AT! %s\n", oob->prefix);
|
||||
oob->cb();
|
||||
|
||||
|
@ -298,18 +298,18 @@ restart:
|
|||
// This allows recv("Foo: %s\n") to work, and not match with just the first character of a string
|
||||
// (scanf does not itself match whitespace in its format string, so \n is not significant to it)
|
||||
} else {
|
||||
sscanf(_buffer+offset, _buffer, &count);
|
||||
sscanf(_buffer + offset, _buffer, &count);
|
||||
}
|
||||
|
||||
// We only succeed if all characters in the response are matched
|
||||
if (count == j) {
|
||||
debug_if(_dbg_on, "AT= %s\n", _buffer+offset);
|
||||
debug_if(_dbg_on, "AT= %s\n", _buffer + offset);
|
||||
// Reuse the front end of the buffer
|
||||
memcpy(_buffer, response, i);
|
||||
_buffer[i] = 0;
|
||||
|
||||
// Store the found results
|
||||
vsscanf(_buffer+offset, _buffer, args);
|
||||
vsscanf(_buffer + offset, _buffer, args);
|
||||
|
||||
// Jump to next line and continue parsing
|
||||
response += i;
|
||||
|
@ -318,8 +318,8 @@ restart:
|
|||
|
||||
// Clear the buffer when we hit a newline or ran out of space
|
||||
// running out of space usually means we ran into binary data
|
||||
if (c == '\n' || j+1 >= _buffer_size - offset) {
|
||||
debug_if(_dbg_on, "AT< %s", _buffer+offset);
|
||||
if (c == '\n' || j + 1 >= _buffer_size - offset) {
|
||||
debug_if(_dbg_on, "AT< %s", _buffer + offset);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ bool ATCmdParser::process_oob()
|
|||
|
||||
// Clear the buffer when we hit a newline or ran out of space
|
||||
// running out of space usually means we ran into binary data
|
||||
if (((i+1) >= _buffer_size) || (c == '\n')) {
|
||||
if (((i + 1) >= _buffer_size) || (c == '\n')) {
|
||||
debug_if(_dbg_on, "AT< %s", _buffer);
|
||||
i = 0;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
*/
|
||||
|
||||
class ATCmdParser : private NonCopyable<ATCmdParser>
|
||||
{
|
||||
class ATCmdParser : private NonCopyable<ATCmdParser> {
|
||||
private:
|
||||
// File handle
|
||||
// Not owned by ATCmdParser
|
||||
|
@ -198,7 +197,7 @@ public:
|
|||
* @param ... all printf-like arguments to insert into command
|
||||
* @return true only if command is successfully sent
|
||||
*/
|
||||
bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2);
|
||||
bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2);
|
||||
|
||||
bool vsend(const char *command, va_list args);
|
||||
|
||||
|
@ -216,7 +215,7 @@ public:
|
|||
* @param ... all scanf-like arguments to extract from response
|
||||
* @return true only if response is successfully matched
|
||||
*/
|
||||
bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2);
|
||||
bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2);
|
||||
|
||||
bool vrecv(const char *response, va_list args);
|
||||
|
||||
|
@ -261,7 +260,7 @@ public:
|
|||
* @param ... arguments to printf
|
||||
* @return number of bytes written or -1 on failure
|
||||
*/
|
||||
int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2);
|
||||
int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2);
|
||||
|
||||
int vprintf(const char *format, va_list args);
|
||||
|
||||
|
@ -273,7 +272,7 @@ public:
|
|||
* @param ... arguments to scanf
|
||||
* @return number of bytes read or -1 on failure
|
||||
*/
|
||||
int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2);
|
||||
int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2);
|
||||
|
||||
int vscanf(const char *format, va_list args);
|
||||
|
||||
|
|
|
@ -84,11 +84,10 @@ typedef void (*CThunkEntry)(void);
|
|||
* @note Synchronization level: Not protected
|
||||
*/
|
||||
template<class T>
|
||||
class CThunk
|
||||
{
|
||||
public:
|
||||
class CThunk {
|
||||
public:
|
||||
typedef void (T::*CCallbackSimple)(void);
|
||||
typedef void (T::*CCallback)(void* context);
|
||||
typedef void (T::*CCallback)(void *context);
|
||||
|
||||
inline CThunk(T *instance)
|
||||
{
|
||||
|
@ -100,7 +99,8 @@ class CThunk
|
|||
init(instance, callback, NULL);
|
||||
}
|
||||
|
||||
~CThunk() {
|
||||
~CThunk()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ class CThunk
|
|||
init(instance, (CCallback)callback, NULL);
|
||||
}
|
||||
|
||||
inline CThunk(T &instance, CCallback callback, void* context)
|
||||
inline CThunk(T &instance, CCallback callback, void *context)
|
||||
{
|
||||
init(instance, callback, context);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class CThunk
|
|||
m_callback = (CCallback)callback;
|
||||
}
|
||||
|
||||
inline void context(void* context)
|
||||
inline void context(void *context)
|
||||
{
|
||||
m_thunk.context = (uint32_t)context;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class CThunk
|
|||
|
||||
inline uint32_t entry(void)
|
||||
{
|
||||
return (((uint32_t)&m_thunk)|CTHUNK_ADDRESS);
|
||||
return (((uint32_t)&m_thunk) | CTHUNK_ADDRESS);
|
||||
}
|
||||
|
||||
/* get thunk entry point for connecting rhunk to an IRQ table */
|
||||
|
@ -167,15 +167,14 @@ class CThunk
|
|||
(((CThunkEntry)(entry()))());
|
||||
}
|
||||
|
||||
private:
|
||||
T* m_instance;
|
||||
private:
|
||||
T *m_instance;
|
||||
volatile CCallback m_callback;
|
||||
|
||||
// TODO: this needs proper fix, to refactor toolchain header file and all its use
|
||||
// PACKED there is not defined properly for IAR
|
||||
#if defined (__ICCARM__)
|
||||
typedef __packed struct
|
||||
{
|
||||
typedef __packed struct {
|
||||
CTHUNK_VARIABLES;
|
||||
volatile uint32_t instance;
|
||||
volatile uint32_t context;
|
||||
|
@ -183,8 +182,7 @@ class CThunk
|
|||
volatile uint32_t trampoline;
|
||||
} CThunkTrampoline;
|
||||
#else
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
CTHUNK_VARIABLES;
|
||||
volatile uint32_t instance;
|
||||
volatile uint32_t context;
|
||||
|
@ -193,16 +191,16 @@ class CThunk
|
|||
} __attribute__((__packed__)) CThunkTrampoline;
|
||||
#endif
|
||||
|
||||
static void trampoline(T* instance, void* context, CCallback* callback)
|
||||
static void trampoline(T *instance, void *context, CCallback *callback)
|
||||
{
|
||||
if(instance && *callback) {
|
||||
(static_cast<T*>(instance)->**callback)(context);
|
||||
if (instance && *callback) {
|
||||
(static_cast<T *>(instance)->**callback)(context);
|
||||
}
|
||||
}
|
||||
|
||||
volatile CThunkTrampoline m_thunk;
|
||||
|
||||
inline void init(T *instance, CCallback callback, void* context)
|
||||
inline void init(T *instance, CCallback callback, void *context)
|
||||
{
|
||||
/* remember callback - need to add this level of redirection
|
||||
as pointer size for member functions differs between platforms */
|
||||
|
|
|
@ -13,26 +13,31 @@ namespace mbed {
|
|||
|
||||
class CallChainLink {
|
||||
public:
|
||||
CallChainLink(): cb(), next(NULL) {
|
||||
CallChainLink(): cb(), next(NULL)
|
||||
{
|
||||
// No work to do
|
||||
}
|
||||
|
||||
CallChainLink(Callback<void()> &callback): cb(callback), next(NULL) {
|
||||
CallChainLink(Callback<void()> &callback): cb(callback), next(NULL)
|
||||
{
|
||||
// No work to do
|
||||
}
|
||||
Callback<void()> cb;
|
||||
CallChainLink * next;
|
||||
CallChainLink *next;
|
||||
};
|
||||
|
||||
CallChain::CallChain(int size) : _chain(NULL) {
|
||||
CallChain::CallChain(int size) : _chain(NULL)
|
||||
{
|
||||
// No work to do
|
||||
}
|
||||
|
||||
CallChain::~CallChain() {
|
||||
CallChain::~CallChain()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
pFunctionPointer_t CallChain::add(Callback<void()> func) {
|
||||
pFunctionPointer_t CallChain::add(Callback<void()> func)
|
||||
{
|
||||
CallChainLink *new_link = new CallChainLink(func);
|
||||
if (NULL == _chain) {
|
||||
_chain = new_link;
|
||||
|
@ -49,14 +54,16 @@ pFunctionPointer_t CallChain::add(Callback<void()> func) {
|
|||
}
|
||||
}
|
||||
|
||||
pFunctionPointer_t CallChain::add_front(Callback<void()> func) {
|
||||
pFunctionPointer_t CallChain::add_front(Callback<void()> func)
|
||||
{
|
||||
CallChainLink *link = new CallChainLink(func);
|
||||
link->next = _chain;
|
||||
_chain = link;
|
||||
return &link->cb;
|
||||
}
|
||||
|
||||
int CallChain::size() const {
|
||||
int CallChain::size() const
|
||||
{
|
||||
CallChainLink *link = _chain;
|
||||
int elements = 0;
|
||||
while (link != NULL) {
|
||||
|
@ -66,7 +73,8 @@ int CallChain::size() const {
|
|||
return elements;
|
||||
}
|
||||
|
||||
pFunctionPointer_t CallChain::get(int idx) const {
|
||||
pFunctionPointer_t CallChain::get(int idx) const
|
||||
{
|
||||
CallChainLink *link = _chain;
|
||||
for (int i = 0; i < idx; i++) {
|
||||
if (NULL == link) {
|
||||
|
@ -77,7 +85,8 @@ pFunctionPointer_t CallChain::get(int idx) const {
|
|||
return &link->cb;
|
||||
}
|
||||
|
||||
int CallChain::find(pFunctionPointer_t f) const {
|
||||
int CallChain::find(pFunctionPointer_t f) const
|
||||
{
|
||||
CallChainLink *link = _chain;
|
||||
int i = 0;
|
||||
while (link != NULL) {
|
||||
|
@ -90,7 +99,8 @@ int CallChain::find(pFunctionPointer_t f) const {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void CallChain::clear() {
|
||||
void CallChain::clear()
|
||||
{
|
||||
CallChainLink *link = _chain;
|
||||
_chain = NULL;
|
||||
while (link != NULL) {
|
||||
|
@ -100,7 +110,8 @@ void CallChain::clear() {
|
|||
}
|
||||
}
|
||||
|
||||
bool CallChain::remove(pFunctionPointer_t f) {
|
||||
bool CallChain::remove(pFunctionPointer_t f)
|
||||
{
|
||||
CallChainLink *link = _chain;
|
||||
while (link != NULL) {
|
||||
if (f == &link->cb) {
|
||||
|
@ -112,7 +123,8 @@ bool CallChain::remove(pFunctionPointer_t f) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void CallChain::call() {
|
||||
void CallChain::call()
|
||||
{
|
||||
CallChainLink *link = _chain;
|
||||
while (link != NULL) {
|
||||
link->cb.call();
|
||||
|
|
|
@ -122,7 +122,8 @@ public:
|
|||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"The add function does not support cv-qualifiers. Replaced by "
|
||||
"add(callback(obj, method)).")
|
||||
pFunctionPointer_t add(T *obj, M method) {
|
||||
pFunctionPointer_t add(T *obj, M method)
|
||||
{
|
||||
return add(callback(obj, method));
|
||||
}
|
||||
|
||||
|
@ -156,7 +157,8 @@ public:
|
|||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"The add_front function does not support cv-qualifiers. Replaced by "
|
||||
"add_front(callback(obj, method)).")
|
||||
pFunctionPointer_t add_front(T *obj, M method) {
|
||||
pFunctionPointer_t add_front(T *obj, M method)
|
||||
{
|
||||
return add_front(callback(obj, method));
|
||||
}
|
||||
|
||||
|
@ -231,7 +233,8 @@ public:
|
|||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
|
||||
"public API of mbed-os and is being removed in the future.")
|
||||
void operator ()(void) {
|
||||
void operator()(void)
|
||||
{
|
||||
call();
|
||||
}
|
||||
|
||||
|
@ -242,7 +245,8 @@ public:
|
|||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the "
|
||||
"public API of mbed-os and is being removed in the future.")
|
||||
pFunctionPointer_t operator [](int i) const {
|
||||
pFunctionPointer_t operator [](int i) const
|
||||
{
|
||||
return get(i);
|
||||
}
|
||||
|
||||
|
|
1362
platform/Callback.h
1362
platform/Callback.h
File diff suppressed because it is too large
Load Diff
|
@ -24,17 +24,29 @@ namespace mbed {
|
|||
namespace internal {
|
||||
/* Detect if CounterType of the Circular buffer is of unsigned type. */
|
||||
template<typename T>
|
||||
struct is_unsigned { static const bool value = false; };
|
||||
struct is_unsigned {
|
||||
static const bool value = false;
|
||||
};
|
||||
template<>
|
||||
struct is_unsigned<unsigned char> { static const bool value = true; };
|
||||
struct is_unsigned<unsigned char> {
|
||||
static const bool value = true;
|
||||
};
|
||||
template<>
|
||||
struct is_unsigned<unsigned short> { static const bool value = true; };
|
||||
struct is_unsigned<unsigned short> {
|
||||
static const bool value = true;
|
||||
};
|
||||
template<>
|
||||
struct is_unsigned<unsigned int> { static const bool value = true; };
|
||||
struct is_unsigned<unsigned int> {
|
||||
static const bool value = true;
|
||||
};
|
||||
template<>
|
||||
struct is_unsigned<unsigned long> { static const bool value = true; };
|
||||
struct is_unsigned<unsigned long> {
|
||||
static const bool value = true;
|
||||
};
|
||||
template<>
|
||||
struct is_unsigned<unsigned long long> { static const bool value = true; };
|
||||
struct is_unsigned<unsigned long long> {
|
||||
static const bool value = true;
|
||||
};
|
||||
};
|
||||
|
||||
/** \addtogroup platform */
|
||||
|
@ -52,7 +64,8 @@ struct is_unsigned<unsigned long long> { static const bool value = true; };
|
|||
template<typename T, uint32_t BufferSize, typename CounterType = uint32_t>
|
||||
class CircularBuffer {
|
||||
public:
|
||||
CircularBuffer() : _head(0), _tail(0), _full(false) {
|
||||
CircularBuffer() : _head(0), _tail(0), _full(false)
|
||||
{
|
||||
MBED_STATIC_ASSERT(
|
||||
internal::is_unsigned<CounterType>::value,
|
||||
"CounterType must be unsigned"
|
||||
|
@ -65,7 +78,8 @@ public:
|
|||
);
|
||||
}
|
||||
|
||||
~CircularBuffer() {
|
||||
~CircularBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
/** Push the transaction to the buffer. This overwrites the buffer if it's
|
||||
|
@ -73,7 +87,8 @@ public:
|
|||
*
|
||||
* @param data Data to be pushed to the buffer
|
||||
*/
|
||||
void push(const T& data) {
|
||||
void push(const T &data)
|
||||
{
|
||||
core_util_critical_section_enter();
|
||||
if (full()) {
|
||||
_tail++;
|
||||
|
@ -92,7 +107,8 @@ public:
|
|||
* @param data Data to be popped from the buffer
|
||||
* @return True if the buffer is not empty and data contains a transaction, false otherwise
|
||||
*/
|
||||
bool pop(T& data) {
|
||||
bool pop(T &data)
|
||||
{
|
||||
bool data_popped = false;
|
||||
core_util_critical_section_enter();
|
||||
if (!empty()) {
|
||||
|
@ -109,7 +125,8 @@ public:
|
|||
*
|
||||
* @return True if the buffer is empty, false if not
|
||||
*/
|
||||
bool empty() const {
|
||||
bool empty() const
|
||||
{
|
||||
core_util_critical_section_enter();
|
||||
bool is_empty = (_head == _tail) && !_full;
|
||||
core_util_critical_section_exit();
|
||||
|
@ -120,7 +137,8 @@ public:
|
|||
*
|
||||
* @return True if the buffer is full, false if not
|
||||
*/
|
||||
bool full() const {
|
||||
bool full() const
|
||||
{
|
||||
core_util_critical_section_enter();
|
||||
bool full = _full;
|
||||
core_util_critical_section_exit();
|
||||
|
@ -130,7 +148,8 @@ public:
|
|||
/** Reset the buffer
|
||||
*
|
||||
*/
|
||||
void reset() {
|
||||
void reset()
|
||||
{
|
||||
core_util_critical_section_enter();
|
||||
_head = 0;
|
||||
_tail = 0;
|
||||
|
@ -139,7 +158,8 @@ public:
|
|||
}
|
||||
|
||||
/** Get the number of elements currently stored in the circular_buffer */
|
||||
CounterType size() const {
|
||||
CounterType size() const
|
||||
{
|
||||
core_util_critical_section_enter();
|
||||
CounterType elements;
|
||||
if (!_full) {
|
||||
|
@ -160,7 +180,8 @@ public:
|
|||
* @param data Data to be peeked from the buffer
|
||||
* @return True if the buffer is not empty and data contains a transaction, false otherwise
|
||||
*/
|
||||
bool peek(T& data) const {
|
||||
bool peek(T &data) const
|
||||
{
|
||||
bool data_updated = false;
|
||||
core_util_critical_section_enter();
|
||||
if (!empty()) {
|
||||
|
|
|
@ -108,7 +108,10 @@ public:
|
|||
* @deprecated Replaced by `int DirHandle::close()'
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by DirHandle::close")
|
||||
virtual int closedir() { return close(); };
|
||||
virtual int closedir()
|
||||
{
|
||||
return close();
|
||||
};
|
||||
|
||||
/** Return the directory entry at the current position, and
|
||||
* advances the position to the next entry.
|
||||
|
@ -130,7 +133,10 @@ public:
|
|||
* @deprecated Replaced by `void DirHandle::rewind()'
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by DirHandle::rewind")
|
||||
virtual void rewinddir() { rewind(); }
|
||||
virtual void rewinddir()
|
||||
{
|
||||
rewind();
|
||||
}
|
||||
|
||||
/** Returns the current position of the DirHandle.
|
||||
*
|
||||
|
@ -140,7 +146,10 @@ public:
|
|||
* @deprecated Replaced by `off_t DirHandle::tell()'
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by DirHandle::tell")
|
||||
virtual off_t telldir() { return tell(); }
|
||||
virtual off_t telldir()
|
||||
{
|
||||
return tell();
|
||||
}
|
||||
|
||||
/** Sets the position of the DirHandle.
|
||||
*
|
||||
|
@ -148,7 +157,10 @@ public:
|
|||
* @deprecated Replaced by `void DirHandle::seek(off_t offset)'
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by DirHandle::seek")
|
||||
virtual void seekdir(off_t location) { seek(location); }
|
||||
virtual void seekdir(off_t location)
|
||||
{
|
||||
seek(location);
|
||||
}
|
||||
};
|
||||
|
||||
/**@}*/
|
||||
|
|
|
@ -24,7 +24,8 @@ SingletonPtr<PlatformMutex> FileBase::_mutex;
|
|||
|
||||
FileBase::FileBase(const char *name, PathType t) : _next(NULL),
|
||||
_name(name),
|
||||
_path_type(t) {
|
||||
_path_type(t)
|
||||
{
|
||||
_mutex->lock();
|
||||
if (name != NULL) {
|
||||
// put this object at head of the list
|
||||
|
@ -36,7 +37,8 @@ FileBase::FileBase(const char *name, PathType t) : _next(NULL),
|
|||
_mutex->unlock();
|
||||
}
|
||||
|
||||
FileBase::~FileBase() {
|
||||
FileBase::~FileBase()
|
||||
{
|
||||
_mutex->lock();
|
||||
if (_name != NULL) {
|
||||
// remove this object from the list
|
||||
|
@ -53,12 +55,13 @@ FileBase::~FileBase() {
|
|||
_mutex->unlock();
|
||||
|
||||
if (getPathType() == FilePathType) {
|
||||
extern void remove_filehandle(FileHandle *file);
|
||||
remove_filehandle(static_cast<FileHandle*>(static_cast<FileLike*>(this)));
|
||||
extern void remove_filehandle(FileHandle * file);
|
||||
remove_filehandle(static_cast<FileHandle *>(static_cast<FileLike *>(this)));
|
||||
}
|
||||
}
|
||||
|
||||
FileBase *FileBase::lookup(const char *name, unsigned int len) {
|
||||
FileBase *FileBase::lookup(const char *name, unsigned int len)
|
||||
{
|
||||
_mutex->lock();
|
||||
FileBase *p = _head;
|
||||
while (p != NULL) {
|
||||
|
@ -73,7 +76,8 @@ FileBase *FileBase::lookup(const char *name, unsigned int len) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
FileBase *FileBase::get(int n) {
|
||||
FileBase *FileBase::get(int n)
|
||||
{
|
||||
_mutex->lock();
|
||||
FileBase *p = _head;
|
||||
int m = 0;
|
||||
|
@ -90,12 +94,14 @@ FileBase *FileBase::get(int n) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const char* FileBase::getName(void) {
|
||||
const char *FileBase::getName(void)
|
||||
{
|
||||
// Constant read so no lock needed
|
||||
return _name;
|
||||
}
|
||||
|
||||
PathType FileBase::getPathType(void) {
|
||||
PathType FileBase::getPathType(void)
|
||||
{
|
||||
// Constant read so no lock needed
|
||||
return _path_type;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
FileBase(const char *name, PathType t);
|
||||
virtual ~FileBase();
|
||||
|
||||
const char* getName(void);
|
||||
const char *getName(void);
|
||||
PathType getPathType(void);
|
||||
|
||||
static FileBase *lookup(const char *name, unsigned int len);
|
||||
|
@ -61,7 +61,7 @@ private:
|
|||
static SingletonPtr<PlatformMutex> _mutex;
|
||||
|
||||
FileBase *_next;
|
||||
const char * const _name;
|
||||
const char *const _name;
|
||||
const PathType _path_type;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
FilePath::FilePath(const char* file_path) : file_name(NULL), fb(NULL) {
|
||||
FilePath::FilePath(const char *file_path) : file_name(NULL), fb(NULL)
|
||||
{
|
||||
// skip slashes
|
||||
file_path += strspn(file_path, "/");
|
||||
|
||||
const char* file_system = file_path;
|
||||
const char *file_system = file_path;
|
||||
file_name = file_system;
|
||||
int len = 0;
|
||||
while (true) {
|
||||
|
@ -41,37 +42,45 @@ FilePath::FilePath(const char* file_path) : file_name(NULL), fb(NULL) {
|
|||
fb = FileBase::lookup(file_system, len);
|
||||
}
|
||||
|
||||
const char* FilePath::fileName(void) {
|
||||
const char *FilePath::fileName(void)
|
||||
{
|
||||
return file_name;
|
||||
}
|
||||
|
||||
bool FilePath::isFileSystem(void) {
|
||||
if (NULL == fb)
|
||||
bool FilePath::isFileSystem(void)
|
||||
{
|
||||
if (NULL == fb) {
|
||||
return false;
|
||||
}
|
||||
return (fb->getPathType() == FileSystemPathType);
|
||||
}
|
||||
|
||||
FileSystemLike* FilePath::fileSystem(void) {
|
||||
FileSystemLike *FilePath::fileSystem(void)
|
||||
{
|
||||
if (isFileSystem()) {
|
||||
return static_cast<FileSystemLike*>(fb);
|
||||
return static_cast<FileSystemLike *>(fb);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool FilePath::isFile(void) {
|
||||
if (NULL == fb)
|
||||
bool FilePath::isFile(void)
|
||||
{
|
||||
if (NULL == fb) {
|
||||
return false;
|
||||
}
|
||||
return (fb->getPathType() == FilePathType);
|
||||
}
|
||||
|
||||
FileLike* FilePath::file(void) {
|
||||
FileLike *FilePath::file(void)
|
||||
{
|
||||
if (isFile()) {
|
||||
return (FileLike*)fb;
|
||||
return (FileLike *)fb;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool FilePath::exists(void) {
|
||||
bool FilePath::exists(void)
|
||||
{
|
||||
return fb != NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,20 +40,20 @@ public:
|
|||
*
|
||||
* @param file_path The path of file.
|
||||
*/
|
||||
FilePath(const char* file_path);
|
||||
FilePath(const char *file_path);
|
||||
|
||||
const char* fileName(void);
|
||||
const char *fileName(void);
|
||||
|
||||
bool isFileSystem(void);
|
||||
FileSystemLike* fileSystem(void);
|
||||
FileSystemLike *fileSystem(void);
|
||||
|
||||
bool isFile(void);
|
||||
FileLike* file(void);
|
||||
FileLike *file(void);
|
||||
bool exists(void);
|
||||
|
||||
private:
|
||||
const char* file_name;
|
||||
FileBase* fb;
|
||||
const char *file_name;
|
||||
FileBase *fb;
|
||||
};
|
||||
|
||||
/**@}*/
|
||||
|
|
|
@ -36,20 +36,22 @@ class FunctionPointerArg1 : public Callback<R(A1)> {
|
|||
public:
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
|
||||
FunctionPointerArg1(R (*function)(A1) = 0)
|
||||
FunctionPointerArg1(R(*function)(A1) = 0)
|
||||
: Callback<R(A1)>(function) {}
|
||||
|
||||
template<typename T>
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
|
||||
FunctionPointerArg1(T *object, R (T::*member)(A1))
|
||||
FunctionPointerArg1(T *object, R(T::*member)(A1))
|
||||
: Callback<R(A1)>(object, member) {}
|
||||
|
||||
R (*get_function())(A1) {
|
||||
return *reinterpret_cast<R (**)(A1)>(this);
|
||||
R(*get_function())(A1)
|
||||
{
|
||||
return *reinterpret_cast<R(* *)(A1)>(this);
|
||||
}
|
||||
|
||||
R call(A1 a1) const {
|
||||
R call(A1 a1) const
|
||||
{
|
||||
if (!Callback<R(A1)>::operator bool()) {
|
||||
return (R)0;
|
||||
}
|
||||
|
@ -57,7 +59,8 @@ public:
|
|||
return Callback<R(A1)>::call(a1);
|
||||
}
|
||||
|
||||
R operator()(A1 a1) const {
|
||||
R operator()(A1 a1) const
|
||||
{
|
||||
return Callback<R(A1)>::call(a1);
|
||||
}
|
||||
};
|
||||
|
@ -67,20 +70,22 @@ class FunctionPointerArg1<R, void> : public Callback<R()> {
|
|||
public:
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"FunctionPointer has been replaced by Callback<void()>")
|
||||
FunctionPointerArg1(R (*function)() = 0)
|
||||
FunctionPointerArg1(R(*function)() = 0)
|
||||
: Callback<R()>(function) {}
|
||||
|
||||
template<typename T>
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"FunctionPointer has been replaced by Callback<void()>")
|
||||
FunctionPointerArg1(T *object, R (T::*member)())
|
||||
FunctionPointerArg1(T *object, R(T::*member)())
|
||||
: Callback<R()>(object, member) {}
|
||||
|
||||
R (*get_function())() {
|
||||
return *reinterpret_cast<R (**)()>(this);
|
||||
R(*get_function())()
|
||||
{
|
||||
return *reinterpret_cast<R(* *)()>(this);
|
||||
}
|
||||
|
||||
R call() const {
|
||||
R call() const
|
||||
{
|
||||
if (!Callback<R()>::operator bool()) {
|
||||
return (R)0;
|
||||
}
|
||||
|
@ -88,7 +93,8 @@ public:
|
|||
return Callback<R()>::call();
|
||||
}
|
||||
|
||||
R operator()() const {
|
||||
R operator()() const
|
||||
{
|
||||
return Callback<R()>::call();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -45,7 +45,8 @@ typedef struct { /* File Search info record */
|
|||
#define RESERVED_FOR_USER_APPLICATIONS (0x100) /* 0x100 - 0x1ff */
|
||||
#define USR_XFFIND (RESERVED_FOR_USER_APPLICATIONS + 0)
|
||||
|
||||
static int xffind (const char *pattern, XFINFO *info) {
|
||||
static int xffind(const char *pattern, XFINFO *info)
|
||||
{
|
||||
unsigned param[4];
|
||||
|
||||
param[0] = (unsigned long)pattern;
|
||||
|
@ -63,7 +64,8 @@ static int xffind (const char *pattern, XFINFO *info) {
|
|||
#define OPEN_A 8
|
||||
#define OPEN_INVALID -1
|
||||
|
||||
int posix_to_semihost_open_flags(int flags) {
|
||||
int posix_to_semihost_open_flags(int flags)
|
||||
{
|
||||
/* POSIX flags -> semihosting open mode */
|
||||
int openmode;
|
||||
if (flags & O_RDWR) {
|
||||
|
@ -94,7 +96,8 @@ int posix_to_semihost_open_flags(int flags) {
|
|||
return openmode;
|
||||
}
|
||||
|
||||
FILEHANDLE local_file_open(const char* name, int flags) {
|
||||
FILEHANDLE local_file_open(const char *name, int flags)
|
||||
{
|
||||
int openmode = posix_to_semihost_open_flags(flags);
|
||||
if (openmode == OPEN_INVALID) {
|
||||
return (FILEHANDLE)NULL;
|
||||
|
@ -108,42 +111,48 @@ FILEHANDLE local_file_open(const char* name, int flags) {
|
|||
return fh;
|
||||
}
|
||||
|
||||
LocalFileHandle::LocalFileHandle(FILEHANDLE fh) : _fh(fh), pos(0) {
|
||||
LocalFileHandle::LocalFileHandle(FILEHANDLE fh) : _fh(fh), pos(0)
|
||||
{
|
||||
// No lock needed in constructor
|
||||
}
|
||||
|
||||
int LocalFileHandle::close() {
|
||||
int LocalFileHandle::close()
|
||||
{
|
||||
int retval = semihost_close(_fh);
|
||||
delete this;
|
||||
return retval;
|
||||
}
|
||||
|
||||
ssize_t LocalFileHandle::write(const void *buffer, size_t length) {
|
||||
ssize_t LocalFileHandle::write(const void *buffer, size_t length)
|
||||
{
|
||||
lock();
|
||||
ssize_t n = semihost_write(_fh, (const unsigned char*)buffer, length, 0); // number of characters not written
|
||||
ssize_t n = semihost_write(_fh, (const unsigned char *)buffer, length, 0); // number of characters not written
|
||||
n = length - n; // number of characters written
|
||||
pos += n;
|
||||
unlock();
|
||||
return n;
|
||||
}
|
||||
|
||||
ssize_t LocalFileHandle::read(void *buffer, size_t length) {
|
||||
ssize_t LocalFileHandle::read(void *buffer, size_t length)
|
||||
{
|
||||
lock();
|
||||
ssize_t n = semihost_read(_fh, (unsigned char*)buffer, length, 0); // number of characters not read
|
||||
ssize_t n = semihost_read(_fh, (unsigned char *)buffer, length, 0); // number of characters not read
|
||||
n = length - n; // number of characters read
|
||||
pos += n;
|
||||
unlock();
|
||||
return n;
|
||||
}
|
||||
|
||||
int LocalFileHandle::isatty() {
|
||||
int LocalFileHandle::isatty()
|
||||
{
|
||||
lock();
|
||||
int ret = semihost_istty(_fh);
|
||||
unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t LocalFileHandle::seek(off_t position, int whence) {
|
||||
off_t LocalFileHandle::seek(off_t position, int whence)
|
||||
{
|
||||
lock();
|
||||
if (whence == SEEK_CUR) {
|
||||
position += pos;
|
||||
|
@ -158,25 +167,29 @@ off_t LocalFileHandle::seek(off_t position, int whence) {
|
|||
return position;
|
||||
}
|
||||
|
||||
int LocalFileHandle::sync() {
|
||||
int LocalFileHandle::sync()
|
||||
{
|
||||
lock();
|
||||
int ret = semihost_ensure(_fh);
|
||||
unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t LocalFileHandle::size() {
|
||||
off_t LocalFileHandle::size()
|
||||
{
|
||||
lock();
|
||||
off_t off = semihost_flen(_fh);
|
||||
unlock();
|
||||
return off;
|
||||
}
|
||||
|
||||
void LocalFileHandle::lock() {
|
||||
void LocalFileHandle::lock()
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
|
||||
void LocalFileHandle::unlock() {
|
||||
void LocalFileHandle::unlock()
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
|
@ -185,18 +198,21 @@ class LocalDirHandle : public DirHandle {
|
|||
public:
|
||||
XFINFO info;
|
||||
|
||||
LocalDirHandle() : info() {
|
||||
LocalDirHandle() : info()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int close() {
|
||||
virtual int close()
|
||||
{
|
||||
// No lock can be used in destructor
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int read(struct dirent *ent) {
|
||||
virtual int read(struct dirent *ent)
|
||||
{
|
||||
lock();
|
||||
if (xffind("*", &info)!=0) {
|
||||
if (xffind("*", &info) != 0) {
|
||||
unlock();
|
||||
return 0;
|
||||
}
|
||||
|
@ -205,20 +221,23 @@ public:
|
|||
return 1;
|
||||
}
|
||||
|
||||
virtual void rewind() {
|
||||
virtual void rewind()
|
||||
{
|
||||
lock();
|
||||
info.fileID = 0;
|
||||
unlock();
|
||||
}
|
||||
|
||||
virtual off_t tell() {
|
||||
virtual off_t tell()
|
||||
{
|
||||
lock();
|
||||
int fileId = info.fileID;
|
||||
unlock();
|
||||
return fileId;
|
||||
}
|
||||
|
||||
virtual void seek(off_t offset) {
|
||||
virtual void seek(off_t offset)
|
||||
{
|
||||
lock();
|
||||
info.fileID = offset;
|
||||
unlock();
|
||||
|
@ -227,16 +246,19 @@ public:
|
|||
protected:
|
||||
PlatformMutex _mutex;
|
||||
|
||||
virtual void lock() {
|
||||
virtual void lock()
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
|
||||
virtual void unlock() {
|
||||
virtual void unlock()
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
int LocalFileSystem::open(FileHandle **file, const char* name, int flags) {
|
||||
int LocalFileSystem::open(FileHandle **file, const char *name, int flags)
|
||||
{
|
||||
// No global state modified so function is thread safe
|
||||
|
||||
/* reject filenames with / in them */
|
||||
|
@ -260,13 +282,15 @@ int LocalFileSystem::open(FileHandle **file, const char* name, int flags) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LocalFileSystem::remove(const char *filename) {
|
||||
int LocalFileSystem::remove(const char *filename)
|
||||
{
|
||||
// No global state modified so function is thread safe
|
||||
|
||||
return semihost_remove(filename);
|
||||
}
|
||||
|
||||
int LocalFileSystem::open(DirHandle **dir, const char *name) {
|
||||
int LocalFileSystem::open(DirHandle **dir, const char *name)
|
||||
{
|
||||
// No global state modified so function is thread safe
|
||||
|
||||
*dir = new LocalDirHandle();
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace mbed {
|
|||
* @{
|
||||
*/
|
||||
|
||||
FILEHANDLE local_file_open(const char* name, int flags);
|
||||
FILEHANDLE local_file_open(const char *name, int flags);
|
||||
|
||||
/**
|
||||
* @class LocalFileHandle
|
||||
|
@ -106,7 +106,8 @@ class LocalFileSystem : public FileSystemLike, private NonCopyable<LocalFileSyst
|
|||
// No modifiable state
|
||||
|
||||
public:
|
||||
LocalFileSystem(const char* n) : FileSystemLike(n) {
|
||||
LocalFileSystem(const char *n) : FileSystemLike(n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ protected:
|
|||
* Copy of non copyable resources can lead to resource leak and random error.
|
||||
*/
|
||||
MBED_DEPRECATED("Invalid copy construction of a NonCopyable resource.")
|
||||
NonCopyable(const NonCopyable&)
|
||||
NonCopyable(const NonCopyable &)
|
||||
{
|
||||
debug("Invalid copy construction of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ protected:
|
|||
* Copy of non copyable resources can lead to resource leak and random error.
|
||||
*/
|
||||
MBED_DEPRECATED("Invalid copy assignment of a NonCopyable resource.")
|
||||
NonCopyable& operator=(const NonCopyable&)
|
||||
NonCopyable &operator=(const NonCopyable &)
|
||||
{
|
||||
debug("Invalid copy assignment of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
|
||||
return *this;
|
||||
|
@ -196,13 +196,13 @@ private:
|
|||
* Declare copy constructor as private, any attempt to copy construct
|
||||
* a NonCopyable will fail at compile time.
|
||||
*/
|
||||
NonCopyable(const NonCopyable&);
|
||||
NonCopyable(const NonCopyable &);
|
||||
|
||||
/**
|
||||
* Declare copy assignment operator as private, any attempt to copy assign
|
||||
* a NonCopyable will fail at compile time.
|
||||
*/
|
||||
NonCopyable& operator=(const NonCopyable&);
|
||||
NonCopyable &operator=(const NonCopyable &);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -33,19 +33,23 @@ typedef rtos::Mutex PlatformMutex;
|
|||
*/
|
||||
class PlatformMutex : private mbed::NonCopyable<PlatformMutex> {
|
||||
public:
|
||||
PlatformMutex() {
|
||||
PlatformMutex()
|
||||
{
|
||||
// Stub
|
||||
|
||||
}
|
||||
~PlatformMutex() {
|
||||
~PlatformMutex()
|
||||
{
|
||||
// Stub
|
||||
}
|
||||
|
||||
void lock() {
|
||||
void lock()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
void unlock()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
};
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
* @param lockable reference to the instance of Lockable object
|
||||
* @note lockable object should outlive the ScopedLock object
|
||||
*/
|
||||
ScopedLock(Lockable& lockable): _lockable(lockable)
|
||||
ScopedLock(Lockable &lockable): _lockable(lockable)
|
||||
{
|
||||
_lockable.lock();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
_lockable.unlock();
|
||||
}
|
||||
private:
|
||||
Lockable& _lockable;
|
||||
Lockable &_lockable;
|
||||
};
|
||||
|
||||
/**@}*/
|
||||
|
|
|
@ -56,7 +56,7 @@ inline static void singleton_lock(void)
|
|||
inline static void singleton_unlock(void)
|
||||
{
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
osMutexRelease (singleton_mutex_id);
|
||||
osMutexRelease(singleton_mutex_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,8 @@ struct SingletonPtr {
|
|||
* @returns
|
||||
* A pointer to the singleton
|
||||
*/
|
||||
T* get() {
|
||||
T *get()
|
||||
{
|
||||
if (NULL == _ptr) {
|
||||
singleton_lock();
|
||||
if (NULL == _ptr) {
|
||||
|
@ -99,7 +100,8 @@ struct SingletonPtr {
|
|||
* @returns
|
||||
* A pointer to the singleton
|
||||
*/
|
||||
T* operator->() {
|
||||
T *operator->()
|
||||
{
|
||||
return get();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
|
||||
Stream::Stream(const char *name) : FileLike(name), _file(NULL)
|
||||
{
|
||||
// No lock needed in constructor
|
||||
/* open ourselves */
|
||||
_file = fdopen(this, "w+");
|
||||
|
@ -33,47 +34,54 @@ Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
|
|||
}
|
||||
}
|
||||
|
||||
Stream::~Stream() {
|
||||
Stream::~Stream()
|
||||
{
|
||||
// No lock can be used in destructor
|
||||
fclose(_file);
|
||||
}
|
||||
|
||||
int Stream::putc(int c) {
|
||||
int Stream::putc(int c)
|
||||
{
|
||||
lock();
|
||||
fflush(_file);
|
||||
int ret = std::fputc(c, _file);
|
||||
unlock();
|
||||
return ret;
|
||||
}
|
||||
int Stream::puts(const char *s) {
|
||||
int Stream::puts(const char *s)
|
||||
{
|
||||
lock();
|
||||
fflush(_file);
|
||||
int ret = std::fputs(s, _file);
|
||||
unlock();
|
||||
return ret;
|
||||
}
|
||||
int Stream::getc() {
|
||||
int Stream::getc()
|
||||
{
|
||||
lock();
|
||||
fflush(_file);
|
||||
int ret = mbed_getc(_file);
|
||||
unlock();
|
||||
return ret;
|
||||
}
|
||||
char* Stream::gets(char *s, int size) {
|
||||
char *Stream::gets(char *s, int size)
|
||||
{
|
||||
lock();
|
||||
fflush(_file);
|
||||
char *ret = mbed_gets(s,size,_file);
|
||||
char *ret = mbed_gets(s, size, _file);
|
||||
unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Stream::close() {
|
||||
int Stream::close()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t Stream::write(const void* buffer, size_t length) {
|
||||
const char* ptr = (const char*)buffer;
|
||||
const char* end = ptr + length;
|
||||
ssize_t Stream::write(const void *buffer, size_t length)
|
||||
{
|
||||
const char *ptr = (const char *)buffer;
|
||||
const char *end = ptr + length;
|
||||
|
||||
lock();
|
||||
while (ptr != end) {
|
||||
|
@ -83,48 +91,58 @@ ssize_t Stream::write(const void* buffer, size_t length) {
|
|||
}
|
||||
unlock();
|
||||
|
||||
return ptr - (const char*)buffer;
|
||||
return ptr - (const char *)buffer;
|
||||
}
|
||||
|
||||
ssize_t Stream::read(void* buffer, size_t length) {
|
||||
char* ptr = (char*)buffer;
|
||||
char* end = ptr + length;
|
||||
ssize_t Stream::read(void *buffer, size_t length)
|
||||
{
|
||||
char *ptr = (char *)buffer;
|
||||
char *end = ptr + length;
|
||||
|
||||
lock();
|
||||
while (ptr != end) {
|
||||
int c = _getc();
|
||||
if (c==EOF) break;
|
||||
if (c == EOF) {
|
||||
break;
|
||||
}
|
||||
*ptr++ = c;
|
||||
}
|
||||
unlock();
|
||||
|
||||
return ptr - (const char*)buffer;
|
||||
return ptr - (const char *)buffer;
|
||||
}
|
||||
|
||||
off_t Stream::seek(off_t offset, int whence) {
|
||||
off_t Stream::seek(off_t offset, int whence)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
off_t Stream::tell() {
|
||||
off_t Stream::tell()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Stream::rewind() {
|
||||
void Stream::rewind()
|
||||
{
|
||||
}
|
||||
|
||||
int Stream::isatty() {
|
||||
int Stream::isatty()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Stream::sync() {
|
||||
int Stream::sync()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
off_t Stream::size() {
|
||||
off_t Stream::size()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Stream::printf(const char* format, ...) {
|
||||
int Stream::printf(const char *format, ...)
|
||||
{
|
||||
lock();
|
||||
std::va_list arg;
|
||||
va_start(arg, format);
|
||||
|
@ -135,7 +153,8 @@ int Stream::printf(const char* format, ...) {
|
|||
return r;
|
||||
}
|
||||
|
||||
int Stream::scanf(const char* format, ...) {
|
||||
int Stream::scanf(const char *format, ...)
|
||||
{
|
||||
lock();
|
||||
std::va_list arg;
|
||||
va_start(arg, format);
|
||||
|
@ -146,7 +165,8 @@ int Stream::scanf(const char* format, ...) {
|
|||
return r;
|
||||
}
|
||||
|
||||
int Stream::vprintf(const char* format, std::va_list args) {
|
||||
int Stream::vprintf(const char *format, std::va_list args)
|
||||
{
|
||||
lock();
|
||||
fflush(_file);
|
||||
int r = vfprintf(_file, format, args);
|
||||
|
@ -154,7 +174,8 @@ int Stream::vprintf(const char* format, std::va_list args) {
|
|||
return r;
|
||||
}
|
||||
|
||||
int Stream::vscanf(const char* format, std::va_list args) {
|
||||
int Stream::vscanf(const char *format, std::va_list args)
|
||||
{
|
||||
lock();
|
||||
fflush(_file);
|
||||
int r = vfscanf(_file, format, args);
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace mbed {
|
|||
|
||||
extern void mbed_set_unbuffered_stream(std::FILE *_file);
|
||||
extern int mbed_getc(std::FILE *_file);
|
||||
extern char* mbed_gets(char *s, int size, std::FILE *_file);
|
||||
extern char *mbed_gets(char *s, int size, std::FILE *_file);
|
||||
|
||||
/** File stream
|
||||
*
|
||||
|
@ -42,24 +42,27 @@ extern char* mbed_gets(char *s, int size, std::FILE *_file);
|
|||
class Stream : public FileLike, private NonCopyable<Stream> {
|
||||
|
||||
public:
|
||||
Stream(const char *name=NULL);
|
||||
Stream(const char *name = NULL);
|
||||
virtual ~Stream();
|
||||
|
||||
int putc(int c);
|
||||
int puts(const char *s);
|
||||
int getc();
|
||||
char *gets(char *s, int size);
|
||||
int printf(const char* format, ...);
|
||||
int scanf(const char* format, ...);
|
||||
int vprintf(const char* format, std::va_list args);
|
||||
int vscanf(const char* format, std::va_list args);
|
||||
int printf(const char *format, ...);
|
||||
int scanf(const char *format, ...);
|
||||
int vprintf(const char *format, std::va_list args);
|
||||
int vscanf(const char *format, std::va_list args);
|
||||
|
||||
operator std::FILE*() {return _file;}
|
||||
operator std::FILE *()
|
||||
{
|
||||
return _file;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual int close();
|
||||
virtual ssize_t write(const void* buffer, size_t length);
|
||||
virtual ssize_t read(void* buffer, size_t length);
|
||||
virtual ssize_t write(const void *buffer, size_t length);
|
||||
virtual ssize_t read(void *buffer, size_t length);
|
||||
virtual off_t seek(off_t offset, int whence);
|
||||
virtual off_t tell();
|
||||
virtual void rewind();
|
||||
|
@ -74,13 +77,15 @@ protected:
|
|||
|
||||
/** Acquire exclusive access to this object.
|
||||
*/
|
||||
virtual void lock() {
|
||||
virtual void lock()
|
||||
{
|
||||
// Stub
|
||||
}
|
||||
|
||||
/** Release exclusive access to this object.
|
||||
*/
|
||||
virtual void unlock() {
|
||||
virtual void unlock()
|
||||
{
|
||||
// Stub
|
||||
}
|
||||
};
|
||||
|
|
|
@ -46,20 +46,24 @@ typedef struct {
|
|||
template<typename Class>
|
||||
class Transaction {
|
||||
public:
|
||||
Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) {
|
||||
Transaction(Class *tpointer, const transaction_t &transaction) : _obj(tpointer), _data(transaction)
|
||||
{
|
||||
}
|
||||
|
||||
Transaction() : _obj(), _data() {
|
||||
Transaction() : _obj(), _data()
|
||||
{
|
||||
}
|
||||
|
||||
~Transaction() {
|
||||
~Transaction()
|
||||
{
|
||||
}
|
||||
|
||||
/** Get object's instance for the transaction
|
||||
*
|
||||
* @return The object which was stored
|
||||
*/
|
||||
Class* get_object() {
|
||||
Class *get_object()
|
||||
{
|
||||
return _obj;
|
||||
}
|
||||
|
||||
|
@ -67,12 +71,13 @@ public:
|
|||
*
|
||||
* @return The transaction which was stored
|
||||
*/
|
||||
transaction_t* get_transaction() {
|
||||
transaction_t *get_transaction()
|
||||
{
|
||||
return &_data;
|
||||
}
|
||||
|
||||
private:
|
||||
Class* _obj;
|
||||
Class *_obj;
|
||||
transaction_t _data;
|
||||
};
|
||||
/**@}*/
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
Formatted .\ATCmdParser.cpp
|
||||
Formatted .\ATCmdParser.h
|
||||
Formatted .\Callback.h
|
||||
Formatted .\CallChain.cpp
|
||||
Formatted .\CallChain.h
|
||||
Formatted .\CircularBuffer.h
|
||||
Unchanged .\critical.h
|
||||
Formatted .\CriticalSectionLock.h
|
||||
Formatted .\CThunk.h
|
||||
Unchanged .\DeepSleepLock.h
|
||||
Formatted .\DirHandle.h
|
||||
Formatted .\FileBase.cpp
|
||||
Formatted .\FileBase.h
|
||||
Unchanged .\FileHandle.cpp
|
||||
Formatted .\FileHandle.h
|
||||
Unchanged .\FileLike.h
|
||||
Formatted .\FilePath.cpp
|
||||
Formatted .\FilePath.h
|
||||
Unchanged .\FileSystemHandle.cpp
|
||||
Formatted .\FileSystemHandle.h
|
||||
Formatted .\FileSystemLike.h
|
||||
Formatted .\FunctionPointer.h
|
||||
Formatted .\LocalFileSystem.cpp
|
||||
Formatted .\LocalFileSystem.h
|
||||
Formatted .\mbed_alloc_wrappers.cpp
|
||||
Formatted .\mbed_application.c
|
||||
Unchanged .\mbed_application.h
|
||||
Unchanged .\mbed_assert.c
|
||||
Unchanged .\mbed_assert.h
|
||||
Formatted .\mbed_board.c
|
||||
Formatted .\mbed_critical.c
|
||||
Formatted .\mbed_critical.h
|
||||
Formatted .\mbed_debug.h
|
||||
Formatted .\mbed_error.c
|
||||
Formatted .\mbed_error.h
|
||||
Formatted .\mbed_error_hist.c
|
||||
Formatted .\mbed_error_hist.h
|
||||
Formatted .\mbed_interface.c
|
||||
Formatted .\mbed_interface.h
|
||||
Formatted .\mbed_mem_trace.cpp
|
||||
Formatted .\mbed_mem_trace.h
|
||||
Formatted .\mbed_mktime.c
|
||||
Formatted .\mbed_mktime.h
|
||||
Unchanged .\mbed_poll.cpp
|
||||
Unchanged .\mbed_poll.h
|
||||
Formatted .\mbed_power_mgmt.h
|
||||
Unchanged .\mbed_preprocessor.h
|
||||
Formatted .\mbed_retarget.cpp
|
||||
Formatted .\mbed_retarget.h
|
||||
Formatted .\mbed_rtc_time.cpp
|
||||
Unchanged .\mbed_rtc_time.h
|
||||
Formatted .\mbed_sdk_boot.c
|
||||
Formatted .\mbed_semihost_api.c
|
||||
Formatted .\mbed_semihost_api.h
|
||||
Unchanged .\mbed_sleep.h
|
||||
Unchanged .\mbed_stats.c
|
||||
Unchanged .\mbed_stats.h
|
||||
Formatted .\mbed_toolchain.h
|
||||
Formatted .\mbed_wait_api.h
|
||||
Formatted .\mbed_wait_api_no_rtos.c
|
||||
Formatted .\mbed_wait_api_rtos.cpp
|
||||
Formatted .\NonCopyable.h
|
||||
Unchanged .\platform.h
|
||||
Formatted .\PlatformMutex.h
|
||||
Unchanged .\rtc_time.h
|
||||
Formatted .\ScopedLock.h
|
||||
Unchanged .\semihost_api.h
|
||||
Formatted .\SingletonPtr.h
|
||||
Unchanged .\sleep.h
|
||||
Formatted .\Stream.cpp
|
||||
Formatted .\Stream.h
|
||||
Unchanged .\toolchain.h
|
||||
Formatted .\Transaction.h
|
||||
Unchanged .\wait_api.h
|
|
@ -76,33 +76,35 @@ void mbed_stats_heap_get(mbed_stats_heap_t *stats)
|
|||
#endif/* FEATURE_UVISOR */
|
||||
|
||||
extern "C" {
|
||||
void * __real__malloc_r(struct _reent * r, size_t size);
|
||||
void * __real__memalign_r(struct _reent * r, size_t alignment, size_t bytes);
|
||||
void * __real__realloc_r(struct _reent * r, void * ptr, size_t size);
|
||||
void __real__free_r(struct _reent * r, void * ptr);
|
||||
void* __real__calloc_r(struct _reent * r, size_t nmemb, size_t size);
|
||||
void* malloc_wrapper(struct _reent * r, size_t size, void * caller);
|
||||
void free_wrapper(struct _reent * r, void * ptr, void* caller);
|
||||
void *__real__malloc_r(struct _reent *r, size_t size);
|
||||
void *__real__memalign_r(struct _reent *r, size_t alignment, size_t bytes);
|
||||
void *__real__realloc_r(struct _reent *r, void *ptr, size_t size);
|
||||
void __real__free_r(struct _reent *r, void *ptr);
|
||||
void *__real__calloc_r(struct _reent *r, size_t nmemb, size_t size);
|
||||
void *malloc_wrapper(struct _reent *r, size_t size, void *caller);
|
||||
void free_wrapper(struct _reent *r, void *ptr, void *caller);
|
||||
}
|
||||
|
||||
// TODO: memory tracing doesn't work with uVisor enabled.
|
||||
#if !defined(FEATURE_UVISOR)
|
||||
|
||||
extern "C" void * __wrap__malloc_r(struct _reent * r, size_t size) {
|
||||
extern "C" void *__wrap__malloc_r(struct _reent *r, size_t size)
|
||||
{
|
||||
return malloc_wrapper(r, size, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
extern "C" void * malloc_wrapper(struct _reent * r, size_t size, void * caller) {
|
||||
extern "C" void *malloc_wrapper(struct _reent *r, size_t size, void *caller)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
#endif
|
||||
#ifdef MBED_HEAP_STATS_ENABLED
|
||||
malloc_stats_mutex->lock();
|
||||
alloc_info_t *alloc_info = (alloc_info_t*)__real__malloc_r(r, size + sizeof(alloc_info_t));
|
||||
alloc_info_t *alloc_info = (alloc_info_t *)__real__malloc_r(r, size + sizeof(alloc_info_t));
|
||||
if (alloc_info != NULL) {
|
||||
alloc_info->size = size;
|
||||
ptr = (void*)(alloc_info + 1);
|
||||
ptr = (void *)(alloc_info + 1);
|
||||
heap_stats.current_size += size;
|
||||
heap_stats.total_size += size;
|
||||
heap_stats.alloc_cnt += 1;
|
||||
|
@ -123,7 +125,8 @@ extern "C" void * malloc_wrapper(struct _reent * r, size_t size, void * caller)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void * __wrap__realloc_r(struct _reent * r, void * ptr, size_t size) {
|
||||
extern "C" void *__wrap__realloc_r(struct _reent *r, void *ptr, size_t size)
|
||||
{
|
||||
void *new_ptr = NULL;
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
|
@ -139,7 +142,7 @@ extern "C" void * __wrap__realloc_r(struct _reent * r, void * ptr, size_t size)
|
|||
// Get old size
|
||||
uint32_t old_size = 0;
|
||||
if (ptr != NULL) {
|
||||
alloc_info_t *alloc_info = ((alloc_info_t*)ptr) - 1;
|
||||
alloc_info_t *alloc_info = ((alloc_info_t *)ptr) - 1;
|
||||
old_size = alloc_info->size;
|
||||
}
|
||||
|
||||
|
@ -152,7 +155,7 @@ extern "C" void * __wrap__realloc_r(struct _reent * r, void * ptr, size_t size)
|
|||
// and free the old buffer
|
||||
if (new_ptr != NULL) {
|
||||
uint32_t copy_size = (old_size < size) ? old_size : size;
|
||||
memcpy(new_ptr, (void*)ptr, copy_size);
|
||||
memcpy(new_ptr, (void *)ptr, copy_size);
|
||||
free(ptr);
|
||||
}
|
||||
#else // #ifdef MBED_HEAP_STATS_ENABLED
|
||||
|
@ -165,11 +168,13 @@ extern "C" void * __wrap__realloc_r(struct _reent * r, void * ptr, size_t size)
|
|||
return new_ptr;
|
||||
}
|
||||
|
||||
extern "C" void __wrap__free_r(struct _reent * r, void * ptr) {
|
||||
extern "C" void __wrap__free_r(struct _reent *r, void *ptr)
|
||||
{
|
||||
free_wrapper(r, ptr, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
extern "C" void free_wrapper(struct _reent * r, void * ptr, void * caller) {
|
||||
extern "C" void free_wrapper(struct _reent *r, void *ptr, void *caller)
|
||||
{
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
#endif
|
||||
|
@ -177,11 +182,11 @@ extern "C" void free_wrapper(struct _reent * r, void * ptr, void * caller) {
|
|||
malloc_stats_mutex->lock();
|
||||
alloc_info_t *alloc_info = NULL;
|
||||
if (ptr != NULL) {
|
||||
alloc_info = ((alloc_info_t*)ptr) - 1;
|
||||
alloc_info = ((alloc_info_t *)ptr) - 1;
|
||||
heap_stats.current_size -= alloc_info->size;
|
||||
heap_stats.alloc_cnt -= 1;
|
||||
}
|
||||
__real__free_r(r, (void*)alloc_info);
|
||||
__real__free_r(r, (void *)alloc_info);
|
||||
malloc_stats_mutex->unlock();
|
||||
#else // #ifdef MBED_HEAP_STATS_ENABLED
|
||||
__real__free_r(r, ptr);
|
||||
|
@ -192,7 +197,8 @@ extern "C" void free_wrapper(struct _reent * r, void * ptr, void * caller) {
|
|||
#endif // #ifdef MBED_MEM_TRACING_ENABLED
|
||||
}
|
||||
|
||||
extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size) {
|
||||
extern "C" void *__wrap__calloc_r(struct _reent *r, size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
|
@ -214,7 +220,8 @@ extern "C" void * __wrap__calloc_r(struct _reent * r, size_t nmemb, size_t size)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void * __wrap__memalign_r(struct _reent * r, size_t alignment, size_t bytes) {
|
||||
extern "C" void *__wrap__memalign_r(struct _reent *r, size_t alignment, size_t bytes)
|
||||
{
|
||||
return __real__memalign_r(r, alignment, bytes);
|
||||
}
|
||||
|
||||
|
@ -255,26 +262,28 @@ extern "C" {
|
|||
void *SUPER_REALLOC(void *ptr, size_t size);
|
||||
void *SUPER_CALLOC(size_t nmemb, size_t size);
|
||||
void SUPER_FREE(void *ptr);
|
||||
void *malloc_wrapper(size_t size, void* caller);
|
||||
void free_wrapper(void *ptr, void* caller);
|
||||
void *malloc_wrapper(size_t size, void *caller);
|
||||
void free_wrapper(void *ptr, void *caller);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void* SUB_MALLOC(size_t size) {
|
||||
extern "C" void *SUB_MALLOC(size_t size)
|
||||
{
|
||||
return malloc_wrapper(size, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
extern "C" void* malloc_wrapper(size_t size, void* caller) {
|
||||
extern "C" void *malloc_wrapper(size_t size, void *caller)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
#endif
|
||||
#ifdef MBED_HEAP_STATS_ENABLED
|
||||
malloc_stats_mutex->lock();
|
||||
alloc_info_t *alloc_info = (alloc_info_t*)SUPER_MALLOC(size + sizeof(alloc_info_t));
|
||||
alloc_info_t *alloc_info = (alloc_info_t *)SUPER_MALLOC(size + sizeof(alloc_info_t));
|
||||
if (alloc_info != NULL) {
|
||||
alloc_info->size = size;
|
||||
ptr = (void*)(alloc_info + 1);
|
||||
ptr = (void *)(alloc_info + 1);
|
||||
heap_stats.current_size += size;
|
||||
heap_stats.total_size += size;
|
||||
heap_stats.alloc_cnt += 1;
|
||||
|
@ -296,7 +305,8 @@ extern "C" void* malloc_wrapper(size_t size, void* caller) {
|
|||
}
|
||||
|
||||
|
||||
extern "C" void* SUB_REALLOC(void *ptr, size_t size) {
|
||||
extern "C" void *SUB_REALLOC(void *ptr, size_t size)
|
||||
{
|
||||
void *new_ptr = NULL;
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
|
@ -307,7 +317,7 @@ extern "C" void* SUB_REALLOC(void *ptr, size_t size) {
|
|||
// Get old size
|
||||
uint32_t old_size = 0;
|
||||
if (ptr != NULL) {
|
||||
alloc_info_t *alloc_info = ((alloc_info_t*)ptr) - 1;
|
||||
alloc_info_t *alloc_info = ((alloc_info_t *)ptr) - 1;
|
||||
old_size = alloc_info->size;
|
||||
}
|
||||
|
||||
|
@ -320,7 +330,7 @@ extern "C" void* SUB_REALLOC(void *ptr, size_t size) {
|
|||
// and free the old buffer
|
||||
if (new_ptr != NULL) {
|
||||
uint32_t copy_size = (old_size < size) ? old_size : size;
|
||||
memcpy(new_ptr, (void*)ptr, copy_size);
|
||||
memcpy(new_ptr, (void *)ptr, copy_size);
|
||||
free(ptr);
|
||||
}
|
||||
#else // #ifdef MBED_HEAP_STATS_ENABLED
|
||||
|
@ -333,7 +343,8 @@ extern "C" void* SUB_REALLOC(void *ptr, size_t size) {
|
|||
return new_ptr;
|
||||
}
|
||||
|
||||
extern "C" void *SUB_CALLOC(size_t nmemb, size_t size) {
|
||||
extern "C" void *SUB_CALLOC(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
|
@ -354,11 +365,13 @@ extern "C" void *SUB_CALLOC(size_t nmemb, size_t size) {
|
|||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void SUB_FREE(void *ptr) {
|
||||
extern "C" void SUB_FREE(void *ptr)
|
||||
{
|
||||
free_wrapper(ptr, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
extern "C" void free_wrapper(void *ptr, void* caller) {
|
||||
extern "C" void free_wrapper(void *ptr, void *caller)
|
||||
{
|
||||
#ifdef MBED_MEM_TRACING_ENABLED
|
||||
mbed_mem_trace_lock();
|
||||
#endif
|
||||
|
@ -366,11 +379,11 @@ extern "C" void free_wrapper(void *ptr, void* caller) {
|
|||
malloc_stats_mutex->lock();
|
||||
alloc_info_t *alloc_info = NULL;
|
||||
if (ptr != NULL) {
|
||||
alloc_info = ((alloc_info_t*)ptr) - 1;
|
||||
alloc_info = ((alloc_info_t *)ptr) - 1;
|
||||
heap_stats.current_size -= alloc_info->size;
|
||||
heap_stats.alloc_cnt -= 1;
|
||||
}
|
||||
SUPER_FREE((void*)alloc_info);
|
||||
SUPER_FREE((void *)alloc_info);
|
||||
malloc_stats_mutex->unlock();
|
||||
#else // #ifdef MBED_HEAP_STATS_ENABLED
|
||||
SUPER_FREE(ptr);
|
||||
|
|
|
@ -46,8 +46,8 @@ void mbed_start_application(uintptr_t address)
|
|||
powerdown_nvic();
|
||||
powerdown_scb(address);
|
||||
|
||||
sp = *((void**)address + 0);
|
||||
pc = *((void**)address + 1);
|
||||
sp = *((void **)address + 0);
|
||||
pc = *((void **)address + 1);
|
||||
start_new_application(sp, pc);
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ __asm static void start_new_application(void *sp, void *pc)
|
|||
|
||||
void start_new_application(void *sp, void *pc)
|
||||
{
|
||||
__asm volatile (
|
||||
__asm volatile(
|
||||
"movw r2, #0 \n" // Fail to compile "mov r2, #0" with ARMC6. Replace with MOVW.
|
||||
// We needn't "movt r2, #0" immediately following because MOVW
|
||||
// will zero-extend the 16-bit immediate.
|
||||
|
@ -142,7 +142,7 @@ void start_new_application(void *sp, void *pc)
|
|||
"msr primask, r2 \n" // Enable interrupts
|
||||
"bx %1 \n"
|
||||
:
|
||||
: "l" (sp), "l" (pc)
|
||||
: "l"(sp), "l"(pc)
|
||||
: "r2", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -26,11 +26,13 @@ extern int stdio_uart_inited;
|
|||
extern serial_t stdio_uart;
|
||||
#endif
|
||||
|
||||
WEAK void mbed_die(void) {
|
||||
WEAK void mbed_die(void)
|
||||
{
|
||||
#if !defined (NRF51_H) && !defined(TARGET_EFM32)
|
||||
core_util_critical_section_enter();
|
||||
#endif
|
||||
gpio_t led_err; gpio_init_out(&led_err, LED1);
|
||||
gpio_t led_err;
|
||||
gpio_init_out(&led_err, LED1);
|
||||
|
||||
while (1) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
|
@ -49,14 +51,16 @@ WEAK void mbed_die(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void mbed_error_printf(const char* format, ...) {
|
||||
void mbed_error_printf(const char *format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
mbed_error_vfprintf(format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
void mbed_error_vfprintf(const char * format, va_list arg) {
|
||||
void mbed_error_vfprintf(const char *format, va_list arg)
|
||||
{
|
||||
#if DEVICE_SERIAL
|
||||
#define ERROR_BUF_SIZE (128)
|
||||
core_util_critical_section_enter();
|
||||
|
|
|
@ -57,7 +57,7 @@ bool core_util_are_interrupts_enabled(void)
|
|||
bool core_util_is_isr_active(void)
|
||||
{
|
||||
#if defined(__CORTEX_A9)
|
||||
switch(__get_CPSR() & 0x1FU) {
|
||||
switch (__get_CPSR() & 0x1FU) {
|
||||
case CPSR_M_USR:
|
||||
case CPSR_M_SYS:
|
||||
return false;
|
||||
|
@ -79,7 +79,7 @@ void core_util_critical_section_enter(void)
|
|||
{
|
||||
// FIXME
|
||||
#ifdef FEATURE_UVISOR
|
||||
#warning "core_util_critical_section_enter needs fixing to work from unprivileged code"
|
||||
#warning "core_util_critical_section_enter needs fixing to work from unprivileged code"
|
||||
#else
|
||||
// If the reentrancy counter overflows something has gone badly wrong.
|
||||
MBED_ASSERT(critical_section_reentrancy_counter < UINT32_MAX);
|
||||
|
@ -94,7 +94,7 @@ void core_util_critical_section_exit(void)
|
|||
{
|
||||
// FIXME
|
||||
#ifdef FEATURE_UVISOR
|
||||
#warning "core_util_critical_section_exit needs fixing to work from unprivileged code"
|
||||
#warning "core_util_critical_section_exit needs fixing to work from unprivileged code"
|
||||
#endif /* FEATURE_UVISOR */
|
||||
|
||||
// If critical_section_enter has not previously been called, do nothing
|
||||
|
@ -330,18 +330,21 @@ uint32_t core_util_atomic_decr_u32(volatile uint32_t *valuePtr, uint32_t delta)
|
|||
#endif
|
||||
|
||||
|
||||
bool core_util_atomic_cas_ptr(void * volatile *ptr, void **expectedCurrentValue, void *desiredValue) {
|
||||
bool core_util_atomic_cas_ptr(void *volatile *ptr, void **expectedCurrentValue, void *desiredValue)
|
||||
{
|
||||
return core_util_atomic_cas_u32(
|
||||
(volatile uint32_t *)ptr,
|
||||
(uint32_t *)expectedCurrentValue,
|
||||
(uint32_t)desiredValue);
|
||||
}
|
||||
|
||||
void *core_util_atomic_incr_ptr(void * volatile *valuePtr, ptrdiff_t delta) {
|
||||
void *core_util_atomic_incr_ptr(void *volatile *valuePtr, ptrdiff_t delta)
|
||||
{
|
||||
return (void *)core_util_atomic_incr_u32((volatile uint32_t *)valuePtr, (uint32_t)delta);
|
||||
}
|
||||
|
||||
void *core_util_atomic_decr_ptr(void * volatile *valuePtr, ptrdiff_t delta) {
|
||||
void *core_util_atomic_decr_ptr(void *volatile *valuePtr, ptrdiff_t delta)
|
||||
{
|
||||
return (void *)core_util_atomic_decr_u32((volatile uint32_t *)valuePtr, (uint32_t)delta);
|
||||
}
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ bool core_util_atomic_cas_u32(volatile uint32_t *ptr, uint32_t *expectedCurrentV
|
|||
* always succeeds if the current value is expected, as per the pseudocode
|
||||
* above; it will not spuriously fail as "atomic_compare_exchange_weak" may.
|
||||
*/
|
||||
bool core_util_atomic_cas_ptr(void * volatile *ptr, void **expectedCurrentValue, void *desiredValue);
|
||||
bool core_util_atomic_cas_ptr(void *volatile *ptr, void **expectedCurrentValue, void *desiredValue);
|
||||
|
||||
/**
|
||||
* Atomic increment.
|
||||
|
@ -350,7 +350,7 @@ uint32_t core_util_atomic_incr_u32(volatile uint32_t *valuePtr, uint32_t delta);
|
|||
* @note The type of the pointer argument is not taken into account
|
||||
* and the pointer is incremented by bytes.
|
||||
*/
|
||||
void *core_util_atomic_incr_ptr(void * volatile *valuePtr, ptrdiff_t delta);
|
||||
void *core_util_atomic_incr_ptr(void *volatile *valuePtr, ptrdiff_t delta);
|
||||
|
||||
/**
|
||||
* Atomic decrement.
|
||||
|
@ -385,7 +385,7 @@ uint32_t core_util_atomic_decr_u32(volatile uint32_t *valuePtr, uint32_t delta);
|
|||
* @note The type of the pointer argument is not taken into account
|
||||
* and the pointer is decremented by bytes
|
||||
*/
|
||||
void *core_util_atomic_decr_ptr(void * volatile *valuePtr, ptrdiff_t delta);
|
||||
void *core_util_atomic_decr_ptr(void *volatile *valuePtr, ptrdiff_t delta);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
@ -37,7 +37,8 @@ extern "C" {
|
|||
*
|
||||
* @param format printf-style format string, followed by variables
|
||||
*/
|
||||
static inline void debug(const char *format, ...) {
|
||||
static inline void debug(const char *format, ...)
|
||||
{
|
||||
#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
@ -55,7 +56,8 @@ static inline void debug(const char *format, ...) {
|
|||
* @param condition output only if condition is true (!= 0)
|
||||
* @param format printf-style format string, followed by variables
|
||||
*/
|
||||
static inline void debug_if(int condition, const char *format, ...) {
|
||||
static inline void debug_if(int condition, const char *format, ...)
|
||||
{
|
||||
#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
|
||||
if (condition) {
|
||||
va_list args;
|
||||
|
|
|
@ -59,7 +59,7 @@ static void mbed_halt_system(void)
|
|||
{
|
||||
//If not in ISR context exit, otherwise spin on WFI
|
||||
if (core_util_is_isr_active() || !core_util_are_interrupts_enabled()) {
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
__WFI();
|
||||
}
|
||||
} else {
|
||||
|
@ -68,7 +68,8 @@ static void mbed_halt_system(void)
|
|||
}
|
||||
}
|
||||
|
||||
WEAK void error(const char* format, ...) {
|
||||
WEAK void error(const char *format, ...)
|
||||
{
|
||||
|
||||
// Prevent recursion if error is called again
|
||||
if (error_in_progress) {
|
||||
|
@ -194,8 +195,9 @@ mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *e
|
|||
WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
|
||||
{
|
||||
//set the error reported and then halt the system
|
||||
if ( MBED_SUCCESS != handle_error(error_status, error_value, filename, line_number))
|
||||
if (MBED_SUCCESS != handle_error(error_status, error_value, filename, line_number)) {
|
||||
return MBED_ERROR_FAILED_OPERATION;
|
||||
}
|
||||
|
||||
//On fatal errors print the error context/report
|
||||
print_error_report(&last_error_ctx, error_msg);
|
||||
|
@ -208,7 +210,7 @@ WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char
|
|||
mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t error_hook_in)
|
||||
{
|
||||
//register the new hook/callback
|
||||
if ( error_hook_in != NULL ) {
|
||||
if (error_hook_in != NULL) {
|
||||
error_hook = error_hook_in;
|
||||
return MBED_SUCCESS;
|
||||
}
|
||||
|
@ -217,14 +219,14 @@ mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t error_hook_in)
|
|||
}
|
||||
|
||||
//Retrieve the first error context from error log
|
||||
mbed_error_status_t mbed_get_first_error_info (mbed_error_ctx *error_info)
|
||||
mbed_error_status_t mbed_get_first_error_info(mbed_error_ctx *error_info)
|
||||
{
|
||||
memcpy(error_info, &first_error_ctx, sizeof(first_error_ctx));
|
||||
return MBED_SUCCESS;
|
||||
}
|
||||
|
||||
//Retrieve the last error context from error log
|
||||
mbed_error_status_t mbed_get_last_error_info (mbed_error_ctx *error_info)
|
||||
mbed_error_status_t mbed_get_last_error_info(mbed_error_ctx *error_info)
|
||||
{
|
||||
memcpy(error_info, &last_error_ctx, sizeof(mbed_error_ctx));
|
||||
return MBED_SUCCESS;
|
||||
|
@ -233,21 +235,23 @@ mbed_error_status_t mbed_get_last_error_info (mbed_error_ctx *error_info)
|
|||
//Makes an mbed_error_status_t value
|
||||
mbed_error_status_t mbed_make_error(mbed_error_type_t error_type, mbed_module_type_t entity, mbed_error_code_t error_code)
|
||||
{
|
||||
switch(error_type)
|
||||
{
|
||||
switch (error_type) {
|
||||
case MBED_ERROR_TYPE_POSIX:
|
||||
if (error_code >= MBED_POSIX_ERROR_BASE && error_code <= MBED_SYSTEM_ERROR_BASE)
|
||||
if (error_code >= MBED_POSIX_ERROR_BASE && error_code <= MBED_SYSTEM_ERROR_BASE) {
|
||||
return -error_code;
|
||||
}
|
||||
break;
|
||||
|
||||
case MBED_ERROR_TYPE_SYSTEM:
|
||||
if (error_code >= MBED_SYSTEM_ERROR_BASE && error_code <= MBED_CUSTOM_ERROR_BASE)
|
||||
if (error_code >= MBED_SYSTEM_ERROR_BASE && error_code <= MBED_CUSTOM_ERROR_BASE) {
|
||||
return MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, entity, error_code);
|
||||
}
|
||||
break;
|
||||
|
||||
case MBED_ERROR_TYPE_CUSTOM:
|
||||
if (error_code >= MBED_CUSTOM_ERROR_BASE)
|
||||
if (error_code >= MBED_CUSTOM_ERROR_BASE) {
|
||||
return MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, entity, error_code);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -292,7 +296,7 @@ static void print_thread(osRtxThread_t *thread)
|
|||
static void print_threads_info(osRtxThread_t *threads)
|
||||
{
|
||||
while (threads != NULL) {
|
||||
print_thread( threads );
|
||||
print_thread(threads);
|
||||
threads = threads->thread_next;
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +389,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
|
|||
|
||||
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
|
||||
//Retrieve the error context from error log at the specified index
|
||||
mbed_error_status_t mbed_get_error_hist_info (int index, mbed_error_ctx *error_info)
|
||||
mbed_error_status_t mbed_get_error_hist_info(int index, mbed_error_ctx *error_info)
|
||||
{
|
||||
return mbed_error_hist_get(index, error_info);
|
||||
}
|
||||
|
@ -404,13 +408,13 @@ mbed_error_status_t mbed_save_error_hist(const char *path)
|
|||
FILE *error_log_file = NULL;
|
||||
|
||||
//Ensure path is valid
|
||||
if (path==NULL) {
|
||||
if (path == NULL) {
|
||||
ret = MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INVALID_ARGUMENT);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
//Open the file for saving the error log info
|
||||
if ((error_log_file = fopen( path, "w" )) == NULL){
|
||||
if ((error_log_file = fopen(path, "w")) == NULL) {
|
||||
ret = MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OPEN_FAILED);
|
||||
goto exit;
|
||||
}
|
||||
|
|
|
@ -205,8 +205,7 @@ typedef int mbed_error_status_t;
|
|||
* MBED_ERROR_TYPE_POSIX - Used to indicate that the error status is of Posix error type.\n
|
||||
*
|
||||
*/
|
||||
typedef enum _mbed_error_type_t
|
||||
{
|
||||
typedef enum _mbed_error_type_t {
|
||||
MBED_ERROR_TYPE_SYSTEM = 0,
|
||||
MBED_ERROR_TYPE_CUSTOM = 1,
|
||||
//2 is reserved
|
||||
|
@ -577,206 +576,206 @@ typedef enum _mbed_error_code {
|
|||
//POSIX ERROR CODE definitions starts at offset 0(MBED_POSIX_ERROR_BASE) to align them with actual Posix Error Code
|
||||
//defintions in mbed_retarget.h
|
||||
// Error Name Error Code
|
||||
MBED_DEFINE_POSIX_ERROR( EPERM ,EPERM ), /* 1 Operation not permitted */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOENT ,ENOENT ), /* 2 No such file or directory */
|
||||
MBED_DEFINE_POSIX_ERROR( ESRCH ,ESRCH ), /* 3 No such process */
|
||||
MBED_DEFINE_POSIX_ERROR( EINTR ,EINTR ), /* 4 Interrupted system call */
|
||||
MBED_DEFINE_POSIX_ERROR( EIO ,EIO ), /* 5 I/O error */
|
||||
MBED_DEFINE_POSIX_ERROR( ENXIO ,ENXIO ), /* 6 No such device or address */
|
||||
MBED_DEFINE_POSIX_ERROR( E2BIG ,E2BIG ), /* 7 Argument list too long */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOEXEC ,ENOEXEC ), /* 8 Exec format error */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADF ,EBADF ), /* 9 Bad file number */
|
||||
MBED_DEFINE_POSIX_ERROR( ECHILD ,ECHILD ), /* 10 No child processes */
|
||||
MBED_DEFINE_POSIX_ERROR( EAGAIN ,EAGAIN ), /* 11 Try again */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOMEM ,ENOMEM ), /* 12 Out of memory */
|
||||
MBED_DEFINE_POSIX_ERROR( EACCES ,EACCES ), /* 13 Permission denied */
|
||||
MBED_DEFINE_POSIX_ERROR( EFAULT ,EFAULT ), /* 14 Bad address */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTBLK ,ENOTBLK ), /* 15 Block device required */
|
||||
MBED_DEFINE_POSIX_ERROR( EBUSY ,EBUSY ), /* 16 Device or resource busy */
|
||||
MBED_DEFINE_POSIX_ERROR( EEXIST ,EEXIST ), /* 17 File exists */
|
||||
MBED_DEFINE_POSIX_ERROR( EXDEV ,EXDEV ), /* 18 Cross-device link */
|
||||
MBED_DEFINE_POSIX_ERROR( ENODEV ,ENODEV ), /* 19 No such device */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTDIR ,ENOTDIR ), /* 20 Not a directory */
|
||||
MBED_DEFINE_POSIX_ERROR( EISDIR ,EISDIR ), /* 21 Is a directory */
|
||||
MBED_DEFINE_POSIX_ERROR( EINVAL ,EINVAL ), /* 22 Invalid argument */
|
||||
MBED_DEFINE_POSIX_ERROR( ENFILE ,ENFILE ), /* 23 File table overflow */
|
||||
MBED_DEFINE_POSIX_ERROR( EMFILE ,EMFILE ), /* 24 Too many open files */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTTY ,ENOTTY ), /* 25 Not a typewriter */
|
||||
MBED_DEFINE_POSIX_ERROR( ETXTBSY ,ETXTBSY ), /* 26 Text file busy */
|
||||
MBED_DEFINE_POSIX_ERROR( EFBIG ,EFBIG ), /* 27 File too large */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOSPC ,ENOSPC ), /* 28 No space left on device */
|
||||
MBED_DEFINE_POSIX_ERROR( ESPIPE ,ESPIPE ), /* 29 Illegal seek */
|
||||
MBED_DEFINE_POSIX_ERROR( EROFS ,EROFS ), /* 30 Read-only file system */
|
||||
MBED_DEFINE_POSIX_ERROR( EMLINK ,EMLINK ), /* 31 Too many links */
|
||||
MBED_DEFINE_POSIX_ERROR( EPIPE ,EPIPE ), /* 32 Broken pipe */
|
||||
MBED_DEFINE_POSIX_ERROR( EDOM ,EDOM ), /* 33 Math argument out of domain of func */
|
||||
MBED_DEFINE_POSIX_ERROR( ERANGE ,ERANGE ), /* 34 Math result not representable */
|
||||
MBED_DEFINE_POSIX_ERROR( EDEADLK ,EDEADLK ), /* 35 Resource deadlock would occur */
|
||||
MBED_DEFINE_POSIX_ERROR( ENAMETOOLONG ,ENAMETOOLONG ), /* 36 File name too long */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOLCK ,ENOLCK ), /* 37 No record locks available */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOSYS ,ENOSYS ), /* 38 Function not implemented */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTEMPTY ,ENOTEMPTY ), /* 39 Directory not empty */
|
||||
MBED_DEFINE_POSIX_ERROR( ELOOP ,ELOOP ), /* 40 Too many symbolic links encountered */
|
||||
MBED_DEFINE_POSIX_ERROR( EWOULDBLOCK ,EAGAIN ), /* EAGAIN Operation would block */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOMSG ,ENOMSG ), /* 42 No message of desired type */
|
||||
MBED_DEFINE_POSIX_ERROR( EIDRM ,EIDRM ), /* 43 Identifier removed */
|
||||
MBED_DEFINE_POSIX_ERROR( ECHRNG ,ECHRNG ), /* 44 Channel number out of range */
|
||||
MBED_DEFINE_POSIX_ERROR( EL2NSYNC ,EL2NSYNC ), /* 45 Level 2 not synchronized */
|
||||
MBED_DEFINE_POSIX_ERROR( EL3HLT ,EL3HLT ), /* 46 Level 3 halted */
|
||||
MBED_DEFINE_POSIX_ERROR( EL3RST ,EL3RST ), /* 47 Level 3 reset */
|
||||
MBED_DEFINE_POSIX_ERROR( ELNRNG ,ELNRNG ), /* 48 Link number out of range */
|
||||
MBED_DEFINE_POSIX_ERROR( EUNATCH ,EUNATCH ), /* 49 Protocol driver not attached */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOCSI ,ENOCSI ), /* 50 No CSI structure available */
|
||||
MBED_DEFINE_POSIX_ERROR( EL2HLT ,EL2HLT ), /* 51 Level 2 halted */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADE ,EBADE ), /* 52 Invalid exchange */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADR ,EBADR ), /* 53 Invalid request descriptor */
|
||||
MBED_DEFINE_POSIX_ERROR( EXFULL ,EXFULL ), /* 54 Exchange full */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOANO ,ENOANO ), /* 55 No anode */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADRQC ,EBADRQC ), /* 56 Invalid request code */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADSLT ,EBADSLT ), /* 57 Invalid slot */
|
||||
MBED_DEFINE_POSIX_ERROR( EDEADLOCK ,EDEADLK ), /* EDEADLK Resource deadlock would occur */
|
||||
MBED_DEFINE_POSIX_ERROR( EBFONT ,EBFONT ), /* 59 Bad font file format */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOSTR ,ENOSTR ), /* 60 Device not a stream */
|
||||
MBED_DEFINE_POSIX_ERROR( ENODATA ,ENODATA ), /* 61 No data available */
|
||||
MBED_DEFINE_POSIX_ERROR( ETIME ,ETIME ), /* 62 Timer expired */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOSR ,ENOSR ), /* 63 Out of streams resources */
|
||||
MBED_DEFINE_POSIX_ERROR( ENONET ,ENONET ), /* 64 Machine is not on the network */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOPKG ,ENOPKG ), /* 65 Package not installed */
|
||||
MBED_DEFINE_POSIX_ERROR( EREMOTE ,EREMOTE ), /* 66 Object is remote */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOLINK ,ENOLINK ), /* 67 Link has been severed */
|
||||
MBED_DEFINE_POSIX_ERROR( EADV ,EADV ), /* 68 Advertise error */
|
||||
MBED_DEFINE_POSIX_ERROR( ESRMNT ,ESRMNT ), /* 69 Srmount error */
|
||||
MBED_DEFINE_POSIX_ERROR( ECOMM ,ECOMM ), /* 70 Communication error on send */
|
||||
MBED_DEFINE_POSIX_ERROR( EPROTO ,EPROTO ), /* 71 Protocol error */
|
||||
MBED_DEFINE_POSIX_ERROR( EMULTIHOP ,EMULTIHOP ), /* 72 Multihop attempted */
|
||||
MBED_DEFINE_POSIX_ERROR( EDOTDOT ,EDOTDOT ), /* 73 RFS specific error */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADMSG ,EBADMSG ), /* 74 Not a data message */
|
||||
MBED_DEFINE_POSIX_ERROR( EOVERFLOW ,EOVERFLOW ), /* 75 Value too large for defined data type */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTUNIQ ,ENOTUNIQ ), /* 76 Name not unique on network */
|
||||
MBED_DEFINE_POSIX_ERROR( EBADFD ,EBADFD ), /* 77 File descriptor in bad state */
|
||||
MBED_DEFINE_POSIX_ERROR( EREMCHG ,EREMCHG ), /* 78 Remote address changed */
|
||||
MBED_DEFINE_POSIX_ERROR( ELIBACC ,ELIBACC ), /* 79 Can not access a needed shared library */
|
||||
MBED_DEFINE_POSIX_ERROR( ELIBBAD ,ELIBBAD ), /* 80 Accessing a corrupted shared library */
|
||||
MBED_DEFINE_POSIX_ERROR( ELIBSCN ,ELIBSCN ), /* 81 .lib section in a.out corrupted */
|
||||
MBED_DEFINE_POSIX_ERROR( ELIBMAX ,ELIBMAX ), /* 82 Attempting to link in too many shared libraries */
|
||||
MBED_DEFINE_POSIX_ERROR( ELIBEXEC ,ELIBEXEC ), /* 83 Cannot exec a shared library directly */
|
||||
MBED_DEFINE_POSIX_ERROR( EILSEQ ,EILSEQ ), /* 84 Illegal byte sequence */
|
||||
MBED_DEFINE_POSIX_ERROR( ERESTART ,ERESTART ), /* 85 Interrupted system call should be restarted */
|
||||
MBED_DEFINE_POSIX_ERROR( ESTRPIPE ,ESTRPIPE ), /* 86 Streams pipe error */
|
||||
MBED_DEFINE_POSIX_ERROR( EUSERS ,EUSERS ), /* 87 Too many users */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTSOCK ,ENOTSOCK ), /* 88 Socket operation on non-socket */
|
||||
MBED_DEFINE_POSIX_ERROR( EDESTADDRREQ ,EDESTADDRREQ ), /* 89 Destination address required */
|
||||
MBED_DEFINE_POSIX_ERROR( EMSGSIZE ,EMSGSIZE ), /* 90 Message too long */
|
||||
MBED_DEFINE_POSIX_ERROR( EPROTOTYPE ,EPROTOTYPE ), /* 91 Protocol wrong type for socket */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOPROTOOPT ,ENOPROTOOPT ), /* 92 Protocol not available */
|
||||
MBED_DEFINE_POSIX_ERROR( EPROTONOSUPPORT ,EPROTONOSUPPORT ), /* 93 Protocol not supported */
|
||||
MBED_DEFINE_POSIX_ERROR( ESOCKTNOSUPPORT ,ESOCKTNOSUPPORT ), /* 94 Socket type not supported */
|
||||
MBED_DEFINE_POSIX_ERROR( EOPNOTSUPP ,EOPNOTSUPP ), /* 95 Operation not supported on transport endpoint */
|
||||
MBED_DEFINE_POSIX_ERROR( EPFNOSUPPORT ,EPFNOSUPPORT ), /* 96 Protocol family not supported */
|
||||
MBED_DEFINE_POSIX_ERROR( EAFNOSUPPORT ,EAFNOSUPPORT ), /* 97 Address family not supported by protocol */
|
||||
MBED_DEFINE_POSIX_ERROR( EADDRINUSE ,EADDRINUSE ), /* 98 Address already in use */
|
||||
MBED_DEFINE_POSIX_ERROR( EADDRNOTAVAIL ,EADDRNOTAVAIL ), /* 99 Cannot assign requested address */
|
||||
MBED_DEFINE_POSIX_ERROR( ENETDOWN ,ENETDOWN ), /* 100 Network is down */
|
||||
MBED_DEFINE_POSIX_ERROR( ENETUNREACH ,ENETUNREACH ), /* 101 Network is unreachable */
|
||||
MBED_DEFINE_POSIX_ERROR( ENETRESET ,ENETRESET ), /* 102 Network dropped connection because of reset */
|
||||
MBED_DEFINE_POSIX_ERROR( ECONNABORTED ,ECONNABORTED ), /* 103 Software caused connection abort */
|
||||
MBED_DEFINE_POSIX_ERROR( ECONNRESET ,ECONNRESET ), /* 104 Connection reset by peer */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOBUFS ,ENOBUFS ), /* 105 No buffer space available */
|
||||
MBED_DEFINE_POSIX_ERROR( EISCONN ,EISCONN ), /* 106 Transport endpoint is already connected */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTCONN ,ENOTCONN ), /* 107 Transport endpoint is not connected */
|
||||
MBED_DEFINE_POSIX_ERROR( ESHUTDOWN ,ESHUTDOWN ), /* 108 Cannot send after transport endpoint shutdown */
|
||||
MBED_DEFINE_POSIX_ERROR( ETOOMANYREFS ,ETOOMANYREFS ), /* 109 Too many references: cannot splice */
|
||||
MBED_DEFINE_POSIX_ERROR( ETIMEDOUT ,ETIMEDOUT ), /* 110 Connection timed out */
|
||||
MBED_DEFINE_POSIX_ERROR( ECONNREFUSED ,ECONNREFUSED ), /* 111 Connection refused */
|
||||
MBED_DEFINE_POSIX_ERROR( EHOSTDOWN ,EHOSTDOWN ), /* 112 Host is down */
|
||||
MBED_DEFINE_POSIX_ERROR( EHOSTUNREACH ,EHOSTUNREACH ), /* 113 No route to host */
|
||||
MBED_DEFINE_POSIX_ERROR( EALREADY ,EALREADY ), /* 114 Operation already in progress */
|
||||
MBED_DEFINE_POSIX_ERROR( EINPROGRESS ,EINPROGRESS ), /* 115 Operation now in progress */
|
||||
MBED_DEFINE_POSIX_ERROR( ESTALE ,ESTALE ), /* 116 Stale NFS file handle */
|
||||
MBED_DEFINE_POSIX_ERROR( EUCLEAN ,EUCLEAN ), /* 117 Structure needs cleaning */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTNAM ,ENOTNAM ), /* 118 Not a XENIX named type file */
|
||||
MBED_DEFINE_POSIX_ERROR( ENAVAIL ,ENAVAIL ), /* 119 No XENIX semaphores available */
|
||||
MBED_DEFINE_POSIX_ERROR( EISNAM ,EISNAM ), /* 120 Is a named type file */
|
||||
MBED_DEFINE_POSIX_ERROR( EREMOTEIO ,EREMOTEIO ), /* 121 Remote I/O error */
|
||||
MBED_DEFINE_POSIX_ERROR( EDQUOT ,EDQUOT ), /* 122 Quota exceeded */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOMEDIUM ,ENOMEDIUM ), /* 123 No medium found */
|
||||
MBED_DEFINE_POSIX_ERROR( EMEDIUMTYPE ,EMEDIUMTYPE ), /* 124 Wrong medium type */
|
||||
MBED_DEFINE_POSIX_ERROR( ECANCELED ,ECANCELED ), /* 125 Operation Canceled */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOKEY ,ENOKEY ), /* 126 Required key not available */
|
||||
MBED_DEFINE_POSIX_ERROR( EKEYEXPIRED ,EKEYEXPIRED ), /* 127 Key has expired */
|
||||
MBED_DEFINE_POSIX_ERROR( EKEYREVOKED ,EKEYREVOKED ), /* 128 Key has been revoked */
|
||||
MBED_DEFINE_POSIX_ERROR( EKEYREJECTED ,EKEYREJECTED ), /* 129 Key was rejected by service */
|
||||
MBED_DEFINE_POSIX_ERROR( EOWNERDEAD ,EOWNERDEAD ), /* 130 Owner died */
|
||||
MBED_DEFINE_POSIX_ERROR( ENOTRECOVERABLE ,ENOTRECOVERABLE ), /* 131 State not recoverable */
|
||||
MBED_DEFINE_POSIX_ERROR(EPERM, EPERM), /* 1 Operation not permitted */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOENT, ENOENT), /* 2 No such file or directory */
|
||||
MBED_DEFINE_POSIX_ERROR(ESRCH, ESRCH), /* 3 No such process */
|
||||
MBED_DEFINE_POSIX_ERROR(EINTR, EINTR), /* 4 Interrupted system call */
|
||||
MBED_DEFINE_POSIX_ERROR(EIO, EIO), /* 5 I/O error */
|
||||
MBED_DEFINE_POSIX_ERROR(ENXIO, ENXIO), /* 6 No such device or address */
|
||||
MBED_DEFINE_POSIX_ERROR(E2BIG, E2BIG), /* 7 Argument list too long */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOEXEC, ENOEXEC), /* 8 Exec format error */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADF, EBADF), /* 9 Bad file number */
|
||||
MBED_DEFINE_POSIX_ERROR(ECHILD, ECHILD), /* 10 No child processes */
|
||||
MBED_DEFINE_POSIX_ERROR(EAGAIN, EAGAIN), /* 11 Try again */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOMEM, ENOMEM), /* 12 Out of memory */
|
||||
MBED_DEFINE_POSIX_ERROR(EACCES, EACCES), /* 13 Permission denied */
|
||||
MBED_DEFINE_POSIX_ERROR(EFAULT, EFAULT), /* 14 Bad address */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTBLK, ENOTBLK), /* 15 Block device required */
|
||||
MBED_DEFINE_POSIX_ERROR(EBUSY, EBUSY), /* 16 Device or resource busy */
|
||||
MBED_DEFINE_POSIX_ERROR(EEXIST, EEXIST), /* 17 File exists */
|
||||
MBED_DEFINE_POSIX_ERROR(EXDEV, EXDEV), /* 18 Cross-device link */
|
||||
MBED_DEFINE_POSIX_ERROR(ENODEV, ENODEV), /* 19 No such device */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTDIR, ENOTDIR), /* 20 Not a directory */
|
||||
MBED_DEFINE_POSIX_ERROR(EISDIR, EISDIR), /* 21 Is a directory */
|
||||
MBED_DEFINE_POSIX_ERROR(EINVAL, EINVAL), /* 22 Invalid argument */
|
||||
MBED_DEFINE_POSIX_ERROR(ENFILE, ENFILE), /* 23 File table overflow */
|
||||
MBED_DEFINE_POSIX_ERROR(EMFILE, EMFILE), /* 24 Too many open files */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTTY, ENOTTY), /* 25 Not a typewriter */
|
||||
MBED_DEFINE_POSIX_ERROR(ETXTBSY, ETXTBSY), /* 26 Text file busy */
|
||||
MBED_DEFINE_POSIX_ERROR(EFBIG, EFBIG), /* 27 File too large */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOSPC, ENOSPC), /* 28 No space left on device */
|
||||
MBED_DEFINE_POSIX_ERROR(ESPIPE, ESPIPE), /* 29 Illegal seek */
|
||||
MBED_DEFINE_POSIX_ERROR(EROFS, EROFS), /* 30 Read-only file system */
|
||||
MBED_DEFINE_POSIX_ERROR(EMLINK, EMLINK), /* 31 Too many links */
|
||||
MBED_DEFINE_POSIX_ERROR(EPIPE, EPIPE), /* 32 Broken pipe */
|
||||
MBED_DEFINE_POSIX_ERROR(EDOM, EDOM), /* 33 Math argument out of domain of func */
|
||||
MBED_DEFINE_POSIX_ERROR(ERANGE, ERANGE), /* 34 Math result not representable */
|
||||
MBED_DEFINE_POSIX_ERROR(EDEADLK, EDEADLK), /* 35 Resource deadlock would occur */
|
||||
MBED_DEFINE_POSIX_ERROR(ENAMETOOLONG, ENAMETOOLONG), /* 36 File name too long */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOLCK, ENOLCK), /* 37 No record locks available */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOSYS, ENOSYS), /* 38 Function not implemented */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTEMPTY, ENOTEMPTY), /* 39 Directory not empty */
|
||||
MBED_DEFINE_POSIX_ERROR(ELOOP, ELOOP), /* 40 Too many symbolic links encountered */
|
||||
MBED_DEFINE_POSIX_ERROR(EWOULDBLOCK, EAGAIN), /* EAGAIN Operation would block */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOMSG, ENOMSG), /* 42 No message of desired type */
|
||||
MBED_DEFINE_POSIX_ERROR(EIDRM, EIDRM), /* 43 Identifier removed */
|
||||
MBED_DEFINE_POSIX_ERROR(ECHRNG, ECHRNG), /* 44 Channel number out of range */
|
||||
MBED_DEFINE_POSIX_ERROR(EL2NSYNC, EL2NSYNC), /* 45 Level 2 not synchronized */
|
||||
MBED_DEFINE_POSIX_ERROR(EL3HLT, EL3HLT), /* 46 Level 3 halted */
|
||||
MBED_DEFINE_POSIX_ERROR(EL3RST, EL3RST), /* 47 Level 3 reset */
|
||||
MBED_DEFINE_POSIX_ERROR(ELNRNG, ELNRNG), /* 48 Link number out of range */
|
||||
MBED_DEFINE_POSIX_ERROR(EUNATCH, EUNATCH), /* 49 Protocol driver not attached */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOCSI, ENOCSI), /* 50 No CSI structure available */
|
||||
MBED_DEFINE_POSIX_ERROR(EL2HLT, EL2HLT), /* 51 Level 2 halted */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADE, EBADE), /* 52 Invalid exchange */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADR, EBADR), /* 53 Invalid request descriptor */
|
||||
MBED_DEFINE_POSIX_ERROR(EXFULL, EXFULL), /* 54 Exchange full */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOANO, ENOANO), /* 55 No anode */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADRQC, EBADRQC), /* 56 Invalid request code */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADSLT, EBADSLT), /* 57 Invalid slot */
|
||||
MBED_DEFINE_POSIX_ERROR(EDEADLOCK, EDEADLK), /* EDEADLK Resource deadlock would occur */
|
||||
MBED_DEFINE_POSIX_ERROR(EBFONT, EBFONT), /* 59 Bad font file format */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOSTR, ENOSTR), /* 60 Device not a stream */
|
||||
MBED_DEFINE_POSIX_ERROR(ENODATA, ENODATA), /* 61 No data available */
|
||||
MBED_DEFINE_POSIX_ERROR(ETIME, ETIME), /* 62 Timer expired */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOSR, ENOSR), /* 63 Out of streams resources */
|
||||
MBED_DEFINE_POSIX_ERROR(ENONET, ENONET), /* 64 Machine is not on the network */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOPKG, ENOPKG), /* 65 Package not installed */
|
||||
MBED_DEFINE_POSIX_ERROR(EREMOTE, EREMOTE), /* 66 Object is remote */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOLINK, ENOLINK), /* 67 Link has been severed */
|
||||
MBED_DEFINE_POSIX_ERROR(EADV, EADV), /* 68 Advertise error */
|
||||
MBED_DEFINE_POSIX_ERROR(ESRMNT, ESRMNT), /* 69 Srmount error */
|
||||
MBED_DEFINE_POSIX_ERROR(ECOMM, ECOMM), /* 70 Communication error on send */
|
||||
MBED_DEFINE_POSIX_ERROR(EPROTO, EPROTO), /* 71 Protocol error */
|
||||
MBED_DEFINE_POSIX_ERROR(EMULTIHOP, EMULTIHOP), /* 72 Multihop attempted */
|
||||
MBED_DEFINE_POSIX_ERROR(EDOTDOT, EDOTDOT), /* 73 RFS specific error */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADMSG, EBADMSG), /* 74 Not a data message */
|
||||
MBED_DEFINE_POSIX_ERROR(EOVERFLOW, EOVERFLOW), /* 75 Value too large for defined data type */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTUNIQ, ENOTUNIQ), /* 76 Name not unique on network */
|
||||
MBED_DEFINE_POSIX_ERROR(EBADFD, EBADFD), /* 77 File descriptor in bad state */
|
||||
MBED_DEFINE_POSIX_ERROR(EREMCHG, EREMCHG), /* 78 Remote address changed */
|
||||
MBED_DEFINE_POSIX_ERROR(ELIBACC, ELIBACC), /* 79 Can not access a needed shared library */
|
||||
MBED_DEFINE_POSIX_ERROR(ELIBBAD, ELIBBAD), /* 80 Accessing a corrupted shared library */
|
||||
MBED_DEFINE_POSIX_ERROR(ELIBSCN, ELIBSCN), /* 81 .lib section in a.out corrupted */
|
||||
MBED_DEFINE_POSIX_ERROR(ELIBMAX, ELIBMAX), /* 82 Attempting to link in too many shared libraries */
|
||||
MBED_DEFINE_POSIX_ERROR(ELIBEXEC, ELIBEXEC), /* 83 Cannot exec a shared library directly */
|
||||
MBED_DEFINE_POSIX_ERROR(EILSEQ, EILSEQ), /* 84 Illegal byte sequence */
|
||||
MBED_DEFINE_POSIX_ERROR(ERESTART, ERESTART), /* 85 Interrupted system call should be restarted */
|
||||
MBED_DEFINE_POSIX_ERROR(ESTRPIPE, ESTRPIPE), /* 86 Streams pipe error */
|
||||
MBED_DEFINE_POSIX_ERROR(EUSERS, EUSERS), /* 87 Too many users */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTSOCK, ENOTSOCK), /* 88 Socket operation on non-socket */
|
||||
MBED_DEFINE_POSIX_ERROR(EDESTADDRREQ, EDESTADDRREQ), /* 89 Destination address required */
|
||||
MBED_DEFINE_POSIX_ERROR(EMSGSIZE, EMSGSIZE), /* 90 Message too long */
|
||||
MBED_DEFINE_POSIX_ERROR(EPROTOTYPE, EPROTOTYPE), /* 91 Protocol wrong type for socket */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOPROTOOPT, ENOPROTOOPT), /* 92 Protocol not available */
|
||||
MBED_DEFINE_POSIX_ERROR(EPROTONOSUPPORT, EPROTONOSUPPORT), /* 93 Protocol not supported */
|
||||
MBED_DEFINE_POSIX_ERROR(ESOCKTNOSUPPORT, ESOCKTNOSUPPORT), /* 94 Socket type not supported */
|
||||
MBED_DEFINE_POSIX_ERROR(EOPNOTSUPP, EOPNOTSUPP), /* 95 Operation not supported on transport endpoint */
|
||||
MBED_DEFINE_POSIX_ERROR(EPFNOSUPPORT, EPFNOSUPPORT), /* 96 Protocol family not supported */
|
||||
MBED_DEFINE_POSIX_ERROR(EAFNOSUPPORT, EAFNOSUPPORT), /* 97 Address family not supported by protocol */
|
||||
MBED_DEFINE_POSIX_ERROR(EADDRINUSE, EADDRINUSE), /* 98 Address already in use */
|
||||
MBED_DEFINE_POSIX_ERROR(EADDRNOTAVAIL, EADDRNOTAVAIL), /* 99 Cannot assign requested address */
|
||||
MBED_DEFINE_POSIX_ERROR(ENETDOWN, ENETDOWN), /* 100 Network is down */
|
||||
MBED_DEFINE_POSIX_ERROR(ENETUNREACH, ENETUNREACH), /* 101 Network is unreachable */
|
||||
MBED_DEFINE_POSIX_ERROR(ENETRESET, ENETRESET), /* 102 Network dropped connection because of reset */
|
||||
MBED_DEFINE_POSIX_ERROR(ECONNABORTED, ECONNABORTED), /* 103 Software caused connection abort */
|
||||
MBED_DEFINE_POSIX_ERROR(ECONNRESET, ECONNRESET), /* 104 Connection reset by peer */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOBUFS, ENOBUFS), /* 105 No buffer space available */
|
||||
MBED_DEFINE_POSIX_ERROR(EISCONN, EISCONN), /* 106 Transport endpoint is already connected */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTCONN, ENOTCONN), /* 107 Transport endpoint is not connected */
|
||||
MBED_DEFINE_POSIX_ERROR(ESHUTDOWN, ESHUTDOWN), /* 108 Cannot send after transport endpoint shutdown */
|
||||
MBED_DEFINE_POSIX_ERROR(ETOOMANYREFS, ETOOMANYREFS), /* 109 Too many references: cannot splice */
|
||||
MBED_DEFINE_POSIX_ERROR(ETIMEDOUT, ETIMEDOUT), /* 110 Connection timed out */
|
||||
MBED_DEFINE_POSIX_ERROR(ECONNREFUSED, ECONNREFUSED), /* 111 Connection refused */
|
||||
MBED_DEFINE_POSIX_ERROR(EHOSTDOWN, EHOSTDOWN), /* 112 Host is down */
|
||||
MBED_DEFINE_POSIX_ERROR(EHOSTUNREACH, EHOSTUNREACH), /* 113 No route to host */
|
||||
MBED_DEFINE_POSIX_ERROR(EALREADY, EALREADY), /* 114 Operation already in progress */
|
||||
MBED_DEFINE_POSIX_ERROR(EINPROGRESS, EINPROGRESS), /* 115 Operation now in progress */
|
||||
MBED_DEFINE_POSIX_ERROR(ESTALE, ESTALE), /* 116 Stale NFS file handle */
|
||||
MBED_DEFINE_POSIX_ERROR(EUCLEAN, EUCLEAN), /* 117 Structure needs cleaning */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTNAM, ENOTNAM), /* 118 Not a XENIX named type file */
|
||||
MBED_DEFINE_POSIX_ERROR(ENAVAIL, ENAVAIL), /* 119 No XENIX semaphores available */
|
||||
MBED_DEFINE_POSIX_ERROR(EISNAM, EISNAM), /* 120 Is a named type file */
|
||||
MBED_DEFINE_POSIX_ERROR(EREMOTEIO, EREMOTEIO), /* 121 Remote I/O error */
|
||||
MBED_DEFINE_POSIX_ERROR(EDQUOT, EDQUOT), /* 122 Quota exceeded */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOMEDIUM, ENOMEDIUM), /* 123 No medium found */
|
||||
MBED_DEFINE_POSIX_ERROR(EMEDIUMTYPE, EMEDIUMTYPE), /* 124 Wrong medium type */
|
||||
MBED_DEFINE_POSIX_ERROR(ECANCELED, ECANCELED), /* 125 Operation Canceled */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOKEY, ENOKEY), /* 126 Required key not available */
|
||||
MBED_DEFINE_POSIX_ERROR(EKEYEXPIRED, EKEYEXPIRED), /* 127 Key has expired */
|
||||
MBED_DEFINE_POSIX_ERROR(EKEYREVOKED, EKEYREVOKED), /* 128 Key has been revoked */
|
||||
MBED_DEFINE_POSIX_ERROR(EKEYREJECTED, EKEYREJECTED), /* 129 Key was rejected by service */
|
||||
MBED_DEFINE_POSIX_ERROR(EOWNERDEAD, EOWNERDEAD), /* 130 Owner died */
|
||||
MBED_DEFINE_POSIX_ERROR(ENOTRECOVERABLE, ENOTRECOVERABLE), /* 131 State not recoverable */
|
||||
|
||||
//Below are MBED SYSTEM ERROR CODE definitions
|
||||
//MBED SYSTEM ERROR CODE definitions starts at offset MBED_SYSTEM_ERROR_BASE, see above.
|
||||
// Error Name Error Offset Error Code
|
||||
MBED_DEFINE_SYSTEM_ERROR( UNKNOWN ,0 ), /* 256 Unknown error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INVALID_ARGUMENT ,1 ), /* 257 Invalid Argument */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INVALID_DATA_DETECTED ,2 ), /* 258 Invalid data detected */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INVALID_FORMAT ,3 ), /* 259 Invalid format */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INVALID_INDEX ,4 ), /* 260 Invalid Index */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INVALID_SIZE ,5 ), /* 261 Inavlid Size */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INVALID_OPERATION ,6 ), /* 262 Invalid Operation */
|
||||
MBED_DEFINE_SYSTEM_ERROR( ITEM_NOT_FOUND ,7 ), /* 263 Item Not Found */
|
||||
MBED_DEFINE_SYSTEM_ERROR( ACCESS_DENIED ,8 ), /* 264 Access Denied */
|
||||
MBED_DEFINE_SYSTEM_ERROR( UNSUPPORTED ,9 ), /* 265 Unsupported */
|
||||
MBED_DEFINE_SYSTEM_ERROR( BUFFER_FULL ,10 ), /* 266 Buffer Full */
|
||||
MBED_DEFINE_SYSTEM_ERROR( MEDIA_FULL ,11 ), /* 267 Media/Disk Full */
|
||||
MBED_DEFINE_SYSTEM_ERROR( ALREADY_IN_USE ,12 ), /* 268 Already in use */
|
||||
MBED_DEFINE_SYSTEM_ERROR( TIME_OUT ,13 ), /* 269 Timeout error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( NOT_READY ,14 ), /* 270 Not Ready */
|
||||
MBED_DEFINE_SYSTEM_ERROR( FAILED_OPERATION ,15 ), /* 271 Requested Operation failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( OPERATION_PROHIBITED ,16 ), /* 272 Operation prohibited */
|
||||
MBED_DEFINE_SYSTEM_ERROR( OPERATION_ABORTED ,17 ), /* 273 Operation failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( WRITE_PROTECTED ,18 ), /* 274 Attempt to write to write-protected resource */
|
||||
MBED_DEFINE_SYSTEM_ERROR( NO_RESPONSE ,19 ), /* 275 No response */
|
||||
MBED_DEFINE_SYSTEM_ERROR( SEMAPHORE_LOCK_FAILED ,20 ), /* 276 Sempahore lock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( MUTEX_LOCK_FAILED ,21 ), /* 277 Mutex lock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( SEMAPHORE_UNLOCK_FAILED ,22 ), /* 278 Sempahore unlock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( MUTEX_UNLOCK_FAILED ,23 ), /* 279 Mutex unlock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CRC_ERROR ,24 ), /* 280 CRC error or mismatch */
|
||||
MBED_DEFINE_SYSTEM_ERROR( OPEN_FAILED ,25 ), /* 281 Open failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CLOSE_FAILED ,26 ), /* 282 Close failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( READ_FAILED ,27 ), /* 283 Read failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( WRITE_FAILED ,28 ), /* 284 Write failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( INITIALIZATION_FAILED ,29 ), /* 285 Initialization failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( BOOT_FAILURE ,30 ), /* 286 Boot failure */
|
||||
MBED_DEFINE_SYSTEM_ERROR( OUT_OF_MEMORY ,31 ), /* 287 Out of memory */
|
||||
MBED_DEFINE_SYSTEM_ERROR( OUT_OF_RESOURCES ,32 ), /* 288 Out of resources */
|
||||
MBED_DEFINE_SYSTEM_ERROR( ALLOC_FAILED ,33 ), /* 289 Alloc failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( FREE_FAILED ,34 ), /* 290 Free failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( OVERFLOW ,35 ), /* 291 Overflow error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( UNDERFLOW ,36 ), /* 292 Underflow error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( STACK_OVERFLOW ,37 ), /* 293 Stack overflow error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( ISR_QUEUE_OVERFLOW ,38 ), /* 294 ISR queue overflow */
|
||||
MBED_DEFINE_SYSTEM_ERROR( TIMER_QUEUE_OVERFLOW ,39 ), /* 295 Timer Queue overflow */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CLIB_SPACE_UNAVAILABLE ,40 ), /* 296 Standard library error - Space unavailable */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CLIB_EXCEPTION ,41 ), /* 297 Standard library error - Exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CLIB_MUTEX_INIT_FAILURE ,42 ), /* 298 Standard library error - Mutex Init failure */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CREATE_FAILED ,43 ), /* 299 Create failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( DELETE_FAILED ,44 ), /* 300 Delete failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( THREAD_CREATE_FAILED ,45 ), /* 301 Thread Create failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( THREAD_DELETE_FAILED ,46 ), /* 302 Thread Delete failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR( PROHIBITED_IN_ISR_CONTEXT ,47 ), /* 303 Operation Prohibited in ISR context */
|
||||
MBED_DEFINE_SYSTEM_ERROR( PINMAP_INVALID ,48 ), /* 304 Pinmap Invalid */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_EVENT ,49 ), /* 305 Unknown Rtos Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_THREAD_EVENT ,50 ), /* 306 Rtos Thread Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_MUTEX_EVENT ,51 ), /* 307 Rtos Mutex Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_SEMAPHORE_EVENT ,52 ), /* 308 Rtos Semaphore Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_MEMORY_POOL_EVENT ,53 ), /* 309 Rtos Memory Pool Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_TIMER_EVENT ,54 ), /* 310 Rtos Timer Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_EVENT_FLAGS_EVENT ,55 ), /* 311 Rtos Event flags Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( RTOS_MESSAGE_QUEUE_EVENT ,56 ), /* 312 Rtos Message queue Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR( DEVICE_BUSY ,57 ), /* 313 Device Busy */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CONFIG_UNSUPPORTED ,58 ), /* 314 Configuration not supported */
|
||||
MBED_DEFINE_SYSTEM_ERROR( CONFIG_MISMATCH ,59 ), /* 315 Configuration mismatch */
|
||||
MBED_DEFINE_SYSTEM_ERROR( ALREADY_INITIALIZED ,60 ), /* 316 Already initialzied */
|
||||
MBED_DEFINE_SYSTEM_ERROR( HARDFAULT_EXCEPTION ,61 ), /* 317 HardFault exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR( MEMMANAGE_EXCEPTION ,62 ), /* 318 MemManage exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR( BUSFAULT_EXCEPTION ,63 ), /* 319 BusFault exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR( USAGEFAULT_EXCEPTION ,64 ), /* 320 UsageFault exception*/
|
||||
MBED_DEFINE_SYSTEM_ERROR(UNKNOWN, 0), /* 256 Unknown error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INVALID_ARGUMENT, 1), /* 257 Invalid Argument */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INVALID_DATA_DETECTED, 2), /* 258 Invalid data detected */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INVALID_FORMAT, 3), /* 259 Invalid format */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INVALID_INDEX, 4), /* 260 Invalid Index */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INVALID_SIZE, 5), /* 261 Inavlid Size */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INVALID_OPERATION, 6), /* 262 Invalid Operation */
|
||||
MBED_DEFINE_SYSTEM_ERROR(ITEM_NOT_FOUND, 7), /* 263 Item Not Found */
|
||||
MBED_DEFINE_SYSTEM_ERROR(ACCESS_DENIED, 8), /* 264 Access Denied */
|
||||
MBED_DEFINE_SYSTEM_ERROR(UNSUPPORTED, 9), /* 265 Unsupported */
|
||||
MBED_DEFINE_SYSTEM_ERROR(BUFFER_FULL, 10), /* 266 Buffer Full */
|
||||
MBED_DEFINE_SYSTEM_ERROR(MEDIA_FULL, 11), /* 267 Media/Disk Full */
|
||||
MBED_DEFINE_SYSTEM_ERROR(ALREADY_IN_USE, 12), /* 268 Already in use */
|
||||
MBED_DEFINE_SYSTEM_ERROR(TIME_OUT, 13), /* 269 Timeout error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(NOT_READY, 14), /* 270 Not Ready */
|
||||
MBED_DEFINE_SYSTEM_ERROR(FAILED_OPERATION, 15), /* 271 Requested Operation failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(OPERATION_PROHIBITED, 16), /* 272 Operation prohibited */
|
||||
MBED_DEFINE_SYSTEM_ERROR(OPERATION_ABORTED, 17), /* 273 Operation failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(WRITE_PROTECTED, 18), /* 274 Attempt to write to write-protected resource */
|
||||
MBED_DEFINE_SYSTEM_ERROR(NO_RESPONSE, 19), /* 275 No response */
|
||||
MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_LOCK_FAILED, 20), /* 276 Sempahore lock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(MUTEX_LOCK_FAILED, 21), /* 277 Mutex lock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_UNLOCK_FAILED, 22), /* 278 Sempahore unlock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(MUTEX_UNLOCK_FAILED, 23), /* 279 Mutex unlock failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CRC_ERROR, 24), /* 280 CRC error or mismatch */
|
||||
MBED_DEFINE_SYSTEM_ERROR(OPEN_FAILED, 25), /* 281 Open failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CLOSE_FAILED, 26), /* 282 Close failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(READ_FAILED, 27), /* 283 Read failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(WRITE_FAILED, 28), /* 284 Write failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(INITIALIZATION_FAILED, 29), /* 285 Initialization failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(BOOT_FAILURE, 30), /* 286 Boot failure */
|
||||
MBED_DEFINE_SYSTEM_ERROR(OUT_OF_MEMORY, 31), /* 287 Out of memory */
|
||||
MBED_DEFINE_SYSTEM_ERROR(OUT_OF_RESOURCES, 32), /* 288 Out of resources */
|
||||
MBED_DEFINE_SYSTEM_ERROR(ALLOC_FAILED, 33), /* 289 Alloc failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(FREE_FAILED, 34), /* 290 Free failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(OVERFLOW, 35), /* 291 Overflow error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(UNDERFLOW, 36), /* 292 Underflow error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(STACK_OVERFLOW, 37), /* 293 Stack overflow error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(ISR_QUEUE_OVERFLOW, 38), /* 294 ISR queue overflow */
|
||||
MBED_DEFINE_SYSTEM_ERROR(TIMER_QUEUE_OVERFLOW, 39), /* 295 Timer Queue overflow */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CLIB_SPACE_UNAVAILABLE, 40), /* 296 Standard library error - Space unavailable */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CLIB_EXCEPTION, 41), /* 297 Standard library error - Exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CLIB_MUTEX_INIT_FAILURE, 42), /* 298 Standard library error - Mutex Init failure */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CREATE_FAILED, 43), /* 299 Create failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(DELETE_FAILED, 44), /* 300 Delete failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(THREAD_CREATE_FAILED, 45), /* 301 Thread Create failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(THREAD_DELETE_FAILED, 46), /* 302 Thread Delete failed */
|
||||
MBED_DEFINE_SYSTEM_ERROR(PROHIBITED_IN_ISR_CONTEXT, 47), /* 303 Operation Prohibited in ISR context */
|
||||
MBED_DEFINE_SYSTEM_ERROR(PINMAP_INVALID, 48), /* 304 Pinmap Invalid */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_EVENT, 49), /* 305 Unknown Rtos Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_THREAD_EVENT, 50), /* 306 Rtos Thread Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_MUTEX_EVENT, 51), /* 307 Rtos Mutex Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_SEMAPHORE_EVENT, 52), /* 308 Rtos Semaphore Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_MEMORY_POOL_EVENT, 53), /* 309 Rtos Memory Pool Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_TIMER_EVENT, 54), /* 310 Rtos Timer Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_EVENT_FLAGS_EVENT, 55), /* 311 Rtos Event flags Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(RTOS_MESSAGE_QUEUE_EVENT, 56), /* 312 Rtos Message queue Error */
|
||||
MBED_DEFINE_SYSTEM_ERROR(DEVICE_BUSY, 57), /* 313 Device Busy */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CONFIG_UNSUPPORTED, 58), /* 314 Configuration not supported */
|
||||
MBED_DEFINE_SYSTEM_ERROR(CONFIG_MISMATCH, 59), /* 315 Configuration mismatch */
|
||||
MBED_DEFINE_SYSTEM_ERROR(ALREADY_INITIALIZED, 60), /* 316 Already initialzied */
|
||||
MBED_DEFINE_SYSTEM_ERROR(HARDFAULT_EXCEPTION, 61), /* 317 HardFault exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR(MEMMANAGE_EXCEPTION, 62), /* 318 MemManage exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR(BUSFAULT_EXCEPTION, 63), /* 319 BusFault exception */
|
||||
MBED_DEFINE_SYSTEM_ERROR(USAGEFAULT_EXCEPTION, 64), /* 320 UsageFault exception*/
|
||||
|
||||
//Everytime you add a new system error code, you must update
|
||||
//Error documentation under Handbook to capture the info on
|
||||
|
@ -865,7 +864,7 @@ typedef struct _mbed_error_ctx {
|
|||
*
|
||||
*/
|
||||
|
||||
void error(const char* format, ...);
|
||||
void error(const char *format, ...);
|
||||
|
||||
/**
|
||||
* Call this Macro to generate a mbed_error_status_t value for a System error
|
||||
|
|
|
@ -84,7 +84,7 @@ mbed_error_status_t mbed_error_hist_get_last_error(mbed_error_ctx *error_ctx)
|
|||
|
||||
int mbed_error_hist_get_count()
|
||||
{
|
||||
return (error_log_count >= MBED_CONF_PLATFORM_ERROR_HIST_SIZE? MBED_CONF_PLATFORM_ERROR_HIST_SIZE:error_log_count+1);
|
||||
return (error_log_count >= MBED_CONF_PLATFORM_ERROR_HIST_SIZE ? MBED_CONF_PLATFORM_ERROR_HIST_SIZE : error_log_count + 1);
|
||||
}
|
||||
|
||||
mbed_error_status_t mbed_error_hist_reset()
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
#define MBED_ERROR_HIST_H
|
||||
|
||||
#ifndef MBED_CONF_PLATFORM_ERROR_HIST_SIZE
|
||||
#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 4
|
||||
#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 4
|
||||
#else
|
||||
#if MBED_CONF_PLATFORM_ERROR_HIST_SIZE == 0
|
||||
#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 1
|
||||
#endif
|
||||
#if MBED_CONF_PLATFORM_ERROR_HIST_SIZE == 0
|
||||
#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -25,11 +25,13 @@
|
|||
#if DEVICE_SEMIHOST
|
||||
|
||||
// return true if a debugger is attached, indicating mbed interface is connected
|
||||
int mbed_interface_connected(void) {
|
||||
int mbed_interface_connected(void)
|
||||
{
|
||||
return semihost_connected();
|
||||
}
|
||||
|
||||
int mbed_interface_reset(void) {
|
||||
int mbed_interface_reset(void)
|
||||
{
|
||||
if (mbed_interface_connected()) {
|
||||
semihost_reset();
|
||||
return 0;
|
||||
|
@ -38,7 +40,8 @@ int mbed_interface_reset(void) {
|
|||
}
|
||||
}
|
||||
|
||||
WEAK int mbed_interface_uid(char *uid) {
|
||||
WEAK int mbed_interface_uid(char *uid)
|
||||
{
|
||||
if (mbed_interface_connected()) {
|
||||
return semihost_uid(uid); // Returns 0 if successful, -1 on failure
|
||||
} else {
|
||||
|
@ -47,11 +50,13 @@ WEAK int mbed_interface_uid(char *uid) {
|
|||
}
|
||||
}
|
||||
|
||||
int mbed_interface_disconnect(void) {
|
||||
int mbed_interface_disconnect(void)
|
||||
{
|
||||
int res;
|
||||
if (mbed_interface_connected()) {
|
||||
if ((res = semihost_disabledebug()) != 0)
|
||||
if ((res = semihost_disabledebug()) != 0) {
|
||||
return res;
|
||||
}
|
||||
while (mbed_interface_connected());
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -59,11 +64,13 @@ int mbed_interface_disconnect(void) {
|
|||
}
|
||||
}
|
||||
|
||||
int mbed_interface_powerdown(void) {
|
||||
int mbed_interface_powerdown(void)
|
||||
{
|
||||
int res;
|
||||
if (mbed_interface_connected()) {
|
||||
if ((res = semihost_powerdown()) != 0)
|
||||
if ((res = semihost_powerdown()) != 0) {
|
||||
return res;
|
||||
}
|
||||
while (mbed_interface_connected());
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -73,16 +80,19 @@ int mbed_interface_powerdown(void) {
|
|||
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.9", "This function shouldn't be used in new code."
|
||||
"For system reset funcionality use system_reset()")
|
||||
void mbed_reset(void) {
|
||||
void mbed_reset(void)
|
||||
{
|
||||
mbed_interface_reset();
|
||||
}
|
||||
|
||||
WEAK int mbed_uid(char *uid) {
|
||||
WEAK int mbed_uid(char *uid)
|
||||
{
|
||||
return mbed_interface_uid(uid);
|
||||
}
|
||||
#endif
|
||||
|
||||
WEAK void mbed_mac_address(char *mac) {
|
||||
WEAK void mbed_mac_address(char *mac)
|
||||
{
|
||||
#if DEVICE_SEMIHOST
|
||||
char uid[DEVICE_ID_LENGTH + 1];
|
||||
int i;
|
||||
|
@ -93,7 +103,7 @@ WEAK void mbed_mac_address(char *mac) {
|
|||
#if defined(DEVICE_MAC_OFFSET)
|
||||
p += DEVICE_MAC_OFFSET;
|
||||
#endif
|
||||
for (i=0; i<6; i++) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
int byte;
|
||||
sscanf(p, "%2x", &byte);
|
||||
mac[i] = byte;
|
||||
|
|
|
@ -135,7 +135,7 @@ void mbed_die(void);
|
|||
* @endcode
|
||||
*
|
||||
*/
|
||||
void mbed_error_printf(const char* format, ...);
|
||||
void mbed_error_printf(const char *format, ...);
|
||||
|
||||
/** Print out an error message. Similar to mbed_error_printf
|
||||
* but uses a va_list.
|
||||
|
@ -146,7 +146,7 @@ void mbed_error_printf(const char* format, ...);
|
|||
* @param arg Variable arguments list
|
||||
*
|
||||
*/
|
||||
void mbed_error_vfprintf(const char * format, va_list arg);
|
||||
void mbed_error_vfprintf(const char *format, va_list arg);
|
||||
/** @}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -41,7 +41,8 @@ static SingletonPtr<PlatformMutex> mem_trace_mutex;
|
|||
* Public interface
|
||||
*****************************************************************************/
|
||||
|
||||
void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb) {
|
||||
void mbed_mem_trace_set_callback(mbed_mem_trace_cb_t cb)
|
||||
{
|
||||
mem_trace_cb = cb;
|
||||
}
|
||||
|
||||
|
@ -57,7 +58,8 @@ void mbed_mem_trace_unlock()
|
|||
mem_trace_mutex->unlock();
|
||||
}
|
||||
|
||||
void *mbed_mem_trace_malloc(void *res, size_t size, void *caller) {
|
||||
void *mbed_mem_trace_malloc(void *res, size_t size, void *caller)
|
||||
{
|
||||
if (mem_trace_cb) {
|
||||
if (TRACE_FIRST_LOCK()) {
|
||||
mem_trace_cb(MBED_MEM_TRACE_MALLOC, res, caller, size);
|
||||
|
@ -66,7 +68,8 @@ void *mbed_mem_trace_malloc(void *res, size_t size, void *caller) {
|
|||
return res;
|
||||
}
|
||||
|
||||
void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller) {
|
||||
void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller)
|
||||
{
|
||||
if (mem_trace_cb) {
|
||||
if (TRACE_FIRST_LOCK()) {
|
||||
mem_trace_cb(MBED_MEM_TRACE_REALLOC, res, caller, ptr, size);
|
||||
|
@ -75,7 +78,8 @@ void *mbed_mem_trace_realloc(void *res, void *ptr, size_t size, void *caller) {
|
|||
return res;
|
||||
}
|
||||
|
||||
void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller) {
|
||||
void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller)
|
||||
{
|
||||
if (mem_trace_cb) {
|
||||
if (TRACE_FIRST_LOCK()) {
|
||||
mem_trace_cb(MBED_MEM_TRACE_CALLOC, res, caller, num, size);
|
||||
|
@ -84,7 +88,8 @@ void *mbed_mem_trace_calloc(void *res, size_t num, size_t size, void *caller) {
|
|||
return res;
|
||||
}
|
||||
|
||||
void mbed_mem_trace_free(void *ptr, void *caller) {
|
||||
void mbed_mem_trace_free(void *ptr, void *caller)
|
||||
{
|
||||
if (mem_trace_cb) {
|
||||
if (TRACE_FIRST_LOCK()) {
|
||||
mem_trace_cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr);
|
||||
|
@ -92,20 +97,21 @@ void mbed_mem_trace_free(void *ptr, void *caller) {
|
|||
}
|
||||
}
|
||||
|
||||
void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...) {
|
||||
void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...)
|
||||
{
|
||||
va_list va;
|
||||
size_t temp_s1, temp_s2;
|
||||
void *temp_ptr;
|
||||
|
||||
va_start(va, caller);
|
||||
switch(op) {
|
||||
switch (op) {
|
||||
case MBED_MEM_TRACE_MALLOC:
|
||||
temp_s1 = va_arg(va, size_t);
|
||||
printf(MBED_MEM_DEFAULT_TRACER_PREFIX "m:%p;%p-%u\n", res, caller, temp_s1);
|
||||
break;
|
||||
|
||||
case MBED_MEM_TRACE_REALLOC:
|
||||
temp_ptr = va_arg(va, void*);
|
||||
temp_ptr = va_arg(va, void *);
|
||||
temp_s1 = va_arg(va, size_t);
|
||||
printf(MBED_MEM_DEFAULT_TRACER_PREFIX "r:%p;%p-%p;%u\n", res, caller, temp_ptr, temp_s1);
|
||||
break;
|
||||
|
@ -117,7 +123,7 @@ void mbed_mem_trace_default_callback(uint8_t op, void *res, void *caller, ...) {
|
|||
break;
|
||||
|
||||
case MBED_MEM_TRACE_FREE:
|
||||
temp_ptr = va_arg(va, void*);
|
||||
temp_ptr = va_arg(va, void *);
|
||||
printf(MBED_MEM_DEFAULT_TRACER_PREFIX "f:%p;%p-%p\n", res, caller, temp_ptr);
|
||||
break;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ enum {
|
|||
* - for calloc: cb(MBED_MEM_TRACE_CALLOC, res, caller, nmemb, size).
|
||||
* - for free: cb(MBED_MEM_TRACE_FREE, NULL, caller, ptr).
|
||||
*/
|
||||
typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void* caller, ...);
|
||||
typedef void (*mbed_mem_trace_cb_t)(uint8_t op, void *res, void *caller, ...);
|
||||
|
||||
/**
|
||||
* Set the callback used by the memory tracer (use NULL for disable tracing).
|
||||
|
|
|
@ -39,34 +39,35 @@ static const uint32_t seconds_before_month[2][12] = {
|
|||
{
|
||||
0,
|
||||
31 * SECONDS_BY_DAY,
|
||||
(31 + 28) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 28) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30) *SECONDS_BY_DAY,
|
||||
},
|
||||
{
|
||||
0,
|
||||
31 * SECONDS_BY_DAY,
|
||||
(31 + 29) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31) * SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30) * SECONDS_BY_DAY,
|
||||
(31 + 29) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31) *SECONDS_BY_DAY,
|
||||
(31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30) *SECONDS_BY_DAY,
|
||||
}
|
||||
};
|
||||
|
||||
bool _rtc_is_leap_year(int year, rtc_leap_year_support_t leap_year_support) {
|
||||
bool _rtc_is_leap_year(int year, rtc_leap_year_support_t leap_year_support)
|
||||
{
|
||||
/*
|
||||
* since in practice, the value manipulated by this algorithm lie in the
|
||||
* range: [70 : 206] the algorithm can be reduced to: year % 4 with exception for 200 (year 2100 is not leap year).
|
||||
|
@ -90,7 +91,8 @@ bool _rtc_is_leap_year(int year, rtc_leap_year_support_t leap_year_support) {
|
|||
return (year) % 4 ? false : true;
|
||||
}
|
||||
|
||||
bool _rtc_maketime(const struct tm* time, time_t * seconds, rtc_leap_year_support_t leap_year_support) {
|
||||
bool _rtc_maketime(const struct tm *time, time_t *seconds, rtc_leap_year_support_t leap_year_support)
|
||||
{
|
||||
if (seconds == NULL || time == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -133,7 +135,8 @@ bool _rtc_maketime(const struct tm* time, time_t * seconds, rtc_leap_year_suppor
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _rtc_localtime(time_t timestamp, struct tm* time_info, rtc_leap_year_support_t leap_year_support) {
|
||||
bool _rtc_localtime(time_t timestamp, struct tm *time_info, rtc_leap_year_support_t leap_year_support)
|
||||
{
|
||||
if (time_info == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ bool _rtc_is_leap_year(int year, rtc_leap_year_support_t leap_year_support);
|
|||
* @note Full and partial leap years support.
|
||||
* @note For use by the HAL only
|
||||
*/
|
||||
bool _rtc_maketime(const struct tm* time, time_t * seconds, rtc_leap_year_support_t leap_year_support);
|
||||
bool _rtc_maketime(const struct tm *time, time_t *seconds, rtc_leap_year_support_t leap_year_support);
|
||||
|
||||
/* Convert a given time in seconds since epoch into calendar time.
|
||||
*
|
||||
|
@ -118,7 +118,7 @@ bool _rtc_maketime(const struct tm* time, time_t * seconds, rtc_leap_year_suppor
|
|||
* @note For use by the HAL only.
|
||||
* @note Full and partial leap years support.
|
||||
*/
|
||||
bool _rtc_localtime(time_t timestamp, struct tm* time_info, rtc_leap_year_support_t leap_year_support);
|
||||
bool _rtc_localtime(time_t timestamp, struct tm *time_info, rtc_leap_year_support_t leap_year_support);
|
||||
|
||||
/** @}*/
|
||||
|
||||
|
|
|
@ -111,10 +111,11 @@ static SingletonPtr<PlatformMutex> filehandle_mutex;
|
|||
namespace mbed {
|
||||
void mbed_set_unbuffered_stream(std::FILE *_file);
|
||||
|
||||
void remove_filehandle(FileHandle *file) {
|
||||
void remove_filehandle(FileHandle *file)
|
||||
{
|
||||
filehandle_mutex->lock();
|
||||
/* Remove all open filehandles for this */
|
||||
for (unsigned int fh_i = 0; fh_i < sizeof(filehandles)/sizeof(*filehandles); fh_i++) {
|
||||
for (unsigned int fh_i = 0; fh_i < sizeof(filehandles) / sizeof(*filehandles); fh_i++) {
|
||||
if (filehandles[fh_i] == file) {
|
||||
filehandles[fh_i] = NULL;
|
||||
}
|
||||
|
@ -137,23 +138,30 @@ public:
|
|||
DirectSerial(PinName tx, PinName rx, int baud);
|
||||
virtual ssize_t write(const void *buffer, size_t size);
|
||||
virtual ssize_t read(void *buffer, size_t size);
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET) {
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET)
|
||||
{
|
||||
return -ESPIPE;
|
||||
}
|
||||
virtual off_t size() {
|
||||
virtual off_t size()
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
virtual int isatty() {
|
||||
virtual int isatty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual int close() {
|
||||
virtual int close()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual short poll(short events) const;
|
||||
};
|
||||
|
||||
DirectSerial::DirectSerial(PinName tx, PinName rx, int baud) {
|
||||
if (stdio_uart_inited) return;
|
||||
DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
|
||||
{
|
||||
if (stdio_uart_inited) {
|
||||
return;
|
||||
}
|
||||
serial_init(&stdio_uart, tx, rx);
|
||||
serial_baud(&stdio_uart, baud);
|
||||
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
|
||||
|
@ -165,7 +173,8 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud) {
|
|||
#endif
|
||||
}
|
||||
|
||||
ssize_t DirectSerial::write(const void *buffer, size_t size) {
|
||||
ssize_t DirectSerial::write(const void *buffer, size_t size)
|
||||
{
|
||||
const unsigned char *buf = static_cast<const unsigned char *>(buffer);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
serial_putc(&stdio_uart, buf[i]);
|
||||
|
@ -173,7 +182,8 @@ ssize_t DirectSerial::write(const void *buffer, size_t size) {
|
|||
return size;
|
||||
}
|
||||
|
||||
ssize_t DirectSerial::read(void *buffer, size_t size) {
|
||||
ssize_t DirectSerial::read(void *buffer, size_t size)
|
||||
{
|
||||
unsigned char *buf = static_cast<unsigned char *>(buffer);
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
|
@ -182,7 +192,8 @@ ssize_t DirectSerial::read(void *buffer, size_t size) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
short DirectSerial::poll(short events) const {
|
||||
short DirectSerial::poll(short events) const
|
||||
{
|
||||
short revents = 0;
|
||||
if ((events & POLLIN) && serial_readable(&stdio_uart)) {
|
||||
revents |= POLLIN;
|
||||
|
@ -198,18 +209,32 @@ class Sink : public FileHandle {
|
|||
public:
|
||||
virtual ssize_t write(const void *buffer, size_t size);
|
||||
virtual ssize_t read(void *buffer, size_t size);
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET) { return ESPIPE; }
|
||||
virtual off_t size() { return -EINVAL; }
|
||||
virtual int isatty() { return true; }
|
||||
virtual int close() { return 0; }
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET)
|
||||
{
|
||||
return ESPIPE;
|
||||
}
|
||||
virtual off_t size()
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
virtual int isatty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual int close()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
ssize_t Sink::write(const void *buffer, size_t size) {
|
||||
ssize_t Sink::write(const void *buffer, size_t size)
|
||||
{
|
||||
// Just swallow the data - this is historical non-DEVICE_SERIAL behaviour
|
||||
return size;
|
||||
}
|
||||
|
||||
ssize_t Sink::read(void *buffer, size_t size) {
|
||||
ssize_t Sink::read(void *buffer, size_t size)
|
||||
{
|
||||
// Produce 1 zero byte - historical behaviour returned 1 without touching
|
||||
// the buffer
|
||||
unsigned char *buf = static_cast<unsigned char *>(buffer);
|
||||
|
@ -218,17 +243,17 @@ ssize_t Sink::read(void *buffer, size_t size) {
|
|||
}
|
||||
|
||||
|
||||
MBED_WEAK FileHandle* mbed::mbed_target_override_console(int fd)
|
||||
MBED_WEAK FileHandle *mbed::mbed_target_override_console(int fd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MBED_WEAK FileHandle* mbed::mbed_override_console(int fd)
|
||||
MBED_WEAK FileHandle *mbed::mbed_override_console(int fd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static FileHandle* default_console()
|
||||
static FileHandle *default_console()
|
||||
{
|
||||
#if DEVICE_SERIAL
|
||||
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL
|
||||
|
@ -250,7 +275,8 @@ static FileHandle* default_console()
|
|||
}
|
||||
|
||||
/* Locate the default console for stdout, stdin, stderr */
|
||||
static FileHandle* get_console(int fd) {
|
||||
static FileHandle *get_console(int fd)
|
||||
{
|
||||
FileHandle *fh = mbed_override_console(fd);
|
||||
if (fh) {
|
||||
return fh;
|
||||
|
@ -263,7 +289,8 @@ static FileHandle* get_console(int fd) {
|
|||
}
|
||||
|
||||
/* Deal with the fact C library may not _open descriptors 0, 1, 2 - auto bind */
|
||||
static FileHandle* get_fhc(int fd) {
|
||||
static FileHandle *get_fhc(int fd)
|
||||
{
|
||||
if (fd >= OPEN_MAX) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -281,27 +308,29 @@ static FileHandle* get_fhc(int fd) {
|
|||
* @param error is a negative error code returned from an mbed function and
|
||||
* will be negated to store a positive error code in errno
|
||||
*/
|
||||
static int handle_open_errors(int error, unsigned filehandle_idx) {
|
||||
static int handle_open_errors(int error, unsigned filehandle_idx)
|
||||
{
|
||||
errno = -error;
|
||||
// Free file handle
|
||||
filehandles[filehandle_idx] = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int openflags_to_posix(int openflags) {
|
||||
static inline int openflags_to_posix(int openflags)
|
||||
{
|
||||
int posix = openflags;
|
||||
#ifdef __ARMCC_VERSION
|
||||
if (openflags & OPEN_PLUS) {
|
||||
posix = O_RDWR;
|
||||
} else if(openflags & OPEN_W) {
|
||||
} else if (openflags & OPEN_W) {
|
||||
posix = O_WRONLY;
|
||||
} else if(openflags & OPEN_A) {
|
||||
posix = O_WRONLY|O_APPEND;
|
||||
} else if (openflags & OPEN_A) {
|
||||
posix = O_WRONLY | O_APPEND;
|
||||
} else {
|
||||
posix = O_RDONLY;
|
||||
}
|
||||
/* a, w, a+, w+ all create if file does not already exist */
|
||||
if (openflags & (OPEN_A|OPEN_W)) {
|
||||
if (openflags & (OPEN_A | OPEN_W)) {
|
||||
posix |= O_CREAT;
|
||||
}
|
||||
/* w and w+ truncate */
|
||||
|
@ -310,26 +339,41 @@ static inline int openflags_to_posix(int openflags) {
|
|||
}
|
||||
#elif defined(__ICCARM__)
|
||||
switch (openflags & _LLIO_RDWRMASK) {
|
||||
case _LLIO_RDONLY: posix = O_RDONLY; break;
|
||||
case _LLIO_WRONLY: posix = O_WRONLY; break;
|
||||
case _LLIO_RDWR : posix = O_RDWR ; break;
|
||||
case _LLIO_RDONLY:
|
||||
posix = O_RDONLY;
|
||||
break;
|
||||
case _LLIO_WRONLY:
|
||||
posix = O_WRONLY;
|
||||
break;
|
||||
case _LLIO_RDWR :
|
||||
posix = O_RDWR ;
|
||||
break;
|
||||
}
|
||||
if (openflags & _LLIO_CREAT) {
|
||||
posix |= O_CREAT;
|
||||
}
|
||||
if (openflags & _LLIO_APPEND) {
|
||||
posix |= O_APPEND;
|
||||
}
|
||||
if (openflags & _LLIO_TRUNC) {
|
||||
posix |= O_TRUNC;
|
||||
}
|
||||
if (openflags & _LLIO_CREAT ) posix |= O_CREAT;
|
||||
if (openflags & _LLIO_APPEND) posix |= O_APPEND;
|
||||
if (openflags & _LLIO_TRUNC ) posix |= O_TRUNC;
|
||||
#elif defined(TOOLCHAIN_GCC)
|
||||
posix &= ~O_BINARY;
|
||||
#endif
|
||||
return posix;
|
||||
}
|
||||
|
||||
static int reserve_filehandle() {
|
||||
static int reserve_filehandle()
|
||||
{
|
||||
// find the first empty slot in filehandles, after the slots reserved for stdin/stdout/stderr
|
||||
filehandle_mutex->lock();
|
||||
int fh_i;
|
||||
for (fh_i = 3; fh_i < OPEN_MAX; fh_i++) {
|
||||
/* Take a next free filehandle slot available. */
|
||||
if (filehandles[fh_i] == NULL) break;
|
||||
if (filehandles[fh_i] == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fh_i >= OPEN_MAX) {
|
||||
/* Too many file handles have been opened */
|
||||
|
@ -343,7 +387,8 @@ static int reserve_filehandle() {
|
|||
return fh_i;
|
||||
}
|
||||
|
||||
int mbed::bind_to_fd(FileHandle *fh) {
|
||||
int mbed::bind_to_fd(FileHandle *fh)
|
||||
{
|
||||
int fildes = reserve_filehandle();
|
||||
if (fildes < 0) {
|
||||
return fildes;
|
||||
|
@ -356,7 +401,8 @@ int mbed::bind_to_fd(FileHandle *fh) {
|
|||
return fildes;
|
||||
}
|
||||
|
||||
static int unbind_from_fd(int fd, FileHandle *fh) {
|
||||
static int unbind_from_fd(int fd, FileHandle *fh)
|
||||
{
|
||||
if (filehandles[fd] == fh) {
|
||||
filehandles[fd] = NULL;
|
||||
return 0;
|
||||
|
@ -368,7 +414,7 @@ static int unbind_from_fd(int fd, FileHandle *fh) {
|
|||
|
||||
#ifndef __IAR_SYSTEMS_ICC__
|
||||
/* IAR provides fdopen itself */
|
||||
extern "C" std::FILE* fdopen(int fildes, const char *mode)
|
||||
extern "C" std::FILE *fdopen(int fildes, const char *mode)
|
||||
{
|
||||
// This is to avoid scanf and the bloat it brings.
|
||||
char buf[1 + sizeof fildes]; /* @(integer) */
|
||||
|
@ -416,7 +462,8 @@ std::FILE *fdopen(FileHandle *fh, const char *mode)
|
|||
* EMFILE the maximum number of open files was exceeded.
|
||||
*
|
||||
* */
|
||||
extern "C" FILEHANDLE PREFIX(_open)(const char *name, int openflags) {
|
||||
extern "C" FILEHANDLE PREFIX(_open)(const char *name, int openflags)
|
||||
{
|
||||
#if defined(__MICROLIB) && (__ARMCC_VERSION>5030000)
|
||||
#if !defined(MBED_CONF_RTOS_PRESENT)
|
||||
// valid only for mbed 2
|
||||
|
@ -463,7 +510,8 @@ extern "C" FILEHANDLE PREFIX(_open)(const char *name, int openflags) {
|
|||
return open(name, openflags_to_posix(openflags));
|
||||
}
|
||||
|
||||
extern "C" int open(const char *name, int oflag, ...) {
|
||||
extern "C" int open(const char *name, int oflag, ...)
|
||||
{
|
||||
int fildes = reserve_filehandle();
|
||||
if (fildes < 0) {
|
||||
return fildes;
|
||||
|
@ -499,12 +547,14 @@ extern "C" int open(const char *name, int oflag, ...) {
|
|||
return fildes;
|
||||
}
|
||||
|
||||
extern "C" int PREFIX(_close)(FILEHANDLE fh) {
|
||||
extern "C" int PREFIX(_close)(FILEHANDLE fh)
|
||||
{
|
||||
return close(fh);
|
||||
}
|
||||
|
||||
extern "C" int close(int fildes) {
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
extern "C" int close(int fildes)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
filehandles[fildes] = NULL;
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
|
@ -520,7 +570,8 @@ extern "C" int close(int fildes) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool convert_crlf(int fd) {
|
||||
static bool convert_crlf(int fd)
|
||||
{
|
||||
#if MBED_CONF_PLATFORM_STDIO_CONVERT_TTY_NEWLINES
|
||||
return isatty(fd);
|
||||
#elif MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
|
||||
|
@ -531,9 +582,11 @@ static bool convert_crlf(int fd) {
|
|||
}
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
extern "C" size_t __write (int fh, const unsigned char *buffer, size_t length) {
|
||||
extern "C" size_t __write(int fh, const unsigned char *buffer, size_t length)
|
||||
{
|
||||
#else
|
||||
extern "C" int PREFIX(_write)(FILEHANDLE fh, const unsigned char *buffer, unsigned int length, int mode) {
|
||||
extern "C" int PREFIX(_write)(FILEHANDLE fh, const unsigned char *buffer, unsigned int length, int mode)
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED && defined(MBED_CONF_RTOS_PRESENT)
|
||||
|
@ -610,9 +663,10 @@ finish:
|
|||
#endif
|
||||
}
|
||||
|
||||
extern "C" ssize_t write(int fildes, const void *buf, size_t length) {
|
||||
extern "C" ssize_t write(int fildes, const void *buf, size_t length)
|
||||
{
|
||||
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -628,20 +682,24 @@ extern "C" ssize_t write(int fildes, const void *buf, size_t length) {
|
|||
}
|
||||
|
||||
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
extern "C" void PREFIX(_exit)(int return_code) {
|
||||
while(1) {}
|
||||
extern "C" void PREFIX(_exit)(int return_code)
|
||||
{
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
extern "C" void _ttywrch(int ch) {
|
||||
extern "C" void _ttywrch(int ch)
|
||||
{
|
||||
char c = ch;
|
||||
write(STDOUT_FILENO, &c, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
extern "C" size_t __read (int fh, unsigned char *buffer, size_t length) {
|
||||
extern "C" size_t __read(int fh, unsigned char *buffer, size_t length)
|
||||
{
|
||||
#else
|
||||
extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, unsigned int length, int mode) {
|
||||
extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, unsigned int length, int mode)
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED && defined(MBED_CONF_RTOS_PRESENT)
|
||||
|
@ -700,9 +758,10 @@ extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, unsigned int
|
|||
#endif
|
||||
}
|
||||
|
||||
extern "C" ssize_t read(int fildes, void *buf, size_t length) {
|
||||
extern "C" ssize_t read(int fildes, void *buf, size_t length)
|
||||
{
|
||||
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -727,8 +786,9 @@ extern "C" int _isatty(FILEHANDLE fh)
|
|||
return isatty(fh);
|
||||
}
|
||||
|
||||
extern "C" int isatty(int fildes) {
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
extern "C" int isatty(int fildes)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return 0;
|
||||
|
@ -765,8 +825,9 @@ int _lseek(FILEHANDLE fh, int offset, int whence)
|
|||
return off;
|
||||
}
|
||||
|
||||
extern "C" off_t lseek(int fildes, off_t offset, int whence) {
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
extern "C" off_t lseek(int fildes, off_t offset, int whence)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -781,13 +842,15 @@ extern "C" off_t lseek(int fildes, off_t offset, int whence) {
|
|||
}
|
||||
|
||||
#ifdef __ARMCC_VERSION
|
||||
extern "C" int PREFIX(_ensure)(FILEHANDLE fh) {
|
||||
extern "C" int PREFIX(_ensure)(FILEHANDLE fh)
|
||||
{
|
||||
return fsync(fh);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" int fsync(int fildes) {
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
extern "C" int fsync(int fildes)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -803,8 +866,9 @@ extern "C" int fsync(int fildes) {
|
|||
}
|
||||
|
||||
#ifdef __ARMCC_VERSION
|
||||
extern "C" long PREFIX(_flen)(FILEHANDLE fh) {
|
||||
FileHandle* fhc = get_fhc(fh);
|
||||
extern "C" long PREFIX(_flen)(FILEHANDLE fh)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fh);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -837,7 +901,8 @@ extern "C" MBED_WEAK __value_in_regs struct __initial_stackheap _mbed_user_setup
|
|||
return r;
|
||||
}
|
||||
|
||||
extern "C" __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
|
||||
extern "C" __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3)
|
||||
{
|
||||
return _mbed_user_setup_stackheap(R0, R1, R2, R3);
|
||||
}
|
||||
|
||||
|
@ -845,13 +910,15 @@ extern "C" __value_in_regs struct __initial_stackheap __user_setup_stackheap(uin
|
|||
|
||||
|
||||
#if !defined(__ARMCC_VERSION) && !defined(__ICCARM__)
|
||||
extern "C" int _fstat(int fh, struct stat *st) {
|
||||
extern "C" int _fstat(int fh, struct stat *st)
|
||||
{
|
||||
return fstat(fh, st);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" int fstat(int fildes, struct stat *st) {
|
||||
FileHandle* fhc = get_fhc(fildes);
|
||||
extern "C" int fstat(int fildes, struct stat *st)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
@ -862,7 +929,8 @@ extern "C" int fstat(int fildes, struct stat *st) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int fcntl(int fildes, int cmd, ...) {
|
||||
extern "C" int fcntl(int fildes, int cmd, ...)
|
||||
{
|
||||
FileHandle *fhc = get_fhc(fildes);
|
||||
if (fhc == NULL) {
|
||||
errno = EBADF;
|
||||
|
@ -919,7 +987,8 @@ extern "C" int poll(struct pollfd fds[], nfds_t nfds, int timeout)
|
|||
}
|
||||
|
||||
namespace std {
|
||||
extern "C" int remove(const char *path) {
|
||||
extern "C" int remove(const char *path)
|
||||
{
|
||||
FilePath fp(path);
|
||||
FileSystemHandle *fs = fp.fileSystem();
|
||||
if (fs == NULL) {
|
||||
|
@ -936,7 +1005,8 @@ extern "C" int remove(const char *path) {
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" int rename(const char *oldname, const char *newname) {
|
||||
extern "C" int rename(const char *oldname, const char *newname)
|
||||
{
|
||||
FilePath fpOld(oldname);
|
||||
FilePath fpNew(newname);
|
||||
FileSystemHandle *fsOld = fpOld.fileSystem();
|
||||
|
@ -962,26 +1032,30 @@ extern "C" int rename(const char *oldname, const char *newname) {
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" char *tmpnam(char *s) {
|
||||
extern "C" char *tmpnam(char *s)
|
||||
{
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern "C" FILE *tmpfile() {
|
||||
extern "C" FILE *tmpfile()
|
||||
{
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#ifdef __ARMCC_VERSION
|
||||
extern "C" char *_sys_command_string(char *cmd, int len) {
|
||||
extern "C" char *_sys_command_string(char *cmd, int len)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" DIR *opendir(const char *path) {
|
||||
extern "C" DIR *opendir(const char *path)
|
||||
{
|
||||
FilePath fp(path);
|
||||
FileSystemHandle* fs = fp.fileSystem();
|
||||
FileSystemHandle *fs = fp.fileSystem();
|
||||
if (fs == NULL) {
|
||||
errno = ENODEV;
|
||||
return NULL;
|
||||
|
@ -997,7 +1071,8 @@ extern "C" DIR *opendir(const char *path) {
|
|||
return dir;
|
||||
}
|
||||
|
||||
extern "C" struct dirent *readdir(DIR *dir) {
|
||||
extern "C" struct dirent *readdir(DIR *dir)
|
||||
{
|
||||
static struct dirent ent;
|
||||
int err = dir->read(&ent);
|
||||
if (err < 1) {
|
||||
|
@ -1010,7 +1085,8 @@ extern "C" struct dirent *readdir(DIR *dir) {
|
|||
return &ent;
|
||||
}
|
||||
|
||||
extern "C" int closedir(DIR *dir) {
|
||||
extern "C" int closedir(DIR *dir)
|
||||
{
|
||||
int err = dir->close();
|
||||
if (err < 0) {
|
||||
errno = -err;
|
||||
|
@ -1020,19 +1096,23 @@ extern "C" int closedir(DIR *dir) {
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" void rewinddir(DIR *dir) {
|
||||
extern "C" void rewinddir(DIR *dir)
|
||||
{
|
||||
dir->rewind();
|
||||
}
|
||||
|
||||
extern "C" off_t telldir(DIR *dir) {
|
||||
extern "C" off_t telldir(DIR *dir)
|
||||
{
|
||||
return dir->tell();
|
||||
}
|
||||
|
||||
extern "C" void seekdir(DIR *dir, off_t off) {
|
||||
extern "C" void seekdir(DIR *dir, off_t off)
|
||||
{
|
||||
dir->seek(off);
|
||||
}
|
||||
|
||||
extern "C" int mkdir(const char *path, mode_t mode) {
|
||||
extern "C" int mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
FilePath fp(path);
|
||||
FileSystemHandle *fs = fp.fileSystem();
|
||||
if (fs == NULL) {
|
||||
|
@ -1049,7 +1129,8 @@ extern "C" int mkdir(const char *path, mode_t mode) {
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" int stat(const char *path, struct stat *st) {
|
||||
extern "C" int stat(const char *path, struct stat *st)
|
||||
{
|
||||
FilePath fp(path);
|
||||
FileSystemHandle *fs = fp.fileSystem();
|
||||
if (fs == NULL) {
|
||||
|
@ -1066,7 +1147,8 @@ extern "C" int stat(const char *path, struct stat *st) {
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" int statvfs(const char *path, struct statvfs *buf) {
|
||||
extern "C" int statvfs(const char *path, struct statvfs *buf)
|
||||
{
|
||||
FilePath fp(path);
|
||||
FileSystemHandle *fs = fp.fileSystem();
|
||||
if (fs == NULL) {
|
||||
|
@ -1087,12 +1169,14 @@ extern "C" int statvfs(const char *path, struct statvfs *buf) {
|
|||
/* prevents the exception handling name demangling code getting pulled in */
|
||||
#include "mbed_error.h"
|
||||
namespace __gnu_cxx {
|
||||
void __verbose_terminate_handler() {
|
||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_CLIB_EXCEPTION),"Exception", 0);
|
||||
}
|
||||
void __verbose_terminate_handler()
|
||||
{
|
||||
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_CLIB_EXCEPTION), "Exception", 0);
|
||||
}
|
||||
}
|
||||
extern "C" WEAK void __cxa_pure_virtual(void);
|
||||
extern "C" WEAK void __cxa_pure_virtual(void) {
|
||||
extern "C" WEAK void __cxa_pure_virtual(void)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1120,31 +1204,33 @@ extern "C" int errno;
|
|||
// TARGET_NUMAKER_PFM_M453 targets/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/TOOLCHAIN_GCC_ARM/m451_retarget.c
|
||||
// TARGET_STM32L4 targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4/l4_retarget.c
|
||||
extern "C" void *__wrap__sbrk(int incr);
|
||||
extern "C" caddr_t _sbrk(int incr) {
|
||||
extern "C" caddr_t _sbrk(int incr)
|
||||
{
|
||||
return (caddr_t) __wrap__sbrk(incr);
|
||||
}
|
||||
#else
|
||||
// Linker defined symbol used by _sbrk to indicate where heap should start.
|
||||
extern "C" uint32_t __end__;
|
||||
// Weak attribute allows user to override, e.g. to use external RAM for dynamic memory.
|
||||
extern "C" WEAK caddr_t _sbrk(int incr) {
|
||||
static unsigned char* heap = (unsigned char*)&__end__;
|
||||
unsigned char* prev_heap = heap;
|
||||
unsigned char* new_heap = heap + incr;
|
||||
extern "C" WEAK caddr_t _sbrk(int incr)
|
||||
{
|
||||
static unsigned char *heap = (unsigned char *)&__end__;
|
||||
unsigned char *prev_heap = heap;
|
||||
unsigned char *new_heap = heap + incr;
|
||||
|
||||
#if defined(TARGET_CORTEX_A)
|
||||
if (new_heap >= (unsigned char*)&__HeapLimit) { /* __HeapLimit is end of heap section */
|
||||
if (new_heap >= (unsigned char *)&__HeapLimit) { /* __HeapLimit is end of heap section */
|
||||
#else
|
||||
if (new_heap >= (unsigned char*)__get_MSP()) {
|
||||
if (new_heap >= (unsigned char *)__get_MSP()) {
|
||||
#endif
|
||||
errno = ENOMEM;
|
||||
return (caddr_t)-1;
|
||||
return (caddr_t) -1;
|
||||
}
|
||||
|
||||
// Additional heap checking if set
|
||||
if (mbed_heap_size && (new_heap >= mbed_heap_start + mbed_heap_size)) {
|
||||
errno = ENOMEM;
|
||||
return (caddr_t)-1;
|
||||
return (caddr_t) -1;
|
||||
}
|
||||
|
||||
heap = new_heap;
|
||||
|
@ -1154,10 +1240,12 @@ extern "C" WEAK caddr_t _sbrk(int incr) {
|
|||
#endif
|
||||
|
||||
#if defined(TOOLCHAIN_GCC_ARM) || defined(TOOLCHAIN_GCC_CR)
|
||||
extern "C" void _exit(int return_code) {
|
||||
extern "C" void _exit(int return_code)
|
||||
{
|
||||
#else
|
||||
namespace std {
|
||||
extern "C" void exit(int return_code) {
|
||||
extern "C" void exit(int return_code)
|
||||
{
|
||||
#endif
|
||||
|
||||
#if DEVICE_STDIO_MESSAGES
|
||||
|
@ -1191,16 +1279,19 @@ extern "C" void exit(int return_code) {
|
|||
// More informations about this topic for ARMCC here:
|
||||
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/6449.html
|
||||
extern "C" {
|
||||
int __aeabi_atexit(void *object, void (*dtor)(void* /*this*/), void *handle) {
|
||||
int __aeabi_atexit(void *object, void (*dtor)(void * /*this*/), void *handle)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int __cxa_atexit(void (*dtor)(void* /*this*/), void *object, void *handle) {
|
||||
int __cxa_atexit(void (*dtor)(void * /*this*/), void *object, void *handle)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void __cxa_finalize(void *handle) {
|
||||
}
|
||||
void __cxa_finalize(void *handle)
|
||||
{
|
||||
}
|
||||
|
||||
} // end of extern "C"
|
||||
|
||||
|
@ -1216,25 +1307,27 @@ void __cxa_finalize(void *handle) {
|
|||
*
|
||||
* To overcome this limitation, exit and atexit are overriden here.
|
||||
*/
|
||||
extern "C"{
|
||||
extern "C" {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Retarget of exit for GCC.
|
||||
* @details Unlike the standard version, this function doesn't call any function
|
||||
* registered with atexit before calling _exit.
|
||||
*/
|
||||
void __wrap_exit(int return_code) {
|
||||
void __wrap_exit(int return_code)
|
||||
{
|
||||
_exit(return_code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Retarget atexit from GCC.
|
||||
* @details This function will always fail and never register any handler to be
|
||||
* called at exit.
|
||||
*/
|
||||
int __wrap_atexit(void (*func)()) {
|
||||
int __wrap_atexit(void (*func)())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1244,20 +1337,22 @@ int __wrap_atexit(void (*func)()) {
|
|||
|
||||
namespace mbed {
|
||||
|
||||
void mbed_set_unbuffered_stream(std::FILE *_file) {
|
||||
void mbed_set_unbuffered_stream(std::FILE *_file)
|
||||
{
|
||||
#if defined (__ICCARM__)
|
||||
char buf[2];
|
||||
std::setvbuf(_file,buf,_IONBF,NULL);
|
||||
std::setvbuf(_file, buf, _IONBF, NULL);
|
||||
#else
|
||||
setbuf(_file, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
int mbed_getc(std::FILE *_file){
|
||||
int mbed_getc(std::FILE *_file)
|
||||
{
|
||||
#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ < 8000000)
|
||||
/*This is only valid for unbuffered streams*/
|
||||
int res = std::fgetc(_file);
|
||||
if (res>=0){
|
||||
if (res >= 0) {
|
||||
_file->_Mode = (unsigned short)(_file->_Mode & ~ 0x1000);/* Unset read mode */
|
||||
_file->_Rend = _file->_Wend;
|
||||
_file->_Next = _file->_Wend;
|
||||
|
@ -1268,18 +1363,19 @@ int mbed_getc(std::FILE *_file){
|
|||
#endif
|
||||
}
|
||||
|
||||
char* mbed_gets(char*s, int size, std::FILE *_file){
|
||||
char *mbed_gets(char *s, int size, std::FILE *_file)
|
||||
{
|
||||
#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ < 8000000)
|
||||
/*This is only valid for unbuffered streams*/
|
||||
char *str = fgets(s,size,_file);
|
||||
if (str!=NULL){
|
||||
char *str = fgets(s, size, _file);
|
||||
if (str != NULL) {
|
||||
_file->_Mode = (unsigned short)(_file->_Mode & ~ 0x1000);/* Unset read mode */
|
||||
_file->_Rend = _file->_Wend;
|
||||
_file->_Next = _file->_Wend;
|
||||
}
|
||||
return str;
|
||||
#else
|
||||
return std::fgets(s,size,_file);
|
||||
return std::fgets(s, size, _file);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1393,8 @@ extern "C" WEAK void __iar_file_Mtxlock(__iar_Rmtx *mutex) {}
|
|||
extern "C" WEAK void __iar_file_Mtxunlock(__iar_Rmtx *mutex) {}
|
||||
#if defined(__IAR_SYSTEMS_ICC__ ) && (__VER__ >= 8000000)
|
||||
#pragma section="__iar_tls$$DATA"
|
||||
extern "C" WEAK void *__aeabi_read_tp (void) {
|
||||
extern "C" WEAK void *__aeabi_read_tp(void)
|
||||
{
|
||||
// Thread Local storage is not supported, using main thread memory for errno
|
||||
return __section_begin("__iar_tls$$DATA");
|
||||
}
|
||||
|
@ -1307,27 +1404,27 @@ extern "C" WEAK void *__aeabi_read_tp (void) {
|
|||
#elif defined (__GNUC__)
|
||||
struct _reent;
|
||||
// Stub out locks when an rtos is not present
|
||||
extern "C" WEAK void __rtos_malloc_lock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_malloc_unlock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_env_lock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_env_unlock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_malloc_lock(struct _reent *_r) {}
|
||||
extern "C" WEAK void __rtos_malloc_unlock(struct _reent *_r) {}
|
||||
extern "C" WEAK void __rtos_env_lock(struct _reent *_r) {}
|
||||
extern "C" WEAK void __rtos_env_unlock(struct _reent *_r) {}
|
||||
|
||||
extern "C" void __malloc_lock( struct _reent *_r )
|
||||
extern "C" void __malloc_lock(struct _reent *_r)
|
||||
{
|
||||
__rtos_malloc_lock(_r);
|
||||
}
|
||||
|
||||
extern "C" void __malloc_unlock( struct _reent *_r )
|
||||
extern "C" void __malloc_unlock(struct _reent *_r)
|
||||
{
|
||||
__rtos_malloc_unlock(_r);
|
||||
}
|
||||
|
||||
extern "C" void __env_lock( struct _reent *_r )
|
||||
extern "C" void __env_lock(struct _reent *_r)
|
||||
{
|
||||
__rtos_env_lock(_r);
|
||||
}
|
||||
|
||||
extern "C" void __env_unlock( struct _reent *_r )
|
||||
extern "C" void __env_unlock(struct _reent *_r)
|
||||
{
|
||||
__rtos_env_unlock(_r);
|
||||
}
|
||||
|
@ -1380,10 +1477,10 @@ extern "C" void __cxa_guard_abort(int *guard_object_p)
|
|||
// provide the implementation for these. Note: this needs to use the wrappers
|
||||
// instead of malloc()/free() as the caller address would point to wrappers,
|
||||
// not the caller of "new" or "delete".
|
||||
extern "C" void* malloc_wrapper(size_t size, const void* caller);
|
||||
extern "C" void free_wrapper(void *ptr, const void* caller);
|
||||
extern "C" void *malloc_wrapper(size_t size, const void *caller);
|
||||
extern "C" void free_wrapper(void *ptr, const void *caller);
|
||||
|
||||
void *operator new(std::size_t count)
|
||||
void *operator new (std::size_t count)
|
||||
{
|
||||
void *buffer = malloc_wrapper(count, MBED_CALLER_ADDR());
|
||||
if (NULL == buffer) {
|
||||
|
@ -1401,17 +1498,17 @@ void *operator new[](std::size_t count)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
void *operator new(std::size_t count, const std::nothrow_t& tag)
|
||||
void *operator new (std::size_t count, const std::nothrow_t &tag)
|
||||
{
|
||||
return malloc_wrapper(count, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
void *operator new[](std::size_t count, const std::nothrow_t& tag)
|
||||
void *operator new[](std::size_t count, const std::nothrow_t &tag)
|
||||
{
|
||||
return malloc_wrapper(count, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
void operator delete (void *ptr)
|
||||
{
|
||||
free_wrapper(ptr, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
@ -1424,10 +1521,10 @@ void operator delete[](void *ptr)
|
|||
|
||||
#include <reent.h>
|
||||
|
||||
extern "C" void* malloc_wrapper(struct _reent * r, size_t size, void * caller);
|
||||
extern "C" void free_wrapper(struct _reent * r, void * ptr, void * caller);
|
||||
extern "C" void *malloc_wrapper(struct _reent *r, size_t size, void *caller);
|
||||
extern "C" void free_wrapper(struct _reent *r, void *ptr, void *caller);
|
||||
|
||||
void *operator new(std::size_t count)
|
||||
void *operator new (std::size_t count)
|
||||
{
|
||||
void *buffer = malloc_wrapper(_REENT, count, MBED_CALLER_ADDR());
|
||||
if (NULL == buffer) {
|
||||
|
@ -1445,17 +1542,17 @@ void *operator new[](std::size_t count)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
void *operator new(std::size_t count, const std::nothrow_t& tag)
|
||||
void *operator new (std::size_t count, const std::nothrow_t &tag)
|
||||
{
|
||||
return malloc_wrapper(_REENT, count, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
void *operator new[](std::size_t count, const std::nothrow_t& tag)
|
||||
void *operator new[](std::size_t count, const std::nothrow_t &tag)
|
||||
{
|
||||
return malloc_wrapper(_REENT, count, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
void operator delete (void *ptr)
|
||||
{
|
||||
free_wrapper(_REENT, ptr, MBED_CALLER_ADDR());
|
||||
}
|
||||
|
@ -1467,7 +1564,7 @@ void operator delete[](void *ptr)
|
|||
|
||||
#else
|
||||
|
||||
void *operator new(std::size_t count)
|
||||
void *operator new (std::size_t count)
|
||||
{
|
||||
void *buffer = malloc(count);
|
||||
if (NULL == buffer) {
|
||||
|
@ -1485,17 +1582,17 @@ void *operator new[](std::size_t count)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
void *operator new(std::size_t count, const std::nothrow_t& tag)
|
||||
void *operator new (std::size_t count, const std::nothrow_t &tag)
|
||||
{
|
||||
return malloc(count);
|
||||
}
|
||||
|
||||
void *operator new[](std::size_t count, const std::nothrow_t& tag)
|
||||
void *operator new[](std::size_t count, const std::nothrow_t &tag)
|
||||
{
|
||||
return malloc(count);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
void operator delete (void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
@ -1526,7 +1623,7 @@ extern "C" clock_t clock()
|
|||
}
|
||||
|
||||
// temporary - Default to 1MHz at 32 bits if target does not have us_ticker_get_info
|
||||
MBED_WEAK const ticker_info_t* us_ticker_get_info()
|
||||
MBED_WEAK const ticker_info_t *us_ticker_get_info()
|
||||
{
|
||||
static const ticker_info_t info = {
|
||||
1000000,
|
||||
|
@ -1536,7 +1633,7 @@ MBED_WEAK const ticker_info_t* us_ticker_get_info()
|
|||
}
|
||||
|
||||
// temporary - Default to 1MHz at 32 bits if target does not have lp_ticker_get_info
|
||||
MBED_WEAK const ticker_info_t* lp_ticker_get_info()
|
||||
MBED_WEAK const ticker_info_t *lp_ticker_get_info()
|
||||
{
|
||||
static const ticker_info_t info = {
|
||||
1000000,
|
||||
|
|
|
@ -108,7 +108,7 @@ class DirHandle;
|
|||
* @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO
|
||||
* @return pointer to FileHandle to override normal stream otherwise NULL
|
||||
*/
|
||||
FileHandle* mbed_target_override_console(int fd);
|
||||
FileHandle *mbed_target_override_console(int fd);
|
||||
|
||||
/** Applications may implement this to change stdin, stdout, stderr.
|
||||
*
|
||||
|
@ -130,7 +130,7 @@ FileHandle* mbed_target_override_console(int fd);
|
|||
* @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO
|
||||
* @return pointer to FileHandle to override normal stream otherwise NULL
|
||||
*/
|
||||
FileHandle* mbed_override_console(int fd);
|
||||
FileHandle *mbed_override_console(int fd);
|
||||
|
||||
}
|
||||
|
||||
|
@ -483,7 +483,7 @@ struct statvfs {
|
|||
* consistency where structure may be different with different toolchains
|
||||
*/
|
||||
struct dirent {
|
||||
char d_name[NAME_MAX+1]; ///< Name of file
|
||||
char d_name[NAME_MAX + 1]; ///< Name of file
|
||||
uint8_t d_type; ///< Type of file
|
||||
};
|
||||
|
||||
|
@ -515,9 +515,9 @@ extern "C" {
|
|||
int open(const char *path, int oflag, ...);
|
||||
#ifndef __IAR_SYSTEMS_ICC__ /* IAR provides fdopen itself */
|
||||
#if __cplusplus
|
||||
std::FILE* fdopen(int fildes, const char *mode);
|
||||
std::FILE *fdopen(int fildes, const char *mode);
|
||||
#else
|
||||
FILE* fdopen(int fildes, const char *mode);
|
||||
FILE *fdopen(int fildes, const char *mode);
|
||||
#endif
|
||||
#endif
|
||||
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||
|
@ -531,12 +531,12 @@ extern "C" {
|
|||
int close(int fildes);
|
||||
int stat(const char *path, struct stat *st);
|
||||
int statvfs(const char *path, struct statvfs *buf);
|
||||
DIR *opendir(const char*);
|
||||
DIR *opendir(const char *);
|
||||
struct dirent *readdir(DIR *);
|
||||
int closedir(DIR*);
|
||||
void rewinddir(DIR*);
|
||||
long telldir(DIR*);
|
||||
void seekdir(DIR*, long);
|
||||
int closedir(DIR *);
|
||||
void rewinddir(DIR *);
|
||||
long telldir(DIR *);
|
||||
void seekdir(DIR *, long);
|
||||
int mkdir(const char *name, mode_t n);
|
||||
#if __cplusplus
|
||||
}; // extern "C"
|
||||
|
@ -556,7 +556,7 @@ namespace mbed {
|
|||
*
|
||||
* @returns a pointer to FILE
|
||||
*/
|
||||
std::FILE* fdopen(mbed::FileHandle *fh, const char *mode);
|
||||
std::FILE *fdopen(mbed::FileHandle *fh, const char *mode);
|
||||
|
||||
/** Bind an mbed FileHandle to a POSIX file descriptor
|
||||
*
|
||||
|
|
|
@ -88,7 +88,7 @@ time_t time(time_t *timer)
|
|||
}
|
||||
}
|
||||
|
||||
time_t t = (time_t)-1;
|
||||
time_t t = (time_t) -1;
|
||||
if (_rtc_read != NULL) {
|
||||
t = _rtc_read();
|
||||
}
|
||||
|
@ -100,7 +100,8 @@ time_t time(time_t *timer)
|
|||
return t;
|
||||
}
|
||||
|
||||
void set_time(time_t t) {
|
||||
void set_time(time_t t)
|
||||
{
|
||||
_mutex->lock();
|
||||
if (_rtc_init != NULL) {
|
||||
_rtc_init();
|
||||
|
@ -111,7 +112,8 @@ void set_time(time_t t) {
|
|||
_mutex->unlock();
|
||||
}
|
||||
|
||||
void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)) {
|
||||
void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void))
|
||||
{
|
||||
_mutex->lock();
|
||||
_rtc_read = read_rtc;
|
||||
_rtc_write = write_rtc;
|
||||
|
|
|
@ -56,7 +56,7 @@ void mbed_copy_nvic(void)
|
|||
#if !defined(__CORTEX_M0) && !defined(__CORTEX_A9)
|
||||
#ifdef NVIC_RAM_VECTOR_ADDRESS
|
||||
uint32_t *old_vectors = (uint32_t *)SCB->VTOR;
|
||||
uint32_t *vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
uint32_t *vectors = (uint32_t *)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (int i = 0; i < NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
#define USR_DISABLEDEBUG (RESERVED_FOR_USER_APPLICATIONS + 5)
|
||||
|
||||
#if DEVICE_LOCALFILESYSTEM
|
||||
FILEHANDLE semihost_open(const char* name, int openmode) {
|
||||
FILEHANDLE semihost_open(const char *name, int openmode)
|
||||
{
|
||||
uint32_t args[3];
|
||||
args[0] = (uint32_t)name;
|
||||
args[1] = (uint32_t)openmode;
|
||||
|
@ -52,12 +53,16 @@ FILEHANDLE semihost_open(const char* name, int openmode) {
|
|||
return __semihost(SYS_OPEN, args);
|
||||
}
|
||||
|
||||
int semihost_close(FILEHANDLE fh) {
|
||||
int semihost_close(FILEHANDLE fh)
|
||||
{
|
||||
return __semihost(SYS_CLOSE, &fh);
|
||||
}
|
||||
|
||||
int semihost_write(FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode) {
|
||||
if (length == 0) return 0;
|
||||
int semihost_write(FILEHANDLE fh, const unsigned char *buffer, unsigned int length, int mode)
|
||||
{
|
||||
if (length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t args[3];
|
||||
args[0] = (uint32_t)fh;
|
||||
|
@ -66,7 +71,8 @@ int semihost_write(FILEHANDLE fh, const unsigned char* buffer, unsigned int leng
|
|||
return __semihost(SYS_WRITE, args);
|
||||
}
|
||||
|
||||
int semihost_read(FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode) {
|
||||
int semihost_read(FILEHANDLE fh, unsigned char *buffer, unsigned int length, int mode)
|
||||
{
|
||||
uint32_t args[3];
|
||||
args[0] = (uint32_t)fh;
|
||||
args[1] = (uint32_t)buffer;
|
||||
|
@ -74,33 +80,39 @@ int semihost_read(FILEHANDLE fh, unsigned char* buffer, unsigned int length, int
|
|||
return __semihost(SYS_READ, args);
|
||||
}
|
||||
|
||||
int semihost_istty(FILEHANDLE fh) {
|
||||
int semihost_istty(FILEHANDLE fh)
|
||||
{
|
||||
return __semihost(SYS_ISTTY, &fh);
|
||||
}
|
||||
|
||||
int semihost_seek(FILEHANDLE fh, long position) {
|
||||
int semihost_seek(FILEHANDLE fh, long position)
|
||||
{
|
||||
uint32_t args[2];
|
||||
args[0] = (uint32_t)fh;
|
||||
args[1] = (uint32_t)position;
|
||||
return __semihost(SYS_SEEK, args);
|
||||
}
|
||||
|
||||
int semihost_ensure(FILEHANDLE fh) {
|
||||
int semihost_ensure(FILEHANDLE fh)
|
||||
{
|
||||
return __semihost(SYS_ENSURE, &fh);
|
||||
}
|
||||
|
||||
long semihost_flen(FILEHANDLE fh) {
|
||||
long semihost_flen(FILEHANDLE fh)
|
||||
{
|
||||
return __semihost(SYS_FLEN, &fh);
|
||||
}
|
||||
|
||||
int semihost_remove(const char *name) {
|
||||
int semihost_remove(const char *name)
|
||||
{
|
||||
uint32_t args[2];
|
||||
args[0] = (uint32_t)name;
|
||||
args[1] = (uint32_t)strlen(name);
|
||||
return __semihost(SYS_REMOVE, args);
|
||||
}
|
||||
|
||||
int semihost_rename(const char *old_name, const char *new_name) {
|
||||
int semihost_rename(const char *old_name, const char *new_name)
|
||||
{
|
||||
uint32_t args[4];
|
||||
args[0] = (uint32_t)old_name;
|
||||
args[1] = (uint32_t)strlen(old_name);
|
||||
|
@ -110,35 +122,41 @@ int semihost_rename(const char *old_name, const char *new_name) {
|
|||
}
|
||||
#endif
|
||||
|
||||
int semihost_exit(void) {
|
||||
int semihost_exit(void)
|
||||
{
|
||||
uint32_t args[4];
|
||||
return __semihost(SYS_EXIT, args);
|
||||
}
|
||||
|
||||
int semihost_uid(char *uid) {
|
||||
int semihost_uid(char *uid)
|
||||
{
|
||||
uint32_t args[2];
|
||||
args[0] = (uint32_t)uid;
|
||||
args[1] = DEVICE_ID_LENGTH + 1;
|
||||
return __semihost(USR_UID, &args);
|
||||
}
|
||||
|
||||
int semihost_reset(void) {
|
||||
int semihost_reset(void)
|
||||
{
|
||||
// Does not normally return, however if used with older firmware versions
|
||||
// that do not support this call it will return -1.
|
||||
return __semihost(USR_RESET, NULL);
|
||||
}
|
||||
|
||||
int semihost_vbus(void) {
|
||||
int semihost_vbus(void)
|
||||
{
|
||||
return __semihost(USR_VBUS, NULL);
|
||||
}
|
||||
|
||||
int semihost_powerdown(void) {
|
||||
int semihost_powerdown(void)
|
||||
{
|
||||
return __semihost(USR_POWERDOWN, NULL);
|
||||
}
|
||||
|
||||
#if DEVICE_DEBUG_AWARENESS
|
||||
|
||||
int semihost_connected(void) {
|
||||
int semihost_connected(void)
|
||||
{
|
||||
return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -146,12 +164,14 @@ int semihost_connected(void) {
|
|||
// These processors cannot know if the interface is connect, assume so:
|
||||
static int is_debugger_attached = 1;
|
||||
|
||||
int semihost_connected(void) {
|
||||
int semihost_connected(void)
|
||||
{
|
||||
return is_debugger_attached;
|
||||
}
|
||||
#endif
|
||||
|
||||
int semihost_disabledebug(void) {
|
||||
int semihost_disabledebug(void)
|
||||
{
|
||||
uint32_t args[1];
|
||||
#if !(DEVICE_DEBUG_AWARENESS)
|
||||
is_debugger_attached = 0;
|
||||
|
|
|
@ -29,8 +29,9 @@ extern "C" {
|
|||
#if !defined(__CC_ARM) && !defined(__ARMCC_VERSION)
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
static inline int __semihost(int reason, const void *arg) {
|
||||
return __semihosting(reason, (void*)arg);
|
||||
static inline int __semihost(int reason, const void *arg)
|
||||
{
|
||||
return __semihosting(reason, (void *)arg);
|
||||
}
|
||||
#else
|
||||
|
||||
|
@ -44,16 +45,17 @@ static inline int __semihost(int reason, const void *arg) {
|
|||
# define AngelSWIAsm swi
|
||||
#endif
|
||||
|
||||
static inline int __semihost(int reason, const void *arg) {
|
||||
static inline int __semihost(int reason, const void *arg)
|
||||
{
|
||||
int value;
|
||||
|
||||
asm volatile (
|
||||
asm volatile(
|
||||
"mov r0, %1" "\n\t"
|
||||
"mov r1, %2" "\n\t"
|
||||
AngelSWIInsn " %a3" "\n\t"
|
||||
"mov %0, r0"
|
||||
: "=r" (value) /* output operands */
|
||||
: "r" (reason), "r" (arg), "i" (AngelSWI) /* input operands */
|
||||
: "=r"(value) /* output operands */
|
||||
: "r"(reason), "r"(arg), "i"(AngelSWI) /* input operands */
|
||||
: "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" /* list of clobbered registers */
|
||||
);
|
||||
|
||||
|
@ -63,14 +65,14 @@ static inline int __semihost(int reason, const void *arg) {
|
|||
#endif
|
||||
|
||||
#if DEVICE_LOCALFILESYSTEM
|
||||
FILEHANDLE semihost_open(const char* name, int openmode);
|
||||
int semihost_close (FILEHANDLE fh);
|
||||
int semihost_read (FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode);
|
||||
int semihost_write (FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode);
|
||||
FILEHANDLE semihost_open(const char *name, int openmode);
|
||||
int semihost_close(FILEHANDLE fh);
|
||||
int semihost_read(FILEHANDLE fh, unsigned char *buffer, unsigned int length, int mode);
|
||||
int semihost_write(FILEHANDLE fh, const unsigned char *buffer, unsigned int length, int mode);
|
||||
int semihost_ensure(FILEHANDLE fh);
|
||||
long semihost_flen (FILEHANDLE fh);
|
||||
int semihost_seek (FILEHANDLE fh, long position);
|
||||
int semihost_istty (FILEHANDLE fh);
|
||||
long semihost_flen(FILEHANDLE fh);
|
||||
int semihost_seek(FILEHANDLE fh, long position);
|
||||
int semihost_istty(FILEHANDLE fh);
|
||||
|
||||
int semihost_remove(const char *name);
|
||||
int semihost_rename(const char *old_name, const char *new_name);
|
||||
|
|
|
@ -396,7 +396,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef FILEHANDLE
|
||||
typedef int FILEHANDLE;
|
||||
typedef int FILEHANDLE;
|
||||
#endif
|
||||
|
||||
// Backwards compatibility
|
||||
|
|
|
@ -21,15 +21,18 @@
|
|||
#include "platform/mbed_wait_api.h"
|
||||
#include "hal/us_ticker_api.h"
|
||||
|
||||
void wait(float s) {
|
||||
void wait(float s)
|
||||
{
|
||||
wait_us(s * 1000000.0f);
|
||||
}
|
||||
|
||||
void wait_ms(int ms) {
|
||||
void wait_ms(int ms)
|
||||
{
|
||||
wait_us(ms * 1000);
|
||||
}
|
||||
|
||||
void wait_us(int us) {
|
||||
void wait_us(int us)
|
||||
{
|
||||
const ticker_data_t *const ticker = get_us_ticker_data();
|
||||
uint32_t start = ticker_read(ticker);
|
||||
while ((ticker_read(ticker) - start) < (uint32_t)us);
|
||||
|
|
|
@ -24,15 +24,18 @@
|
|||
#include "platform/mbed_critical.h"
|
||||
#include "platform/mbed_power_mgmt.h"
|
||||
|
||||
void wait(float s) {
|
||||
void wait(float s)
|
||||
{
|
||||
wait_us(s * 1000000.0f);
|
||||
}
|
||||
|
||||
void wait_ms(int ms) {
|
||||
void wait_ms(int ms)
|
||||
{
|
||||
wait_us(ms * 1000);
|
||||
}
|
||||
|
||||
void wait_us(int us) {
|
||||
void wait_us(int us)
|
||||
{
|
||||
const ticker_data_t *const ticker = get_us_ticker_data();
|
||||
|
||||
uint32_t start = ticker_read(ticker);
|
||||
|
|
Loading…
Reference in New Issue