/******************************************************************************/
/*                                                                            */
/*  Copyright (C), 1995-2007, SanDisk IL Ltd. All rights reserved.            */
/*                                                                            */
/*  Redistribution and use in source and binary forms, with or without        */
/*  modification, are permitted provided that the following conditions are    */
/*  met:                                                                      */
/*  1. Redistributions of source code must retain the above copyright notice, */
/*     this list of conditions and the following disclaimer.                  */
/*  2. Redistributions in binary form must reproduce the above copyright      */
/*     notice, this list of conditions and the following disclaimer in the    */
/*     documentation and/or other materials provided with the distribution.   */
/*  3. Neither the name of SanDisk IL nor the names of its contributors may be*/
/*     used to endorse or promote products derived from this software without */
/*     specific prior written permission.                                     */
/*                                                                            */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       */
/*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR             */
/*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      */
/*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     */
/*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  */
/*  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    */
/*  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
/*  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      */
/*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
/*                                                                            */
/*  NOTWITHSTANDING ANYTHING STATED TO THE CONTRARY, SANDISK'S TOTAL LIABILITY*/
/*  ARISING OUT OF OR RELATED TO THE SOFTWARE OR ANY SUPPORT SERVICES         */
/*  PROVIDED WITH RESPECT THERETO SHALL NOT EXCEED $100.                      */
/*                                                                            */
/*  The laws of the State of California, United States of America, exclusive  */
/*  of conflict-of-laws provisions, shall govern this license in all respects.*/
/*  The the federal or state courts of competent jurisdiction in the State    */ 
/*  of California shall have exclusive jurisdiction with respect to all       */
/*  actions commenced in relation to the software. Licensee agrees not        */ 
/*  to export or re-export, directly or indirectly any technical data         */ 
/*  acquired from SanDisk or any products utilizing such data in violation    */
/*  of applicable export laws and regulations.                                */
/*                                                                            */
/******************************************************************************/
/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/Test for 7.x/src/H3/bdkemul.h-arc  $
 * 
 *    Rev 1.15   Dec 11 2007 12:25:10   einat.avidan
 * Add format start and format complete signatures in disk user attributes
 * 
 *    Rev 1.14   Oct 22 2007 11:34:48   einat.avidan
 * update copyrights header
 * 
 *    Rev 1.13   Sep 11 2006 13:45:10   yaniv.iarovici
 * Legal header added
 * 
 *    Rev 1.12   Aug 09 2006 17:34:14   Polina.Marimont
 * initial for DOC Driver 1.0
 * 
 *    Rev 1.11   May 28 2006 12:48:42   polina.marimont
 * comments
 * 
 *    Rev 1.10   May 17 2006 12:51:04   polina.marimont
 * 1. DOCH_DiskUserAttrWithBinary - changed to support floors
 * 2. DOCH macros use instead of numerical constants
 * 
 *    Rev 1.9   Mar 22 2006 17:35:46   DoronC
 * Bug fix - add signature to disk attributes in order to use only 
 * format made by TrueFFS 7.1 and not by host SDK.
 * Other format will force reformating of the media.
 * 
 *    Rev 1.8   Feb 16 2006 11:32:36   DoronC
 * Store binary partition flags in the attributes and return then 
 * when requested by extendedInfo for compatability with legacy 
 * devices.
 * 
 *    Rev 1.7   Feb 14 2006 10:50:04   DoronC
 * Remove large variables from stack. use one global buffer for 
 * all large buffers needs.
 */
#ifndef BDKEMUL_H
#define BDKEMUL_H

#include "part_inf.h"

/*Unit size*/
#define BDK_SECTORS_IN_UNIT 0x200
#define BDK_UNIT_SIZE (BDK_SECTORS_IN_UNIT<<DOCH_SECTOR_SIZE_BITS)

/*Partition User Attributes*/
#define SUB_PARTITIONS_PER_BINARY	10

/*16Byte overall*/
typedef struct {
	FLByte	bSignature[4];			/*Partition signature*/
	FLDword dwOffset;				/*From start of binary partition in sectors */
	FLDword dwSize;					/*Total sub-partition size in sectors */
	FLDword dwUsedSize;				/*Used size in sectors */
} DOCH_BinarySubPartitionEmulation;

/*164Byte overall*/
typedef struct {
	FLByte	bNumOfSubPartitions;		/*Number of created sub-partitions*/
	FLByte  bReserved[3];
    FLDword dwPartitionFlags;
	DOCH_BinarySubPartitionEmulation subPartitions[SUB_PARTITIONS_PER_BINARY];
} DOCH_BinaryPartitionEmulation;

/*512Byte overall (1 sector)*/
typedef struct { 
	FLByte	bReservedSDK[DOCH_PART_INFO_SDK_RESERVED_BYTES];		/*Reserved for SDK use*/
	FLByte	bType;					/*DOCH_PartitionType*/
	FLByte	breserved1[3];
	DOCH_BinaryPartitionEmulation	binPartHeader;	/*Valid only if type = PARTITION_TYPE_BINARY*/
	FLByte  bDPSFwd;				/*Next partition has same passkey (!=0)*/
	FLByte  bDPSBwd;				/*Previous partition has same passkey (!=0)*/
	FLByte	bProtected;				/*Partition was defined with PROTECTABLE flag*/
	FLByte	bChangableProtection;	/*Partition was defined with CHANGEABLE_PROTECTION flag*/
	FLByte  bReserved2[0x110];
} DOCH_PartitionUserAttrWithBinary;

typedef struct {
	FLByte bReservedSDK[DOCH_DEVICE_INFO_SDK_RESERVED_BYTES];		/*Reserved for SDK use*/
	FLByte bIplPresent;				/*Exists in DOCH_DeviceAttributes as well !*/
	FLByte bOtpPresent;				/*OTP partition is present*/		
	FLByte bNumOfBinaryPartitions;	/*Number of emulated binary partitions*/
	FLByte bReserved1;
	FLByte bProgrammerName[4];
	FLByte bProgrammerVersion[4];
	FLByte bTFFSVersion[10];
    FLByte bMigrationSignature[10];
	FLByte bFormatStartSignature[16];    /*starting from DD 1.1 beta*/
	FLByte bFormatCompleteSignature[16]; /*starting from DD 1.1 beta*/
	FLByte bReserved[0x17A];
} DOCH_DiskUserAttrWithBinary;

#endif /*BDKEMUL_H*/
