xref: /titanic_51/usr/src/uts/common/sys/cpr.h (revision bc98fec63b7c15cd5221dc0353042ebadc1872c7)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_CPR_H
27 #define	_SYS_CPR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/obpdefs.h>
36 #include <sys/param.h>
37 #include <sys/mutex.h>
38 #include <sys/uadmin.h>
39 #include <sys/compress.h>
40 #include <sys/archsystm.h>
41 
42 /*
43  * definitions for kernel, cprboot, pmconfig
44  */
45 #define	CPR_VERSION		6
46 #define	CPR_CONFIG		"/etc/.cpr_config"
47 
48 
49 /*
50  * magic numbers for cpr files
51  */
52 #define	CPR_CONFIG_MAGIC	0x436E4667	/* 'CnFg' */
53 #define	CPR_DEFAULT_MAGIC	0x44664C74	/* 'DfLt' */
54 
55 /*
56  * max(strlen("true"), strlen("false")) + 1
57  */
58 #define	PROP_BOOL_LEN		6
59 #define	PROP_MOD		'Y'
60 #define	PROP_NOMOD		'N'
61 
62 /*
63  * max property name length used
64  * max property count
65  */
66 #define	CPR_MAXPLEN		15
67 #define	CPR_MAXPROP		5
68 
69 /*
70  * name/value of nvram properties
71  */
72 struct cpr_prop_info {
73 	char	mod;
74 	char	name[CPR_MAXPLEN];
75 	char	value[OBP_MAXPATHLEN];
76 };
77 typedef struct cpr_prop_info cprop_t;
78 
79 struct cpr_default_mini {
80 	int	magic;				/* magic word for booter */
81 	int	reusable;			/* true if resuable statefile */
82 };
83 typedef struct cpr_default_mini cmini_t;
84 
85 struct cpr_default_info {
86 	cmini_t	mini;
87 	cprop_t	props[CPR_MAXPROP];		/* nvram property info */
88 };
89 typedef struct cpr_default_info cdef_t;
90 
91 
92 /*
93  * Configuration info provided by user via pmconfig.
94  *
95  * The first part (cf_type, cf_path, cf_fs, cf_devfs, cf_dev_prom)
96  * is used by both the cpr kernel module and cpr booter program
97  * to locate the statefile.
98  *
99  * cf_type	CFT_UFS
100  * cf_path	(path within file system) ".CPR"
101  * cf_fs	(mount point for the statefile's filesystem) "/export/home"
102  * cf_devfs	(devfs path of disk parition mounted there) "/dev/dsk/c0t0d0s7"
103  * cf_dev_prom	(prom device path of the above disk partition)
104  *			"/sbus/espdma/dma/sd@0:h"
105  *
106  * If the statefile were on a character special device (/dev//rdsk/c0t1d0s7),
107  * the fields would have the typical values shown below:
108  *
109  * cf_type	CFT_SPEC
110  * cf_path	ignored
111  * cf_fs	ignored
112  * cf_devfs	/dev/rdsk/c1t0d0s7
113  * cf_dev_prom	(prom device path of the above special file)
114  *			"/sbus/espdma/dma/sd@1:h"
115  *
116  * If the statefile is on a zvol, the fields would have these values:
117  *
118  * cf_type	CFT_ZVOL
119  * cf_path	ignored
120  * cf_fs	(the zvol name e.g. "dump" portion of rootpool/dump)
121  * cf_devfs	(devfs path) "/dev/zvol/dsk/<pool>/<zvol>"
122  * cf_dev_prom	(prom device path of the above special file)
123  *		e.g. "/sbus/espdma/dma/sd@1:h"
124  *
125  * The rest of the fields are autoshutdown and autopm configuration related.
126  * They are updated by pmconfig and consumed by both powerd and dtpower.
127  */
128 
129 struct cprconfig {
130 	int	cf_magic;			/* magic word for	*/
131 						/* booter to verify	*/
132 	int	cf_type;			/* CFT_UFS or CFT_SPEC	*/
133 	char	cf_path[MAXNAMELEN];		/* fs-relative path	*/
134 						/* for the state file	*/
135 	char	cf_fs[MAXNAMELEN];		/* mount point for fs	*/
136 						/* holding state file	*/
137 	char	cf_devfs[MAXNAMELEN];		/* path to device node	*/
138 						/* for above mount pt.	*/
139 	char	cf_dev_prom[OBP_MAXPATHLEN];	/* full device path of	*/
140 						/* above filesystem	*/
141 	/*
142 	 * autoshutdown configuration fields
143 	 */
144 	int	is_cpr_capable;			/* 0 - False, 1 - True */
145 	int	is_cpr_default;			/* 0 - False, 1 - True */
146 	int	is_autowakeup_capable;		/* 0 - False, 1 - True */
147 	int	as_idle;			/* idle time in min */
148 	int	as_sh;				/* Start_time hour */
149 	int	as_sm;				/* Start_time minutes */
150 	int	as_fh;				/* Finish_time hour */
151 	int	as_fm;				/* Finish_time minute */
152 	char	as_behavior[64];		/* "default","unconfigured", */
153 						/* "shutdown", "autowakeup" */
154 						/*  or "noshutdown" */
155 	int	ttychars_thold;			/* default = 0 */
156 	float	loadaverage_thold;		/* default = 0.04  */
157 	int	diskreads_thold;		/* default = 0 */
158 	int	nfsreqs_thold;			/* default = 0 */
159 	char	idlecheck_path[MAXPATHLEN];	/* default = "" */
160 
161 	/*
162 	 * autopm behavior field
163 	 */
164 	int	is_autopm_default;		/* 0 - False, 1 - True */
165 	char	apm_behavior[64];		/* "enable","disable" or */
166 						/* "default" */
167 };
168 
169 
170 /*
171  * values for cf_type
172  */
173 #define	CFT_UFS		1		/* statefile is ufs file	*/
174 #define	CFT_SPEC	2		/* statefile is special file	*/
175 #define	CFT_ZVOL	3		/* statefile is a zvol		*/
176 
177 
178 /*
179  * definitions for kernel, cprboot
180  */
181 #ifdef _KERNEL
182 
183 #include <sys/promif.h>
184 #include <sys/sunddi.h>
185 #include <sys/sysmacros.h>
186 #include <sys/vnode.h>
187 #include <sys/cpr_impl.h>
188 
189 extern int	cpr_debug;
190 
191 #define	errp	prom_printf
192 #define	DPRINT
193 
194 /*
195  * CPR_DEBUG1 displays the main flow of CPR. Use it to identify which
196  * sub-module of CPR causes problems.
197  * CPR_DEBUG2 displays minor stuff that normally won't matter.
198  * CPR_DEBUG3 displays some big loops (cpr_dump); requires much longer runtime.
199  * CPR_DEBUG4 displays lots of cprboot output, cpr_read and page handling.
200  * CPR_DEBUG5 various, mostly unique stuff
201  * CPR_DEBUG9 displays statistical data for CPR on console (by using printf),
202  *	such as num page invalidated, etc.
203  */
204 #define	CPR_DEBUG1	0x1
205 #define	CPR_DEBUG2	0x2
206 #define	CPR_DEBUG3	0x4
207 #define	CPR_DEBUG4	0x8
208 #define	CPR_DEBUG5	0x10
209 #define	CPR_DEBUG6	0x20
210 #define	CPR_DEBUG7	0x40
211 #define	CPR_DEBUG8	0x80
212 #define	CPR_DEBUG9	CPR_DEBUG6
213 
214 #define	CPR_DEBUG(level, ...) if (cpr_debug & level) cpr_dprintf(__VA_ARGS__)
215 
216 #define	CPR_DEBUG_BIT(dval)	(1 << (dval - AD_CPR_DEBUG0 - 1))
217 #define	DBG_DONTSHOWRANGE	0
218 #define	DBG_SHOWRANGE		1
219 
220 /*
221  * CPR FILE FORMAT:
222  *
223  * 	Dump Header: general dump data:
224  *		cpr_dump_desc
225  *
226  *	Machdep descriptor: cpr_machdep_desc
227  *	Machdep data: sun4m/sun4u machine dependent info:
228  *		cpr_sun4m_machdep
229  *		cpr_sun4u_machdep, var length prom words
230  *
231  * 	Page Map: bitmap record consisting of a descriptor and data:
232  *		cpr_bitmap_desc
233  *		(char) bitmap[cpr_bitmap_desc.cbd_size]
234  *
235  * 	Page data: Contains one or more physical page records,
236  *		each record consists of a descriptor and data:
237  *		cpr_page_desc
238  *		(char) page_data[cpr_page_desc.cpd_offset]
239  *
240  *	Terminator: end marker
241  *		cpr_terminator
242  *
243  *	NOTE: cprboot now supports both ILP32 and LP64 kernels;
244  *	the size of these structures written to a cpr statefile
245  *	must be the same for ILP32 and LP64.  For details, see
246  *	sun4u/sys/cpr_impl.h
247  */
248 
249 #define	CPR_DUMP_MAGIC		0x44754d70	/* 'DuMp' */
250 #define	CPR_BITMAP_MAGIC	0x42744d70	/* 'BtMp' */
251 #define	CPR_PAGE_MAGIC		0x50614765	/* 'PaGe' */
252 #define	CPR_MACHDEP_MAGIC	0x4d614470	/* 'MaDp' */
253 #define	CPR_TERM_MAGIC		0x5465526d	/* 'TeRm' */
254 
255 /*
256  * header at the begining of the dump data section
257  */
258 struct cpr_dump_desc {
259 	uint_t		cdd_magic;	/* paranoia check */
260 	ushort_t	cdd_version;	/* version number */
261 	ushort_t	cdd_machine;	/* sun4m, sun4u */
262 	int		cdd_bitmaprec;	/* number of bitmap records */
263 	int		cdd_dumppgsize;	/* total # of frames dumped, in pages */
264 	int		cdd_test_mode;	/* true if called by uadmin test mode */
265 	int		cdd_debug;	/* turn on debug in cprboot */
266 	cpr_ext		cdd_filesize;	/* statefile size in bytes */
267 };
268 typedef struct cpr_dump_desc cdd_t;
269 
270 /*
271  * physical memory bitmap descriptor, preceeds the actual bitmap.
272  */
273 struct cpr_bitmap_desc {
274 	uint_t		cbd_magic;	/* so we can spot it better */
275 	pfn_t		cbd_spfn;   	/* starting pfn */
276 	pfn_t		cbd_epfn;	/* ending pfn */
277 	size_t		cbd_size;	/* size of this bitmap, in bytes */
278 	cpr_ptr		cbd_reg_bitmap;	/* regular bitmap */
279 	cpr_ptr		cbd_vlt_bitmap; /* volatile bitmap */
280 	cpr_ptr		cbd_auxmap; 	/* aux bitmap used during thaw */
281 };
282 typedef struct cpr_bitmap_desc cbd_t;
283 
284 /*
285  * Maximum supported bitmap descriptors; 1-2 + null-terminator is common
286  */
287 #define	CPR_MAX_BMDESC	(16 + 1)
288 
289 /*
290  * Describes the contiguous pages saved in the storage area.
291  * To save space data will be compressed before saved.
292  * However some data end up bigger after compression.
293  * In that case, we save the raw data and make a note
294  * of it in the csd_clean_compress field.
295  */
296 struct cpr_storage_desc {
297 	pfn_t		csd_dirty_spfn;		/* starting dirty pfn */
298 	pgcnt_t		csd_dirty_npages;
299 	cpr_ptr		csd_clean_sva;		/* starting clean va */
300 	size_t		csd_clean_sz;
301 	int		csd_clean_compressed;
302 #ifdef DEBUG
303 	uint_t		csd_usum;
304 	uint_t		csd_csum;
305 #endif
306 };
307 typedef struct cpr_storage_desc csd_t;
308 
309 /*
310  * Describes saved pages, preceeds page data;
311  * cpd_lenth len is important when pages are compressed.
312  */
313 struct cpr_page_desc {
314 	uint_t	cpd_magic;	/* so we can spot it better */
315 	pfn_t	cpd_pfn;   	/* kern physical address page # */
316 	pgcnt_t	cpd_pages;	/* number of contiguous pages */
317 	size_t	cpd_length;	/* data segment size in bytes */
318 	uint_t	cpd_flag;	/* see below */
319 	uint_t	cpd_csum;	/* "after compression" checksum */
320 	uint_t	cpd_usum;	/* "before compression" checksum */
321 };
322 typedef struct cpr_page_desc cpd_t;
323 
324 /*
325  * cpd_flag values
326  */
327 #define	CPD_COMPRESS	0x0001	/* set if compressed */
328 #define	CPD_CSUM	0x0002	/* set if "after compression" checsum valid */
329 #define	CPD_USUM	0x0004	/* set if "before compression" checsum valid */
330 
331 /*
332  * machdep header stores the length of the platform specific information
333  * that are used by resume.
334  *
335  * Note: the md_size field is the total length of the machine dependent
336  * information.  This always includes a fixed length section and may
337  * include a variable length section following it on some platforms.
338  */
339 struct cpr_machdep_desc {
340 	uint_t md_magic;	/* paranoia check */
341 	uint_t md_size;		/* the size of the "opaque" data following */
342 };
343 typedef struct cpr_machdep_desc cmd_t;
344 
345 typedef struct timespec32 cpr_time_t;
346 
347 struct cpr_terminator {
348 	uint_t	magic;			/* paranoia check */
349 	size_t	real_statef_size;	/* ...in bytes */
350 	cpr_ptr	va;			/* virtual addr of this struct */
351 	cpr_ext	pfn;			/* phys addr of this struct */
352 	cpr_time_t tm_shutdown;		/* time in milisec when shutdown */
353 	cpr_time_t tm_cprboot_start;	/* time when cprboot starts to run */
354 	cpr_time_t tm_cprboot_end;	/* time before jumping to kernel */
355 };
356 typedef struct cpr_terminator ctrm_t;
357 
358 
359 #define	REGULAR_BITMAP		1
360 #define	VOLATILE_BITMAP		0
361 
362 /*
363  * reference the right bitmap based on the arg descriptor and flag
364  */
365 #define	DESC_TO_MAP(desc, flag)	(flag == REGULAR_BITMAP) ? \
366 	(char *)desc->cbd_reg_bitmap : (char *)desc->cbd_vlt_bitmap
367 /*
368  * checks if a phys page is within the range covered by a bitmap
369  */
370 #define	PPN_IN_RANGE(ppn, desc) \
371 	(ppn <= desc->cbd_epfn && ppn >= desc->cbd_spfn)
372 
373 #define	WRITE_TO_STATEFILE	0
374 #define	SAVE_TO_STORAGE		1
375 #define	STORAGE_DESC_ALLOC	2
376 
377 
378 /*
379  * prom_read() max is 32k
380  * for sun4m, page size is 4k, CPR_MAXCONTIG is 8
381  * for sun4u, page size is 8k, CPR_MAXCONTIG is 4
382  */
383 #define	PROM_MAX_READ	0x8000
384 #define	CPR_MAX_BLOCK	0x8000
385 #define	CPR_MAXCONTIG	(CPR_MAX_BLOCK / MMU_PAGESIZE)
386 
387 #define	PAGE_ROUNDUP(val)	(((val) + MMU_PAGEOFFSET) & MMU_PAGEMASK)
388 
389 /*
390  * converts byte size to bitmap size; 1 bit represents one phys page
391  */
392 #define	BITMAP_BYTES(size)	((size) >> (MMU_PAGESHIFT + 3))
393 
394 
395 /*
396  * redefinitions of uadmin subcommands for A_FREEZE
397  */
398 #define	AD_CPR_COMPRESS		AD_COMPRESS /* store state file compressed */
399 #define	AD_CPR_FORCE		AD_FORCE /* force to do AD_CPR_COMPRESS */
400 #define	AD_CPR_CHECK		AD_CHECK /* test if CPR module is there */
401 #define	AD_CPR_REUSEINIT	AD_REUSEINIT /* write cprinfo file */
402 #define	AD_CPR_REUSABLE		AD_REUSABLE /* create reusable statefile */
403 #define	AD_CPR_REUSEFINI	AD_REUSEFINI /* revert to non-reusable CPR */
404 #define	AD_CPR_TESTHALT		6	/* test mode, halt */
405 #define	AD_CPR_TESTNOZ		7	/* test mode, auto-restart uncompress */
406 #define	AD_CPR_TESTZ		8	/* test mode, auto-restart compress */
407 #define	AD_CPR_PRINT		9	/* print out stats */
408 #define	AD_CPR_NOCOMPRESS	10	/* store state file uncompressed */
409 #define	AD_CPR_SUSP_DEVICES	11	/* Only suspend resume devices */
410 #define	AD_CPR_DEBUG0		100	/* clear debug flag */
411 #define	AD_CPR_DEBUG1		101	/* display CPR main flow via prom */
412 #define	AD_CPR_DEBUG2		102	/* misc small/mid size loops */
413 #define	AD_CPR_DEBUG3		103	/* exhaustive big loops */
414 #define	AD_CPR_DEBUG4		104	/* debug cprboot */
415 #define	AD_CPR_DEBUG5		105	/* debug machdep part of resume */
416 #define	AD_CPR_DEBUG7		107	/* debug bitmap code */
417 #define	AD_CPR_DEBUG8		108
418 #define	AD_CPR_DEBUG9		109	/* display stat data on console */
419 
420 /*
421  * Suspend to RAM test points.
422  * Probably belong above, but are placed here for now.
423  */
424 /* S3 leave hardware on and return success */
425 #define	AD_LOOPBACK_SUSPEND_TO_RAM_PASS	22
426 
427 /* S3 leave hardware on and return failure */
428 #define	AD_LOOPBACK_SUSPEND_TO_RAM_FAIL	23
429 
430 /* S3 ignored devices that fail to suspend */
431 #define	AD_FORCE_SUSPEND_TO_RAM		24
432 
433 /* S3 on a specified device */
434 #define	AD_DEVICE_SUSPEND_TO_RAM	25
435 
436 
437 
438 /*
439  * Temporary definition of the Suspend to RAM development subcommands
440  * so that non-ON apps will work after initial integration.
441  */
442 #define	DEV_SUSPEND_TO_RAM	200
443 #define	DEV_CHECK_SUSPEND_TO_RAM	201
444 
445 /*
446  * cprboot related information and definitions.
447  * The statefile names are hardcoded for now.
448  */
449 #define	CPR_DEFAULT		"/.cpr_default"
450 #define	CPR_STATE_FILE		"/.CPR"
451 
452 
453 /*
454  * definitions for CPR statistics
455  */
456 #define	CPR_E_NAMELEN		64
457 #define	CPR_E_MAX_EVENTNUM	64
458 
459 struct cpr_tdata {
460 	time_t	mtime;		/* mean time on this event */
461 	time_t	stime;		/* start time on this event */
462 	time_t	etime;		/* end time on this event */
463 	time_t	ltime;		/* time duration of the last event */
464 };
465 typedef struct cpr_tdata ctd_t;
466 
467 struct cpr_event {
468 	struct	cpr_event *ce_next;	/* next event in the list */
469 	long	ce_ntests;		/* num of the events since loaded */
470 	ctd_t	ce_sec;			/* cpr time in sec on this event */
471 	ctd_t	ce_msec;		/* cpr time in 100*millisec */
472 	char 	ce_name[CPR_E_NAMELEN];
473 };
474 
475 struct cpr_stat {
476 	int	cs_ntests;		/* num of cpr's since loaded */
477 	int	cs_mclustsz;		/* average cluster size: all in bytes */
478 	int	cs_upage2statef;	/* actual # of upages gone to statef */
479 	int	cs_min_comprate;	/* minimum compression ratio * 100 */
480 	pgcnt_t	cs_nosw_pages;		/* # of pages of no backing store */
481 	size_t	cs_nocomp_statefsz;	/* statefile size without compression */
482 	size_t	cs_est_statefsz;	/* estimated statefile size */
483 	size_t	cs_real_statefsz;	/* real statefile size */
484 	size_t	cs_dumped_statefsz;	/* how much has been dumped out */
485 	struct cpr_event *cs_event_head; /* The 1st one in stat event list */
486 	struct cpr_event *cs_event_tail; /* The last one in stat event list */
487 };
488 
489 /*
490  * macros for CPR statistics evaluation
491  */
492 #define	CPR_STAT_EVENT_START(s)		cpr_stat_event_start(s, 0)
493 #define	CPR_STAT_EVENT_END(s)		cpr_stat_event_end(s, 0)
494 /*
495  * use the following is other time zone is required
496  */
497 #define	CPR_STAT_EVENT_START_TMZ(s, t)	cpr_stat_event_start(s, t)
498 #define	CPR_STAT_EVENT_END_TMZ(s, t)	cpr_stat_event_end(s, t)
499 
500 #define	CPR_STAT_EVENT_PRINT		cpr_stat_event_print
501 
502 
503 /*
504  * State Structure for CPR
505  */
506 typedef struct cpr {
507 	uint_t		c_cprboot_magic;
508 	uint_t		c_flags;
509 	int		c_substate;	/* tracking suspend progress */
510 	int		c_fcn;		/* uadmin subcommand */
511 	vnode_t		*c_vp;		/* vnode for statefile */
512 	cbd_t  		*c_bmda;	/* bitmap descriptor array */
513 	caddr_t		c_mapping_area;	/* reserve for dumping kas phys pages */
514 	struct cpr_stat	c_stat;
515 	char		c_alloc_cnt;	/* # of statefile alloc retries */
516 } cpr_t;
517 
518 /*
519  * c_flags definitions
520  */
521 #define	C_SUSPENDING		0x01
522 #define	C_RESUMING		0x02
523 #define	C_COMPRESSING		0x04
524 #define	C_REUSABLE		0x08
525 #define	C_ERROR			0x10
526 
527 extern cpr_t cpr_state;
528 #define	CPR	(&cpr_state)
529 #define	STAT	(&cpr_state.c_stat)
530 
531 /*
532  * definitions for c_substate. It works together w/ c_flags to determine which
533  * stages the CPR is at.
534  */
535 #define	C_ST_SUSPEND_BEGIN		0
536 #define	C_ST_MP_OFFLINE			1
537 #define	C_ST_STOP_USER_THREADS		2
538 #define	C_ST_PM_REATTACH_NOINVOL	3
539 #define	C_ST_DISABLE_UFS_LOGGING	4
540 #define	C_ST_STATEF_ALLOC		5
541 #define	C_ST_SUSPEND_DEVICES		6
542 #define	C_ST_STOP_KERNEL_THREADS	7
543 #define	C_ST_SETPROPS_1			8
544 #define	C_ST_DUMP			9
545 #define	C_ST_SETPROPS_0			10
546 #define	C_ST_DUMP_NOSPC			11
547 #define	C_ST_REUSABLE			12
548 #define	C_ST_NODUMP			13
549 #define	C_ST_MP_PAUSED			14
550 
551 #define	cpr_set_substate(a)	(CPR->c_substate = (a))
552 
553 #define	C_VP		(CPR->c_vp)
554 
555 #define	C_MAX_ALLOC_RETRY	4
556 
557 #define	CPR_PROM_SAVE		0
558 #define	CPR_PROM_RESTORE	1
559 #define	CPR_PROM_FREE		2
560 
561 /*
562  * default/historic size for cpr write buffer
563  */
564 #define	CPRBUFSZ		0x20000
565 
566 /*
567  * cpr statefile I/O on a block device begins after the disk label
568  * and bootblock (primarily for disk slices that start at cyl 0);
569  * the offset should be at least (label size + bootblock size = 8k)
570  */
571 #define	CPR_SPEC_OFFSET		16384
572 
573 typedef int (*bitfunc_t)(pfn_t, int);
574 
575 /*
576  * arena scan info
577  */
578 struct cpr_walkinfo {
579 	int mapflag;
580 	bitfunc_t bitfunc;
581 	pgcnt_t pages;
582 	size_t size;
583 	int ranges;
584 };
585 
586 /*
587  * Value used by cpr, found in devi_cpr_flags
588  */
589 #define	DCF_CPR_SUSPENDED	0x1	/* device went through cpr_suspend */
590 
591 /*
592  * Values used to differentiate between suspend to disk and suspend to ram
593  * in cpr_suspend and cpr_resume
594  */
595 
596 #define	CPR_TORAM	3
597 #define	CPR_TODISK	4
598 
599 #ifndef _ASM
600 
601 extern char *cpr_build_statefile_path(void);
602 extern char *cpr_enumerate_promprops(char **, size_t *);
603 extern char *cpr_get_statefile_prom_path(void);
604 extern int cpr_contig_pages(vnode_t *, int);
605 extern int cpr_default_setup(int);
606 extern int cpr_dump(vnode_t *);
607 extern int cpr_get_reusable_mode(void);
608 extern int cpr_isset(pfn_t, int);
609 extern int cpr_main(int);
610 extern int cpr_mp_offline(void);
611 extern int cpr_mp_online(void);
612 extern int cpr_nobit(pfn_t, int);
613 extern int cpr_open_deffile(int, vnode_t **);
614 extern int cpr_read_cdump(int, cdd_t *, ushort_t);
615 extern int cpr_read_cprinfo(int, char *, char *);
616 extern int cpr_read_machdep(int, caddr_t, size_t);
617 extern int cpr_read_phys_page(int, uint_t, int *);
618 extern int cpr_read_terminator(int, ctrm_t *, caddr_t);
619 extern int cpr_resume_devices(dev_info_t *, int);
620 extern int cpr_set_properties(int);
621 extern int cpr_statefile_is_spec(void);
622 extern int cpr_statefile_offset(void);
623 extern int cpr_stop_kernel_threads(void);
624 extern int cpr_threads_are_stopped(void);
625 extern int cpr_stop_user_threads(void);
626 extern int cpr_suspend_devices(dev_info_t *);
627 extern int cpr_validate_definfo(int);
628 extern int cpr_write(vnode_t *, caddr_t, size_t);
629 extern int cpr_update_nvram(cprop_t *);
630 extern int cpr_write_deffile(cdef_t *);
631 extern int i_cpr_alloc_bitmaps(void);
632 extern int i_cpr_dump_sensitive_kpages(vnode_t *);
633 extern int i_cpr_save_sensitive_kpages(void);
634 extern pgcnt_t cpr_count_kpages(int, bitfunc_t);
635 extern pgcnt_t cpr_count_pages(caddr_t, size_t, int, bitfunc_t, int);
636 extern pgcnt_t cpr_count_volatile_pages(int, bitfunc_t);
637 extern pgcnt_t i_cpr_count_sensitive_kpages(int, bitfunc_t);
638 extern pgcnt_t i_cpr_count_special_kpages(int, bitfunc_t);
639 extern pgcnt_t i_cpr_count_storage_pages(int, bitfunc_t);
640 extern ssize_t cpr_get_machdep_len(int);
641 extern void cpr_clear_definfo(void);
642 extern void cpr_restore_time(void);
643 extern void cpr_save_time(void);
644 extern void cpr_show_range(char *, size_t, int, bitfunc_t, pgcnt_t);
645 extern void cpr_signal_user(int sig);
646 extern void cpr_spinning_bar(void);
647 extern void cpr_start_user_threads(void);
648 extern void cpr_stat_cleanup(void);
649 extern void cpr_stat_event_end(char *, cpr_time_t *);
650 extern void cpr_stat_event_print(void);
651 extern void cpr_stat_event_start(char *, cpr_time_t *);
652 extern void cpr_stat_record_events(void);
653 extern void cpr_tod_get(cpr_time_t *ctp);
654 extern void cpr_tod_fault_reset(void);
655 extern void i_cpr_bitmap_cleanup(void);
656 extern void i_cpr_stop_other_cpus(void);
657 extern void i_cpr_alloc_cpus(void);
658 extern void i_cpr_free_cpus(void);
659 
660 /*PRINTFLIKE2*/
661 extern void cpr_err(int, const char *, ...) __KPRINTFLIKE(2);
662 
663 extern cpr_time_t wholecycle_tv;
664 extern int cpr_reusable_mode;
665 
666 #endif	/* _ASM */
667 #endif	/* _KERNEL */
668 
669 
670 #ifdef	__cplusplus
671 }
672 #endif
673 
674 #endif	/* _SYS_CPR_H */
675