/*static char *SCCSID = "@(#)types.h	6.1 90/11/18";*/
/*static char *SCCSID = "@(#)types.h    13.4 90/02/15";*/
/***	TYPES.H - definitions of data types
 *
 *	HPFS UTILITIES
 *	Peter A. Williams
 *	Copyright 1988 Microsoft Corporation
 *
 *	This header file defines data types used by Pinball file system
 *	utilities.  Data types that are utility-specific (such as the
 *	structure of a boot record for FORMAT) should be placed in a
 *	local file, LTYPES.H.  Each utility's LTYPES.H should include
 *	this file.
 *
 *	This file includes definitions of file system structures from
 *	the file system's header files.
 *
 *	Note that this file uses several definitions from DEFS.H, so that
 *	file should be included before this one.
 *
 *	Modification history:
 *	P.A. Williams	07/14/89     Added PBLK and BLK.
 *	G.A. Jones	08/08/89     Moved typedefs out of FS headers.
 *	G.A. Jones	08/09/89     Moved boot_sector out of pformat/ltypes.h.
 *
 */


#include <u_misc.h>		/* include the file system headers */
#include <chain.h>
#include <storage.h>
#include <fnode.h>
#include <superb.h>
#include <boot.h>

/* pChkdsk uses a private local copy of buf.h because its buf.h has 
   differences between it and HDRS\buf.h, as a result Pchkdsk will
   do its own include of its buf.h.
*/
#ifndef PCHKDSK
#include <buf.h>
#endif

#include <dir.h>
#include <cdib.h>
#include <codepage.h>

/*
 * device_param - the parameter packet used by the get BPB IOCTL.
 */

struct device_param {
  EXTENDED_BPB    dev_bpb;
  UCHAR  reserved [6];
  USHORT num_cylinders;
  UCHAR  device_type;		/* hi floppy, lo floppy, fixed etc */
  USHORT device_attr;		/* removable flag, detect change flag */
};

/*
 * Structures which define what the master boot record looks like.
 * They are used to find the Pinball partition on disk.  They remain
 * here for compatibility with the 1.1 version of Pinball.
 */

struct part {
  UCHAR bootind;			/* == 0x80 means partition is bootable */
  UCHAR starthead;			/* head number of partition start */
  UCHAR startsect;			/* sector number */
  UCHAR startcyl;			/* cylinder number */
  UCHAR systind;			/* partition ID;  'P' means Pinball */
  UCHAR endhead;			/* head number of partition end */
  UCHAR endsect;			/* sector number */
  UCHAR endcyl; 			/* cylinder number */
  ULONG lsn;				/* number of sectors before partition */
  ULONG nsects; 			/* number of sectors in partition */
};

struct mbr {
  UCHAR code [0x1be];			/* boot record code and data */
  struct part ptbl [4]; 		/* the partition table */
  USHORT sig;				/* special signature */
};

/*
 * Structure used for disk I/O, using disk IOCTLs.
 */

struct diskpkt {
  UCHAR cmdinfo;
  USHORT head;
  USHORT cyl;
  USHORT sect;
  USHORT nsect;
  struct {
    USHORT sectno;
    USHORT sectsize;
  } map [MAX_SECTORS_PER_TRACK];
};

/*
 * Structure used to determine physical disk dimensions.  It is defined
 * for compatibility with the 1.1 Version of Pinball.  The 1.2 Versions
 * of the utilities should all use a device_param structure.
 */

struct diskprm {
  USHORT reserved1;
  USHORT ncyl;
  USHORT nh;
  USHORT spt;
  USHORT reserved2 [4];
};

/*
 * A generic structure to read a block into.  It contains a DIRBLK, an
 * FNODE, and an ALSEC in one package.	It is used to avoid verbose type-
 * casts and multiple pointers to access file system objects.
 */

union blk {
  struct DIRBLK d;
  struct FNODE f;
  struct ALSEC a;
};

typedef union blk BLK;
typedef union blk *PBLK;

/*
 * A structure used for walking directories.  It contains a pointer to a
 * directory entry for member access, and a byte pointer for arithmetic.
 */

union dp {
  struct DIRENT *d;
  UCHAR *p;
};

/*
 * boot_sector - the boot sector structure as found on the first sector
 *               of the disk, plus a pad for the rest of the boot code
 *               (SEC_SUPERB-1 sectors).
 */

typedef struct boot_sector { /* BOOT_SECTOR */
  EXTENDED_BOOT Extended_Boot;                  /* Structures for boot sector */
  UCHAR pad [SECSIZE - sizeof (EXTENDED_BOOT) - sizeof(USHORT)];
                                                /* the boot code itself */
  USHORT signature;                             /* magic signature value */
  UCHAR pad2 [(SEC_SUPERB-1) * SECSIZE];	/* the rest of the boot code */
} BOOT_SECTOR;

typedef BOOT_SECTOR far * PBOOT_SECTOR;
