2004-03-23 23:10:07 +01:00
|
|
|
/*
|
2005-06-05 11:16:00 +02:00
|
|
|
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
2004-03-23 23:10:07 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
|
|
|
* Authors: Andrew Schultz
|
|
|
|
* Miguel Serrano
|
2004-03-23 23:10:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file
|
2004-05-12 22:55:49 +02:00
|
|
|
* Simple PCI IDE controller with bus mastering capability and UDMA
|
|
|
|
* modeled after controller in the Intel PIIX4 chip
|
2004-03-23 23:10:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IDE_CTRL_HH__
|
|
|
|
#define __IDE_CTRL_HH__
|
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
#include "base/bitunion.hh"
|
2004-03-23 23:10:07 +01:00
|
|
|
#include "dev/pcidev.hh"
|
|
|
|
#include "dev/pcireg.h"
|
|
|
|
#include "dev/io_device.hh"
|
2007-07-24 06:51:38 +02:00
|
|
|
#include "params/IdeController.hh"
|
2004-03-23 23:10:07 +01:00
|
|
|
|
|
|
|
class IdeDisk;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Device model for an Intel PIIX4 IDE controller
|
|
|
|
*/
|
|
|
|
|
|
|
|
class IdeController : public PciDev
|
|
|
|
{
|
2008-12-07 21:59:48 +01:00
|
|
|
private:
|
|
|
|
// Bus master IDE status register bit fields
|
|
|
|
BitUnion8(BMIStatusReg)
|
|
|
|
Bitfield<6> dmaCap0;
|
|
|
|
Bitfield<5> dmaCap1;
|
|
|
|
Bitfield<2> intStatus;
|
|
|
|
Bitfield<1> dmaError;
|
|
|
|
Bitfield<0> active;
|
|
|
|
EndBitUnion(BMIStatusReg)
|
|
|
|
|
|
|
|
BitUnion8(BMICommandReg)
|
|
|
|
Bitfield<3> rw;
|
|
|
|
Bitfield<0> startStop;
|
|
|
|
EndBitUnion(BMICommandReg)
|
|
|
|
|
|
|
|
struct Channel
|
|
|
|
{
|
|
|
|
std::string _name;
|
|
|
|
|
|
|
|
const std::string
|
|
|
|
name()
|
|
|
|
{
|
|
|
|
return _name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Command and control block registers */
|
|
|
|
Addr cmdAddr, cmdSize, ctrlAddr, ctrlSize;
|
|
|
|
|
|
|
|
/** Registers used for bus master interface */
|
|
|
|
struct BMIRegs
|
|
|
|
{
|
|
|
|
BMICommandReg command;
|
|
|
|
uint8_t reserved0;
|
|
|
|
BMIStatusReg status;
|
|
|
|
uint8_t reserved1;
|
|
|
|
uint32_t bmidtp;
|
|
|
|
} bmiRegs;
|
2004-11-13 21:45:22 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
/** IDE disks connected to this controller */
|
|
|
|
IdeDisk *master, *slave;
|
2005-08-15 22:59:58 +02:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
/** Currently selected disk */
|
|
|
|
IdeDisk *selected;
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
bool selectBit;
|
2005-08-15 22:59:58 +02:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
void
|
|
|
|
select(bool selSlave)
|
|
|
|
{
|
|
|
|
selectBit = selSlave;
|
|
|
|
selected = selectBit ? slave : master;
|
|
|
|
}
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
void accessCommand(Addr offset, int size, uint8_t *data, bool read);
|
|
|
|
void accessControl(Addr offset, int size, uint8_t *data, bool read);
|
|
|
|
void accessBMI(Addr offset, int size, uint8_t *data, bool read);
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
Channel(std::string newName, Addr _cmdSize, Addr _ctrlSize);
|
|
|
|
~Channel();
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-15 08:29:49 +01:00
|
|
|
void serialize(const std::string &base, std::ostream &os);
|
|
|
|
void unserialize(const std::string &base, Checkpoint *cp,
|
|
|
|
const std::string §ion);
|
|
|
|
};
|
2004-05-03 17:47:52 +02:00
|
|
|
|
2008-12-15 08:29:49 +01:00
|
|
|
Channel primary;
|
|
|
|
Channel secondary;
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
/** Bus master interface (BMI) registers */
|
|
|
|
Addr bmiAddr, bmiSize;
|
2004-05-03 17:47:52 +02:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
/** Registers used in device specific PCI configuration */
|
|
|
|
uint16_t primaryTiming, secondaryTiming;
|
|
|
|
uint8_t deviceTiming;
|
|
|
|
uint8_t udmaControl;
|
|
|
|
uint16_t udmaTiming;
|
|
|
|
uint16_t ideConfig;
|
|
|
|
|
|
|
|
// Internal management variables
|
|
|
|
bool ioEnabled;
|
|
|
|
bool bmEnabled;
|
|
|
|
|
|
|
|
void dispatchAccess(PacketPtr pkt, bool read);
|
2004-06-23 21:37:05 +02:00
|
|
|
|
2004-03-23 23:10:07 +01:00
|
|
|
public:
|
2007-07-24 06:51:38 +02:00
|
|
|
typedef IdeControllerParams Params;
|
2004-11-13 21:45:22 +01:00
|
|
|
const Params *params() const { return (const Params *)_params; }
|
|
|
|
IdeController(Params *p);
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
/** See if a disk is selected based on its pointer */
|
|
|
|
bool isDiskSelected(IdeDisk *diskPtr);
|
|
|
|
|
|
|
|
void intrPost();
|
|
|
|
|
|
|
|
Tick writeConfig(PacketPtr pkt);
|
|
|
|
Tick readConfig(PacketPtr pkt);
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2004-05-03 17:47:52 +02:00
|
|
|
void setDmaComplete(IdeDisk *disk);
|
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
Tick read(PacketPtr pkt);
|
|
|
|
Tick write(PacketPtr pkt);
|
2004-03-23 23:10:07 +01:00
|
|
|
|
2008-12-07 21:59:48 +01:00
|
|
|
void serialize(std::ostream &os);
|
|
|
|
void unserialize(Checkpoint *cp, const std::string §ion);
|
2004-03-23 23:10:07 +01:00
|
|
|
};
|
|
|
|
#endif // __IDE_CTRL_HH_
|