47 #ifndef __DEV_STORAGE_IDE_DISK_HH__
48 #define __DEV_STORAGE_IDE_DISK_HH__
56 #include "params/IdeDisk.hh"
61 #define DMA_BACKOFF_PERIOD 200
63 #define MAX_DMA_SIZE 0x20000 // 128K
64 #define MAX_SINGLE_DMA_SIZE 0x10000
65 #define MAX_MULTSECT (128)
67 #define PRD_BASE_MASK 0xfffffffe
68 #define PRD_COUNT_MASK 0xfffe
69 #define PRD_EOT_MASK 0x8000
98 #define DATA_OFFSET (0)
99 #define ERROR_OFFSET (1)
100 #define FEATURES_OFFSET (1)
101 #define NSECTOR_OFFSET (2)
102 #define SECTOR_OFFSET (3)
103 #define LCYL_OFFSET (4)
104 #define HCYL_OFFSET (5)
105 #define SELECT_OFFSET (6)
106 #define DRIVE_OFFSET (6)
107 #define STATUS_OFFSET (7)
108 #define COMMAND_OFFSET (7)
110 #define CONTROL_OFFSET (2)
111 #define ALTSTAT_OFFSET (2)
113 #define SELECT_DEV_BIT 0x10
114 #define CONTROL_RST_BIT 0x04
115 #define CONTROL_IEN_BIT 0x02
116 #define STATUS_BSY_BIT 0x80
117 #define STATUS_DRDY_BIT 0x40
118 #define STATUS_DRQ_BIT 0x08
119 #define STATUS_SEEK_BIT 0x10
120 #define STATUS_DF_BIT 0x20
121 #define DRIVE_LBA_BIT 0x40
286 if (
ctrl)
panic(
"Cannot change the controller once set!\n");
297 void startDma(
const uint32_t &prdTableBase);
373 #endif // __DEV_STORAGE_IDE_DISK_HH__
bool nIENBit
Interrupt enable bit.
void reset(int id)
Reset the device state.
void writeCommand(const Addr offset, int size, const uint8_t *data)
EventWrapper< IdeDisk,&IdeDisk::dmaWriteDone > dmaWriteEvent
~IdeDisk()
Delete the data buffer.
DmaState_t dmaState
Dma state.
ChunkGenerator * dmaWriteCG
struct PrdEntry PrdEntry_t
uint32_t curPrdAddr
PRD table base address.
void regStats() override
Register Statistics.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Device model for an Intel PIIX4 IDE controller.
struct CommandReg CommandReg_t
#define MAX_SINGLE_DMA_SIZE
int devID
Device ID (master=0/slave=1)
DiskImage * image
The image that contains the data of this disk.
Simple PCI IDE controller with bus mastering capability and UDMA modeled after controller in the Inte...
bool dmaAborted
DMA Aborted.
EventWrapper< IdeDisk,&IdeDisk::dmaPrdReadDone > dmaPrdReadEvent
uint32_t drqBytesLeft
Number of bytes left in DRQ block.
void updateState(DevAction_t action)
Stats::Scalar dmaWriteBytes
Declaration of Statistics objects.
EventWrapper< IdeDisk,&IdeDisk::doDmaTransfer > dmaTransferEvent
This is a simple scalar statistic, like a counter.
uint32_t cmdBytesLeft
Number of bytes left in command data transfer.
void readCommand(const Addr offset, int size, uint8_t *data)
Stats::Scalar dmaReadBytes
This class takes an arbitrary memory region (address/length pair) and generates a series of appropria...
struct ataparams driveID
Drive identification structure for this disk.
EventWrapper< IdeDisk,&IdeDisk::doDmaWrite > dmaWriteWaitEvent
void writeControl(const Addr offset, int size, const uint8_t *data)
Basic interface for accessing a disk image.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint32_t curSector
Current sector in access.
uint8_t status
Status register.
EventWrapper< IdeDisk,&IdeDisk::doDmaRead > dmaReadWaitEvent
DevState_t devState
Device state.
enum DevAction DevAction_t
ChunkGenerator * dmaReadCG
uint32_t cmdBytes
Number of bytes in command data transfer.
PrdTableEntry curPrd
PRD entry.
CommandReg_t cmdReg
Command block registers.
bool intrPending
Interrupt pending.
std::ostream CheckpointOut
EventWrapper< IdeDisk,&IdeDisk::dmaReadDone > dmaReadEvent
bool dmaRead
Dma transaction is a read.
void startDma(const uint32_t &prdTableBase)
Addr pciToDma(Addr pciAddr)
Stats::Scalar dmaReadFullPages
IdeController * ctrl
The IDE controller for this disk.
void writeDisk(uint32_t sector, uint8_t *data)
uint8_t * dataBuffer
Data buffer for transfers.
void setController(IdeController *c)
Set the controller for this device.
void readControl(const Addr offset, int size, uint8_t *data)
void readDisk(uint32_t sector, uint8_t *data)
Stats::Scalar dmaWriteFullPages
Abstract superclass for simulation objects.
int diskDelay
The disk delay in microseconds.
Stats::Scalar dmaWriteTxs