/*
* 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 the routines for the IDE drive interface
*/
#include "global.h"
#include <memory.h>
#include <malloc.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/byteorder.h>
#include <errno.h>
#if defined(i386)
#endif
#include "startup.h"
#include "misc.h"
#include "ctlr_ata.h"
#include "analyze.h"
#include "param.h"
#include "io.h"
#include "badsec.h"
#include "menu_fdisk.h"
int wr_altsctr();
int read_altsctr();
int updatebadsec();
#ifdef __STDC__
static int ata_ck_format(void);
#ifdef i386
static int ata_ex_cur(struct defect_list *);
static int ata_wr_cur(struct defect_list *);
static int ata_repair(diskaddr_t, int);
#endif /* i386 */
#else /* __STDC__ */
static int ata_ck_format();
#ifdef i386
static int ata_ex_cur();
static int ata_wr_cur();
static int ata_repair();
#endif /* i386 */
#endif
#if defined(sparc)
0,
0,
0,
0,
0,
0,
#else
0,
0,
0,
#endif /* defined(sparc) */
};
0,
0,
0,
0,
0,
0,
};
#if defined(i386)
#endif /* defined(i386) */
extern struct badsec_lst *badsl_chain;
extern int badsl_chain_cnt;
extern struct badsec_lst *gbadsl_chain;
extern int gbadsl_chain_cnt;
extern struct alts_mempart *ap;
static char *dadkrawioerrs[] = {
"cmd was successful", /* DADKIO_STAT_NO_ERROR */
"device not ready", /* DADKIO_STAT_NOT_READY */
"error on medium blkno: %d", /* DADKIO_STAT_MEDIUM_ERROR */
"other hardware error", /* DADKIO_STAT_HARDWARE_ERROR */
"illegal request", /* DADKIO_STAT_ILLEGAL_REQUEST */
"illegal block address: %d", /* DADKIO_STAT_ILLEGAL_ADDRESS */
"device write-protected", /* DADKIO_STAT_WRITE_PROTECTED */
"no response from device", /* DADKIO_STAT_TIMED_OUT */
"parity error in data", /* DADKIO_STAT_PARITY */
"error on bus", /* DADKIO_STAT_BUS_ERROR */
"data recovered via ECC", /* DADKIO_STAT_SOFT_ERROR */
"no resources for cmd", /* DADKIO_STAT_NO_RESOURCES */
"device is not formatted", /* DADKIO_STAT_NOT_FORMATTED */
"device is reserved", /* DADKIO_STAT_RESERVED */
"feature not supported", /* DADKIO_STAT_NOT_SUPPORTED */
};
/*ARGSUSED6*/
#if defined(i386)
int
#else /* defined(i386) */
static int
#endif /* defined(i386) */
{
int tmpsec;
/* Doing raw read */
media_error = 0;
/*
* PCATA requires to use "p0" when calling
*/
(void) open_cur_file(FD_USE_P0_PATH);
}
return (1);
}
/* Restore cur_file with cur_disk->disk_path */
(void) open_cur_file(FD_USE_CUR_DISK_PATH);
}
case DADKIO_STAT_NOT_READY:
break;
case DADKIO_STAT_RESERVED:
break;
break;
case DADKIO_STAT_MEDIUM_ERROR:
media_error = 1;
break;
}
return (1);
}
return (0);
}
int
{
char *bufaddr;
int status;
return (!status);
}
#if defined(i386)
static int
{
int i;
return (-1);
}
alts_slice = i;
}
}
if (alts_slice == -1) {
return (-1);
}
if (!solaris_offset)
return (-1);
return (SUCCESS);
}
static int
{
int status;
status = wr_altsctr();
if (status) {
return (status);
}
sync();
return (-1);
}
sync();
return (0);
}
static int
{
int i;
switch (list_format) {
case BFI_FORMAT:
sizeof (struct defect_entry));
if (new_defect == NULL) {
"ata_convert_list: calloc failed\n");
fullabort();
}
i++, new_defect++) {
new_defect->cyl =
new_defect->head =
new_defect->sect =
}
} else {
sizeof (struct defect_entry));
if (new_defect == NULL) {
"ata_convert_list: calloc failed\n");
fullabort();
}
}
break;
default:
err_print("ata_convert_list: can't deal with it\n");
exit(0);
}
return (0);
}
/*
* NB - there used to be a ata_ex_man() which was identical to
* ata_ex_cur; since it's really not a "manufacturer's list",
* it's gone; if we ever want that exact functionality back,
* we can add ata_ex_cur() to the ctlr_ops above. Otherwise,
* if this is ever modified to support formatting of IDE drives,
* we should probably add something that issues the
* drive Read Defect list rather than getting the s9 info
* as ata_ex_cur() does.
*/
static int
{
int status;
status = get_alts_slice();
if (status)
return (status);
if (status) {
return (status);
}
return (status);
}
int
{
int status;
#ifdef lint
flag++;
#endif
(void) get_alts_slice();
if (!gbadsl_chain) {
if (!blc_p) {
"Unable to allocate memory for additional bad sectors\n");
return (-1);
}
}
"Unable to allocate memory for additional bad sectors\n");
return (-1);
}
}
(void) updatebadsec(dpart, 0);
status = put_alts_slice();
/* clear out the bad sector list chains that were generated */
if (badsl_chain) {
} else {
}
}
badsl_chain = NULL;
badsl_chain_cnt = 0;
}
if (gbadsl_chain) {
} else {
}
}
gbadsl_chain = NULL;
gbadsl_chain_cnt = 0;
}
return (status);
}
int
{
int status;
int sec_count;
int x;
return (-1);
(void) get_alts_slice();
for (x = 0; x < sec_count; x++) {
/* test for unsupported list format */
"BFI unsuported format for bad sectors\n");
return (-1);
}
if (!gbadsl_chain) {
if (!blc_p) {
"Unable to allocate memory for additional bad sectors\n");
return (-1);
}
}
"Unable to allocate memory for additional bad sectors\n");
return (-1);
}
}
dlist++;
}
(void) updatebadsec(dpart, 0);
status = put_alts_slice();
/* clear out the bad sector list chains that were generated */
if (badsl_chain) {
} else {
}
}
badsl_chain = NULL;
badsl_chain_cnt = 0;
}
if (gbadsl_chain) {
} else {
}
}
gbadsl_chain = NULL;
gbadsl_chain_cnt = 0;
}
return (status);
}
#endif /* defined(i386) */