Issue created by Wayne Thornton: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5659



## Background & Motivation

Executing 64-bit e6500 SMP test suites (such as `smpspinwait01.exe`) inside 
QEMU (`-M ppce500 -cpu e6500 -m 1024 -smp 4`) using the default bare-metal 
`qoriq_e6500_64` BSP results in a silent console hang. This occurs because 
QEMU's generic `ppce500` machine model does not emulate physical NXP T-series 
CCSR memory maps or the on-chip NS16550 UART registers at their bare-metal 
physical addresses.

To successfully run and capture terminal output in QEMU, the BSP must be built 
as a **Hypervisor Guest**. Enabling this mode switches the console driver to 
use the ePAPR byte channel (routing output cleanly to QEMU's virtual terminal) 
and replaces physical MPIC timer dependencies with standard PowerPC decrementer 
clocks.

However, enabling Hypervisor Guest mode strips out physical external interrupt 
line definitions from `<bsp/irq.h>`, exposing an architectural bug where legacy 
VME bus driver code is being compiled against the 64-bit e6500 target.

---

## Environment & Configuration

* **RTEMS Version:** `7.0.not_released` (master branch)
* **Target Architecture:** `powerpc`
* **Target BSP:** `qoriq_e6500_64`
* **Host OS:** Linux x86_64 (WSL2 / GCC 15 toolchain environment)
* **Build System:** Waf

### Custom `config.ini`

```
[powerpc/qoriq_e6500_64]
RTEMS_SMP = True
BUILD_TESTS = True
RTEMS_POSIX_API = True
WARNING_FLAGS = -Wall -Wextra -Werror -Wno-unused-parameter 
-Wno-missing-field-initializers
CC_WARNING_FLAGS = -Wmissing-prototypes -Wimplicit-function-declaration 
-Wstrict-prototypes -Wnested-externs -Wold-styl>

QORIQ_IS_HYPERVISOR_GUEST = True
QORIQ_UART_0_ENABLE = False
QORIQ_UART_1_ENABLE = False
```

## Steps to Reproduce

1. Apply the 'config.ini' build options shown above
2. Configure the build tree with the following command:

`./waf configure --rtems-bsps=powerpc/qoriq_e6500_64`

3. Execute the build with './waf'

## Actual Behavior

The build aborts during the compilation of 
`bsps/powerpc/shared/vme/vme_universe.c`. Because physical external interrupts 
are omitted in hypervisor guest mode, the macro `QORIQ_IRQ_EXT_0` is undeclared:

```
In file included from ../../../bsps/powerpc/shared/vme/vme_universe.c:12:
../../../bsps/powerpc/shared/vme/vme_universe.c: In function 
'BSP_VMEIrqMgrInstall':
../../../bsps/powerpc/qoriq/include/bsp/VMEConfig.h:82:7: error: 
'QORIQ_IRQ_EXT_0' undeclared (first use in this function)
   82 |       QORIQ_IRQ_EXT_0, \
      |       ^~~~~~~~~~~~~~~
../../../bsps/powerpc/shared/vme/vme_universe.c:422:3: note: in expansion of 
macro 'BSP_VME_INSTALL_IRQ_MGR'
  422 |   BSP_VME_INSTALL_IRQ_MGR(err);
      |   ^~~~~~~~~~~~~~~~~~~~~~~
../../../bsps/powerpc/qoriq/include/bsp/VMEConfig.h:82:7: note: each undeclared 
identifier is reported only once for each function it appears in
   82 |       QORIQ_IRQ_EXT_0, \
      |       ^~~~~~~~~~~~~~~
../../../bsps/powerpc/shared/vme/vme_universe.c:422:3: note: in expansion of 
macro 'BSP_VME_INSTALL_IRQ_MGR'
  422 |   BSP_VME_INSTALL_IRQ_MGR(err);
      |   ^~~~~~~~~~~~~~~~~~~~~~~

Waf: Leaving directory `/home/wmthornton/src/rtems/build/powerpc/qoriq_e6500_64'
Build failed
 -> task in '/bsps/powerpc/objvme' failed with exit status 1
```

## Root Cause Analysis

Unscoped Waf Dependency: In `spec/build/bsps/powerpc/qoriq/`, the VME bus 
driver group (`objvme`) is linked to the broader `qoriq` BSP family rather than 
being restricted exclusively to the `mvme2500` BSP variant. As a result, the 
build system attempts to compile `vme_universe.c` for 64-bit e6500 targets that 
do not possess a VME Universe II or Tsi148 bridge.

Hardcoded Legacy Macro: In `bsps/powerpc/qoriq/include/bsp/VMEConfig.h`, the 
interrupt handler is hardcoded to `QORIQ_IRQ_EXT_0`. An existing comment in the 
source code explicitly acknowledges this technical debt:

```
 grep -n -C 10 "QORIQ_IRQ_EXT_0" bsps/powerpc/qoriq/include/bsp/VMEConfig.h
65- */
66-#define _VME_A32_WIN0_ON_PCI   (bsp_vme_pcie_base_address + 0x10000000)
67-#define _VME_A24_ON_PCI        (bsp_vme_pcie_base_address + 0x03000000)
68-#define _VME_A16_ON_PCI        (bsp_vme_pcie_base_address + 0x02000000)
69-#define _VME_CSR_ON_PCI        (bsp_vme_pcie_base_address + 0x01000000)
70-
71-/* FIXME: Make this a BSP config option */
72-#define _VME_A32_WIN0_ON_VME 0x20000000
73-
74-/*
75: * FIXME: The fixed QORIQ_IRQ_EXT_0 is valid for the MVME2500 board. In 
theory
76- * there should be some possibility to get that information from the device 
tree
77- * or from PCI config space. But I didn't find it anywhere.
78- */
79-#define BSP_VME_INSTALL_IRQ_MGR(err) \
80-  do { \
81-    err = qoriq_pic_set_sense_and_polarity(\
82:      QORIQ_IRQ_EXT_0, \
83-      QORIQ_EIRQ_TRIGGER_LEVEL_LOW, \
84-      NULL \
85-    ); \
86-    if (err == 0) { \
87:      err = vmeTsi148InstallIrqMgrAlt(0, 0, QORIQ_IRQ_EXT_0, -1); \
88-    } \
89-  } while (0)
90-
91-/* Add prototypes that are in all VMEConfig.h files */
92-extern int BSP_VMEInit(void);
93-extern int BSP_VMEIrqMgrInstall(void);
94-extern unsigned short (*_BSP_clear_vmebridge_errors)(int);
95-
96-#ifdef __cplusplus
97-}
```

Hypervisor IRQ Strip: When `QORIQ_IS_HYPERVISOR_GUEST = True` is defined, RTEMS 
alters the interrupt mappings in `<bsp/irq.h>`. Because virtual guest 
environments do not map physical external hardware IRQ pins (`QORIQ_IRQ_EXT_0` 
through `QORIQ_IRQ_EXT_11`), the symbol evaluates as undeclared during macro 
expansion, breaking the build.

## Suggested Solutions

Option A (Waf Specification Fix): Update the YAML build specifications in 
`spec/build/bsps/powerpc/qoriq/` so that the `objvme` group (and its associated 
drivers like `vme_universe.c`) is compiled only when building the `mvme2500` 
target, removing it entirely from `qoriq_e6500_64` build pipelines.

Option B (Header Guard Fix): If the VME files must remain in the shared family 
build path, wrap `bsps/powerpc/qoriq/include/bsp/VMEConfig.h` in a preprocessor 
guard that checks for VME hardware capability, or provide a safe fallback for 
virtualized guest builds:

```
#ifndef QORIQ_IRQ_EXT_0
  #define QORIQ_IRQ_EXT_0 0 /* Fallback for hypervisor guest and non-VME 
targets */
#endif
```

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5659
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/sent_notifications/4-cgixhl3tyfjhqxienpzzng2w5-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to