/* * Check to see if the system paniced, pause and then reboot * according to the specified delay. */ static void shutdown_panic(void *junk, int howto) { int loop; if (howto & RB_DUMP) { if (PANIC_REBOOT_WAIT_TIME != 0) { if (PANIC_REBOOT_WAIT_TIME != -1) { kprintf("Automatic reboot in %d seconds - " "press a key on the console to abort\n", PANIC_REBOOT_WAIT_TIME); for (loop = PANIC_REBOOT_WAIT_TIME * 10; loop > 0; --loop) { DELAY(1000 * 100); /* 1/10th second */ /* Did user type a key? */ if (cncheckc() != -1) break; } if (!loop) return; } } else { /* zero time specified - reboot NOW */ return; } kprintf("--> Press a key on the console to reboot,\n"); kprintf("--> or switch off the system now.\n"); cngetc(); } }
static int blk_dump(struct dumperinfo *di, vm_paddr_t pa, vm_size_t size) { vm_size_t pos, rsz; vm_offset_t va; int c, counter, error, twiddle; printf(" chunk at %#lx: %ld bytes ", (u_long)pa, (long)size); va = 0L; error = counter = twiddle = 0; for (pos = 0; pos < size; pos += MAXDUMPSZ, counter++) { if (counter % 128 == 0) printf("%c\b", "|/-\\"[twiddle++ & 3]); rsz = size - pos; rsz = (rsz > MAXDUMPSZ) ? MAXDUMPSZ : rsz; va = TLB_PHYS_TO_DIRECT(pa + pos); error = dump_write(di, (void *)va, 0, dumplo, rsz); if (error) break; dumplo += rsz; /* Check for user abort. */ c = cncheckc(); if (c == 0x03) return (ECANCELED); if (c != -1) printf("(CTRL-C to abort) "); } printf("... %s\n", (error) ? "fail" : "ok"); return (error); }
DB_SHOW_COMMAND(ktr, db_ktr_all) { tstate.cur = (ktr_idx - 1) & (KTR_ENTRIES - 1); tstate.first = -1; db_ktr_verbose = 0; db_ktr_verbose |= (index(modif, 'v') != NULL) ? 2 : 0; db_ktr_verbose |= (index(modif, 'V') != NULL) ? 1 : 0; /* just timestap please */ if (index(modif, 'a') != NULL) { db_disable_pager(); while (cncheckc() != -1) if (db_mach_vtrace() == 0) break; } else { while (!db_pager_quit) if (db_mach_vtrace() == 0) break; } }
void dumpsys(struct dumperinfo *di) { off_t dumplo; vm_offset_t a, addr; u_int count, left, u; void *va; int i, mb; int c; printf("Dumping %ld MB\n", Maxmem / (1024*1024 / PAGE_SIZE)); /* Fill in the kernel dump header */ strcpy(kdh.magic, KERNELDUMPMAGIC); strcpy(kdh.architecture, "amd64"); kdh.version = htod32(KERNELDUMPVERSION); kdh.architectureversion = htod32(KERNELDUMP_I386_VERSION); kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE); kdh.dumptime = htod64(time_second); kdh.blocksize = htod32(di->blocksize); strncpy(kdh.hostname, hostname, sizeof kdh.hostname); strncpy(kdh.versionstring, version, sizeof kdh.versionstring); if (panicstr != NULL) strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring); kdh.parity = kerneldump_parity(&kdh); /* * Check if we will have enough room to save the coredump. * The partition size needed is the sum of: * Memory to save + header + trailer + Room to leave untouched * at partition head. (an arbitrary amount). */ if (di->mediasize < Maxmem * (off_t)PAGE_SIZE + sizeof kdh * 2 + 64*1024) { printf("\nDump failed. Partition too small.\n"); return; } dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE; dumplo -= sizeof kdh * 2; i = di->dumper(di->priv, &kdh, 0, dumplo, sizeof kdh); if (i) printf("\nDump failed writing header (%d)\n", i); dumplo += sizeof kdh; i = 0; addr = 0; va = 0; mb = 0; for (count = 0; count < Maxmem;) { left = Maxmem - count; if (left > MAXDUMPPGS) left = MAXDUMPPGS; for (u = 0; u < left; u++) { a = addr + u * PAGE_SIZE; if (!is_physical_memory(a)) a = 0; va = pmap_kenter_temporary(trunc_page(a), u); } i = count / (16*1024*1024 / PAGE_SIZE); if (i != mb) { printf(" %d", count / (1024 * 1024 / PAGE_SIZE)); mb = i; } i = di->dumper(di->priv, va, 0, dumplo, left * PAGE_SIZE); if (i) break; count += left; dumplo += left * PAGE_SIZE; addr += left * PAGE_SIZE; if ((c = cncheckc()) == 0x03) { printf("\nDump aborted.\n"); return; } else if (c != -1) printf("[CTRL-C to abort] "); } if (i) printf("\nDump failed writing data (%d)\n", i); i = di->dumper(di->priv, &kdh, 0, dumplo, sizeof kdh); if (i) printf("\nDump failed writing trailer (%d)\n", i); di->dumper(di->priv, NULL, 0, 0, 0); /* tell them we are done */ printf("\nDump complete\n"); return; }