Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Brian Cain <[email protected]>
---
MAINTAINERS | 2 +
docs/system/hexagon/cdsp.rst | 48 +++++++++++++++
.gitignore | 1 +
.gitmodules | 3 +
pc-bios/README | 7 +++
pc-bios/hexagon-hypervisor-license.txt | 26 ++++++++
pc-bios/meson.build | 11 ++++
roms/Makefile | 83 ++++++++++++++++++++++++++
roms/hexagon-hypervisor | 1 +
9 files changed, 182 insertions(+)
create mode 100644 pc-bios/hexagon-hypervisor-license.txt
create mode 160000 roms/hexagon-hypervisor
diff --git a/MAINTAINERS b/MAINTAINERS
index 70e9fed7769..3b12ba90f21 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1397,6 +1397,8 @@ F: tests/functional/hexagon/
F: tests/qtest/hexagon-config-test.c
F: tests/qtest/qcom-dsp-test.c
F: docs/devel/hexagon-sys.rst
+F: pc-bios/hexagon*
+F: roms/hexagon-hypervisor
LoongArch Machines
------------------
diff --git a/docs/system/hexagon/cdsp.rst b/docs/system/hexagon/cdsp.rst
index 237529273cb..8d3a1f611b0 100644
--- a/docs/system/hexagon/cdsp.rst
+++ b/docs/system/hexagon/cdsp.rst
@@ -10,3 +10,51 @@ A Hexagon CDSP is designed as a computation offload device
for an SoC. The
* QTimer timer device
This machine will support any Hexagon CPU, but will default to ``v66``.
+
+H2 boot firmware
+----------------
+
+These machines can be started through the H2 hypervisor images shipped in
+``pc-bios``, selected with ``-bios``:
+
+.. list-table::
+ :header-rows: 1
+
+ * - Machine
+ - CPU
+ - ``-kernel`` address
+ - Image suffix
+ * - ``qcs6490-cdsp``
+ - ``v68``
+ - ``0xa1000000``
+ - ``qcs6490_cdsp``
+ * - ``sa8775p-cdsp``
+ - ``v73``
+ - ``0xa0000000``
+ - ``sa8775p_cdsp``
+ * - ``sm8975-nsp``
+ - ``v85``
+ - ``0xa0000000``
+ - ``sm8975_nsp``
+ * - ``sc8480xp-nsp0``
+ - ``v81``
+ - ``0xa0000000``
+ - ``sc8480xp_nsp0``
+ * - ``sa8797p-nsp0``
+ - ``v81``
+ - ``0xa0000000``
+ - ``sa8797p_nsp0``
+
+``hexagon_booter_<suffix>``
+ H2 plus a loader that reads guest ELF files from the host through QEMU
+ semihosting::
+
+ qemu-system-hexagon -M qcs6490-cdsp -serial stdio -display none \
+ -bios hexagon_booter_qcs6490_cdsp \
+ -semihosting-config enable=on,target=native,arg=booter,arg=guest.elf
+
+ Guests are loaded at ``0xa2000000``.
+
+``hexagon_loadlinux_<suffix>``
+ H2 plus a loader that starts a kernel which QEMU has placed at the
+ ``-kernel`` address in the table above.
diff --git a/.gitignore b/.gitignore
index 61fa39967b5..7ea1afbb4e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
/GNUmakefile
/build/
+/roms/hexagon-firmware-build/
/.cache/
/.vscode/
*.pyc
diff --git a/.gitmodules b/.gitmodules
index c307216d173..7042b599f65 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -45,3 +45,6 @@
[submodule "tests/lcitool/libvirt-ci"]
path = tests/lcitool/libvirt-ci
url = https://gitlab.com/libvirt/libvirt-ci.git
+[submodule "roms/hexagon-hypervisor"]
+ path = roms/hexagon-hypervisor
+ url = https://gitlab.com/qemu-project/hexagon-hypervisor.git
diff --git a/pc-bios/README b/pc-bios/README
index 2f8a565245f..661feddf3ac 100644
--- a/pc-bios/README
+++ b/pc-bios/README
@@ -1,6 +1,13 @@
- SeaBIOS (bios.bin) is the successor of pc bios.
See http://www.seabios.org/ for more information.
+- hexagon_booter_<machine> and hexagon_loadlinux_<machine> are the H2
+ hypervisor firmware for the Hexagon machines. The sources are at
+ https://gitlab.com/qemu-project/hexagon-hypervisor, built from commit
+ 23d5bde4313c1e63ba64dd5d7f542b1055188ef8 with Hexagon SDK 6.7.0.0
+ via "make -C roms hexagon-<machine>". H2 is distributed under the terms
+ given in "hexagon-hypervisor-license.txt".
+
- The VGA BIOS and the Cirrus VGA BIOS come from the LGPL VGA bios
project (http://www.nongnu.org/vgabios/).
diff --git a/pc-bios/hexagon-hypervisor-license.txt
b/pc-bios/hexagon-hypervisor-license.txt
new file mode 100644
index 00000000000..389b5477129
--- /dev/null
+++ b/pc-bios/hexagon-hypervisor-license.txt
@@ -0,0 +1,26 @@
+Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/pc-bios/meson.build b/pc-bios/meson.build
index 961d99fde4e..05cb2d40d9c 100644
--- a/pc-bios/meson.build
+++ b/pc-bios/meson.build
@@ -73,6 +73,17 @@ blobs = [
'edk2-licenses.txt',
'hppa-firmware.img',
'hppa-firmware64.img',
+ 'hexagon_booter_qcs6490_cdsp',
+ 'hexagon_loadlinux_qcs6490_cdsp',
+ 'hexagon_booter_sm8975_nsp',
+ 'hexagon_loadlinux_sm8975_nsp',
+ 'hexagon_booter_sa8775p_cdsp',
+ 'hexagon_loadlinux_sa8775p_cdsp',
+ 'hexagon_booter_sc8480xp_nsp0',
+ 'hexagon_loadlinux_sc8480xp_nsp0',
+ 'hexagon_booter_sa8797p_nsp0',
+ 'hexagon_loadlinux_sa8797p_nsp0',
+ 'hexagon-hypervisor-license.txt',
'opensbi-riscv32-generic-fw_dynamic.bin',
'opensbi-riscv64-generic-fw_dynamic.bin',
'npcm7xx_bootrom.bin',
diff --git a/roms/Makefile b/roms/Makefile
index f15189a5409..bae8f3b766b 100644
--- a/roms/Makefile
+++ b/roms/Makefile
@@ -74,6 +74,11 @@ default help:
@echo " opensbi64-generic -- update OpenSBI for 64-bit generic
machine"
@echo " qboot -- update qboot"
@echo " hppa-firmware -- update 32- and 64-bit hppa firmware"
+ @echo " hexagon-qcs6490-cdsp -- update H2 firmware for qcs6490-cdsp"
+ @echo " hexagon-sm8975-nsp -- update H2 firmware for sm8975-nsp"
+ @echo " hexagon-sa8775p-cdsp -- update H2 firmware for sa8775p-cdsp"
+ @echo " hexagon-sc8480xp-nsp0 -- update H2 firmware for sc8480xp-nsp0"
+ @echo " hexagon-sa8797p-nsp0 -- update H2 firmware for sa8797p-nsp0"
@echo " clean -- delete the files generated by the
previous" \
"build targets"
@@ -211,6 +216,83 @@ hppa-firmware:
cp seabios-hppa/out/hppa-firmware.img ../pc-bios/
cp seabios-hppa/out-64/hppa-firmware64.img ../pc-bios/
+# Needs Hexagon SDK on PATH.
+hexagon_h2_build := hexagon-firmware-build
+hexagon_h2_src := $(CURDIR)/hexagon-hypervisor
+hexagon_h2_out = $(CURDIR)/$(hexagon_h2_build)
+hexagon_h2_booters := hexagon-booter-qcs6490-cdsp \
+ hexagon-booter-sm8975-nsp hexagon-booter-sa8775p-cdsp \
+ hexagon-booter-sc8480xp-nsp0 hexagon-booter-sa8797p-nsp0
+hexagon_h2_loadlinux := hexagon-loadlinux-qcs6490-cdsp \
+ hexagon-loadlinux-sm8975-nsp hexagon-loadlinux-sa8775p-cdsp \
+ hexagon-loadlinux-sc8480xp-nsp0 hexagon-loadlinux-sa8797p-nsp0
+hexagon_h2_common_flags = USE_PKW=0 TARGET=opt NULL_ANGEL_TRAP=1 \
+ HMX_HLX_SUPPORT=1 \
+ H2K_LOAD_ADDR=0x9b800000 H2K_GUEST_START=0xa2000000 \
+ H2K_GIT_COMMIT=0x$(shell git -C hexagon-hypervisor rev-parse --short=8
HEAD) \
+ H2K_GIT_COMMIT_LONG=0x$(shell git -C hexagon-hypervisor rev-parse HEAD)
\
+ JFLAG=-j$(shell nproc)
+
+.PHONY: hexagon-qcs6490-cdsp hexagon-sm8975-nsp \
+ hexagon-sa8775p-cdsp hexagon-sc8480xp-nsp0 hexagon-sa8797p-nsp0 \
+ $(hexagon_h2_booters) $(hexagon_h2_loadlinux)
+
+hexagon-qcs6490-cdsp: hexagon-booter-qcs6490-cdsp \
+ hexagon-loadlinux-qcs6490-cdsp
+hexagon-sm8975-nsp: hexagon-booter-sm8975-nsp hexagon-loadlinux-sm8975-nsp
+hexagon-sa8775p-cdsp: hexagon-booter-sa8775p-cdsp \
+ hexagon-loadlinux-sa8775p-cdsp
+hexagon-sc8480xp-nsp0: hexagon-booter-sc8480xp-nsp0 \
+ hexagon-loadlinux-sc8480xp-nsp0
+hexagon-sa8797p-nsp0: hexagon-booter-sa8797p-nsp0 \
+ hexagon-loadlinux-sa8797p-nsp0
+
+hexagon-booter-qcs6490-cdsp hexagon-loadlinux-qcs6490-cdsp: \
+ hexagon_h2_machine_flags = ARCHV=68
+hexagon-booter-sm8975-nsp hexagon-loadlinux-sm8975-nsp: \
+ hexagon_h2_machine_flags = ARCHV=81 TOOLARCH=85 KERNEL_TOOLARCH=85
+hexagon-booter-sa8775p-cdsp hexagon-loadlinux-sa8775p-cdsp: \
+ hexagon_h2_machine_flags = ARCHV=73
+hexagon-booter-sc8480xp-nsp0 hexagon-loadlinux-sc8480xp-nsp0: \
+ hexagon_h2_machine_flags = ARCHV=81
+hexagon-booter-sa8797p-nsp0 hexagon-loadlinux-sa8797p-nsp0: \
+ hexagon_h2_machine_flags = ARCHV=81
+
+hexagon-loadlinux-qcs6490-cdsp: hexagon_h2_linux_flags = \
+ LINUX_LINK_ADDR=0xa1000000
+hexagon-loadlinux-sm8975-nsp hexagon-loadlinux-sa8775p-cdsp \
+ hexagon-loadlinux-sc8480xp-nsp0 hexagon-loadlinux-sa8797p-nsp0: \
+ hexagon_h2_linux_flags = LINUX_LINK_ADDR=0xa0000000
+
+$(hexagon_h2_booters): hexagon-booter-%:
+ rm -rf $(hexagon_h2_out)/booter-$*
+ $(MAKE) -C hexagon-hypervisor $(hexagon_h2_common_flags) \
+ $(hexagon_h2_machine_flags) \
+ INSTALLPATH=$(hexagon_h2_out)/booter-$*/install
+ hexagon-strip --strip-debug -o ../pc-bios/hexagon_booter_$(subst
-,_,$*) \
+ $(hexagon_h2_build)/booter-$*/install/bin/booter
+ chmod -x ../pc-bios/hexagon_booter_$(subst -,_,$*)
+
+$(hexagon_h2_loadlinux): hexagon-loadlinux-%:
+ rm -rf $(hexagon_h2_out)/loadlinux-$*
+ $(MAKE) -C hexagon-hypervisor $(hexagon_h2_common_flags) \
+ $(hexagon_h2_machine_flags) \
+ INSTALLPATH=$(hexagon_h2_out)/loadlinux-$*/install
+ mkdir -p $(hexagon_h2_out)/loadlinux-$*/linux
+ $(MAKE) -C $(hexagon_h2_out)/loadlinux-$*/linux \
+ -f $(hexagon_h2_src)/linux/makefile -I $(hexagon_h2_src)/linux \
+ --eval='vpath %.c $(hexagon_h2_src)/linux' \
+ --eval='vpath %.S $(hexagon_h2_src)/linux' \
+ H2DIR=$(hexagon_h2_src) EXTRA_CFLAGS=-I$(hexagon_h2_src)/linux \
+ $(hexagon_h2_common_flags) $(hexagon_h2_machine_flags) \
+ NO_LOAD=1 NO_PRINT=1 $(hexagon_h2_linux_flags) \
+ INSTALLPATH=$(hexagon_h2_out)/loadlinux-$*/install \
+ KERNELPATH=$(hexagon_h2_out)/loadlinux-$*/build/kernel \
+ loadlinux
+ hexagon-strip --strip-debug -o ../pc-bios/hexagon_loadlinux_$(subst
-,_,$*) \
+ $(hexagon_h2_build)/loadlinux-$*/linux/loadlinux
+ chmod -x ../pc-bios/hexagon_loadlinux_$(subst -,_,$*)
+
clean:
rm -rf seabios/.config seabios/out seabios/builds
$(MAKE) -C ipxe/src veryclean
@@ -225,3 +307,4 @@ clean:
$(MAKE) -C qboot clean
$(MAKE) -C vbootrom clean
$(MAKE) -C seabios-hppa clean
+ rm -rf $(hexagon_h2_build)
diff --git a/roms/hexagon-hypervisor b/roms/hexagon-hypervisor
new file mode 160000
index 00000000000..23d5bde4313
--- /dev/null
+++ b/roms/hexagon-hypervisor
@@ -0,0 +1 @@
+Subproject commit 23d5bde4313c1e63ba64dd5d7f542b1055188ef8
--
2.34.1