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