gem5 v24.0.0.0
Loading...
Searching...
No Matches
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 =
100 {"raz2", (PCI_CONFIG_SIZE + 1) - 0x4c};
101
102 void serialize(CheckpointOut &cp) const;
103 void unserialize(CheckpointIn &cp);
104 };
105
106 ConfigSpaceRegs configSpaceRegs;
107
108 public:
109 class Channel : public Named
110 {
111 private:
113
120 IdeDisk *device0 = nullptr, *device1 = nullptr;
121
123 IdeDisk *_selected = nullptr;
124
125 bool selectBit = false;
127
128 bool _pendingInterrupt = false;
129
130 public:
131 bool isPrimary() const { return primary; }
132
133 bool pendingInterrupt() const { return _pendingInterrupt; }
134
135 IdeDisk *selected() const { return _selected; }
136 IdeController *controller() const { return ctrl; }
137
138 void
140 {
141 assert(!device0 && disk);
142 device0 = disk;
143 }
144
145 void
147 {
148 assert(!device1 && disk);
149 device1 = disk;
150 }
151
153 struct BMIRegs
154 {
155 void
157 {
158 memset(static_cast<void *>(this), 0, sizeof(*this));
159 }
160
161 BMICommandReg command;
162 uint8_t reserved0;
163 BMIStatusReg status;
164 uint8_t reserved1;
165 uint32_t bmidtp;
167
168 void
169 select(bool select_device_1)
170 {
171 selectBit = select_device_1;
173 }
174
175 void accessCommand(Addr offset, int size, uint8_t *data, bool read);
176 void accessControl(Addr offset, int size, uint8_t *data, bool read);
177 void accessBMI(Addr offset, int size, uint8_t *data, bool read);
178
179 void setDmaComplete();
180
181 void postInterrupt();
182 void clearInterrupt();
183
184 Channel(std::string new_name, IdeController *new_ctrl,
185 bool new_primary);
186
187 void serialize(const std::string &base, std::ostream &os) const;
188 void unserialize(const std::string &base, CheckpointIn &cp);
189 };
190
191 private:
194
196
197 void dispatchAccess(PacketPtr pkt, bool read);
198
199 public:
201 IdeController(const Params &p);
202
203 virtual void postInterrupt(bool is_primary);
204 virtual void clearInterrupt(bool is_primary);
205
206 Tick writeConfig(PacketPtr pkt) override;
207 Tick readConfig(PacketPtr pkt) override;
208
209 Tick read(PacketPtr pkt) override;
210 Tick write(PacketPtr pkt) override;
211
212 void serialize(CheckpointOut &cp) const override;
213 void unserialize(CheckpointIn &cp) override;
214};
215
216} // namespace gem5
217
218#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:146
void select(bool select_device_1)
Definition ide_ctrl.hh:169
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:139
void accessBMI(Addr offset, int size, uint8_t *data, bool read)
Definition ide_ctrl.cc:230
IdeController * controller() const
Definition ide_ctrl.hh:136
IdeDisk * _selected
Currently selected disk.
Definition ide_ctrl.hh:123
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:120
struct gem5::IdeController::Channel::BMIRegs bmiRegs
Channel(std::string new_name, IdeController *new_ctrl, bool new_primary)
Definition ide_ctrl.cc:64
IdeDisk * selected() const
Definition ide_ctrl.hh:135
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
IdeController(const Params &p)
Definition ide_ctrl.cc:73
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:838
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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:154
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0