fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _SD_PCU_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_PCU_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * All structures here are on-disk, unless specified otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In-core stuff is hidden inside implementation modules.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Header.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_PWF_MAGIC 0xbcbcbc01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sdbc_pwf_hdr_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t magic; /* magic number to distinguish file revs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t alignment; /* all sections are multiples of this */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* a cache block is this identical size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t bmap_size; /* number of entries in each bitmap entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t cd_count; /* number of devices we have data for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t string_pool; /* offset in file to pool of filenames */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t descriptor_pool; /* offset in file to dbc_pwf_desc_t vector */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int64_t dump_time; /* Timestamp == longest time_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sdbc_pwf_hdr_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * File description
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sdbc_pwf_desc_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t pad0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t name; /* name + stringpool == offset of filename */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the name given to nsc_open */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t blocks; /* offset into swap for this device's data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t bitmaps; /* offset into swap for data bitmaps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* (i.e. nothing to do with rdc bitmaps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t nblocks; /* number of data blocks == bitmap dimension */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* long rdc_data; */ /* offset to rdc data (NYI) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sdbc_pwf_desc_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * record status section - describes the state of each cache block in the file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * zaitcev - XXX errs is per block, not per fba?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sdbc_pwf_rec_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t dirty; /* Bitmap of dirty fba'a (_sd_bitmap_t) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t errs; /* error status per fba, needed to recover */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* from errors to a raidset where we must recover */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* from a stripe write error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* (i.e. parity is bad or suspect ) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_off_t fba_num; /* the block on the disk */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sdbc_pwf_rec_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sdbc_pwf_bitmap_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_pwf_rec_t bitmaps[1]; /* dynamic array based on cache block size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sdbc_pwf_bitmap_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Prototypes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _KERNEL /* XXX Split into sd_pcu_ondisk.h, sd_pcu_iface.h */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char _sdbc_shutdown_in_progress;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _sdbc_pcu_config(int c, char **v);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_pcu_unload(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_power_lost(int rideout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_power_ok(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void _sdbc_power_down(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SD_PCU_H */