xen_disk: remove use of grant map/unmap
[qemu.git] / target / xtensa / import_core.sh
blobaf6c6104792d806c38ac7840257ab7b456829c4c
1 #! /bin/bash -e
3 OVERLAY="$1"
4 NAME="$2"
5 FREQ=40000
6 BASE=$(dirname "$0")
7 TARGET="$BASE"/core-$NAME
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
20 [ $# -ge 3 ] && FREQ="$3"
21 mkdir -p "$TARGET"
22 tar -xf "$OVERLAY" -C "$TARGET" --strip-components=1 \
23 --xform='s/core/core-isa/' config/core.h
24 tar -xf "$OVERLAY" -O gdb/xtensa-config.c | \
25 sed -n '1,/*\//p;/XTREG/,/XTREG_END/p' > "$TARGET"/gdb-config.inc.c
27 # Fix up known issues in the xtensa-modules.c
29 tar -xf "$OVERLAY" -O binutils/xtensa-modules.c | \
30 sed -e 's/\(xtensa_opcode_encode_fn.*\[\] =\)/static \1/' \
31 -e '/^int num_bypass_groups()/,/}/d' \
32 -e '/^int num_bypass_group_chunks()/,/}/d' \
33 -e '/^uint32 \*bypass_entry(int i)/,/}/d' \
34 -e '/^#include "ansidecl.h"/d' \
35 -e '/^Slot_[a-zA-Z0-9_]\+_decode (const xtensa_insnbuf insn)/,/^}/s/^ return 0;$/ return XTENSA_UNDEFINED;/' \
36 -e 's/#include <xtensa-isa.h>/#include "xtensa-isa.h"/' \
37 > "$TARGET"/xtensa-modules.inc.c
39 cat <<EOF > "${TARGET}.c"
40 #include "qemu/osdep.h"
41 #include "cpu.h"
42 #include "exec/exec-all.h"
43 #include "exec/gdbstub.h"
44 #include "qemu-common.h"
45 #include "qemu/host-utils.h"
47 #include "core-$NAME/core-isa.h"
48 #include "overlay_tool.h"
50 #define xtensa_modules xtensa_modules_$NAME
51 #include "core-$NAME/xtensa-modules.inc.c"
53 static XtensaConfig $NAME __attribute__((unused)) = {
54 .name = "$NAME",
55 .gdb_regmap = {
56 .reg = {
57 #include "core-$NAME/gdb-config.inc.c"
60 .isa_internal = &xtensa_modules,
61 .clock_freq_khz = $FREQ,
62 DEFAULT_SECTIONS
65 REGISTER_CORE($NAME)
66 EOF
68 grep -q core-${NAME}.o "$BASE"/Makefile.objs || \
69 echo "obj-y += core-${NAME}.o" >> "$BASE"/Makefile.objs