[BACK]Return to dsk.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / sandpoint / stand / altboot

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/sandpoint/stand/altboot/dsk.c between version 1.11.4.1 and 1.11.4.2

version 1.11.4.1, 2012/02/18 07:33:05 version 1.11.4.2, 2012/04/29 23:04:42
Line 77  static void drive_ident(struct disk *, c
Line 77  static void drive_ident(struct disk *, c
 static char *mkident(char *, int);  static char *mkident(char *, int);
 static void set_xfermode(struct dkdev_ata *, int);  static void set_xfermode(struct dkdev_ata *, int);
 static void decode_dlabel(struct disk *, char *);  static void decode_dlabel(struct disk *, char *);
   static struct disklabel *search_dmagic(char *);
 static int lba_read(struct disk *, int64_t, int, void *);  static int lba_read(struct disk *, int64_t, int, void *);
 static void issue48(struct dvata_chan *, int64_t, int);  static void issue48(struct dvata_chan *, int64_t, int);
 static void issue28(struct dvata_chan *, int64_t, int);  static void issue28(struct dvata_chan *, int64_t, int);
 static struct disk *lookup_disk(int);  static struct disk *lookup_disk(int);
   
 #define MAX_UNITS 8  
 static struct disk ldisk[MAX_UNITS];  static struct disk ldisk[MAX_UNITS];
   
 int  int
Line 306  decode_dlabel(struct disk *d, char *iobu
Line 306  decode_dlabel(struct disk *d, char *iobu
         struct mbr_partition *mp, *bsdp;          struct mbr_partition *mp, *bsdp;
         struct disklabel *dlp;          struct disklabel *dlp;
         struct partition *pp;          struct partition *pp;
         char *dp;  
         int i, first, rf_offset;          int i, first, rf_offset;
   
         bsdp = NULL;          bsdp = NULL;
Line 324  decode_dlabel(struct disk *d, char *iobu
Line 323  decode_dlabel(struct disk *d, char *iobu
         rf_offset = 0;          rf_offset = 0;
         first = (bsdp) ? bswap32(bsdp->mbrp_start) : 0;          first = (bsdp) ? bswap32(bsdp->mbrp_start) : 0;
         (*d->lba_read)(d, first + LABELSECTOR, 1, iobuf);          (*d->lba_read)(d, first + LABELSECTOR, 1, iobuf);
         dp = iobuf /* + LABELOFFSET */;          dlp = search_dmagic(iobuf);
         for (i = 0; i < 512 - sizeof(struct disklabel); i++, dp += 4) {          if (dlp == NULL)
                 dlp = (struct disklabel *)dp;                  goto notfound;
                 if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC) {          if (dlp->d_partitions[0].p_fstype == FS_RAID) {
                         if (dlp->d_partitions[0].p_fstype == FS_RAID) {                  printf("%s%c: raid\n", d->xname, 0 + 'a');
                                 printf("%s%c: raid\n", d->xname, i + 'a');                  snprintf(d->xname, sizeof(d->xname), "raid.");
                                 snprintf(d->xname, sizeof(d->xname), "raid.");                  rf_offset
                                 rf_offset = dlp->d_partitions[0].p_offset +                      = dlp->d_partitions[0].p_offset + RF_PROTECTED_SECTORS;
                                     RF_PROTECTED_SECTORS;                  (*d->lba_read)(d, rf_offset + LABELSECTOR, 1, iobuf);
                                 (*d->lba_read)(d, rf_offset + LABELSECTOR, 1,                  dlp = search_dmagic(iobuf);
                                     iobuf);                  if (dlp == NULL)
                                 dp = iobuf /* + LABELOFFSET */;                          goto notfound;
                                 for (i = 0; i < 512 - sizeof(struct disklabel); i++, dp += 4) {  
                                         dlp = (struct disklabel *)dp;  
                                         if (dlp->d_magic == DISKMAGIC &&  
                                             dlp->d_magic2 == DISKMAGIC)  
                                                 goto found;  
                                 }  
                         } else  /* Not RAID */  
                                 goto found;  
                 }  
         }          }
         d->dlabel = NULL;  
         printf("%s: no disklabel\n", d->xname);  
         return;  
   found:  
         for (i = 0; i < dlp->d_npartitions; i += 1) {          for (i = 0; i < dlp->d_npartitions; i += 1) {
                 const char *type;                  const char *type;
                 pp = &dlp->d_partitions[i];                  pp = &dlp->d_partitions[i];
                 pp->p_offset += rf_offset;                  pp->p_offset += rf_offset;
                 type = NULL;                  type = NULL;
                 switch (pp->p_fstype) {                  switch (pp->p_fstype) {
                 case FS_SWAP: /* swap */                  case FS_SWAP:
                         type = "swap";                          type = "swap";
                         break;                          break;
                 case FS_BSDFFS:                  case FS_BSDFFS:
Line 372  decode_dlabel(struct disk *d, char *iobu
Line 358  decode_dlabel(struct disk *d, char *iobu
         }          }
         d->dlabel = allocaligned(sizeof(struct disklabel), 4);          d->dlabel = allocaligned(sizeof(struct disklabel), 4);
         memcpy(d->dlabel, dlp, sizeof(struct disklabel));          memcpy(d->dlabel, dlp, sizeof(struct disklabel));
           return;
     notfound:
           d->dlabel = NULL;
           printf("%s: no disklabel\n", d->xname);
           return;
   }
   
   struct disklabel *
   search_dmagic(char *dp)
   {
           int i;
           struct disklabel *dlp;
   
           for (i = 0; i < 512 - sizeof(struct disklabel); i += 4, dp += 4) {
                   dlp = (struct disklabel *)dp;
                   if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC)
                           return dlp;
           }
           return NULL;
 }  }
   
 static void  static void
Line 456  static struct disk *
Line 461  static struct disk *
 lookup_disk(int unit)  lookup_disk(int unit)
 {  {
   
         return &ldisk[unit];          return (unit >= 0 && unit < MAX_UNITS) ? &ldisk[unit] : NULL;
   }
   
   int
   dlabel_valid(int unit)
   {
           struct disk *dsk;
   
           dsk = lookup_disk(unit);
           if (dsk == NULL)
                   return NULL;
           return dsk->dlabel != NULL;
 }  }
   
 int  int
Line 481  dsk_open(struct open_file *f, ...)
Line 497  dsk_open(struct open_file *f, ...)
   
         if ((d = lookup_disk(unit)) == NULL)          if ((d = lookup_disk(unit)) == NULL)
                 return ENXIO;                  return ENXIO;
         f->f_devdata = d;  
         if ((dlp = d->dlabel) == NULL || part >= dlp->d_npartitions)          if ((dlp = d->dlabel) == NULL || part >= dlp->d_npartitions)
                 return ENXIO;                  return ENXIO;
         d->part = part;          d->part = part;
           f->f_devdata = d;
   
         snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), name);          snprintf(bi_path.bootpath, sizeof(bi_path.bootpath), name);
         if (dlp->d_partitions[part].p_fstype == FS_BSDFFS) {          if (dlp->d_partitions[part].p_fstype == FS_BSDFFS) {

Legend:
Removed from v.1.11.4.1  
changed lines
  Added in v.1.11.4.2

CVSweb <webmaster@jp.NetBSD.org>