gem5  v20.1.0.0
ide_ctrl.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
34 #ifndef __DEV_STORAGE_IDE_CTRL_HH__
35 #define __DEV_STORAGE_IDE_CTRL_HH__
36 
37 #include "base/bitunion.hh"
38 #include "dev/io_device.hh"
39 #include "dev/pci/device.hh"
40 #include "params/IdeController.hh"
41 
42 class IdeDisk;
43 
48 class IdeController : public PciDevice
49 {
50  private:
51  // Bus master IDE status register bit fields
52  BitUnion8(BMIStatusReg)
53  Bitfield<6> dmaCap0;
54  Bitfield<5> dmaCap1;
55  Bitfield<2> intStatus;
56  Bitfield<1> dmaError;
57  Bitfield<0> active;
58  EndBitUnion(BMIStatusReg)
59 
60  BitUnion8(BMICommandReg)
61  Bitfield<3> rw;
62  Bitfield<0> startStop;
63  EndBitUnion(BMICommandReg)
64 
65  struct Channel
66  {
67  std::string _name;
68 
69  const std::string
70  name()
71  {
72  return _name;
73  }
74 
76  Addr cmdAddr, cmdSize, ctrlAddr, ctrlSize;
77 
79  struct BMIRegs
80  {
81  void reset() {
82  memset(static_cast<void *>(this), 0, sizeof(*this));
83  }
84 
85  BMICommandReg command;
86  uint8_t reserved0;
87  BMIStatusReg status;
88  uint8_t reserved1;
89  uint32_t bmidtp;
90  } bmiRegs;
91 
98  IdeDisk *device0, *device1;
99 
101  IdeDisk *selected;
102 
103  bool selectBit;
104 
105  void
106  select(bool select_device_1)
107  {
108  selectBit = select_device_1;
109  selected = selectBit ? device1 : device0;
110  }
111 
112  void accessCommand(Addr offset, int size, uint8_t *data, bool read);
113  void accessControl(Addr offset, int size, uint8_t *data, bool read);
114  void accessBMI(Addr offset, int size, uint8_t *data, bool read);
115 
116  Channel(std::string newName, Addr _cmdSize, Addr _ctrlSize);
117  ~Channel();
118 
119  void serialize(const std::string &base, std::ostream &os) const;
120  void unserialize(const std::string &base, CheckpointIn &cp);
121  };
122 
123  Channel primary;
124  Channel secondary;
125 
128 
131  uint8_t deviceTiming;
132  uint8_t udmaControl;
133  uint16_t udmaTiming;
134  uint16_t ideConfig;
135 
136  // Internal management variables
137  bool ioEnabled;
138  bool bmEnabled;
139 
140  uint32_t ioShift, ctrlOffset;
141 
142  void dispatchAccess(PacketPtr pkt, bool read);
143 
144  public:
145  typedef IdeControllerParams Params;
146  const Params *params() const { return (const Params *)_params; }
148 
150  bool isDiskSelected(IdeDisk *diskPtr);
151 
152  void intrPost();
153 
154  Tick writeConfig(PacketPtr pkt) override;
155  Tick readConfig(PacketPtr pkt) override;
156 
157  void setDmaComplete(IdeDisk *disk);
158 
159  Tick read(PacketPtr pkt) override;
160  Tick write(PacketPtr pkt) override;
161 
162  void serialize(CheckpointOut &cp) const override;
163  void unserialize(CheckpointIn &cp) override;
164 };
165 #endif // __DEV_STORAGE_IDE_CTRL_HH_
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
io_device.hh
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
IdeController::dmaCap1
Bitfield< 5 > dmaCap1
Definition: ide_ctrl.hh:54
IdeController::ctrlOffset
uint32_t ctrlOffset
Definition: ide_ctrl.hh:140
data
const char data[]
Definition: circlebuf.test.cc:42
IdeController
Device model for an Intel PIIX4 IDE controller.
Definition: ide_ctrl.hh:48
IdeController::serialize
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: ide_ctrl.cc:563
IdeController::IdeController
IdeController(Params *p)
Definition: ide_ctrl.cc:91
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
IdeController::udmaTiming
uint16_t udmaTiming
Definition: ide_ctrl.hh:133
IdeController::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: ide_ctrl.cc:556
IdeController::udmaControl
uint8_t udmaControl
Definition: ide_ctrl.hh:132
IdeController::active
Bitfield< 0 > active
Definition: ide_ctrl.hh:57
X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
IdeController::secondaryTiming
uint16_t secondaryTiming
Definition: ide_ctrl.hh:130
Stats::reset
void reset()
Definition: statistics.cc:569
IdeController::bmiSize
Addr bmiSize
Definition: ide_ctrl.hh:127
device.hh
IdeController::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: ide_ctrl.cc:549
IdeController::intStatus
Bitfield< 2 > intStatus
Definition: ide_ctrl.hh:55
IdeController::deviceTiming
uint8_t deviceTiming
Definition: ide_ctrl.hh:131
IdeController::Params
IdeControllerParams Params
Definition: ide_ctrl.hh:145
IdeController::dmaError
Bitfield< 1 > dmaError
Definition: ide_ctrl.hh:56
IdeController::isDiskSelected
bool isDiskSelected(IdeDisk *diskPtr)
See if a disk is selected based on its pointer.
Definition: ide_ctrl.cc:143
cp
Definition: cprintf.cc:40
IdeController::dispatchAccess
void dispatchAccess(PacketPtr pkt, bool read)
Definition: ide_ctrl.cc:484
IdeController::setDmaComplete
void setDmaComplete(IdeDisk *disk)
Definition: ide_ctrl.cc:156
bitunion.hh
IdeController::params
const Params * params() const
Definition: ide_ctrl.hh:146
IdeController::EndBitUnion
EndBitUnion(BMIStatusReg) BitUnion8(BMICommandReg) Bitfield< 3 > rw
IdeController::ioEnabled
bool ioEnabled
Definition: ide_ctrl.hh:137
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
IdeController::writeConfig
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Definition: ide_ctrl.cc:255
IdeDisk
IDE Disk device model.
Definition: ide_disk.hh:205
IdeController::ioShift
uint32_t ioShift
Definition: ide_ctrl.hh:140
IdeController::primary
Channel primary
Definition: ide_ctrl.hh:121
IdeController::EndBitUnion
EndBitUnion(BMICommandReg) struct Channel
Definition: ide_ctrl.hh:63
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
IdeController::ideConfig
uint16_t ideConfig
Definition: ide_ctrl.hh:134
IdeController::readConfig
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
Definition: ide_ctrl.cc:173
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
IdeController::BitUnion8
BitUnion8(BMIStatusReg) Bitfield< 6 > dmaCap0
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
ArmISA::rw
Bitfield< 31 > rw
Definition: miscregs_types.hh:249
IdeController::bmiAddr
Addr bmiAddr
Bus master interface (BMI) registers.
Definition: ide_ctrl.hh:127
IdeController::primaryTiming
uint16_t primaryTiming
Registers used in device specific PCI configuration.
Definition: ide_ctrl.hh:130
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
IdeController::startStop
Bitfield< 0 > startStop
Definition: ide_ctrl.hh:62
IdeController::intrPost
void intrPost()
Definition: ide_ctrl.cc:149
IdeController::secondary
Channel secondary
Definition: ide_ctrl.hh:124
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
CheckpointIn
Definition: serialize.hh:67
PciDevice
PCI device, base implementation is only config space.
Definition: device.hh:66
DmaDevice::Params
DmaDeviceParams Params
Definition: dma_device.hh:171
IdeController::unserialize
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: ide_ctrl.cc:606
ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:153
IdeController::bmEnabled
bool bmEnabled
Definition: ide_ctrl.hh:138

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17