gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Andrew Schultz
29  * Miguel Serrano
30  */
31 
37 #ifndef __DEV_STORAGE_IDE_CTRL_HH__
38 #define __DEV_STORAGE_IDE_CTRL_HH__
39 
40 #include "base/bitunion.hh"
41 #include "dev/io_device.hh"
42 #include "dev/pci/device.hh"
43 #include "params/IdeController.hh"
44 
45 class IdeDisk;
46 
51 class IdeController : public PciDevice
52 {
53  private:
54  // Bus master IDE status register bit fields
55  BitUnion8(BMIStatusReg)
56  Bitfield<6> dmaCap0;
57  Bitfield<5> dmaCap1;
58  Bitfield<2> intStatus;
59  Bitfield<1> dmaError;
60  Bitfield<0> active;
61  EndBitUnion(BMIStatusReg)
62 
63  BitUnion8(BMICommandReg)
64  Bitfield<3> rw;
65  Bitfield<0> startStop;
66  EndBitUnion(BMICommandReg)
67 
68  struct Channel
69  {
70  std::string _name;
71 
72  const std::string
73  name()
74  {
75  return _name;
76  }
77 
79  Addr cmdAddr, cmdSize, ctrlAddr, ctrlSize;
80 
82  struct BMIRegs
83  {
84  void reset() {
85  memset(static_cast<void *>(this), 0, sizeof(*this));
86  }
87 
88  BMICommandReg command;
89  uint8_t reserved0;
90  BMIStatusReg status;
91  uint8_t reserved1;
92  uint32_t bmidtp;
93  } bmiRegs;
94 
96  IdeDisk *master, *slave;
97 
99  IdeDisk *selected;
100 
101  bool selectBit;
102 
103  void
104  select(bool selSlave)
105  {
106  selectBit = selSlave;
107  selected = selectBit ? slave : master;
108  }
109 
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);
113 
114  Channel(std::string newName, Addr _cmdSize, Addr _ctrlSize);
115  ~Channel();
116 
117  void serialize(const std::string &base, std::ostream &os) const;
118  void unserialize(const std::string &base, CheckpointIn &cp);
119  };
120 
121  Channel primary;
122  Channel secondary;
123 
126 
129  uint8_t deviceTiming;
130  uint8_t udmaControl;
131  uint16_t udmaTiming;
132  uint16_t ideConfig;
133 
134  // Internal management variables
135  bool ioEnabled;
136  bool bmEnabled;
137 
138  uint32_t ioShift, ctrlOffset;
139 
140  void dispatchAccess(PacketPtr pkt, bool read);
141 
142  public:
143  typedef IdeControllerParams Params;
144  const Params *params() const { return (const Params *)_params; }
145  IdeController(Params *p);
146 
148  bool isDiskSelected(IdeDisk *diskPtr);
149 
150  void intrPost();
151 
152  Tick writeConfig(PacketPtr pkt) override;
153  Tick readConfig(PacketPtr pkt) override;
154 
155  void setDmaComplete(IdeDisk *disk);
156 
157  Tick read(PacketPtr pkt) override;
158  Tick write(PacketPtr pkt) override;
159 
160  void serialize(CheckpointOut &cp) const override;
161  void unserialize(CheckpointIn &cp) override;
162 };
163 #endif // __DEV_STORAGE_IDE_CTRL_HH_
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
Definition: ide_ctrl.cc:177
IdeControllerParams Params
Definition: ide_ctrl.hh:143
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: ide_ctrl.cc:610
PCI device, base implementation is only config space.
Definition: device.hh:70
bool isDiskSelected(IdeDisk *diskPtr)
See if a disk is selected based on its pointer.
Definition: ide_ctrl.cc:147
uint16_t ideConfig
Definition: ide_ctrl.hh:132
uint16_t secondaryTiming
Definition: ide_ctrl.hh:128
Device model for an Intel PIIX4 IDE controller.
Definition: ide_ctrl.hh:51
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: ide_ctrl.cc:553
void reset()
Definition: statistics.cc:570
BitUnion8(BMIStatusReg) Bitfield< 6 > dmaCap0
Bitfield< 23, 0 > offset
Definition: types.hh:154
Definition: cprintf.cc:42
bool ioEnabled
Definition: ide_ctrl.hh:135
uint8_t udmaControl
Definition: ide_ctrl.hh:130
uint16_t primaryTiming
Registers used in device specific PCI configuration.
Definition: ide_ctrl.hh:128
Bitfield< 0 > startStop
Definition: ide_ctrl.hh:65
IdeController(Params *p)
Definition: ide_ctrl.cc:95
Bitfield< 17 > os
Definition: misc.hh:805
void dispatchAccess(PacketPtr pkt, bool read)
Definition: ide_ctrl.cc:488
EndBitUnion(BMICommandReg) struct Channel
Definition: ide_ctrl.hh:66
Bitfield< 5, 0 > status
uint32_t ctrlOffset
Definition: ide_ctrl.hh:138
Channel primary
Definition: ide_ctrl.hh:119
Bitfield< 1 > dmaError
Definition: ide_ctrl.hh:59
uint8_t deviceTiming
Definition: ide_ctrl.hh:129
uint64_t Tick
Tick count type.
Definition: types.hh:63
uint16_t udmaTiming
Definition: ide_ctrl.hh:131
Bitfield< 51, 12 > base
Definition: pagetable.hh:142
uint32_t ioShift
Definition: ide_ctrl.hh:138
const Params * params() const
Definition: ide_ctrl.hh:144
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
virtual const std::string name() const
Definition: sim_object.hh:120
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Addr bmiAddr
Bus master interface (BMI) registers.
Definition: ide_ctrl.hh:125
IDE Disk device model.
Definition: ide_disk.hh:207
std::ostream CheckpointOut
Definition: serialize.hh:68
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
EndBitUnion(BMIStatusReg) BitUnion8(BMICommandReg) Bitfield< 3 > rw
Channel secondary
Definition: ide_ctrl.hh:122
Bitfield< 31 > rw
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: ide_ctrl.cc:567
bool bmEnabled
Definition: ide_ctrl.hh:136
Bitfield< 0 > active
Definition: ide_ctrl.hh:60
Bitfield< 0 > p
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: ide_ctrl.cc:560
const char data[]
void setDmaComplete(IdeDisk *disk)
Definition: ide_ctrl.cc:160
Bitfield< 5 > dmaCap1
Definition: ide_ctrl.hh:57
void intrPost()
Definition: ide_ctrl.cc:153
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Definition: ide_ctrl.cc:259
Bitfield< 2 > intStatus
Definition: ide_ctrl.hh:58

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13