mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-13 00:25:26 +00:00
Adds a temporary version of block access writing.
Whatever I'm doing, it's still not correct. The Macintosh ostensibly appears to 0-fill the direct-access device, then reads a sector back and hangs.
This commit is contained in:
@@ -27,6 +27,9 @@ size_t HFV::get_number_of_blocks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> HFV::get_block(size_t address) {
|
std::vector<uint8_t> HFV::get_block(size_t address) {
|
||||||
|
const auto written = writes_.find(address);
|
||||||
|
if(written != writes_.end()) return written->second;
|
||||||
|
|
||||||
const auto source_address = mapper_.to_source_address(address);
|
const auto source_address = mapper_.to_source_address(address);
|
||||||
if(source_address >= 0 && size_t(source_address)*get_block_size() < size_t(file_.stats().st_size)) {
|
if(source_address >= 0 && size_t(source_address)*get_block_size() < size_t(file_.stats().st_size)) {
|
||||||
const long file_offset = long(get_block_size()) * long(source_address);
|
const long file_offset = long(get_block_size()) * long(source_address);
|
||||||
@@ -38,12 +41,19 @@ std::vector<uint8_t> HFV::get_block(size_t address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HFV::set_block(size_t address, const std::vector<uint8_t> &contents) {
|
void HFV::set_block(size_t address, const std::vector<uint8_t> &contents) {
|
||||||
const auto source_address = mapper_.to_source_address(address);
|
writes_[address] = contents;
|
||||||
if(source_address >= 0 && size_t(source_address)*get_block_size() < size_t(file_.stats().st_size)) {
|
|
||||||
const long file_offset = long(get_block_size()) * long(source_address);
|
printf("[%zu]: ", address);
|
||||||
file_.seek(file_offset, SEEK_SET);
|
for(uint8_t v: contents) {
|
||||||
file_.write(contents);
|
printf("%02x ", v);
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
|
// const auto source_address = mapper_.to_source_address(address);
|
||||||
|
// if(source_address >= 0 && size_t(source_address)*get_block_size() < size_t(file_.stats().st_size)) {
|
||||||
|
// const long file_offset = long(get_block_size()) * long(source_address);
|
||||||
|
// file_.seek(file_offset, SEEK_SET);
|
||||||
|
// file_.write(contents);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void HFV::set_drive_type(Encodings::Macintosh::DriveType drive_type) {
|
void HFV::set_drive_type(Encodings::Macintosh::DriveType drive_type) {
|
||||||
|
@@ -13,6 +13,9 @@
|
|||||||
#include "../../FileHolder.hpp"
|
#include "../../FileHolder.hpp"
|
||||||
#include "../Encodings/MacintoshVolume.hpp"
|
#include "../Encodings/MacintoshVolume.hpp"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace MassStorage {
|
namespace MassStorage {
|
||||||
|
|
||||||
@@ -41,6 +44,8 @@ class HFV: public MassStorageDevice, public Encodings::Macintosh::Volume {
|
|||||||
|
|
||||||
/* Encodings::Macintosh::Volume overrides. */
|
/* Encodings::Macintosh::Volume overrides. */
|
||||||
void set_drive_type(Encodings::Macintosh::DriveType) final;
|
void set_drive_type(Encodings::Macintosh::DriveType) final;
|
||||||
|
|
||||||
|
std::map<size_t, std::vector<uint8_t>> writes_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -28,8 +28,8 @@ bool DirectAccessDevice::read(const Target::CommandState &state, Target::Respond
|
|||||||
bool DirectAccessDevice::write(const Target::CommandState &state, Target::Responder &responder) {
|
bool DirectAccessDevice::write(const Target::CommandState &state, Target::Responder &responder) {
|
||||||
if(!device_) return false;
|
if(!device_) return false;
|
||||||
|
|
||||||
const auto target_address = state.address();
|
responder.receive_data(device_->get_block_size(), [this] (const Target::CommandState &state, Target::Responder &responder) {
|
||||||
responder.receive_data(device_->get_block_size(), [target_address] (const Target::CommandState &state, Target::Responder &responder) {
|
this->device_->set_block(state.address(), state.received_data());
|
||||||
responder.terminate_command(Target::Responder::Status::Good);
|
responder.terminate_command(Target::Responder::Status::Good);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ class CommandState {
|
|||||||
};
|
};
|
||||||
ReadBuffer read_buffer_specs() const;
|
ReadBuffer read_buffer_specs() const;
|
||||||
|
|
||||||
const std::vector<uint8_t> &received_data() {
|
const std::vector<uint8_t> &received_data() const {
|
||||||
return received_;
|
return received_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,6 +21,9 @@ template <typename Executor> void Target<Executor>::scsi_bus_did_change(Bus *, B
|
|||||||
time."
|
time."
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Wait for deskew, at the very least.
|
||||||
|
if(time_since_change < SCSI::DeskewDelay) return;
|
||||||
|
|
||||||
// A reset always takes precedence over anything else ongoing.
|
// A reset always takes precedence over anything else ongoing.
|
||||||
if(new_state & Line::Reset) {
|
if(new_state & Line::Reset) {
|
||||||
phase_ = Phase::AwaitingSelection;
|
phase_ = Phase::AwaitingSelection;
|
||||||
|
Reference in New Issue
Block a user