xref: /haiku/src/system/kernel/device_manager/BaseDevice.h (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
1 /*
2  * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef BASE_DEVICE_H
6 #define BASE_DEVICE_H
7 
8 
9 #include <device_manager.h>
10 
11 
12 class BaseDevice {
13 public:
14 							BaseDevice();
15 	virtual					~BaseDevice();
16 
17 			void			SetID(ino_t id)	{ fID = id; }
18 			ino_t			ID() const		{ return fID; }
19 
20 	virtual	status_t		InitDevice();
21 	virtual	void			UninitDevice();
22 
23 	virtual void			Removed();
24 
25 	virtual	bool			HasSelect() const;
26 	virtual	bool			HasDeselect() const;
27 	virtual	bool			HasRead() const;
28 	virtual	bool			HasWrite() const;
29 	virtual	bool			HasIO() const;
30 
31 	virtual	status_t		Open(const char* path, int openMode,
32 								void** _cookie) = 0;
33 	virtual	status_t		Read(void* cookie, off_t pos, void* buffer,
34 								size_t* _length);
35 	virtual	status_t		Write(void* cookie, off_t pos, const void* buffer,
36 								size_t* _length);
37 	virtual	status_t		IO(void* cookie, io_request* request);
38 	virtual	status_t		Control(void* cookie, int32 op, void* buffer,
39 								size_t length);
40 	virtual	status_t		Select(void* cookie, uint8 event, selectsync* sync);
41 	virtual	status_t		Deselect(void* cookie, uint8 event,
42 								selectsync* sync);
43 
44 	virtual	status_t		Close(void* cookie) = 0;
45 	virtual	status_t		Free(void* cookie) = 0;
46 
47 protected:
48 	ino_t					fID;
49 };
50 
51 
52 #endif	// BASE_DEVICE_H
53