Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libkvm/kvm_minidump_mips.c
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | _mips_minidump_freevtop(kvm_t *kd) | ||||
free(vm); | free(vm); | ||||
kd->vmst = NULL; | kd->vmst = NULL; | ||||
} | } | ||||
static int | static int | ||||
_mips_minidump_initvtop(kvm_t *kd) | _mips_minidump_initvtop(kvm_t *kd) | ||||
{ | { | ||||
struct vmstate *vmst; | struct vmstate *vmst; | ||||
off_t off, sparse_off; | off_t off, dump_avail_off, sparse_off; | ||||
vmst = _kvm_malloc(kd, sizeof(*vmst)); | vmst = _kvm_malloc(kd, sizeof(*vmst)); | ||||
if (vmst == NULL) { | if (vmst == NULL) { | ||||
_kvm_err(kd, kd->program, "cannot allocate vm"); | _kvm_err(kd, kd->program, "cannot allocate vm"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
kd->vmst = vmst; | kd->vmst = vmst; | ||||
Show All 11 Lines | _mips_minidump_initvtop(kvm_t *kd) | ||||
} | } | ||||
if (strncmp(MINIDUMP_MAGIC, vmst->hdr.magic, | if (strncmp(MINIDUMP_MAGIC, vmst->hdr.magic, | ||||
sizeof(vmst->hdr.magic)) != 0) { | sizeof(vmst->hdr.magic)) != 0) { | ||||
_kvm_err(kd, kd->program, "not a minidump for this platform"); | _kvm_err(kd, kd->program, "not a minidump for this platform"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
vmst->hdr.version = _kvm32toh(kd, vmst->hdr.version); | vmst->hdr.version = _kvm32toh(kd, vmst->hdr.version); | ||||
if (vmst->hdr.version != MINIDUMP_VERSION) { | if (vmst->hdr.version != MINIDUMP_VERSION && vmst->hdr.version != 1) { | ||||
_kvm_err(kd, kd->program, "wrong minidump version. " | _kvm_err(kd, kd->program, "wrong minidump version. " | ||||
"Expected %d got %d", MINIDUMP_VERSION, vmst->hdr.version); | "Expected %d got %d", MINIDUMP_VERSION, vmst->hdr.version); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
vmst->hdr.msgbufsize = _kvm32toh(kd, vmst->hdr.msgbufsize); | vmst->hdr.msgbufsize = _kvm32toh(kd, vmst->hdr.msgbufsize); | ||||
vmst->hdr.bitmapsize = _kvm32toh(kd, vmst->hdr.bitmapsize); | vmst->hdr.bitmapsize = _kvm32toh(kd, vmst->hdr.bitmapsize); | ||||
vmst->hdr.ptesize = _kvm32toh(kd, vmst->hdr.ptesize); | vmst->hdr.ptesize = _kvm32toh(kd, vmst->hdr.ptesize); | ||||
vmst->hdr.kernbase = _kvm64toh(kd, vmst->hdr.kernbase); | vmst->hdr.kernbase = _kvm64toh(kd, vmst->hdr.kernbase); | ||||
vmst->hdr.dmapbase = _kvm64toh(kd, vmst->hdr.dmapbase); | vmst->hdr.dmapbase = _kvm64toh(kd, vmst->hdr.dmapbase); | ||||
vmst->hdr.dmapend = _kvm64toh(kd, vmst->hdr.dmapend); | vmst->hdr.dmapend = _kvm64toh(kd, vmst->hdr.dmapend); | ||||
vmst->hdr.dumpavailsize = vmst->hdr.version == MINIDUMP_VERSION ? | |||||
_kvm32toh(kd, vmst->hdr.dumpavailsize) : 0; | |||||
/* Skip header and msgbuf */ | /* Skip header and msgbuf */ | ||||
off = MIPS_PAGE_SIZE + mips_round_page(vmst->hdr.msgbufsize); | dump_avail_off = MIPS_PAGE_SIZE + mips_round_page(vmst->hdr.msgbufsize); | ||||
/* Skip dump_avail */ | |||||
off = dump_avail_off + mips_round_page(vmst->hdr.dumpavailsize); | |||||
sparse_off = off + mips_round_page(vmst->hdr.bitmapsize) + | sparse_off = off + mips_round_page(vmst->hdr.bitmapsize) + | ||||
mips_round_page(vmst->hdr.ptesize); | mips_round_page(vmst->hdr.ptesize); | ||||
if (_kvm_pt_init(kd, vmst->hdr.bitmapsize, off, sparse_off, | if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, | ||||
MIPS_PAGE_SIZE, sizeof(uint32_t)) == -1) { | vmst->hdr.bitmapsize, off, sparse_off, MIPS_PAGE_SIZE, | ||||
sizeof(uint32_t)) == -1) { | |||||
return (-1); | return (-1); | ||||
} | } | ||||
off += mips_round_page(vmst->hdr.bitmapsize); | off += mips_round_page(vmst->hdr.bitmapsize); | ||||
if (_kvm_pmap_init(kd, vmst->hdr.ptesize, off) == -1) { | if (_kvm_pmap_init(kd, vmst->hdr.ptesize, off) == -1) { | ||||
return (-1); | return (-1); | ||||
} | } | ||||
off += mips_round_page(vmst->hdr.ptesize); | off += mips_round_page(vmst->hdr.ptesize); | ||||
▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines |