bcm2835_peripherals: add rollup device for bcm2835 peripherals
[qemu/ar7.git] / target-xtensa / import_core.sh
blob351bee41c2d2fd6ac9a6ded42ea0d79b0ff995b2
1 #! /bin/bash -e
3 OVERLAY="$1"
4 NAME="$2"
5 FREQ=40000
6 BASE=$(dirname "$0")
7 TARGET="$BASE"/core-$NAME
9 [ $# -ge 2 -a -f "$OVERLAY" ] || { cat <<EOF
10 Usage: $0 overlay-archive-to-import core-name [frequency-in-KHz]
11 overlay-archive-to-import: file name of xtensa-config-overlay.tar.gz
12 to import configuration from.
13 core-name: QEMU name of the imported core. Must be valid
14 C identifier.
15 frequency-in-KHz: core frequency (40MHz if not specified).
16 EOF
17 exit
20 [ $# -ge 3 ] && FREQ="$3"
21 mkdir -p "$TARGET"
22 tar -xf "$OVERLAY" -C "$TARGET" --strip-components=1 \
23 --xform='s/core/core-isa/' config/core.h
24 tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \
25 sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.c
27 cat <<EOF > "${TARGET}.c"
28 #include "cpu.h"
29 #include "exec/exec-all.h"
30 #include "exec/gdbstub.h"
31 #include "qemu/host-utils.h"
33 #include "core-$NAME/core-isa.h"
34 #include "overlay_tool.h"
36 static XtensaConfig $NAME __attribute__((unused)) = {
37 .name = "$NAME",
38 .gdb_regmap = {
39 .reg = {
40 #include "core-$NAME/gdb-config.c"
43 .clock_freq_khz = $FREQ,
44 DEFAULT_SECTIONS
47 REGISTER_CORE($NAME)
48 EOF
50 grep -q core-${NAME}.o "$BASE"/Makefile.objs || \
51 echo "obj-y += core-${NAME}.o" >> "$BASE"/Makefile.objs