2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Andrew Schultz
33 * Simple PCI IDE controller with bus mastering capability and UDMA
34 * modeled after controller in the Intel PIIX4 chip
37 #ifndef __DEV_STORAGE_IDE_CTRL_HH__
38 #define __DEV_STORAGE_IDE_CTRL_HH__
40 #include "base/bitunion.hh"
41 #include "dev/io_device.hh"
42 #include "dev/pci/device.hh"
43 #include "params/IdeController.hh"
48 * Device model for an Intel PIIX4 IDE controller
51 class IdeController : public PciDevice
54 // Bus master IDE status register bit fields
55 BitUnion8(BMIStatusReg)
58 Bitfield<2> intStatus;
61 EndBitUnion(BMIStatusReg)
63 BitUnion8(BMICommandReg)
65 Bitfield<0> startStop;
66 EndBitUnion(BMICommandReg)
78 /** Command and control block registers */
79 Addr cmdAddr, cmdSize, ctrlAddr, ctrlSize;
81 /** Registers used for bus master interface */
85 memset(static_cast<void *>(this), 0, sizeof(*this));
88 BMICommandReg command;
95 /** IDE disks connected to this controller */
96 IdeDisk *master, *slave;
98 /** Currently selected disk */
104 select(bool selSlave)
106 selectBit = selSlave;
107 selected = selectBit ? slave : master;
110 void accessCommand(Addr offset, int size, uint8_t *data, bool read);
111 void accessControl(Addr offset, int size, uint8_t *data, bool read);
112 void accessBMI(Addr offset, int size, uint8_t *data, bool read);
114 Channel(std::string newName, Addr _cmdSize, Addr _ctrlSize);
117 void serialize(const std::string &base, std::ostream &os) const;
118 void unserialize(const std::string &base, CheckpointIn &cp);
124 /** Bus master interface (BMI) registers */
125 Addr bmiAddr, bmiSize;
127 /** Registers used in device specific PCI configuration */
128 uint16_t primaryTiming, secondaryTiming;
129 uint8_t deviceTiming;
134 // Internal management variables
138 uint32_t ioShift, ctrlOffset;
140 void dispatchAccess(PacketPtr pkt, bool read);
143 typedef IdeControllerParams Params;
144 const Params *params() const { return (const Params *)_params; }
145 IdeController(Params *p);
147 /** See if a disk is selected based on its pointer */
148 bool isDiskSelected(IdeDisk *diskPtr);
152 Tick writeConfig(PacketPtr pkt) override;
153 Tick readConfig(PacketPtr pkt) override;
155 void setDmaComplete(IdeDisk *disk);
157 Tick read(PacketPtr pkt) override;
158 Tick write(PacketPtr pkt) override;
160 void serialize(CheckpointOut &cp) const override;
161 void unserialize(CheckpointIn &cp) override;
163 #endif // __DEV_STORAGE_IDE_CTRL_HH_