The red-black tree node held its links and its color in a nested
member. The nesting came from the entry macro of the header which the
previous commit removed. It served no purpose, and each access had to
name the nested member.
Move the links and the color into the node. Change the prefix of the
fields from rbe_ of the entry to rbn_ of the node. The Linux API
wrapper <linux/rbtree.h> renames the Linux fields with
"#define rb_left rbn_left" and "#define rb_right rbn_right". Other
Linux compatibility layers such as the linuxkpi of FreeBSD define
rb_left and rb_right as object-like macros. The prefix rbn_ is no
Linux name, so these macros leave the fields alone.
The tests sprbtree01 and ts-unit-no-clock-0 passed on the boards of
eight targets.
Target Processor
aarch64/zynqmp_apu Cortex-A53
LS1046A Cortex-A72
arm/zynqmp_rpu_lock_step Cortex-R5F
arm/samrh71_flexram Cortex-M7
arm/xilinx_zynq_zc702 Cortex-A9
riscv/mpfs_e51 E51
riscv/mpfs_u54 U54
sparc/gr740 LEON4
Update #5804.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The red-black tree of the score used <rtems/score/bsd-tree.h>, an import
of the FreeBSD <sys/tree.h> of 2020. FreeBSD replaced this red-black
tree by a rank-balanced tree, so the header has no upstream any more.
The macros of the header generated the functions of the tree. Most of
the header, such as the splay tree, served no code of RTEMS.
Translate each macro which the score uses into a static inline function
of <rtems/score/rbtree.h> or <rtems/score/rbtreeimpl.h>. Each field of
a node gets a getter and a setter. The body of each generated function
moves into the function which called it. Each statement of a macro maps
to one statement of the translation. Remove the header with its unused
parts and keep its copyright in each file which receives its code. The
node keeps its layout and its field names, and the colors keep their
names.
The test sptree01 checked that the RTEMS_ prefixed macros of the header
did not clash with the macros of <sys/tree.h>. It ran no check at
runtime. Remove the test with the header.
The tests sprbtree01 and ts-unit-no-clock-0 passed on the boards of
eight targets.
Target Processor
aarch64/zynqmp_apu Cortex-A53
LS1046A Cortex-A72
arm/zynqmp_rpu_lock_step Cortex-R5F
arm/samrh71_flexram Cortex-M7
arm/xilinx_zynq_zc702 Cortex-A9
riscv/mpfs_e51 E51
riscv/mpfs_u54 U54
sparc/gr740 LEON4
Update #5804.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The thread queues and the watchdogs order their elements in red-black
trees. No test measured the runtime of the tree operations.
Add a runtime measurement test for the insert, the extract, the
minimum, the successor and the replace. The tree sizes cover the
special paths of one to three nodes and grow by a factor of about 2.6
up to 233 nodes. One operation takes 30 ns to 250 ns on the boards,
and the counter of some boards has a step of 10 ns or more. One sample
therefore covers the operation in each of 16 trees of the same shape.
Update #5804.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The recently added code to add memory mappings for PCIe uses addresses
that are 64-bits. These do not work on ilp32. Since ilp32 is scheduled
for removal after 7.1 is released, disable the code doing the mapping.
If someone wants PCIe, use ilp64.
This is where the fix came from. GCC's -fanalyzer reports:
rtems-rfs-buffer.c:274:24: warning: dereference of NULL 'buffer'
[CWE-476] [-Wanalyzer-null-dereference]
Mounting RFS with max-held-bufs=0 dereferences a NULL pointer on the first
buffer release.
rtems_rfs_buffer_handle_release evicts a held buffer when
(fs->release_count + fs->release_modified_count) >= fs->max_held_buffers
taking it from fs->release when release_count is the larger and from
fs->release_modified otherwise, then doing buffer->user = (void*)0 at
rtems-rfs-buffer.c:274 with no NULL test. rtems_chain_get_unprotected
returns NULL for an empty chain by design.
For max_held_buffers >= 1 the guard implies one of the counts is non-zero
and the branch selects the queue holding it, so the result is never NULL.
At zero the guard is 0 >= 0, true on the first release with both queues
still empty; 0 > 0 is false so the else branch runs; the count underflows
from zero; and the NULL reaches :274.
The value is a mount option and nothing range checked it: the parser used
strtoul straight into the local and rtems_rfs_fs_open assigned it
unchecked. Zero held buffers is not a meaningful configuration, so reject
it where it is parsed.
It mounts with max-held-bufs=0 and requires EINVAL, and with
max-held-bufs=1, which must succeed: the guard is >=, so at one the first
release sees 0 >= 1 and evicts nothing, which puts the boundary exactly
where the arithmetic says it is.
Also removes a stray printf("options=%s") from the option parsing loop.
It is debug output left in the mount path, so every RFS mount printed a
line per option to the console. It is in the function this commit already
changes, and it was polluting the test output above.
Signed-off-by: Samuel Price <thesamprice@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Move common APIC register definitions to a shared
bsps/include/bsp/apic.h header and keep architecture
specific definitions in respective BSP headers,
aviudubg cross BSP dependencies.
Standardize LAPIC register access in pc386 to use array
indexing and LAPIC_REGISTER_* definitions. Rename
architecture-specific symbols to BSP-neutral names and
standardize APIC base access.
Fixes#5516
The 64-bit product of the counter ticks and the scaler overflowed.
rtems_counter_ticks_to_sbintime() returned a wrong value for more than
2 s. rtems_counter_ticks_to_nanoseconds() returned a wrong value for
more than 4.29 s, where the product overflowed and the cast to 32 bits
truncated the result. The test framework measures durations with
rtems_counter_ticks_to_sbintime(). On a 25 MHz counter, the
performance test suite reported 107 s for a run of 731 s.
Compute the 96-bit product from two 32-bit by 32-bit products. The
result is the same as before for each value which did not overflow.
Return the nanoseconds with 64 bits.
The test spcpucounter01 checked the conversions at one second alone.
Check them at three seconds and at the maximum counter ticks.
Close#5806.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The cache size functions returned 16 times the size of each cache
level. They added the offset of four to the line size field of
CCSIDR_EL1 twice. Level zero wrote the reserved level field seven
into CSSELR_EL1, so the result depended on the core. For a unified
level, the instruction cache size selected a cache which does not
exist. The performance measurement framework sizes its chunk with
level zero. It dirtied 64 MiB instead of 4 MiB per sample on the
LS1046A.
Add the offset once. Map level zero to the level of coherency. Select
the data, the instruction or the unified cache of a level by the cache
type in CLIDR_EL1.
The validation test called the cache size directives and checked no
value. Check that level zero is at least as large as each level.
Where the architecture provides cache geometry registers, compare each
level with the size which the registers specify.
Close#5805.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Move the PCIe initialization logic to a helper function and derive
the PCIe address ranges from the device tree when a PCIe node is
present. If the node is not available, fall back to the previous
static PCIe MMU mappings to preserve existing BSP behaviour.
This removes the ZYNQMP_MMU_PCIE_ENABLE option and avoids hardcoded
PCIe mappings while maintaining compatibility with existing users.
Fixes#5510
R_ARM_PREL31 writes the relocated value to bits 30:0 of the place.
Bit 31 has a separate meaning and must retain its original value.
Replace the misleading sign_extend31() helper with prel31_field(). The new
helper masks the relocation result to 31 bits and combines it with bit 31
from the original place.
Closes#5225.
No test checked the dispatch of the controller line of the extended
interrupt as a standard controller line. On the GR765, no bus line of
the reset map goes to this controller line.
Map a free bus line to the controller line of the extended interrupt
where the BSP uses an interrupt map. Raise it and check the dispatch
of its interrupt handler.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
No test triggered the fatal errors of leon3_check_ipi_vector(). With
the interrupt map, the default configuration cannot trigger them.
Add the two test suites which the fatal error specifications generate.
Each defines LEON3_mp_irq. With the interrupt map, it selects a bus
line which no driver uses and maps that bus line before the BSP reads
the interrupt map. Without the interrupt map, it selects an invalid
vector or an extended controller line.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
No test checked that a bus line whose map entry is zero is associated
with no interrupt vector.
Add the test case which the specification of invalid interrupt map
entries generates. Build it in the BSP validation test suite of the
GR740 and the GR765, which use the interrupt map.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
leon3_irqmap_set() is new, and no test checked it.
Add the test case which the specification of leon3_irqmap_set()
generates. Build it beside the test cases of the other interrupt map
functions.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
No test checked what leon3_ext_irq_init() writes to the interrupt
controller and to the interrupt map copy.
Add the test case which the specification of leon3_ext_irq_init()
generates. Build it beside the test case of leon3_irqmap_get().
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The validation test suite checked no LEON3 interrupt map function.
Add the test case which the specification of leon3_irqmap_get()
generates. Build it in the BSP validation test suite of the GR712RC,
the GR740 and the GR765.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
A test of the interrupt map changes the map entry of a bus line. The
GR740 has an unassigned bus line, and the GR765 has none. The test
needs a bus line which no driver uses on each chip.
Define TM27_IRQMAP_BUS_LINE by the bus line count. Use the unassigned
bus line 13 on the GR740. Use the eFPGA bus line 19 on the GR765,
which the plug and play information does not report.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The BSP read the interrupt map once during initialization. An
application could not change the controller line of a bus line. It
could not move a device off a controller line which the reset map
shares.
Add leon3_irqmap_set(). It writes the map register and the copy under
the interrupt support mutex and the interrupt controller lock. It
refuses the change while a handler is installed on the current
controller line of the bus line. That handler would no longer see the
interrupt.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The BSP sent the inter-processor interrupt on bus line 14 and followed
the interrupt map. The GR765 reset map maps bus line 14 to controller
line 1, which the DMA controllers use. The GR765 keeps the controller
lines 13 and 14 free after reset. No peripheral drives bus line 0.
Add the option LEON3_IPI_BUS_LINE for the initial value of
LEON3_mp_irq. It is 0 for the GR740 and the GR765, and 14 otherwise.
With a map, map bus line 0 in the copy to the controller line defined
by the new option LEON3_IPI_CONTROLLER_LINE, which is 14 by default.
Accept vector 0 where its map entry is not zero. Let the shared memory
driver force the controller line of LEON3_mp_irq.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
bsp_interrupt_vector_enable() and bsp_interrupt_set_affinity() mapped
the bus line to its controller line. They passed the result to
leon3_interrupt_vector_enable(), which mapped it a second time. The
GR765 reset map maps bus line 14 to controller line 1. A bus line
remapped to controller line 14 therefore unmasked controller line 1.
Map the vector once, in the callers of leon3_interrupt_vector_enable().
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The documentation of leon3_ext_irq_init() stated only that the function
initializes the interrupt controller. It did not state what a caller
can rely on.
Document the state which the function establishes for the boot
processor and for the interrupt map copy. State that the parameter
references the first interrupt controller.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
leon3_ext_irq_init() took the register block of the interrupt
controller as a parameter. It read the interrupt map through
LEON3_IrqCtrl_Regs instead and every other register through the
parameter.
Read the interrupt map through the parameter.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
leon3_check_ipi_vector() took the status of
bsp_interrupt_get_attributes() as the validity of the IPI vector. The
function returns RTEMS_SUCCESSFUL for every vector. An IPI bus line
which the interrupt map connected to no controller line passed the
check.
Both failures of the check reported LEON3_FATAL_IPI_INITIALIZATION, so
the fatal code did not tell them apart.
Check the vector with bsp_interrupt_is_valid_vector() before the
attributes are read. Replace the fatal code with
LEON3_FATAL_INVALID_IPI_VECTOR for an invalid vector and with
LEON3_FATAL_CANNOT_RAISE_IPI for a vector which cannot be raised on a
processor.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
bsp_interrupt_set_affinity() requires a valid vector.
rtems_interrupt_set_affinity() and rtems_interrupt_get_affinity()
check the vector before they call the BSP. The leon3 affinity functions
checked the bus line a second time. The RTEMS_UNSATISFIED return of
that check could not happen.
Use the unchecked map lookup in both functions. Assert the valid
vector and the affinity pointer in both, as the other interrupt
functions of the file do. State the valid vector as a requirement of
bsp_interrupt_get_affinity(), as bsp_interrupt_set_affinity() states
it.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The BSP assumed 64 bus lines for every chip with an interrupt map. The
GR740 has 32 bus lines in eight map registers. The BSP read the
undefined offsets 0x320 to 0x33C, and vector 32 passed as valid, so
ts-validation-intr failed on the GR740. The GR765 has 64 bus lines.
A map field is eight bits wide. A field value above 31 indexed past
the dispatch table of 32 entries and made the bit shifts undefined.
Replace the option LEON3_IRQAMP_IRQMAP by LEON3_IRQMAP_BUS_LINE_COUNT,
which is 32 for the GR740 and 64 for the GR765. With an interrupt map,
an interrupt vector is a bus line. The vector count is then the bus
line count, and the dispatch table keeps one entry for each controller
line. Bound each map entry by the dispatch table, so that a hardware
fault cannot index past it.
The description of LEON3_IRQAMP_EXTENDED_INTERRUPT named an interrupt
line and did not say which kind. Call it a controller line, the term
which the other options use.
The extended interrupt raise test took a vector for its controller
line. It raised 1U << vector for vectors up to the count, which is
undefined from 32 on. Its specification item did not exist.
Regenerate the test from the new item. It raises the mapped controller
line of each vector which maps to an extended controller line. It
checks that it exercised each extended controller line.
Close#5786.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
<bsp/irq.h> and <bsp/irqimpl.h> both declared LEON3_IrqCtrl_Mapping.
leon3_irqmap_get() was declared in <bsp/irqimpl.h> and defined only
where the BSP uses the interrupt map. An application for a BSP without
the interrupt map could not call it. The function wrote through its
pointer parameter without a check. Its documentation did not follow
the style of the API directives and stated no constraints.
Make leon3_irqmap_get() part of the API of every BSP of the family.
Where the BSP uses no interrupt map, it reports the controller line of
the same number. It returns RTEMS_INVALID_ADDRESS for a NULL pointer
first, as the API directives do. For an invalid bus line, it stores
UINT32_MAX, so that a caller which ignores the status reads no
indeterminate value. Document it in the style of the API directives,
with a parameter name which says that it holds a controller line.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
AM335X_GPIO_CLEARDATAOUT and AM335X_GPIO_SETDATAOUT are write-1-to-clear
and write-1-to-set registers. Reading either register returns the current
GPIO_DATAOUT state.
Using mmio_set() performed a read-modify-write on these registers. For
CLEARDATAOUT, this wrote 1s for all currently active output pins, causing
all set pins in the bank to be unintentionally cleared whenever any single
pin was cleared.
Fix this by using mmio_write() instead of mmio_set() to write only the
target pin mask directly without reading back the current output state.
Fixes#5235.
The test asked for the scheduler of processor 1. A uniprocessor
configuration owns processor 0 alone.
rtems_scheduler_ident_by_processor() therefore returned
RTEMS_INVALID_NAME and the test ended with a failed assertion.
Ask for the scheduler of the last processor of the configuration. The
directive under test refuses a scheduler change of a sporadic server
thread whatever the scheduler is.
Closes#5788.
Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The POSIX sporadic server takes the real priority node of a thread out
of the priority aggregation while the thread runs at the low priority.
_Scheduler_Set() extracts that node without a check. It skips the
extract where a scheduler change inhibitor is present, and only an SMP
build had one. A uniprocessor build with the POSIX API therefore
extracted a node which sits in no tree. A debug build ended psx09 with
a failed assertion in _RBTree_Extract() and a release build broke the
priority aggregation of the thread.
The sporadic server is a property of the POSIX API alone. Enable the
scheduler change inhibitors wherever the POSIX API is enabled.
rtems_task_set_scheduler() then returns RTEMS_RESOURCE_IN_USE for a
sporadic server thread at both priorities, as it does in an SMP build.
Closes#5745.
Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
rtems_clock_set() accepted years up to TOD_LATEST_YEAR defined as 4095.
However, realtime watchdogs represent timestamps using 34 bits for
seconds since the UNIX Epoch (WATCHDOG_MAX_SECONDS), which wraps around
year 2514. Setting CLOCK_REALTIME beyond year 2514 breaks every subsequent
tick: in debug builds _Watchdog_Ticks_from_timespec() asserts that the
timestamp is not far future, while in release builds the realtime watchdog
collection is tickled with wrapped values.
As discussed in the Year 4000 (Y4K) problem topic on the RTEMS forum,
extending the calendar to year 4095 is prevented by this 34-bit watchdog
seconds limit.
Furthermore, _TOD_Validate() checked year bounds while
_TOD_Is_valid_new_time_of_day() checked seconds against
TOD_SECONDS_1970_THROUGH_2400, leaving a boundary mismatch between
rtems_clock_set() and POSIX clock_settime().
Bound TOD_LATEST_YEAR to 2400 and align TOD_SECONDS_1970_THROUGH_2400
as an exclusive upper limit in _TOD_Is_valid_new_time_of_day(). Both
rtems_clock_set() and clock_settime() now consistently accept times up
to 2400-12-31T23:59:59.999999999Z and reject later values, leaving over
113 years of system uptime headroom before watchdog overflow. Synchronize
documentation and update psxclock, spclock_err02, and clock validation
test suites accordingly.
Closes#5749.
rtems_termios_baud_table listed B28800 after B38400, but
rtems_termios_set_best_baud() scans forward to the first entry at or
above the request and so assumes ascending order. The two rates around
the out-of-place row came back wrong: 28800 returned B19200, and 40000
returned B28800.
Move the row between B19200 and B38400. Nothing else depends on the
order: rtems_termios_baud_to_index() is a self-contained switch and the
num/baud conversions search by value. test_set_best_baud() had skipped
every extension rate, which is the region where the table was out of
order, so add 28800, 38400 and 40000.
Signed-off-by: Samuel Price <thesamprice@gmail.com>
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
On 64-bit platforms, `struct ambapp_dev` is 36 bytes which get padded to 40
bytes.
In that scenario, substracting the size of the struct to get the address of the
parent struct yields incorrect results.
We instead use `RTEMS_CONTAINER_OF()` which will always give the correct parent
no matter the padding.
The hurricane, rbtx4925 and rbtx4938 BSPs excluded dl01 to dl13. The
exclusion dates from 2015 and answers a link failure of dl01. The
build of that era passed the compiler flags to rtems-syms as a string
and let the tool call the compiler. The string lost -EL, so the tool
built a big endian object for a little endian target and the link
rejected it.
The waf build runs rtems-syms with -S, which writes a C source file,
and compiles that file itself with the flags of the BSP. The flag
cannot get lost.
Drop the exclusion of the three BSPs. Twelve tests return, because
dl13 belongs to arm. The other users of the item keep it.
No simulator runs these three BSPs, so the link is the only evidence
available. The link is what the report named.
Update #2279.
Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Nothing checked that the context switch, interrupt processing and the
exception resume of the MIPS port keep the register sets which the ABI
requires. Three defects of the port reached the test suite unseen.
The interrupt return dropped the status register. The exception path
saved a floating point data register in place of the control register.
The exception resume left the call-saved registers as the fatal error
chain left them.
Add three test cases from the specification items
spec/score/cpu/mips/val/context, spec/score/cpu/mips/val/interrupt and
spec/score/cpu/mips/val/resume. Each case loads a distinct pattern
into every register of its set, runs the operation and takes a trap.
The frame of that trap reports what the operation left behind. So no
register under test carries the address of the store-out.
The cases join ts-validation-no-clock-0. That suite needs no clock
driver, and the interrupt case raises the software interrupt of the
processor through the TM27 support.
Update #5754.
Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The exception path of _ISR_Handler() read the control and status
register of coprocessor 1 with mfc1 and wrote it back with mtc1.
Those instructions address a floating point data register. cfc1 and
ctc1 address a control register.
So the save put the bits of $f31 into the frame at R_FCSR, over the
value which the prologue stored there. The restore put the slot into
$f31 and destroyed that register. The same pair used C1_REVISION,
which is $f0 and which holds the identity of the unit rather than
state of a context.
Drop both accesses. The prologue stores the register through the
two-read idiom of the port and the exit restores it with ctc1, so the
exception path needs neither. Nothing fills R_FEIR, because no MIPS32
processor carries that register.
Update #5769.
Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
The port had no _CPU_Exception_resume(). A fatal error extension
which inspects an exception frame could not continue the interrupted
context. Every exception therefore ended the system.
The chain which reaches such an extension ends in a fatal error. No
function of that chain returns, so no function of it puts a call-saved
register back. _Terminate() also clears the interrupt enable before
it calls the extensions. The frame is the only source of s0 to s7 and
of the interrupt level.
Add the routine. It restores the registers which the interrupted
context owns and continues at the exception program counter of the
frame. The header comment of the file names the registers which it
leaves out and the reason for each.
Update #5754.
Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>