From ec94351a5e2edf94b3373e13e42a75b4f4b86395 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 17:57:31 -0500 Subject: [PATCH] Add RTEMS-pc686-qemu for use on RTEMS 5.x RTEMS 5.x moved the PC BSP to 686. This commit makes the EPICS target match; RTEMS-pc386 and the -qemu variant can only be built when RTEMS_VERSION != 5, whereas RTEMS-pc686 and its -qemu version will only build when RTEMS_VERSION == 5 (there are checks with descriptive errors included). makeTestFile.pl was also reformatted and modified to use exec to run tests on non-Windows hosts as required by the Perl test harness. --- configure/os/CONFIG.Common.RTEMS-pc386 | 17 ++- configure/os/CONFIG.Common.RTEMS-pc386-qemu | 3 +- configure/os/CONFIG.Common.RTEMS-pc686 | 17 ++- configure/os/CONFIG.Common.RTEMS-pc686-qemu | 11 ++ .../os/CONFIG_SITE.Common.RTEMS-pc386-qemu | 2 +- .../os/CONFIG_SITE.Common.RTEMS-pc686-qemu | 9 ++ src/tools/makeTestfile.pl | 100 ++++++++---------- 7 files changed, 88 insertions(+), 71 deletions(-) create mode 100644 configure/os/CONFIG.Common.RTEMS-pc686-qemu create mode 100644 configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu diff --git a/configure/os/CONFIG.Common.RTEMS-pc386 b/configure/os/CONFIG.Common.RTEMS-pc386 index bb4f3e7c7..9fc518d6b 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386 +++ b/configure/os/CONFIG.Common.RTEMS-pc386 @@ -1,10 +1,10 @@ +# CONFIG.Common.RTEMS-pc386 # -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment +# Definitions for the RTEMS-pc386 target, RTEMS 4.x only +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc386 # +#------------------------------------------------------- + RTEMS_BSP = pc386 RTEMS_TARGET_CPU = i386 GNU_TARGET = i386-rtems @@ -23,3 +23,10 @@ include $(CONFIG)/os/CONFIG.Common.RTEMS # Put text segment where it will work with etherboot # OP_SYS_LDFLAGS += -Wl,-Ttext,0x100000 + +# This check must appear after the above include +ifeq ($(RTEMS_VERSION),5) + $(info *** This target is not compatible with the configured RTEMS version.) + $(info *** Build the RTEMS-pc686 (-qemu) target for RTEMS 5.x) + $(error Can't continue) +endif diff --git a/configure/os/CONFIG.Common.RTEMS-pc386-qemu b/configure/os/CONFIG.Common.RTEMS-pc386-qemu index 29196ff65..684f01a19 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG.Common.RTEMS-pc386-qemu @@ -6,7 +6,6 @@ #------------------------------------------------------- # Include definitions from RTEMS-pc386 -# For Tests overwrite it with pc686 -include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc386 RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG.Common.RTEMS-pc686 b/configure/os/CONFIG.Common.RTEMS-pc686 index 43849744f..7f9446e1e 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc686 +++ b/configure/os/CONFIG.Common.RTEMS-pc686 @@ -1,10 +1,10 @@ +# CONFIG.Common.RTEMS-pc686 # -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment +# Definitions for the RTEMS-pc686 target, RTEMS 5.x only +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc686 # +#------------------------------------------------------- + RTEMS_BSP = pc686 RTEMS_TARGET_CPU = i386 GNU_TARGET = i386-rtems @@ -23,3 +23,10 @@ include $(CONFIG)/os/CONFIG.Common.RTEMS # Put text segment where it will work with etherboot # OP_SYS_LDFLAGS += -Wl,-Ttext,0x100000 + +# This check must appear after the above include +ifneq ($(RTEMS_VERSION),5) + $(info *** This target is not compatible with the configured RTEMS version.) + $(info *** Build the RTEMS-pc386 (-qemu) target for RTEMS 4.x) + $(error Can't continue) +endif diff --git a/configure/os/CONFIG.Common.RTEMS-pc686-qemu b/configure/os/CONFIG.Common.RTEMS-pc686-qemu new file mode 100644 index 000000000..1de543a30 --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-pc686-qemu @@ -0,0 +1,11 @@ +# CONFIG.Common.RTEMS-pc686-qemu +# +# Definitions for the RTEMS-pc686-qemu target +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc686-qemu +# +#------------------------------------------------------- + +# Include definitions from RTEMS-pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 + +RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu b/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu index 027dcf4ab..0f930c5d9 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu @@ -6,4 +6,4 @@ # If you're building this architecture you _probably_ want to # run the tests for it under QEMU, but if not you can turn # them off here by commenting out this line: -CROSS_COMPILER_RUNTEST_ARCHS += RTEMS-pc386-qemu +CROSS_COMPILER_RUNTEST_ARCHS += $(T_A) diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu b/configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu new file mode 100644 index 000000000..4ed2ed36c --- /dev/null +++ b/configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu @@ -0,0 +1,9 @@ +# CONFIG_SITE.Common.RTEMS-pc686-qemu +# +# Site-specific overrides for the RTEMS-pc686-qemu target +# + +# If you're building this architecture you _probably_ want to +# run the tests for it under QEMU, but if not you can turn +# them off here by commenting out this line: +CROSS_COMPILER_RUNTEST_ARCHS += $(T_A) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index e9643783d..efac61aba 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -24,75 +24,59 @@ use strict; my ($TA, $HA, $target, $exe) = @ARGV; -my $exec; +my ($exec, $error); -# Use WINE to run windows target executables on non-windows host -if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { - # new deb. derivatives have wine32 and wine64 - # older have wine and wine64 - # prefer wine32 if present - my $wine32 = "/usr/bin/wine32"; - $wine32 = "/usr/bin/wine" if ! -x $wine32; - $exec = "$wine32 $exe"; -} elsif( $TA =~ /^windows-x64/ && $HA !~ /^win/ ) { - $exec = "wine64 $exe"; - -# Run pc386 test harness w/ QEMU -} elsif( $TA =~ /^RTEMS-pc386-qemu$/ ) { - $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=e1000 -net nic,model=ne2k_pci -net user,restrict=yes -append --console=/dev/com1 -kernel $exe"; - -# Explicitly fail for other RTEMS targets -} elsif( $TA =~ /^RTEMS-/ ) { - die "$0: I don't know how to create scripts for testing $TA on $HA\n"; - -} else { - $exec = "./$exe"; +if ($TA =~ /^win32-x86/ && $HA !~ /^win/) { + # Use WINE to run win32-x86 executables on non-windows hosts. + # New Debian derivatives have wine32 and wine64, older ones have + # wine and wine64. We prefer wine32 if present. + my $wine32 = "/usr/bin/wine32"; + $wine32 = "/usr/bin/wine" if ! -x $wine32; + $error = $exec = "$wine32 $exe"; +} +elsif ($TA =~ /^windows-x64/ && $HA !~ /^win/) { + # Use WINE to run windows-x64 executables on non-windows hosts. + $error = $exec = "wine64 $exe"; +} +elsif ($TA =~ /^RTEMS-pc[36]86-qemu$/) { + # Run the pc386 and pc686 test harness w/ QEMU + $exec = "qemu-system-i386 -m 64 -no-reboot " + . "-serial stdio -display none " + . "-net nic,model=e1000 -net nic,model=ne2k_pci " + . "-net user,restrict=yes " + . "-append --console=/dev/com1 " + . "-kernel $exe"; + $error = "qemu-system-i386 ... -kernel $exe"; +} +elsif ($TA =~ /^RTEMS-/) { + # Explicitly fail for other RTEMS targets + die "$0: I don't know how to create scripts for testing $TA on $HA\n"; +} +else { + # Assume it's directly executable on other targets + $error = $exec = "./$exe"; } -# Ensure that Windows interactive error handling is disabled. -# This setting is inherited by the test process. -# Set SEM_FAILCRITICALERRORS (1) Disable critical-error-handler dialog -# Clear SEM_NOGPFAULTERRORBOX (2) Enabled WER to allow automatic post mortem debugging (AeDebug) -# Clear SEM_NOALIGNMENTFAULTEXCEPT (4) Allow alignment fixups -# Set SEM_NOOPENFILEERRORBOX (0x8000) Prevent dialog on some I/O errors -# https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode?redirectedfrom=MSDN -my $sem = $^O ne 'MSWin32' ? '' : <import(\$sem); - }; - eval { - require Win32API::File; - Win32API::File->import(\$sem); - } if \$@; - SetErrorMode(0x8001) unless \$@; -} -ENDBEGIN +# Run the test program with system on Windows, exec elsewhere. +# This is required by the Perl test harness. +my $runtest = ($^O eq 'MSWin32') ? + "system('$exec') == 0" : "exec '$exec'"; -open(my $OUT, '>', $target) or die "Can't create $target: $!\n"; +open my $OUT, '>', $target + or die "Can't create $target: $!\n"; -print $OUT <> 8; -} -else { - exec '$exec' or die "Can't run $exec: \$!\\n"; -} -EOF +$runtest + or die "Can't run $error: \$!\\n"; +__EOF__ -close $OUT or die "Can't close $target: $!\n"; +close $OUT + or die "Can't close $target: $!\n";