mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-02 02:03:20 +00:00
DM: VMcfg: support VM1 on MRB
Add build-in vm1 configuration for MRB platform, this is also an example about how to add new VM configurations Tracked-On: #1528 Acked-by: Yin Fengwei <fengwei.yin@intel.com> Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
This commit is contained in:
parent
ae5b32dcb3
commit
d2ed9955fd
@ -134,6 +134,7 @@ SRCS += arch/x86/pm.c
|
||||
|
||||
# vmcfg
|
||||
SRCS += vmcfg/vmcfg.c
|
||||
SRCS += vmcfg/apl-mrb/vm1/vm1.c
|
||||
|
||||
OBJS := $(patsubst %.c,$(DM_OBJDIR)/%.o,$(SRCS))
|
||||
|
||||
|
@ -16,4 +16,5 @@ struct vmcfg_arg {
|
||||
extern struct vmcfg_arg **args_buildin;
|
||||
extern int num_args_buildin;
|
||||
|
||||
extern struct vmcfg_arg mrb_vm1_args;
|
||||
#endif
|
||||
|
@ -3,3 +3,5 @@ mainmenu "VM Configuration"
|
||||
config VM_CFG
|
||||
bool "Enable build-in VM configuration"
|
||||
default n
|
||||
|
||||
source "apl-mrb/vm1/Kconfig"
|
||||
|
375
devicemodel/vmcfg/apl-mrb/vm1/Kconfig
Normal file
375
devicemodel/vmcfg/apl-mrb/vm1/Kconfig
Normal file
@ -0,0 +1,375 @@
|
||||
menuconfig MRB_VM1
|
||||
bool "Build-in VM1 configuration for MRB"
|
||||
default n
|
||||
depends on VM_CFG
|
||||
|
||||
config MRB_VM1_NAME
|
||||
string "Name of VM1"
|
||||
default "mrb-vm1-aaag"
|
||||
depends on MRB_VM1
|
||||
|
||||
menuconfig MRB_VM1_UUID
|
||||
bool "UUID of VM1"
|
||||
default n
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_UUID_VAL
|
||||
string "UUID Value"
|
||||
default "2d26d588-485d-11e8-8e17-d368e4b04324"
|
||||
depends on MRB_VM1_UUID
|
||||
|
||||
config MRB_VM1_ACPI
|
||||
bool "create ACPI tables"
|
||||
default y
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_MEM
|
||||
int "memory size in MB"
|
||||
default 1750
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_CPU
|
||||
int "# cpus (default 1)"
|
||||
default 3
|
||||
depends on MRB_VM1
|
||||
|
||||
menuconfig MRB_VM1_VSBL
|
||||
bool "VSBL file"
|
||||
default y
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_VSBL_IMAGE
|
||||
string "vsbl path"
|
||||
default "/usr/share/acrn/bios/VSBL.bin"
|
||||
depends on MRB_VM1_VSBL
|
||||
|
||||
menuconfig MRB_VM1_GVT
|
||||
bool "GVT Support"
|
||||
default y
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_GVT_DEV
|
||||
string "GVT device"
|
||||
default "2,pci-gvt"
|
||||
depends on MRB_VM1_GVT
|
||||
|
||||
config MRB_VM1_GVT_ARG
|
||||
string "GVT args"
|
||||
default "64 448 8"
|
||||
depends on MRB_VM1_GVT
|
||||
|
||||
menuconfig MRB_VM1_HOSTBRIDGE
|
||||
bool "pci hostbridge"
|
||||
default y
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_HOSTBRIDGE_OPT
|
||||
string "optional args"
|
||||
default "0:0,hostbridge"
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
menuconfig MRB_VM1_NPK
|
||||
bool "NPK device"
|
||||
default n
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_NPK_OPT
|
||||
string "optional args"
|
||||
default "-s 0:0:2,npk,8/24"
|
||||
depends on MRB_VM1_NPK
|
||||
|
||||
menuconfig MRB_VM1_USB_XHCI
|
||||
bool "USB xHCI"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_USB_XHCI_OPT
|
||||
string "optional args"
|
||||
default "7,xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl"
|
||||
depends on MRB_VM1_USB_XHCI
|
||||
|
||||
menuconfig MRB_VM1_VIRTIO_RPMB
|
||||
bool "virtio-_rpmb"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_VIRTIO_RPMB_OPT
|
||||
string "optional args"
|
||||
default "13,virtio-rpmb"
|
||||
depends on MRB_VM1_VIRTIO_RPMB
|
||||
|
||||
menuconfig MRB_VM1_VIRTIO_HYPER_DMABUF
|
||||
bool "virtio-hypey_dmabuf"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_VIRTIO_HYPER_DMABUF_OPT
|
||||
string "optional args"
|
||||
default "10,virtio-hyper_dmabuf"
|
||||
depends on MRB_VM1_VIRTIO_HYPER_DMABUF
|
||||
|
||||
menuconfig MRB_VM1_WDT_I6300ESB
|
||||
bool "wdt-i6300esb"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_WDT_I6300ESB_OPT
|
||||
string "optional args"
|
||||
default "11,wdt-i6300esb"
|
||||
depends on MRB_VM1_WDT_I6300ESB
|
||||
|
||||
menuconfig MRB_VM1_VIRTIO_BLK
|
||||
bool "virtio block device"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_VIRTIO_BLK_OPT
|
||||
string "optional args"
|
||||
default "3,virtio-blk,b,/data/android/android.img"
|
||||
depends on MRB_VM1_VIRTIO_BLK
|
||||
|
||||
menuconfig MRB_VM1_VIRTIO_NET
|
||||
bool "virtio net device"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_VIRTIO_NET_OPT
|
||||
string "optional args"
|
||||
default "9,virtio-net,tap_AaaG"
|
||||
depends on MRB_VM1_VIRTIO_NET
|
||||
|
||||
menuconfig MRB_VM1_VIRTIO_IPU
|
||||
bool "virtio IPU"
|
||||
default n
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
config MRB_VM1_VIRTIO_IPU_OPT
|
||||
string "optional args"
|
||||
default "21,virtio-ipu"
|
||||
depends on MRB_VM1_VIRTIO_IPU
|
||||
|
||||
menuconfig MRB_VM1_PTDEV
|
||||
bool "passthrough device"
|
||||
default y
|
||||
depends on MRB_VM1_HOSTBRIDGE
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_USB
|
||||
bool "USB passthrough"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_USB_OPT_1
|
||||
string "optional args"
|
||||
default "8,passthru,0/15/1"
|
||||
depends on MRB_VM1_PTDEV_USB
|
||||
|
||||
config MRB_VM1_PTDEV_USB_ID_1
|
||||
string "Device ID"
|
||||
default "8086 5aaa"
|
||||
depends on MRB_VM1_PTDEV_USB
|
||||
|
||||
config MRB_VM1_PTDEV_USB_DEVINFO_1
|
||||
string "Device info"
|
||||
default "0000:00:15.1"
|
||||
depends on MRB_VM1_PTDEV_USB
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_AUDIO
|
||||
bool "audio device"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_AUDIO_OPT
|
||||
string "optional args"
|
||||
default "14,passthru,0/e/0,keep_gsi"
|
||||
depends on MRB_VM1_PTDEV_AUDIO
|
||||
|
||||
config MRB_VM1_PTDEV_AUDIO_ID
|
||||
string "Device ID"
|
||||
default "8086 5a98"
|
||||
depends on MRB_VM1_PTDEV_AUDIO
|
||||
|
||||
config MRB_VM1_PTDEV_AUDIO_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:0e.0"
|
||||
depends on MRB_VM1_PTDEV_AUDIO
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_AUDIO_CODEC
|
||||
bool "audio codec"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_AUDIO_CODEC_OPT
|
||||
string "optional args"
|
||||
default "23,passthru,0/17/0"
|
||||
depends on MRB_VM1_PTDEV_AUDIO_CODEC
|
||||
|
||||
config MRB_VM1_PTDEV_AUDIO_CODEC_ID
|
||||
string "Device ID"
|
||||
default "8086 5ab4"
|
||||
depends on MRB_VM1_PTDEV_AUDIO_CODEC
|
||||
|
||||
config MRB_VM1_PTDEV_AUDIO_CODEC_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:17.0"
|
||||
depends on MRB_VM1_PTDEV_AUDIO_CODEC
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_CSME
|
||||
bool "Converged Security Manageability Engine"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_CSME_OPT
|
||||
string "optional args"
|
||||
default "15,passthru,0/f/0"
|
||||
depends on MRB_VM1_PTDEV_CSME
|
||||
|
||||
config MRB_VM1_PTDEV_CSME_ID
|
||||
string "Device ID"
|
||||
default "8086 5a9a"
|
||||
depends on MRB_VM1_PTDEV_CSME
|
||||
|
||||
config MRB_VM1_PTDEV_CSME_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:0f.0"
|
||||
depends on MRB_VM1_PTDEV_CSME
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_IPU
|
||||
bool "IPU passthrough"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_IPU_OPT
|
||||
string "IPU passthrough optional args"
|
||||
default "12,passthru,0/3/0"
|
||||
depends on MRB_VM1_PTDEV_IPU
|
||||
|
||||
config MRB_VM1_PTDEV_IPU_ID
|
||||
string "Device ID"
|
||||
default "8086 5a88"
|
||||
depends on MRB_VM1_PTDEV_IPU
|
||||
|
||||
config MRB_VM1_PTDEV_IPU_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:03.0"
|
||||
depends on MRB_VM1_PTDEV_IPU
|
||||
|
||||
config MRB_VM1_PTDEV_IPU_I2C
|
||||
string "Related I2C optional args"
|
||||
default "22,passthru,0/16/0"
|
||||
depends on MRB_VM1_PTDEV_IPU
|
||||
|
||||
config MRB_VM1_PTDEV_IPU_I2C_ID
|
||||
string "Device ID"
|
||||
default "8086 5aac"
|
||||
depends on MRB_VM1_PTDEV_IPU
|
||||
|
||||
config MRB_VM1_PTDEV_IPU_I2C_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:16.0"
|
||||
depends on MRB_VM1_PTDEV_IPU
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_SD
|
||||
bool "SD card passthrough"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_SD_OPT
|
||||
string "optional args"
|
||||
default "27,passthru,0/1b/0"
|
||||
depends on MRB_VM1_PTDEV_SD
|
||||
|
||||
config MRB_VM1_PTDEV_SD_ID
|
||||
string "Device ID"
|
||||
default "8086 5aca"
|
||||
depends on MRB_VM1_PTDEV_SD
|
||||
|
||||
config MRB_VM1_PTDEV_SD_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:1b.0"
|
||||
depends on MRB_VM1_PTDEV_SD
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_WIFI
|
||||
bool "wifi passthrough"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_WIFI_OPT
|
||||
string "optional args"
|
||||
default "18,passthru,3/0/0,keep_gsi"
|
||||
depends on MRB_VM1_PTDEV_WIFI
|
||||
|
||||
config MRB_VM1_PTDEV_WIFI_ID
|
||||
string "Device ID"
|
||||
default "11ab 2b38"
|
||||
depends on MRB_VM1_PTDEV_WIFI
|
||||
|
||||
config MRB_VM1_PTDEV_WIFI_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:03:00.0"
|
||||
depends on MRB_VM1_PTDEV_WIFI
|
||||
|
||||
menuconfig MRB_VM1_PTDEV_BLUETOOTH
|
||||
bool "Bluetooth passthrough"
|
||||
default y
|
||||
depends on MRB_VM1_PTDEV
|
||||
|
||||
config MRB_VM1_PTDEV_BLUETOOTH_OPT
|
||||
string "optional args"
|
||||
default "24,passthru,0/18/0"
|
||||
depends on MRB_VM1_PTDEV_BLUETOOTH
|
||||
|
||||
config MRB_VM1_PTDEV_BLUETOOTH_ID
|
||||
string "Device ID"
|
||||
default "8086 5abc"
|
||||
depends on MRB_VM1_PTDEV_BLUETOOTH
|
||||
|
||||
config MRB_VM1_PTDEV_BLUETOOTH_DEVINFO
|
||||
string "Device info"
|
||||
default "0000:00:18.0"
|
||||
depends on MRB_VM1_PTDEV_BLUETOOTH
|
||||
|
||||
menuconfig MRB_VM1_IOC
|
||||
bool "ioc"
|
||||
default y
|
||||
depends on MRB_VM1
|
||||
select MRB_VM1_LPC_COM2
|
||||
|
||||
config MRB_VM1_IOC_UART
|
||||
string "Virtual Uart Path"
|
||||
default "/run/acrn/ioc_"
|
||||
depends on MRB_VM1_IOC
|
||||
|
||||
config MRB_VM1_IOC_REASON
|
||||
string "Wakeup Reason"
|
||||
default "0x20"
|
||||
depends on MRB_VM1_IOC
|
||||
|
||||
menuconfig MRB_VM1_LPC
|
||||
bool "lpc"
|
||||
default y
|
||||
depends on MRB_VM1
|
||||
|
||||
config MRB_VM1_LPC_OPT
|
||||
string "lpc optional args"
|
||||
default "1:0,lpc"
|
||||
depends on MRB_VM1_LPC
|
||||
|
||||
config MRB_VM1_LPC_COM1
|
||||
bool "lpc com1"
|
||||
default y
|
||||
depends on MRB_VM1_LPC
|
||||
|
||||
config MRB_VM1_LPC_COM1_OPT
|
||||
string "optional args"
|
||||
default "com1,stdio"
|
||||
depends on MRB_VM1_LPC_COM1
|
||||
|
||||
config MRB_VM1_LPC_COM2
|
||||
bool "lpc com2"
|
||||
default y
|
||||
depends on MRB_VM1_LPC
|
||||
|
||||
config MRB_VM1_LPC_COM2_OPT
|
||||
string "optional args"
|
||||
default "com2,/run/acrn/ioc_"
|
||||
depends on MRB_VM1_LPC_COM2
|
294
devicemodel/vmcfg/apl-mrb/vm1/vm1.c
Normal file
294
devicemodel/vmcfg/apl-mrb/vm1/vm1.c
Normal file
@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (C)2018 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <vmcfg_config.h>
|
||||
#include <vmcfg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define TOSTR(X) #X
|
||||
#define STR(X) TOSTR(X)
|
||||
|
||||
#ifdef CONFIG_MRB_VM1
|
||||
static char cmdline_fmt[] = "maxcpus=" STR(CONFIG_MRB_VM1_CPU) " "
|
||||
"nohpet tsc=reliable intel_iommu=off "
|
||||
"androidboot.serialno=%s%s "
|
||||
"i915.enable_rc6=1 "
|
||||
"i915.enable_fbc=1 "
|
||||
"i915.enable_guc_loading=0 "
|
||||
"i915.avail_planes_per_pipe=0x070F00 "
|
||||
"i915.enable_hangcheck=0 "
|
||||
"use_nuclear_flip=1 "
|
||||
"i915.enable_guc_submission=0 "
|
||||
"i915.enable_guc=0 ";
|
||||
|
||||
static char kernel_cmdline[sizeof(cmdline_fmt) + 256];
|
||||
|
||||
static char *mrb_vm1_options[] = {
|
||||
NULL, /*Reserved for program name*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_UUID
|
||||
"-U", CONFIG_MRB_VM1_UUID_VAL,
|
||||
#endif /*CONFIG_MRB_VM1_UUID*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_ACPI
|
||||
"-A",
|
||||
#endif /*CONFIG_MRB_VM1_ACPI*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_MEM
|
||||
"-m", STR(CONFIG_MRB_VM1_MEM) "M",
|
||||
#endif /*CONFIG_MRB_VM1_MEN*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_CPU
|
||||
"-c", STR(CONFIG_MRB_VM1_CPU),
|
||||
#endif /*CONFIG_MRB_VM1_CPU*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_GVT
|
||||
"-s", CONFIG_MRB_VM1_GVT_DEV,
|
||||
"-G", CONFIG_MRB_VM1_GVT_ARG,
|
||||
#endif /*CONFIG_MRB_VM1_GVT*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_HOSTBRIDGE
|
||||
"-s", CONFIG_MRB_VM1_HOSTBRIDGE_OPT,
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_USB_XHCI
|
||||
"-s", CONFIG_MRB_VM1_USB_XHCI_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_USB_XHCI*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_USB
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_USB_OPT_1,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_USB*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_VIRTIO_RPMB
|
||||
"-s", CONFIG_MRB_VM1_VIRTIO_RPMB_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_VIRTIO_RPMB*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_VIRTIO_HYPER_DMABUF
|
||||
"-s", CONFIG_MRB_VM1_VIRTIO_HYPER_DMABUF_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_VIRTIO_HYPER_DMABUF*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_WDT_I6300ESB
|
||||
"-s", CONFIG_MRB_VM1_WDT_I6300ESB_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_WDT_I6300ESB*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_VIRTIO_BLK
|
||||
"-s", CONFIG_MRB_VM1_VIRTIO_BLK_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_VIRTIO_BLK*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_VIRTIO_NET
|
||||
"-s", CONFIG_MRB_VM1_VIRTIO_NET_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_VIRTIO_NET*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_AUDIO
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_AUDIO_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_AUDIO*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_AUDIO_CODEC
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_AUDIO_CODEC_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_AUDIO_CODEC*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_CSME
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_CSME_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_CSME */
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_IPU
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_IPU_OPT, /*ipu device*/
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_IPU_I2C, /*ipu related i2c*/
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_IPU*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_SD
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_SD_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_SD*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_WIFI
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_WIFI_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_WIFI*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_BLUETOOTH
|
||||
"-s", CONFIG_MRB_VM1_PTDEV_BLUETOOTH_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_BLUETOOTH*/
|
||||
|
||||
#endif /*CONFIG_MRB_VM1_HOSTBRIDGE */
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_LPC
|
||||
"-s", CONFIG_MRB_VM1_LPC_OPT,
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_IOC
|
||||
"-i", CONFIG_MRB_VM1_IOC_UART CONFIG_MRB_VM1_NAME ","
|
||||
CONFIG_MRB_VM1_IOC_REASON,
|
||||
#endif /*CONFIG_MRB_VM1_IOC */
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_LPC_COM1
|
||||
"-l", CONFIG_MRB_VM1_LPC_COM1_OPT,
|
||||
#endif /*CONFIG_MRB_VM1_LPC_COM1 */
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_LPC_COM2
|
||||
"-l", CONFIG_MRB_VM1_LPC_COM2_OPT CONFIG_MRB_VM1_NAME,
|
||||
#endif /*CONFIG_MRB_VM1_LPC_COM2 */
|
||||
|
||||
#endif /*CONFIG_MRB_VM1_LPC */
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_VSBL_IMAGE
|
||||
"--vsbl", CONFIG_MRB_VM1_VSBL_IMAGE,
|
||||
#endif /*CONFIG_MRB_VM1_VSBL_IMAGE */
|
||||
|
||||
"--enable_trusty",
|
||||
|
||||
/*command line */
|
||||
"-B",
|
||||
|
||||
kernel_cmdline,
|
||||
|
||||
/* VM name */
|
||||
CONFIG_MRB_VM1_NAME,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV
|
||||
#define PCI_UNBIND_PATH(X) \
|
||||
"/sys/bus/pci/devices/" X "/driver/unbind"
|
||||
|
||||
static int pci_dev_unbind(char *path, char *bdf)
|
||||
{
|
||||
int fd = -1;
|
||||
int ret = -1;
|
||||
|
||||
fd = open(path, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror(path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = write(fd, bdf, strnlen(bdf, 64));
|
||||
if (ret != strnlen(bdf, 64)) {
|
||||
perror(bdf);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pci_dev_newid(char *id)
|
||||
{
|
||||
int fd = -1;
|
||||
int ret = -1;
|
||||
|
||||
fd = open("/sys/bus/pci/drivers/pci-stub/new_id", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("/sys/bus/pci/drivers/pci-stub/new_id");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = write(fd, id, strnlen(id, 64));
|
||||
if (ret != strnlen(id, 64)) {
|
||||
perror(id);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define PTDEV_SETUP(ID, DEVINFO) \
|
||||
do { \
|
||||
pci_dev_newid(ID); \
|
||||
pci_dev_unbind(PCI_UNBIND_PATH(DEVINFO), DEVINFO); \
|
||||
} while(0)
|
||||
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV*/
|
||||
|
||||
static void check_str(char *str, int len)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
if (str[i] < 0x20 || str[i] > 0x7e)
|
||||
str[i] = 0;
|
||||
}
|
||||
|
||||
static int mrb_vm1_setup(void)
|
||||
{
|
||||
char mmc_name[64] = {};
|
||||
char mmc_serial[64] = {};
|
||||
int ret = 0;
|
||||
int fd = -1;
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_USB
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_USB_ID_1,
|
||||
CONFIG_MRB_VM1_PTDEV_USB_DEVINFO_1);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_USB*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_AUDIO
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_AUDIO_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_AUDIO_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_AUDIO*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_AUDIO_CODEC
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_AUDIO_CODEC_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_AUDIO_CODEC_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_AUDIO*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_CSME
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_CSME_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_CSME_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_CSME*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_IPU
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_IPU_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_IPU_DEVINFO);
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_IPU_I2C_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_IPU_I2C_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_IPU*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_SD
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_SD_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_SD_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_SD*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_WIFI
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_WIFI_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_WIFI_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_WIFI*/
|
||||
|
||||
#ifdef CONFIG_MRB_VM1_PTDEV_BLUETOOTH
|
||||
PTDEV_SETUP(CONFIG_MRB_VM1_PTDEV_BLUETOOTH_ID,
|
||||
CONFIG_MRB_VM1_PTDEV_BLUETOOTH_DEVINFO);
|
||||
#endif /*CONFIG_MRB_VM1_PTDEV_BLUETOOTH*/
|
||||
|
||||
memset(kernel_cmdline, 0, sizeof(kernel_cmdline));
|
||||
|
||||
fd = open("/sys/block/mmcblk1/device/name", O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
ret = read(fd, mmc_name, sizeof(mmc_name));
|
||||
if (ret >= sizeof(mmc_name))
|
||||
mmc_name[sizeof(mmc_name) - 1] = 0;
|
||||
check_str(mmc_name, sizeof(mmc_name));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
fd = open("/sys/block/mmcblk1/device/serial", O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
ret = read(fd, mmc_serial, sizeof(mmc_serial));
|
||||
if (ret >= sizeof(mmc_serial))
|
||||
mmc_name[sizeof(mmc_serial) - 1] = 0;
|
||||
check_str(mmc_serial, sizeof(mmc_serial));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
snprintf(kernel_cmdline, sizeof(kernel_cmdline) - 1, cmdline_fmt,
|
||||
mmc_name, mmc_serial);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct vmcfg_arg mrb_vm1_args = {
|
||||
.argv = mrb_vm1_options,
|
||||
.argc = sizeof(mrb_vm1_options) / sizeof(char *),
|
||||
.setup = mrb_vm1_setup,
|
||||
};
|
||||
#endif /*CONFIG_MRB_VM1 */
|
@ -7,6 +7,9 @@
|
||||
#include <vmcfg.h>
|
||||
|
||||
static struct vmcfg_arg *vmcfg_buildin_args[] = {
|
||||
#ifdef CONFIG_MRB_VM1
|
||||
&mrb_vm1_args,
|
||||
#endif /*CONFIG_MRB_VM1*/
|
||||
};
|
||||
|
||||
struct vmcfg_arg **args_buildin = vmcfg_buildin_args;
|
||||
|
Loading…
Reference in New Issue
Block a user