Browse Source

Fix the problem of sata ports scanning

Before: When port1 and port2 had hard disks, we found that port2 was wd0 and port1 was
wd1,because the code scaned port2 earlier than port1, so it caused the problem as bug  278
described as http://10.2.5.24/dev/bugzilla/show_bug.cgi?id=278 shows.
Now: When port1 and port2 have hard disks, we exchange the names of their device structure in
linked list of device.
Test: Make sure that port1 and port2 have hard disks, and boot to PMON interface, run "load
/dev/fs/ext2@wd0/boot/" and "load /dev/fs/ext2@wd1/boot/", you will find that informations
are right.

Targets: All
master
fandongdong 13 years ago
committed by wanghongmei
parent
commit
c0f280b099
  1. 16
      sys/dev/ic/wdc.c
  2. 21
      sys/dev/pci/pciide.c
  3. 18
      sys/kern/subr_autoconf.c

16
sys/dev/ic/wdc.c

@ -155,6 +155,14 @@ struct channel_softc_vtbl wdc_default_vtbl = {
wdc_default_write_raw_multi_4
};
/*********sata flags for port0 - port5***************/
int sata_flags[6] = {0};
/***************************************************/
u_int8_t
wdc_default_read_reg(chp, reg)
struct channel_softc *chp;
@ -679,6 +687,14 @@ wdcattach(chp)
aa_link.aa_channel = chp->channel;
aa_link.aa_openings = 1;
aa_link.aa_drv_data = &chp->ch_drive[i];
//set flags if port1 and port2 have satadisks
if(chp->channel == 0 && i == 1)
sata_flags[1] = 1;
if(chp->channel == 1 && i == 0)
sata_flags[2] = 1;
config_found(&chp->wdc->sc_dev, (void *)&aa_link, wdprint);
}

21
sys/dev/pci/pciide.c

@ -415,6 +415,8 @@ const struct pciide_vendor_desc pciide_vendors[] = {
#define PCIIDE_CHANNEL_NAME(chan) ((chan) == 0 ? "ch 0" : "ch 1")
extern struct device *sata_devs[6];
/* options passed via the 'flags' config keyword */
#define PCIIDE_OPTIONS_DMA 0x01
@ -1211,6 +1213,9 @@ default_chip_map(sc, pa)
sc->sc_tag, PCI_CLASS_REG));
pcireg_t csr;
int channel;
char tmp[16];
static once = 0;
#if !defined(PMON)||defined(IDE_DMA)
int drive;
struct ata_drive_datas *drvp;
@ -1310,6 +1315,22 @@ next:
}
}
//swap the names of port1 and port2 only once if both of them have satadisks
if(sata_devs[1] != NULL && sata_devs[2] != NULL && !once)
{
strcpy(tmp, (sata_devs[1])->dv_xname);
strcpy( (sata_devs[1])->dv_xname, (sata_devs[2])->dv_xname);
strcpy( (sata_devs[2])->dv_xname, tmp);
once = 1;
sata_devs[1] = NULL;
sata_devs[2] = NULL;
}
#if !defined(PMON)||defined(IDE_DMA)
if (sc->sc_dma_ok == 0)
return;

18
sys/kern/subr_autoconf.c

@ -310,6 +310,9 @@ config_rootsearch(fn, rootname, aux)
char *msgs[3] = { "", " not configured\n", " unsupported\n" };
struct device *sata_devs[6]={NULL}; //array for pointers of sata devs
extern int sata_flags[6];
/*
* The given `aux' argument describes a device that has been found
* on the given parent, but not necessarily configured. Locate the
@ -327,8 +330,21 @@ config_found_sm(parent, aux, print, submatch)
{
void *match;
struct device *dev = NULL;
static int i = 1;
if ((match = config_search(submatch, parent, aux)) != NULL)
return (config_attach(parent, match, aux, print));
{
dev =config_attach(parent, match, aux, print);
if(sata_flags[i] == 1)
{
sata_devs[i] = dev; //save pointer of dev when port1 and port2 have satadisks
i++;
}
return dev;
}
if (print)
printf(msgs[(*print)(aux, parent->dv_xname)]);
return (NULL);

Loading…
Cancel
Save