/*
 * $Header: /smsa/bsd:include/dev/badblk.h:bsd  1.4  $
 * $Source: /smsa/bsd:include/dev/badblk.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 */
/*
 *	Format of the bad sector replacement track,
 *	and associated data structures.
 *
 *	John Collins, Xi Software Ltd, March 1988.
 *
 *
 *	Maximum number of bad blocks we can handle.
 *	This number must be such that the "badblk_hdr" fit onto 512 bytes.
 */

#ifndef __dev_badblk_h
#define __dev_badblk_h

#define	BB_MAX	84

typedef	unsigned  short	track_address;

typedef	struct	{
	unsigned  short	cylinder;
	track_address	block;
}  disc_address;

struct	badblk_hdr	{
	unsigned  	bb_magic;	/*  Magic number  */
	unsigned  	bb_number;	/*  No of bad blocks  */
	disc_address	bb_blocks[BB_MAX];
	track_address	bb_replacement[BB_MAX];
};


#define	BB_MAGIC	(('B'<<24)|('a'<<16)|('d'<<8)|('!'))
#define	BB_OFFSET	4

/*
 *	The following structure is used to chain together records of bad
 *	sectors in ascending order within the cylinder.
 */

struct	bb_addr	{
	struct	bb_addr	*next;
	track_address	address, replacement;
};

/*
 *	A vector of these structures is used to search and see whether the
 *	given cylinder has any bad sectors in it.
 */

struct	bb_cyl	{
	unsigned	cylinder;
	struct	bb_addr	*chain;
};

/* 
 * A map of the bad block information for an individual disc
 */

struct bbmap {
  int bb_cyl_count;
  struct bb_cyl *bb_cyltab;
};

extern	struct	bb_addr	*bad_cyl();
extern	unsigned	find_repl();
extern	void	initbblist();

#endif/*__dev_badblk_h*/

/* EOF badblk.h */
