mb/qemu-riscv: update to match current qemu version

Boots again to payload not found on qemu.

Change-Id: Ie107eb882cbaac5a5a06c1ff990e7b9364377640
Signed-off-by: Philipp Hug <philipp@hug.cx>
Reviewed-on: https://review.coreboot.org/c/30554
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Philipp Hug 2018-12-31 14:13:47 +01:00 committed by Patrick Georgi
parent 175778f059
commit 2ef569a405
10 changed files with 56 additions and 17 deletions

View File

@ -0,0 +1,8 @@
# Qemu RISC-V emulator
## Building coreboot and running it in Qemu
- Configure coreboot and run `make` as usual
- Run `util/riscv/make-spike-elf.sh build/coreboot.rom build/coreboot.elf` to
convert coreboot to an ELF that Qemu can load
- Run `qemu-system-riscv64 -M virt -m 1024M -nographic -kernel build/coreboot.elf`

View File

@ -19,6 +19,7 @@ This section contains documentation about coreboot on specific mainboards.
The boards in this section are not real mainboards, but emulators. The boards in this section are not real mainboards, but emulators.
- [Spike RISC-V emulator](emulation/spike-riscv.md) - [Spike RISC-V emulator](emulation/spike-riscv.md)
- [Qemu RISC-V emulator](emulation/qemu-riscv.md)
## Intel ## Intel

View File

@ -13,7 +13,8 @@
## GNU General Public License for more details. ## GNU General Public License for more details.
# To execute, do: # To execute, do:
# qemu-system-arm -M vexpress-a9 -m 1024M -nographic -kernel build/coreboot.rom # util/riscv/make-spike-elf.sh build/coreboot.rom build/coreboot.elf
# qemu-system-riscv64 -M virt -m 1024M -nographic -kernel build/coreboot.elf
if BOARD_EMULATION_QEMU_RISCV if BOARD_EMULATION_QEMU_RISCV

View File

@ -14,7 +14,7 @@
bootblock-y += uart.c bootblock-y += uart.c
bootblock-y += rom_media.c bootblock-y += rom_media.c
bootblock-y += mtime.c bootblock-y += clint.c
romstage-y += romstage.c romstage-y += romstage.c
romstage-y += uart.c romstage-y += uart.c
@ -22,8 +22,10 @@ romstage-y += rom_media.c
ramstage-y += uart.c ramstage-y += uart.c
ramstage-y += rom_media.c ramstage-y += rom_media.c
ramstage-y += mtime.c ramstage-y += clint.c
bootblock-y += memlayout.ld bootblock-y += memlayout.ld
romstage-y += memlayout.ld romstage-y += memlayout.ld
ramstage-y += memlayout.ld ramstage-y += memlayout.ld
CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include

View File

@ -14,9 +14,12 @@
*/ */
#include <mcall.h> #include <mcall.h>
#include <mainboard/addressmap.h>
/* FIXME: This is an empty implementation, please improve */
/* This function is used to initialize HLS()->time/HLS()->timecmp */ /* This function is used to initialize HLS()->time/HLS()->timecmp */
void mtime_init(void) void mtime_init(void)
{ {
long hart_id = read_csr(mhartid);
HLS()->time = (uint64_t *)(QEMU_VIRT_CLINT + 0xbff8);
HLS()->timecmp = (uint64_t *)(QEMU_VIRT_CLINT + 0x4000 + 8 * hart_id);
} }

View File

@ -0,0 +1,20 @@
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2018 Philipp Hug
*
* 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.
*/
#define QEMU_VIRT_CLINT 0x02000000
#define QEMU_VIRT_PLIC 0x0c000000
#define QEMU_VIRT_UART0 0x10000000
#define QEMU_VIRT_VIRTIO 0x10001000
#define QEMU_VIRT_DRAM 0x80000000

View File

@ -16,6 +16,7 @@
#include <console/console.h> #include <console/console.h>
#include <device/device.h> #include <device/device.h>
#include <cbmem.h> #include <cbmem.h>
#include <symbols.h>
static void mainboard_enable(struct device *dev) static void mainboard_enable(struct device *dev)
{ {
@ -24,7 +25,7 @@ static void mainboard_enable(struct device *dev)
die("No dev0; die\n"); die("No dev0; die\n");
} }
ram_resource(dev, 0, 2048, 32768); ram_resource(dev, 0, (uintptr_t)_dram / KiB, CONFIG_DRAM_SIZE_MB * KiB);
cbmem_recovery(0); cbmem_recovery(0);
} }

View File

@ -14,15 +14,16 @@
*/ */
#include <memlayout.h> #include <memlayout.h>
#include <arch/header.ld> #include <arch/header.ld>
#define START 0x80000000
SECTIONS SECTIONS
{ {
DRAM_START(0x0) DRAM_START(START)
BOOTBLOCK(0x0, 64K) BOOTBLOCK(START, 64K)
ROMSTAGE(0x20000, 128K) STACK(START + 4M, 4K)
STACK(0x40000, 0x3ff00) ROMSTAGE(START + 4M + 64K, 128K)
PRERAM_CBMEM_CONSOLE(0x80000, 8K) PRERAM_CBMEM_CONSOLE(START + 4M + 192K, 8K)
RAMSTAGE(0x100000, 16M) RAMSTAGE(START + 4M + 200K, 16M)
} }

View File

@ -14,11 +14,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <boot_device.h> #include <boot_device.h>
#include <symbols.h>
/* This assumes that the CBFS resides at 0x0, which is true for the default /* This assumes that the CBFS resides at start of dram, which is true for the
* configuration. */ * default configuration. */
static const struct mem_region_device boot_dev = static const struct mem_region_device boot_dev =
MEM_REGION_DEV_RO_INIT(NULL, CONFIG_ROM_SIZE); MEM_REGION_DEV_RO_INIT(_dram, CONFIG_ROM_SIZE);
const struct region_device *boot_device_ro(void) const struct region_device *boot_device_ro(void)
{ {

View File

@ -17,8 +17,9 @@
#include <console/uart.h> #include <console/uart.h>
#include <arch/io.h> #include <arch/io.h>
#include <boot/coreboot_tables.h> #include <boot/coreboot_tables.h>
#include <mainboard/addressmap.h>
static uint8_t *buf = (void *)0x3f8; static uint8_t *buf = (void *)QEMU_VIRT_UART0;
uintptr_t uart_platform_base(int idx) uintptr_t uart_platform_base(int idx)
{ {
return (uintptr_t) buf; return (uintptr_t) buf;
@ -47,7 +48,7 @@ void uart_fill_lb(void *data)
{ {
struct lb_serial serial; struct lb_serial serial;
serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED;
serial.baseaddr = 0x3f8; serial.baseaddr = QEMU_VIRT_UART0;
serial.baud = 115200; serial.baud = 115200;
serial.regwidth = 1; serial.regwidth = 1;
lb_add_serial(&serial, data); lb_add_serial(&serial, data);