gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  BMICommandReg command;
85  uint8_t reserved0;
86  BMIStatusReg status;
87  uint8_t reserved1;
88  uint32_t bmidtp;
89  } bmiRegs;
90 
92  IdeDisk *master, *slave;
93 
95  IdeDisk *selected;
96 
97  bool selectBit;
98 
99  void
100  select(bool selSlave)
101  {
102  selectBit = selSlave;
103  selected = selectBit ? slave : master;
104  }
105 
106  void accessCommand(Addr offset, int size, uint8_t *data, bool read);
107  void accessControl(Addr offset, int size, uint8_t *data, bool read);
108  void accessBMI(Addr offset, int size, uint8_t *data, bool read);
109 
110  Channel(std::string newName, Addr _cmdSize, Addr _ctrlSize);
111  ~Channel();
112 
113  void serialize(const std::string &base, std::ostream &os) const;
114  void unserialize(const std::string &base, CheckpointIn &cp);
115  };
116 
117  Channel primary;
118  Channel secondary;
119 
122 
125  uint8_t deviceTiming;
126  uint8_t udmaControl;
127  uint16_t udmaTiming;
128  uint16_t ideConfig;
129 
130  // Internal management variables
131  bool ioEnabled;
132  bool bmEnabled;
133 
134  uint32_t ioShift, ctrlOffset;
135 
136  void dispatchAccess(PacketPtr pkt, bool read);
137 
138  public:
139  typedef IdeControllerParams Params;
140  const Params *params() const { return (const Params *)_params; }
142 
144  bool isDiskSelected(IdeDisk *diskPtr);
145 
146  void intrPost();
147 
148  Tick writeConfig(PacketPtr pkt) override;
149  Tick readConfig(PacketPtr pkt) override;
150 
151  void setDmaComplete(IdeDisk *disk);
152 
153  Tick read(PacketPtr pkt) override;
154  Tick write(PacketPtr pkt) override;
155 
156  void serialize(CheckpointOut &cp) const override;
157  void unserialize(CheckpointIn &cp) override;
158 };
159 #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:169
IdeControllerParams Params
Definition: ide_ctrl.hh:139
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: ide_ctrl.cc:602
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:139
uint16_t ideConfig
Definition: ide_ctrl.hh:128
uint16_t secondaryTiming
Definition: ide_ctrl.hh:124
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:545
const Params * params() const
Definition: ide_ctrl.hh:140
BitUnion8(BMIStatusReg) Bitfield< 6 > dmaCap0
Bitfield< 23, 0 > offset
Definition: types.hh:149
bool ioEnabled
Definition: ide_ctrl.hh:131
uint8_t udmaControl
Definition: ide_ctrl.hh:126
uint16_t primaryTiming
Registers used in device specific PCI configuration.
Definition: ide_ctrl.hh:124
Bitfield< 0 > startStop
Definition: ide_ctrl.hh:65
IdeController(Params *p)
Definition: ide_ctrl.cc:95
Bitfield< 17 > os
Definition: misc.hh:804
void dispatchAccess(PacketPtr pkt, bool read)
Definition: ide_ctrl.cc:480
const char data[]
Definition: circlebuf.cc:43
Bitfield< 5, 0 > status
Definition: miscregs.hh:1604
uint32_t ctrlOffset
Definition: ide_ctrl.hh:134
Channel primary
Definition: ide_ctrl.hh:115
Bitfield< 1 > dmaError
Definition: ide_ctrl.hh:59
uint8_t deviceTiming
Definition: ide_ctrl.hh:125
DmaDeviceParams Params
Definition: dma_device.hh:160
uint64_t Tick
Tick count type.
Definition: types.hh:63
uint16_t udmaTiming
Definition: ide_ctrl.hh:127
Bitfield< 51, 12 > base
Definition: pagetable.hh:85
uint32_t ioShift
Definition: ide_ctrl.hh:134
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
Addr bmiAddr
Bus master interface (BMI) registers.
Definition: ide_ctrl.hh:121
int size()
Definition: pagetable.hh:146
virtual const std::string name() const
Definition: sim_object.hh:117
IDE Disk device model.
Definition: ide_disk.hh:207
std::ostream CheckpointOut
Definition: serialize.hh:67
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
EndBitUnion(BMIStatusReg) BitUnion8(BMICommandReg) Bitfield< 3 > rw
Channel secondary
Definition: ide_ctrl.hh:118
Bitfield< 31 > rw
Definition: miscregs.hh:1449
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: ide_ctrl.cc:559
bool bmEnabled
Definition: ide_ctrl.hh:132
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:552
void setDmaComplete(IdeDisk *disk)
Definition: ide_ctrl.cc:152
Bitfield< 5 > dmaCap1
Definition: ide_ctrl.hh:57
void intrPost()
Definition: ide_ctrl.cc:145
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Definition: ide_ctrl.cc:251
Bitfield< 2 > intStatus
Definition: ide_ctrl.hh:58

Generated on Fri Jun 9 2017 13:03:47 for gem5 by doxygen 1.8.6