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