+ }
+
+ return 0;
+}
+
+static int s390x_write_elf64_fpregset(note_t *note, CPUArchState *env)
+{
+ int i;
+
+ note->hdr.n_type = cpu_to_be32(NT_FPREGSET);
+
+ note->contents.fpregset.fpc = cpu_to_be32(env->fpc);
+ for (i = 0; i <= 15; i++) {
+ note->contents.fpregset.fprs[i] = cpu_to_be64(env->fregs[i].ll);
+ }
+
+ return 0;
+}
+
+
+static int s390x_write_elf64_timer(note_t *note, CPUArchState *env)
+{
+ note->hdr.n_type = cpu_to_be32(NT_S390_TIMER);
+
+ note->contents.timer = cpu_to_be64((uint64_t)(env->cputm));
+
+ return 0;
+}
+
+static int s390x_write_elf64_todcmp(note_t *note, CPUArchState *env)
+{
+ note->hdr.n_type = cpu_to_be32(NT_S390_TODCMP);
+
+ note->contents.todcmp = cpu_to_be64((uint64_t)(env->ckc));
+
+ return 0;
+}
+
+static int s390x_write_elf64_todpreg(note_t *note, CPUArchState *env)
+{
+ note->hdr.n_type = cpu_to_be32(NT_S390_TODPREG);
+
+ note->contents.todpreg = cpu_to_be32((uint32_t)(env->todpr));
+
+ return 0;
+}
+
+static int s390x_write_elf64_ctrs(note_t *note, CPUArchState *env)
+{
+ int i;
+
+ note->hdr.n_type = cpu_to_be32(NT_S390_CTRS);
+
+ for (i = 0; i <= 15; i++) {
+ note->contents.ctrs[i] = cpu_to_be32(env->cregs[i]);
+ }
+
+ return 0;
+}
+
+static int s390x_write_elf64_prefix(note_t *note, CPUArchState *env)
+{
+ note->hdr.n_type = cpu_to_be32(NT_S390_PREFIX);
+
+ note->contents.prefix = cpu_to_be32((uint32_t)(env->psa));
+
+ return 0;
+}
+
+
+struct note_func_desc_struct {
+ int contents_size;
+ int (*note_contents_func)(note_t *note, CPUArchState *env);
+} note_func[] = {
+ { sizeof(((note_t *)0)->contents.prstatus), s390x_write_elf64_prstatus },
+ { sizeof(((note_t *)0)->contents.prefix), s390x_write_elf64_prefix },
+ { sizeof(((note_t *)0)->contents.fpregset), s390x_write_elf64_fpregset },
+ { sizeof(((note_t *)0)->contents.ctrs), s390x_write_elf64_ctrs },
+ { sizeof(((note_t *)0)->contents.timer), s390x_write_elf64_timer },
+ { sizeof(((note_t *)0)->contents.todcmp), s390x_write_elf64_todcmp },
+ { sizeof(((note_t *)0)->contents.todpreg), s390x_write_elf64_todpreg },
+
+ { 0, NULL}
+};
+
+
+static int s390x_write_all_elf64_notes(const char *note_name,
+ WriteCoreDumpFunction f,
+ CPUArchState *env,
+ int id,
+ void *opaque)
+{
+ note_t note;
+ struct note_func_desc_struct *nf;
+ int note_size;
+ int ret = -1;
+
+ for (nf = note_func; nf->note_contents_func; nf++) {
+ note.hdr.n_namesz = cpu_to_be32(sizeof(note.name));
+ note.hdr.n_descsz = cpu_to_be32(nf->contents_size);
+ strncpy(note.name, note_name, sizeof(note.name));
+ ret = (*nf->note_contents_func)(¬e, env);
+
+ note_size = cpu_to_be32(sizeof(note) -
+ sizeof(note.contents) +
+ nf->contents_size);
+ ret = f(¬e, note_size, opaque);
+
+ if (ret < 0) {
+ return -1;
+ }
+
+ }
+
+ return 0;
+}
+
+
+int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
+ int cpuid, void *opaque)
+{
+ S390CPU *cpu = S390_CPU(cs);
+ return s390x_write_all_elf64_notes("CORE", f, &cpu->env, cpuid, opaque);
+}
+
+int cpu_get_dump_info(ArchDumpInfo *info)
+{
+ info->d_machine = EM_S390;
+ info->d_endian = ELFDATA2MSB;
+ info->d_class = ELFCLASS64;
+
+ return 0;
+}
+
+ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)
+{
+ int name_size = 8; /* "CORE" or "QEMU" rounded*/
+ size_t elf_note_size = 0;
+ int note_head_size;
+ struct note_func_desc_struct *nf;
+
+ assert(class == ELFCLASS64);
+ note_head_size = sizeof(Elf64_Nhdr);
+
+ assert(machine == EM_S390);
+
+ for (nf = note_func; nf->note_contents_func; nf++) {
+ elf_note_size = elf_note_size +
+ note_head_size +
+ name_size +
+ nf->contents_size;
+ }
+
+ return (elf_note_size) * nr_cpus;
+
+}
+
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index 34d45c2..3370fb9 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -73,4 +73,25 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)
void s390_cpu_do_interrupt(CPUState *cpu);
+int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque);
+
+static inline int s390_cpu_write_elf64_qemunote(WriteCoreDumpFunction f,
+ CPUState *env, void *opaque)
+{
+ return 0;
+}
+
+static inline int s390_cpu_write_elf32_qemunote(WriteCoreDumpFunction f,
+ CPUState *env, void *opaque)
+{
+ return 0;
+}
+
+static inline int s390_cpu_write_elf32_note(WriteCoreDumpFunction f,
+ CPUState *env, int cpuid, void *opaque)
+{
+ return 0;
+}
+
#endif
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 23fe51f..27cfbc0 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -27,6 +27,7 @@
#include "qemu-common.h"
#include "qemu/timer.h"
#include "hw/hw.h"
+#include "cpu-qom.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu/arch_init.h"
#endif
@@ -168,6 +169,12 @@ static void s390_cpu_class_init(ObjectClass *oc, void
*data)
scc->parent_reset = cc->reset;
cc->reset = s390_cpu_reset;
+#if !defined(CONFIG_USER_ONLY)
+ cc->write_elf64_note = s390_cpu_write_elf64_note;
+ cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote;
+ cc->write_elf32_note = s390_cpu_write_elf32_note;
+ cc->write_elf32_qemunote = s390_cpu_write_elf32_qemunote;
+#endif
cc->do_interrupt = s390_cpu_do_interrupt;
dc->vmsd = &vmstate_s390_cpu;
--
1.7.12.4