Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / kernel / cpr / cpr_dump.c
blob314f0f478bab1e5c316e12cb1b22f4303f865c89
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Fill in and write out the cpr state file
28 * 1. Allocate and write headers, ELF and cpr dump header
29 * 2. Allocate bitmaps according to phys_install
30 * 3. Tag kernel pages into corresponding bitmap
31 * 4. Write bitmaps to state file
32 * 5. Write actual physical page data to state file
35 #include <sys/types.h>
36 #include <sys/systm.h>
37 #include <sys/vm.h>
38 #include <sys/memlist.h>
39 #include <sys/kmem.h>
40 #include <sys/vnode.h>
41 #include <sys/fs/ufs_inode.h>
42 #include <sys/errno.h>
43 #include <sys/cmn_err.h>
44 #include <sys/debug.h>
45 #include <vm/page.h>
46 #include <vm/seg.h>
47 #include <vm/seg_kmem.h>
48 #include <vm/seg_kpm.h>
49 #include <vm/hat.h>
50 #include <sys/cpr.h>
51 #include <sys/conf.h>
52 #include <sys/ddi.h>
53 #include <sys/panic.h>
54 #include <sys/thread.h>
55 #include <sys/note.h>
57 /* Local defines and variables */
58 #define BTOb(bytes) ((bytes) << 3) /* Bytes to bits, log2(NBBY) */
59 #define bTOB(bits) ((bits) >> 3) /* bits to Bytes, log2(NBBY) */
62 int cpr_flush_write(vnode_t *);
64 int cpr_contig_pages(vnode_t *, int);
66 void cpr_clear_bitmaps();
68 extern size_t cpr_get_devsize(dev_t);
69 extern int i_cpr_dump_setup(vnode_t *);
70 extern int i_cpr_blockzero(char *, char **, int *, vnode_t *);
71 extern int cpr_test_mode;
72 int cpr_setbit(pfn_t, int);
73 int cpr_clrbit(pfn_t, int);
75 ctrm_t cpr_term;
77 char *cpr_buf, *cpr_buf_end;
78 int cpr_buf_blocks; /* size of cpr_buf in blocks */
79 size_t cpr_buf_size; /* size of cpr_buf in bytes */
80 size_t cpr_bitmap_size;
81 int cpr_nbitmaps;
83 char *cpr_pagedata; /* page buffer for compression / tmp copy */
84 size_t cpr_pagedata_size; /* page buffer size in bytes */
87 char cpr_pagecopy[CPR_MAXCONTIG * MMU_PAGESIZE];
92 * creates the CPR state file, the following sections are
93 * written out in sequence:
94 * - writes the cpr dump header
95 * - writes the memory usage bitmaps
96 * - writes the platform dependent info
97 * - writes the remaining user pages
98 * - writes the kernel pages
100 #if defined(__x86)
101 _NOTE(ARGSUSED(0))
102 #endif
104 cpr_dump(vnode_t *vp)
107 return (0);