dde_linux: add virt_linux lx_emul flavor

To support device-less protocol-stacks only ports, we can use a
Virt I/O Linux kernel flavor, and export the lx_kit/lx_emul parts
not depending on platform API and devices.

Ref #4397
This commit is contained in:
Stefan Kalkowski 2022-03-07 15:32:00 +01:00
parent 35cf8aada4
commit 9713014130
8 changed files with 170 additions and 0 deletions

View File

@ -0,0 +1,12 @@
LIBS += virt_linux_generated
LX_SRC_DIR := $(call select_from_ports,linux)/src/linux
ifeq ($(wildcard $(LX_SRC_DIR)),)
LX_SRC_DIR := $(call select_from_repositories,src/linux)
endif
LX_GEN_DIR := $(LIB_CACHE_DIR)/virt_linux_generated
-include $(call select_from_repositories,lib/import/import-lx_emul_common.inc)
SRC_CC += lx_kit/memory_non_dma.cc

View File

@ -0,0 +1,2 @@
# the lx_emul libray exists only for the import file

View File

@ -0,0 +1,3 @@
LINUX_ARCH=x86_64
include $(REP_DIR)/lib/mk/virt_linux_generated.inc

View File

@ -0,0 +1,30 @@
CUSTOM_TARGET_DEPS := kernel_build.phony
LX_DIR := $(call select_from_ports,linux)/src/linux
PWD := $(shell pwd)
LX_MK_ARGS = ARCH=$(LINUX_ARCH) CROSS_COMPILE=$(CROSS_DEV_PREFIX)
#
# Linux kernel configuration
#
# define 'LX_ENABLE' and 'LX_DISABLE'
include $(REP_DIR)/src/virt_linux/target.inc
# filter for make output of kernel build system
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
kernel_config.tag:
$(MSG_CONFIG)Linux
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
$(VERBOSE)$(LX_DIR)/scripts/config $(addprefix --enable ,$(LX_ENABLE))
$(VERBOSE)$(LX_DIR)/scripts/config $(addprefix --disable ,$(LX_DISABLE))
$(VERBOSE)$(MAKE) $(LX_MK_ARGS) olddefconfig $(BUILD_OUTPUT_FILTER)
$(VERBOSE)$(MAKE) $(LX_MK_ARGS) prepare $(BUILD_OUTPUT_FILTER)
$(VERBOSE)touch $@
# update Linux kernel config on makefile changes
kernel_config.tag: $(MAKEFILE_LIST)
kernel_build.phony: kernel_config.tag

View File

@ -0,0 +1,14 @@
# RUN virt_linux under Qemu (x86_64)
qemu-system-x86_64 \
-no-kvm -m 512 \
-chardev stdio,id=virtiocon0 \
-device virtio-serial \
-device virtconsole,chardev=virtiocon0 \
-netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
-net nic,model=virtio,netdev=net0 \
-kernel virt_linux/x86_64/arch/x86_64/boot/bzImage \
-initrd busybox/initramfs.cpio.gz \
-append "console=hvc0 ip=dhcp"

View File

@ -0,0 +1,35 @@
#
# Linux kernel configuration
#
# kernel fundamentals
LX_ENABLE += TTY SERIAL_EARLYCON SERIAL_OF_PLATFORM PRINTK HAS_IOMEM
# initrd support
LX_ENABLE += BINFMT_ELF BLK_DEV_INITRD
# network infrastructure
LX_ENABLE += NET NETDEVICES
# PCI support
LX_ENABLE += PCI
# Virtio devices
LX_ENABLE += VIRTIO_MENU VIRTIO_PCI VIRTIO_NET VIRTIO_CONSOLE
# network protocols
LX_ENABLE += INET IP_PNP IP_PNP_DHCP
# random number generator
LX_ENABLE += HW_RANDOM ARCH_RANDOM RANDOM_TRUST_CPU RANDOM_TRUST_BOOTLOADER
LX_ENABLE += CRYPTO_JITTERENTROPY CRYPTO_ANSI_CPRNG HW_RANDOM_TIMERIOMEM
# wireguard driver
LX_ENABLE += WIREGUARD WIREGUARD_DEBUG
# disable optimization not possible in PIC code under Genode
LX_DISABLE += CC_HAS_ASM_GOTO
# slim down kernel by removing superfluous drivers
LX_DISABLE += HID HID_GENERIC USB_HID VGA_CONSOLE DUMMY_CONSOLE NLS VGA_ARB DEBUG_LIST
LX_DISABLE += INPUT_KEYBOARD INPUT_MOUSE WLAN WIRELESS ETHERNET

View File

@ -0,0 +1,37 @@
TARGET := x86_32_virt_linux
REQUIRES := x86_32
CUSTOM_TARGET_DEPS := kernel_build.phony
LX_DIR := $(call select_from_ports,linux)/src/linux
PWD := $(shell pwd)
LX_MK_ARGS = ARCH=x86 CROSS_COMPILE=$(CROSS_DEV_PREFIX)
#
# Linux kernel configuration
#
# Start with 'make tinyconfig', enable/disable options via 'scripts/config',
# and resolve config dependencies via 'make olddefconfig'.
#
# define 'LX_ENABLE' and 'LX_DISABLE'
include $(REP_DIR)/src/virt_linux/target.inc
# filter for make output of kernel build system
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
kernel_config.tag:
$(MSG_CONFIG)Linux
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
$(VERBOSE)$(LX_DIR)/scripts/config --file $(PWD)/.config $(addprefix --enable ,$(LX_ENABLE))
$(VERBOSE)$(LX_DIR)/scripts/config --file $(PWD)/.config $(addprefix --disable ,$(LX_DISABLE))
$(VERBOSE)$(MAKE) $(LX_MK_ARGS) olddefconfig $(BUILD_OUTPUT_FILTER)
$(VERBOSE)touch $@
# update Linux kernel config on makefile changes
kernel_config.tag: $(MAKEFILE_LIST)
kernel_build.phony: kernel_config.tag
$(MSG_BUILD)Linux
$(VERBOSE)$(MAKE) $(LX_MK_ARGS) bzImage $(BUILD_OUTPUT_FILTER)

View File

@ -0,0 +1,37 @@
TARGET := x86_64_virt_linux
REQUIRES := x86_64
CUSTOM_TARGET_DEPS := kernel_build.phony
LX_DIR := $(call select_from_ports,linux)/src/linux
PWD := $(shell pwd)
LX_MK_ARGS = ARCH=x86_64 CROSS_COMPILE=$(CROSS_DEV_PREFIX)
#
# Linux kernel configuration
#
# Start with 'make tinyconfig', enable/disable options via 'scripts/config',
# and resolve config dependencies via 'make olddefconfig'.
#
# define 'LX_ENABLE' and 'LX_DISABLE'
include $(REP_DIR)/src/virt_linux/target.inc
# filter for make output of kernel build system
BUILD_OUTPUT_FILTER = 2>&1 | sed "s/^/ [Linux] /"
kernel_config.tag:
$(MSG_CONFIG)Linux
$(VERBOSE)$(MAKE) -C $(LX_DIR) O=$(PWD) $(LX_MK_ARGS) tinyconfig $(BUILD_OUTPUT_FILTER)
$(VERBOSE)$(LX_DIR)/scripts/config --file $(PWD)/.config $(addprefix --enable ,$(LX_ENABLE))
$(VERBOSE)$(LX_DIR)/scripts/config --file $(PWD)/.config $(addprefix --disable ,$(LX_DISABLE))
$(VERBOSE)$(MAKE) $(LX_MK_ARGS) olddefconfig $(BUILD_OUTPUT_FILTER)
$(VERBOSE)touch $@
# update Linux kernel config on makefile changes
kernel_config.tag: $(MAKEFILE_LIST)
kernel_build.phony: kernel_config.tag
$(MSG_BUILD)Linux
$(VERBOSE)$(MAKE) $(LX_MK_ARGS) bzImage $(BUILD_OUTPUT_FILTER)