Go to the documentation of this file.
47 #include "debug/IdeCtrl.hh"
51 #include "params/IdeController.hh"
80 for (
int i = 0;
i <
params().disks.size();
i++) {
97 panic(
"IDE controllers support a maximum "
98 "of 4 devices attached!\n");
101 params().disks[
i]->setController(
this, 4 * 1024);
150 panic(
"Unable to find disk based on pointer %#x\n", disk);
169 DPRINTF(IdeCtrl,
"PCI read offset: %#x size: %d data: %#x\n",
offset, size,
187 DPRINTF(IdeCtrl,
"PCI write offset: %#x size: %d data: %#x\n",
198 int size, uint8_t *
data,
bool read)
200 const Addr SelectOffset = 6;
201 const uint8_t SelectDevBit = 0x10;
207 assert(size ==
sizeof(uint8_t));
220 if (selected == NULL) {
221 assert(size ==
sizeof(uint8_t));
236 memcpy(
data, (uint8_t *)&bmiRegs +
offset, size);
241 if (size !=
sizeof(uint8_t))
242 panic(
"Invalid BMIC write size: %x\n", size);
244 BMICommandReg oldVal = bmiRegs.command;
245 BMICommandReg newVal = *
data;
248 if (oldVal.startStop && oldVal.rw != newVal.rw)
249 oldVal.rw = newVal.rw;
251 if (oldVal.startStop != newVal.startStop) {
252 if (selected == NULL)
253 panic(
"DMA start for disk which does not exist\n");
255 if (oldVal.startStop) {
256 DPRINTF(IdeCtrl,
"Stopping DMA transfer\n");
257 bmiRegs.status.active = 0;
259 selected->abortDma();
261 DPRINTF(IdeCtrl,
"Starting DMA transfer\n");
262 bmiRegs.status.active = 1;
264 selected->startDma(
letoh(bmiRegs.bmidtp));
268 bmiRegs.command = newVal;
273 if (size !=
sizeof(uint8_t))
274 panic(
"Invalid BMIS write size: %x\n", size);
276 BMIStatusReg oldVal = bmiRegs.status;
277 BMIStatusReg newVal = *
data;
280 newVal.active = oldVal.active;
283 if ((oldVal.intStatus == 1) && (newVal.intStatus == 1)) {
284 newVal.intStatus = 0;
289 uint8_t tmp = oldVal.intStatus;
290 newVal.intStatus = tmp;
292 if ((oldVal.dmaError == 1) && (newVal.dmaError == 1)) {
295 uint8_t tmp = oldVal.dmaError;
296 newVal.dmaError = tmp;
299 bmiRegs.status = newVal;
303 if (size !=
sizeof(uint32_t))
304 panic(
"Invalid BMIDTP write size: %x\n", size);
305 bmiRegs.bmidtp =
htole(*(uint32_t *)
data & ~0x3);
308 if (size !=
sizeof(uint8_t) && size !=
sizeof(uint16_t) &&
309 size !=
sizeof(uint32_t))
310 panic(
"IDE controller write of invalid write 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",
410 uint8_t command = bmiRegs.command;
413 uint8_t
status = bmiRegs.status;
439 bmiRegs.command = command;
void makeAtomicResponse()
#define UNSERIALIZE_SCALAR(scalar)
virtual Tick writeConfig(PacketPtr pkt)
Write to the PCI config space data that is stored locally.
void accessBMI(Addr offset, int size, uint8_t *data, bool read)
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
virtual Tick readConfig(PacketPtr pkt)
Read from the PCI config space data that is stored locally.
struct IdeController::Channel::BMIRegs bmiRegs
uint64_t Tick
Tick count type.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
PCIConfig config
The current config space.
IdeDisk * selected
Currently selected disk.
Channel(std::string newName)
IdeDisk * device0
IDE disks connected to this controller For more details about device0 and device1 see: https://en....
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
#define PCI_DEVICE_SPECIFIC
void unserialize(ThreadContext &tc, CheckpointIn &cp)
bool isDiskSelected(IdeDisk *diskPtr)
See if a disk is selected based on its pointer.
void dispatchAccess(PacketPtr pkt, bool read)
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
void setDmaComplete(IdeDisk *disk)
void accessControl(Addr offset, int size, uint8_t *data, bool read)
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
void select(bool select_device_1)
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
void accessCommand(Addr offset, int size, uint8_t *data, bool read)
#define SERIALIZE_SCALAR(scalar)
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
virtual const std::string name() const
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
Registers used for bus master interface.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void readCommand(const Addr offset, int size, uint8_t *data)
EndBitUnion(BMICommandReg) class ConfigSpaceRegs ConfigSpaceRegs configSpaceRegs
Registers used in device specific PCI configuration.
T * getPtr()
get a pointer to the data ptr.
void unserialize(const std::string &base, CheckpointIn &cp)
std::ostream CheckpointOut
const Params & params() const
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
void serialize(const std::string &base, std::ostream &os) const
void writeCommand(const Addr offset, int size, const uint8_t *data)
const T * getConstPtr() const
PCI device, base implementation is only config space.
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
IdeController(const Params &p)
#define panic(...)
This implements a cprintf based panic() function.
bool getBAR(Addr addr, int &num, Addr &offs)
Which base address register (if any) maps the given address?
Generated on Tue Mar 23 2021 19:41:26 for gem5 by doxygen 1.8.17