-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.hpp
52 lines (42 loc) · 916 Bytes
/
storage.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef STORAGE_HPP
#define STORAGE_HPP
#include <limits>
#include <string>
#include <cstdlib>
#include <cmath>
#include "peripheral.hpp"
#include "bus.hpp"
using UData = Port;
const UData HEX_SIZE = std::ceil<UData>(std::log10<UData>(std::numeric_limits<UData>::max()));
const std::string FSCANF_ARG = "%0" + std::to_string(HEX_SIZE) + "x";
namespace StorageCommand {
enum STORAGE_COMMANDS {
read = 1,
write = 2,
info = 3
};
}
namespace StorageErr {
enum STORAGE_ACCESS_ERRORS {
index_out_of_bounds = -1,
seek_err = -2,
read_err = -3,
write_err = -4
};
}
class Storage : public Peripheral {
public:
Storage(const char *storage_path);
~Storage();
Data get() override;
void send(Data d1 = 0, Data d2 = 0, Data d3 = 0) override;
protected:
Data get_storage_size();
Data storage_size;
private:
Data command;
Data index;
Data write_data;
std::FILE* file;
};
#endif /* STORAGE_HPP */