/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CPR_H
#define _SYS_CPR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/compress.h>
#include <sys/archsystm.h>
/*
* definitions for kernel, cprboot, pmconfig
*/
/*
* magic numbers for cpr files
*/
/*
* max(strlen("true"), strlen("false")) + 1
*/
/*
* max property name length used
* max property count
*/
/*
*/
struct cpr_prop_info {
char mod;
};
struct cpr_default_mini {
};
struct cpr_default_info {
};
/*
* Configuration info provided by user via pmconfig.
*
* The first part (cf_type, cf_path, cf_fs, cf_devfs, cf_dev_prom)
* is used by both the cpr kernel module and cpr booter program
* to locate the statefile.
*
* cf_type CFT_UFS
* cf_path (path within file system) ".CPR"
* cf_dev_prom (prom device path of the above disk partition)
*
* the fields would have the typical values shown below:
*
* cf_type CFT_SPEC
* cf_path ignored
* cf_fs ignored
* cf_dev_prom (prom device path of the above special file)
*
* If the statefile is on a zvol, the fields would have these values:
*
* cf_type CFT_ZVOL
* cf_path ignored
* cf_dev_prom (prom device path of the above special file)
*
* The rest of the fields are autoshutdown and autopm configuration related.
* They are updated by pmconfig and consumed by both powerd and dtpower.
*/
struct cprconfig {
/* booter to verify */
/* for the state file */
/* holding state file */
/* for above mount pt. */
/* above filesystem */
/*
* autoshutdown configuration fields
*/
/* "shutdown", "autowakeup" */
/* or "noshutdown" */
/*
* autopm behavior field
*/
/* "default" */
};
/*
* values for cf_type
*/
/*
* definitions for kernel, cprboot
*/
#ifdef _KERNEL
#include <sys/sysmacros.h>
#include <sys/cpr_impl.h>
extern int cpr_debug;
#define DPRINT
/*
* CPR_DEBUG1 displays the main flow of CPR. Use it to identify which
* sub-module of CPR causes problems.
* CPR_DEBUG2 displays minor stuff that normally won't matter.
* CPR_DEBUG3 displays some big loops (cpr_dump); requires much longer runtime.
* CPR_DEBUG4 displays lots of cprboot output, cpr_read and page handling.
* CPR_DEBUG5 various, mostly unique stuff
* CPR_DEBUG9 displays statistical data for CPR on console (by using printf),
* such as num page invalidated, etc.
*/
#define DBG_DONTSHOWRANGE 0
/*
* CPR FILE FORMAT:
*
* Dump Header: general dump data:
* cpr_dump_desc
*
* Machdep descriptor: cpr_machdep_desc
* cpr_sun4m_machdep
* cpr_sun4u_machdep, var length prom words
*
* Page Map: bitmap record consisting of a descriptor and data:
* cpr_bitmap_desc
* (char) bitmap[cpr_bitmap_desc.cbd_size]
*
* Page data: Contains one or more physical page records,
* each record consists of a descriptor and data:
* cpr_page_desc
* (char) page_data[cpr_page_desc.cpd_offset]
*
* Terminator: end marker
* cpr_terminator
*
* NOTE: cprboot now supports both ILP32 and LP64 kernels;
* the size of these structures written to a cpr statefile
* must be the same for ILP32 and LP64. For details, see
*/
/*
* header at the begining of the dump data section
*/
struct cpr_dump_desc {
};
/*
* physical memory bitmap descriptor, preceeds the actual bitmap.
*/
struct cpr_bitmap_desc {
};
/*
* Maximum supported bitmap descriptors; 1-2 + null-terminator is common
*/
/*
* Describes the contiguous pages saved in the storage area.
* To save space data will be compressed before saved.
* However some data end up bigger after compression.
* In that case, we save the raw data and make a note
* of it in the csd_clean_compress field.
*/
struct cpr_storage_desc {
int csd_clean_compressed;
#ifdef DEBUG
#endif
};
/*
* Describes saved pages, preceeds page data;
* cpd_lenth len is important when pages are compressed.
*/
struct cpr_page_desc {
};
/*
* cpd_flag values
*/
/*
* machdep header stores the length of the platform specific information
* that are used by resume.
*
* Note: the md_size field is the total length of the machine dependent
* information. This always includes a fixed length section and may
* include a variable length section following it on some platforms.
*/
struct cpr_machdep_desc {
};
struct cpr_terminator {
};
#define VOLATILE_BITMAP 0
/*
* reference the right bitmap based on the arg descriptor and flag
*/
/*
* checks if a phys page is within the range covered by a bitmap
*/
#define WRITE_TO_STATEFILE 0
/*
* prom_read() max is 32k
* for sun4m, page size is 4k, CPR_MAXCONTIG is 8
* for sun4u, page size is 8k, CPR_MAXCONTIG is 4
*/
/*
* converts byte size to bitmap size; 1 bit represents one phys page
*/
/*
* redefinitions of uadmin subcommands for A_FREEZE
*/
/*
* Suspend to RAM test points.
* Probably belong above, but are placed here for now.
*/
/* S3 leave hardware on and return success */
/* S3 leave hardware on and return failure */
/* S3 ignored devices that fail to suspend */
/* S3 on a specified device */
/*
* Temporary definition of the Suspend to RAM development subcommands
* so that non-ON apps will work after initial integration.
*/
/*
* cprboot related information and definitions.
* The statefile names are hardcoded for now.
*/
/*
* definitions for CPR statistics
*/
struct cpr_tdata {
};
struct cpr_event {
};
struct cpr_stat {
};
/*
* macros for CPR statistics evaluation
*/
/*
* use the following is other time zone is required
*/
/*
* State Structure for CPR
*/
typedef struct cpr {
} cpr_t;
/*
* c_flags definitions
*/
/*
* definitions for c_substate. It works together w/ c_flags to determine which
* stages the CPR is at.
*/
#define C_ST_SUSPEND_BEGIN 0
#define CPR_PROM_SAVE 0
/*
*/
/*
* cpr statefile I/O on a block device begins after the disk label
* and bootblock (primarily for disk slices that start at cyl 0);
* the offset should be at least (label size + bootblock size = 8k)
*/
/*
* arena scan info
*/
struct cpr_walkinfo {
int mapflag;
int ranges;
};
/*
* Value used by cpr, found in devi_cpr_flags
*/
/*
* Values used to differentiate between suspend to disk and suspend to ram
* in cpr_suspend and cpr_resume
*/
#ifndef _ASM
extern char *cpr_build_statefile_path(void);
extern char *cpr_enumerate_promprops(char **, size_t *);
extern char *cpr_get_statefile_prom_path(void);
extern int cpr_contig_pages(vnode_t *, int);
extern int cpr_default_setup(int);
extern int cpr_get_reusable_mode(void);
extern int cpr_main(int);
extern int cpr_mp_offline(void);
extern int cpr_mp_online(void);
extern int cpr_open_deffile(int, vnode_t **);
extern int cpr_read_cprinfo(int, char *, char *);
extern int cpr_read_phys_page(int, uint_t, int *);
extern int cpr_resume_devices(dev_info_t *, int);
extern int cpr_set_properties(int);
extern int cpr_statefile_is_spec(void);
extern int cpr_statefile_offset(void);
extern int cpr_stop_kernel_threads(void);
extern int cpr_threads_are_stopped(void);
extern int cpr_stop_user_threads(void);
extern int cpr_suspend_devices(dev_info_t *);
extern int cpr_validate_definfo(int);
extern int cpr_update_nvram(cprop_t *);
extern int cpr_write_deffile(cdef_t *);
extern int i_cpr_alloc_bitmaps(void);
extern int i_cpr_dump_sensitive_kpages(vnode_t *);
extern int i_cpr_save_sensitive_kpages(void);
extern ssize_t cpr_get_machdep_len(int);
extern void cpr_clear_definfo(void);
extern void cpr_restore_time(void);
extern void cpr_save_time(void);
extern void cpr_signal_user(int sig);
extern void cpr_spinning_bar(void);
extern void cpr_start_user_threads(void);
extern void cpr_stat_cleanup(void);
extern void cpr_stat_event_end(char *, cpr_time_t *);
extern void cpr_stat_event_print(void);
extern void cpr_stat_event_start(char *, cpr_time_t *);
extern void cpr_stat_record_events(void);
extern void cpr_tod_status_set(int);
extern void i_cpr_bitmap_cleanup(void);
extern void i_cpr_stop_other_cpus(void);
extern void i_cpr_alloc_cpus(void);
extern void i_cpr_free_cpus(void);
/*PRINTFLIKE2*/
extern cpr_time_t wholecycle_tv;
extern int cpr_reusable_mode;
#endif /* _ASM */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_CPR_H */