2019-08-22 03:22:58 +00:00
|
|
|
//
|
|
|
|
// MassStorageDevice.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 21/08/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2019-08-22 03:22:58 +00:00
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::MassStorage {
|
2019-08-22 03:22:58 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
A mass storage device is usually:
|
|
|
|
|
|
|
|
* large;
|
|
|
|
* fixed; and
|
|
|
|
* part of a class with a very wide array of potential speeds and timings.
|
|
|
|
|
|
|
|
Within this emulator, mass storage devices don't attempt to emulate
|
|
|
|
any specific medium, they just offer block-based access to a
|
|
|
|
linearly-addressed store.
|
|
|
|
*/
|
|
|
|
class MassStorageDevice {
|
|
|
|
public:
|
2024-02-17 02:47:23 +00:00
|
|
|
virtual ~MassStorageDevice() = default;
|
2019-08-22 03:22:58 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns The size of each individual block.
|
|
|
|
*/
|
|
|
|
virtual size_t get_block_size() = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Block addresses run from 0 to n. The total number of blocks, n,
|
|
|
|
therefore provides the range of valid addresses.
|
|
|
|
|
|
|
|
@returns The total number of blocks on the device.
|
|
|
|
*/
|
|
|
|
virtual size_t get_number_of_blocks() = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@returns The current contents of the block at @c address.
|
|
|
|
*/
|
|
|
|
virtual std::vector<uint8_t> get_block(size_t address) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets new contents for the block at @c address.
|
|
|
|
*/
|
2020-05-30 04:37:06 +00:00
|
|
|
virtual void set_block([[maybe_unused]] size_t address, const std::vector<uint8_t> &) {}
|
2019-08-22 03:22:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|