Memory model for RTOS and No RTOS was initially single stack and heap,
only few targets implemented 2-region RAM model.
2-region RAM model is applied for all toolchains and targets.
GCC: __wrap__sbrk was implemented for 2-region ram model, with switch to 2-region
for all targets, we do not need target specific implementation of this API
Also _sbrk is WEAK function, hence can be over written in target folder for
special cases
The following commits: #8039, #9092 added Boot/ISR stack definition to all scatter files (ARM_LIB_STACK).
This has changed memory model for RTOS-less builds to 2-region memory model and caused failure in case of rtos less builds.
This PR defines valid heap/stack regions for rtos-less builds.
A couple of places in mbed_retarget.cpp were testing for either ARMC5 or
ARMC6 in a long-winded fashion. Testing for __ARMCC_VERSION being
defined is sufficient.
Similar to SingletonPtr, use atomic accesses when loading the guard word
outside the lock, and when storing, to ensure no races for threads that
don't take the lock.
Lack of atomics unlikely to be a problem in current builds, but code
could conceivably be subject to reordering if link-time optimisation was
enabled.
Mbed retarget does an `fflush` on stdout and stderr on exit - this
flushes the C library buffers (if it is buffering), but doesn't
flush any device buffers (eg UARTSerial's TX buffer). Add
sync() calls to the output device to do this.
You are allowed in POSIX / ANSI C to read and write on the same stream, but you
have to do an fseek in between read and write call (getc->fseek->putc)
Thanks @Alex-EEE for sharing the fix: https://github.com/ARMmbed/mbed-os/pull/7749
Added test case for verification of the behavior
Add the POSIX fcntl call, but only implementing F_SETFL and F_GETFL
for O_NONBLOCK, so users can control the blocking flag of streams
with only the integer file descriptor.
Necessary to portably control the blockingness of the console:
int flags = fcntl(STDOUT_FILENO, F_GETFL);
fcntl(STDOUT_FILENO, F_SETFL, flags | O_NONBLOCK);
Some platforms have interface chips with hardware flow control
enabled by default. This commit adds configurable flow control to
STDOUT.
Usage:
* Define pin names STDIO_UART_RTS for Rx-flow-control and
STDIO_UART_CTS for Tx-flow-control.
* Set target.console-uart-flow-control. Valid options are:
null, RTS, CTS, and RTSCTS.
Rework so that everything is a FileHandle, including
stdin/stdout/stderr.
Provide legacy functionality of calling serial_getc and serial_putc as
an internal "DirectSerial" FileHandle.
Add a JSON option to use UARTSerial instead.
Add hooks for target and application to provide custom FileHandles.
Allow for CRLF conversion to work on any FileHandle that isatty(),
as stdin/stdout or any other FILE. Optimise the conversion so it
doesn't force all write calls to be 1 byte. Limit the conversion
to the stdio layer, so that read() and write() work the same as
the FileHandle methods - this seems less confusing.
Rationalise layers a little more to add the POSIX standard fdopen(int)
and a local open(FileHandle) to map a FileHandle to a POSIX file
descriptor.
fdopen(FileHandle) is now a composite of those two, rather than being
a primitive.
Index the FileHandle array from 0 - now if filehandle[0..2] is
NULL, it uses the built-in serial for stdin/stdout/stderr,
else it will use a FileHandle.
No mechanism to actually put a FileHandle in that position yet.
Fill in a gap by providing the POSIX file functions corresponding
to the FileHandle API, so FileHandles can be used from C without
going through the C library stdio layer.
This aligns with the fact we already provide POSIX directory
functions.
Fix EOF handling for ARM C Library _sys_read.
Fix the caller address logging on the GCC compilation too.
Previously the code logged the caller address as C++ wrapper,
not the actual caller of the C++ operator new or delete.
The C++ "operator new" and "operator delete" (and their array
variants) were logging the the caller address wrong. In practice
if one used "operator new", the logged caller address pointed
to mbed_retarget.cpp, not to the client. Fix this by exposing
the alloc wrappers to the the retarget.
Note: this fixes only the ARMCC variants, as the GCC ones have
different different API and implementation.
The API is as per posix standard, but does not provide stats for file/directory.
Stats buffer (block size, total block count, free block count) is filled for
entire mounted filesystem.