Changeset View
Changeset View
Standalone View
Standalone View
sys/sparc64/sparc64/dump_machdep.c
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | reg_write(struct dumperinfo *di, vm_paddr_t pa, vm_size_t size) | ||||
return (dumpsys_buf_write(di, (char *)&r, sizeof(r))); | return (dumpsys_buf_write(di, (char *)&r, sizeof(r))); | ||||
} | } | ||||
int | int | ||||
dumpsys(struct dumperinfo *di) | dumpsys(struct dumperinfo *di) | ||||
{ | { | ||||
static struct kerneldumpheader kdh; | static struct kerneldumpheader kdh; | ||||
struct sparc64_dump_hdr hdr; | struct sparc64_dump_hdr hdr; | ||||
vm_size_t size, totsize, hdrsize; | vm_size_t size, hdrsize; | ||||
int error, i, nreg; | int error, i, nreg; | ||||
/* Set up dump_map and calculate dump size. */ | /* Set up dump_map and calculate dump size. */ | ||||
size = 0; | size = 0; | ||||
nreg = sparc64_nmemreg; | nreg = sparc64_nmemreg; | ||||
memset(dump_map, 0, sizeof(dump_map)); | memset(dump_map, 0, sizeof(dump_map)); | ||||
for (i = 0; i < nreg; i++) { | for (i = 0; i < nreg; i++) { | ||||
dump_map[i].pa_start = sparc64_memreg[i].mr_start; | dump_map[i].pa_start = sparc64_memreg[i].mr_start; | ||||
size += dump_map[i].pa_size = sparc64_memreg[i].mr_size; | size += dump_map[i].pa_size = sparc64_memreg[i].mr_size; | ||||
} | } | ||||
/* Account for the header size. */ | /* Account for the header size. */ | ||||
hdrsize = roundup2(sizeof(hdr) + sizeof(struct sparc64_dump_reg) * nreg, | hdrsize = roundup2(sizeof(hdr) + sizeof(struct sparc64_dump_reg) * nreg, | ||||
DEV_BSIZE); | DEV_BSIZE); | ||||
size += hdrsize; | size += hdrsize; | ||||
totsize = size + 2 * di->blocksize + | |||||
kerneldumpcrypto_dumpkeysize(di->kdc); | |||||
if (totsize > di->mediasize) { | |||||
printf("Insufficient space on device (need %ld, have %ld), " | |||||
"refusing to dump.\n", (long)totsize, | |||||
(long)di->mediasize); | |||||
error = ENOSPC; | |||||
goto fail; | |||||
} | |||||
/* Determine dump offset on device. */ | |||||
dumplo = di->mediaoffset + di->mediasize - totsize; | |||||
/* Initialize kernel dump crypto. */ | |||||
error = kerneldumpcrypto_init(di->kdc); | |||||
if (error) | |||||
goto fail; | |||||
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size, | mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size, | ||||
kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); | kerneldumpcrypto_dumpkeysize(di->kdc), di->blocksize); | ||||
printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg); | printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg); | ||||
/* Dump leader */ | error = dump_start(di, &kdh, &dumplo); | ||||
error = dump_write_header(di, &kdh, 0, dumplo); | if (error != 0) | ||||
if (error) | |||||
goto fail; | goto fail; | ||||
dumplo += di->blocksize; | |||||
/* Dump key */ | |||||
error = dump_write_key(di, 0, dumplo); | |||||
if (error) | |||||
goto fail; | |||||
dumplo += kerneldumpcrypto_dumpkeysize(di->kdc); | |||||
/* Dump the private header. */ | /* Dump the private header. */ | ||||
hdr.dh_hdr_size = hdrsize; | hdr.dh_hdr_size = hdrsize; | ||||
hdr.dh_tsb_pa = tsb_kernel_phys; | hdr.dh_tsb_pa = tsb_kernel_phys; | ||||
hdr.dh_tsb_size = tsb_kernel_size; | hdr.dh_tsb_size = tsb_kernel_size; | ||||
hdr.dh_tsb_mask = tsb_kernel_mask; | hdr.dh_tsb_mask = tsb_kernel_mask; | ||||
hdr.dh_nregions = nreg; | hdr.dh_nregions = nreg; | ||||
if (dumpsys_buf_write(di, (char *)&hdr, sizeof(hdr)) != 0) | if (dumpsys_buf_write(di, (char *)&hdr, sizeof(hdr)) != 0) | ||||
Show All 9 Lines | dumpsys(struct dumperinfo *di) | ||||
} | } | ||||
dumpsys_buf_flush(di); | dumpsys_buf_flush(di); | ||||
/* Dump memory chunks. */ | /* Dump memory chunks. */ | ||||
error = dumpsys_foreach_chunk(dumpsys_cb_dumpdata, di); | error = dumpsys_foreach_chunk(dumpsys_cb_dumpdata, di); | ||||
if (error < 0) | if (error < 0) | ||||
goto fail; | goto fail; | ||||
/* Dump trailer */ | error = dump_finish(di, &kdh, dumplo); | ||||
error = dump_write_header(di, &kdh, 0, dumplo); | if (error != 0) | ||||
if (error) | |||||
goto fail; | goto fail; | ||||
dumplo += di->blocksize; | |||||
/* Signal completion, signoff and exit stage left. */ | |||||
dump_write(di, NULL, 0, 0, 0); | |||||
printf("\nDump complete\n"); | printf("\nDump complete\n"); | ||||
return (0); | return (0); | ||||
fail: | fail: | ||||
if (error < 0) | if (error < 0) | ||||
error = -error; | error = -error; | ||||
/* XXX It should look more like VMS :-) */ | /* XXX It should look more like VMS :-) */ | ||||
printf("** DUMP FAILED (ERROR %d) **\n", error); | printf("** DUMP FAILED (ERROR %d) **\n", error); | ||||
return (error); | return (error); | ||||
} | } |