mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-22 08:16:42 +00:00
Add an 8272 results phase.
This commit is contained in:
@@ -15,33 +15,33 @@
|
||||
|
||||
namespace Intel::i8272 {
|
||||
|
||||
enum class Command {
|
||||
ReadData = 0x06,
|
||||
ReadDeletedData = 0x0c,
|
||||
|
||||
WriteData = 0x05,
|
||||
WriteDeletedData = 0x09,
|
||||
|
||||
ReadTrack = 0x02,
|
||||
ReadID = 0x0a,
|
||||
FormatTrack = 0x0d,
|
||||
|
||||
ScanLow = 0x11,
|
||||
ScanLowOrEqual = 0x19,
|
||||
ScanHighOrEqual = 0x1d,
|
||||
|
||||
Recalibrate = 0x07,
|
||||
Seek = 0x0f,
|
||||
|
||||
SenseInterruptStatus = 0x08,
|
||||
Specify = 0x03,
|
||||
SenseDriveStatus = 0x04,
|
||||
|
||||
Invalid = 0x00,
|
||||
};
|
||||
|
||||
class CommandDecoder {
|
||||
public:
|
||||
enum class Command {
|
||||
ReadData = 0x06,
|
||||
ReadDeletedData = 0x0c,
|
||||
|
||||
WriteData = 0x05,
|
||||
WriteDeletedData = 0x09,
|
||||
|
||||
ReadTrack = 0x02,
|
||||
ReadID = 0x0a,
|
||||
FormatTrack = 0x0d,
|
||||
|
||||
ScanLow = 0x11,
|
||||
ScanLowOrEqual = 0x19,
|
||||
ScanHighOrEqual = 0x1d,
|
||||
|
||||
Recalibrate = 0x07,
|
||||
Seek = 0x0f,
|
||||
|
||||
SenseInterruptStatus = 0x08,
|
||||
Specify = 0x03,
|
||||
SenseDriveStatus = 0x04,
|
||||
|
||||
Invalid = 0x00,
|
||||
};
|
||||
|
||||
/// Add a byte to the current command.
|
||||
void push_back(uint8_t byte) {
|
||||
command_.push_back(byte);
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Results.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 27/11/2023.
|
||||
// Copyright © 2023 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef Results_hpp
|
||||
#define Results_hpp
|
||||
|
||||
#include "CommandDecoder.hpp"
|
||||
#include "Status.hpp"
|
||||
|
||||
namespace Intel::i8272 {
|
||||
|
||||
class Results {
|
||||
public:
|
||||
/// Serialises the response to Command::Invalid and Command::SenseInterruptStatus when no interrupt source was found.
|
||||
void serialise_none() {
|
||||
result_ = { 0x80 };
|
||||
}
|
||||
|
||||
/// Serialises the response to Command::SenseInterruptStatus for a found drive.
|
||||
void serialise(const Status &status, uint8_t cylinder) {
|
||||
result_ = { cylinder, status[0] };
|
||||
}
|
||||
|
||||
/// Serialises the seven-byte response to Command::SenseDriveStatus.
|
||||
void serialise(uint8_t flags, uint8_t drive_side) {
|
||||
result_ = { uint8_t(flags | drive_side) };
|
||||
}
|
||||
|
||||
/// Serialises the response to:
|
||||
///
|
||||
/// * Command::ReadData;
|
||||
/// * Command::ReadDeletedData;
|
||||
/// * Command::WriteData;
|
||||
/// * Command::WriteDeletedData;
|
||||
/// * Command::ReadID;
|
||||
/// * Command::ReadTrack;
|
||||
/// * Command::FormatTrack;
|
||||
/// * Command::ScanLow; and
|
||||
/// * Command::ScanHighOrEqual.
|
||||
void serialise(const Status &status, uint8_t cylinder, uint8_t head, uint8_t sector, uint8_t size) {
|
||||
result_ = { size, sector, head, cylinder, status[2], status[1], status[0] };
|
||||
}
|
||||
|
||||
/// @returns @c true if all result bytes are exhausted; @c false otherwise.
|
||||
bool empty() const { return result_.empty(); }
|
||||
|
||||
/// @returns The next byte of the result.
|
||||
uint8_t next() {
|
||||
const uint8_t next = result_.back();
|
||||
result_.pop_back();
|
||||
return next;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> result_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* Results_hpp */
|
||||
@@ -60,9 +60,8 @@ enum class Status3: uint8_t {
|
||||
Fault = 0x80,
|
||||
WriteProtected = 0x40,
|
||||
Ready = 0x20,
|
||||
Track9 = 0x10,
|
||||
Track0 = 0x10,
|
||||
TwoSided = 0x08,
|
||||
|
||||
HeadAddress = 0x04,
|
||||
UnitSelect = 0x03,
|
||||
};
|
||||
|
||||
@@ -268,7 +268,6 @@ void i8272::posit_event(int event_type) {
|
||||
}
|
||||
|
||||
// Jump to the proper place.
|
||||
using Command = CommandDecoder::Command;
|
||||
switch(command_.command()) {
|
||||
case Command::ReadData:
|
||||
case Command::ReadDeletedData:
|
||||
|
||||
Reference in New Issue
Block a user