From: Andrew Schultz Date: Wed, 23 Jun 2004 19:37:05 +0000 (-0400) Subject: Fix to properly shadow the DEV bit in the Drive/Head register so other X-Git-Tag: m5_1.0_tutorial~294^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=06d8f0af5def68e395b58636d5e7d6ca69daa51f;p=gem5.git Fix to properly shadow the DEV bit in the Drive/Head register so other disks are properly detected and handled --HG-- extra : convert_revision : ffc3046deb68458ee2ef6fa5263dc471488abc45 --- diff --git a/dev/ide_ctrl.cc b/dev/ide_ctrl.cc index 46a0e8179..4805570d2 100644 --- a/dev/ide_ctrl.cc +++ b/dev/ide_ctrl.cc @@ -192,6 +192,22 @@ IdeController::getDisk(IdeDisk *diskPtr) return -1; } +bool +IdeController::isDiskSelected(IdeDisk *diskPtr) +{ + for (int i = 0; i < 4; i++) { + if ((long)diskPtr == (long)disks[i]) { + // is disk is on primary or secondary channel + int channel = i/2; + // is disk the master or slave + int devID = i%2; + + return (dev[channel] == devID); + } + } + panic("Unable to find disk by pointer!!\n"); +} + //// // Command completion //// diff --git a/dev/ide_ctrl.hh b/dev/ide_ctrl.hh index 679c7422b..39c64eb30 100644 --- a/dev/ide_ctrl.hh +++ b/dev/ide_ctrl.hh @@ -144,6 +144,10 @@ class IdeController : public PciDev /** Select the disk based on a pointer */ int getDisk(IdeDisk *diskPtr); + public: + /** See if a disk is selected based on its pointer */ + bool isDiskSelected(IdeDisk *diskPtr); + public: /** * Constructs and initializes this controller. diff --git a/dev/ide_disk.cc b/dev/ide_disk.cc index 0f5c02660..ee21feaea 100644 --- a/dev/ide_disk.cc +++ b/dev/ide_disk.cc @@ -167,6 +167,12 @@ IdeDisk::reset(int id) // Utility functions //// +bool +IdeDisk::isDEVSelect() +{ + return ctrl->isDiskSelected(this); +} + Addr IdeDisk::pciToDma(Addr pciAddr) { diff --git a/dev/ide_disk.hh b/dev/ide_disk.hh index 409aaef9a..9c6eea623 100644 --- a/dev/ide_disk.hh +++ b/dev/ide_disk.hh @@ -320,7 +320,7 @@ class IdeDisk : public SimObject // Utility functions bool isBSYSet() { return (status & STATUS_BSY_BIT); } bool isIENSet() { return nIENBit; } - bool isDEVSelect() { return ((cmdReg.drive & SELECT_DEV_BIT) == devID); } + bool isDEVSelect(); void setComplete() {