gem5 v23.0.0.1
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
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 "dev/reg_bank.hh"
41#include "params/IdeController.hh"
42
43namespace gem5
44{
45
46class IdeDisk;
47
53{
54 private:
55 // Bus master IDE status register bit fields
56 BitUnion8(BMIStatusReg)
57 Bitfield<6> dmaCap0;
58 Bitfield<5> dmaCap1;
59 Bitfield<2> intStatus;
60 Bitfield<1> dmaError;
61 Bitfield<0> active;
62 EndBitUnion(BMIStatusReg)
63
64 BitUnion8(BMICommandReg)
65 Bitfield<3> rw;
66 Bitfield<0> startStop;
67 EndBitUnion(BMICommandReg)
68
69
70 class ConfigSpaceRegs : public RegisterBankLE
71 {
72 public:
73 ConfigSpaceRegs(const std::string &name) :
75 {
76 // None of these registers are actually hooked up to control
77 // anything, so they have no specially defined behaviors. They
78 // just store values for now, but should presumably do something
79 // in a more accurate model.
80 addRegisters({primaryTiming, secondaryTiming, deviceTiming, raz0,
81 udmaControl, raz1, udmaTiming, raz2});
82 }
83
84 enum
85 {
86 TimeRegWithDecodeEnabled = 0x8000
87 };
88
89 /* Offset in config space */
90 /* 0x40-0x41 */ Register16 primaryTiming =
91 {"primary timing", TimeRegWithDecodeEnabled};
92 /* 0x42-0x43 */ Register16 secondaryTiming =
93 {"secondary timing", TimeRegWithDecodeEnabled};
94 /* 0x44 */ Register8 deviceTiming = {"device timing"};
95 /* 0x45-0x47 */ RegisterRaz raz0 = {"raz0", 3};
96 /* 0x48 */ Register8 udmaControl = {"udma control"};
97 /* 0x49 */ RegisterRaz raz1 = {"raz1", 1};
98 /* 0x4a-0x4b */ Register16 udmaTiming = {"udma timing"};
99 /* 0x4c-... */ RegisterRaz raz2 = {"raz2", PCI_CONFIG_SIZE - 0x4c};
100
101 void serialize(CheckpointOut &cp) const;
102 void unserialize(CheckpointIn &cp);
103 };
104
105 ConfigSpaceRegs configSpaceRegs;
106
107 public:
108 class Channel : public Named
109 {
110 private:
112
119 IdeDisk *device0 = nullptr, *device1 = nullptr;
120
122 IdeDisk *_selected = nullptr;
123
124 bool selectBit = false;
126
127 bool _pendingInterrupt = false;
128
129 public:
130 bool isPrimary() const { return primary; }
131
132 bool pendingInterrupt() const { return _pendingInterrupt; }
133
134 IdeDisk *selected() const { return _selected; }
135 IdeController *controller() const { return ctrl; }
136
137 void
139 {
140 assert(!device0 && disk);
141 device0 = disk;
142 }
143
144 void
146 {
147 assert(!device1 && disk);
148 device1 = disk;
149 }
150
152 struct BMIRegs
153 {
154 void
156 {
157 memset(static_cast<void *>(this), 0, sizeof(*this));
158 }
159
160 BMICommandReg command;
161 uint8_t reserved0;
162 BMIStatusReg status;
163 uint8_t reserved1;
164 uint32_t bmidtp;
166
167 void
168 select(bool select_device_1)
169 {
170 selectBit = select_device_1;
172 }
173
174 void accessCommand(Addr offset, int size, uint8_t *data, bool read);
175 void accessControl(Addr offset, int size, uint8_t *data, bool read);
176 void accessBMI(Addr offset, int size, uint8_t *data, bool read);
177
178 void setDmaComplete();
179
180 void postInterrupt();
181 void clearInterrupt();
182
183 Channel(std::string new_name, IdeController *new_ctrl,
184 bool new_primary);
185
186 void serialize(const std::string &base, std::ostream &os) const;
187 void unserialize(const std::string &base, CheckpointIn &cp);
188 };
189
190 private:
193
195
196 void dispatchAccess(PacketPtr pkt, bool read);
197
198 public:
200 IdeController(const Params &p);
201
202 virtual void postInterrupt(bool is_primary);
203 virtual void clearInterrupt(bool is_primary);
204
205 Tick writeConfig(PacketPtr pkt) override;
206 Tick readConfig(PacketPtr pkt) override;
207
208 Tick read(PacketPtr pkt) override;
209 Tick write(PacketPtr pkt) override;
210
211 void serialize(CheckpointOut &cp) const override;
212 void unserialize(CheckpointIn &cp) override;
213};
214
215} // namespace gem5
216
217#endif // __DEV_STORAGE_IDE_CTRL_HH_
#define BitUnion8(name)
Definition bitunion.hh:497
const char data[]
DmaDeviceParams Params
void accessControl(Addr offset, int size, uint8_t *data, bool read)
Definition ide_ctrl.cc:216
void setDevice1(IdeDisk *disk)
Definition ide_ctrl.hh:145
void select(bool select_device_1)
Definition ide_ctrl.hh:168
void serialize(const std::string &base, std::ostream &os) const
Definition ide_ctrl.cc:415
void accessCommand(Addr offset, int size, uint8_t *data, bool read)
Definition ide_ctrl.cc:196
void setDevice0(IdeDisk *disk)
Definition ide_ctrl.hh:138
void accessBMI(Addr offset, int size, uint8_t *data, bool read)
Definition ide_ctrl.cc:230
IdeController * controller() const
Definition ide_ctrl.hh:135
IdeDisk * _selected
Currently selected disk.
Definition ide_ctrl.hh:122
void unserialize(const std::string &base, CheckpointIn &cp)
Definition ide_ctrl.cc:443
IdeDisk * device0
IDE disks connected to this controller For more details about device0 and device1 see: https://en....
Definition ide_ctrl.hh:119
struct gem5::IdeController::Channel::BMIRegs bmiRegs
IdeDisk * selected() const
Definition ide_ctrl.hh:134
Device model for an Intel PIIX4 IDE controller.
Definition ide_ctrl.hh:53
virtual void postInterrupt(bool is_primary)
Definition ide_ctrl.cc:140
EndBitUnion(BMIStatusReg) BitUnion8(BMICommandReg) Bitfield< 3 > rw
virtual void clearInterrupt(bool is_primary)
Definition ide_ctrl.cc:149
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition ide_ctrl.cc:387
Bitfield< 0 > startStop
Definition ide_ctrl.hh:66
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition ide_ctrl.cc:394
EndBitUnion(BMICommandReg) class ConfigSpaceRegs ConfigSpaceRegs configSpaceRegs
Registers used in device specific PCI configuration.
Definition ide_ctrl.hh:67
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition ide_ctrl.cc:401
BitUnion8(BMIStatusReg) Bitfield< 6 > dmaCap0
Bitfield< 2 > intStatus
Definition ide_ctrl.hh:59
void dispatchAccess(PacketPtr pkt, bool read)
Definition ide_ctrl.cc:317
Bitfield< 1 > dmaError
Definition ide_ctrl.hh:60
Bitfield< 0 > active
Definition ide_ctrl.hh:61
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition ide_ctrl.cc:429
Bitfield< 5 > dmaCap1
Definition ide_ctrl.hh:58
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
Definition ide_ctrl.cc:158
PARAMS(IdeController)
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Definition ide_ctrl.cc:177
IDE Disk device model.
Definition ide_disk.hh:217
Interface for things with names.
Definition named.hh:39
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
PCI device, base implementation is only config space.
Definition device.hh:270
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
Bitfield< 31 > rw
Bitfield< 23, 0 > offset
Definition types.hh:144
Bitfield< 0 > p
Bitfield< 51, 12 > base
Definition pagetable.hh:141
Bitfield< 17 > os
Definition misc.hh:810
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
void unserialize(ThreadContext &tc, CheckpointIn &cp)
uint64_t Tick
Tick count type.
Definition types.hh:58
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
#define PCI_DEVICE_SPECIFIC
Definition pcireg.h:164
#define PCI_CONFIG_SIZE
Definition pcireg.h:165
Registers used for bus master interface.
Definition ide_ctrl.hh:153
const std::string & name()
Definition trace.cc:48

Generated on Mon Jul 10 2023 15:32:03 for gem5 by doxygen 1.9.7