1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Added storage for the extended four status registers, and made an attempt at implementing the two most trivial result-phase commands. Am slightly paused momentarily trying to figure out whether seek activity is orthogonal to read/write activity.

This commit is contained in:
Thomas Harte 2017-08-06 12:55:57 -04:00
parent 89f6de1383
commit c12425e141
2 changed files with 51 additions and 27 deletions

View File

@ -13,12 +13,18 @@
using namespace Intel; using namespace Intel;
namespace { namespace {
const uint8_t StatusRQM = 0x80; // Set indicates: ready to send or receive from processor. const uint8_t StatusRQM = 0x80; // Set: ready to send or receive from processor.
const uint8_t StatusDIO = 0x40; // Set: data is expected to be taken from the 8272 by the processor.
const uint8_t StatusNDM = 0x20; // Set: the execution phase of a data transfer command is ongoing and DMA mode is disabled.
const uint8_t StatusD3B = 0x08; // Set: drive 3 is seeking.
const uint8_t StatusD2B = 0x04; // Set: drive 2 is seeking.
const uint8_t StatusD1B = 0x02; // Set: drive 1 is seeking.
const uint8_t StatusD0B = 0x01; // Set: drive 0 is seeking.
} }
i8272::i8272(Cycles clock_rate, int clock_rate_multiplier, int revolutions_per_minute) : i8272::i8272(Cycles clock_rate, int clock_rate_multiplier, int revolutions_per_minute) :
Storage::Disk::MFMController(clock_rate, clock_rate_multiplier, revolutions_per_minute), Storage::Disk::MFMController(clock_rate, clock_rate_multiplier, revolutions_per_minute),
status_(StatusRQM), main_status_(StatusRQM),
interesting_event_mask_((int)Event8272::CommandByte), interesting_event_mask_((int)Event8272::CommandByte),
resume_point_(0), resume_point_(0),
delay_time_(0) { delay_time_(0) {
@ -42,7 +48,7 @@ void i8272::set_register(int address, uint8_t value) {
if(!address) return; if(!address) return;
// if not ready for commands, do nothing // if not ready for commands, do nothing
if(!(status_ & StatusRQM)) return; if(!(main_status_ & StatusRQM)) return;
// accumulate latest byte in the command byte sequence // accumulate latest byte in the command byte sequence
command_.push_back(value); command_.push_back(value);
@ -52,10 +58,14 @@ void i8272::set_register(int address, uint8_t value) {
uint8_t i8272::get_register(int address) { uint8_t i8272::get_register(int address) {
if(address) { if(address) {
printf("8272 get data\n"); printf("8272 get data\n");
return 0xff; if(result_.empty()) return 0xff;
uint8_t result = result_.back();
result_.pop_back();
if(result_.empty()) posit_event((int)Event8272::ResultEmpty);
return result;
} else { } else {
printf("8272 get status\n"); printf("8272 get main status\n");
return status_; return main_status_;
} }
} }
@ -75,9 +85,9 @@ void i8272::posit_event(int type) {
command_.clear(); command_.clear();
wait_for_complete_command_sequence: wait_for_complete_command_sequence:
status_ |= StatusRQM; main_status_ |= StatusRQM;
WAIT_FOR_EVENT(Event8272::CommandByte) WAIT_FOR_EVENT(Event8272::CommandByte)
status_ &= ~StatusRQM; main_status_ &= ~StatusRQM;
switch(command_[0] & 0x1f) { switch(command_[0] & 0x1f) {
case 0x06: // read data case 0x06: // read data
@ -144,55 +154,57 @@ void i8272::posit_event(int type) {
} }
read_data: read_data:
printf("Read data unimplemented!!"); printf("Read data unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
read_deleted_data: read_deleted_data:
printf("Read deleted data unimplemented!!"); printf("Read deleted data unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
write_data: write_data:
printf("Write data unimplemented!!"); printf("Write data unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
write_deleted_data: write_deleted_data:
printf("Write deleted data unimplemented!!"); printf("Write deleted data unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
read_track: read_track:
printf("Read track unimplemented!!"); printf("Read track unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
read_id: read_id:
printf("Read ID unimplemented!!"); printf("Read ID unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
format_track: format_track:
printf("Fromat track unimplemented!!"); printf("Fromat track unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
scan_low: scan_low:
printf("Scan low unimplemented!!"); printf("Scan low unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
scan_low_or_equal: scan_low_or_equal:
printf("Scan low or equal unimplemented!!"); printf("Scan low or equal unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
scan_high_or_equal: scan_high_or_equal:
printf("Scan high or equal unimplemented!!"); printf("Scan high or equal unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
recalibrate: recalibrate:
printf("Recalibrate unimplemented!!"); printf("Recalibrate unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
sense_interrupt_status: sense_interrupt_status:
printf("Sense interrupt status unimplemented!!"); printf("Sense interrupt status\n");
goto wait_for_command; result_.push_back(head_position_);
result_.push_back(status_[0]);
goto post_result;
specify: specify:
printf("Specify"); printf("Specify\n");
step_rate_time_ = command_[1] &0xf0; // i.e. 16 to 240m step_rate_time_ = command_[1] &0xf0; // i.e. 16 to 240m
head_unload_time_ = command_[1] & 0x0f; // i.e. 1 to 16ms head_unload_time_ = command_[1] & 0x0f; // i.e. 1 to 16ms
head_load_time_ = command_[2] & ~1; // i.e. 2 to 254 ms in increments of 2ms head_load_time_ = command_[2] & ~1; // i.e. 2 to 254 ms in increments of 2ms
@ -200,16 +212,23 @@ void i8272::posit_event(int type) {
goto wait_for_command; goto wait_for_command;
sense_drive_status: sense_drive_status:
printf("Sense drive status unimplemented!!"); printf("Sense drive status\n");
goto wait_for_command; result_.push_back(status_[3]);
goto post_result;
seek: seek:
printf("Seek unimplemented!!"); printf("Seek unimplemented!!\n");
goto wait_for_command; goto wait_for_command;
invalid: invalid:
// A no-op, causing the FDC to go back into standby mode. // A no-op, causing the FDC to go back into standby mode.
goto wait_for_command; goto wait_for_command;
post_result:
main_status_ |= StatusRQM | StatusDIO;
WAIT_FOR_EVENT(Event8272::ResultEmpty);
main_status_ &= ~StatusDIO;
goto wait_for_command;
END_SECTION() END_SECTION()
} }

View File

@ -27,13 +27,16 @@ class i8272: public Storage::Disk::MFMController {
private: private:
void posit_event(int type); void posit_event(int type);
uint8_t status_; uint8_t main_status_;
uint8_t status_[4];
std::vector<uint8_t> command_; std::vector<uint8_t> command_;
std::vector<uint8_t> result_;
enum class Event8272: int { enum class Event8272: int {
CommandByte = (1 << 3), CommandByte = (1 << 3),
Timer = (1 << 4), Timer = (1 << 4),
ResultEmpty = (1 << 5),
}; };
int interesting_event_mask_; int interesting_event_mask_;
@ -44,6 +47,8 @@ class i8272: public Storage::Disk::MFMController {
int head_unload_time_; int head_unload_time_;
int head_load_time_; int head_load_time_;
bool dma_mode_; bool dma_mode_;
uint8_t head_position_;
}; };
} }