KONRAD Frederic

Merge branch 'tlm2c-next' into 'tlm2c'

next



See merge request !25
... ... @@ -116,3 +116,5 @@ qbox-arm926-obj-$(CONFIG_QBOX) += qbox/
qbox-arm926-obj-$(CONFIG_QBOX) += hw/
qbox-cortexm3-obj-$(CONFIG_QBOX) += qbox/
qbox-cortexm3-obj-$(CONFIG_QBOX) += hw/
qbox-zynq-a9-obj-$(CONFIG_QBOX) += qbox/
qbox-zynq-a9-obj-$(CONFIG_QBOX) += hw/
... ...
... ... @@ -45,7 +45,7 @@ config-target.h-timestamp: config-target.mak
ifdef CONFIG_QBOX
# Compile QBOX libraries.
ifeq ($(TARGET_NAME), arm)
QBOX_PROGS=libqbox-arm926$(DSOSUF) libqbox-cortex-m3$(DSOSUF)
QBOX_PROGS=libqbox-arm926$(DSOSUF) libqbox-cortex-m3$(DSOSUF) libqbox-zynq-a9$(DSOSUF)
endif
endif
... ... @@ -175,14 +175,19 @@ block-obj-y :=
common-obj-y :=
qbox-arm926-obj-y :=
qbox-cortexm3-obj-y :=
qbox-zynq-a9-obj-y :=
include $(SRC_PATH)/Makefile.objs
qbox-cortexm3-obj-y-save := $(qbox-cortexm3-obj-y)
qbox-zynq-a9-obj-y-save := $(qbox-zynq-a9-obj-y)
target-obj-y-save := $(target-obj-y)
dummy := $(call unnest-vars,,qbox-arm926-obj-y)
qbox-arm926-obj-y-save := $(qbox-arm926-obj-y)
qbox-cortexm3-obj-y := $(qbox-cortexm3-obj-y-save)
dummy := $(call unnest-vars,,qbox-cortexm3-obj-y)
qbox-cortexm3-obj-y-save := $(qbox-cortexm3-obj-y)
qbox-zynq-a9-obj-y := $(qbox-zynq-a9-obj-y-save)
dummy := $(call unnest-vars,,qbox-zynq-a9-obj-y)
qbox-zynq-a9-obj-y-save := $(qbox-zynq-a9-obj-y)
target-obj-y := $(target-obj-y-save)
dummy := $(call unnest-vars,,target-obj-y)
target-obj-y-save := $(target-obj-y)
... ... @@ -194,6 +199,7 @@ dummy := $(call unnest-vars,.., \
target-obj-y := $(target-obj-y-save)
qbox-arm926-obj-y := $(qbox-arm926-obj-y-save)
qbox-cortexm3-obj-y := $(qbox-cortexm3-obj-y-save)
qbox-zynq-a9-obj-y := $(qbox-zynq-a9-obj-y-save)
all-obj-y += $(common-obj-y)
all-obj-y += $(target-obj-y)
all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
... ... @@ -213,6 +219,10 @@ libqbox-cortex-m3$(DSOSUF): $(all-obj-y) $(qbox-cortexm3-obj-y) ../libqemuutil.a
../libqemustub.a
$(call LINK,$^)
libqbox-zynq-a9$(DSOSUF): $(all-obj-y) $(qbox-zynq-a9-obj-y) ../libqemuutil.a \
../libqemustub.a
$(call LINK,$^)
gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
$(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")
... ...
... ... @@ -34,9 +34,13 @@ QBox also supports the use of:
QBox requires:
* git > 1.7
* [tlm2c](https://git.greensocs.com/tlm/tlm2c) > 1.0
* glib2 dev
* pixman dev
* [TLM2C](https://git.greensocs.com/tlm/tlm2c) > 1.0
* glib2 and glib2-dev > 2.20 on Windows, 2.12 otherwise
* pixman dev > 0.21.8
* gettext runtime > 0.18
* pkg-config > 0.23
* flex > 2.5.35
* bison > 2.4.1
Official OS support:
... ... @@ -51,13 +55,13 @@ Official OS support:
**Ubuntu / Debian :**
```sh
$ sudo apt-get install libglib2.0-dev libpixman-1-dev
$ sudo apt-get install libglib2.0-dev libpixman-1-dev flex bison pkg-config
```
**CentOS / Fedora :**
```sh
$ sudo yum install glib2-devel pixman-devel
$ sudo yum install glib2-devel pixman-devel flex bison pkgconfig
```
### Windows
... ... @@ -66,29 +70,26 @@ Please try to install packages in paths without spaces.
* [MinGW](http://sourceforge.net/projects/mingw/) with MSYS
With MinGW Installer, install these following packages:
With MinGW Installer, install these following packages:
**MinGW**
* gcc
* gcc-g++
* libz-dev
* pthreads-w32-dev
* mingw32-base
* mingw32-gcc-g++
* mingw-developer-toolkit
* msys-base
**MSYS**
* flex
* bison
* msys-flex
* msys-bison
You also need:
You also need glib2, glib2-dev, pixman-dev, gettext-runtime and pkg-config. You can compile these packages from source or you can download binaries (which is faster).
* pkg-config
* glib
* libpixman
You can compile these packages using sources and Google or you can download binaries (fastest).
`pkg-config`, `glib` and `libpixman` can be found here : [GTK Download](http://www.gtk.org/download/win32.php).
* glib2 and glib2-dev: [Download](http://ftp.gnome.org/pub/gnome/binaries/win32/glib/)
* pkg-config: [Download](http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/)
* gettext-runtime: [Download](http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/)
* pixman-dev: [Download](http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/)
Then, install packages (copy / paste files) in your MinGW installation.
... ... @@ -104,6 +105,8 @@ $ git submodule update --init dtc
## Configure
Be sure you have [TLM2C](https://git.greensocs.com/tlm/tlm2c) compiled before configuring. All instructions are available in the TLM2C README.
```sh
$ ./configure --target-list=arm-softmmu --library --qbox --with-tlm2c=[TLM2C_PATH] --prefix=[PREFIX_PATH] --disable-pie --extra-cflags=-fPIC\ -fpic\ -ftls-model=initial-exec
```
... ... @@ -112,13 +115,13 @@ Please fill options:
* `[TLM2C_PATH]` : Specify [TLM2C](https://git.greensocs.com/tlm/tlm2c) build path
* `[PREFIX_PATH]` : Specify build path
*
*
This will result in generating the `Makefile` to build QBox.
### Example
```sh
./configure --target-list=arm-softmmu --library --qbox --with-tlm2c=`pwd`/tlm2c/build --prefix=`pwd`/build --disable-pie --extra-cflags=-ftls-model=initial-exec
./configure --target-list=arm-softmmu --library --qbox --with-tlm2c=`pwd`/tlm2c/build --prefix=`pwd`/build --disable-pie --extra-cflags=-ftls-model=initial-exec
```
## Build
... ...
dtc @ 65cc4d27
Subproject commit bc895d6d09695d05ceb8b52486ffe861d6cfbdde
Subproject commit 65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf
... ...
... ... @@ -35,4 +35,5 @@ devices-dirs-y += core/
common-obj-y += $(devices-dirs-y)
obj-y += $(devices-dirs-y)
qbox-arm926-obj-$(CONFIG_QBOX) += arm/
qbox-cortexm3-obj-$(CONFIG_QBOX) += arm/
\ No newline at end of file
qbox-cortexm3-obj-$(CONFIG_QBOX) += arm/
qbox-zynq-a9-obj-$(CONFIG_QBOX) += arm/
... ...
... ... @@ -12,3 +12,4 @@ obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o
obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
qbox-arm926-obj-y += qbox_arm926.o
qbox-cortexm3-obj-y += qbox_cortex_m3.o
qbox-zynq-a9-obj-y += qbox_zynq_a9.o
... ...
/*
* qbox_zynq_a9.c
*
* Copyright (C) 2015, GreenSocs Ltd.
*
* Developped by Konrad Frederic <fred.konrad@greensocs.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; either version 2 of the License, or (at
* your option) any later version.
*
* 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, see <http://www.gnu.org/licenses>.
*
* Linking GreenSocs code, statically or dynamically with other modules
* is making a combined work based on GreenSocs code. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders, GreenSocs
* Ltd, give you permission to combine GreenSocs code with free software
* programs or libraries that are released under the GNU LGPL, under the
* OSCI license, under the OCP TLM Kit Research License Agreement or
* under the OVP evaluation license.You may copy and distribute such a
* system following the terms of the GNU GPL and the licenses of the
* other code concerned.
*
* Note that people who make modified versions of GreenSocs code are not
* obligated to grant this special exception for their modified versions;
* it is their choice whether to do so. The GNU General Public License
* gives permission to release a modified version without this exception;
* this exception also makes it possible to release a modified version
* which carries forward this exception.
*
*/
#include "hw/sysbus.h"
#include "hw/arm/arm.h"
#include "exec/address-spaces.h"
#include "sysemu/sysemu.h"
#include "hw/boards.h"
#include "hw/loader.h"
#include "qemu/error-report.h"
#include "qbox/qboxbase.h"
#define IRQ_OFFSET 32
#define MPCORE_PERIPHBASE 0xF8F00000
#define ZYNQ_BOARD_MIDR 0x413FC090
static struct arm_boot_info zynq_binfo = {};
static void qbox_zynq_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *cpu_model = machine->cpu_model;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
ObjectClass *cpu_oc;
ARMCPU *cpu;
DeviceState *dev;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
int n;
if (!cpu_model) {
cpu_model = "cortex-a9";
}
cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
cpu = ARM_CPU(object_new(object_class_get_name(cpu_oc)));
object_property_set_int(OBJECT(cpu), ZYNQ_BOARD_MIDR, "midr", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_int(OBJECT(cpu), MPCORE_PERIPHBASE, "reset-cbar", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
if (err) {
error_report("%s", error_get_pretty(err));
exit(1);
}
dev = qdev_create(NULL, "xilinx,zynq_slcr");
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000);
dev = qdev_create(NULL, "a9mpcore_priv");
qdev_prop_set_uint32(dev, "num-cpu", 1);
qdev_init_nofail(dev);
busdev = SYS_BUS_DEVICE(dev);
sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
sysbus_create_varargs("cadence_ttc", 0xF8001000,
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
sysbus_create_varargs("cadence_ttc", 0xF8002000,
pic[69-IRQ_OFFSET], pic[70-IRQ_OFFSET], pic[71-IRQ_OFFSET], NULL);
qbox_export_irq(qbox_get_handle(), pic, 64);
qbox_dmi_discovery();
zynq_binfo.ram_size = ram_size;
zynq_binfo.kernel_filename = kernel_filename;
zynq_binfo.kernel_cmdline = kernel_cmdline;
zynq_binfo.initrd_filename = initrd_filename;
zynq_binfo.nb_cpus = 1;
zynq_binfo.board_id = 0xd32;
zynq_binfo.loader_start = 0;
arm_load_kernel(ARM_CPU(first_cpu), &zynq_binfo);
}
static QEMUMachine qbox_zynq_machine = {
.name = "qbox_zynq_a9",
.desc = "QBOX ZYNQ",
.init = qbox_zynq_init,
.max_cpus = 1,
.no_sdcard = 1,
};
static void qbox_zynq_machine_init(void)
{
qemu_register_machine(&qbox_zynq_machine);
}
machine_init(qbox_zynq_machine_init);
... ...
target-obj-y += qboxbase.o
qbox-arm926-obj-y += qbox_arm926.o
qbox-cortexm3-obj-y += qbox_cortex_m3.o
\ No newline at end of file
qbox-cortexm3-obj-y += qbox_cortex_m3.o
qbox-zynq-a9-obj-y += qbox_zynq_a9.o
... ...
/*
* qbox_zynq.cpp
*
* Copyright (C) 2015 Konrad Frederic
*
* 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; either version 2 of the License, or (at
* your option) any later version.
*
* 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, see <http://www.gnu.org/licenses>.
*
* Linking GreenSocs code, statically or dynamically with other modules
* is making a combined work based on GreenSocs code. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders, GreenSocs
* Ltd, give you permission to combine GreenSocs code with free software
* programs or libraries that are released under the GNU LGPL, under the
* OSCI license, under the OCP TLM Kit Research License Agreement or
* under the OVP evaluation license.You may copy and distribute such a
* system following the terms of the GNU GPL and the licenses of the
* other code concerned.
*
* Note that people who make modified versions of GreenSocs code are not
* obligated to grant this special exception for their modified versions;
* it is their choice whether to do so. The GNU General Public License
* gives permission to release a modified version without this exception;
* this exception also makes it possible to release a modified version
* which carries forward this exception.
*
*/
#include <tlm2c/tlm2c.h>
#include "qbox/qboxbase.h"
struct QBOXZYNQA9
{
QBOXBase *base;
};
typedef struct QBOXZYNQA9 QBOXZYNQA9;
QBOXZYNQA9 zynq_a9_handle;
static void qbox_zynq_a9_init(QBOXBase *qbox)
{
qbox_add_standard_arguments(qbox);
qbox_add_argument(qbox, "-icount");
qbox_add_argument(qbox, "1");
qbox_add_argument(qbox, "-M");
qbox_add_argument(qbox, "qbox_zynq_a9");
qbox_add_argument(qbox, "--nographic");
qbox_add_argument(qbox, "--monitor");
qbox_add_argument(qbox, "null");
qbox_add_linux_arguments(qbox);
qbox_add_extra_arguments(qbox);
}
Model *tlm2c_elaboration(Environment *environment)
{
/* Entry point called by the bridge. */
tlm2c_set_environment(environment);
zynq_a9_handle.base = qbox_base_init();
qbox_register_end_of_elaboration(zynq_a9_handle.base, qbox_zynq_a9_init);
return (Model *)(qbox_get_handle());
}
... ...