2014-06-14 10:26:22 +04:00
|
|
|
#! /bin/bash -e
|
|
|
|
|
|
|
|
OVERLAY="$1"
|
|
|
|
NAME="$2"
|
|
|
|
FREQ=40000
|
|
|
|
BASE=$(dirname "$0")
|
|
|
|
TARGET="$BASE"/core-$NAME
|
|
|
|
|
|
|
|
[ $# -ge 2 -a -f "$OVERLAY" ] || { cat <<EOF
|
|
|
|
Usage: $0 overlay-archive-to-import core-name [frequency-in-KHz]
|
|
|
|
overlay-archive-to-import: file name of xtensa-config-overlay.tar.gz
|
|
|
|
to import configuration from.
|
|
|
|
core-name: QEMU name of the imported core. Must be valid
|
|
|
|
C identifier.
|
|
|
|
frequency-in-KHz: core frequency (40MHz if not specified).
|
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
[ $# -ge 3 ] && FREQ="$3"
|
|
|
|
mkdir -p "$TARGET"
|
|
|
|
tar -xf "$OVERLAY" -C "$TARGET" --strip-components=1 \
|
|
|
|
--xform='s/core/core-isa/' config/core.h
|
|
|
|
tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \
|
2018-03-22 20:45:57 +03:00
|
|
|
sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.inc.c
|
2017-11-01 05:14:20 +03:00
|
|
|
#
|
|
|
|
# Fix up known issues in the xtensa-modules.c
|
|
|
|
#
|
|
|
|
tar -xf "$OVERLAY" -O binutils/xtensa-modules.c | \
|
|
|
|
sed -e 's/\(xtensa_opcode_encode_fn.*\[\] =\)/static \1/' \
|
|
|
|
-e '/^int num_bypass_groups()/,/}/d' \
|
|
|
|
-e '/^int num_bypass_group_chunks()/,/}/d' \
|
|
|
|
-e '/^uint32 \*bypass_entry(int i)/,/}/d' \
|
|
|
|
-e '/^#include "ansidecl.h"/d' \
|
|
|
|
-e '/^Slot_[a-zA-Z0-9_]\+_decode (const xtensa_insnbuf insn)/,/^}/s/^ return 0;$/ return XTENSA_UNDEFINED;/' \
|
2018-03-22 20:54:30 +03:00
|
|
|
-e 's/#include <xtensa-isa.h>/#include "xtensa-isa.h"/' \
|
2018-03-22 20:45:57 +03:00
|
|
|
> "$TARGET"/xtensa-modules.inc.c
|
2014-06-14 10:26:22 +04:00
|
|
|
|
|
|
|
cat <<EOF > "${TARGET}.c"
|
2017-02-10 06:13:42 +03:00
|
|
|
#include "qemu/osdep.h"
|
2014-06-14 10:26:22 +04:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "exec/gdbstub.h"
|
2017-02-10 06:13:42 +03:00
|
|
|
#include "qemu-common.h"
|
2014-06-14 10:26:22 +04:00
|
|
|
#include "qemu/host-utils.h"
|
|
|
|
|
|
|
|
#include "core-$NAME/core-isa.h"
|
|
|
|
#include "overlay_tool.h"
|
|
|
|
|
2017-11-01 05:14:20 +03:00
|
|
|
#define xtensa_modules xtensa_modules_$NAME
|
2018-03-22 20:45:57 +03:00
|
|
|
#include "core-$NAME/xtensa-modules.inc.c"
|
2017-11-01 05:14:20 +03:00
|
|
|
|
2015-07-01 13:00:29 +03:00
|
|
|
static XtensaConfig $NAME __attribute__((unused)) = {
|
2014-06-14 10:26:22 +04:00
|
|
|
.name = "$NAME",
|
|
|
|
.gdb_regmap = {
|
|
|
|
.reg = {
|
2018-03-22 20:45:57 +03:00
|
|
|
#include "core-$NAME/gdb-config.inc.c"
|
2014-06-14 10:26:22 +04:00
|
|
|
}
|
|
|
|
},
|
2017-11-01 05:14:20 +03:00
|
|
|
.isa_internal = &xtensa_modules,
|
2014-06-14 10:26:22 +04:00
|
|
|
.clock_freq_khz = $FREQ,
|
|
|
|
DEFAULT_SECTIONS
|
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_CORE($NAME)
|
|
|
|
EOF
|
|
|
|
|
|
|
|
grep -q core-${NAME}.o "$BASE"/Makefile.objs || \
|
|
|
|
echo "obj-y += core-${NAME}.o" >> "$BASE"/Makefile.objs
|