pclabel.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/dditypes.h>
/* Future WORK */
/* Card Services header files should be removed. When pcata.h is split */
#include <sys/cis_handlers.h>
#include <sys/cs_types.h>
static int pcdsklbl_chk(struct dk_label *, unsigned short *);
/*
* accepts pointer to buffer containing the on-disk label data
* data could be VTOC8 or VTOC16
* data could be in a struct buf or in lbl
*
* verifies magic numbers in label and checksum
*
* if the parameter pointing to the checksum points to a location
* within the label, this routine will generate the checksum
*/
static int
{
short *sp;
short count;
unsigned short sum;
/*
* Check magic number of the label
*/
#ifdef ATA_DEBUG
if (pcata_debug & DLBL) {
"magic: 0x%x not MAGIC:0x%x\n",
}
#endif
return (DDI_FAILURE);
}
#ifdef ATA_DEBUG
if (pcata_debug & DLBL) {
"sanity: 0x%x not SANE:0x%x\n",
}
#endif
return (DDI_FAILURE);
}
#ifdef ATA_DEBUG
if (pcata_debug & DLBL) {
"version: 0x%x not 0x%x\n",
}
#endif
return (DDI_FAILURE);
}
/*
* Check the checksum of the label
*/
sum = 0;
while (count--) {
}
if (sum)
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
void
{
/*
* clear pmap (all 20 slices)
*/
/*
* calc total blocks on device
*/
/*
* The whole disk is represented here (this is the p0 partition.)
*/
}
/*
* read sector 0 of the disk and call fdisk parse
*/
int
{
int ret;
/*
* read fdisk sector (device block 0)
*/
(void) pcata_strategy(bp);
return (DDI_FAILURE);
return (ret);
}
/*
* We have this wonderful scenario
* where there exists two different kinds of labeling schemes,
*
* Procedurely we do the following
* clear pmap[s0-s15,p0-p5]
* set pmap[p0] to entire disk
* set uidx = p0
*
* read disk block 0 and check for fdisk record
* if (fdisk record exists) {
* set pmap[p1-p4]
* if (Solaris partiton exists) {
* set uidx to px
* }
* }
*
* if (fdisk record does not exist OR a Solaris partiton exists) {
* read disk block 1 of pmap[uidx] and check for VTOC
* if (VTOC exists) {
* set pmap[s0-s15] from vtoc
* }
* set pmap[s2] to entire Solaris partition
* }
*
* for s0 to s15
* add start address of pmap[uidx] to pmap [s0-s15]
* (do not change incore vtoc record)
*/
int
{
int i;
/* check to see if valid fdisk record exists */
#ifdef ATA_DEBUG
if (pcata_debug & DLBL)
"fdisk signature=%04x MBB_MAGIC=%04x\n",
#endif
/* fdisk record exists */
/* copy fdisk table so it is aligned on 4 byte boundry */
#ifdef ATA_DEBUG
if (pcata_debug & DLBL)
i,
#endif
/*
* make sure numbers are reasonable
*/
rel < 0 ||
num <= 0 ||
continue;
}
}
}
}
/*
* Partitions p0 - p4 are established correctly
* now check for Solaris vtoc
*/
/*
* if there is no MBR (fdisk label)
* or there is an FDISK label which defines a Solaris partition
* then call rdvtoc.
*
* note: if fdisk does exist, but does not define a Solaris partiton
* s0-s15 are set to zero length
*/
/* failures leave pmap in the correct state, so we don't care */
}
#ifdef ATA_DEBUG
if (pcata_debug & DLBL) {
for (i = 0; i <= NUM_PARTS; i++)
i,
}
#endif
return (DDI_SUCCESS);
}
static int
{
unsigned short sum;
int i;
/*
* read the label from the uidx partition (p0-p4)
*/
(void) pcata_strategy(bp);
return (DDI_FAILURE);
}
if (!lbp) {
return (DDI_FAILURE);
}
/*
* check label
*/
/*
* record label information
* copy the data from the buf_t memory to the lblp memory
*/
} else {
#ifdef ATA_DEBUG
if (pcata_debug & DLBL)
#endif
/*
* Since there is no valid vtoc and there should be
* create one based on the solaris partition (possibly p0)
*/
}
/*
* adjust the lbp to point to data in the lbl structures
* rather than the data in the buf_t structure
* this is where the data was left by either the bcopy or preplb
*/
#if defined(_SUNOS_VTOC_16)
#elif defined(_SUNOS_VTOC_8)
for (i = 0; i < NDKMAP; i++) {
/*
* convert SUNOS (VTOC8) info
*/
}
#else
#endif
/*
* adjust the offsets of slices 0-15 or 0-7 by the base of the uidx
*/
for (i = 0; i < NDKMAP; i++) {
/*
* Initialize logical partition info when VTOC is read.
*/
#if defined(_SUNOS_VTOC_8)
#endif
}
return (DDI_SUCCESS);
}
/*
* Using the disk size information in unit and the partition data (p0-p4)
* construct a default device label
* Note - all offsets for slices 0-15 are zero based
* (do not include the offset of the partition which defines s2)
*
* There is a number of cases we have to worry about:
*
* 1) There is an fdisk partition but no Solaris partition.
* In this case the s2 slice size is zero since a valid
* Solaris partition must be present for us to decide the
* the size of the Solaris partition.
*
* 2) There is an fdisk parition and a Solaris partition.
* We got here because the Solaris partition was not labeled
* or the label has been corrupted, declare the entire Solaris
* parition as the s2 slice
*
* 3) There is no fdisk partition.
* We have to declare the entire disk as the s2 slice,
* with some room for the fdisk partition (I think)
*/
static void
{
int s2size;
int nspc;
/* sectors per cylinder */
/*
* set size of s2 from uidx
*/
#if defined(_SUNOS_VTOC_16)
/*
*/
/* Add full disk slice as slice 2 to the disk */
/* Boot slice */
"DEFAULT cyl %d alt %d hd %d sec %d",
#elif defined(_SUNOS_VTOC_8)
/* Add full disk slice as slice 2 to the disk */
"DEFAULT cyl %d alt %d hd %d sec %d",
#else
#endif
/*
* an on-disk label has been constructed above
* call pcdsklbl_chk with the 2nd parm pointing into the label
* will generate a correct checksum in the label
*/
}
int
{
int status;
int backup_block;
int count;
/*
* Data is originated from vtoc. One copy of the data is stored in
* lblp->ondsklbl. This is what we think of as the copy of the lable
* on this held in memory. The other copy (to the lbp) is to be
* written out to the disk.
*/
/*
* check label
*/
#ifdef ATA_DEBUG
if (pcata_debug & DLBL)
#endif
(void) pcata_strategy(bp);
return (status);
/*
* DO backup copies of vtoc
*/
/* issue read */
(void) pcata_strategy(bp);
backup_block += 2;
}
return (0);
}
void
{
#if defined(_SUNOS_VTOC_16)
sizeof (*vtocp));
#elif defined(_SUNOS_VTOC_8)
int i;
#ifdef _SYSCALL32
#else
#endif
/*
* Data is originated from vtoc. One copy of the data is stored in
* lblp->ondsklbl. This is what we think of as the copy of the label
* on the disk held in memory. The other copy (to the lbp) is to be
* written out to the disk.
*/
/*
* Put appropriate vtoc structure fields into the disk label
*
*/
/* For now may want to add the sectorsz field to the generic structur */
/*
* Note the conversion from starting sector number
* to starting cylinder number.
*/
/* Bug Check this */
lmap++;
lpart++;
vpart++;
}
#else
#endif
}
void
{
#if defined(_SUNOS_VTOC_16)
sizeof (*vtocp));
#elif defined(_SUNOS_VTOC_8)
/*
* Put appropriate vtoc structure fields into the disk label
*
*/
{
int i;
#ifdef _SYSCALL32
#else
#endif
/*
* Data is originated from vtoc. One copy of the data is stored in
* lblp->ondsklbl. This is what we think of as the copy of the label
* on this disk held in memory.
*/
sizeof (vtocp->v_bootinfo));
sizeof (vtocp->v_reserved));
/*
* Note the conversion from starting sector number
* to starting cylinder number.
*/
lmap++;
lpart++;
vpart++;
}
}
#else
#endif
}
void
{
#ifdef ATA_DEBUG
" head= %d sect = %d intrlv = %d \n",
dp->dkl_intrlv);
#endif
#if !defined(__sparc)
#endif
}
void
{
#if !defined(__sparc)
#endif
}