19 , diskManipulator(config.getReactor().getDiskManipulator())
20 , devName(config.getChildData(
"name",
"openMSX hard disk"))
31bool IDEHD::isPacketDevice()
36std::string_view IDEHD::getDeviceName()
41void IDEHD::fillIdentifyBlock(AlignedBuffer& buf)
44 const uint16_t heads = 16;
45 const uint16_t sectors = 32;
46 auto cylinders = narrow<uint16_t>(totalSectors /
size_t(heads * sectors));
52 buf[47 * 2 + 1] = 0x80;
56 buf[49 * 2 + 1] = 0x0A;
62unsigned IDEHD::readBlockStart(AlignedBuffer& buf,
unsigned count)
68 *aligned_cast<SectorBuffer*>(buf));
69 ++transferSectorNumber;
71 }
catch (MSXException&) {
77void IDEHD::writeBlockComplete(AlignedBuffer& buf,
unsigned count)
80 assert((count % 512) == 0);
81 size_t num =
count / 512;
82 for (
auto i :
xrange(num)) {
84 *aligned_cast<SectorBuffer*>(buf + 512 * i));
86 }
catch (MSXException&) {
91void IDEHD::executeCommand(
byte cmd)
93 if (0x10 <= cmd && cmd < 0x20) {
112 transferSectorNumber = sectorNumber;
134template<
typename Archive>
138 ar.template serializeBase<HD>(*
this);
139 ar.template serializeBase<AbstractIDEDevice>(*
this);
140 ar.serialize(
"transferSectorNumber", transferSectorNumber);
void startWriteTransfer(unsigned count)
Indicates the start of a write data transfer.
static constexpr byte UNC
void startLongReadTransfer(unsigned count)
Indicates the start of a read data transfer which uses blocks.
virtual void executeCommand(byte cmd)
Starts execution of an IDE command.
void setSectorNumber(unsigned lba)
Writes a 28-bit LBA sector number in the registers.
void setByteCount(unsigned count)
Writes the byte count of a packet transfer in the registers.
unsigned getNumSectors() const
Gets the number of sectors indicated by the sector count register.
void abortReadTransfer(byte error)
Aborts the read transfer in progress.
void setError(byte error)
Indicates an error: sets error register, error flag, aborts transfers.
void abortWriteTransfer(byte error)
Aborts the write transfer in progress.
static constexpr byte IDNF
unsigned getSectorNumber() const
Creates an LBA sector address from the contents of the sectorNumReg, cylinderLowReg,...
MSXMotherBoard & getMotherBoard() const
void unregisterDrive(DiskContainer &drive)
void registerDrive(DiskContainer &drive, std::string_view prefix)
void serialize(Archive &ar, unsigned version)
IDEHD(const DeviceConfig &config)
std::string_view getMachineID() const
size_t getNbSectors() const
void readSector(size_t sector, SectorBuffer &buf) const
void writeSector(size_t sector, const SectorBuffer &buf)
void writeL32(void *p, uint32_t x)
void writeL16(void *p, uint16_t x)
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
This file implemented 3 utility functions:
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
TemporaryString tmpStrCat(Ts &&... ts)
constexpr auto xrange(T e)