#
# Test to trigger periodically ACPI suspend and resume and periodically
# trying to restart graphic driver, ps/2, ahci and nvme driver.
#
# Main test hardware so far:
# - Lenovo X201 - resume of intel/display + AHCI + PS/2 working
# - Lenovo T490 - resume of intel/display + NVME + PS/2 working + GPU
# - Qemu - resume happens, vesa_fb fails, ahci fails, nvme fails
#
# Not working: vesa_fb nor boot_fb after resume
# Untested: all other drivers, e.g. nic, wifi, sd_card, usb ... all others
#
# UART via Intel AMT SOL is most the time not working after resume. Using
# it may hang up the boot for unknown reasons. On X201 it must not be used to
# get reliable resume results! However using PCMCIA serial card in X201 seems
# ok.
#
# Thereby, by default serial output is disabled by this script for non Qemu.
assert_spec x86
if {
![have_spec hw] &&
![have_spec nova]
} {
puts "Platform is unsupported."
exit 0
}
if {[have_spec nova]} {
# enable logmem to get kernel logs in memory
proc kernel_output { } { return "logmem" }
}
# serial is not ever usable on hardware after resume, avoid hang by now
if {![have_include "power_on/qemu"]} {
# switch off serial device usage by kernel and core
proc boot_output { } { return "" }
}
# non Intel machines have no GPU support, e.g. Qemu and AMD
set board_non_intel [expr [have_include "power_on/qemu"]]
set use_gpu_client 1
set use_gpe "no"
set use_ahci 0
set use_nvme 0
set use_wifi 1
proc priority_timer { } { return {priority="0"} }
proc priority_base { } { return {priority="-1"} }
proc priority_config { } { return {priority="-1"} }
proc priority_gui { } { return {priority="-1"} }
proc priority_wm { } { return {priority="-2"} }
proc priority_log { } { return {priority="-2"} }
proc priority_drivers { } { return {priority="-2"} }
proc priority_scenario { } { return {priority="-3"} }
proc display_config { } {
global board_non_intel
if {$board_non_intel} {
return {
}
return $return_display
}
return {
}
}
proc restartable_drivers { } {
set return_drivers ""
append return_drivers {
} [display_config] {
} [input_config] {
} [wifi_config] {
}
return $return_drivers
}
proc gui_config { } {
set return_gui ""
append return_gui {
}
return $return_gui
}
proc input_config { } {
return {
}
}
proc log_output { } {
set return_log ""
append return_log {
}
append_if [have_spec nova] return_log {
}
return $return_log
}
proc ahci_config { } {
global use_ahci
set return_ahci ""
if {!$use_ahci} {
return $return_ahci
}
append return_ahci {
}
append return_ahci {
}
return $return_ahci
}
proc nvme_config { } {
global use_nvme
set return_nvme ""
if {!$use_nvme} {
return $return_nvme
}
append return_nvme {
}
append return_nvme {
}
return $return_nvme
}
proc gpu_config { } {
global board_non_intel
if {$board_non_intel} return
set return_gpu ""
append return_gpu {
}
return $return_gpu
}
proc gpu_client { } {
global board_non_intel
global use_gpu_client
if { $board_non_intel || !$use_gpu_client } return
set return_gpu ""
append return_gpu {
}
return $return_gpu
}
proc wifi_config { } {
global use_wifi
set return_wifi ""
if {!$use_wifi} { return $return_wifi }
append return_wifi {
}
return $return_wifi
}
build {
core timer init lib/ld
server/report_rom
server/dynamic_rom
server/rom_filter
driver/acpi
driver/platform
driver/framebuffer/intel/pc
driver/framebuffer/vesa
driver/framebuffer/boot
driver/gpu/intel
driver/ahci
driver/nvme
driver/rtc
app/acpica
app/pci_decode
app/block_tester
}
create_boot_directory
import_from_depot [depot_user]/src/init \
[depot_user]/src/nitpicker \
[depot_user]/src/ps2 \
[depot_user]/pkg/themed_wm \
[depot_user]/pkg/terminal \
[depot_user]/src/terminal_log \
[depot_user]/src/event_filter \
[depot_user]/raw/drivers_interactive-pc \
[depot_user]/src/report_rom \
[depot_user]/src/dynamic_rom \
[depot_user]/src/nano3d \
[depot_user]/src/log_core
if {$use_gpu_client} {
import_from_depot [depot_user]/pkg/glmark2
}
if {$use_wifi} {
import_from_depot [depot_user]/pkg/pc_wifi \
[depot_user]/raw/pc_wifi_firmware
}
set config ""
append config {
} [ gpu_config] {
} [ gui_config] {
} [ log_output] {
} [ gpu_client] {
} [ ahci_config] {
} [ nvme_config] {
}
install_config $config
build_boot_image [build_artifacts]
# qemu machine model q35 and multiple CPUs don't work with NOVA kernel
#
# src/lapic.cpp Acpi::delay(2) spins on PM_TMR forever
#
# According to qemu monitor "info mtree",
#
# address-space: I/O
# 0000000000000000-000000000000ffff (prio 0, i/o): io
# ...
# 0000000000000600-000000000000067f (prio 0, i/o): ich9-pm
# 0000000000000600-0000000000000603 (prio 0, i/o): acpi-evt
# 0000000000000604-0000000000000605 (prio 0, i/o): acpi-cnt
# 0000000000000608-000000000000060b (prio 0, i/o): acpi-tmr
# 0000000000000620-000000000000062f (prio 0, i/o): acpi-gpe0
# 0000000000000630-0000000000000637 (prio 0, i/o): acpi-smi
# 0000000000000660-000000000000067f (prio 0, i/o): sm-tco
#
# address-space: I/O
# 0000000000000000-000000000000ffff (prio 0, i/o): io
# 0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
# 0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
# 0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
# 0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
# 0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
# 0000000000000060-000000000000007f (prio 0, i/o): sm-tco
#
# the "ich9-pm" device behind/attached on a LPC PCI device
#
# ./hw/isa/lpc_ich9.c
# ./hw/acpi/ich9.c: memory_region_init(&pm->io, OBJECT(lpc_pci), "ich9-pm", ICH9_PMIO_SIZE)
#
# is not at the right i/o space right location anymore. It seems that the
# parent of ich9-pm stays disabled ...
#
# Further debugging shows:
#
# qemu/roms/seabios/src/resume.c s3_resume -> pci_resume
# qemu/roms/seabios/src/fw/pciinit.c pci_resume
#
# In pci_resume the mmcfg and q35 and ich9-pm for PCIe is tried to be
# re-enabled, but actually the calls never hit in Qemu.
# It seems that mch_mmconfig_setup should use I/O PCI access in order to
# enable MMIO PCI MMCFG access.
#
append qemu_args "-smp 1"
if {[have_include "power_on/qemu"] && $use_ahci} {
append qemu_args " -device ahci,id=ahci "
append qemu_args " -drive id=disk,file=bin/ext2.raw,format=raw,if=none"
append qemu_args " -device ide-hd,drive=disk,bus=ahci.0 "
#
# Build EXT2-file-system image
#
set mke2fs [installed_command mke2fs]
set dd [installed_command dd]
catch { exec $dd if=/dev/zero of=bin/ext2.raw bs=1M count=16 }
catch { exec $mke2fs -F bin/ext2.raw }
}
if {[have_include "power_on/qemu"] && $use_nvme} {
#
# Create raw image
#
set dd [installed_command dd]
catch { exec $dd if=/dev/zero of=bin/nvme.raw bs=1M count=32 }
append qemu_args " -device pcie-root-port,id=root_port1 "
append qemu_args " -drive id=nvme0,file=bin/nvme.raw,format=raw,if=none "
append qemu_args " -device nvme,drive=nvme0,serial=fnord,id=nvme0n1,bus=root_port1 "
}
run_genode_until forever