The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/amd64/amd64/dump_machdep.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2002 Poul-Henning Kamp
    3  * Copyright (c) 2002 Networks Associates Technology, Inc.
    4  * All rights reserved.
    5  *
    6  * This software was developed for the FreeBSD Project by Poul-Henning Kamp
    7  * and NAI Labs, the Security Research Division of Network Associates, Inc.
    8  * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
    9  * DARPA CHATS research program.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. The names of the authors may not be used to endorse or promote
   20  *    products derived from this software without specific prior written
   21  *    permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __FBSDID("$FreeBSD: releng/5.3/sys/amd64/amd64/dump_machdep.c 118031 2003-07-25 21:19:19Z obrien $");
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/conf.h>
   42 #include <sys/cons.h>
   43 #include <sys/kernel.h>
   44 #include <sys/kerneldump.h>
   45 #include <vm/vm.h>
   46 #include <vm/pmap.h>
   47 #include <machine/md_var.h>
   48 
   49 CTASSERT(sizeof(struct kerneldumpheader) == 512);
   50 
   51 static struct kerneldumpheader kdh;
   52 
   53 void
   54 dumpsys(struct dumperinfo *di)
   55 {
   56         off_t dumplo;
   57         vm_offset_t a, addr;
   58         u_int count, left, u;
   59         void *va;
   60         int i, mb;
   61         int c;
   62 
   63         printf("Dumping %ld MB\n", Maxmem / (1024*1024 / PAGE_SIZE));
   64 
   65         /* Fill in the kernel dump header */
   66         strcpy(kdh.magic, KERNELDUMPMAGIC);
   67         strcpy(kdh.architecture, "amd64");
   68         kdh.version = htod32(KERNELDUMPVERSION);
   69         kdh.architectureversion = htod32(KERNELDUMP_I386_VERSION);
   70         kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE);
   71         kdh.dumptime = htod64(time_second);
   72         kdh.blocksize = htod32(di->blocksize);
   73         strncpy(kdh.hostname, hostname, sizeof kdh.hostname);
   74         strncpy(kdh.versionstring, version, sizeof kdh.versionstring);
   75         if (panicstr != NULL)
   76                 strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring);
   77         kdh.parity = kerneldump_parity(&kdh);
   78 
   79         /*
   80          * Check if we will have enough room to save the coredump.
   81          * The partition size needed is the sum of:
   82          * Memory to save + header + trailer + Room to leave untouched
   83          * at partition head. (an arbitrary amount).
   84          */
   85         if (di->mediasize <  
   86             Maxmem * (off_t)PAGE_SIZE + sizeof kdh * 2 + 64*1024) {
   87                 printf("\nDump failed. Partition too small.\n");
   88                 return;
   89         }
   90         dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE;
   91         dumplo -= sizeof kdh * 2;
   92         i = di->dumper(di->priv, &kdh, 0, dumplo, sizeof kdh);
   93         if (i)
   94                 printf("\nDump failed writing header (%d)\n", i);
   95         dumplo += sizeof kdh;
   96         i = 0;
   97         addr = 0;
   98         va = 0;
   99         mb = 0;
  100         for (count = 0; count < Maxmem;) {
  101                 left = Maxmem - count;
  102                 if (left > MAXDUMPPGS)
  103                         left = MAXDUMPPGS;
  104                 for (u = 0; u < left; u++) {
  105                         a = addr + u * PAGE_SIZE;
  106                         if (!is_physical_memory(a))
  107                                 a = 0;
  108                         va = pmap_kenter_temporary(trunc_page(a), u);
  109                 }
  110                 i = count / (16*1024*1024 / PAGE_SIZE);
  111                 if (i != mb) {
  112                         printf(" %d", count / (1024 * 1024 / PAGE_SIZE));
  113                         mb = i;
  114                 }
  115                 i = di->dumper(di->priv, va, 0, dumplo, left * PAGE_SIZE);
  116                 if (i)
  117                         break;
  118                 count += left;
  119                 dumplo += left * PAGE_SIZE;
  120                 addr += left * PAGE_SIZE;
  121                 if ((c = cncheckc()) == 0x03) {
  122                         printf("\nDump aborted.\n");
  123                         return;
  124                 } else if (c != -1)
  125                         printf("[CTRL-C to abort] ");
  126         }
  127         if (i) 
  128                 printf("\nDump failed writing data (%d)\n", i);
  129         i = di->dumper(di->priv, &kdh, 0, dumplo, sizeof kdh);
  130         if (i)
  131                 printf("\nDump failed writing trailer (%d)\n", i);
  132         di->dumper(di->priv, NULL, 0, 0, 0);  /* tell them we are done */
  133         printf("\nDump complete\n");
  134         return;
  135 }

Cache object: 59e67e4170a45d449c996bb4fc3e6c9d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.