Commit Graph

1228 Commits

Author SHA1 Message Date
Sebastian Huber
8f1e8f8f26 kern_ntptime.c: Port to RTEMS
Remove previous adjtime() implementation.

Update #2348.
2022-02-21 14:16:41 +01:00
Sebastian Huber
d69acf87dc config: CONFIGURE_DISABLE_NEWLIB_REENTRANCY
Do not initialize Thread_Control::libc_reent if
CONFIGURE_DISABLE_NEWLIB_REENTRANCY is defined.  This helps to catch errors
with a NULL pointer exception rather than a corruption of the thread control
block.
2022-02-21 11:08:30 +01:00
Christian Mauderer
7b5948d4d2 termios: Pass number of sent chars to l_start
At the moment the line discipline start function (l_start) has no
possibility to get feedback about the number of characters that have
been sent. This patch passes that information via an additional
parameter.

The change might trigger a warning on existing code because of a pointer
mismatch but it shouldn't break it. An existing function with the old
API will just ignore the additional parameter.

Update #4493
2022-02-10 09:07:26 +01:00
Sebastian Huber
2145e0c7bf Remove obsolete rtems_gxx_*() implementation
GCC versions prior to 6.1 used a RTEMS thread model based on
rtems_gxx_*() functions. GCC version 6.1 or later uses the
self-contained synchronization objects of Newlib <sys/lock.h> for the
RTEMS thread model.

Remove the obsolete implementation.

Close #3143.
2022-01-27 11:06:46 +01:00
Sebastian Huber
d40477161e rtems: Fix Clock Manager parameter descriptions
Update #4572.
2021-12-22 08:17:50 +01:00
Vikram Garhwal
75b3f48aa3 libfdt: overlay: make overlay_get_target() public
This is done to get the target path for the overlay nodes which is very useful
in many cases. For example, Xen hypervisor needs it when applying overlays
because Xen needs to do further processing of the overlay nodes, e.g. mapping of
resources(IRQs and IOMMUs) to other VMs, creation of SMMU pagetables, etc.

Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
Message-Id: <1637204036-382159-2-git-send-email-fnu.vikram@xilinx.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Andre Przywara
c07e23899b fdtget: Fix signedness comparisons warnings
With -Wsign-compare, compilers warn about a mismatching signedness in
the different legs of the conditional operator, in fdtget.c.

In the questionable expression, we are constructing a 16-bit value out of
two unsigned 8-bit values, however are relying on the compiler's
automatic expansion of the uint8_t to a larger type, to survive the left
shift. This larger type happens to be an "int", so this part of the
expression becomes signed.

Fix this by explicitly blowing up the uint8_t to a larger *unsigned* type,
before doing the left shift. And while we are at it, convert the hardly
readable conditional operator usage into a sane switch/case expression.

This fixes "make fdtget", when compiled with -Wsign-compare.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20210618172030.9684-3-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Justin Covell
a582ab37c2 Set last_comp_version correctly in new dtb and fix potential version issues in fdt_open_into
Changes in v3:
- Remove noop version sets
- Set version correctly on loaded fdt in fdt_open_into

Fixes: f1879e1a50eb ("Add limited read-only support for older (V2 and V3) device tree to libfdt.")

Signed-off-by: Justin Covell <jujugoboom@gmail.com>

Message-Id: <20201229041749.2187-1-jujugoboom@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Tom Rini
03b601aff1 libfdt: Internally perform potentially unaligned loads
Commits 6dcb8ba4 "libfdt: Add helpers for accessing unaligned words"
introduced changes to support unaligned reads for ARM platforms and
11738cf01f15 "libfdt: Don't use memcpy to handle unaligned reads on ARM"
improved the performance of these helpers.

On further discussion, while there are potential cases where we could be
used on platforms that do not fixup unaligned reads for us, making this
choice the default is very expensive in terms of binary size and access
time.  To address this, introduce and use new fdt{32,64}_ld_ functions
that call fdt{32,64}_to_cpu() as was done prior to the above mentioned
commits.  Leave the existing load functions as unaligned-safe and
include comments in both cases.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Message-Id: <20201211022736.31657-1-trini@konsulko.com>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Tom Rini
064a1d76a4 libfdt: Check for 8-byte address alignment in fdt_ro_probe_()
The device tree must be loaded in to memory at an 8-byte aligned
address.  Add a check for this condition in fdt_ro_probe_() and a new
error code to return if we are not.

Signed-off-by: Tom Rini <trini@konsulko.com>
Message-Id: <20201104130605.28874-1-trini@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Andre Przywara
611a2a5a51 libfdt: Fix kernel-doc comments
The API documentation in libfdt.h seems to follow the Linux kernel's
kernel-doc format[1].

Running "scripts/kernel-doc -v -none" on the file reports some problems,
mostly missing return values and missing parameter descriptions.

Fix those up by providing the missing bits, and fixing the other small
issues reported by the script.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/doc-guide/kernel-doc.rst
Message-Id: <20201012165331.25016-1-andre.przywara@arm.com>

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Patrick Oppenlander
f5379faf35 libfdt: add extern "C" for C++
Signed-off-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Message-Id: <20200616011217.15253-1-patrick.oppenlander@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2021-12-14 16:00:44 +01:00
Sebastian Huber
868e6d8a75 rtems: Improve ordering in <rtems/rtems/intr.h>
Move the data structure definitions closer to the directives which use
them.
2021-12-13 07:32:58 +01:00
Sebastian Huber
fb17dfb1ad Avoid ISR_LOCK_MEMBER() since it confuses Doxygen
If RTEMS_SMP is not defined, then Doxygen adds the comments intended for
conditional the lock member to the next member.
2021-12-09 16:37:30 +01:00
Sebastian Huber
39e6f53298 score: Fix _Workspace_Initialize_for_one_area()
In _Workspace_Initialize_for_one_area(), properly check  if there is enough
free memory available for the configured workspace size.

The bug was introduced by commit 3d0620b607.
2021-12-07 16:32:54 +01:00
Sebastian Huber
69d643f711 score: Fix atomic stores for C++
Close #4566.
2021-12-07 12:24:15 +01:00
Sebastian Huber
9089bcc7b9 rtems: Move all Interrupt Manager stuff to intr.h
Since the previous Interrupt Manager Extension API moved to the
Interrupt Manager, we can move the interfaces to <rtems/rtems/intr.h> so
that they are available via #include <rtems.h>.
2021-12-02 15:11:39 +01:00
Sebastian Huber
0d83bed2e5 rtems: Move scheduler directives to own header
Move all rtems_scheduler_* directives to the new header file
<rtems/rtems/scheduler.h>.  Add a Scheduler Manager API and
implementation group.
2021-12-02 14:09:51 +01:00
Sebastian Huber
d7205f0083 libc: Optimize malloc() initialization
The BSPs provide memory for the separate C Program Heap initialization
via _Memory_Get().  Most BSPs provide exactly one memory area.  Only two
BSPs provide more than one memory area (arm/altera-cyclone-v and
bsps/powerpc/mpc55xxevb).  Only if more than one memory area is
provided, there is a need to use _Heap_Extend().  Provide two
implementations to initialize the separate C Program Heap and let the
BSP select one of the implementations based on the number of provided
memory areas.  This gets rid of a dependency on _Heap_Extend().  It
also avoids dead code sections for most BSPs.

Change licence to BSD-2-Clause according to file history.

Update #3053.
2021-11-30 08:33:12 +01:00
Sebastian Huber
3d0620b607 score: Optimize Workspace Handler initialization
The BSPs provide memory for the workspace initialization via
_Memory_Get().  Most BSPs provide exactly one memory area.  Only two
BSPs provide more than one memory area (arm/altera-cyclone-v and
bsps/powerpc/mpc55xxevb).  Only if more than one memory area is
provided, there is a need to use _Heap_Extend().  Provide two
implementations to initialize the workspace handler and let the BSP
select one of the implementations based on the number of provided memory
areas.  This gets rid of a dependency on _Heap_Extend().  It also avoids
dead code sections for most BSPs.
2021-11-30 08:31:59 +01:00
Sebastian Huber
675e879b8b rtems: Replace "precision" with "resolution"
Resolution is the right term for the documented property.
2021-11-23 15:18:25 +01:00
Sebastian Huber
546846472a score: Properly continue the thread during restart
The _Thread_queue_Extract() does not deal with potential priority
updates and the SMP locking protocol handling.  Use
_Thread_queue_Continue().  For the POSIX signals processing this is
currently probably unnecessary, however, the use case is similar to the
restart so use the same appoach.

Close #4546.
2021-11-23 11:00:28 +01:00
Sebastian Huber
2e56aabdb1 score: Move _Thread_queue_Extract()
Move _Thread_queue_Extract() since this function is not used by the core
services (threads, semaphores, mutexes, message queues).

Update #4546.
2021-11-23 11:00:28 +01:00
Sebastian Huber
e429e9742a score: Simplify thread wait state handling
Remove the THREAD_WAIT_STATE_READY_AGAIN and simply use the initial value to
indicate that a thread does not wait on something.  Rename
THREAD_WAIT_FLAGS_INITIAL to THREAD_WAIT_STATE_READY.  This change is necessary
so that _Thread_Continue() can be called for threads which never waited on
something (for example dormant threads).

Update #4546.
2021-11-23 11:00:28 +01:00
Sebastian Huber
50aef135a4 score: Add _Thread_MP_Extract_proxy()
Remove _Thread_queue_Extract_with_proxy() and move the proxy extraction
to _Thread_MP_Extract_proxy().  Move similar code blocks of the previous
caller of _Thread_queue_Extract_with_proxy() to helper functions.

Update #4546.
2021-11-23 11:00:28 +01:00
Sebastian Huber
c69a70a597 rtems: Fix rtems_scheduler_remove_processor()
Return an error status for the following error condition in
rtems_scheduler_remove_processor():

While an attempt is made to remove a processor from a scheduler, while
the processor is the only processor owned by the scheduler, if a thread
exists which uses the scheduler as a helping scheduler, then the
processor shall not be removed.

The reason is that ask for help requests and withdraw node requests are
processed asynchronously in any order.  An ask for help request carried
out on a scheduler without a processor is undefined behaviour.

Update error status description.

Update #4544.
2021-11-23 11:00:28 +01:00
Sebastian Huber
6443c9dbb7 score: Fix assertion in SMP scheduler framework
Properly assert that the scheduled chain is not empty.  Fix formatting.

Close #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
fc64e837c3 score: Rework ask for help requests
Process ask for help requests on the current processor.  This avoids
using inter-processor interrupts to make the system behaviour a bit more
predictable.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
4d90289e71 score: _Scheduler_SMP_Schedule_highest_ready()
Simplify callers of _Scheduler_SMP_Schedule_highest_ready().  Move the node
state change and the extraction from scheduled into
_Scheduler_SMP_Schedule_highest_ready().  Move the idle thread release to the
caller which have more information about the presence of an idle thread.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
d0434b8863 score: Remove victim thread from CPU allocation
Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
c6362f640a score: Move _Scheduler_Unblock_node()
Move _Scheduler_Unblock_node() into _Scheduler_SMP_Unblock().  This simplifies
the code and makes it easier to review.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
dcd8b939ba score: Move _Scheduler_Block_node()
Move _Scheduler_Block_node() into _Scheduler_SMP_Block().  This simplifies the
code and makes it easier to review.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
f767ef8059 score: Simplify _Scheduler_SMP_Yield()
There is not need to actively ask for help in a yield operation.  The helping
is already done on demand by the other scheduler operations.
2021-11-23 11:00:28 +01:00
Sebastian Huber
6d20f0c525 score: Add node to insert to Chain_Node_order
This allows to use additional members of the nodes for comparision.

Update #4534.
2021-11-23 11:00:28 +01:00
Sebastian Huber
ff20bc9816 score: Rework idle handling in SMP schedulers
This patch fixes an issue with the idle thread handling in the SMP
scheduler framework used for the MrsP locking protocol.  The approach to
use a simple chain of unused idle threads is broken for schedulers which
support thread to processor affinity.  The reason is that the thread to
processor affinity introduces another ordering indicator which may under
certain conditions lead to a reordering of idle threads in the scheduled
chain.  This reordering is not propagated to the chain of unused idle
threads.  This could lead to use an idle thread for a sticky scheduler
node which is already in use.  This locks up the system in infinite
loops in the thread context switch procedure.

To fix this, the SMP scheduler implementations must now provide
callbacks to get and release an unused idle thread.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
3d6ebde1ac score: Add SMP scheduler make/clean sticky
This patch fixes the following broken behaviour:

  While a thread is scheduled on a helping scheduler, while it does not
  own a MrsP semaphore, if it obtains a MrsP semaphore, then no
  scheduler node using an idle thread and the ceiling priority of the
  semaphore is unblocked for the home scheduler.

This could lead to priority inversion issues and is not in line
with the MrsP protocol.

Introduce two new scheduler operations which are only enabled if
RTEMS_SMP is defined.  The operations are used to make the scheduler
node of the home scheduler sticky and to clean the sticky property.
This helps to keep the sticky handing out of the frequently used
priority update operation.

Close #4532.
2021-11-23 11:00:28 +01:00
Sebastian Huber
3781709f28 score: Add SMP scheduler idle exchange callback
Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
9d3e821279 score: Rework affine ready queue handling
Rework the handling of the affine ready queue for the EDF SMP scheduler.
Do the queue handling in the node insert, move, and extract operations.
Remove the queue handling from _Scheduler_EDF_SMP_Allocate_processor().

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
a53229bbb6 score: Use extract from scheduled callbacks
Use the extract from scheduled callback provided by the scheduler
implementation in the SMP scheduler framework.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
757a10964f score: Remove return value from enqueue scheduled
The return value was unused.  Remove it.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
6286a40aa3 score: Scheduler insert after move
Insert nodes after moving the second node to reduce the items in the
data structure for the insert operation.  This also avoids having two
nodes for the same processor inserted into the scheduled chain.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
81659420b0 score: Add missing idle thread exchanges
Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
e787091764 score: Add missing idle thread releases
Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
bd55f69f5b score: Simplify _Scheduler_Exchange_idle_thread()
Remove superfluous idle parameter.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
f0f60a1ec3 score: Change _Scheduler_Try_to_schedule_node()
Add the victim node as parameter instead of the idle thread.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
7ae4f56929 score: Not set CPU in _Scheduler_Use_idle_thread()
Do not set the CPU of the idle thread in _Scheduler_Use_idle_thread().  This
helps to use _Scheduler_Try_to_schedule_node() under more general conditions in
the future, for example in case the owner and user of a node are not the same.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
45e942d1ae score: Rename _Scheduler_Set_idle_thread()
Rename _Scheduler_Set_idle_thread() in _Scheduler_Node_set_idle_user() and move
it to <rtems/score/schedulernodeimpl.h>.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
577262a737 score: Add red-black tree append/prepend
These functions are a faster alternative to _RBTree_Insert_inline() if
it is known that the new node is the maximum/minimum node.

Update #4531.
2021-11-23 11:00:28 +01:00
Sebastian Huber
3c0760414e score: Simplify _Scheduler_Generic_block()
If we block the executing thread and it is not the heir thread, then there is
no need to run the schedule operation.  The scheduler already selected a new
heir.
2021-11-23 11:00:28 +01:00
Kinsey Moore
50cf19320d cpukit: Enable debug for SMP AArch64
Ensure when both RTEMS_DEBUG is specified and pointers are large that
enough space is allocated to accomodate the Per_CPU_Control structure.
This changes the calculation to be more compositional instead of trying
to list out every permutation of options possible.
2021-11-22 15:51:40 -06:00