⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 promise_ide.c

📁 promise_ide vxWorks driver
💻 C
📖 第 1 页 / 共 5 页
字号:

    case 2:    
      drive_pci = 0x68;
      status = pciConfigInLong(
                        BusNo,       /* bus number */
                        DeviceNo,    /* device number */
                        FuncNo,      /* function number */
                        drive_pci,   /* offset into the configuration space */
                        &drive_conf  /* data write from offset */
                         );
#if 0
      if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4)) {
        goto chipset_is_set;
      }
#endif
      status = pciConfigInByte(
                        BusNo,       /* bus number */
                        DeviceNo,    /* device number */
                        FuncNo,      /* function number */
                        drive_pci,   /* offset into the configuration space */
                        &test1       /* data write from offset */
                        );

#if 1
      if (!(test1 & SYNC_ERRDY_EN)) {
        status = pciConfigOutByte(
                          BusNo,              /* bus number */
                          DeviceNo,           /* device number */
                          FuncNo,             /* function number */
                          drive_pci,          /* offset into the configuration space */
                          test1|SYNC_ERRDY_EN /* data write from offset */
                          );

      }
#endif
      break;

    case 3:    
      drive_pci = 0x6c;
      status = pciConfigInLong(
                        BusNo,       /* bus number */
                        DeviceNo,    /* device number */
                        FuncNo,      /* function number */
                        drive_pci,   /* offset into the configuration space */
                        &drive_conf  /* data write from offset */
                        );
#if 0
      if ((drive_conf != 0x004ff304) && (drive_conf != 0x004ff3c4)) {
        goto chipset_is_set;
      }
#endif

      status = pciConfigInByte(
                        BusNo,       /* bus number */
                        DeviceNo,    /* device number */
                        FuncNo,      /* function number */
                        0x68,        /* offset into the configuration space */
                        &test1       /* data write from offset */
                        );
      status = pciConfigInByte(
                        BusNo,       /* bus number */
                        DeviceNo,    /* device number */
                        FuncNo,      /* function number */
                        drive_pci,   /* offset into the configuration space */
                        &test2       /* data write from offset */
                        );

      if ((test1 & SYNC_ERRDY_EN) && !(test2 & SYNC_ERRDY_EN)) {
        status = pciConfigOutByte(
                          BusNo,              /* bus number */
                          DeviceNo,           /* device number */
                          FuncNo,             /* function number */
                          drive_pci,          /* offset into the configuration space */
                          test2|SYNC_ERRDY_EN /* data write from offset */
                       );
      }
      break;

    default:
      return ide_dma_off;
    }

chipset_is_set:

//    if (drive->media != ide_disk)  
//              return ide_dma_off_quietly;
       
  status = pciConfigInByte(
                BusNo,          /* bus number */
                DeviceNo,       /* device number */
                FuncNo,         /* function number */
                drive_pci,      /* offset into the configuration space */
                &AP             /* data write from offset */
                );
  status = pciConfigInByte(
                BusNo,          /* bus number */
                DeviceNo,       /* device number */
                FuncNo,         /* function number */
                drive_pci|0x01, /* offset into the configuration space */
                &BP             /* data write from offset */
                );
  status = pciConfigInByte(
                BusNo,          /* bus number */
                DeviceNo,       /* device number */
                FuncNo,         /* function number */
                drive_pci|0x02, /* offset into the configuration space */
                &CP             /* data write from offset */
                );
  status = pciConfigInByte(
                BusNo,          /* bus number */
                DeviceNo,       /* device number */
                FuncNo,         /* function number */
                drive_pci|0x03, /* offset into the configuration space */
                &DP             /* data write from offset */
                );
  if (pDrive->okIordy) {      /* IORDY_EN */
    status = pciConfigOutByte(
                   BusNo,       /* bus number */
                   DeviceNo,    /* device number */
                   FuncNo,      /* function number */
                   drive_pci,   /* offset into the configuration space */
                   AP|IORDY_EN  /* data write from offset */
                   );

    status = pciConfigInByte(
                   BusNo,       /* bus number */
                   DeviceNo,    /* device number */
                   FuncNo,      /* function number */
                   drive_pci,   /* offset into the configuration space */
                   &AP          /* data write from offset */
                   );
    
  }

// look in id->word0 ?????
//    if (drive->media == ide_disk) {}        /* PREFETCH_EN */
if (pDrive->type == ATA_TYPE_ATA) {
  status = pciConfigOutByte(
                  BusNo,         /* bus number */
                  DeviceNo,      /* device number */
                  FuncNo,        /* function number */
                  drive_pci,     /* offset into the configuration space */
                  AP|PREFETCH_EN /* data write from offset */
                  );
  status = pciConfigInByte(
                  BusNo,         /* bus number */
                  DeviceNo,      /* device number */
                  FuncNo,        /* function number */
                  drive_pci,     /* offset into the configuration space */
                  &AP            /* data write from offset */
                  );
}


/* hack set PIO mode 4 here */
  AP = AP | 0x01;
  BP = BP | 0x04;
  status = pciConfigOutByte(
                  BusNo,         /* bus number */
                  DeviceNo,      /* device number */
                  FuncNo,        /* function number */
                  drive_pci,     /* offset into the configuration space */
                  AP             /* data write from offset */
                  );

  status = pciConfigOutByte(
                  BusNo,         /* bus number */
                  DeviceNo,      /* device number */
                  FuncNo,        /* function number */
                  drive_pci+1,     /* offset into the configuration space */
                  BP             /* data write from offset */
                  );

  status = pciConfigInByte(
                  BusNo,         /* bus number */
                  DeviceNo,      /* device number */
                  FuncNo,        /* function number */
                  drive_pci,     /* offset into the configuration space */
                  &AP             /* data write from offset */
                  );

  status = pciConfigInByte(
                  BusNo,         /* bus number */
                  DeviceNo,      /* device number */
                  FuncNo,        /* function number */
                  drive_pci+1,     /* offset into the configuration space */
                  &BP             /* data write from offset */
                  );



  if ((BP & 0xF0) && (CP & 0x0F)) {
    /* clear DMA modes of upper 842 bits of B Register */
    /* clear PIO forced mode upper 1 bit of B Register */
    status = pciConfigOutByte(
                    BusNo,          /* bus number */
                    DeviceNo,       /* device number */
                    FuncNo,         /* function number */
                    drive_pci|0x01, /* offset into the configuration space */
                    BP & ~0xF0      /* data write from offset */
                    );
    status = pciConfigInByte(
                    BusNo,          /* bus number */
                    DeviceNo,       /* device number */
                    FuncNo,         /* function number */
                    drive_pci|0x01, /* offset into the configuration space */
                    &BP             /* data write from offset */
                    );


    /* clear DMA modes of lower 8421 bits of C Register */
    status = pciConfigOutByte(
                    BusNo,         /* bus number */
                    DeviceNo,      /* device number */
                    FuncNo,        /* function number */
                    drive_pci|0x02,/* offset into the configuration space */
                    CP & ~0x0F     /* data write from offset */
                    );

    status = pciConfigInByte(
                    BusNo,         /* bus number */
                    DeviceNo,      /* device number */
                    FuncNo,        /* function number */
                    drive_pci|0x02,/* offset into the configuration space */
                    &CP            /* data write from offset */
                    );
  }

  status = pciConfigInByte(
                BusNo,         /* bus number */
                DeviceNo,      /* device number */
                FuncNo,        /* function number */
                drive_pci,     /* offset into the configuration space */
                &AP            /* data write from offset */
                );

  status = pciConfigInByte(
                BusNo,         /* bus number */
                DeviceNo,      /* device number */
                FuncNo,        /* function number */
                drive_pci|0x01,/* offset into the configuration space */
                &BP            /* data write from offset */
                );

  status = pciConfigInByte(
                BusNo,         /* bus number */
                DeviceNo,      /* device number */
                FuncNo,        /* function number */
                drive_pci|0x02,/* offset into the configuration space */
                &CP            /* data write from offset */
                );
      
        
  udma_66 = 1;
  udma_33 = (udma) ? udma_33 : 0;

  if ((id->ultraDma & 0x0010) && (udma_66) && (udma_33)) {
    if (!((id->ultraDma >> 8) & 16)) {
      id->ultraDma &= ~0xFF00;
      id->ultraDma |= 0x1010;
      id->multiDma &= ~0x0F00;
      id->singleDma &= ~0x0F00;
    }
    
    /* speed 8 == UDMA mode 4 == speed 6 plus cable */
    status = pciConfigOutByte(
                    BusNo,           /* bus number */
                    DeviceNo,        /* device number */
                    FuncNo,          /* function number */
                    drive_pci|0x01,  /* offset into the configuration space */
                    BP|0x20          /* data write from offset */
                    );


    status = pciConfigOutByte(
                    BusNo,           /* bus number */
                    DeviceNo,        /* device number */
                    FuncNo,          /* function number */
                    drive_pci|0x02,  /* offset into the configuration space */
                    CP|0x01          /* data write from offset */
                    );

    speed = ATA_DMA_ULTRA_W_4;

  } else if ((id->ultraDma & 0x0008) && (udma_66) && (udma_33)) {
    if (!((id->ultraDma >> 8) & 8)) {
      id->ultraDma &= ~0xFF00;
      id->ultraDma |= 0x0808;
      id->multiDma &= ~0x0F00;
      id->singleDma &= ~0x0F00;
    }

    /* speed 7 == UDMA mode 3 == speed 5 plus cable */
    status = pciConfigOutByte(
                    BusNo,          /* bus number */
                    DeviceNo,       /* device number */
                    FuncNo,         /* function number */
                    drive_pci|0x01, /* offset into the configuration space */
                    BP|0x40         /* data write from offset */
                    );

    status = pciConfigOutByte(
                    BusNo,          /* bus number */
                    DeviceNo,       /* device number */
                    FuncNo,         /* function number */
                    drive_pci|0x02, /* offset into the configuration space */
                    CP|0x02         /* data write from offset */
                );

    speed = ATA_DMA_ULTRA_W_3;
  } else if ((id->ultraDma & 0x0004) && (udma_33)) {
    if (!((id->ultraDma >> 8) & 4)) {
      id->ultraDma &= ~0x0F00;
      id->ultraDma |= 0x0404;
      id->multiDma &= ~0x0F00;
      id->singleDma &= ~0x0F00;
    }
    
    /* speed 6 == UDMA mode 2 */
    status = pciConfigOutByte(
                    BusNo,         /* bus number */
                    DeviceNo,      /* device number */
                    FuncNo,        /* function number */
                    drive_pci|0x01,/* offset into the configuration space */
                    BP|0x20        /* data write from offset */
                    );

    status = pciConfigOutByte(
                    BusNo,         /* bus number */
                    DeviceNo,      /* device number */
                    FuncNo,        /* function number */
                    drive_pci|0x02,/* offset into the configuration space */
                    CP|0x01        /* data write from offset */
                    );

    speed = ATA_DMA_ULTRA_W_2;
  } else if ((id->ultraDma & 0x0002) && (udma_33)) {
    if (!((id->ultraDma >> 8) & 2)) {
      id->ultraDma &= ~0x0F00;
      id->ultraDma |= 0x0202;
      id->multiDma &= ~0x0F00;
      id->singleDma &= ~0x0F00;
    }
    
    /* speed 5 == UDMA mode 1 */
    status = pciConfigOutByte(
                    BusNo,         /* bus number */
                    DeviceNo,      /* device number */
                    FuncNo,        /* function number */
                    drive_pci|0x01,/* offset into the configuration space */
                    BP|0x40        /* data write from offset */
                    );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -