mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-25 11:17:26 +00:00
Adds support for Macintosh SCSI device images.
This is now in addition to the single-partition images previously supported.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// DSK.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 01/05/2021.
|
||||
// Copyright © 2021 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "DSK.hpp"
|
||||
|
||||
using namespace Storage::MassStorage;
|
||||
|
||||
DSK::DSK(const std::string &file_name) : RawSectorDump(file_name) {
|
||||
// Minimum validation: check the first sector for a device signature,
|
||||
// with 512-byte blocks.
|
||||
const auto sector = get_block(0);
|
||||
if(sector.size() != 512) {
|
||||
throw std::exception();
|
||||
}
|
||||
if(sector[0] != 0x45 || sector[1] != 0x52 || sector[2] != 0x02 || sector[3] != 0x00) {
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// DSK.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 01/05/2021.
|
||||
// Copyright © 2021 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef MassStorage_DSK_hpp
|
||||
#define MassStorage_DSK_hpp
|
||||
|
||||
#include "RawSectorDump.hpp"
|
||||
|
||||
namespace Storage {
|
||||
namespace MassStorage {
|
||||
|
||||
/*!
|
||||
Provides a @c MassStorageDevice containing a Macintosh DSK image, which is just a
|
||||
sector dump of an entire HFS drive. It will be validated for an Apple-style partition map and communicate
|
||||
in 512-byte blocks.
|
||||
*/
|
||||
class DSK: public RawSectorDump<512> {
|
||||
public:
|
||||
DSK(const std::string &file_name);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MassStorage_DSK_hpp */
|
||||
@@ -15,7 +15,10 @@ HFV::HFV(const std::string &file_name) : file_(file_name) {
|
||||
const auto file_size = file_.stats().st_size;
|
||||
if(file_size & 511 || file_size <= 800*1024) throw std::exception();
|
||||
|
||||
// TODO: check filing system for MFS, HFS or HFS+.
|
||||
// Is this an HFS volume?
|
||||
// TODO: check filing system for MFS or HFS+.
|
||||
const auto prefix = file_.read(2);
|
||||
if(prefix[0] != 'L' || prefix[1] != 'K') throw std::exception();
|
||||
}
|
||||
|
||||
size_t HFV::get_block_size() {
|
||||
|
||||
@@ -19,7 +19,7 @@ bool DirectAccessDevice::read(const Target::CommandState &state, Target::Respond
|
||||
if(!device_) return false;
|
||||
|
||||
const auto specs = state.read_write_specs();
|
||||
LOG("Read: " << specs.number_of_blocks << " from " << specs.address);
|
||||
LOG("Read: " << std::dec << specs.number_of_blocks << " from " << specs.address);
|
||||
|
||||
std::vector<uint8_t> output = device_->get_block(specs.address);
|
||||
for(uint32_t offset = 1; offset < specs.number_of_blocks; ++offset) {
|
||||
|
||||
Reference in New Issue
Block a user