fclose(f);
}
+static void dump(const char src[], const uint8_t ram[]) {
+ const char *ptr = strchr(src, ':');
+ if (!ptr) {
+ printf("Invalid dump\n");
+ exit(1);
+ }
+
+ char name[PATH_MAX];
+ memcpy(name, src, ptr - src);
+ name[ptr - src] = '\0';
+
+ ptr++;
+ const uint32_t addr = strtol(ptr, NULL, 0);
+
+ ptr = strchr(ptr, ':');
+ if (!ptr) {
+ printf("Invalid dump\n");
+ exit(1);
+ }
+
+ ptr++;
+ const uint32_t len = strtol(ptr, NULL, 0);
+
+ //printf("Saving to %s, from %x, len %u\n", name, addr, len);
+
+ FILE *f = fopen(name, "w");
+ if (!f) {
+ printf("Can't open %s\n", name);
+ exit(1);
+ }
+
+ if (fwrite(&ram[addr], len, 1, f) != 1)
+ abort();
+
+ fclose(f);
+}
+
static void setfpregs(const int vcpu, struct kvm_fpu *fpregs) {
// KVM_[SG]ET_FPU isn't supported on PPC, we have to move individual regs...
unsigned i;
printf("Exited because %u\n", run->exit_reason);
}
+ unsigned i;
+ for (i = 0; i < num_dumps; i++) {
+ dump(dumps[i], ram);
+ }
+
close(kvm);
free(progmem);
free(ram);