diff --git a/src/mainboard/emulation/Kconfig b/src/mainboard/emulation/Kconfig index ea6b18077b..8456be469d 100644 --- a/src/mainboard/emulation/Kconfig +++ b/src/mainboard/emulation/Kconfig @@ -6,6 +6,9 @@ choice config BOARD_EMULATION_QEMU_X86 bool "QEMU x86" +config BOARD_EMULATION_FOUNDATION_ARMV8 + bool "Foundation ARMV8 (may also work in qemu)" + config BOARD_EMULATION_QEMU_ARMV7 bool "QEMU armv7 (vexpress-a9)" @@ -13,6 +16,7 @@ endchoice source "src/mainboard/emulation/qemu-x86/Kconfig" source "src/mainboard/emulation/qemu-armv7/Kconfig" +source "src/mainboard/emulation/foundation-armv8/Kconfig" config MAINBOARD_VENDOR string diff --git a/src/mainboard/emulation/foundation-armv8/Kconfig b/src/mainboard/emulation/foundation-armv8/Kconfig new file mode 100644 index 0000000000..0448f91fa7 --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/Kconfig @@ -0,0 +1,106 @@ +## +## 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. + +if BOARD_EMULATION_FOUNDATION_ARMV8 + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select ARCH_AARCH64 + select CPU_ARMLTD_ARMV8 + select HAVE_UART_MEMORY_MAPPED + select HAVE_UART_SPECIAL + select BOARD_ROMSIZE_KB_4096 + +config MAINBOARD_DIR + string + default emulation/foundation-armv8 + +config MAINBOARD_PART_NUMBER + string + default "FOUNDATION ARMV8" + +config MAX_CPUS + int + default 1 + +config MAINBOARD_VENDOR + string + default "ARM Ltd." + +config BOOTBLOCK_MAINBOARD_INIT + string + default "mainboard/emulation/foundation-armv8/bootblock.c" + +config DRAM_SIZE_MB + int + default 1024 + +# Memory map +# +# 0xA000_0000: first instruction (called from BL3) + +config BOOTBLOCK_BASE + hex + default 0xA0000000 + +config ID_SECTION_BASE + hex + default 0xA001f000 + +config ROMSTAGE_BASE + hex + default 0xA0020000 + +config ROMSTAGE_SIZE + hex + default 0x20000 + +config BOOTBLOCK_ROM_OFFSET + hex + default 0x0 + +config CBFS_HEADER_ROM_OFFSET + hex + default 0x0100000 + +config CBFS_ROM_OFFSET + hex + default 0x0110000 + +config IRAM_STACK + hex + default 0x0007ff00 + +config XIP_ROM_SIZE + hex + default ROMSTAGE_SIZE + +config SYS_SDRAM_BASE + hex "SDRAM base address" + default 0x01000000 + +config SYS_TEXT_BASE + hex "Executable code section" + default 0x04e00000 + +config RAMBASE + hex + default SYS_SDRAM_BASE + +# according to stefan, this is RAMBASE + 1M. +config RAMTOP + hex + default 0x01100000 + +endif # BOARD_EMULATION_FOUNDATION_ARMV8 diff --git a/src/mainboard/emulation/foundation-armv8/Makefile.inc b/src/mainboard/emulation/foundation-armv8/Makefile.inc new file mode 100644 index 0000000000..431d9ab865 --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/Makefile.inc @@ -0,0 +1,27 @@ +## +## 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. + +romstage-y += romstage.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-$(CONFIG_BOOTBLOCK_CONSOLE) += uart.c +romstage-$(CONFIG_EARLY_CONSOLE) += uart.c +ramstage-y += uart.c diff --git a/src/mainboard/emulation/foundation-armv8/bootblock.c b/src/mainboard/emulation/foundation-armv8/bootblock.c new file mode 100644 index 0000000000..daf15b0dfa --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/bootblock.c @@ -0,0 +1,25 @@ +/* + * 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 + +void bootblock_mainboard_init(void); +void bootblock_mainboard_init(void) +{ + /* if you want a banner in the bootblock, you'll have to call + * console_init. + */ + //printk(BIOS_INFO, "\n\n\n%s: ARMv7 Emulation Started.\n", __func__); +} diff --git a/src/mainboard/emulation/foundation-armv8/devicetree.cb b/src/mainboard/emulation/foundation-armv8/devicetree.cb new file mode 100644 index 0000000000..91534427a9 --- /dev/null +++ b/src/mainboard/emulation/foundation-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/foundation-armv8/mainboard.c b/src/mainboard/emulation/foundation-armv8/mainboard.c new file mode 100644 index 0000000000..eda93c53e1 --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/mainboard.c @@ -0,0 +1,27 @@ +/* + * 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 +#include + +static void mainboard_enable(device_t dev) +{ + printk(BIOS_INFO, "Enable foundation/armv8 device...\n"); +} + +struct chip_operations mainboard_ops = { + .enable_dev = mainboard_enable, +}; + diff --git a/src/mainboard/emulation/foundation-armv8/media.c b/src/mainboard/emulation/foundation-armv8/media.c new file mode 100644 index 0000000000..f56e07cff7 --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/media.c @@ -0,0 +1,58 @@ +/* + * 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 +#include +#include + +/* Simple memory-mapped ROM emulation. */ + +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) { + return (void*)(offset + CONFIG_BOOTBLOCK_BASE); +} + +static void *emu_rom_unmap(struct cbfs_media *media, const void *address) { + return NULL; +} + +static size_t emu_rom_read(struct cbfs_media *media, void *dest, size_t offset, + size_t count) { + void *ptr = emu_rom_map(media, offset, count); + memcpy(dest, ptr, count); + emu_rom_unmap(media, ptr); + return count; +} + +static int emu_rom_close(struct cbfs_media *media) { + return 0; +} + +int init_emu_rom_cbfs_media(struct cbfs_media *media); +int init_emu_rom_cbfs_media(struct cbfs_media *media) { + 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/foundation-armv8/romstage.c b/src/mainboard/emulation/foundation-armv8/romstage.c new file mode 100644 index 0000000000..4a16436015 --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/romstage.c @@ -0,0 +1,29 @@ +/* + * 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 +#include +#include + +void main(void) +{ + void *entry; + + console_init(); + + entry = cbfs_load_stage(CBFS_DEFAULT_MEDIA, "fallback/coreboot_ram"); + + stage_exit(entry); +} diff --git a/src/mainboard/emulation/foundation-armv8/timer.c b/src/mainboard/emulation/foundation-armv8/timer.c new file mode 100644 index 0000000000..7569a92e75 --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/timer.c @@ -0,0 +1,24 @@ +/* + * 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 + +void udelay(unsigned int n) { + /* TODO provide delay here. */ +} + +int init_timer(void) { + return 0; +} diff --git a/src/mainboard/emulation/foundation-armv8/uart.c b/src/mainboard/emulation/foundation-armv8/uart.c new file mode 100644 index 0000000000..26cd4ef65b --- /dev/null +++ b/src/mainboard/emulation/foundation-armv8/uart.c @@ -0,0 +1,58 @@ +/* + * 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 +#include + +static void pl011_init_dev(void) { +} + +static void pl011_uart_tx_byte(unsigned char data) { + static volatile unsigned int *uart0_address = (void *)0; + + *uart0_address = (unsigned int)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 0; +} + +#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