Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/i386/minidump_machdep.c
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
#define MD_ALIGN(x) (((off_t)(x) + PAGE_MASK) & ~PAGE_MASK) | #define MD_ALIGN(x) (((off_t)(x) + PAGE_MASK) & ~PAGE_MASK) | ||||
#define DEV_ALIGN(x) roundup2((off_t)(x), DEV_BSIZE) | #define DEV_ALIGN(x) roundup2((off_t)(x), DEV_BSIZE) | ||||
uint32_t *vm_page_dump; | uint32_t *vm_page_dump; | ||||
int vm_page_dump_size; | int vm_page_dump_size; | ||||
static struct kerneldumpheader kdh; | static struct kerneldumpheader kdh; | ||||
static off_t dumplo; | |||||
/* Handle chunked writes. */ | /* Handle chunked writes. */ | ||||
static size_t fragsz; | static size_t fragsz; | ||||
static void *dump_va; | static void *dump_va; | ||||
static uint64_t counter, progress; | static uint64_t counter, progress; | ||||
CTASSERT(sizeof(*vm_page_dump) == 4); | CTASSERT(sizeof(*vm_page_dump) == 4); | ||||
Show All 15 Lines | |||||
static int | static int | ||||
blk_flush(struct dumperinfo *di) | blk_flush(struct dumperinfo *di) | ||||
{ | { | ||||
int error; | int error; | ||||
if (fragsz == 0) | if (fragsz == 0) | ||||
return (0); | return (0); | ||||
error = dump_write(di, dump_va, 0, dumplo, fragsz); | error = dump_write(di, dump_va, 0, fragsz); | ||||
dumplo += fragsz; | |||||
fragsz = 0; | fragsz = 0; | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) | blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) | ||||
{ | { | ||||
size_t len; | size_t len; | ||||
Show All 31 Lines | while (sz) { | ||||
if (counter >> 24) { | if (counter >> 24) { | ||||
printf(" %lld", PG2MB(progress >> PAGE_SHIFT)); | printf(" %lld", PG2MB(progress >> PAGE_SHIFT)); | ||||
counter &= (1<<24) - 1; | counter &= (1<<24) - 1; | ||||
} | } | ||||
wdog_kern_pat(WD_LASTVAL); | wdog_kern_pat(WD_LASTVAL); | ||||
if (ptr) { | if (ptr) { | ||||
error = dump_write(di, ptr, 0, dumplo, len); | error = dump_write(di, ptr, 0, len); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
dumplo += len; | |||||
ptr += len; | ptr += len; | ||||
sz -= len; | sz -= len; | ||||
} else { | } else { | ||||
for (i = 0; i < len; i += PAGE_SIZE) | for (i = 0; i < len; i += PAGE_SIZE) | ||||
dump_va = pmap_kenter_temporary(pa + i, (i + fragsz) >> PAGE_SHIFT); | dump_va = pmap_kenter_temporary(pa + i, (i + fragsz) >> PAGE_SHIFT); | ||||
fragsz += len; | fragsz += len; | ||||
pa += len; | pa += len; | ||||
sz -= len; | sz -= len; | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize, | mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize, | ||||
di->blocksize); | di->blocksize); | ||||
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576); | printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576); | ||||
printf("Dumping %llu MB:", (long long)dumpsize >> 20); | printf("Dumping %llu MB:", (long long)dumpsize >> 20); | ||||
error = dump_start(di, &kdh, &dumplo); | error = dump_start(di, &kdh); | ||||
if (error != 0) | if (error != 0) | ||||
goto fail; | goto fail; | ||||
/* Dump my header */ | /* Dump my header */ | ||||
bzero(&fakept, sizeof(fakept)); | bzero(&fakept, sizeof(fakept)); | ||||
bcopy(&mdhdr, &fakept, sizeof(mdhdr)); | bcopy(&mdhdr, &fakept, sizeof(mdhdr)); | ||||
error = blk_write(di, (char *)&fakept, 0, PAGE_SIZE); | error = blk_write(di, (char *)&fakept, 0, PAGE_SIZE); | ||||
if (error) | if (error) | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | while (bits) { | ||||
bits &= ~(1ul << bit); | bits &= ~(1ul << bit); | ||||
} | } | ||||
} | } | ||||
error = blk_flush(di); | error = blk_flush(di); | ||||
if (error) | if (error) | ||||
goto fail; | goto fail; | ||||
error = dump_finish(di, &kdh, dumplo); | error = dump_finish(di, &kdh); | ||||
if (error != 0) | if (error != 0) | ||||
goto fail; | goto fail; | ||||
printf("\nDump complete\n"); | printf("\nDump complete\n"); | ||||
return (0); | return (0); | ||||
fail: | fail: | ||||
if (error < 0) | if (error < 0) | ||||
Show All 33 Lines |