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