qemu_fwcfg.c (26d9f973d8691eccc098ded7326137d6f76ad243) | qemu_fwcfg.c (55c13f6e7a412cc4bd0ea3fc183cd7c5c2348f01) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG 5 * Author: Corvin Köhne <c.koehne@beckhoff.com> 6 */ 7 8#include <sys/param.h> --- 9 unchanged lines hidden (view full) --- 18#include <stdio.h> 19#include <stdlib.h> 20#include <string.h> 21#include <unistd.h> 22 23#include "acpi_device.h" 24#include "bhyverun.h" 25#include "inout.h" | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG 5 * Author: Corvin Köhne <c.koehne@beckhoff.com> 6 */ 7 8#include <sys/param.h> --- 9 unchanged lines hidden (view full) --- 18#include <stdio.h> 19#include <stdlib.h> 20#include <string.h> 21#include <unistd.h> 22 23#include "acpi_device.h" 24#include "bhyverun.h" 25#include "inout.h" |
26#include "pci_lpc.h" | 26#ifdef __amd64__ 27#include "amd64/pci_lpc.h" 28#endif |
27#include "qemu_fwcfg.h" 28 29#define QEMU_FWCFG_ACPI_DEVICE_NAME "FWCF" 30#define QEMU_FWCFG_ACPI_HARDWARE_ID "QEMU0002" 31 32#define QEMU_FWCFG_SELECTOR_PORT_NUMBER 0x510 33#define QEMU_FWCFG_SELECTOR_PORT_SIZE 1 34#define QEMU_FWCFG_SELECTOR_PORT_FLAGS IOPORT_F_INOUT --- 383 unchanged lines hidden (view full) --- 418 .name = QEMU_FWCFG_ACPI_DEVICE_NAME, 419 .hid = QEMU_FWCFG_ACPI_HARDWARE_ID, 420}; 421 422int 423qemu_fwcfg_init(struct vmctx *const ctx) 424{ 425 int error; | 29#include "qemu_fwcfg.h" 30 31#define QEMU_FWCFG_ACPI_DEVICE_NAME "FWCF" 32#define QEMU_FWCFG_ACPI_HARDWARE_ID "QEMU0002" 33 34#define QEMU_FWCFG_SELECTOR_PORT_NUMBER 0x510 35#define QEMU_FWCFG_SELECTOR_PORT_SIZE 1 36#define QEMU_FWCFG_SELECTOR_PORT_FLAGS IOPORT_F_INOUT --- 383 unchanged lines hidden (view full) --- 420 .name = QEMU_FWCFG_ACPI_DEVICE_NAME, 421 .hid = QEMU_FWCFG_ACPI_HARDWARE_ID, 422}; 423 424int 425qemu_fwcfg_init(struct vmctx *const ctx) 426{ 427 int error; |
428 bool fwcfg_enabled; |
|
426 427 /* | 429 430 /* |
431 * The fwcfg implementation currently only provides an I/O port 432 * interface and thus is amd64-specific for now. An MMIO interface is 433 * required for other platforms. 434 */ 435#ifdef __amd64__ 436 fwcfg_enabled = strcmp(lpc_fwcfg(), "qemu") == 0; 437#else 438 fwcfg_enabled = false; 439#endif 440 441 /* |
|
428 * Bhyve supports fwctl (bhyve) and fwcfg (qemu) as firmware interfaces. 429 * Both are using the same ports. So, it's not possible to provide both 430 * interfaces at the same time to the guest. Therefore, only create acpi 431 * tables and register io ports for fwcfg, if it's used. 432 */ | 442 * Bhyve supports fwctl (bhyve) and fwcfg (qemu) as firmware interfaces. 443 * Both are using the same ports. So, it's not possible to provide both 444 * interfaces at the same time to the guest. Therefore, only create acpi 445 * tables and register io ports for fwcfg, if it's used. 446 */ |
433 if (strcmp(lpc_fwcfg(), "qemu") == 0) { | 447 if (fwcfg_enabled) { |
434 error = acpi_device_create(&fwcfg_sc.acpi_dev, &fwcfg_sc, ctx, 435 &qemu_fwcfg_acpi_device_emul); 436 if (error) { 437 warnx("%s: failed to create ACPI device for QEMU FwCfg", 438 __func__); 439 goto done; 440 } 441 --- 174 unchanged lines hidden --- | 448 error = acpi_device_create(&fwcfg_sc.acpi_dev, &fwcfg_sc, ctx, 449 &qemu_fwcfg_acpi_device_emul); 450 if (error) { 451 warnx("%s: failed to create ACPI device for QEMU FwCfg", 452 __func__); 453 goto done; 454 } 455 --- 174 unchanged lines hidden --- |