xref: /onnv-gate/usr/src/uts/common/avs/ns/sdbc/sd_pcu.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef _SD_PCU_H
27*7836SJohn.Forte@Sun.COM #define	_SD_PCU_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM /*
30*7836SJohn.Forte@Sun.COM  * All structures here are on-disk, unless specified otherwise.
31*7836SJohn.Forte@Sun.COM  * In-core stuff is hidden inside implementation modules.
32*7836SJohn.Forte@Sun.COM  */
33*7836SJohn.Forte@Sun.COM 
34*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
35*7836SJohn.Forte@Sun.COM extern "C" {
36*7836SJohn.Forte@Sun.COM #endif
37*7836SJohn.Forte@Sun.COM 
38*7836SJohn.Forte@Sun.COM /*
39*7836SJohn.Forte@Sun.COM  * Header.
40*7836SJohn.Forte@Sun.COM  */
41*7836SJohn.Forte@Sun.COM #define	SDBC_PWF_MAGIC	0xbcbcbc01
42*7836SJohn.Forte@Sun.COM 
43*7836SJohn.Forte@Sun.COM typedef struct sdbc_pwf_hdr_s {
44*7836SJohn.Forte@Sun.COM 	int32_t magic;		/* magic number to distinguish file revs */
45*7836SJohn.Forte@Sun.COM 	int32_t alignment;	/* all sections are multiples of this */
46*7836SJohn.Forte@Sun.COM 				/* a cache block is this identical size */
47*7836SJohn.Forte@Sun.COM 	int32_t bmap_size;	/* number of entries in each bitmap entry */
48*7836SJohn.Forte@Sun.COM 	int32_t cd_count;	/* number of devices we have data for */
49*7836SJohn.Forte@Sun.COM 	nsc_off_t string_pool;	/* offset in file to pool of filenames */
50*7836SJohn.Forte@Sun.COM 	nsc_off_t descriptor_pool; /* offset in file to dbc_pwf_desc_t vector */
51*7836SJohn.Forte@Sun.COM 	int64_t dump_time;	/* Timestamp == longest time_t */
52*7836SJohn.Forte@Sun.COM } sdbc_pwf_hdr_t;
53*7836SJohn.Forte@Sun.COM 
54*7836SJohn.Forte@Sun.COM /*
55*7836SJohn.Forte@Sun.COM  * File description
56*7836SJohn.Forte@Sun.COM  */
57*7836SJohn.Forte@Sun.COM typedef struct sdbc_pwf_desc_s {
58*7836SJohn.Forte@Sun.COM 	int32_t pad0;
59*7836SJohn.Forte@Sun.COM 	uint32_t name;		/* name + stringpool == offset of filename */
60*7836SJohn.Forte@Sun.COM 				/* the name given to nsc_open */
61*7836SJohn.Forte@Sun.COM 	nsc_off_t blocks;	/* offset into swap for this device's data */
62*7836SJohn.Forte@Sun.COM 	nsc_off_t bitmaps;	/* offset into swap for data bitmaps */
63*7836SJohn.Forte@Sun.COM 				/* (i.e. nothing to do with rdc bitmaps */
64*7836SJohn.Forte@Sun.COM 	uint64_t nblocks;	/* number of data blocks == bitmap dimension */
65*7836SJohn.Forte@Sun.COM 	/* long	rdc_data; */	/* offset to rdc data (NYI) */
66*7836SJohn.Forte@Sun.COM } sdbc_pwf_desc_t;
67*7836SJohn.Forte@Sun.COM 
68*7836SJohn.Forte@Sun.COM /*
69*7836SJohn.Forte@Sun.COM  * record status section - describes the state of each cache block in the file
70*7836SJohn.Forte@Sun.COM  *
71*7836SJohn.Forte@Sun.COM  * zaitcev - XXX errs is per block, not per fba?
72*7836SJohn.Forte@Sun.COM  */
73*7836SJohn.Forte@Sun.COM typedef struct sdbc_pwf_rec_s {
74*7836SJohn.Forte@Sun.COM 	uint32_t dirty;		/* Bitmap of dirty fba'a (_sd_bitmap_t) */
75*7836SJohn.Forte@Sun.COM 	int32_t errs;	/* error status per fba, needed to recover */
76*7836SJohn.Forte@Sun.COM 			/* from errors to a raidset where we must recover */
77*7836SJohn.Forte@Sun.COM 			/* from a stripe write error */
78*7836SJohn.Forte@Sun.COM 			/* (i.e. parity is bad or suspect ) */
79*7836SJohn.Forte@Sun.COM 	nsc_off_t fba_num;	/* the block on the disk */
80*7836SJohn.Forte@Sun.COM } sdbc_pwf_rec_t;
81*7836SJohn.Forte@Sun.COM 
82*7836SJohn.Forte@Sun.COM typedef struct sdbc_pwf_bitmap_s {
83*7836SJohn.Forte@Sun.COM 	sdbc_pwf_rec_t bitmaps[1]; /* dynamic array based on cache block size */
84*7836SJohn.Forte@Sun.COM } sdbc_pwf_bitmap_t;
85*7836SJohn.Forte@Sun.COM 
86*7836SJohn.Forte@Sun.COM /*
87*7836SJohn.Forte@Sun.COM  * Prototypes
88*7836SJohn.Forte@Sun.COM  */
89*7836SJohn.Forte@Sun.COM #ifdef _KERNEL	/* XXX Split into sd_pcu_ondisk.h, sd_pcu_iface.h */
90*7836SJohn.Forte@Sun.COM extern char _sdbc_shutdown_in_progress;
91*7836SJohn.Forte@Sun.COM 
92*7836SJohn.Forte@Sun.COM extern int _sdbc_pcu_config(int c, char **v);
93*7836SJohn.Forte@Sun.COM extern void _sdbc_pcu_unload(void);
94*7836SJohn.Forte@Sun.COM extern void _sdbc_power_lost(int rideout);
95*7836SJohn.Forte@Sun.COM extern void _sdbc_power_ok(void);
96*7836SJohn.Forte@Sun.COM extern void _sdbc_power_down(void);
97*7836SJohn.Forte@Sun.COM #endif
98*7836SJohn.Forte@Sun.COM 
99*7836SJohn.Forte@Sun.COM #ifdef __cplusplus
100*7836SJohn.Forte@Sun.COM }
101*7836SJohn.Forte@Sun.COM #endif
102*7836SJohn.Forte@Sun.COM 
103*7836SJohn.Forte@Sun.COM #endif	/* _SD_PCU_H */
104