4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
34 * This file contains definitions related to the defect list.
37 extern struct defect_list work_list
;
38 extern struct dkbad badmap
;
41 * This is the structure of the header of a defect list. It is always
42 * the first sector on a track containing a defect list.
52 * This is the structure of a defect. Defects are stored on the disk
53 * as an array of these structures following the defect header.
64 * This is the internal representation of a defect list. We store
65 * the header statically, but dynamically allocate space for the
66 * actual defects, since their number may vary. The flags field is
67 * used to keep track of whether the list has been modified.
70 struct defectHeader header
;
71 struct defect_entry
*list
;
76 * This defines the number of copies of the defect list kept on the disk.
77 * They are stored 1/track, starting at track 0 of the second alternate cyl.
82 * These defines are the flags for the defect list.
84 #define LIST_DIRTY 0x01 /* List needs to be synced */
85 #define LIST_RELOAD 0x02 /* Reload list after formatting (SCSI) */
86 #define LIST_PGLIST 0x04 /* embedded SCSI - both manufacturer's (P) */
87 /* and grown (G) list */
90 * Miscellaneous defines.
92 #define DEFECT_MAGIC 0x89898989 /* magic no for defect lists */
93 #define NO_CHECKSUM 0x1 /* magic no for no checksum in */
95 #define UNKNOWN (-1) /* value used in defect fields */
96 #define DEF_PRINTHEADER " num cyl hd bfi len sec blk\n"
99 * This defines the number of copies of the bad block table kept on the
100 * disk. They are stored in the first 5 even sectors on the last track
101 * of the disk. Note: this also defines the number of backup labels,
102 * which are kept in the first 5 odd sectors of the appropriate
105 #define BAD_LISTCNT 5
109 * Prototypes for ANSI C compilers
111 void read_list(struct defect_list
*list
);
112 int makebfi(struct defect_list
*list
, struct defect_entry
*def
);
113 void calc_bfi(struct defect_list
*list
, struct defect_entry
*def
,
114 struct defect_entry
*end
, int skew
);
115 int makelsect(struct defect_list
*list
);
116 int checkdefsum(struct defect_list
*list
, int mode
);
117 void pr_defect(struct defect_entry
*def
, int num
);
118 int sort_defect(struct defect_entry
*def
, struct defect_list
*list
);
119 void write_deflist(struct defect_list
*list
);
120 void add_ldef(diskaddr_t blkno
, struct defect_list
*list
);
121 void add_def(struct defect_entry
*def
, struct defect_list
*list
,
123 void kill_deflist(struct defect_list
*list
);
126 * This defines the size (in sectors) of the defect array given the number
127 * of defects in the array. It must be rounded to a sector boundary since
128 * that is the atomic disk size. We make a zero length list use up a
129 * sector because it is convenient to have malloc'd space in every
132 int deflist_size(int secsz
, int sz
);
138 #endif /* _DEFECT_H */