diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-05-30 15:41:48 +0200 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2013-06-05 17:46:14 +0200 |
commit | 2b9620343bdde1055585182aeccb77726f047c8f (patch) | |
tree | 30db98215efb119e71ab0b4e82edeb378b03300e /src | |
parent | 019f0fc2c7ced8a7c02d5334a7ea4342aae97f55 (diff) | |
download | coreboot-2b9620343bdde1055585182aeccb77726f047c8f.tar.xz |
qemu: Initial support for the qemu firmware config interface.
qemu has a special device to pass configuration information
from qemu to the firmware. This patch adds initial support
the interface, namely some infrastructure, detection code and
a function to query the number of CPUs.
Change-Id: I43ff5f4fbf12334a91422aa38f514a82a1d5219e
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-on: http://review.coreboot.org/3343
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/emulation/qemu-x86/Makefile.inc | 1 | ||||
-rw-r--r-- | src/mainboard/emulation/qemu-x86/fw_cfg.c | 59 | ||||
-rw-r--r-- | src/mainboard/emulation/qemu-x86/fw_cfg.h | 19 | ||||
-rw-r--r-- | src/mainboard/emulation/qemu-x86/fw_cfg_if.h | 53 |
4 files changed, 132 insertions, 0 deletions
diff --git a/src/mainboard/emulation/qemu-x86/Makefile.inc b/src/mainboard/emulation/qemu-x86/Makefile.inc index 22fdfe1c57..21d73442ca 100644 --- a/src/mainboard/emulation/qemu-x86/Makefile.inc +++ b/src/mainboard/emulation/qemu-x86/Makefile.inc @@ -1,2 +1,3 @@ cpu_incs += $(src)/mainboard/emulation/qemu-x86/cache_as_ram.inc ramstage-y += northbridge.c +ramstage-y += fw_cfg.c diff --git a/src/mainboard/emulation/qemu-x86/fw_cfg.c b/src/mainboard/emulation/qemu-x86/fw_cfg.c new file mode 100644 index 0000000000..5166f83092 --- /dev/null +++ b/src/mainboard/emulation/qemu-x86/fw_cfg.c @@ -0,0 +1,59 @@ +/* + * This file is part of the coreboot project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <string.h> +#include <console/console.h> +#include <arch/io.h> + +#include "fw_cfg.h" +#include "fw_cfg_if.h" + +#define FW_CFG_PORT_CTL 0x0510 +#define FW_CFG_PORT_DATA 0x0511 + +static unsigned char fw_cfg_detected = 0xff; + +static int fw_cfg_present(void) +{ + static const char qsig[] = "QEMU"; + unsigned char sig[4]; + + if (fw_cfg_detected == 0xff) { + fw_cfg_get(FW_CFG_SIGNATURE, sig, sizeof(sig)); + fw_cfg_detected = (memcmp(sig, qsig, 4) == 0) ? 1 : 0; + printk(BIOS_INFO, "QEMU: firmware config interface %s\n", + fw_cfg_detected ? "detected" : "not found"); + } + return fw_cfg_detected; +} + +void fw_cfg_get(int entry, void *dst, int dstlen) +{ + outw(entry, FW_CFG_PORT_CTL); + insb(FW_CFG_PORT_DATA, dst, dstlen); +} + +int fw_cfg_max_cpus(void) +{ + unsigned short max_cpus; + + if (!fw_cfg_present()) + return -1; + + fw_cfg_get(FW_CFG_MAX_CPUS, &max_cpus, sizeof(max_cpus)); + return max_cpus; +} diff --git a/src/mainboard/emulation/qemu-x86/fw_cfg.h b/src/mainboard/emulation/qemu-x86/fw_cfg.h new file mode 100644 index 0000000000..063e48f838 --- /dev/null +++ b/src/mainboard/emulation/qemu-x86/fw_cfg.h @@ -0,0 +1,19 @@ +/* + * This file is part of the coreboot project. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +void fw_cfg_get(int entry, void *dst, int dstlen); +int fw_cfg_max_cpus(void); diff --git a/src/mainboard/emulation/qemu-x86/fw_cfg_if.h b/src/mainboard/emulation/qemu-x86/fw_cfg_if.h new file mode 100644 index 0000000000..d159f12d09 --- /dev/null +++ b/src/mainboard/emulation/qemu-x86/fw_cfg_if.h @@ -0,0 +1,53 @@ +/* + * This are the qemu firmware config interface defines and structs. + * Copyed over from qemu soure tree, include/hw/nvram/fw_cfg.h + */ + +#define FW_CFG_SIGNATURE 0x00 +#define FW_CFG_ID 0x01 +#define FW_CFG_UUID 0x02 +#define FW_CFG_RAM_SIZE 0x03 +#define FW_CFG_NOGRAPHIC 0x04 +#define FW_CFG_NB_CPUS 0x05 +#define FW_CFG_MACHINE_ID 0x06 +#define FW_CFG_KERNEL_ADDR 0x07 +#define FW_CFG_KERNEL_SIZE 0x08 +#define FW_CFG_KERNEL_CMDLINE 0x09 +#define FW_CFG_INITRD_ADDR 0x0a +#define FW_CFG_INITRD_SIZE 0x0b +#define FW_CFG_BOOT_DEVICE 0x0c +#define FW_CFG_NUMA 0x0d +#define FW_CFG_BOOT_MENU 0x0e +#define FW_CFG_MAX_CPUS 0x0f +#define FW_CFG_KERNEL_ENTRY 0x10 +#define FW_CFG_KERNEL_DATA 0x11 +#define FW_CFG_INITRD_DATA 0x12 +#define FW_CFG_CMDLINE_ADDR 0x13 +#define FW_CFG_CMDLINE_SIZE 0x14 +#define FW_CFG_CMDLINE_DATA 0x15 +#define FW_CFG_SETUP_ADDR 0x16 +#define FW_CFG_SETUP_SIZE 0x17 +#define FW_CFG_SETUP_DATA 0x18 +#define FW_CFG_FILE_DIR 0x19 + +#define FW_CFG_FILE_FIRST 0x20 +#define FW_CFG_FILE_SLOTS 0x10 +#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS) + +#define FW_CFG_WRITE_CHANNEL 0x4000 +#define FW_CFG_ARCH_LOCAL 0x8000 +#define FW_CFG_ENTRY_MASK ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL) + +#define FW_CFG_INVALID 0xffff + +typedef struct FWCfgFile { + uint32_t size; /* file size */ + uint16_t select; /* write this to 0x510 to read it */ + uint16_t reserved; + char name[56]; +} FWCfgFile; + +typedef struct FWCfgFiles { + uint32_t count; + FWCfgFile f[]; +} FWCfgFiles; |