[coreboot-gerrit] New patch to review for coreboot: armv8 : coreboot for qemu aarch64 #Work in progress# This patchset aims to add a new mainboard (emulation) for arm64. By the end of this work, we will have coreboot running on a qemu-system-aarch64.
Naman Govil (namangov@gmail.com)
gerrit at coreboot.org
Fri Jun 12 18:40:40 CEST 2015
Naman Govil (namangov at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10527
-gerrit
commit b7e15be6f8c8ec79e2d18967f227a62e1687dd7a
Author: Naman Govil <namangov at gmail.com>
Date: Wed Jun 10 16:18:52 2015 -0400
armv8 : coreboot for qemu aarch64 #Work in progress#
This patchset aims to add a new mainboard
(emulation) for arm64. By the
end of this work, we will have coreboot running
on a qemu-system-aarch64.
Change-Id: I5550dcaae9981908e0c3bf6961206a70bebac5d1
Signed-off-by: Naman Govil <namangov at gmail.com>
---
src/mainboard/emulation/qemu-armv8/Kconfig | 54 +++++++++++++
src/mainboard/emulation/qemu-armv8/Kconfig.name | 2 +
src/mainboard/emulation/qemu-armv8/Makefile.inc | 35 +++++++++
src/mainboard/emulation/qemu-armv8/board_info.txt | 3 +
src/mainboard/emulation/qemu-armv8/cbmem.c | 25 ++++++
src/mainboard/emulation/qemu-armv8/devicetree.cb | 20 +++++
src/mainboard/emulation/qemu-armv8/mainboard.c | 27 +++++++
src/mainboard/emulation/qemu-armv8/media.c | 95 +++++++++++++++++++++++
src/mainboard/emulation/qemu-armv8/memlayout.ld | 48 ++++++++++++
src/mainboard/emulation/qemu-armv8/romstage.c | 29 +++++++
src/mainboard/emulation/qemu-armv8/timer.c | 27 +++++++
src/mainboard/emulation/qemu-armv8/uart.c | 60 ++++++++++++++
12 files changed, 425 insertions(+)
diff --git a/src/mainboard/emulation/qemu-armv8/Kconfig b/src/mainboard/emulation/qemu-armv8/Kconfig
new file mode 100644
index 0000000..d223f7b
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/Kconfig
@@ -0,0 +1,54 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2015, Naman Govil <namangov at gmail.com>
+##
+## This software is licensed under the terms of the GNU General Public
+## License version 2, as published by the Free Software Foundation, and
+## may be copied, distributed, and modified under those terms.
+##
+## 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.
+
+# WRITE THE INSTRUCTIONS TO EXECUTE
+# To execute, do:
+# export QEMU_AUDIO_DRV=none
+# qemu-system-arm -M vexpress-a9 -m 1024M -nographic -kernel build/coreboot.rom
+
+if BOARD_EMULATION_QEMU_ARMV8
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+ def_bool y
+ select CPU_ARMv8
+ select DRIVERS_UART_PL011
+ select BOOTBLOCK_CONSOLE
+ select EARLY_CONSOLE
+ select CONSOLE_SERIAL
+ select ARM_BOOTBLOCK_ARMV7
+ select ARM_ROMSTAGE_ARMV7
+ select ARM_RAMSTAGE_ARMV7
+ select BOARD_ROMSIZE_KB_4096
+
+config MAINBOARD_DIR
+ string
+ default emulation/qemu-armv8
+
+config MAINBOARD_PART_NUMBER
+ string
+ default "QEMU ARMv8"
+
+config MAX_CPUS
+ int
+ default 1
+
+config MAINBOARD_VENDOR
+ string
+ default "ARM Ltd."
+
+config DRAM_SIZE_MB
+ int
+ default 1024
+
+endif # BOARD_EMULATION_QEMU_ARMV8
diff --git a/src/mainboard/emulation/qemu-armv8/Kconfig.name b/src/mainboard/emulation/qemu-armv8/Kconfig.name
new file mode 100644
index 0000000..bb3a0e4
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/Kconfig.name
@@ -0,0 +1,2 @@
+config BOARD_EMULATION_QEMU_ARMV8
+ bool "QEMU armv8"
diff --git a/src/mainboard/emulation/qemu-armv8/Makefile.inc b/src/mainboard/emulation/qemu-armv8/Makefile.inc
new file mode 100644
index 0000000..2eb08a4
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/Makefile.inc
@@ -0,0 +1,35 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2013 Google Inc.
+## Copyright (C) 2015, Naman Govil <namangov at gmail.com>
+##
+## This software is licensed under the terms of the GNU General Public
+## License version 2, as published by the Free Software Foundation, and
+## may be copied, distributed, and modified under those terms.
+##
+## 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.
+
+romstage-y += romstage.c
+
+romstage-y += cbmem.c
+ramstage-y += cbmem.c
+
+bootblock-y += media.c
+romstage-y += media.c
+ramstage-y += media.c
+
+bootblock-y += timer.c
+romstage-y += timer.c
+ramstage-y += timer.c
+
+bootblock-y += uart.c
+romstage-y += uart.c
+ramstage-y += uart.c
+
+bootblock-y += memlayout.ld
+romstage-y += memlayout.ld
+ramstage-y += memlayout.ld
diff --git a/src/mainboard/emulation/qemu-armv8/board_info.txt b/src/mainboard/emulation/qemu-armv8/board_info.txt
new file mode 100644
index 0000000..1bb78e9
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/board_info.txt
@@ -0,0 +1,3 @@
+Board name: QEMU armv7 (vexpress-a9)
+Category: emulation
+Board URL: http://fabrice.bellard.free.fr/qemu/
diff --git a/src/mainboard/emulation/qemu-armv8/cbmem.c b/src/mainboard/emulation/qemu-armv8/cbmem.c
new file mode 100644
index 0000000..d3a2d6f
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/cbmem.c
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#include <stddef.h>
+#include <cbmem.h>
+#include <symbols.h>
+
+void *cbmem_top(void)
+{
+ return _dram + (CONFIG_DRAM_SIZE_MB << 20);
+}
diff --git a/src/mainboard/emulation/qemu-armv8/devicetree.cb b/src/mainboard/emulation/qemu-armv8/devicetree.cb
new file mode 100644
index 0000000..9153442
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/devicetree.cb
@@ -0,0 +1,20 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2013 Google, Inc.
+##
+## This software is licensed under the terms of the GNU General Public
+## License version 2, as published by the Free Software Foundation, and
+## may be copied, distributed, and modified under those terms.
+##
+## 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.
+
+# TODO fill with Versatile Express board data in QEMU.
+chip cpu/armltd/cortex-a9
+ chip drivers/generic/generic # I2C0 controller
+ device i2c 6 on end # Fake component for testing
+ end
+end
diff --git a/src/mainboard/emulation/qemu-armv8/mainboard.c b/src/mainboard/emulation/qemu-armv8/mainboard.c
new file mode 100644
index 0000000..b73ab9d
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/mainboard.c
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ * Copyright (C) 2015 Naman Govil, <namangov at gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#include <console/console.h>
+#include <device/device.h>
+
+static void mainboard_enable(device_t dev)
+{
+ printk(BIOS_INFO, "Enable qemu/armv8 device...\n");
+}
+
+struct chip_operations mainboard_ops = {
+ .enable_dev = mainboard_enable,
+};
diff --git a/src/mainboard/emulation/qemu-armv8/media.c b/src/mainboard/emulation/qemu-armv8/media.c
new file mode 100644
index 0000000..e0f2251
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/media.c
@@ -0,0 +1,95 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+#include <boot_device.h>
+#include <cbfs.h>
+#include <string.h>
+#include <symbols.h>
+#include <console/console.h>
+
+/* Maps directly to qemu memory mapped space of 0x10000 up to rom size. */
+static const struct mem_region_device gboot_dev =
+ MEM_REGION_DEV_INIT((void *)0x10000, CONFIG_ROM_SIZE);
+
+const struct region_device *boot_device_ro(void)
+{
+ return &gboot_dev.rdev;
+}
+
+static int emu_rom_open(struct cbfs_media *media)
+{
+ return 0;
+}
+
+static void *emu_rom_map(struct cbfs_media *media, size_t offset, size_t count)
+{
+ const struct region_device *boot_dev;
+ void *ptr;
+
+ boot_dev = media->context;
+
+ ptr = rdev_mmap(boot_dev, offset, count);
+
+ if (ptr == NULL)
+ return (void *)-1;
+
+ return ptr;
+}
+
+static void *emu_rom_unmap(struct cbfs_media *media, const void *address)
+{
+ const struct region_device *boot_dev;
+
+ boot_dev = media->context;
+
+ rdev_munmap(boot_dev, (void *)address);
+
+ return NULL;
+}
+
+static size_t emu_rom_read(struct cbfs_media *media, void *dest, size_t offset,
+ size_t count)
+{
+ const struct region_device *boot_dev;
+
+ boot_dev = media->context;
+
+ if (rdev_readat(boot_dev, dest, offset, count) < 0)
+ return 0;
+
+ return count;
+}
+
+static int emu_rom_close(struct cbfs_media *media)
+{
+ return 0;
+}
+
+static int init_emu_rom_cbfs_media(struct cbfs_media *media)
+{
+ boot_device_init();
+
+ media->context = (void *)boot_device_ro();
+ media->open = emu_rom_open;
+ media->close = emu_rom_close;
+ media->map = emu_rom_map;
+ media->unmap = emu_rom_unmap;
+ media->read = emu_rom_read;
+ return 0;
+}
+
+int init_default_cbfs_media(struct cbfs_media *media)
+{
+ return init_emu_rom_cbfs_media(media);
+}
diff --git a/src/mainboard/emulation/qemu-armv8/memlayout.ld b/src/mainboard/emulation/qemu-armv8/memlayout.ld
new file mode 100644
index 0000000..ee8132d
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/memlayout.ld
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Google Inc.
+ * Copyright (C )2015, Naman Govil <namangov at gmail.com>
+ *
+ * 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.
+ */
+
+#include <memlayout.h>
+
+#include <arch/header.ld>
+
+/*
+ * Memory map for qemu armv8:
+ *
+ * 0x0000_0000: jump instruction (required by qemu)
+ * 0x0001_0000: bootblock (entry of kernel / firmware)
+ * 0x0002_0000: romstage, assume up to 128KB in size.
+ * 0x0007_ff00: stack pointer
+ * 0x0010_0000: CBFS header
+ * 0x0011_0000: CBFS data
+ * 0x0100_0000: reserved for ramstage
+ * 0x1000_0000: I/O map address
+ */
+
+SECTIONS
+{
+ /* TODO: does this thing emulate SRAM? */
+
+ BOOTBLOCK(0x10000, 64K)
+ ROMSTAGE(0x20000, 128K)
+ STACK(0x000FC000, 16K)
+
+ DRAM_START(0x01000000)
+ RAMSTAGE(0x01000000, 16M)
+}
diff --git a/src/mainboard/emulation/qemu-armv8/romstage.c b/src/mainboard/emulation/qemu-armv8/romstage.c
new file mode 100644
index 0000000..fc4de3e
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/romstage.c
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ * Copyright (C) 2015, Naman Govil <namangov at gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#include <cbfs.h>
+#include <console/console.h>
+#include <program_loading.h>
+#include <arch/stages.h>
+
+void main(void)
+{
+ void *entry;
+ console_init();
+ entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, "fallback/ramstage");
+ stage_exit(entry);
+ //run_ramstage();
+}
diff --git a/src/mainboard/emulation/qemu-armv8/timer.c b/src/mainboard/emulation/qemu-armv8/timer.c
new file mode 100644
index 0000000..b6d048b
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/timer.c
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google, Inc.
+ * Copyright (C) 2015, Naman Govil <namangov at gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+void udelay(unsigned int n);
+void udelay(unsigned int n)
+{
+ /* TODO provide delay here. */
+}
+
+int init_timer(void);
+int init_timer(void)
+{
+ return 0;
+}
diff --git a/src/mainboard/emulation/qemu-armv8/uart.c b/src/mainboard/emulation/qemu-armv8/uart.c
new file mode 100644
index 0000000..b7f7cea
--- /dev/null
+++ b/src/mainboard/emulation/qemu-armv8/uart.c
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Naman Govil, <namangov at gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#include <console/console.h>
+#include <uart.h>
+
+#define UART0_IO_ADDRESS (0x1C090000)
+
+static void pl011_init_dev(void) {
+ /*Do we need to make the pins 0 and 8 high?
+ * */
+}
+
+static void pl011_uart_tx_byte(unsigned char data) {
+ static volatile uint32_t *uart0_address =
+ (uint32_t *)UART0_IO_ADDRESS;
+
+ *uart0_address = (uint32_t)data;
+}
+
+static void pl011_uart_tx_flush(void) {
+}
+
+#if !defined(__PRE_RAM__)
+static const struct console_driver pl011_uart_console __console = {
+ .init = pl011_init_dev,
+ .tx_byte = pl011_uart_tx_byte,
+ .tx_flush = pl011_uart_tx_flush,
+};
+
+uint32_t uartmem_getbaseaddr(void)
+{
+ return UART0_IO_ADDRESS;
+}
+
+#else
+void uart_init(void){
+ pl011_init_dev();
+}
+
+void uart_tx_byte(unsigned char data){
+ pl011_uart_tx_byte(data);
+}
+
+void uart_tx_flush(void) {
+ pl011_uart_tx_flush();
+}
+#endif
More information about the coreboot-gerrit
mailing list