-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRAMDisk.h
More file actions
49 lines (40 loc) · 1.04 KB
/
RAMDisk.h
File metadata and controls
49 lines (40 loc) · 1.04 KB
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
/** @file RAMDisk.h
*
* RAM Disk structure derived from Disk
*
* @author Copyright Aniesh Chawla, Sept 2006
**/
#ifndef RAMDISK_H
#define RAMDISK_H
#include "includes.h"
#include "Disk.h"
/// A RAMDisk has fixed blocks of 512 bytes
#define RAM_BLOCK_SIZE (512)
#if RAM_BLOCK_SIZE > MAX_BLOCK_SIZE
# error "RAM block size too large"
#endif
#if RAM_BLOCK_SIZE % MIN_BLOCK_SIZE
# error "RAM block size must be multiple of MIN_BLOCK_SIZE"
#endif
typedef char RAMDiskBlock[RAM_BLOCK_SIZE];
/** The RAMDisk class is derived from Disk. It implements a block device in
* memory.
*/
class RAMDisk : public Disk
{
private:
/// The number of blocks.
int size;
/// The RAMDisk data content.
RAMDiskBlock *data;
public:
RAMDisk();
virtual ~RAMDisk();
virtual int num_blocks() const;
virtual int block_size() const;
virtual int format(int num_blocks);
virtual int read(int block_num, char *buf) const;
virtual int write(int block_num, const char *buf);
/* RAMDisk& operator=(RAMDisk&);*/
};
#endif