Go to the documentation of this file.
46 #include "debug/IdeCtrl.hh"
50 #include "params/IdeController.hh"
66 Named(new_name), ctrl(new_ctrl), primary(new_primary)
80 "IDE controllers support a maximum of 4 devices attached!");
83 for (
int i = 0;
i <
params().disks.size();
i++) {
93 channel.setDevice1(disk);
96 disk->setChannel(&channel, 4 * 1024);
134 bmiRegs.status.intStatus = 0;
135 _pendingInterrupt =
false;
136 ctrl->clearInterrupt(isPrimary());
144 if (!other.pendingInterrupt())
153 if (!other.pendingInterrupt())
168 DPRINTF(IdeCtrl,
"PCI read offset: %#x size: %d data: %#x\n",
offset, size,
186 DPRINTF(IdeCtrl,
"PCI write offset: %#x size: %d data: %#x\n",
199 const Addr SelectOffset = 6;
200 const uint8_t SelectDevBit = 0x10;
203 select(*
data & SelectDevBit);
205 if (selected() == NULL) {
206 assert(size ==
sizeof(uint8_t));
219 if (selected() == NULL) {
220 assert(size ==
sizeof(uint8_t));
235 memcpy(
data, (uint8_t *)&bmiRegs +
offset, size);
240 if (size !=
sizeof(uint8_t))
241 panic(
"Invalid BMIC write size: %x\n", size);
243 BMICommandReg oldVal = bmiRegs.command;
244 BMICommandReg newVal = *
data;
247 if (oldVal.startStop && oldVal.rw != newVal.rw)
248 oldVal.rw = newVal.rw;
250 if (oldVal.startStop != newVal.startStop) {
251 if (selected() == NULL)
252 panic(
"DMA start for disk which does not exist\n");
254 if (oldVal.startStop) {
255 DPRINTF(IdeCtrl,
"Stopping DMA transfer\n");
256 bmiRegs.status.active = 0;
258 selected()->abortDma();
260 DPRINTF(IdeCtrl,
"Starting DMA transfer\n");
261 bmiRegs.status.active = 1;
263 selected()->startDma(
letoh(bmiRegs.bmidtp));
267 bmiRegs.command = newVal;
272 if (size !=
sizeof(uint8_t))
273 panic(
"Invalid BMIS write size: %x\n", size);
275 BMIStatusReg oldVal = bmiRegs.status;
276 BMIStatusReg newVal = *
data;
279 newVal.active = oldVal.active;
282 if ((oldVal.intStatus == 1) && (newVal.intStatus == 1)) {
283 newVal.intStatus = 0;
288 uint8_t tmp = oldVal.intStatus;
289 newVal.intStatus = tmp;
291 if ((oldVal.dmaError == 1) && (newVal.dmaError == 1)) {
294 uint8_t tmp = oldVal.dmaError;
295 newVal.dmaError = tmp;
298 bmiRegs.status = newVal;
302 if (size !=
sizeof(uint32_t))
303 panic(
"Invalid BMIDTP write size: %x\n", size);
304 bmiRegs.bmidtp =
htole(*(uint32_t *)
data & ~0x3);
307 if (size !=
sizeof(uint8_t) && size !=
sizeof(uint16_t) &&
308 size !=
sizeof(uint32_t)) {
309 panic(
"IDE controller write of invalid size: %x\n", size);
311 memcpy((uint8_t *)&bmiRegs +
offset,
data, size);
324 uint8_t *dataPtr = pkt->
getPtr<uint8_t>();
329 "IDE controller access to invalid address: %#x.",
addr);
350 PciCommandRegister command =
letoh(
config.command);
351 if (!
read && !command.busMaster)
371 DPRINTF(IdeCtrl,
"%s from offset: %#x size: %#x data: %#x\n",
381 bmiRegs.command.startStop = 0;
382 bmiRegs.status.active = 0;
383 bmiRegs.status.intStatus = 1;
418 uint8_t command = bmiRegs.command;
420 paramOut(cp,
base +
".bmiRegs.reserved0", bmiRegs.reserved0);
421 uint8_t
status = bmiRegs.status;
423 paramOut(cp,
base +
".bmiRegs.reserved1", bmiRegs.reserved1);
447 bmiRegs.command = command;
448 paramIn(cp,
base +
".bmiRegs.reserved0", bmiRegs.reserved0);
452 paramIn(cp,
base +
".bmiRegs.reserved1", bmiRegs.reserved1);
453 paramIn(cp,
base +
".bmiRegs.bmidtp", bmiRegs.bmidtp);
void serialize(const std::string &base, std::ostream &os) const
void unserialize(ThreadContext &tc, CheckpointIn &cp)
PCIConfig config
The current config space.
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
#define UNSERIALIZE_SCALAR(scalar)
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
void setDevice0(IdeDisk *disk)
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void accessCommand(Addr offset, int size, uint8_t *data, bool read)
void makeAtomicResponse()
#define PCI_DEVICE_SPECIFIC
void unserialize(const std::string &base, CheckpointIn &cp)
Interface for things with names.
void accessControl(Addr offset, int size, uint8_t *data, bool read)
virtual Tick writeConfig(PacketPtr pkt)
Write to the PCI config space data that is stored locally.
Registers used for bus master interface.
virtual std::string name() const
const Params & params() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void accessBMI(Addr offset, int size, uint8_t *data, bool read)
uint64_t Tick
Tick count type.
IdeController(const Params &p)
void dispatchAccess(PacketPtr pkt, bool read)
const T * getConstPtr() const
PCI device, base implementation is only config space.
bool getBAR(Addr addr, int &num, Addr &offs)
Which base address register (if any) maps the given address?
Channel(std::string new_name, IdeController *new_ctrl, bool new_primary)
Device model for an Intel PIIX4 IDE controller.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
#define SERIALIZE_SCALAR(scalar)
struct gem5::IdeController::Channel::BMIRegs bmiRegs
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
virtual Tick readConfig(PacketPtr pkt)
Read from the PCI config space data that is stored locally.
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
virtual void clearInterrupt(bool is_primary)
virtual void postInterrupt(bool is_primary)
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
EndBitUnion(BMICommandReg) class ConfigSpaceRegs ConfigSpaceRegs configSpaceRegs
Registers used in device specific PCI configuration.
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
std::ostream CheckpointOut
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void select(bool select_device_1)
#define panic(...)
This implements a cprintf based panic() function.
T * getPtr()
get a pointer to the data ptr.
Generated on Sun Jul 30 2023 01:56:56 for gem5 by doxygen 1.8.17