-
Notifications
You must be signed in to change notification settings - Fork 5
/
floppyIO.h
91 lines (65 loc) · 2.27 KB
/
floppyIO.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// File: FloppyIO.h
// Author: Ioannis Charalampidis <ioannis.charalampidis AT cern DOT ch>
//
// Hypervisor-Virtual machine bi-directional communication
// through floppy disk.
//
// This class provides the hypervisor-side of the script.
// For the guest-side, check the perl scripts that
// were available with this code.
//
// Here is the layout of the floppy disk image (Example of 28k):
//
// +-----------------+------------------------------------------------+
// | 0x0000 - 0x37FF | Hypervisor -> Guest Buffer |
// | 0x3800 - 0x6FFE | Guest -> Hypervisor Buffer |
// | 0x6FFF | "Data available for guest" flag byte |
// | 0x7000 | "Data available for hypervisor" flag byte |
// +-----------------+------------------------------------------------+
//
// Created on November 24, 2011, 12:30 PM
#ifndef FLOPPYIO_H
#define FLOPPYIO_H
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
// Do not initialize (reset) floppy disk image at open.
// (Flag used at FloppyIO constructor)
#define F_NOINIT 1
// Do not create the filename (assume it exists)
// (Flag used at FloppyIO constructor)
#define F_NOCREATE 2
// Synchronize I/O [NOT YET IMPLEMENTED]
// This flag will block the script until the guest has read/written the data.
// (Flag used at FloppyIO constructor)
#define F_SYNCHRONIZED 4
// Default floppy disk size (In bytes)
//
// VirtualBox complains if bigger than 28K
// It's supposed to go till 1474560 however (!.44 Mb)
#define DEFAULT_FLOPPY_SIZE 28672
// Floppy I/O Communication class
class FloppyIO {
public:
// Construcors
FloppyIO(const char * filename);
FloppyIO(const char * filename, int flags);
virtual ~FloppyIO();
// Functions
void reset();
void send(string strData);
string receive();
// Topology info
int ofsInput; // Input buffer offset & size
int szInput;
int ofsOutput; // Output buffer offset & size
int szOutput;
int ofsCtrlByteIn; // Control byte offset for input
int ofsCtrlByteOut; // Control byte offset for output
private:
// Floppy Info
fstream * fIO;
int szFloppy;
};
#endif // FLOPPYIO_H