2014-06-14 14:26:22 +08: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"
|
2019-12-08 17:54:43 +08:00
|
|
|
tar -xf "$OVERLAY" -C "$TARGET" --strip-components=2 \
|
2019-12-08 14:27:23 +08:00
|
|
|
xtensa/config/core-isa.h \
|
|
|
|
xtensa/config/core-matmap.h
|
2014-06-14 14:26:22 +08:00
|
|
|
tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \
|
2018-03-23 01:45:57 +08:00
|
|
|
sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.inc.c
|
2017-11-01 10:14:20 +08:00
|
|
|
#
|
|
|
|
# Fix up known issues in the xtensa-modules.c
|
|
|
|
#
|
|
|
|
tar -xf "$OVERLAY" -O binutils/xtensa-modules.c | \
|
2018-12-08 07:58:39 +08:00
|
|
|
sed -e 's/^\(xtensa_opcode_encode_fn.*\[\] =\)/static \1/' \
|
2017-11-01 10:14:20 +08:00
|
|
|
-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-23 01:54:30 +08:00
|
|
|
-e 's/#include <xtensa-isa.h>/#include "xtensa-isa.h"/' \
|
2018-03-23 01:45:57 +08:00
|
|
|
> "$TARGET"/xtensa-modules.inc.c
|
2014-06-14 14:26:22 +08:00
|
|
|
|
|
|
|
cat <<EOF > "${TARGET}.c"
|
2017-02-10 11:13:42 +08:00
|
|
|
#include "qemu/osdep.h"
|
2014-06-14 14:26:22 +08:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "exec/gdbstub.h"
|
2017-02-10 11:13:42 +08:00
|
|
|
#include "qemu-common.h"
|
2014-06-14 14:26:22 +08:00
|
|
|
#include "qemu/host-utils.h"
|
|
|
|
|
|
|
|
#include "core-$NAME/core-isa.h"
|
2019-12-08 14:27:23 +08:00
|
|
|
#include "core-$NAME/core-matmap.h"
|
2014-06-14 14:26:22 +08:00
|
|
|
#include "overlay_tool.h"
|
|
|
|
|
2017-11-01 10:14:20 +08:00
|
|
|
#define xtensa_modules xtensa_modules_$NAME
|
2018-03-23 01:45:57 +08:00
|
|
|
#include "core-$NAME/xtensa-modules.inc.c"
|
2017-11-01 10:14:20 +08:00
|
|
|
|
2015-07-01 18:00:29 +08:00
|
|
|
static XtensaConfig $NAME __attribute__((unused)) = {
|
2014-06-14 14:26:22 +08:00
|
|
|
.name = "$NAME",
|
|
|
|
.gdb_regmap = {
|
|
|
|
.reg = {
|
2018-03-23 01:45:57 +08:00
|
|
|
#include "core-$NAME/gdb-config.inc.c"
|
2014-06-14 14:26:22 +08:00
|
|
|
}
|
|
|
|
},
|
2017-11-01 10:14:20 +08:00
|
|
|
.isa_internal = &xtensa_modules,
|
2014-06-14 14:26:22 +08: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
|