summaryrefslogtreecommitdiff
path: root/Source/Kernel/Devices/Floppy/FloppyDrive.class.h
blob: 75926ea6e54581bd0900d5fb0f2be27cec345fe7 (plain) (blame)
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
#ifndef DEF_FLOPPYDRIVE_CLASS_H
#define DEF_FLOPPYDRIVE_CLASS_H

#include <Devices/BlockDevice.proto.h>

#include "FloppyController.class.h"

class FloppyDrive : public BlockDevice {
	friend class FloppyController;
	friend u32int floppyMotorTimer(void*);
	private:
	FloppyDrive(FloppyController *fdc, u8int number, u8int type);	//Private constructor, called by FloppyController()

	u8int m_motorState, m_motorTimeout, m_driveNumber, m_driveType;
	u32int m_cylinders, m_sectors;
	FloppyController *m_fdc;

	u8int m_buffer[FLOPPY_DMALEN];
	u32int m_buffCyl, m_buffTime;	//Used for keeping track of what is in buffer, this is a sort of cache system

	bool setup();
	bool calibrate();
	bool setMotorState(bool on);
	bool killMotor();
	bool seek(u32int cyli, s32int head);
	bool doTrack(u32int cyl, u8int dir);

	public:
	String getClass();
	String getName();

	bool readOnly();
	u64int blocks();
	bool readBlocks(u64int startblock, u32int count, u8int *data);
	bool writeBlocks(u64int startblock, u32int count, u8int* data);
	u32int blockSize();	//Always 512

	u64int chs2lba(u32int cylinder, u32int head, u32int sector);
};

#endif