2017-08-05 23:45:52 +00:00
|
|
|
//
|
|
|
|
// i8272.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 05/08/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef i8272_hpp
|
|
|
|
#define i8272_hpp
|
|
|
|
|
2017-08-06 13:45:16 +00:00
|
|
|
#include "../../Storage/Disk/MFMDiskController.hpp"
|
2017-08-06 19:22:07 +00:00
|
|
|
#include "../../Storage/Disk/Drive.hpp"
|
2017-08-06 13:45:16 +00:00
|
|
|
|
2017-08-05 23:45:52 +00:00
|
|
|
#include <cstdint>
|
2017-08-06 02:26:59 +00:00
|
|
|
#include <vector>
|
2017-08-05 23:45:52 +00:00
|
|
|
|
|
|
|
namespace Intel {
|
|
|
|
|
2017-08-06 13:45:16 +00:00
|
|
|
class i8272: public Storage::Disk::MFMController {
|
2017-08-05 23:45:52 +00:00
|
|
|
public:
|
2017-08-06 13:45:16 +00:00
|
|
|
i8272(Cycles clock_rate, int clock_rate_multiplier, int revolutions_per_minute);
|
|
|
|
|
|
|
|
void run_for(Cycles);
|
|
|
|
|
2017-08-05 23:45:52 +00:00
|
|
|
void set_register(int address, uint8_t value);
|
|
|
|
uint8_t get_register(int address);
|
2017-08-06 02:26:59 +00:00
|
|
|
|
2017-08-06 17:24:14 +00:00
|
|
|
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive);
|
|
|
|
|
2017-08-06 02:26:59 +00:00
|
|
|
private:
|
2017-08-06 16:36:18 +00:00
|
|
|
void posit_event(int type);
|
2017-08-06 16:55:57 +00:00
|
|
|
uint8_t main_status_;
|
|
|
|
uint8_t status_[4];
|
|
|
|
|
2017-08-06 02:26:59 +00:00
|
|
|
std::vector<uint8_t> command_;
|
2017-08-06 16:55:57 +00:00
|
|
|
std::vector<uint8_t> result_;
|
2017-08-06 16:36:18 +00:00
|
|
|
|
|
|
|
enum class Event8272: int {
|
|
|
|
CommandByte = (1 << 3),
|
|
|
|
Timer = (1 << 4),
|
2017-08-06 16:55:57 +00:00
|
|
|
ResultEmpty = (1 << 5),
|
2017-08-06 16:36:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int interesting_event_mask_;
|
|
|
|
int resume_point_;
|
|
|
|
int delay_time_;
|
|
|
|
|
|
|
|
int step_rate_time_;
|
|
|
|
int head_unload_time_;
|
|
|
|
int head_load_time_;
|
|
|
|
bool dma_mode_;
|
2017-08-06 16:55:57 +00:00
|
|
|
|
2017-08-06 19:22:07 +00:00
|
|
|
struct Drive {
|
|
|
|
uint8_t head_position;
|
|
|
|
|
|
|
|
enum Phase {
|
|
|
|
NotSeeking,
|
|
|
|
Seeking,
|
|
|
|
CompletedSeeking
|
|
|
|
} phase;
|
|
|
|
int step_rate_counter;
|
|
|
|
int permitted_steps;
|
|
|
|
int target_head_position; // either an actual number, or -1 to indicate to step until track zero
|
|
|
|
|
2017-08-06 23:25:44 +00:00
|
|
|
std::shared_ptr<Storage::Disk::Drive> drive;
|
2017-08-06 19:22:07 +00:00
|
|
|
|
2017-08-06 23:25:44 +00:00
|
|
|
Drive() : head_position(0), phase(NotSeeking), drive(new Storage::Disk::Drive) {};
|
2017-08-06 19:22:07 +00:00
|
|
|
} drives_[4];
|
2017-08-06 22:06:20 +00:00
|
|
|
|
|
|
|
uint8_t header_[6];
|
|
|
|
int distance_into_header_;
|
2017-08-06 23:25:44 +00:00
|
|
|
int index_hole_limit_;
|
2017-08-05 23:45:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* i8272_hpp */
|