/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file contains routines that manipulate the defect list.
*/
#include "global.h"
#if defined(sparc)
#endif /* defined(sparc) */
#include <string.h>
#include <unistd.h>
#include <memory.h>
#if defined(sparc)
#endif /* defined(sparc) */
#include "misc.h"
#include "param.h"
#if defined(sparc)
/*
* This structure is the bad block table for the current disk if
* the disk uses bad-144 defect mapping.
*/
#endif /* defined(sparc) */
/*
* This routine reads the defect list off the disk. It also reads in the
* bad block table if the disk is a BAD144 type. The defect list is
* located on the first 2 tracks of the 2nd alternate cylinder of all
* disks. The bad block map is located on the first 5 even sectors of
* the last track of the last cylinder.
*/
void
{
#if defined(sparc)
#endif /* defined(sparc) */
/*
* This flags has been introduced only for Sparc ATA IDE.
* This indicates that no list manipulation is done in this controller
* and hence return without any other checking.
*/
return;
}
/*
* Panther's working list is maintained by the controller
*/
fmt_print("Defect list BAD\n");
} else {
fmt_print("Controller working list found\n");
}
return;
}
fmt_print("Defect list BAD\n");
} else {
fmt_print("MANUFACTURER's list found\n");
}
return;
}
fmt_print("No defect list found\n");
return;
}
/*
* Loop for each copy of the defect list until we get a good one.
*/
/*
* Try to read the list header.
*/
continue;
/*
* If the magic number is wrong, this copy is corrupt.
*/
continue;
/*
* Allocate space for the rest of the list.
*/
/*
* Try to read in the rest of the list. If there is an
* error, or the checksum is wrong, this copy is corrupt.
*/
/*
* Destroy the list and go on.
*/
continue;
}
/*
* Got a good copy, stop searching.
*/
break;
}
#if defined(sparc)
return;
/*
* The disk uses BAD144, read in the bad-block table.
*/
if (status)
continue;
/*
* Do a sanity check on the list read in. If it passes,
* stop searching.
*/
continue;
break;
continue;
status = -1;
break;
}
}
if (status)
continue;
return;
}
/*
* If we couldn't find the bad block table, initialize it to
* zero entries.
*/
#endif /* defined(sparc) */
}
/*
* This routine either checks or calculates the checksum for a defect
* list, depending on the mode parameter. In check mode, it returns
* whether or not the checksum is correct.
*/
int
{
/*
* Perform the rolling xor to get what the checksum should be.
*/
sizeof (struct defect_entry) / sizeof (int)); i++)
/*
* If in check mode, return whether header checksum was correct.
*/
if (mode == CK_CHECKSUM)
/*
* If in create mode, set the header checksum.
*/
else {
return (0);
}
}
/*
* This routine prints a single defect to stdout in a readable format.
*/
void
{
/*
* Make defect numbering look 1 relative.
*/
++num;
/*
* Print out common values.
*/
/*
* The rest of the values may be unknown. If they are, just
* print blanks instead. Also, only print length only if bfi is
* known, and assume that a known bfi implies an unknown sect.
*/
} else {
fmt_print(" ");
}
fmt_print("\n");
}
/*
* This routine calculates where in a defect list a given defect should
* be sorted. It returns the index that the defect should become. The
* adds all logical sector defects to the end of the list. This is
* necessary because the ordering of logical sector defects is significant
* when sector slipping is employed.
*/
int
{
/*
* If it's a logical sector defect, return the entry at the end
* of the list.
*/
/*
* It's a bfi defect. Loop through the defect list.
*/
/*
* If we get to a logical sector defect, put this defect
* right before it.
*/
goto found;
/*
* If we get to a defect that is past this one in
*/
goto found;
continue;
goto found;
continue;
goto found;
}
/*
* Return the index to put the defect at.
*/
}
/*
* This routine writes the defect list on the back on the disk. It also
* writes the bad block table to disk if bad-144 mapping applies to the
* current disk.
*/
void
{
#if defined(sparc)
int sec;
#endif /* defined(sparc) */
/*
* Sparc ATA IDE.
* This indicates that no list manipulation is done in this controller
* and hence return without any other checking.
*/
return;
}
/*
* Panther's working list is maintained by the controller
*/
return;
}
/*
* If the list is null, there is nothing to write.
*/
/*
* calculate how many sectors the defect list will occupy.
*/
/*
* Loop for each copy of the list to be written. Write
* out the header of the list followed by the data.
*/
if (status) {
"Warning: error saving defect list.\n");
continue;
}
if (status)
"Warning: error saving defect list.\n");
}
}
return;
#if defined(sparc)
/*
* Current disk uses bad-144 mapping. Loop for each copy of the
* bad block table to be written and write it out.
*/
if (status) {
"Warning: error saving bad block map table.\n");
continue;
}
}
/*
* Execute an ioctl to tell unix about the new bad block table.
*/
"Warning: error telling SunOS bad block map table.\n");
#endif /* defined(sparc) */
}
/*
* This routine adds a logical sector to the given defect list.
*/
void
{
int index;
/*
* Calculate the fields for the defect struct.
*/
/*
* Initialize the unknown fields.
*/
/*
* Calculate the index into the list that the defect belongs at.
*/
/*
* Add the defect to the list.
*/
}
/*
* This routine adds the given defect struct to the defect list at
* a precalculated index.
*/
void
{
int count, i;
/*
* If adding this defect makes the list overflow into another
* sector, allocate the necessary space.
*/
/*
* Slip all the defects after this one down one slot in the list.
*/
/*
* Fill in the created hole with this defect.
*/
/*
* Increment the count and calculate a new checksum.
*/
}
/*
* This routine sets the given defect list back to null.
*/
void
{
/*
* If it's already null, we're done.
*/
return;
/*
* Free the malloc'd space it's using.
*/
/*
* Mark it as null, and clear any flags.
*/
}
/*
* This routine returns the defect list size
* according to the sector size.
*/
int
{
int rval;
if (secsz == 0) {
}
return (rval);
}