Commit Graph

286 Commits (f1ad089660ac59eb81cfe5d76d7af394d471c30d)

Author SHA1 Message Date
Martin Kojtal e8efe11c0e
Merge pull request #6031 from OpenNuvoton/nuvoton_m2351_cthunk
M23: Fix CThunk error on Cortex-M23
2018-02-08 15:21:24 +00:00
Jimmy Brisson 7b5d48df38
Merge pull request #5571 from kjbracey-arm/retarget_fh
Complete mbed_retarget FileHandle rework
2018-02-07 17:21:09 -06:00
ccli8 e9e9b8ed5c [M23] Fix CThunk error on Cortex-M23
Cortex-M23 doesn't support ARMv8-M Main Extension and so doesn't support:
ldm  r0, {r0, r1, r2, pc}

Fix it by going Cortex-M0/M0+ way:
ldm  r0, {r0, r1, r2, r3}
bx   r3
2018-02-07 15:45:54 +08:00
Cruz Monrreal 07fce417ca
Merge pull request #5852 from maciejbocianski/scoped_lock
ScopedLock implementation
2018-02-06 12:51:21 -06:00
Kevin Bracey f79bfddcad Make stdin/stdout/stderr be FileHandles
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.
2018-02-06 11:07:23 +02:00
Kevin Bracey 96c709fb35 Rework retarget opening
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.
2018-02-06 11:07:21 +02:00
Cruz Monrreal b8d218038b
Merge pull request #5994 from bmcdonnell-ionx/gcc-arm-extram
allow use of external memory as heap with TOOLCHAIN_GCC_ARM
2018-02-01 23:17:29 -06:00
Cruz Monrreal d8aebba542
Merge pull request #5987 from deepikabhavnani/add_macros
Pre-processor common macro addition
2018-02-01 16:34:33 -06:00
Brendan McDonnell a47bf4595f make _sbrk() WEAK so the user can override it, e.g. to make malloc() always use external memory 2018-02-01 11:14:07 -05:00
deepikabhavnani 3977249b54 Added macro: 1. string length and 2. variable argument count 2018-01-31 14:06:16 -06:00
Kevin Bracey b5ac071b66 Add space for real stdin/out FileHandles
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.
2018-01-29 15:29:02 +02:00
Kevin Bracey f391d8a0dc Add POSIX file functions
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.
2018-01-29 15:29:02 +02:00
Michael Kaplan b3a9af49b8 CriticalSectionLock: fixing missing include
Macro MBED_DEPRECATED_SINCE is defined in platform/mbed_toolchain.h which was not included.
If someone used member functions lock or unlock (which are prefixed with MBED_DEPRECATED_SINCE since some time), there would be a compile error instead of a warning.
Including mbed_toolchain.h fixes that.
2018-01-24 08:10:35 +01:00
Amanda Butler 8f175609ae
Copy edit ScopedLock.h
Copy edit document for active voice, present tense and consistent comma use.
2018-01-17 16:56:28 -06:00
Martin Kojtal 4118542bdf critical: fix non valid configuration
If any architecture is added, needs  to update critical exclusive access.

Also fixing if exclusive access is defined, we use the value.
2018-01-17 10:36:47 +00:00
Martin Kojtal b37f24a2cd critical: fix set exclusive access if not yet defined
Fixes #5555 bug.
In case there is not yet defined __EXCLUSIVE_ACCESS, neither MBED_EXCLUSIVE_ACCESS that
we are introducing, use architecture macros to find out if MBED_EXCLUSIVE_ACCESS can be
enabled.
2018-01-17 10:36:36 +00:00
Cruz Monrreal 671c2d7e90
Merge pull request #5346 from scartmell-arm/feature-hal-spec-critical-section
Add Critical Section HAL API specification
2018-01-16 12:49:38 -06:00
Martin Kojtal 280d491ff2
Merge pull request #5456 from TeroJaasko/fix_cpp_alloc_wrappers
platform: make C++ allocation wrappers log the correct caller address
2018-01-15 15:29:54 +00:00
Maciej Bocianski a3c9c124f7 platform: Add ScopedLock 2018-01-15 09:34:05 +01:00
Cruz Monrreal c0c501c70f
Merge pull request #5768 from deepikabhavnani/storage_stats
Added statvfs API to get storage statistics
2018-01-11 10:25:41 -06:00
Steven Cartmell 061795c489 Move in_critical_section implementation into the HAL
- Add function to HAL hal_in_critical_section()
- Wrap assert in FEATURE_UVISOR macro
2018-01-09 10:41:29 +00:00
Deepika d5cf4a6a6a fsblkcnt_t is available in GCC, but adding it for all compilers 2018-01-08 10:42:41 -06:00
Tero Jääskö b81be1e34c platform: Fix C++ allocation wrappers for GCC compilation
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.
2018-01-08 16:09:39 +02:00
Tero Jääskö 1cf5c45615 platform: make C++ allocation wrappers log the correct caller address
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.
2018-01-08 16:09:32 +02:00
Steven Cartmell e14bee5209 Fix potential race condition in critical section HAL API
Call underlying HAL implementation to enter critical section/disable interrupts
before incrementing the global critical section counter.

Modify HAL implementations to track first entrances to the critical section and
only update the saved state on first enter.
2018-01-05 14:55:58 +00:00
Steven Cartmell a07c07fa63 Update HAL API header information 2018-01-05 14:55:57 +00:00
Steven Cartmell 84391f0b64 Remove invalid assert and move uVisor warning to correct function 2018-01-05 14:55:57 +00:00
Steven Cartmell 07a394ee8b Add Critical Section HAL API specification
- Define header functions for Critical Section HAL API
  - hal_critical_section_enter()
  - hal_critical_section_exit()

- Add weak default implementation for HAL API. The default implementation
  matches the previous behaviour stored in mbed_critical:
  - The first call to enter a critical section stores the state of interrupts
    before disabling and each successive call re-disables interrupts.
  - The last call (non-nested) will restore the IRQ state that was set on the
    enter to the critical section. Nested calls are ignored.

- Add function 'core_util_in_critical_section' to User facing API to determine
  if the program is currently in a critical section, instead of depending on
  'core_util_interrupts_enabled'.
2018-01-05 14:53:51 +00:00
Deepika 7a90be0ce1 Added statvfs API to get storage statistics
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.
2017-12-29 16:42:31 -06:00
Anna Bridge eda0acc5da
Merge pull request #5621 from maciejbocianski/critical_section_imp2
CriticalSectionLock class improvement
2017-12-29 14:37:00 +00:00
Anna Bridge 1b53aabc5c
Merge pull request #5733 from deepikabhavnani/non_rtos_serial_fix
Access to serial device is allowed when DEVICE_SERIAL is defined
2017-12-29 14:28:15 +00:00
Maciej Bocianski aa22ef1e1e platform: fix mem_trace trace_level guard 2017-12-23 09:20:35 +01:00
Maciej Bocianski ad67904daa platform: CriticalSectionLock class improvement 2017-12-23 09:18:37 +01:00
Seppo Takalo 6c3f307257 Fix PR5578 2017-12-21 12:22:11 +02:00
Deepika 5bc33b94f8 Access to serial device is allowed when DEVICE_SERIAL is defined 2017-12-20 09:59:06 -06:00
Martin Kojtal b89cf3ff75
Merge pull request #5578 from mprse/CircularBuffer_tests
CircularBuffer class modification and test
2017-12-20 14:51:44 +00:00
Martin Kojtal bea41d1ebb
Merge pull request #5635 from c1728p9/fix_lazy_init
Protect local static object construction in ARMCC
2017-12-12 17:41:21 +00:00
Martin Kojtal be52ba2156
Merge pull request #5363 from mprse/extended_rtc
Add support and tests for extended RTC
2017-12-12 17:36:44 +00:00
Russ Butler c63a627868 Protect local static object construction in ARMCC
Implement the functions __cxa_guard_acquire, __cxa_guard_release
and __cxa_guard_abort for ARMCC so local static object construction is
thread safe.
2017-12-01 11:14:58 -06:00
Przemyslaw Stekiel dc5a66dc5c Add support for extended RTC.
Provide support to use whole 32-bit range (unsigned int) to hold time since UNIX epoch.
The suppoerted time range is now from the 1st of January 1970 at 00:00:00 to the 7th of February 2106 at 06:28:15.
Add support for two types of RTC devices:
- RTCs which handles all leap years in the mentioned year range correctly. Leap year is determined by checking if the year counter value is divisible by 400, 100, and 4.
- RTCs which handles leap years correctly up to 2100. The RTC does a simple bit comparison to see if the two lowest order bits of the year counter are zero. In this case 2100 year will be considered incorrectly as a leap year, so the last valid point in time will be 28.02.2100 23:59:59 and next day will be 29.02.2100 (invalid). So after 28.02.2100 the day counter will be off by a day.
2017-12-01 17:07:34 +01:00
Martin Kojtal b076565ac0
Merge pull request #5596 from kjbracey-arm/strong_cas
Make LDREX/STREX CAS functions strong
2017-11-30 18:04:14 +00:00
Przemyslaw Stekiel c962913ed9 Add assertion to make CounterType consistent with BufferSize.
CounterType is used to define type of _head and _tail counters. This may cause the following problems:
- counters are used as array indexes so only unsigned types should be used for counters,
- CounterType must be consistent with BufferSize and BufferSize is of uint32_t type (i.e. Circular Buffer with the following parameters: BufferSize = 1000, CounterType = unsigned char will not work properly).
2017-11-29 11:26:23 +01:00
Kevin Bracey 59508d46a6 Explicitly note that CAS is strong in docs
Add a note to each CAS making explicit that the functions are strong.

Minor wording change to expectedCurrentValue - use of "still updated"
about the failure case suggested that it might be written to on success.
For some uses it's critically important that expectedCurrentValue only
be written on failure, so change wording to "instead updated".
2017-11-28 14:02:28 +02:00
Kevin Bracey cfa6d07a3b Make LDREX/STREX CAS functions strong
The LDREX/STREX implementations of the compare-and-swap functions were
weak (they could spuriously fail when the value was expected), whereas
the critial section implementation was strong, and the documentation has
no suggestion that there might be spurious failures.

Rationalise by adding a retry loop for STREX failure, so that it only
returns false when the value is not expected.

Fixes https://github.com/ARMmbed/mbed-os/issues/5556
2017-11-28 11:56:50 +02:00
Jimmy Brisson 70e7b40468
Merge pull request #5583 from kjbracey-arm/delete_null
Remove pointless null check in operator delete
2017-11-27 10:37:40 -06:00
Jimmy Brisson b9c3003419
Merge pull request #5466 from kjbracey-arm/write_all
Make POSIX-like writes write everything when blocking
2017-11-27 10:36:28 -06:00
Kevin Bracey ff6bc08c53 Remove pointless null check in operator delete
free() checks for NULL, no need to add another check.
2017-11-24 10:40:15 +02:00
deepikabhavnani e78998e117 Definition for stat was missing in header file 2017-11-22 17:41:24 -06:00
Jimmy Brisson 4b57c5818e
Merge pull request #5528 from c1728p9/simplify_retarget
Use retarget defines where possible
2017-11-22 10:18:36 -06:00
Jimmy Brisson b6e50f5ed9
Merge pull request #5525 from deepikabhavnani/errno_fix
Fixed: errno update failure with IAR8.x
2017-11-22 10:17:56 -06:00