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"
|
2019-12-08 12:54:43 +03:00
|
|
|
tar -xf "$OVERLAY" -C "$TARGET" --strip-components=2 \
|
2019-12-08 09:27:23 +03:00
|
|
|
xtensa/config/core-isa.h \
|
|
|
|
xtensa/config/core-matmap.h
|
2014-06-14 10:26:22 +04:00
|
|
|
tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \
|
2020-02-04 14:41:01 +03:00
|
|
|
sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.c.inc
|
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 | \
|
2018-12-08 02:58:39 +03:00
|
|
|
sed -e 's/^\(xtensa_opcode_encode_fn.*\[\] =\)/static \1/' \
|
2017-11-01 05:14:20 +03: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 20:54:30 +03:00
|
|
|
-e 's/#include <xtensa-isa.h>/#include "xtensa-isa.h"/' \
|
2021-03-30 09:59:49 +03:00
|
|
|
-e 's/^\(xtensa_isa_internal xtensa_modules\)/static \1/' \
|
2020-02-04 14:41:01 +03:00
|
|
|
> "$TARGET"/xtensa-modules.c.inc
|
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"
|
2019-12-08 09:27:23 +03:00
|
|
|
#include "core-$NAME/core-matmap.h"
|
2014-06-14 10:26:22 +04:00
|
|
|
#include "overlay_tool.h"
|
|
|
|
|
2017-11-01 05:14:20 +03:00
|
|
|
#define xtensa_modules xtensa_modules_$NAME
|
2020-02-04 14:41:01 +03:00
|
|
|
#include "core-$NAME/xtensa-modules.c.inc"
|
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 = {
|
2020-02-04 14:41:01 +03:00
|
|
|
#include "core-$NAME/gdb-config.c.inc"
|
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
|