]>
Commit | Line | Data |
---|---|---|
9bea2e91 MF |
1 | #! /bin/bash -e |
2 | ||
3 | OVERLAY="$1" | |
4 | NAME="$2" | |
5 | FREQ=40000 | |
6 | BASE=$(dirname "$0") | |
7 | TARGET="$BASE"/core-$NAME | |
8 | ||
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 | |
18 | } | |
19 | ||
20 | [ $# -ge 3 ] && FREQ="$3" | |
21 | mkdir -p "$TARGET" | |
ca3c979d | 22 | tar -xf "$OVERLAY" -C "$TARGET" --strip-components=2 \ |
a153a3f7 MF |
23 | xtensa/config/core-isa.h \ |
24 | xtensa/config/core-matmap.h | |
9bea2e91 | 25 | tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \ |
139c1837 | 26 | sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.c.inc |
2557c3ad MF |
27 | # |
28 | # Fix up known issues in the xtensa-modules.c | |
29 | # | |
30 | tar -xf "$OVERLAY" -O binutils/xtensa-modules.c | \ | |
571a7e34 | 31 | sed -e 's/^\(xtensa_opcode_encode_fn.*\[\] =\)/static \1/' \ |
2557c3ad MF |
32 | -e '/^int num_bypass_groups()/,/}/d' \ |
33 | -e '/^int num_bypass_group_chunks()/,/}/d' \ | |
34 | -e '/^uint32 \*bypass_entry(int i)/,/}/d' \ | |
35 | -e '/^#include "ansidecl.h"/d' \ | |
36 | -e '/^Slot_[a-zA-Z0-9_]\+_decode (const xtensa_insnbuf insn)/,/^}/s/^ return 0;$/ return XTENSA_UNDEFINED;/' \ | |
2745c3bb | 37 | -e 's/#include <xtensa-isa.h>/#include "xtensa-isa.h"/' \ |
30c67613 | 38 | -e 's/^\(xtensa_isa_internal xtensa_modules\)/static \1/' \ |
139c1837 | 39 | > "$TARGET"/xtensa-modules.c.inc |
9bea2e91 MF |
40 | |
41 | cat <<EOF > "${TARGET}.c" | |
cb3825b9 | 42 | #include "qemu/osdep.h" |
9bea2e91 | 43 | #include "cpu.h" |
4ea5fe99 | 44 | #include "gdbstub/helpers.h" |
9bea2e91 MF |
45 | #include "qemu/host-utils.h" |
46 | ||
47 | #include "core-$NAME/core-isa.h" | |
a153a3f7 | 48 | #include "core-$NAME/core-matmap.h" |
9bea2e91 MF |
49 | #include "overlay_tool.h" |
50 | ||
2557c3ad | 51 | #define xtensa_modules xtensa_modules_$NAME |
139c1837 | 52 | #include "core-$NAME/xtensa-modules.c.inc" |
2557c3ad | 53 | |
1479073b | 54 | static XtensaConfig $NAME __attribute__((unused)) = { |
9bea2e91 MF |
55 | .name = "$NAME", |
56 | .gdb_regmap = { | |
9bea2e91 | 57 | .reg = { |
139c1837 | 58 | #include "core-$NAME/gdb-config.c.inc" |
9bea2e91 MF |
59 | } |
60 | }, | |
2557c3ad | 61 | .isa_internal = &xtensa_modules, |
9bea2e91 MF |
62 | .clock_freq_khz = $FREQ, |
63 | DEFAULT_SECTIONS | |
64 | }; | |
65 | ||
66 | REGISTER_CORE($NAME) | |
67 | EOF | |
2796032a PB |
68 | |
69 | grep -qxf core-${NAME}.c "$BASE"/cores.list || \ | |
70 | echo core-${NAME}.c >> "$BASE"/cores.list |