summaryrefslogtreecommitdiffstats
path: root/cpukit (follow)
Commit message (Collapse)AuthorAgeFilesLines
* kern_ntptime.c: Port to RTEMSSebastian Huber2022-02-215-98/+152
| | | | | | Remove previous adjtime() implementation. Update #2348.
* kern_ntptime.c: Import from FreeBSDSebastian Huber2022-02-211-0/+1053
| | | | | | | | | | | | | | | | | | | | The file was imported from this repository: https://github.com/freebsd/freebsd.git This commit was used: commit 3ec0dc367bff27c345ad83240625b2057af391b9 Author: Sebastian Huber <sebastian.huber@embedded-brains.de> Date: Mon Feb 7 14:16:16 2022 -0700 kern_ntptime.c: Remove ntp_init() The ntp_init() function did set a couple of global objects to zero. These objects are in the .bss section and already initialized to zero during kernel or module loading. Update #2348.
* kern_tc: unify timecounter to bintime delta conversionAndriy Gapon2022-02-211-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two places where we convert from a timecounter delta to a bintime delta: tc_windup and bintime_off. Both functions use the same calculations when the timecounter delta is small. But for a large delta (greater than approximately an equivalent of 1 second) the calculations were different. Both functions use approximate calculations based on th_scale that avoid division. Both produce values slightly greater than a true value, calculated with division by tc_frequency, would be. tc_windup is slightly more accurate, so its result is closer to the true value and, thus, smaller than bintime_off result. As a consequence there can be a jump back in time when time hands are switched after a long period of time (a large delta). Just before the switch the time would be calculated with a large delta from th_offset_count in bintime_off. tc_windup does the switch using its own calculations of a new th_offset using the large delta. As explained earlier, the new th_offset may end up being less than the previously produced binuptime. So, for a period of time new binuptime values may be "back in time" comparing to values just before the switch. Such a jump must never happen. All the code assumes that the uptime is monotonically nondecreasing and some code works incorrectly when that assumption is broken. For example, we have observed sleepq_timeout() ignoring a timeout when the sbinuptime value obtained by the callout code was greater than the expiration value, but the sbinuptime obtained in sleepq_timeout() was less than it. In that case the target thread would never get woken up. The unified calculations should ensure the monotonic property of the uptime. The problem is quite rare as normally tc_windup should be called HZ times per second (typically 1000 or 100). But it may happen in VMs on very busy hypervisors where a VM's virtual CPU may not get an execution time slot for a second or more. Reviewed by: kib MFC after: 2 weeks Sponsored by: Panzura LLC
* timecounter: Initialize tc_lock earlierMark Johnston2022-02-211-1/+2
| | | | | | | | | | | | | Hyper-V wants to register its MSR-based timecounter during SI_SUB_HYPERVISOR, before SI_SUB_LOCK, since an emulated 8254 may not be available for DELAY(). So we cannot use MTX_SYSINIT to initialize the timecounter lock. PR: 259878 Reviewed by: kib MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33014
* config: CONFIGURE_DISABLE_NEWLIB_REENTRANCYSebastian Huber2022-02-211-8/+9
| | | | | | | 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.
* termios: Pass number of sent chars to l_startChristian Mauderer2022-02-102-3/+8
| | | | | | | | | | | | | 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
* cpukit/microblaze: Simplify dispatch assemblyKinsey Moore2022-02-041-45/+3
| | | | | | The dispatch code was unnecessarily saving and restoring an extra interrupt frame. This avoids the extra frame and folds the dispatch call into a fallthrough to the interrupt frame restoration code.
* cpukit/microblaze: Clarify interrupt frame usageKinsey Moore2022-02-042-5/+14
| | | | | | Avoid use of magic numbers in favor of named constants and add MSR to the interrupt frame so that thread dispatch can occur on exceptions as well.
* cpukit/microblaze: Add exception extensionsKinsey Moore2022-02-043-0/+388
| | | | | Add the functions necessary to support RTEMS_EXCEPTION_EXTENSIONS and mark this functionality as available on MicroBlaze.
* cpukit/microblaze: Add debug vector and handlerKinsey Moore2022-02-042-0/+35
| | | | | | This patch adds a vector for debug events along with a hook similar to the exception framework. The debug vector generates an exception frame for use by libdebugger.
* cpukit/microblaze: Add exception frameworkKinsey Moore2022-02-043-17/+187
| | | | | | | | | | | This patch updates the CPU_Exception_frame to include all necessary registers, combines hardware snd software exception handlers into a shared vector, provides an architecture-specific hook for taking control of exception handling, and moves exception handling over to actually using the CPU_Exception_frame instead of a minimal interrupt stack frame. As the significant contents of _exception_handler.S have been entirely rewritten, the copyright information on this file has been updated to reflect that.
* microblaze: Add support for libbsd networkingAlex White2022-02-012-4/+1
| | | | | This includes fixes and improvements necessary to get libbsd networking running.
* cpukit: Prevent error with disabled stack checkerKinsey Moore2022-01-271-0/+5
| | | | | | | | | | | When the stack checker is not enabled, the stack checker reporting function can still be called. This prevents that call from performing a null memory access in trying to find the high water mark if the stack checker was never initialized. This also introduces a test to ensure this call does not cause a crash. Closes #4588
* Remove obsolete rtems_gxx_*() implementationSebastian Huber2022-01-273-343/+2
| | | | | | | | | | | 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.
* arm: Optimize interrupt handlingSebastian Huber2022-01-173-0/+53
| | | | | Use the SRS (Store Return State) instruction if available. This considerably simplifies the context save and restore.
* arm: Fix stack alignment during interrupt handlingSebastian Huber2022-01-171-10/+23
| | | | | | | | | | | On a public interface, the stack pointer must be aligned on an 8-byte boundary. However, it may temporarily be only aligned on a 4-byte boundary. The interrupt handling code must ensure that the stack pointer is properly aligned before it calls a function. See also: https://developer.arm.com/documentation/den0013/d/Interrupt-Handling/External-interrupt-requests/Nested-interrupt-handling Update #4579.
* arm: Avoid duplicate move from CPSRSebastian Huber2022-01-171-4/+3
| | | | Update #4579.
* arm: Rework per-CPU control in interrupt handlingSebastian Huber2022-01-151-56/+46
| | | | | | | | Use volatile register r0 for the per-CPU control of the current processor instead of the non-volatile register r7. This enables the use of r7 in a follow up patch. Do the interrupt handling in ARM mode. Update #4579.
* arm: Use push/pop instructions for readabilitySebastian Huber2022-01-151-11/+11
| | | | Update #4579.
* libtest: Check for pending eventsSebastian Huber2021-12-221-0/+9
| | | | Make sure there are no pending events after a test case.
* rtems: Fix Clock Manager parameter descriptionsSebastian Huber2021-12-221-8/+8
| | | | Update #4572.
* libmisc/rtems-fdt: close() file 'bf'Ryan Long2021-12-171-0/+1
| | | | | | | | close() file 'bf' to avoid leaking descriptor. CID 1437645: Resource leak in rtems_fdt_load(). Closes #4297
* dtc: Update VERSIONSebastian Huber2021-12-141-3/+3
|
* libfdt: overlay: make overlay_get_target() publicVikram Garhwal2021-12-141-0/+18
| | | | | | | | | | | 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>
* libfdt: fix an incorrect integer promotionElvira Khabirova2021-12-141-1/+1
| | | | | | | | | | UINT32_MAX is an integer of type unsigned int. UINT32_MAX + 1 overflows unless explicitly computed as unsigned long long. This led to some invalid addresses being treated as valid. Cast UINT32_MAX to uint64_t explicitly. Signed-off-by: Elvira Khabirova <e.khabirova@omp.ru>
* libfdt: Add ALIGNMENT error stringGeorg Kotheimer2021-12-141-0/+1
| | | | | | | | The ALIGNMENT error was missing a string, leading to <unknown error> being returned. Signed-off-by: Georg Kotheimer <georg.kotheimer@kernkonzept.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* fdtget: Fix signedness comparisons warningsAndre Przywara2021-12-141-0/+7
| | | | | | | | | | | | | | | | | | | | | 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>
* Fix CID 1461557David Gibson2021-12-141-5/+8
| | | | | | | | | | | | Coverity gets a bit confused by loading fdt_size_dt_strings() and using it in a memmove(). In fact this is safe because the callers have verified this information (via FDT_RW_PROBE() in fdt_pack() or construction in fdt_open_into()). Passing in strings_size like we already do struct_size seems to get Coverity to follow what's going on here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Add FDT alignment check to fdt_check_header()Rob Herring2021-12-141-0/+4
| | | | | | | | | | | | | Only checking the FDT alignment in fdt_ro_probe_() means that fdt_check_header() can pass, but then subsequent API calls fail on alignment checks. Let's add an alignment check to fdt_check_header() so alignment errors are found up front. Cc: Tom Rini <trini@konsulko.com> Cc: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20210406190712.2118098-1-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Fix a possible "unchecked return value" warningDavid Gibson2021-12-141-1/+4
| | | | | | | | | | | | | | | | Apparently the unchecked return value of the first fdt_next_tag() call in fdt_add_subnode_namelen() is tripping Coverity Scan in some circumstances, although it appears not to for the scan on our project itself. This fdt_next_tag() should always return FDT_BEGIN_NODE, since otherwise the fdt_subnode_offset_namelen() above would have returned BADOFFSET or BADSTRUCTURE. Still, add a check to shut Coverity up, gated by a can_assume() to avoid bloat in small builds. Reported-by: Ryan Long <ryan.long@oarcorp.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Set last_comp_version correctly in new dtb and fix potential version issues ↵Justin Covell2021-12-143-2/+5
| | | | | | | | | | | | | | | 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>
* libfdt: Tweak description of assume-aligned load helpersDavid Gibson2021-12-141-7/+7
| | | | | | | | There's a small inaccuracy in the comment describing these new helpers. This corrects it, and reformats while we're there. Fixes: f98f28ab ("libfdt: Internally perform potentially unaligned loads") Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Internally perform potentially unaligned loadsTom Rini2021-12-143-15/+32
| | | | | | | | | | | | | | | | | | | | | 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>
* libfdt: Check for 8-byte address alignment in fdt_ro_probe_()Tom Rini2021-12-142-1/+9
| | | | | | | | | | 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>
* libfdt: Fix kernel-doc commentsAndre Przywara2021-12-141-36/+75
| | | | | | | | | | | | | | | | | | 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>
* libfdt: fdt_strerror(): Fix comparison warningAndre Przywara2021-12-141-2/+2
| | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_strerror(). Force FDT_ERRTABSIZE to be signed (it's surely small enough to fit), so that the types match. Also move the minus sign to errval, as this is actually what we use in the next line. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-7-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_get_string(): Fix sequential write comparison warningsAndre Przywara2021-12-141-4/+6
| | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_get_string(). Introduce a new usigned variable, which holds the actual (negated) stroffset value, so we avoid negating all the other variables and have proper types everywhere. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-6-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: libfdt_wip: Fix comparison warningAndre Przywara2021-12-141-1/+1
| | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_setprop_inplace_namelen_partial(). fdt_getprop_namelen() will only return negative error values in "proplen" if the return value is NULL. So we can rely on "proplen" being positive in our case and can safely cast it to an unsigned type. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-5-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_create_with_flags(): Fix comparison warningAndre Przywara2021-12-141-2/+2
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_create_with_flags(). By making hdrsize a signed integer (we are sure it's a very small number), we avoid all the casts and have matching types. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-4-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_move(): Fix comparison warningsAndre Przywara2021-12-141-1/+4
| | | | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_move(). This stems from "bufsize" being passed in as a signed integer, even though we would expect a buffer size to be positive. Short of changing the prototype, check that bufsize is not negative, and cast it to an unsigned type in the comparison. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-3-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_add_string_(): Fix comparison warningAndre Przywara2021-12-141-7/+7
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_add_string_(). Make all variables unsigned, and express the negative offset trick via subtractions in the code. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-2-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_node_offset_by_phandle(): Fix comparison warningAndre Przywara2021-12-141-1/+1
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_node_offset_by_phandle(). Uses a better suited bitwise NOT operator to denote the special value of -1, which automatically results in an unsigned type. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-14-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_resize(): Fix comparison warningAndre Przywara2021-12-141-1/+4
| | | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_resize(). A negative buffer size will surely do us no good, so let's rule this case out first. In the actual comparison we then know that a cast to an unsigned type is safe. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-10-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_splice_(): Fix comparison warningAndre Przywara2021-12-141-1/+1
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_splice_(). Since we just established that oldlen is not negative, we can safely cast it to an unsigned type. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-8-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_get_string(): Fix comparison warningsSimon Glass2021-12-141-2/+2
| | | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_get_string(). In the first two cases, we have just established that the signed values are not negative, so it's safe to cast the values to an unsigned type. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-7-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_grab_space_(): Fix comparison warningAndre Przywara2021-12-141-2/+2
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_grab_space_(). All the involved values cannot be negative, so let's switch the types of the local variables to unsigned to make the compiler happy. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-4-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_mem_rsv(): Fix comparison warningsAndre Przywara2021-12-141-2/+2
| | | | | | | | | | | | With -Wsign-compare, compilers warn about a mismatching signedness in comparisons in fdt_mem_rsv(). Since all involved values must be positive, change the used types to be unsigned. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-3-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fdt_offset_ptr(): Fix comparison warningsAndre Przywara2021-12-141-3/+7
| | | | | | | | | | | | | | | With -Wsign-compare, compilers warn about mismatching signedness in comparisons in fdt_offset_ptr(). This mostly stems from "offset" being passed in as a signed integer, even though the function would not really tolerate negative values. Short of changing the prototype, check that offset is not negative, and use an unsigned type internally. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20200921165303.9115-2-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: fix fdt_check_node_offset_ w/ VALID_INPUTFrank Mehnert2021-12-141-6/+10
| | | | | | | | | | | | | fdt_check_node_offset_() checks for a valid offset but also changes the offset by calling fdt_next_tag(). Hence, do not skip this function if ASSUME_VALID_INPUT is set but only omit the initial offset check in that case. As this function works very similar to fdt_check_prop_offset_(), do the offset check there as well depending on ASSUME_VALID_INPUT. Message-Id: <1913141.TlUzK5foHS@noys4> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: add extern "C" for C++Patrick Oppenlander2021-12-141-0/+8
| | | | | | 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>