Commit Graph

34308 Commits

Author SHA1 Message Date
Sebastian Huber
2fdd00fcdc rtems: Document new rtems_task_delete() error
Update #4414.
2021-05-27 07:12:49 +02:00
Harrison Edward Gerber
e2011dca26 cpukit/libpci: fix potential buffer overflow in pci_cfg_print_code.c
See also CID 1399721

Closes #4442
2021-05-26 16:43:26 -06:00
Kinsey Moore
342fe19842 score/aarch64: Align context validation frame
Ensure the stack remains aligned by keeping the context frame at a
multiple of 16 bytes. This avoids stack alignment exceptions which occur
when the stack pointer is not 16 byte aligned.
2021-05-26 16:08:25 -05:00
Sebastian Huber
de694b753c score: Direct thread dispatch in a self restart
Commit 73ebf9a27e accidentally removed the
direct thread dispatch in a self thread restart.  In case of a self
restart (always in task context) the directive shall not return.  If
this is not possible due to a bad thread dispatch disable level, then a
fatal error shall occur.

Update #4412.
2021-05-26 13:40:24 +02:00
Sebastian Huber
ce6319ade4 score: Fix _Thread_Cancel()
The _Thread_Cancel() (in contrast to _Thread_Restart() which used a
similar code block) may have produced ready threads with an active timer
in case the thread to cancel had its thread life protection enabled. The
problem was this code block:

    Priority_Control priority;

    _Thread_Add_life_change_request( the_thread );

    if ( _Thread_Is_life_change_allowed( previous ) ) {
      _Thread_State_release( the_thread, &lock_context );

      _Thread_queue_Extract_with_proxy( the_thread );
      _Thread_Timer_remove( the_thread );
    } else {
      _Thread_Clear_state_locked( the_thread, STATES_SUSPENDED );
      _Thread_State_release( the_thread, &lock_context );
    }

    priority = _Thread_Get_priority( executing );
    _Thread_Raise_real_priority( the_thread, priority );
    _Thread_Remove_life_change_request( the_thread );

The life change request should only be added/removed if a life change is
allowed (see _Thread_Restart()).  Add _Thread_Try_life_change_request()
and use it in _Thread_Cancel() and _Thread_Restart().

Close #4435.
2021-05-26 13:40:24 +02:00
Sebastian Huber
29187be532 posix: Allow pthread_cancel() from within ISRs
Close #4413.
2021-05-26 13:40:24 +02:00
Sebastian Huber
3cef3198a5 score: Simplify calling _Thread_Exit()
Move common code into _Thread_Exit().  This enables a tail call
optimization in most cases.
2021-05-26 13:40:24 +02:00
Sebastian Huber
b81d1ffd23 rtems: Return RTEMS_CALLED_FROM_ISR
If rtems_task_delete() is called from within interrupt context, then
return RTEMS_CALLED_FROM_ISR.  This makes the behaviour predictable.

Update #4414.
2021-05-26 13:36:57 +02:00
Joel Sherrill
76d5722b4a sysinit: Do not open console when just referencing reentrancy structure.
This change eliminates a system initialization dependentcy which resulted
in an application without a file system or console referencing errno being
forced to include the code to open(/dev/console), close(), atexit(),
and the unmount infrastructure.

Closes #4439.
2021-05-25 08:33:04 -05:00
Joel Sherrill
402a206a1b powerpc/.../sbrk.c: Do not reference errno.
Closes #4r37.
2021-05-25 08:33:04 -05:00
Joel Sherrill
f9d590753a ppc-irq-legacy.c: Use rtems_malloc() instead of malloc().
Closes #4438.
2021-05-25 08:33:04 -05:00
Vijay Kumar Banerjee
71521ff21f telnetd.c: Remove RTEMS_NETWORKING check
Set the priority manually to make telnetd compatible with the
2021-05-20 17:55:33 -06:00
Vijay Kumar Banerjee
a5fd2935b7 testsuites: Remove telnetd01
telnetd01 test cannot be run without a network stack, so this test is being
moved to the rtems-net-legacy repository.
2021-05-20 17:52:37 -06:00
Sebastian Huber
a89ecaa1a9 score: Simplify thread queue timeout handling
Add Thread_queue_Context::timeout_absolute to specify an absolute or
relative timeout.  This avoid having to get the current time twice for
timeouts relative to the current time.  It moves also functionality to
common code.
2021-05-18 18:47:43 +02:00
Sebastian Huber
24c6293294 posix: Fix use of clock for relative times
Close #4426.
2021-05-18 18:47:18 +02:00
Sebastian Huber
d45f87cf35 score: Add _CPU_Context_switch_no_return()
The __builtin_unreachable() cannot be used with current GCC versions to
tell the compiler that a function does not return to the caller, see:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99151

Add a no return variant of _CPU_Context_switch() to avoid generation of
dead code in _Thread_Start_multitasking() if RTEMS was built with SMP
support enabled.
2021-05-18 08:02:50 +02:00
Sebastian Huber
80b3c938ce score: Move _Thread_queue_Queue_get_name_and_id()
Move this diagnostic function to a separate file since it does not
provide a core function of the system.

Change license to BSD-2-Clause according to file history and
re-licensing agreement.

Update #3053.
2021-05-17 17:30:39 +02:00
Sebastian Huber
9918735448 posix: Use RTEMS_POSIX_API in clock_nanosleep()
It is only possible to get interrupted by a POSIX signal if
RTEMS_POSIX_API is defined.
2021-05-17 17:29:36 +02:00
Sebastian Huber
815a94326c posix: Move clock_nanosleep()
Move clock_nanosleep() to a separate file to avoid a dependency on errno
which pulls in the Newlib reentrancy support.  This is an issue since
most parts which are pulled in cannot be garbage collected by the linker
due to the system initialization linker set.
2021-05-17 17:29:36 +02:00
Christian Mauderer
15e26f4d7f bsps/imxrt: Enable DMA clock
The EDMA is intialized so make sure the the clock is initialized too.

Update #4180
2021-05-17 09:06:41 +02:00
Christian Mauderer
691fec407a bsps/imxrt: Fix OCRAM, ITCM and DTCM sizes
The sizes are configurable via fuses or per software via some registers.
At the moment the registers are not changed. Changing the registers
destroys data stored in the RAM areas (like application code or data).
So either the fuses or some bootloader should be used to set them before
the application starts.

This also adds an OCRAM only linker command file.

Update #4180
2021-05-17 09:06:41 +02:00
Christian Mauderer
988cc1a795 bsps/imxrt: Add addresses and interrupts to dts
Add addresses and interrupts for most internal peripherals to the dts.
The additional aliases make it possible for an application to easily
access these informations.

Update #4180
2021-05-17 09:06:41 +02:00
Christian Mauderer
c30566667d bsps/imxrt: Reduce devicetree size
Remove symbols that would be necessary for overlays and decrease padding
that would be necessary for adding stuff during run-time.

Update #4180
2021-05-17 09:06:41 +02:00
Christian Mauderer
08e4e6f2bb bsps/imxrt: Fix documentation error
Update #4180
2021-05-17 09:06:36 +02:00
Sebastian Huber
2cc25cf1b2 score: Add and use _Per_CPU_Is_ISR_in_progress()
Add _Per_CPU_Is_ISR_in_progress() as an optimized version of
_ISR_Is_in_progress().
2021-05-17 08:05:31 +02:00
Sebastian Huber
6f2c8f32e6 score: Improve parameters in _Thread_Change_life() 2021-05-17 08:05:31 +02:00
Sebastian Huber
98cb84ea2f arm/altera-cyclone-v: Fix compile error
Update #4406.
2021-05-17 08:05:31 +02:00
Sebastian Huber
73ebf9a27e rtems: Fix task restart within interrupt context
rtems_task_restart() may be called from within interrupt context.  So
checking only that the thread to restart is equal to the executing
thread is insufficient to determine a self restart.  We have to also
check that no ISR is in progress.  Merge _Thread_Restart_other() and
_Thread_Restart_self() into one _Thread_Restart() since they share a lot
of common code.

Close #4412.
2021-05-14 16:56:03 +02:00
Sebastian Huber
b9083c5597 rtems: Always set the real priority during restart
Unconditionally set the real priority of the task to its initial
priority during a task restart.

Close #4411.
2021-05-14 14:56:29 +02:00
Sebastian Huber
57be57c799 score: Return status in _Thread_Restart_other()
This simplifies rtems_task_restart().
2021-05-14 09:37:19 +02:00
Sebastian Huber
b87d2a6364 rtems: Check entry point in rtems_task_start()
Close #4410.
2021-05-14 09:20:26 +02:00
Sebastian Huber
410317ae3a validation: Add INVALID_ID to tx-support.h 2021-05-14 08:50:10 +02:00
Sebastian Huber
bc29c7c313 validation: Add support library
Add a library for support functions used by validation tests.  Rename
tc-support.* to tx-support.* since this file does not contain test
cases.
2021-05-14 08:48:38 +02:00
Sebastian Huber
45a3495325 rtems: Add TOD_Ticks_validation
Replace defines with an enum.

Update #4406.
2021-05-14 08:09:34 +02:00
Sebastian Huber
523867de9d rtems: Constify rtems_task_wake_when()
Add a parameter to _TOD_Validate() to disable the validation of the
ticks member.

There are two reasons for this change.  Firstly, in
rtems_task_wake_when() was a double check for time_buffer == NULL (one
in rtems_task_wake_when() and one in _TOD_Validate()).  Secondly, the
ticks member is ignored by rtems_task_wake_when().  This was done with a
write of zero to the ticks member and thus a modification of the
user-provided structure.  Now the structure is no longer modified.
Using a mask parameter is quite efficient. You just have to load an
immediate value and there are no additional branches in _TOD_Validate().

Close #4406.
2021-05-12 21:25:37 +02:00
Sebastian Huber
6136918ddf rtems: Document rtems_task_set_scheduler() errors 2021-05-12 21:08:12 +02:00
Sebastian Huber
51f7a82f08 rtems: Clarify rtems_task_get_priority() doc 2021-05-12 21:07:54 +02:00
Sebastian Huber
e3bec23d4d rtems: Use rtems_clock_get_ticks_per_second()
This avoids an integer division at runtime.
2021-05-12 06:41:10 +02:00
Frank Kühndel
3af2dc7802 _TOD_Validate(): Fix incorrect return code
This patch fixes bug #4403. Directives

* rtems_timer_fire_when()
* rtems_timer_server_fire_when()
* rtems_task_wake_when()

are documented to return RTEMS_INVALID_ADDRESS when their time-of-day
argument is NULL. But actually they return RTEMS_INVALID_CLOCK. To fix
the issue this patch changes _TOD_Validate() to return a
status code instead of just true/false.

Close #4403
2021-05-12 06:41:10 +02:00
Sebastian Huber
c2687666b1 rtems: Use _Objects_Free_nothing() for msg queues
Use _Objects_Free_nothing() for rtems_message_queue_construct() to avoid
unreachable code in _CORE_message_queue_Close() in case only
user-provided message buffers are used.

Update #4007.
2021-05-11 07:45:58 +02:00
Sebastian Huber
ab5aeb1be1 score: Rename _Stack_Free_nothing()
Rename _Stack_Free_nothing() in _Objects_Free_nothing() to make it
reusable for the message queue buffers.

Update #4007.
2021-05-11 07:45:58 +02:00
Sebastian Huber
6822af7579 rtems: rtems_scheduler_get_processor_set() docs
Document changed error status.

Update #4401.
2021-05-07 08:08:35 +02:00
Sebastian Huber
2146d347ab rtems_scheduler_ident_by_processor_set() docs
Document new error status.
2021-05-07 08:08:24 +02:00
Sebastian Huber
9f727f9379 validation: Fix handling of N/A pre-conditions
In the action requirements, some pre-conditions are not applicable
depending on the state of other pre-conditions.  There is no particular
order in the pre-conditions, so we have to check the N/A status
individually.
2021-05-07 07:44:07 +02:00
Sebastian Huber
c46d125569 Check the alignment in posix_memalign() earlier
Make sure all conditions to do a proper memory allocation are satisfied
before a zero size memory allocation is performed.

Update #4390.
2021-05-07 07:08:04 +02:00
G S Niteesh Babu
b391affc36 bsps/shared/ofw: Fix coverity defects
This patch adds asserts to fix coverity defects
1) CID 1474437 (Out-of-bounds access)
2) CID 1474436 (Out-of-bounds access)

From manual inspection, out of bounds access cannot occur due to
bounds checking but coverity fails to detect the checks.
We are adding asserts as a secondary check.
2021-05-06 16:44:38 -06:00
Sebastian Huber
2c5199bb04 Return NULL for zero size allocations
In POSIX, zero size memory allocations are implementation-defined
behaviour.  The implementation has two options:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html

https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html

Linux and FreeBSD return a unique pointer for zero size memory
allocations.   Return NULL on RTEMS to more likely catch the use of a
zero size memory area by erroneous applications.

Update #4390.
2021-05-06 08:03:58 +02:00
Sebastian Huber
5580b93f36 libc: Reimplement posix_memlign()
Move all error checks into posix_memalign() so that the returned memory
pointer is set to NULL under all error conditions except
memptr == NULL.

Use parameter names of POSIX documentation.
2021-05-06 08:03:58 +02:00
Sebastian Huber
48898b3a5d rtems: rtems_scheduler_get_processor_set() status
In case the processor set is not large enough to contain the processor
set owned by the scheduler return RTEMS_INVALID_SIZE instead of
RTEMS_INVALID_NUMBER. This is more in line with other directives since
the issue is related to the size of an object.

Close #4401.
2021-05-06 08:03:58 +02:00
Sebastian Huber
3f0c0bfe9a rtems: rtems_scheduler_ident_by_processor_set()
Check for a NULL processor set pointer.
2021-05-06 07:23:11 +02:00